Skip to content

feat: add semantic anomaly detection and reporting - #1

Merged
mohanagy merged 1 commit into
mainfrom
feature/roadmap-implementation
Apr 12, 2026
Merged

mohanagy merged 1 commit into
mainfrom
feature/roadmap-implementation

Conversation

@mohanagy

@mohanagy mohanagy commented Apr 12, 2026 •

Copy link
Copy Markdown
Owner
  • Implemented semantic anomaly detection in the analyze module, including bridge nodes, cross-boundary edges, and low-cohesion communities.
  • Enhanced CLI to support diff commands and added parsing for new arguments related to semantic anomalies.
  • Updated tests to cover new functionality for semantic anomalies in various modules including CLI, report generation, and HTTP server interactions.
  • Improved graph generation to include semantic anomaly counts and reporting in generated outputs.
  • Added support for querying and summarizing semantic anomalies in the serve runtime.
  • Enhanced stdio server to handle semantic anomaly requests and responses.

Summary

Testing

  • npm run test:run
  • npm run typecheck
  • npm run build
  • npm pack --dry-run (if packaging or install behavior changed)

Checklist

  • I updated docs for any user-visible change
  • I added or updated tests when behavior changed
  • I did not commit secrets, private corpora, or accidental generated artifacts
  • I kept this PR focused on a single change or tightly related set of changes

Related issues

Summary by CodeRabbit

Release Notes

  • New Features

    • Added semantic anomaly detection identifying bridge nodes, low-cohesion communities, and cross-boundary edges in knowledge graphs
    • Introduced diff command for comparing graph snapshots with configurable output limits
    • Enhanced query with ranking modes, community scoping, and file-type filtering
    • Added /anomalies HTTP endpoint and MCP tool for semantic analysis reporting
    • Implemented freshness metadata (version identifiers and ETags) to track artifact staleness
    • Added graph-aware prompt generation with community-specific summaries
  • Documentation

    • Updated README with new query capabilities and diff command documentation
    • Expanded current-status guide reflecting semantic anomaly detection and updated serve capabilities

- Implemented semantic anomaly detection in the analyze module, including bridge nodes, cross-boundary edges, and low-cohesion communities.
- Enhanced CLI to support diff commands and added parsing for new arguments related to semantic anomalies.
- Updated tests to cover new functionality for semantic anomalies in various modules including CLI, report generation, and HTTP server interactions.
- Improved graph generation to include semantic anomaly counts and reporting in generated outputs.
- Added support for querying and summarizing semantic anomalies in the serve runtime.
- Enhanced stdio server to handle semantic anomaly requests and responses.
@coderabbitai

coderabbitai Bot commented Apr 12, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e08840dc-f767-4ec4-ba4c-77d8966d639f

📥 Commits

Reviewing files that changed from the base of the PR and between 5f05571 and 59c3346.

📒 Files selected for processing (21)
  • README.md
  • docs/plans/current-status.md
  • src/cli/main.ts
  • src/cli/parser.ts
  • src/infrastructure/generate.ts
  • src/pipeline/analyze.ts
  • src/pipeline/export.ts
  • src/pipeline/report.ts
  • src/runtime/diff.ts
  • src/runtime/freshness.ts
  • src/runtime/http-server.ts
  • src/runtime/serve.ts
  • src/runtime/stdio-server.ts
  • tests/unit/analyze.test.ts
  • tests/unit/cli.test.ts
  • tests/unit/generate.test.ts
  • tests/unit/http-server.test.ts
  • tests/unit/pipeline.test.ts
  • tests/unit/report.test.ts
  • tests/unit/serve.test.ts
  • tests/unit/stdio-server.test.ts

📝 Walkthrough

Walkthrough

This PR introduces semantic anomaly detection (identifying bridge nodes, low-cohesion communities, and cross-boundary edges), graph diffing functionality to compare snapshots over time, and advanced query capabilities with community/file-type filtering and configurable ranking strategies. The changes span CLI commands, analysis pipelines, HTTP/MCP servers, and freshness metadata tracking.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md, docs/plans/current-status.md
Extended feature descriptions and examples to document new diff CLI command, graph snapshot comparison, semantic anomaly detection reporting, and expanded query options (--rank-by, --community, --file-type). Updated artifact specifications to include semantic anomalies and community labels.
CLI Layer
src/cli/parser.ts, src/cli/main.ts
Added parseDiffArgs function and new DiffCliOptions interface for baseline graph comparison. Extended parseQueryArgs to support --rank-by, --community, and --file-type flags with validation. Updated main.ts to execute diff subcommand and pass filter/ranking options to query execution.
Pipeline Analysis
src/pipeline/analyze.ts
Introduced SemanticAnomaly interface and semanticAnomalies() function computing bridge nodes (via betweenness), low-cohesion communities, and cross-boundary edge surprises. Added result caching for betweenness calculations and gated analysis by node count threshold.
Pipeline Export & Report
src/pipeline/export.ts, src/pipeline/report.ts, src/infrastructure/generate.ts
Updated toJson() to accept and serialize semantic_anomalies list. Extended report generation to include "## Semantic Anomalies" section with severity/kind/summary/rationale. Modified GenerateGraphResult to include optional semanticAnomalyCount.
Runtime Query & Serving
src/runtime/serve.ts
Added QueryRankBy, QueryFilters, and QueryGraphOptions types supporting degree/relevance ranking and community/file-type filtering. Enhanced scoreNodes, bfs, dfs to accept ranking mode and filter constraints. Introduced semanticAnomaliesSummary() with artifact fallback and community label merging.
Runtime Diff & Freshness
src/runtime/diff.ts, src/runtime/freshness.ts
New module diff.ts exports diffGraphs() formatting node/edge changes with configurable display limits. New module freshness.ts computes graph version hashes and filesystem-based metadata (GraphFreshnessMetadata, ResourceFreshnessMetadata) with HTTP header/MCP annotation helpers.
Runtime HTTP Server
src/runtime/http-server.ts
Added /anomalies endpoint with top-N filtering. Extended /query to accept rank/rank_by, community, and file_type parameters. Injected freshness headers (x-graphify-graph-version, x-graphify-graph-modified-ms, etag) across responses. Updated response helpers to accept and merge custom headers.
Runtime MCP Server
src/runtime/stdio-server.ts
Added graph_diff and semantic_anomalies MCP tools with optional parameters. Extended resource definitions to include freshness annotations. Implemented graph_community_summary_prompt and context caching keyed by graph mtime. Centralized query option parsing via queryOptionsFromParams() supporting new ranking/filtering parameters.
Test Coverage
tests/unit/*.test.ts
Updated test fixtures to include semantic_anomalies, community_labels, and baseline graphs. Extended assertions for new CLI arguments, HTTP response headers/endpoints, anomaly computation, query filtering/ranking behavior, and freshness metadata caching. Added semantic anomaly threshold and sanitization coverage.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 A diff of graphs we now compare,
With anomalies laid bare—
Bridge nodes gleam, communities align,
Query filters refine,
Fresh versions mark each moment's care! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/roadmap-implementation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mohanagy
mohanagy merged commit c43b456 into main Apr 12, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 27, 2026
8 tasks
mohanagy added a commit that referenced this pull request May 10, 2026
Second slice of #72. Adds the symbol layer on top of slice 1a's
file layer; the projection back to graph.json + byte-equivalence
golden tests are deferred to a separate slice (1c) per scope
discussion.

Adds to src/pipeline/spi/build.ts:
  - buildSpi(opts) — new public entry point covering files + symbols.
    buildSpiFileLayer is kept as a back-compat alias re-exporting the
    same function so slice-1a callers don't break.
  - emitSymbol / emitClassMethods — TypeScript AST walk over each
    source file, producing one SpiSymbol per top-level declaration
    (function / class / interface / type-alias / enum / constant /
    variable / namespace) plus class methods including constructors,
    getters, and setters.
  - declares edges (file -> symbol) for every emitted symbol, all
    high-confidence, source: typescript-syntactic.
  - Method overloads: bare base id for the first overload, #1, #2, ...
    suffixes for subsequent ones in source order, per the design's
    'method overloads append a deterministic 0-based index' rule.

Honors the design contract:
  - Stable IDs: symbol:<file_id>/<kind>/<name>[#<overload>], minted
    purely from path + kind + name (not line numbers), so in-file
    refactors don't invalidate cache keys.
  - Declarations skipped intentionally for v1: destructured variable
    statements (const { a, b } = ...), namespace members, external
    module augmentations (declare module 'string'). Each skip is
    explicit + commented; slice 2 expansion is the natural unblock.

Tests: 14 new tests in tests/unit/spi-symbols.test.ts covering all
symbol kinds, exported flag detection, multi-declarator variable
statements, destructure / namespace-member / module-augmentation
skip rules, class methods (including constructor/getter/setter),
overload indexing, declares-edge shape, ID stability across
in-file reordering, range capture, run-to-run determinism, and a
real run against examples/demo-repo/.

Verified:
  * npm run typecheck — clean
  * npm run build — clean
  * npm run test:run — 1428/1428 (was 1414; +14 new)
mohanagy added a commit that referenced this pull request Aug 12, 2026
`forbidden_target_symbols` carries a `_note` key whose value is a string.
`Object.values(...).flat()` folded that 277-character note into
FORBIDDEN_LITERALS as literal #1 of 8. Harmless today because no
production file contains that exact string, but it becomes a live trap
the moment the note is shortened to something short or common, at which
point the independence guard starts failing production files over a
documentation string.

Skip `_`-prefixed keys, and reject anything that is not an array of
identifiers so a future malformed entry fails loudly instead of silently
widening or narrowing the scan. Each remaining key must also name a real
corpus target.

Verified the guard still fires: appending `SmartRouter` to
src/runtime/graph-summary.ts makes `qualify:validate` fail with
`production file src/runtime/graph-summary.ts contains qualification
literal "SmartRouter"`, and the scan covers 7 symbols rather than 8
entries. A test asserts the map's shape so the defect cannot return.
mohanagy added a commit that referenced this pull request Aug 14, 2026
`forbidden_target_symbols` carries a `_note` key whose value is a string.
`Object.values(...).flat()` folded that 277-character note into
FORBIDDEN_LITERALS as literal #1 of 8. Harmless today because no
production file contains that exact string, but it becomes a live trap
the moment the note is shortened to something short or common, at which
point the independence guard starts failing production files over a
documentation string.

Skip `_`-prefixed keys, and reject anything that is not an array of
identifiers so a future malformed entry fails loudly instead of silently
widening or narrowing the scan. Each remaining key must also name a real
corpus target.

Verified the guard still fires: appending `SmartRouter` to
src/runtime/graph-summary.ts makes `qualify:validate` fail with
`production file src/runtime/graph-summary.ts contains qualification
literal "SmartRouter"`, and the scan covers 7 symbols rather than 8
entries. A test asserts the map's shape so the defect cannot return.
mohanagy added a commit that referenced this pull request Aug 14, 2026
`forbidden_target_symbols` carries a `_note` key whose value is a string.
`Object.values(...).flat()` folded that 277-character note into
FORBIDDEN_LITERALS as literal #1 of 8. Harmless today because no
production file contains that exact string, but it becomes a live trap
the moment the note is shortened to something short or common, at which
point the independence guard starts failing production files over a
documentation string.

Skip `_`-prefixed keys, and reject anything that is not an array of
identifiers so a future malformed entry fails loudly instead of silently
widening or narrowing the scan. Each remaining key must also name a real
corpus target.

Verified the guard still fires: appending `SmartRouter` to
src/runtime/graph-summary.ts makes `qualify:validate` fail with
`production file src/runtime/graph-summary.ts contains qualification
literal "SmartRouter"`, and the scan covers 7 symbols rather than 8
entries. A test asserts the map's shape so the defect cannot return.
mohanagy added a commit that referenced this pull request Aug 14, 2026
) (#681)

* feat(qualification): freeze the independent qualification contract (#655)

Add docs/qualification/, a frozen evaluation contract separate from the
product benchmark suite in docs/benchmarks/suite/, so roadmap changes can
be judged without grading Madar against expectations Madar produced.

Contents:
- corpus.json pins two new TypeScript fixture targets by content digest,
  two public repositories by commit SHA, and one sealed-holdout slot that
  is explicitly unsatisfied.
- tasks.json freezes six prompts with SHA-256 hashes, one per required
  task category, each recording who authored its truth and whether Madar
  output was inspected before freezing.
- truth/ holds per-task independent truth: critical facts, ordered
  execution paths, affected/unaffected sets, seeded-defect root causes,
  required uncertainty, and unsupported-claim traps.
- rubrics.json separates the seven scoring dimensions, uses a different
  method per category, and keeps adoption and broad fallback exploration
  out of the quality score.
- receipt-schema.json requires the full experimental identity, splits
  indexing/context-build/agent cost into separate accounts, and makes an
  invalid run structurally unaggregatable.
- validity-rules.md, holdout-policy.md, stop-rule.md, and
  evidence-categories.md freeze the invalidation, holdout, stop/rollback,
  and evidence-labelling rules.
- tier1.json is the deterministic PR-runnable subset; tier2-matrix.json
  freezes the planned repeated-run matrix while it stays unexecuted.

npm run qualify:validate checks the contract from a clean checkout and
fails if any qualification literal reaches src/, if a frozen file changes
without an explicit refreeze, or if a truth file cites a path that does
not exist.

No production retrieval, ranking, context, or reporting code is touched.

* refactor(qualification): rebuild the corpus on natural pinned repositories (#655)

The first pass built two self-authored TypeScript fixture workspaces as
qualification targets. That satisfied independence from Madar output but
forfeited naturalness, reproducing in a new namespace the defect #655
exists to cure: a corpus of self-made proxies cannot detect production
behaviour drifting toward benchmark-shaped repositories, because the
proxies are shaped by the same hands as the production rules.

Replace both fixtures with real, externally authored, MIT-licensed
TypeScript projects pinned at immutable commits:

- honojs/hono @ 26de73133b8552f56ba72e025ecd82b08900d796
- unjs/unstorage @ e6be6135832f350ca16f9a77432e1d4f0aa85ed7

Seeded defects are now patches applied to the pinned commit rather than
synthetic workspaces authored around their own answer:

- patches/hono-compose-reentrancy-guard.patch weakens the middleware
  re-entrancy guard for the root-cause task.
- patches/hono-error-message-disclosure.patch makes the default error
  handler return the thrown error's stack for the review task.

All six truth files are rewritten from the pinned sources, read directly
and without ever running Madar. Each target records a cited_blobs map of
path to git blob SHA so the validator can check every truth citation
offline; `--verify-corpus` confirms the commits, all 25 blob digests, and
both patches against the live repositories.

corpus.json also discloses that Madar ships a generic Hono adapter
(src/pipeline/spi/framework-hono.ts plus Hono-aware classification in
src/runtime/retrieve.ts). That is declared framework support, not a
repository-specific special case, but it means a hono result partly
measures that adapter. The hono prompts therefore never name the
framework, and unstorage carries production_coupling: none_found as the
uncoupled contrast.

evidence-categories.md separates target naturalness from evidence class
and records two findings: the existing suite corpus is five in-repo
proxies plus six SHA-pinned git rows, and the retrieval/grader isolation
claimed for runtime-proof.json is asserted in prose with no test or CI
check enforcing it.

No production retrieval, ranking, context, or reporting code is touched.

* docs(qualification): surface the no-measured-evidence limitation (#655)

Add a `## Read this first` callout above the corpus description in
docs/qualification/README.md stating plainly that the contract has never
been executed and currently produces no measured evidence of any kind,
followed by the three limits that executing it will not fix: regression
only and never generalization while the sealed holdout is unsatisfied,
thresholds pre-registered rather than calibrated, and Tier 1's network
dependency on cloning the pinned targets.

A reviewer should not have to infer this by cross-referencing tier, kind,
and status across target entries. A test asserts both the wording and
that the callout precedes the corpus description.

Also fix three references left stale by the corpus migration: two dead
task ids in holdout-policy.md and a `pinned_no_truth` status mention in
validity-rules.md that no longer exists in corpus.json.

* fix(qualification): keep prose out of the forbidden-literal scan (#655)

`forbidden_target_symbols` carries a `_note` key whose value is a string.
`Object.values(...).flat()` folded that 277-character note into
FORBIDDEN_LITERALS as literal #1 of 8. Harmless today because no
production file contains that exact string, but it becomes a live trap
the moment the note is shortened to something short or common, at which
point the independence guard starts failing production files over a
documentation string.

Skip `_`-prefixed keys, and reject anything that is not an array of
identifiers so a future malformed entry fails loudly instead of silently
widening or narrowing the scan. Each remaining key must also name a real
corpus target.

Verified the guard still fires: appending `SmartRouter` to
src/runtime/graph-summary.ts makes `qualify:validate` fail with
`production file src/runtime/graph-summary.ts contains qualification
literal "SmartRouter"`, and the scan covers 7 symbols rather than 8
entries. A test asserts the map's shape so the defect cannot return.

* fix(qualification): make the frozen contract portable to Windows (#655)

Both Windows lanes were red on 765802f while ubuntu and macOS passed.
Three assertions in tests/unit/qualification-contract.test.ts failed
because the Windows checkout converts LF to CRLF: two prose assertions
used LF-specific multiline substrings, and the freeze digest is SHA-256
over raw bytes, which CRLF changes.

The freeze is meaningful precisely because it is byte-exact, so the fix
pins the bytes rather than loosening the check. freeze.json is NOT
regenerated and no frozen content changed; `git add --renormalize .`
produces no diff.

- .gitattributes pins `docs/qualification/**` to `text eol=lf`, following
  the existing precedent for the hashed isolation CLAUDE.md, and marks
  `patches/*.patch` as `-text` so seeded-defect patches reach `git apply`
  byte-for-byte in either direction.
- Prose assertions read through a normalizing helper so they test
  semantic content rather than checkout representation. The freeze digest
  deliberately does not use it: it reads a raw Buffer, because that
  guarantee is about bytes.
- The validator normalizes patch text before structural parsing so a
  stray carriage return cannot be captured into a path, rejects a CRLF
  patch outright, and now explains on a digest mismatch that a CRLF file
  is a checkout problem and that regenerating freeze.json is not the fix.
- Two new tests: `.gitattributes` must keep the pin, and no frozen file
  may contain CRLF whatever the checkout did.

Also widen the CI step. `Validate qualification contract` was gated to
ubuntu/Node 22, so it was skipped on Windows entirely and the byte-exact
freeze was only ever verified on one of six lanes — the tests failed
there while the validator that checks the same digests never ran. It now
runs on every lane; the default mode is pure local file I/O with no
network and no spend. A reproducible gate that only reproduces on Linux
is not yet the thing it claims to be.

Verified by simulating the Windows checkout locally: cloning with
core.autocrlf=true converts README.md to CRLF while leaving every file
under docs/qualification as LF, and both the validator and the 38
qualification tests pass in that clone. Forcing CRLF onto a frozen file
there still fails both the digest check and the new CRLF check, so the
guarantee was preserved rather than made vacuous.

* fix(qualification): make the contract validator report rather than throw

Three findings from the independent review of #681, all confirmed against the code before acting.

1. kind and holdout_class described the same distinction but were read by different consumers: this validator branched on kind, tests/unit/qualification-contract.test.ts filtered on holdout_class. A target setting only one would be classified differently by each. Both are now required to agree, and every sealed-target branch derives from one predicate.

2. The independence check dereferenced task.truth_provenance and truth.provenance without confirming either exists, and the receipt loop read receipt.validity and receipt.scores after a schema failure. Either would throw a TypeError before the collected failure list is printed, so a malformed document produced a stack trace instead of the description of what is wrong with it. Both now record a failure and move on.

3. --write persisted freeze.json before the failure gate, so a run over an inconsistent contract exited 1 while leaving a freeze on disk that blessed that state and read back clean afterwards. The write is deferred until after the gate, and a failed --write says the freeze was not written.

Refs #655.

* fix(qualification): make the frozen contract agree with itself

Eight findings from the independent review, all of the same kind: the contract stated a rule in one place and a different rule in another. Each is corrected toward the rule that was already intended, not toward a new one.

receipt-schema.json encoded validity-rules.md in one direction only, so receipts contradicting the prose still validated. Added the three missing branches: an unmeasured cost account must carry nulls rather than zeros, a measured score may not carry null, and a retained artifact must carry a non-empty path and a 64-hex digest. Removed the top-level cache_mode, which duplicated the required identity.cache_mode with no rule keeping the two equal, and dropped it from both examples.

validity-rules.md names five retained artifacts while retention had four slots and additionalProperties false, so a receipt following the prose failed the schema and was then classified incomplete_receipt by the same document. prompt_text, environment_receipt and truth_file are now expressible. They are deliberately not required: which artifacts each tier must retain is an open question, and requiring them here would answer it by accident.

rubrics.json correctness anchors 1 and 2 both read 'no false assertions' and were separated only by 'material gaps', which critical_fact_completeness already measures; they now separate on whether every assertion is verifiable against the pinned source. The evidence-symbol matching rule is stated: truth files record obligations bare while evidence entries qualify them by owner, so exact-string comparison would never match, and last-segment matching is now written down rather than assumed.

README.md claimed target ids are scanned out of src/; corpus.json says they are deliberately excluded. The README now documents the implemented boundary and says why. stop-rule.md S1.4 asked a question that could not be answered, since its absolute clause referenced a phase target the same row records as not set; both clauses now state their behaviour when no target and no previous sweep exist. Patch paths carried no declared base directory even though a failed patch application invalidates a run; corpus.json now records patch_path_base explicitly.

The cited-path traversal, including the new_path exemption, was duplicated between the validator and its test, so a change to one would have left the other enforcing the old rule while still passing. It now lives in one shared module. The test also no longer pins independent_of_production_rule_author to false, which would have failed on the improvement of a second author closing the gap; the current state is asserted separately.

freeze.json is regenerated deliberately because seven frozen files changed. Every digest move is accounted for by an edit above.

Refs #655.

* fix(qualification): decide the five open contract terms (#655)

Eleven of the sixteen review findings were transcription defects, fixed in
2fddb25 and 3091d4f. The remaining five each SET a contract term, so they
were escalated rather than settled by the automation this contract will later
measure. The decisions, and why:

8. correct_uncertainty and evidence_support stop gating and keep being
   measured. No threshold for either has been calibrated, and gating on an
   uncalibrated threshold manufactures confidence and invites the threshold to
   be tuned to whatever passes. Both stay reported on every receipt: an
   exemption that also stops measurement can never end. Each records the
   precondition that would make it gate -- a baseline distribution over the
   natural corpus, with the threshold derived and recorded before any target is
   scored. evidence_support spans tiers 1 and 2, so it carries an explicit
   scope note: the Tier 1 deterministic gate is unaffected and still gates.

10. Run-validity requirements split by tier. Tier 1 never runs an agent, so
    requiring an answer and a transcript contradicted its stated purpose and
    made the valid Tier 1 example fail its own contract. Tier 1 now requires
    the context artifact, prompt text, environment receipt and truth file;
    Tier 2 adds the raw transcript, the answer text and the attributable Madar
    call. Each tier records why, so the split is not later collapsed back.

11. The Tier 1 gate starts inactive. A gate with no baseline gates on noise.
    Activation is recorded as an event naming the run that established the
    baseline, not as a boolean flip.

12. The Tier 2 cells are defined explicitly, mirroring the Tier 1 cells, with
    sealed-holdout-a recorded as contributing through the external sealed
    manifest rather than through this file.

14. hidden_acceptance_test is now consumed: a Tier 2 receipt for a task
    declaring one must carry a not_measured implementation score. A frozen
    contract carrying a field nothing reads is a defect in the contract, so it
    is enforced rather than deleted.

Two terms these decisions introduce are themselves enforced, not decorative:
an active gate must name its baseline run, and the Tier 2 cells must equal the
Tier 1 cells. Each new validator branch was mutation-tested and turns exactly
one regression test red when disabled.

freeze.json digests moved, by decision:

  8      rubrics.json                       358d7883 -> 377a1f72
  10     tasks.json                         61f7e518 -> c9410884
  10     validity-rules.md                  8624a0b9 -> ee3898f5
  10     examples/receipt-tier1-valid.json  8fc8d9c3 -> a68f8d58
  10+14  receipt-schema.json                6fa0e3dc -> e849ba4b
  11     tier1.json                         5faa2089 -> 967e3d3b
  12     tier2-matrix.json                  d4a0a071 -> 449d8076

The other 14 frozen entries are unchanged. Local: qualify:validate consistent,
typecheck clean, qualification-contract.test.ts 43 passed.

Refs #655. Related parent: #649.

* fix(qualification): make validator path output platform-independent (#655)

Both Windows lanes of the exact-head matrix on 6ceef75 failed on the new
Decision 14 regression test: it asserts the validator names the offending
receipt, and `relative()` returns backslashes on Windows, so the expected
`docs/qualification/examples/...` never matched.

Fix it at the source rather than in the assertion. Validator output is
compared in tests and read in CI logs, so it should be byte-identical on every
platform. The file already established that idiom for the freeze map in
cec02d2; this lifts it into one `relPath()` helper and routes the receipt
label, the production-literal message, the freeze map and the --write log
through it.

No frozen digest moves: the freeze map was already normalised, so this only
changes what the validator prints.

Refs #655. Related parent: #649.

* fix(qualification): address the re-review of the decided contract terms (#655)

Five findings from the CodeRabbit re-review of 4c28794, all assessed as real:

1. An empty patch file skipped every structural patch check. `if (patch)` is
   falsy for an empty read, so the diff --git, CRLF and touched-path checks
   were all skipped and the target passed -- and an empty patch means the
   seeded defect is gone, which is exactly what that section exists to catch.
   Now distinguishes unreadable (undefined) from empty ('').

2. Unguarded task field reads could still replace the collected failure list
   with a stack trace. task.prompt.text, task.prompt.sha256 and
   task.scoring.tier2_method were dereferenced directly. That is the defect
   class 2fddb25 fixed, and it should not survive anywhere in this file. Both
   are now guarded and reported, and tier1.cells is iterated defensively to
   match the convention already used further down.

3. The gate activation rule added for decision 11 passed when `active` was
   absent or non-boolean, and accepted an active gate still in state
   pre_baseline. It now requires the block, requires a boolean, and pairs each
   value with its state.

4. single_root_cause_adjudication re-gated correct_uncertainty. Resolved by
   stating the boundary rather than weakening either side: the ratio dimension
   has no calibrated threshold and does not gate, while the method's
   uncertainty_required_for_pass is an explicit pre-registered id list, which
   is checkable without calibration and does gate. Recorded on both the
   dimension and the method so a reader arriving from either finds it.

5. Two tests stated opposite contracts for independent_of_production_rule_author.
   The snapshot test is now named as a snapshot and says that closing the
   independence gap requires updating it in the same change.

Every validator branch touched or added was mutation-tested and turns exactly
one regression test red when disabled.

freeze.json: only rubrics.json moves, 377a1f72 -> bf176381, for finding 4.

Local: qualify:validate consistent, typecheck clean, 50 tests passed.

Refs #655. Related parent: #649.
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