feat(parser): schema-carried is_test flag on chunks — v33, PARSER_VERSION 18 (closes #2249)#2254
Merged
Merged
Conversation
…] detection) Adds a parse-time `is_test` flag on every chunk — the single source of truth, persisted in the new v33 `chunks.is_test` column. A Rust item is flagged test when it carries a #[test]-family attribute (#[test], #[tokio::test]), when it or any ancestor is gated by #[cfg(test)] / #[cfg(all(test, ...))], or when the canonical is_test_chunk registry path/name patterns match (all languages get the registry layer; the AST layer is Rust-only in this pass). The CQS_TESTCODE_DEMOTE knob's detection (apply_testcode_demote) and the test_demote rank-signal (provenance::signals_for) now read this stored flag instead of the rank-time path/name sniff, so the demotion finally sees the dominant self-corpus R@5 crowder: a #[cfg(test)] fn in a src/ file, whose attribute text lives OUTSIDE the chunk body and is invisible to any rank-time content/path/name check. Application and provenance read the same flag, so they cannot diverge. - Schema v32 -> v33: additive ALTER TABLE ADD COLUMN is_test (default 0); threaded through Chunk, ChunkRow (ordinal 16), ChunkSummary, and the batch_insert_chunks write. PARSER_VERSION 17 -> 18 so a plain reindex re-parses every chunk and populates the flag. - (d) tests.rs / test.rs FILENAME shapes added to the Rust registry test_path_patterns (single source of truth — also flags them for chunk_importance / scout / the dead-code SQL filter), not only the parse-time flag. Anchored on a leading `/` so substring traps (contest.rs, latest.rs) do not match. Affected fixtures using test.rs as a neutral path were updated. - Windowed chunks inherit the parent's is_test. - Migration coverage: v32->v33 column-default test, fresh-vs-migrated shape parity, and an is_test=0 guard on a legacy chunk migrated through the full v10->v33 chain. is_test_chunk stays for parse-time input and its other consumers. Out of scope (noted): switching cqs test-map / dead --verdict to the flag; non-Rust attribute detection. closes #2249 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The is_test struct-field fan-out missed four Chunk literals behind `#[cfg(feature = "slow-tests")]` — two integration tests and two enrichment.rs inline test-mod literals — which the lane's `cargo test --features cuda-index` sweep never compiled. CI clippy (`--all-targets --features slow-tests,mcp-http`) surfaced them. All are synthetic fixtures, so is_test: false. Verified clean under the full CI feature set locally. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ixture origin The is_test lane renamed tests/common/mod.rs::test_chunk's origin from test.rs to src/lib.rs but store_test still referenced the old origin at 6 sites (delete_by_origin/prune/FTS-prefix/call-edges/identity), and two schema_version asserts still pinned 32. All 8 updated. gather/hints/ store_calls/task/dead_code verified passing UNCHANGED — their test.rs edge-file params are incidental to the name-keyed graph joins, so no speculative edits there. Verified: full --tests sweep (cuda-index, --no-fail-fast) 5270 passed / 0 failed. The lane's earlier claimed sweep (4211) had not run this test binary — CI was the backstop that surfaced it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…edits Doctests are a compile surface neither clippy nor `cargo test --tests` exercises — the nl/mod.rs doc-comment Chunk literal was the last is_test straggler. Also applied cargo fmt to the store_test origin-string edits. Verified locally: cargo test --doc 0 failed, cargo fmt --check clean, full --tests sweep 5270/0, clippy --all-targets --features slow-tests,mcp-http clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
jamie8johnson
added a commit
that referenced
this pull request
Jul 6, 2026
ROADMAP.md: add v1.54.0 + the post-v1.54.0 arc (MCP Phase 3 SSE #2244/#2250, is_test flag v33/PV18 #2249/#2254, eval gold_set+file-level #2252, off-self eval, testcode-demote knob), fix the stale 'Current: v1.49.0' marker. PROJECT_CONTINUITY.md: collapse five accumulated CURRENT-N paragraphs (all now-landed work) into one clean current-state block; update schema state (v32/PV14 -> v33/PV18), the open-issues table (17 open, verified vs gh, the old 2026-06-25 table had ~half closed), recent release history (add v1.50- v1.54), eval baselines (add the off-self finding + the testcode-demote A/B). notes.toml: the session's sweep-count-verification + env-docs-guard lessons. Co-authored-by: jamie8johnson <jamie8johnson@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2249 — a parse-time, schema-carried
is_testflag on every chunk, so rank-time consumers can identify#[cfg(test)]-in-src/test code that path/name detection can't see. This is the fix theCQS_TESTCODE_DEMOTEA/B (#2251) proved necessary: the audit's dominant near-miss crowders are#[cfg(test)]functions insidesrc/files (e.g.src/parser/chunk.rstests beatingsrc/schema.sqlgolds), invisible tois_test_chunk(src/ path, notest_name) and to content sniffing (chunk content starts atfn).What lands
chunks.is_testcolumn (additive migration, default 0; v10→v33 full chain + is_test=0 legacy-default guard tested) + PARSER_VERSION 17→18 so a plain reindex re-parses and populates the flag.src/parser/chunk.rs): Rust#[test]-family attributes +#[cfg(test)]/cfg(all(test,…))gates on the item or any ancestor mod (any(test,…)/not(test)/feature="test"correctly excluded) + theis_test_chunkregistry patterns (all languages). Windowed chunks inherit the parent's flag.apply_testcode_demoteAND thetest_demoterank-signal both readchunk.is_test(same field on the sameSearchResult— divergence structurally impossible, preserving the feat(search): CQS_TESTCODE_DEMOTE — demote test-origin chunks on non-test-seeking queries (default-inert) #2251 coherence pin).%/tests.rs+%/test.rsadded to the Rust registrytest_path_patterns(leading-/anchored socontest.rs/latest.rsdon't match). A deliberate, testedis_test_chunkbehavior change (single source of truth — the same classifier feedschunk_importance/scout/dead-code); the sharedtests/common/mod.rsfixture was moved off thetest.rsfilename to accommodate it.Review
Fable code-review: APPROVE, no blockers, MEDIUM risk (schema+parser blast radius). Verified: fan-out completeness — all ~130
is_test:construction sites mapped; every parse-path site computes or inherits, everyfalseliteral is amod tests/fixture/ChunkRow::empty()(not thebuild_batched_with_dimsilent-failure class); migration ordinal —is_testpinned at column ordinal 16, both appended-column readers moved 16→17, no other ordinal read ≥14,try_get(16)false-fallback; knob/signal coherence — structural; registry blast radius — intended,/-anchor pins the substring traps, tests.rs reclassification is more-accurate not a regression. Three LOW/INFO non-blocking residuals (chunk_importance still uses the registry sniff sinceCandidateRowlacks the flag; cross-file#[cfg(test)] mod x;/inner#![cfg(test)]under-detection; post-merge ranking shift) → tracked on #2253; the audit's dominant AST case is fully caught.Gates
Full
--testssweep 4211 passed (only the pre-existing umap timing flake red — 5/5 solo, unrelated). Post-merge re-gate on current main: is_test_flag 6/0, provenance 15/0, migration 47/0, eval 8/0; fmt/clippy(all-targets, cuda-index)/provenance clean. Migration: v32→v33 default + fresh-vs-migrated parity + v10→v33 chain + legacy is_test=0 guard.After merge (required)
Daemon redeploy + reindex — PARSER_VERSION 18 drives the full re-parse that populates the flag (no
--forceneeded). Then /recall-gate (default ranking shifts:chunk_importancenow hits tests.rs/test.rs chunks even at the knob's inert default) and a re-run of theCQS_TESTCODE_DEMOTEA/B — this is the change that should let the knob move the self-corpus R@5 the earlier A/B found flat.🤖 Generated with Claude Code