Skip to content

Commit c758b72

Browse files
authored
Merge pull request #111 from ds1sqe/rust-core
feat: add Rust core crate with schema parser, query compiler, and proxy server
2 parents 22e3a91 + ce00cb8 commit c758b72

178 files changed

Lines changed: 38029 additions & 423 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/hooks/check-preexisting.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Stop hook: remind Claude that "it was already broken" is not an excuse
3+
4+
input=$(cat)
5+
transcript_path=$(echo "$input" | jq -r '.transcript_path // empty')
6+
7+
if [[ -z "$transcript_path" || ! -f "$transcript_path" ]]; then
8+
echo '{"decision": "approve"}'
9+
exit 0
10+
fi
11+
12+
# Get all assistant text from the current turn (after the last user message)
13+
current_turn_text=$(
14+
jq -s '
15+
[to_entries[] | {idx: .key, type: .value.type, texts: [.value.message.content[]? | select(.type == "text") | .text]}] |
16+
([.[] | select(.type == "user") | .idx] | max // -1) as $last_user |
17+
[.[] | select(.type == "assistant" and .idx > $last_user) | .texts[]] |
18+
join("\n")
19+
' "$transcript_path" 2>/dev/null
20+
)
21+
22+
# Check for excuse patterns
23+
if echo "$current_turn_text" | grep -qiE 'pre-existing|preexisting|already existed|existed before|was already broken|already failing'; then
24+
echo '{"decision": "block", "reason": "🚨 You mentioned something being pre-existing. This is NOT an excuse. Fix ALL failures regardless of when they were introduced."}'
25+
else
26+
echo '{"decision": "approve"}'
27+
fi

.github/workflows/ci.yml

Lines changed: 160 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,139 @@ on:
77
branches: [master, develop]
88

99
jobs:
10+
# Rust crate: compile, test, lint (parallel with Python jobs)
11+
rust-check:
12+
name: Rust ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
26+
- name: Install Rust toolchain
27+
uses: dtolnay/rust-toolchain@stable
28+
29+
- name: Cache cargo registry and build
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
~/.cargo/registry
34+
~/.cargo/git
35+
type-bridge-core/target
36+
key: ${{ runner.os }}-cargo-${{ hashFiles('type-bridge-core/Cargo.lock') }}
37+
restore-keys: |
38+
${{ runner.os }}-cargo-
39+
40+
- name: cargo check
41+
working-directory: type-bridge-core
42+
run: cargo check --all-targets
43+
44+
- name: cargo test
45+
working-directory: type-bridge-core
46+
run: cargo test --all-targets
47+
48+
- name: cargo clippy
49+
working-directory: type-bridge-core
50+
run: cargo clippy --all-targets -- -D warnings
51+
52+
# Rust code coverage (informational, does not block CI)
53+
rust-coverage:
54+
name: Rust Coverage
55+
runs-on: ubuntu-latest
56+
continue-on-error: true
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Install Rust nightly
62+
uses: dtolnay/rust-toolchain@nightly
63+
with:
64+
components: llvm-tools-preview
65+
66+
- name: Install cargo-llvm-cov
67+
uses: taiki-e/install-action@cargo-llvm-cov
68+
69+
- name: Cache cargo registry and build
70+
uses: actions/cache@v4
71+
with:
72+
path: |
73+
~/.cargo/registry
74+
~/.cargo/git
75+
type-bridge-core/target
76+
key: ${{ runner.os }}-cargo-nightly-${{ hashFiles('type-bridge-core/Cargo.lock') }}
77+
restore-keys: |
78+
${{ runner.os }}-cargo-nightly-
79+
80+
- name: Generate LCOV report
81+
run: ./scripts/coverage.sh branch --lcov
82+
83+
- name: Upload Rust coverage to Codecov
84+
uses: codecov/codecov-action@v5
85+
with:
86+
token: ${{ secrets.CODECOV_TOKEN }}
87+
files: type-bridge-core/target/llvm-cov/lcov.branch.info
88+
flags: rust
89+
fail_ci_if_error: false
90+
91+
# Build maturin wheels for all platforms (parallel with other jobs)
92+
build-wheels:
93+
name: Build wheel (${{ matrix.target }})
94+
runs-on: ${{ matrix.runner }}
95+
strategy:
96+
matrix:
97+
include:
98+
- target: x86_64-unknown-linux-gnu
99+
runner: ubuntu-latest
100+
artifact: wheels-linux-x86_64
101+
- target: aarch64-unknown-linux-gnu
102+
runner: ubuntu-latest
103+
artifact: wheels-linux-aarch64
104+
- target: x86_64-apple-darwin
105+
runner: macos-latest
106+
artifact: wheels-macos-x86_64
107+
- target: aarch64-apple-darwin
108+
runner: macos-latest
109+
artifact: wheels-macos-aarch64
110+
- target: x86_64-pc-windows-msvc
111+
runner: windows-latest
112+
artifact: wheels-windows-x86_64
113+
steps:
114+
- name: Checkout code
115+
uses: actions/checkout@v4
116+
117+
- name: Set up QEMU (Linux aarch64 cross-compilation)
118+
if: matrix.target == 'aarch64-unknown-linux-gnu'
119+
uses: docker/setup-qemu-action@v3
120+
with:
121+
platforms: arm64
122+
123+
- name: Set up Python
124+
if: runner.os != 'Linux'
125+
uses: actions/setup-python@v5
126+
with:
127+
python-version: "3.13"
128+
129+
- name: Build wheel
130+
uses: PyO3/maturin-action@v1
131+
with:
132+
target: ${{ matrix.target }}
133+
args: --release --out dist -i python3.13
134+
manylinux: auto
135+
working-directory: type-bridge-core
136+
137+
- name: Upload wheel artifact
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: ${{ matrix.artifact }}
141+
path: type-bridge-core/dist/*.whl
142+
10143
# Code quality: linting and formatting (parallel)
11144
lint:
12145
name: Python ${{ matrix.check }}
@@ -23,6 +156,9 @@ jobs:
23156
with:
24157
python-version: "3.13"
25158

159+
- name: Install Rust toolchain
160+
uses: dtolnay/rust-toolchain@stable
161+
26162
- name: Install uv
27163
uses: astral-sh/setup-uv@v5
28164
with:
@@ -55,6 +191,9 @@ jobs:
55191
with:
56192
python-version: "3.13"
57193

194+
- name: Install Rust toolchain
195+
uses: dtolnay/rust-toolchain@stable
196+
58197
- name: Install uv
59198
uses: astral-sh/setup-uv@v5
60199
with:
@@ -85,6 +224,9 @@ jobs:
85224
with:
86225
python-version: ${{ matrix.python-version }}
87226

227+
- name: Install Rust toolchain
228+
uses: dtolnay/rust-toolchain@stable
229+
88230
- name: Install uv
89231
uses: astral-sh/setup-uv@v5
90232
with:
@@ -96,8 +238,21 @@ jobs:
96238
- name: Install pytest-xdist for parallel execution
97239
run: uv pip install pytest-xdist
98240

99-
- name: Run unit tests in parallel
100-
run: uv run pytest tests/unit/ -v --tb=short -n auto
241+
- name: Run unit tests with coverage
242+
run: |
243+
uv run pytest tests/unit/ -v --tb=short -n auto \
244+
--cov=type_bridge --cov-branch \
245+
--cov-report=xml:coverage.xml \
246+
--cov-report=term-missing
247+
248+
- name: Upload Python coverage to Codecov
249+
uses: codecov/codecov-action@v5
250+
if: always()
251+
with:
252+
token: ${{ secrets.CODECOV_TOKEN }}
253+
files: coverage.xml
254+
flags: python
255+
fail_ci_if_error: false
101256

102257
# Integration tests (require TypeDB server, parallel by test category)
103258
test-integration:
@@ -123,6 +278,9 @@ jobs:
123278
with:
124279
python-version: "3.13"
125280

281+
- name: Install Rust toolchain
282+
uses: dtolnay/rust-toolchain@stable
283+
126284
- name: Install uv
127285
uses: astral-sh/setup-uv@v5
128286
with:

0 commit comments

Comments
 (0)