Skip to content

feat(parser): schema-carried is_test flag on chunks — v33, PARSER_VERSION 18 (closes #2249)#2254

Merged
jamie8johnson merged 6 commits into
mainfrom
feat/2249-istest-flag
Jul 6, 2026
Merged

feat(parser): schema-carried is_test flag on chunks — v33, PARSER_VERSION 18 (closes #2249)#2254
jamie8johnson merged 6 commits into
mainfrom
feat/2249-istest-flag

Conversation

@jamie8johnson

Copy link
Copy Markdown
Owner

Closes #2249 — a parse-time, schema-carried is_test flag 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 the CQS_TESTCODE_DEMOTE A/B (#2251) proved necessary: the audit's dominant near-miss crowders are #[cfg(test)] functions inside src/ files (e.g. src/parser/chunk.rs tests beating src/schema.sql golds), invisible to is_test_chunk (src/ path, no test_ name) and to content sniffing (chunk content starts at fn).

What lands

  • v33 chunks.is_test column (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.
  • Parse-time detection (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) + the is_test_chunk registry patterns (all languages). Windowed chunks inherit the parent's flag.
  • Knob + signal rewired to the stored flag: apply_testcode_demote AND the test_demote rank-signal both read chunk.is_test (same field on the same SearchResult — divergence structurally impossible, preserving the feat(search): CQS_TESTCODE_DEMOTE — demote test-origin chunks on non-test-seeking queries (default-inert) #2251 coherence pin).
  • The (d) decision: %/tests.rs + %/test.rs added to the Rust registry test_path_patterns (leading-/ anchored so contest.rs/latest.rs don't match). A deliberate, tested is_test_chunk behavior change (single source of truth — the same classifier feeds chunk_importance/scout/dead-code); the shared tests/common/mod.rs fixture was moved off the test.rs filename 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, every false literal is a mod tests/fixture/ChunkRow::empty() (not the build_batched_with_dim silent-failure class); migration ordinalis_test pinned 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 since CandidateRow lacks 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 --tests sweep 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 --force needed). Then /recall-gate (default ranking shifts: chunk_importance now hits tests.rs/test.rs chunks even at the knob's inert default) and a re-run of the CQS_TESTCODE_DEMOTE A/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

jamie8johnson and others added 6 commits July 5, 2026 17:31
…] 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 jamie8johnson merged commit 15da0a6 into main Jul 6, 2026
10 checks passed
@jamie8johnson jamie8johnson deleted the feat/2249-istest-flag branch July 6, 2026 01:02
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>
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.

parser/store: schema-carried is_test flag on chunks (cfg(test)/#[test] detection) — rank-time consumers cant see cfg-test-in-src today

1 participant