diff --git a/AGENTS.md b/AGENTS.md index 8e20de7..692d077 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,13 +22,28 @@ instead of describing product behavior. Use `SHOULD` for polish and edge cases, `[manual]` for UI-only behaviors, and notes or acceptance-checklist bullets for implementation details rather than making every detail an enforced `MUST`. -**When implementing**, every MUST/SHALL requirement needs at least one test +**Requirement substance**: distinguish three kinds of text. Behavioral +requirements state what the product does — the normal home for normative +`MUST`s. Delivered-text contracts (agent-facing or interface text the product +delivers) are normative through the surface that delivers them: pin the +instruction or outcome that must survive, not a whole paragraph or heading +order. Verification notes — test strategy, CI commands, review procedure, +migration bookkeeping, tool versions — belong in notes or acceptance-checklist +bullets, not enforced `MUST`s. + +**When implementing**, every MUST/SHALL requirement needs covering evidence annotated with a comment containing its ID, e.g. `// 2119: REQ-001.2.3` (the -marker line must start with a comment leader). Write tests that would genuinely -fail if the requirement were violated — including its negative space: what the -requirement forbids needs a rejection test, not just what it allows. A -fresh-context reviewer judges each test's honesty; tautological or over-mocked -tests will be rejected. +marker line must start with a comment leader). One test MAY carry several +requirement IDs (`// 2119: REQ-001.2.3, REQ-001.2.4`): annotate existing +evidence that already covers a requirement instead of adding a near-duplicate +test for traceability. Write tests that would genuinely fail if the requirement +were violated — including its negative space: what the requirement forbids needs +a rejection test, not just what it allows — and that stay green under legitimate +non-violating changes (paraphrase, rename, reformat, reorganization); a test +whose only value is pinning spec wording, file layout, or digests the +requirement does not govern is a tripwire, not evidence. A fresh-context +reviewer judges each test's honesty; tautological or over-mocked tests will be +rejected. **Reviewer diversity**: use reviewer models from different providers, routinely or as periodic `npx rfc2119 review --audit` sweeps — adversarial audits of diff --git a/docs/design.md b/docs/design.md index 53d2501..5a499b5 100644 --- a/docs/design.md +++ b/docs/design.md @@ -48,6 +48,37 @@ type. This is presented as a **reference architecture** — the recipe in [`scal describes the shape; an executable example has not shipped yet, and we say so rather than overclaim "supported." +## Verdict invalidation is scoped, and its breadth is a tradeoff + +A verdict vouches for exact content — but deliberately not all content. A test-quality hash +covers the requirement statement, the annotated evidence blocks, and files matched by +`shared_evidence`; it excludes unrelated tests in the same file, other specs, and docs. Two +goals must not be conflated: + +1. **Tests should tolerate legitimate product-preserving changes.** Paraphrasing a requirement, + renaming a symbol, reformatting, or reorganizing files must not invalidate evidence. The + reviewer template's survival probe enforces this at review time: evidence that fails only + because wording or organization changed is a tripwire, and the reviewer rejects it. +2. **Review fingerprints should track everything that could neutralize the evidence.** A passing + suite alone does not keep an old review valid; the hash must include the requirement text and + any shared helper capable of neutering the tests (`shared_evidence`). + +Breadth is therefore a tradeoff, not a dial to maximize. Declaring every helper shared means one +helper edit invalidates every dependent verdict — helper integrity at the cost of unrelated hash +churn. Declaring too little means a neutering helper escapes the hash and verdicts stay green +while the evidence dies. Declare the narrowest boundary that includes the helpers that can +neutralize the evidence, and read a stale-verdict reduction as meaningful only alongside that +integrity check. (Direction, not shipped: explicitly declared shared-evidence groups keep exact +content hashes within a group and preserve universal helpers, without invalidating unrelated +groups; no semantic-equivalence detection, no blanket safe-listing of formatting changes.) + +Rollout is observational, never destructive. Guidance and probe changes land first; 2119 never +deletes or auto-invalidates a repository's tests. Worth watching as trends — never as gates, +because a hard limit (executions per requirement, prose-test ratios) is just another number to +optimize: verdict invalidations after changes that did not alter requirement meaning; time for +documentation-only changes to reach green; tests added versus existing tests cross-referenced +when specs change; requirements covered only by tests skipped in default CI. + ## Specs are agent context; ritual text is banned Every line in a spec file is read by agents on every relevant task, so every line must change diff --git a/eval/calibration/015-prose-tripwire.md b/eval/calibration/015-prose-tripwire.md new file mode 100644 index 0000000..240159f --- /dev/null +++ b/eval/calibration/015-prose-tripwire.md @@ -0,0 +1,32 @@ +--- +expected_verdict: fail +prompt: test-quality +source: accretion study (2119#38), 2026-10 (synthetic) +failure_mode: false rigor — exact-prose pin standing in for behavioral evidence +--- + +## Requirement + +> The CLI MUST print a top-level `--help` flag listing its subcommands. + +## Evidence + +```ts +// 2119: REQ-007.1.1 +it("help output matches the README word for word", () => { + const help = runCli(["--help"]); + const readme = readFileSync("README.md", "utf8"); + for (const line of readme.split("\n").filter((l) => l.startsWith("`2119 "))) { + expect(help).toContain(line.replace(/`/g, "")); + } +}); +``` + +## Why the correct verdict is FAIL + +The assertion pins documentation wording, not behavior. Rephrase the README — a legitimate, +non-violating change — and the test breaks even though the CLI still lists every subcommand; +that is exactly the survival probe the reviewer runs alongside the counterexample probe. The +behavioral evidence is an assertion against the CLI's observable output (each subcommand +present with a description), not against prose or a digest of files the requirement does not +govern. Evidence whose only value is pinning wording, layout, or hashes must be rejected. diff --git a/eval/calibration/016-redundant-matrix.md b/eval/calibration/016-redundant-matrix.md new file mode 100644 index 0000000..bc01eb2 --- /dev/null +++ b/eval/calibration/016-redundant-matrix.md @@ -0,0 +1,35 @@ +--- +expected_verdict: fail +prompt: test-quality +source: accretion study (2119#38), 2026-10 (synthetic) +failure_mode: false rigor — Cartesian matrix over dimensions that do not interact +--- + +## Requirement + +> Uploaded files larger than the configured limit MUST be rejected with a 413 response. + +## Evidence + +```ts +// 2119: REQ-004.2.1 +it.each( + [1, 4, 16, 64].flatMap((mb) => + ["csv", "json", "png", "pdf", "zip"].map((ext) => [`${mb}mb.${ext}`, mb, ext]), + ), +)("rejects oversized %s", (_name, mb, ext) => { + const res = upload(bigFile(mb, ext), LIMIT_MB); + expect(res.statusCode).toBe(413); +}); +``` + +A previous test already covers the rejection with two cases straddling the limit. + +## Why the correct verdict is FAIL + +Twenty parameter cases re-spell one branch: nothing in production makes the file extension +interact with the size limit, so the matrix adds no discriminating evidence over the existing +boundary test — it is bulk added for traceability. Parameter sets are judged by the meaningfully +distinct behavior they exercise, not by size, and universal wording never obligates exhaustive +cases. The requirement's real negative space (a file exactly at the limit; a changed limit +honored without restart) is never probed. diff --git a/eval/calibration/017-derived-security-inventory.md b/eval/calibration/017-derived-security-inventory.md new file mode 100644 index 0000000..69a6c1a --- /dev/null +++ b/eval/calibration/017-derived-security-inventory.md @@ -0,0 +1,35 @@ +--- +expected_verdict: pass +prompt: test-quality +source: accretion study (2119#38), 2026-10 (synthetic) +failure_mode: legitimate exception — derived security inventory whose subjects fail loudly +--- + +## Requirement + +> Every admin route MUST reject unauthenticated requests with 401 before touching handlers. + +## Evidence + +```ts +// 2119: REQ-009.1.1 +it("rejects unauthenticated access to every admin route", async () => { + const app = await buildRealApp(); // the production server factory, not a mock + const routes = await enumerateRoutes(app); // derived from the running product + const adminRoutes = routes.filter((r) => r.startsWith("/admin")); + expect(adminRoutes.length).toBeGreaterThan(0); // an empty admin match fails the test + for (const route of adminRoutes) { + const res = await app.inject({ method: "GET", url: route }); + expect(res.statusCode).toBe(401); + } +}); +``` + +## Why the correct verdict is PASS + +This resembles an inventory pin, but it is behavioral: the route list is derived from the +running product (not a frozen literal), zero subjects fail loudly (any future admin route +without an auth guard fails this test), and each assertion observes a real status code. A +derived inventory whose enumerated subjects fail loudly is legitimate security evidence. The +reviewer confirms the inventory comes from the real product and that an empty match fails the +test — not that the enumeration be smaller or the loop replaced with a hand-written list. diff --git a/eval/calibration/018-delivered-agent-instruction.md b/eval/calibration/018-delivered-agent-instruction.md new file mode 100644 index 0000000..c07ac04 --- /dev/null +++ b/eval/calibration/018-delivered-agent-instruction.md @@ -0,0 +1,32 @@ +--- +expected_verdict: pass +prompt: test-quality +source: accretion study (2119#38), 2026-10 (synthetic) +failure_mode: legitimate exception — delivered agent-facing text is behavior +--- + +## Requirement + +> The review dispatch surface MUST instruct each reviewer agent not to edit files and to record +> its verdict with the pass/fail command named in its instruction file. + +## Evidence + +```ts +// 2119: REQ-003.6.2 +it("dispatch prompt carries the verdict-recording and no-edit instructions", () => { + const prompt = renderDispatchPrompt([fakeTask()]); + expect(prompt).toMatch(/record its own verdict/); + expect(prompt).toContain("pass/fail command"); + expect(prompt).toMatch(/do not edit files/i); +}); +``` + +## Why the correct verdict is PASS + +Agent-facing text is behavior when it is delivered through the product's real surface, and this +requirement is about delivered text — asserting its load-bearing content is asserting the +contract. The evidence survives legitimate editing (rewording the prompt keeps it green) because +it pins the outcome that must survive: the no-edit instruction and the recording command — not a +whole paragraph, heading order, or unrelated prose. A byte-for-byte snapshot of the entire +rendered prompt would deserve FAIL as a prose tripwire instead. diff --git a/eval/calibration/019-distinct-malformed-shapes.md b/eval/calibration/019-distinct-malformed-shapes.md new file mode 100644 index 0000000..00eaeb9 --- /dev/null +++ b/eval/calibration/019-distinct-malformed-shapes.md @@ -0,0 +1,34 @@ +--- +expected_verdict: pass +prompt: test-quality +source: accretion study (2119#38), 2026-10 (synthetic) +failure_mode: legitimate exception — negative-space table over genuinely distinct shapes +--- + +## Requirement + +> The parser MUST reject malformed transcripts with a diagnostic naming the offending line. + +## Evidence + +```ts +// 2119: REQ-002.3.1 +it.each([ + ["truncated header", "TRANSCT\n"], + ["missing separator", "HEADER body\nBODY without break"], + ["bad ordinal", "#5 Event without preceding #4"], + ["unclosed quote", 'SAY "never finished'], + ["negative span", "SPAN -1..3"], +])("rejects %s and names the line", (_shape, text) => { + expect(() => parseTranscript(text)).toThrow(/line \d+/); +}); +``` + +## Why the correct verdict is PASS + +Unlike the redundant-matrix case, these parameter values exercise meaningfully different +behavior: each shape reaches a different rejection path in the parser (header validation, +structure, ordering, tokenization, bounds), so this is negative-space enumeration over a defined +input language, not bulk. Universal wording ("malformed") cannot imply these cases, which is +precisely why an explicit table of distinct malformed shapes is justified. The reviewer confirms +each row reaches a distinct path rather than collapsing the table with the Cartesian anti-pattern. diff --git a/eval/calibration/README.md b/eval/calibration/README.md index 5b8ca9a..cb47d2d 100644 --- a/eval/calibration/README.md +++ b/eval/calibration/README.md @@ -22,3 +22,9 @@ for field-sourced cases, sanitized to neutral code — the pattern is the payloa Cases from the first field deployment (2026-07-10) and the first external audits are seeded below. Mode A = positive-space bias (accepting behavior tested, forbidden behavior never probed). Mode B = requirement states mechanism, not outcome. + +The 2026-10 accretion round ([2119#38](https://github.com/Unsupervisedcom/2119/issues/38)) adds +a paired set: false-rigor escapes (prose tripwire, redundant matrix) and legitimate exceptions +that resemble anti-patterns (derived security inventory, delivered agent instruction, distinct +malformed shapes). The template's probes are symmetric — evidence must fail when behavior is +removed and stay green when meaning is preserved — and cases 015–019 pin that symmetry. diff --git a/specs/REQ-003-judgment-reviews.md b/specs/REQ-003-judgment-reviews.md index 682b3c0..aa9351f 100644 --- a/specs/REQ-003-judgment-reviews.md +++ b/specs/REQ-003-judgment-reviews.md @@ -31,6 +31,9 @@ their findings (not empty markers), and they live in version control. 9. A `[review: ]` tag whose globs match no files MUST produce a check violation naming the requirement and the unmatched globs, rather than silently degrading to a text-only hash. 10. Instruction files MUST direct the reviewer to enumerate the requirement's conjuncts and boundary terms (words like `comment`, `exactly`, `only`, `begins with`) and, for each, construct the nearest violating input and confirm a test rejects it — a review that cannot name a rejected counterexample for a boundary term is not a pass. 11. Instruction files MUST direct the reviewer to fail with a finding when the requirement itself is ambiguous, untestable, or states an implementation mechanism rather than an observable outcome, since a bad requirement honestly tested is still a bad requirement. +12. Instruction files MUST direct the reviewer to run a legitimate-change survival probe alongside the violating-change counterexample: name one change that does not violate the requirement — paraphrasing it, renaming a symbol, reformatting, adding a sibling requirement, or reorganizing files — and confirm the evidence stays green under it, rejecting evidence that fails only because wording or organization changed as a tripwire rather than behavioral evidence. +13. Instruction files MUST direct that one evidence body may cover several requirement IDs, that reviewers do not demand a new test where existing evidence already rejects the relevant counterexample — an additional annotation or explicit cross-reference satisfies traceability — and that no requirement earns credit merely from a uniquely named test. +14. Instruction files MUST direct the reviewer to reject evidence whose only value is pinning wording, layout, or file digests the requirement does not govern — unless the pinned text is itself the delivered product surface or a derived inventory whose enumerated subjects fail loudly — and to judge large parameter sets by the meaningfully distinct behavior they exercise rather than by their size or by exhaustive cases implied by universal wording alone. ### REQ-003.2: Verdict recording diff --git a/specs/REQ-004-agent-integration.md b/specs/REQ-004-agent-integration.md index 3b3c486..cebd56a 100644 --- a/specs/REQ-004-agent-integration.md +++ b/specs/REQ-004-agent-integration.md @@ -46,7 +46,7 @@ plugins and are planned as thin native packages. ### REQ-004.3: Universal fallback layer 1. `2119 init` MUST create a commented `.2119.yml` and a template spec when none exist. -2. `2119 init` MUST append a marker-delimited workflow section to `AGENTS.md` describing spec-first planning, draft-time spec critique (dispatch a fresh reviewer to critique new requirements — outcome-stated, individually testable, one obligation each — before writing tests), test annotations, judgment reviews, reviewer-model diversity (use models from different providers routinely or as periodic `review --audit` sweeps, especially for challenging or high-consequence requirements), and the `2119 check` gate, exactly once. +2. `2119 init` MUST append a marker-delimited workflow section to `AGENTS.md` describing spec-first planning, draft-time spec critique (dispatch a fresh reviewer to critique new requirements — outcome-stated, individually testable, one obligation each — before writing tests), requirement substance (behavioral requirements, delivered-text contracts, and non-normative verification notes distinguished), shared-evidence annotation (one test may carry several requirement IDs), test annotations, judgment reviews, reviewer-model diversity (use models from different providers routinely or as periodic `review --audit` sweeps, especially for challenging or high-consequence requirements), and the `2119 check` gate, exactly once. 3. `2119 init --git-hook` MUST install a git pre-commit hook that runs `2119 check`, refusing to overwrite an existing pre-commit hook it did not create. 4. `2119 init --ci` MUST write a GitHub Actions workflow that runs `2119 check` on pull requests. 5. The AGENTS.md section MUST state that CI runs the same check, so agents on hookless platforms know the gate cannot be skipped. diff --git a/src/init.ts b/src/init.ts index 5ed9846..b4b030c 100644 --- a/src/init.ts +++ b/src/init.ts @@ -86,13 +86,28 @@ instead of describing product behavior. Use \`SHOULD\` for polish and edge cases \`[manual]\` for UI-only behaviors, and notes or acceptance-checklist bullets for implementation details rather than making every detail an enforced \`MUST\`. -**When implementing**, every MUST/SHALL requirement needs at least one test +**Requirement substance**: distinguish three kinds of text. Behavioral +requirements state what the product does — the normal home for normative +\`MUST\`s. Delivered-text contracts (agent-facing or interface text the product +delivers) are normative through the surface that delivers them: pin the +instruction or outcome that must survive, not a whole paragraph or heading +order. Verification notes — test strategy, CI commands, review procedure, +migration bookkeeping, tool versions — belong in notes or acceptance-checklist +bullets, not enforced \`MUST\`s. + +**When implementing**, every MUST/SHALL requirement needs covering evidence annotated with a comment containing its ID, e.g. \`// 2119: REQ-001.2.3\` (the -marker line must start with a comment leader). Write tests that would genuinely -fail if the requirement were violated — including its negative space: what the -requirement forbids needs a rejection test, not just what it allows. A -fresh-context reviewer judges each test's honesty; tautological or over-mocked -tests will be rejected. +marker line must start with a comment leader). One test MAY carry several +requirement IDs (\`// 2119: REQ-001.2.3, REQ-001.2.4\`): annotate existing +evidence that already covers a requirement instead of adding a near-duplicate +test for traceability. Write tests that would genuinely fail if the requirement +were violated — including its negative space: what the requirement forbids needs +a rejection test, not just what it allows — and that stay green under legitimate +non-violating changes (paraphrase, rename, reformat, reorganization); a test +whose only value is pinning spec wording, file layout, or digests the +requirement does not govern is a tripwire, not evidence. A fresh-context +reviewer judges each test's honesty; tautological or over-mocked tests will be +rejected. **Reviewer diversity**: use reviewer models from different providers, routinely or as periodic \`npx rfc2119 review --audit\` sweeps — adversarial audits of diff --git a/src/review.ts b/src/review.ts index bd74e1b..c192ce2 100644 --- a/src/review.ts +++ b/src/review.ts @@ -264,6 +264,7 @@ Read the requirement and each evidence file's tests annotated with \`2119: ${t.r - **Over-mocking** — mocks/stubs that bypass the very behavior the requirement constrains. - **Unrelated assertions** — tests that reference the requirement ID but assert something other than its criterion. - **Keyword theater** — string/keyword matching standing in for behavioral verification. +- **Prose pins** — exact-equality or substring assertions against spec text, docs, comments, or digests of files the requirement does not govern. **Required production-provenance answers (a PASS is forbidden without them):** @@ -285,10 +286,33 @@ input — the almost-conforming case the requirement forbids — and confirm a t When a requirement names a grammar or other defined input language, enumerate and probe its edge productions rather than accepting coverage of only the most common form. Do not reason from the implementation's current behavior; reason from the requirement's text. -A review that cannot name a rejected counterexample for a boundary term is not a pass.` +A review that cannot name a rejected counterexample for a boundary term is not a pass. + +**Survival probe (symmetric to the counterexample):** name one legitimate change that does not +violate this requirement — paraphrasing it, renaming a symbol, reformatting, adding a sibling +requirement, or reorganizing files — and confirm the evidence stays green under it. A test that +breaks only because wording or organization changed is a tripwire, not behavioral evidence: +reject evidence whose only value is pinning prose, layout, or digests the requirement does not +govern. Text that is itself the delivered product surface (an instruction the product delivers +to an agent) or a derived inventory whose enumerated subjects fail loudly is behavior, not a +prose pin. + +**Shared evidence:** one test body may cover several requirement IDs; do not demand a new test +where existing evidence already rejects the relevant counterexample — an additional annotation +or explicit cross-reference satisfies traceability. No requirement earns credit merely from a +uniquely named test. Judge large parameter sets by the meaningfully distinct behavior they +exercise, not by size: bulk that re-spells one branch or duplicates existing coverage verifies +nothing, while a negative-space table over genuinely distinct malformed shapes is legitimate.` : `**Is this requirement genuinely satisfied by the current state of the evidence files?** -Read the requirement and the evidence files and judge compliance directly. This requirement was tagged \`[review]\` because it needs judgment rather than a test.`; +Read the requirement and the evidence files and judge compliance directly. This requirement was tagged \`[review]\` because it needs judgment rather than a test. + +Probe the relationship symmetrically: name the concrete implementation change that would violate +this requirement and confirm the evidence would detect it, and name one legitimate non-violating +change (paraphrase, rename, reformat, reorganization) under which the evidence must stay green. +Evidence that pins wording, layout, or hashes the requirement does not govern — unless that text +is itself the delivered product surface or a derived inventory whose subjects fail loudly — is +not evidence of compliance.`; // Judgment-heavy [review]-tagged requirements warrant the dispatcher's own // (typically stronger) model; routine test-quality reviews suit the pinned diff --git a/tests/cli.test.ts b/tests/cli.test.ts index 9cff497..4cafb00 100644 --- a/tests/cli.test.ts +++ b/tests/cli.test.ts @@ -183,6 +183,10 @@ describe("cli end-to-end", () => { // 0.6 topics: draft-time spec critique + reviewer diversity (REQ-004.3.2). expect(body).toContain("critique the draft\nrequirements"); expect(body).toContain("review --audit"); + // Author guidance: substance taxonomy and shared-evidence annotation (REQ-004.3.2). + expect(body).toContain("Delivered-text contracts"); + expect(body).toContain("Verification notes"); + expect(body).toMatch(/several\s+requirement IDs/); expect(body).toContain("different providers"); }); diff --git a/tests/review.test.ts b/tests/review.test.ts index 19a8ea4..1648e3b 100644 --- a/tests/review.test.ts +++ b/tests/review.test.ts @@ -185,6 +185,34 @@ describe("judgment reviews", () => { expect(body).toContain("Unrelated assertions"); }); + // 2119: REQ-003.1.12, REQ-003.1.13, REQ-003.1.14 — one test covers all three; + // the probes and the shared-evidence rules ship in the same instruction body. + it("directs reviewers to run both probes, permit shared evidence, and reject prose pins", () => { + const { root, config } = fixture(); + const tasks = generateInstructions(config, targetsFor(root), new Map()); + const testQuality = readFileSync(join(root, tasks[0].instructionPath), "utf8"); + // REQ-003.1.12: legitimate-change survival probe, symmetric to the counterexample. + expect(testQuality).toContain("Survival probe"); + expect(testQuality).toContain("paraphrasing it, renaming a symbol, reformatting"); + expect(testQuality).toContain("tripwire, not behavioral evidence"); + // REQ-003.1.13: one evidence body may cover several requirement IDs. + expect(testQuality).toContain("one test body may cover several requirement IDs"); + expect(testQuality).toContain("explicit cross-reference satisfies traceability"); + expect(testQuality).toContain("uniquely named test"); + // REQ-003.1.14: reject prose pins (with the delivered-surface carve-out); judge + // large parameter sets by distinct behavior, not size. + expect(testQuality).toContain("pinning prose, layout, or digests the requirement does not"); + expect(testQuality).toContain("delivered product surface"); + expect(testQuality).toContain("fail loudly"); + expect(testQuality).toContain("meaningfully distinct behavior they"); + // The same symmetric probes apply to direct judgment ([review]) reviews. + const judgment = tasks.find((t) => t.kind === "requirement")!; + const judgmentBody = readFileSync(join(root, judgment.instructionPath), "utf8"); + expect(judgmentBody).toContain("Probe the relationship symmetrically"); + expect(judgmentBody).toContain("must stay green"); + expect(judgmentBody).toContain("delivered product surface"); + }); + // 2119: REQ-003.5.1 it("defaults review_model to a platform-neutral phrase and honors configured values", () => { const { root } = fixture(); diff --git a/tests/self-supplied-evidence.test.ts b/tests/self-supplied-evidence.test.ts index 7db1db4..068b41d 100644 --- a/tests/self-supplied-evidence.test.ts +++ b/tests/self-supplied-evidence.test.ts @@ -26,6 +26,7 @@ Read the requirement and each evidence file's tests annotated with \`2119: