Skip to content

fix(tests): repair stale include_str! paths after monorepo consolidation#1857

Merged
noahgift merged 2 commits into
mainfrom
fix/stale-includestr-paths-v2
May 21, 2026
Merged

fix(tests): repair stale include_str! paths after monorepo consolidation#1857
noahgift merged 2 commits into
mainfrom
fix/stale-includestr-paths-v2

Conversation

@noahgift

Copy link
Copy Markdown
Contributor

Summary

`fusion_gate_contract_falsify.rs` and `parity_contract_falsify.rs` both reference `../../aprender/contracts/*.yaml` from when contracts lived in the standalone aprender repo. Post-consolidation, `contracts/` moved to the workspace root — the correct relative path is `../../../contracts/`.

Symptom (latent on main since the monorepo collapse)

```
error: couldn't read `crates/aprender-serve/tests/../../aprender/contracts/layer-parity-v1.yaml`:
No such file or directory (os error 2)
```

CI's main test command (`cargo test --workspace --lib`) skips integration tests in `tests/`, so this hasn't been a gating failure — but `cargo clippy --all-targets` does build them, and any future PR that expands `--tests` coverage hits these errors. Discovered while running clippy during #1846's E0063 triage.

Verification

```
$ cargo test -p aprender-serve --test parity_contract_falsify --release
test result: ok. 11 passed; 0 failed
```

```
$ cargo test -p aprender-serve --test fusion_gate_contract_falsify --release
test result: FAILED. 4 passed; 1 failed ← QA-002 falsifier doing its job
```

The QA-002 failure is the falsifier working as intended — 5 fused kernels exist in the codebase but lack entries in `contracts/kernel-fusion-v1.yaml` (FusedQKVKernel, FusedGateUpKernel, FusedGemmBiasGeluKernel, FusedRmsNormQ4KGemvKernel, FusedGateUpQ4KGemvKernel). Filed as a separate follow-up issue — out of scope for the path fix.

Test plan

  • `cargo test --test parity_contract_falsify` — 11/11 PASS
  • `cargo test --test fusion_gate_contract_falsify -- falsify_fusion_qa_001 falsify_fusion_qa_003` — 4/4 PASS (QA-002 separate)
  • No new lint regressions

🤖 Generated with Claude Code

`fusion_gate_contract_falsify.rs` and `parity_contract_falsify.rs` both
reference `../../aprender/contracts/*.yaml` from when contracts lived in
the standalone aprender repo. Post-consolidation, contracts/ moved to
the workspace root — the correct relative path is `../../../contracts/`.

Symptom (latent on main since the monorepo collapse):
  error: couldn't read `crates/aprender-serve/tests/../../aprender/contracts/layer-parity-v1.yaml`:
    No such file or directory (os error 2)

CI's main test command (`cargo test --workspace --lib`) skips integration
tests in `tests/`, so this hasn't been a gating failure — but
`cargo clippy --all-targets` does build them, and any future PR that
expands `--tests` coverage hits these errors.

## Verification

Both tests compile and run cleanly after the fix:

```
cargo test -p aprender-serve --test parity_contract_falsify --release
  → 11/11 PASS

cargo test -p aprender-serve --test fusion_gate_contract_falsify --release
  → 4/5 PASS (QA-002 surfaces real contract drift — filed separately)
```

The QA-002 failure is **the falsifier doing its job** — 5 fused kernels
exist in the codebase but lack entries in `contracts/kernel-fusion-v1.yaml`
(FusedQKVKernel, FusedGateUpKernel, FusedGemmBiasGeluKernel,
FusedRmsNormQ4KGemvKernel, FusedGateUpQ4KGemvKernel). Filed as a
separate follow-up.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@noahgift noahgift merged commit 8df1c0c into main May 21, 2026
10 checks passed
@noahgift noahgift deleted the fix/stale-includestr-paths-v2 branch May 21, 2026 17:11
noahgift added a commit that referenced this pull request May 21, 2026
…on contract test (#1860)

Third stale `../../aprender/contracts/` path missed by #1857.

`crates/aprender-gpu/src/kernels/tests/fusion_contract_falsify.rs`
constructed CONTRACT_PATH via:

```
concat!(env!("CARGO_MANIFEST_DIR"), "/../../aprender/contracts/kernel-fusion-v1.yaml")
```

Post-monorepo-consolidation, CARGO_MANIFEST_DIR for `aprender-gpu` is
`crates/aprender-gpu/`, so the old suffix resolved to `crates/aprender/contracts/`
which doesn't exist. The correct suffix is `/../../contracts/`.

Comment also updated to reflect post-monorepo reality.

## Verification

```
cargo test -p aprender-gpu --features cuda --lib --release falsify_fusion_001
```

Now finds the contract and runs the falsifier. The test still fails on
the SAME contract drift surfaced by #1858 (FusedQKVKernel and 4 sibling
kernels missing from `kernel-fusion-v1.yaml`) — that's the falsifier
doing its job, not a regression from this fix.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
noahgift added a commit that referenced this pull request May 22, 2026
…yaml (closes #1858) (#1861)

The QA-002 falsifier (`enforcement.kernel_registry_complete`) detected
five fused kernels that exist in the codebase but lack `fusion_decisions`
entries. Now registered as FUSION-006..010, all status ACTIVE with
verified call sites.

## Why this matters

Without entries, these kernels are invisible to:
- `pv lint` / contract-coverage audits
- The BLOCKED-requires-benchmark rule (QA-003)
- The Poka-Yoke registry check (kernel_registry_complete)

The drift was previously masked because the falsifier tests couldn't
compile (broken `include_str!` paths repaired in #1857 / #1860).
Repairing those paths surfaced the drift in `fusion_gate_contract_falsify`
(aprender-serve) and `falsify_fusion_001_every_fused_kernel_has_yaml_entry`
(aprender-gpu).

## Five entries added

| ID         | Kernel                            | Replaces                          | Call site |
|------------|-----------------------------------|-----------------------------------|-----------|
| FUSION-006 | FusedQKVKernel                    | Q/K/V GEMVs                       | crates/aprender-serve/src/cuda/generate.rs:267 |
| FUSION-007 | FusedGateUpKernel                 | Gate+Up GEMV + SwiGLU (FP32 path) | crates/aprender-serve/src/cuda/generate.rs:270 |
| FUSION-008 | FusedGemmBiasGeluKernel           | GEMM + Bias + GELU                | crates/aprender-gpu/src/memory/resident/ops/composite/linear_bias.rs:232 |
| FUSION-009 | FusedRmsNormQ4KGemvKernel         | RMSNorm + Q4K GEMV                | crates/aprender-serve/src/cuda/generate.rs:202 |
| FUSION-010 | FusedGateUpQ4KGemvKernel          | Gate+Up Q4K GEMVs (shared input)  | crates/aprender-serve/src/cuda/generate.rs:273 |

Each kernel was confirmed via `grep -rn 'pub struct <Name>\b'` and
each call site verified by inspecting the dispatching file.

FUSION-007 vs FUSION-010 distinction documented inline:
- FUSION-007 = FP32-input gate+up+SwiGLU fused (FusedGateUpKernel)
- FUSION-010 = Q4K-input gate+up sharing input vector load
  (FusedGateUpQ4KGemvKernel); SwiGLU applied separately downstream.

## Verification

```
$ cargo run -p aprender-contracts-cli --bin pv -- validate \
    contracts/kernel-fusion-v1.yaml
Contract is valid.

$ cargo test -p aprender-serve --test fusion_gate_contract_falsify --release
test result: ok. 5 passed; 0 failed     ← was 4/5 with QA-002 failing

$ cargo test -p aprender-gpu --features cuda --lib --release \
    falsify_fusion_001_every_fused_kernel_has_yaml_entry
test result: ok. 1 passed; 0 failed     ← was failing on FusedQKVKernel
```

Closes #1858.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant