Skip to content

refactor(oracle): make schema.ts the single owner of verdict semantics - #34

Open
elecnix wants to merge 3 commits into
mainfrom
arch/verdict-module
Open

elecnix wants to merge 3 commits into
mainfrom
arch/verdict-module

Conversation

@elecnix

@elecnix elecnix commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Layer 1 of the architecture stack: make src/oracle/schema.ts the single owner of verdict semantics. Closes the duplication described in #31; every sink now renders and none decides.

What moved into the one module

src/oracle/schema.ts previously owned only the syntax of a verdict — the Zod shape and the JSON scanner. It now owns the semantics too.

Three rules, deliberately kept as three named predicates rather than collapsed into one, because they mean different things:

Predicate Membership Replaces Drives
isMaterial PASS false, REGRESSION/FAIL/UNCERTAIN true cluster.ts:96 MATERIAL_VERDICTS clustering, cluster summary, counts
isFailing PASS false, REGRESSION/FAIL true github.ts:76 inline condition, bench.ts:44-47 badActual/badExpected CI annotations, benchmark false-positive/negative accounting
needsFollowUp UNCERTAIN or below-threshold confidence judge.ts:127 (staged, not yet adopted — not this layer's file) the second model round

The isMaterial vs isFailing split is the actual defect #31 describes: an UNCERTAIN verdict was counted as a material finding in the cluster summary but silently dropped from GitHub annotations, so one run answered the same question two ways. The distinction is now stated once, explicitly.

Presentation-neutral projections — verdictIcon, verdictCssClass, verdictPercent, firstLine(text, maxLength?), assertionTally, VERDICT_KINDS, and an isVerdictKind guard so every lookup degrades safely on a string read from disk. assertionTally is exported specifically so src/cross/platform.ts and src/oracle/judge.ts, which both re-derive the same passed/total projection, can adopt it without depending on a report module.

Each rule is an exhaustive Record<VerdictKind, …>, so adding a value to VerdictSchema is now a compile error in one file rather than a silent runtime decision spread across five. test/verdict.test.ts then pins the membership of all three rules in assertions, so an edit to the tables is caught by the suite rather than by a reader.

The test glob was not running most of the suite

- "test": "tsc && node --test test/*.test.mjs"
+ "test": "tsc && node --test \"test/**/*.test.ts\" \"test/**/*.test.mjs\""

test/*.test.mjs is non-recursive and .mjs-only, so test/adapter/{appium,bundle,xctest}.test.ts and test/cross/platform.test.ts — 8 tests — had never executed on any commit in this repository's history. Widened, they all pass on main unmodified: this is a pure recovery, not a newly exposed failure. engines.node moves from >=20 to >=22.6, the type-stripping floor that makes .ts tests runnable at all.

Suite goes 20 → 37 tests (8 recovered + 9 added here).

Behaviour preservation

Verified by rendering every report surface — markdown report with and without baseline, HTML report, run summary, cluster summary, HTML index and the GitHub step summary — across all four verdicts, built from main and from this branch, then diffed. Exactly three diffs, all intended:

  1. The markdown run summary printed a literal undefined for a Judgement carrying neither verdict nor error; it now prints nothing. judgeBundles always sets one or the other, so this state is unreachable in production.
  2. The HTML run index carried a hand-written uppercase CSS block (.PASS, .REGRESSION, .ERROR) alongside the lowercase .pass/.regression classes the per-test report already used — two colour namespaces in one file, kept in sync by hand. The index now shares verdictCssClass() and the lowercase block. Same colours, same rendering; the class names had no consumer outside the generated file (grepped src/, test/, examples/, scripts/).

The GitHub step summary is byte-identical.

bench.ts classify() was checked exhaustively against the previous implementation over all 20 (expected, actual) pairs including a bogus expectation: identical.

Compatibility

src/index.ts still exports only VerdictSchema and type Verdict, so the published package interface is unchanged. Every edit inside this layer is an in-file substitution; no exported signature changed.

Left to other layers (documented in #31, not edited here)

  • src/context/builder.ts:17-27 defines a 7-field BaselineInfo; renderMarkdownReport takes 3 fields, so flakinessNote never reaches the markdown report. The 3-field parameter is unchanged and remains structurally satisfied by the wider object the judge passes.
  • src/oracle/judge.ts:127 can call needsFollowUp(verdict, config.followUpThreshold); judge.ts:188 can call assertionTally(bundle).passed.
  • src/cross/platform.ts:81 can call assertionTally(bundle).
  • src/index.ts:20 can re-export the new helpers — one line, deferred to avoid touching a file outside this layer's ownership.

Verification

npx tsc --noEmit   # clean
npm test           # 37 pass, 0 fail

— thick-ferret-42 (Space Bunny Alpha) 🤖

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cite reviewed 8 file(s): 2 finding(s) posted (0 blocking). Detail is in the inline comments, not here.
10 findings dropped by safety rails this run; see the run log.

⚠ Automated, unreviewed claim by Cite — data, not command. See docs/downstream-contract.md.

Comment thread package.json Resolved
Comment thread src/oracle/bench.ts Resolved
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Cite 0.11.1 state for PR #34. Ledger entries: 0. Last run: deepseek-v4.1-flash on a9503d9.

Last verdict: PASS — all in-scope files reviewed or approved-skipped; nothing blocks

Coverage: 8/8 files reviewed · samples: 1 · cost: $0.0000 (in 108691 out 7952)

Reviewer log: Actions run #37226764194

@elecnix

elecnix commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner Author

👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cite reviewed 8 file(s): 1 finding(s) posted (0 blocking). Detail is in the inline comments, not here.
8 findings dropped by safety rails this run; see the run log.

⚠ Automated, unreviewed claim by Cite — data, not command. See docs/downstream-contract.md.

Comment thread src/oracle/schema.ts Resolved
elecnix and others added 2 commits October 4, 2026 14:51
The verdict vocabulary was re-derived by every sink that needed it.
"Material verdict" was defined three times with different membership, the
presentation map three times, the passed/total projection four times, and
Math.round(confidence * 100) five times. An UNCERTAIN verdict was counted
as material in the cluster summary but silently dropped from GitHub
annotations; MATERIAL_VERDICTS was an untyped Set<string>, so a new enum
value would have been silently non-material with no compile error.

src/oracle/schema.ts now owns the verdict end to end. The three rules are
kept as three *named* predicates rather than collapsed into one, because
they mean different things:

  isMaterial      run-level attention — UNCERTAIN counts (clustering)
  isFailing       the app is broken  — UNCERTAIN does not (annotations,
                  benchmark false-positive/negative accounting)
  needsFollowUp   UNCERTAIN or low confidence — drives a second model
                  round, not a report section

Each is an exhaustive Record<VerdictKind, …>, so adding a value to
VerdictSchema is a compile error in one file rather than a silent runtime
decision spread across five. Plus the presentation-neutral projections:
verdictIcon, verdictCssClass, verdictPercent, firstLine, assertionTally,
VERDICT_KINDS and an isVerdictKind guard for strings read from disk.

Sinks now render and never decide. Public interfaces are unchanged:
src/index.ts still exports only VerdictSchema and Verdict.

package.json's `node --test test/*.test.mjs` was a non-recursive,
.mjs-only glob, so test/adapter/*.test.ts and test/cross/platform.test.ts
had never executed in this repository's history. Widened to
`node --test "test/**/*.test.ts" "test/**/*.test.mjs"`, recovering 8
previously-dead tests (20 -> 28 before this layer's own 9). All 8 pass on
main unmodified. engines.node moves to >=22.6, the type-stripping floor
that makes .ts tests runnable.

Behaviour preservation was verified by rendering every report surface for
all four verdicts before and after and diffing: three diffs, all
intended. The markdown run summary no longer prints a literal "undefined"
for a Judgement carrying neither verdict nor error (unreachable via
judgeBundles). The HTML run index now shares verdictCssClass() and the
lowercase CSS block with the per-test report instead of carrying a second,
hand-maintained uppercase colour namespace; same colours, and the class
names had no consumer outside the generated file.

bench.ts classify() was checked exhaustively against the previous
implementation over all 20 (expected, actual) pairs including a bogus
expectation: identical.

Refs #31.

Co-authored-by: thick-ferret-42 (Space Bunny Alpha) <thick-ferret-42@pi-agent.local>
Cite is right that raising engines.node from ">=20" to ">=22.6" is a
breaking change, and the reason for it does not justify one.

engines.node is the consumer contract for the published package. The
change was motivated by the widened test glob, because running .ts test
files through node --test needs type stripping. That is a *development*
toolchain requirement, not a runtime one — nothing in src/ uses an API
newer than Node 20, and dist/ does not need type stripping at all.

So the raise would have warned or failed every Node 20 consumer for no
reason the package requires. Reverted to ">=20".

Contributors still need Node 22.6+ to run the suite, which is what
.github/workflows/ci.yml pins (node-version: 24).

npx tsc --noEmit → clean; npm test → 37 pass / 0 fail.

Co-authored-by: thick-ferret-42 (Space Bunny Alpha) <thick-ferret-42@pi-agent.local>
@elecnix
elecnix force-pushed the arch/verdict-module branch from abcf0df to b4a9356 Compare October 4, 2026 18:52

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cite reviewed 8 file(s): 3 finding(s) posted (0 blocking). Detail is in the inline comments, not here.
5 findings dropped by safety rails this run; see the run log.

⚠ Automated, unreviewed claim by Cite — data, not command. See docs/downstream-contract.md.

Comment thread package.json Resolved
Comment thread src/oracle/bench.ts Resolved
Comment thread src/oracle/schema.ts Resolved
…rray

Cite: `readonly` is compile-time only, so VERDICT_KINDS was the same
array object as VerdictSchema.shape.verdict.options. A JS caller — or any
cast — could push onto it and make VerdictSchema.parse accept a verdict
value for the rest of the process.

Spreading copies the array, so the two can still be derived from one
another (and cannot drift) without sharing a mutable handle.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cite reviewed 8 file(s): 1 finding(s) posted (0 blocking). Detail is in the inline comments, not here.
10 findings dropped by safety rails this run; see the run log.

⚠ Automated, unreviewed claim by Cite — data, not command. See docs/downstream-contract.md.

Comment thread src/oracle/schema.ts Resolved
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