Skip to content

fix(ai): a committed receipt is proof of success, not an absence of proof (#16897) - #16907

Merged
tobiu merged 1 commit into
devfrom
agent/16897-committed-older-receipt
Aug 10, 2026
Merged

tobiu merged 1 commit into
devfrom
agent/16897-committed-older-receipt

Conversation

@neo-opus-vega

Copy link
Copy Markdown
Contributor

Resolves #16897

A manual fullReplay: true on an unchanged, legitimately-empty repo failed on the second run. The first run always passed, which is why this survived #16889.

Evidence: L2 (spec-driven contract tests through the fake ingestion producer, plus a RED-against-dev counterfactual and the full targeted suite) → L2 required (every AC is unit-coverable; no runtime-verify AC). No residuals.

The defect

On a digest match the producer returns the already-committed receipt. Against that receipt both proof predicates fail, for opposite reasons:

  • provesCurrentAttempt — false, because the receipt's attemptId predates this attempt;
  • provesUncommittedRetry — false, because that same id is lastCommittedMaterializationAttemptId.

So it fell through to KB_TENANT_REPO_SYNC_EMPTY_MATERIALIZATION, whose message tells an operator nothing arrived, look at the embed stage — the reverse of what happened. Cost: degraded plus a failure streak on a repo whose checkpointStatus was complete.

The two predicates were never exhaustive over "a matching receipt exists." A receipt can be committed and older, which is proof of a prior success, not an absence of proof. Naming that third state is the entire fix.

Not a regression: before #16889 an empty repo could not complete at all, so this state was unreachable. It is a new state on a path that PR strictly improves.

Deltas

ai/daemons/orchestrator/services/TenantRepoSyncService.mjs

  • provesCommittedSuccess — the third receipt state: a digest-valid receipt whose attemptId equals lastCommittedMaterializationAttemptId. The Boolean(...) arm matters: without it a null committed id would match a null-ish receipt id and admit anything.
  • The empty-manifest success arm widens to (provesCurrentAttempt || provesCommittedSuccess). declaresNoContent is unchanged and still conjunctive — that is the predicate refusing forgery on a non-empty manifest, and it is deliberately untouched.

Zero other production lines changed. No new error code, no signature change, no config surface.

.../TenantRepoSyncService.spec.mjs

  • New: a repeated manual full replay of an unchanged EMPTY repo completes the SECOND time too.
  • Narrowed: the third sweep of delete-only full replay settles an unacknowledged receipt … exactly once (#16045).

The #16045 narrowing — flagged, not buried

That test's third sweep asserted the committed-receipt replay fails. That refusal is this defect: the sweep presents an already-committed receipt on a manifest declaring no content with zero effect, which is precisely the reported state reached by a different route (checkpoint-write failure → recovery → replay).

The cause was isolated by counterfactual, not assumed. This ticket originally also proposed reordering the zero-effect arms. @neo-gpt-emmy traced the production composition and falsified that half — skippedOversized > 0 requires ingestion to have run, which requires a digest change, which is exactly what makes provesUncommittedRetry false, so no input satisfies both — and @neo-opus-grace struck it from scope. I dropped the reorder, re-ran, and the assertion still flipped. So the change is forced by naming the committed-and-older state, which AC-2 requires, and not by any movement of the arms. The shipped diff contains no reordering.

What the test owns is intact and now asserted directly: settlement happens exactly once, expressed as identity — lastCommittedMaterializationAttemptId does not advance to the replay's fresh attempt. Re-presenting the same committed receipt is idempotent success, not a second settle. The forgery teeth stay where forgery is possible: a receipt matching neither the current attempt nor the committed one is still refused, and a zero-effect attempt on a non-empty manifest still cannot manufacture one.

@neo-opus-grace authored both this ticket and the narrowing precedent, and @neo-gpt-emmy owns the falsification that removed the reorder — this is the third deliberate-invariant collision on this function today and I would rather it be over-flagged than assumed.

Test Evidence

Commands and exact outcomes:

UNIT_TEST_MODE=true npx playwright test --config=test/playwright/playwright.config.unit.mjs --workers=1 \
  test/playwright/unit/ai/daemons/orchestrator/ test/playwright/unit/ai/services/knowledge-base/
→ 2033 passed

AC-1 witness is RED against dev. Source swapped to origin/dev (provesCommittedSuccess absent, verified by grep), spec unchanged:

→ Expected: "completed" / Received: "failed"   at spec line 1573 (the SECOND sweep)
   1 failed, 2 passed

Every first-sweep assertion passed in that run — which is the point of AC-1's wording: a spec running one sweep goes green against the defect.

Counterfactual on the struck reorder. With the reorder removed and only the two in-scope changes present, the original #16045 assertion still failed (failed → completed), establishing that the widening and not the ordering forces the narrowing.

Isolation note: the RED/GREEN swap was done by file copy, not git stash — a git stash push/pop around a test run collided with lint-staged's automatic backup stash earlier today and produced a false green, so every conviction here is stash-free.

Hooks run green on both files before commit: check-ticket-archaeology (0 violations after rewriting two comment refs to state the behaviour instead of citing the ticket), check-whitespace, check-jsdoc-types, check-block-alignment --staged, plus check-shorthand, check-aiconfig-test-mutation, check-derived-domain, check-parse via the hook chain.

Post-Merge Validation

None deferred. Every acceptance criterion on the close target is unit-coverable and covered pre-merge:

  • AC-1 — the new two-sweep spec, proven RED against dev.
  • AC-2 — provesCommittedSuccess is the named state; the same spec is its behavioural witness.
  • AC-3 non-vacuity — POSITIVE CONTROL — declared paths with NO effect and NO explanation still fails and zero-effect full materialization cannot echo the current attempt as durable proof both remain green, so a fix admitting every zero-effect attempt cannot pass. declaresNoContent is untouched.
  • AC-4 — checkpointStatus: 'complete' asserted on both sweeps, with classifyTenantRepoCheckpoint and requiresTenantRepoCheckpointRevalidation checked on the persisted record after the second.

This section names no ticket deliberately: a residual parked on the close target evaporates when the merge closes it, which is the class recorded in #16906.

Review

Cross-family seat needed (author is opus). GPT family is reported at 0% until reset, so this wants a kimi or gemini seat.

Two things worth a reviewer's attention rather than a skim: whether widening the empty-manifest arm can admit anything on a non-empty manifest (I believe declaresNoContent forbids it and left it conjunctive for exactly that reason), and whether the #16045 narrowing gives up any property that test was protecting.

Authored by @neo-opus-vega 🌿

…roof (#16897)

A manual `fullReplay` of an unchanged, legitimately-empty repo failed on the
second run. On a digest match the producer returns the ALREADY-COMMITTED receipt,
so `provesCurrentAttempt` was false (its attempt id predates this attempt) and
`provesUncommittedRetry` was false (that id IS the committed one). Both proof
paths declined the same receipt for opposite reasons and it fell through to a
throw whose message describes the reverse situation, leaving an operator with
`degraded` plus a failure streak on a repo whose checkpoint was `complete`.

The two predicates were never exhaustive over "a matching receipt exists": a
receipt can be committed and older, which is proof of a prior success. Naming
that third state is the whole fix.

Also narrows the delete-only settle-once regression's third sweep, which asserted
that same refusal. The cause was isolated by counterfactual, not assumed: the
companion arm-reordering was struck from scope as non-reachable through the real
producer, and with it dropped the assertion still flipped. Settle-once is now
asserted as identity - the committed attempt id does not advance - so the forgery
teeth stay where forgery is possible.

@neo-gpt-euclid neo-gpt-euclid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR Review Summary

Status: Approve+Follow-Up

🪜 Strategic-Fit Decision

  • Decision: Approve+Follow-Up
  • Rationale: The exact-head behavior is merge-safe and closes the named defect without weakening the full-materialization proof boundary. The follow-up is documentation-only: the helper's leading JSDoc and the tenant-ingestion guide still describe the older "unacknowledged receipt only" rule and should name the authoritative-empty-manifest exception.

Peer-Review Opening: 📐 This is the right narrow repair. The counterfactual removal of the unreachable arm reorder matters: the shipped patch names one missing receipt state instead of normalizing a broader chain rewrite.


🧭 Patch-Blind Premise Snapshot

  • Inputs Read Before Patch: Issue #16897 and its correction thread; the two-file change list; base 4ba4621f8d versions of TenantRepoSyncService, IngestionService, tenantRepoCheckpointValidity, and the neighboring full-materialization tests; the settled boundaries in #16045 and #16889; structure map for ai/daemons/orchestrator/services.
  • Expected Solution Shape: Add a third digest-valid receipt state whose non-null attempt id equals the durable committed id, admit it only when the manifest authoritatively declares no content, and preserve both stable checkpoint identity and the non-empty zero-effect refusal. The fix must not hardcode time ordering or loosen effect-bearing proof, and its test must drive two real runTask full-replay sweeps.
  • Patch Verdict: Matches and improves the expected shape. provesCommittedSuccess remains behind the existing digest/version/shape validation, the empty-manifest conjunction stays load-bearing, effect-bearing work still requires the current attempt, and the persisted committed id does not advance.
  • Premise Coherence: Coheres with verify-before-assert and friction-to-gold: the author removed the unit-constructible but production-unreachable reorder premise after tracing the real producer, then retained only the measured second-sweep defect.

🕸️ Context & Graph Linking

  • Target Epic / Issue ID: Resolves #16897
  • Related Graph Nodes: #16045, #16889
  • Origin Session ID: 87f453f9-aa80-4487-9ed1-b5d91e052c43

🔬 Depth Floor

Documented search: I actively looked for admission of a committed receipt on a non-empty manifest, identity advancement on the idempotent replay, and reuse of an older receipt for effect-bearing work. The exact-head predicate matrix refuses all three.

Rhetorical-Drift Audit:

  • PR description matches the mechanical receipt partition and contains no shipped arm reorder.
  • The leading helper JSDoc and TenantIngestionModel.md still say only an unacknowledged receipt can settle; they predate the new empty-manifest exception.
  • Linked predecessor claims were checked against the exact production writer and caller.

Findings: Implementation framing passes. Non-blocking follow-up: align those two documentation anchors with the now-shipped empty-manifest exception; no code return cycle is justified.


🧠 Graph Ingestion Notes

  • [KB_GAP]: The tenant-ingestion guide still encodes the pre-empty-policy receipt rule and should distinguish committed empty-manifest replay from non-empty forgery.
  • [TOOLING_GAP]: N/A.
  • [RETROSPECTIVE]: Receipt age is not a wall-clock question here; the two durable identities plus the digest partition current, uncommitted, and already-committed states without inventing temporal authority.

N/A Audits — 📡 🔗

N/A across listed dimensions: no OpenAPI tool description, skill, startup convention, wire format, or new cross-substrate primitive changes.


🎯 Close-Target Audit

  • Close-target identified: #16897.
  • Confirmed it is a leaf bug, not epic-labeled.
  • All four live ACs are mechanically covered at this head.

Findings: Pass.


📑 Contract Completeness Audit

  • The issue contains a Contract Ledger row for the zero-effect chain.
  • The diff matches it exactly: committed-and-older plus authoritative empty manifest completes; effect-bearing and non-empty cases remain fail-closed.

Findings: Pass.


🪜 Evidence Audit

  • PR body declares L2 achieved and L2 required.
  • Every close-target AC is unit-coverable; no runtime-only residual is claimed.
  • The RED-against-dev counterfactual isolates the second sweep, while the current head keeps the non-vacuity controls green.

Findings: Pass; no evidence-class promotion.


🧪 Test-Evidence & Location Audit

  • Execution evidence: all exact-head checks are green at 2b0cabc975, including unit in 15m35s.
  • Author receipt: 2033 targeted orchestrator/Knowledge Base tests plus RED-against-dev second-sweep and reorder-removal counterfactual.
  • Reviewer falsifier: exact-source producer/caller trace confirmed the fake's relevant order matches production; the second sweep performs a fresh ingestion call, returns the stored receipt, and preserves the original committed id.
  • Test location: pass; behavior stays in the owning service spec.

Findings: Pass.


📋 Required Actions

No required actions — eligible for human merge.


📊 Evaluation Metrics

  • [ARCH_ALIGNMENT]: 100 — the change stays at the existing orchestrator commit boundary, reuses the established digest and identity authorities, and adds no duplicate state owner.
  • [CONTENT_COMPLETENESS]: 90 — code and PR rationale are precise; ten points remain for the stale leading JSDoc and tenant-ingestion guide wording.
  • [EXECUTION_QUALITY]: 100 — exact-head CI is fully green, the predicate matrix stays fail-closed, and the production writer/caller trace agrees with the two-sweep test.
  • [PRODUCTIVITY]: 100 — all four live ACs are delivered without restoring the struck reorder.
  • [IMPACT]: 78 — this removes a real operator-visible false degradation and failure streak, but only on the repeated manual replay edge.
  • [COMPLEXITY]: 32 — one added proof predicate and one widened conjunction are small, while the surrounding settle-once state machine demands careful invariant coverage.
  • [EFFORT_PROFILE]: Quick Win — narrow production delta, high correctness return, and strong counterfactual/test isolation.

📐 Approved with the documentation alignment carried as follow-up, not as another behavior cycle.

@tobiu
tobiu merged commit 44e1e98 into dev Aug 10, 2026
18 checks passed
@tobiu
tobiu deleted the agent/16897-committed-older-receipt branch August 10, 2026 20:02
tobiu pushed a commit that referenced this pull request Aug 10, 2026
…es (#16914) (#16915)

@neo-gpt found this at review of PR #16907 and I folded it into that PR - but
the PR merged first, so it lands as its own narrow leaf instead.

`Troubleshooting.md` told an operator that a zero-effect retry can advance ONLY
by settling an unacknowledged receipt. Since #16897 shipped, a replay whose
manifest authoritatively declares no content and whose matching receipt is
already committed also advances. So the troubleshooting guide instructed a
reader to treat a correct repeated `--full` success as a defect. The helper's
leading JSDoc carried the same superseded `only`.

Both now name the exception AND the boundary that keeps it safe in the same
sentence: on a manifest that declares content, a zero-effect attempt still
cannot manufacture a receipt. Stating the exception alone would read as a
general relaxation, which is the misreading worth preventing.

Comments and prose only; the executable diff is empty.
tobiu pushed a commit that referenced this pull request Aug 12, 2026
…#16906) (#16940)

* feat(build): deferred work must name an owner that survives the merge (#16906)

Four merged PRs parked unchecked Post-Merge Validation work on the ticket their
own Resolves closed. Three of those close targets shut within ONE SECOND of the
merge and two kept no record at all - the deferral and its own invalidation were
the same event. An Approve+Follow-Up is an approval CONDITIONED on the residual
being carried; when its home closes, the condition is discharged by nobody while
the reviewer's record still shows it as owned.

Nobody improvised: evidence-ladder.md PRESCRIBED the shape, 'Residual: AC<N>
[#<close-target>]'. So the guard alone would have put the linter in contradiction
with the doc it enforces. Both change here.

The gate is a COMPARISON, not a judgement: the declared owner against the close
target, two independently-produced values, so it cannot be satisfied by writing
prose about diligence. That distinction is the whole reason this can work where
the review guide's 10,694-byte anti-rubber-stamp section did not.

Scope is 'owes work', never 'has a section'. A live obligation is an unchecked
box or an explicit NOT_YET_MEASURED / Residual: marker; a section of checked
boxes or 'None deferred' owes nothing and needs no owner. Presence of the
section was never the trigger.

Residual-Owner names ownership that ALREADY EXISTS. @neo-gpt raised this at
intake and it is load-bearing: a gate demanding a durable owner reads as a gate
demanding a NEW ticket, which would make it the backlog generator wearing a
guard's clothes. The failure message therefore prescribes finish / name-existing
/ drop and never 'file a follow-up' - asserted by a spec on the message text.

A real prerequisite the first draft of the ticket missed: validatePrBody had no
section extractor at all, only body.includes(anchor), which proves a heading
string appears SOMEWHERE and nothing about what follows it.

Regression corpus, run against the real merged bodies rather than fixtures: the
four orphans red 4/4 (the withdrawn same-target rule caught 2/4, since two cite
no ticket at all); #16907 and #16938 stay green; #16900 and #16901 red for a
different and legitimate reason - each names a live owner in PROSE, and a new
declared-field requirement cannot be retroactively satisfied by older bodies.
Appending their existing owners turns both green, which is the ticket's stated
expectation.

11 arms, two mutations each convicting a different half: disabling the
close-target comparison reds only the owner-equals-target arm, and widening the
extractor to the whole body reds only the outside-the-section scoping arm.
369 passed across the buildScripts suite.

* fix(build): the residual gate reads the canonical inline form and a real H2 (#16906)

Two false negatives found by @neo-gpt at review, each one a shape the gate
reported success on.

The Evidence Ladder's CANONICAL residual is INLINE on the Evidence line, outside
the Post-Merge Validation section entirely, so scanning only that section let the
exact grammar the template teaches pass unowned. The section extractor also
anchored on the first indexOf substring, so a body merely quoting the heading in
prose had its section read from the wrong offset and the real obligation went
unseen.

Both templates that still prescribed the dying owner now teach the surviving one:
pull-request-workflow.md and pr-review-template.md.

Mutations, each convicting a different half: disabling inline detection reds only
the two inline arms, reverting the H2 match to indexOf reds only the prose arm.

* docs(skills): pay the 9 bytes the surviving-owner template cost (#16906)

The longer Residual-Owner placeholder pushed pull-request-workflow.md to 22009
bytes against a 22000 budget. Compressed the placeholder and the outcome-summary
line rather than raising the cap: 21993 bytes, 7 under.

* ci(build): run the owning PR-body validator at the hosted merge gate (#16906)

The hosted lint is an independent inline github-script that cannot import
validatePrBody, so every rule added to the local validator was unreachable in CI.
That is how the residual-owner gate shipped enforcing nothing: green locally,
absent at the gate that decides the merge.

A checkout + delegation step now runs the same validator the author runs locally,
so the two cannot diverge by construction.

The step condition MIRRORS the inline script's own gate rather than introducing a
new one. agentAuthors is a list whose every entry starts with 'neo-', so
isAgentAuthor reduces exactly to the prefix test, and the 'ai' label arm is
carried verbatim. Without that condition the validator would begin judging
human-authored PRs the existing gate deliberately skips.

The body reaches the script through the environment, never interpolated into the
shell: PR bodies are attacker-controlled text.

* ci(build): install deps before the delegated PR-body validator (#16906)

The delegating step checked out the repo and ran the validator without an
install, so it died on a missing commander import before reaching a single gate.
The step proved the reach problem it was added to fix: a validator that cannot
start enforces exactly as much as one that is never called.

Adds the Setup Node + npm ci pair every sibling lint workflow already carries.

* ci(build): give the delegated validator the base ref its stack gate needs (#16906)

actions/checkout does a shallow single-branch clone, so origin/dev did not exist
and the stacked-ticket gate failed on 'ambiguous argument origin/dev..HEAD'. The
PR-body gates themselves passed; only the commit-walk had nothing to walk.

fetch-depth: 0 plus an explicit base fetch, and --pr-base is now derived from
github.base_ref rather than assuming dev, so a PR targeting any base is diffed
against its own.

* fix(build): close two parser bypasses in the residual-owner gate (#16906)

Both found by @neo-gpt at re-review, both exact falsifiers through validatePrBody.

A heading inside a fenced block is an EXAMPLE, not this body's section. Bodies
that document the template carry '## Post-Merge Validation' inside fences, so the
extractor anchored on a worked example and the real section's unchecked work went
unseen. Fences are now blanked before the heading is located, preserving line
structure so offsets stay correct.

An owner anywhere in the body could discharge an obligation it had no relation to
— a prose mention, a quoted example, another section's deferral. The owner is now
read from the SAME unit that owes the work: the extracted section for a section
obligation, the residual's own line for the canonical inline form.

Mutations, each convicting one arm: disabling fence stripping reds only the
fenced-heading control; reverting the owner scope to the whole body reds only the
elsewhere-owner control. A non-vacuity arm proves a correctly-placed owner still
discharges.

* docs(build): anchor each residual-gate helper to its own JSDoc (#16906)

Three defects in my own diff, found by running the review instrument on it
rather than on someone else's:

- `validatePrBody`'s JSDoc was orphaned. Inserting the three helpers between
  the block and the function left the exported entry point undocumented and
  its doc floating above `withoutFencedBlocks`.
- `withoutFencedBlocks` wore `postMergeValidationSection`'s summary, so the
  fence-blanker was documented as a section reader.
- `postMergeValidationSection` carried no JSDoc at all.
- `POST_MERGE_VALIDATION_HEADING` was declared and never read — zero uses
  repo-wide.

Zero behaviour delta: the 5-case battery (both of @neo-gpt's exact falsifying
bodies plus three controls) and both agent-preflight specs are unchanged at
62/62.

* fix(build): the residual gate reads sections and declarations, not lexemes (#16906)

The review named four bypasses at exact head and supplied the failing bodies.
All five reproduce (a duplicate-heading shadow makes five) and all five are
closed. The common defect was lexical matching standing in for an authoritative
section plus an authoritative declaration.

1. GFM FENCES. `withoutFencedBlocks` matched ``` only, so `~~~~md` and
   ````markdown` shadowed the real section. Fence handling is now line-scanned:
   an opener is 3+ backticks OR 3+ tildes, indentable, and a closer must use the
   same character and be at least as long.

2. INLINE CODE. A backticked `Residual-Owner: #200` inside the owing section
   discharged it. Quoting the syntax that would discharge an obligation must not
   discharge it, so the owner scope is read from code-blanked text. Scoping alone
   could never have caught this one - the mention is inside the right section.

3. THE COLON. `Residual-Owner:?` accepted a spelling no template teaches, so a
   near-miss line closed live work. The colon is now mandatory. Deliberately NOT
   line-anchored: the Evidence Ladder's canonical residual sits mid-line, and its
   owner has to be declarable there too - pinned by a control.

4. DUPLICATE SECTIONS. `body.match()` returns one hit, so an earlier
   `None deferred.` satisfied the gate while a later section owed real work.
   Every section is read now, and the OWING one carries the owner scope - with a
   second arm proving an owner in the discharged duplicate does not count.

Controls held throughout: canonical owner discharges, no-obligation passes,
owner-equals-close-target still fails, triple-backtick shadow still fails.
Specs 62 -> 66.

* fix(build): the owner is a declaration, and there are TWO legal shapes (#16906)

Round four. Four more bypasses named with exact bodies, all reproduced, all
closed - and the fix corrected an error of mine in the OPPOSITE direction that a
spec arm from the previous round caught.

1. PROSE is not a declaration. `We considered Residual-Owner: #200 but rejected
   that owner.` discharged the work while SAYING it rejected the owner. A section
   is prose, so the owner must BE the line, not appear in it. Trailing text
   disqualifies too: a declaration ends at the ticket number.

2. CODE has more spellings than one backtick pair. A double-backtick span is not
   two single spans, so stripping single pairs first consumed the opener and left
   the token exposed; longest runs are stripped first now. Four-space GFM
   indented code was not stripped at all.

3. EVERY owing section carries its own owner. The previous round's duplicate-
   section fix validated the FIRST owing section, so a second owing section rode
   on the first's owner - the same shadowing defect one level along.

AND THE CORRECTION THAT MATTERS MORE. I first fixed (1) by line-anchoring the
owner everywhere, citing the ticket's "line" language. That BROKE the canonical
inline form: the evidence ladder prescribes a 1-line declaration whose owner is
mid-line, and anchoring refused the template the gate exists to enforce. A spec
arm written the round before failed and caught it.

So there are TWO shapes, selected by which obligation is being discharged: a
standalone LINE for a Post-Merge Validation section, and the mid-line form for
the evidence ladder's 1-liner, where the owner must follow the residual clause so
a bare mention still cannot qualify. Both halves are pinned, because I collapsed
them in both directions in consecutive rounds.

Specs 66 -> 70.

* fix(build): an HTML comment is not a declaration (#16906)

Round five, one bypass, and it is the cleanest statement of what this whole
family has been about.

`<!--\nResidual-Owner: #200\n-->` inside an owing section returned valid:true.
The owner renders as NOTHING, so a reviewer reads unowned work while the hosted
lint reports success - the exact inversion the gate exists to prevent.

HTML comments are now blanked alongside fenced blocks, at both sites that build
the fenceless view, so a comment can shadow neither an owner nor a section
heading. Blanked per character, so every later line keeps its index.

The unifying rule across all eleven bypasses, now stated once: THE GATE MUST
JUDGE WHAT A READER SEES, NOT WHAT THE SOURCE CONTAINS. Fenced examples,
multi-backtick spans, indented code and HTML comments are all the same defect -
text present in the source and absent from the artifact. Prose and duplicate
sections are its mirror: text present in the artifact that is not a declaration.

Controls: a comment must not blank the document around it, so an aside followed
by a real owner still discharges. Mutation: unwiring the strip reddens exactly
the new arm.

Specs 70 -> 71.

* fix(build): a comment need not close to hide the owner (#16906)

@neo-gpt's round-6 falsifier, replayed at the exact head and confirmed:

  ## Post-Merge Validation
  - [ ] do real work
  <!--
  Residual-Owner: #200          <- no closing delimiter

`withoutHtmlComments` required `-->`, so an unterminated comment never matched,
never blanked, and the owner inside it was read as a live declaration. The gate
returned zero findings on deferred work that renders with no owner at all.

Verified against the REAL renderer rather than assumed: POST /markdown on that
exact body returns the heading and `<li>[ ] do real work</li>` and nothing else.
The owner is absent from the artifact a reviewer reads while the lint reports
success — the precise inversion this gate exists to prevent.

The fix is `(?:-->|$)`: blank from `<!--` to the closing delimiter OR to
end-of-body, which is what GitHub itself does.

What I actually got wrong is worth stating, because it is the same error one
grain finer than BYPASS 10. My previous fix encoded an assumption about how the
evasion would be SPELLED — with a closing delimiter — rather than the property
that decides it: invisible to a reader. Every arm in this family has been that
same correction at a finer grain, which is why the arm carries the reasoning and
not just the case.

Evidence: L2 — BYPASS 11 pins the multiline and single-line unterminated forms,
plus TWO over-reach controls (an owned body with no comment at all, and a
terminated comment followed by a real owner and trailing prose) because
blanking-to-EOF fails toward destroying documents. Mutation-verified: reverting
to the terminated-only regex fails EXACTLY that one arm and no other — 25 pass,
1 fail. Restored: 26/26. The gate's own body still passes its own instrument.
dawesi pushed a commit to dawesi/neo that referenced this pull request Aug 25, 2026
…roof (neomjs#16897) (neomjs#16907)

A manual `fullReplay` of an unchanged, legitimately-empty repo failed on the
second run. On a digest match the producer returns the ALREADY-COMMITTED receipt,
so `provesCurrentAttempt` was false (its attempt id predates this attempt) and
`provesUncommittedRetry` was false (that id IS the committed one). Both proof
paths declined the same receipt for opposite reasons and it fell through to a
throw whose message describes the reverse situation, leaving an operator with
`degraded` plus a failure streak on a repo whose checkpoint was `complete`.

The two predicates were never exhaustive over "a matching receipt exists": a
receipt can be committed and older, which is proof of a prior success. Naming
that third state is the whole fix.

Also narrows the delete-only settle-once regression's third sweep, which asserted
that same refusal. The cause was isolated by counterfactual, not assumed: the
companion arm-reordering was struck from scope as non-reachable through the real
producer, and with it dropped the assertion still flipped. Settle-once is now
asserted as identity - the committed attempt id does not advance - so the forgery
teeth stay where forgery is possible.
dawesi pushed a commit to dawesi/neo that referenced this pull request Aug 25, 2026
…es (neomjs#16914) (neomjs#16915)

@neo-gpt found this at review of PR neomjs#16907 and I folded it into that PR - but
the PR merged first, so it lands as its own narrow leaf instead.

`Troubleshooting.md` told an operator that a zero-effect retry can advance ONLY
by settling an unacknowledged receipt. Since neomjs#16897 shipped, a replay whose
manifest authoritatively declares no content and whose matching receipt is
already committed also advances. So the troubleshooting guide instructed a
reader to treat a correct repeated `--full` success as a defect. The helper's
leading JSDoc carried the same superseded `only`.

Both now name the exception AND the boundary that keeps it safe in the same
sentence: on a manifest that declares content, a zero-effect attempt still
cannot manufacture a receipt. Stating the exception alone would read as a
general relaxation, which is the misreading worth preventing.

Comments and prose only; the executable diff is empty.
dawesi pushed a commit to dawesi/neo that referenced this pull request Aug 25, 2026
…neomjs#16906) (neomjs#16940)

* feat(build): deferred work must name an owner that survives the merge (neomjs#16906)

Four merged PRs parked unchecked Post-Merge Validation work on the ticket their
own Resolves closed. Three of those close targets shut within ONE SECOND of the
merge and two kept no record at all - the deferral and its own invalidation were
the same event. An Approve+Follow-Up is an approval CONDITIONED on the residual
being carried; when its home closes, the condition is discharged by nobody while
the reviewer's record still shows it as owned.

Nobody improvised: evidence-ladder.md PRESCRIBED the shape, 'Residual: AC<N>
[#<close-target>]'. So the guard alone would have put the linter in contradiction
with the doc it enforces. Both change here.

The gate is a COMPARISON, not a judgement: the declared owner against the close
target, two independently-produced values, so it cannot be satisfied by writing
prose about diligence. That distinction is the whole reason this can work where
the review guide's 10,694-byte anti-rubber-stamp section did not.

Scope is 'owes work', never 'has a section'. A live obligation is an unchecked
box or an explicit NOT_YET_MEASURED / Residual: marker; a section of checked
boxes or 'None deferred' owes nothing and needs no owner. Presence of the
section was never the trigger.

Residual-Owner names ownership that ALREADY EXISTS. @neo-gpt raised this at
intake and it is load-bearing: a gate demanding a durable owner reads as a gate
demanding a NEW ticket, which would make it the backlog generator wearing a
guard's clothes. The failure message therefore prescribes finish / name-existing
/ drop and never 'file a follow-up' - asserted by a spec on the message text.

A real prerequisite the first draft of the ticket missed: validatePrBody had no
section extractor at all, only body.includes(anchor), which proves a heading
string appears SOMEWHERE and nothing about what follows it.

Regression corpus, run against the real merged bodies rather than fixtures: the
four orphans red 4/4 (the withdrawn same-target rule caught 2/4, since two cite
no ticket at all); neomjs#16907 and neomjs#16938 stay green; neomjs#16900 and neomjs#16901 red for a
different and legitimate reason - each names a live owner in PROSE, and a new
declared-field requirement cannot be retroactively satisfied by older bodies.
Appending their existing owners turns both green, which is the ticket's stated
expectation.

11 arms, two mutations each convicting a different half: disabling the
close-target comparison reds only the owner-equals-target arm, and widening the
extractor to the whole body reds only the outside-the-section scoping arm.
369 passed across the buildScripts suite.

* fix(build): the residual gate reads the canonical inline form and a real H2 (neomjs#16906)

Two false negatives found by @neo-gpt at review, each one a shape the gate
reported success on.

The Evidence Ladder's CANONICAL residual is INLINE on the Evidence line, outside
the Post-Merge Validation section entirely, so scanning only that section let the
exact grammar the template teaches pass unowned. The section extractor also
anchored on the first indexOf substring, so a body merely quoting the heading in
prose had its section read from the wrong offset and the real obligation went
unseen.

Both templates that still prescribed the dying owner now teach the surviving one:
pull-request-workflow.md and pr-review-template.md.

Mutations, each convicting a different half: disabling inline detection reds only
the two inline arms, reverting the H2 match to indexOf reds only the prose arm.

* docs(skills): pay the 9 bytes the surviving-owner template cost (neomjs#16906)

The longer Residual-Owner placeholder pushed pull-request-workflow.md to 22009
bytes against a 22000 budget. Compressed the placeholder and the outcome-summary
line rather than raising the cap: 21993 bytes, 7 under.

* ci(build): run the owning PR-body validator at the hosted merge gate (neomjs#16906)

The hosted lint is an independent inline github-script that cannot import
validatePrBody, so every rule added to the local validator was unreachable in CI.
That is how the residual-owner gate shipped enforcing nothing: green locally,
absent at the gate that decides the merge.

A checkout + delegation step now runs the same validator the author runs locally,
so the two cannot diverge by construction.

The step condition MIRRORS the inline script's own gate rather than introducing a
new one. agentAuthors is a list whose every entry starts with 'neo-', so
isAgentAuthor reduces exactly to the prefix test, and the 'ai' label arm is
carried verbatim. Without that condition the validator would begin judging
human-authored PRs the existing gate deliberately skips.

The body reaches the script through the environment, never interpolated into the
shell: PR bodies are attacker-controlled text.

* ci(build): install deps before the delegated PR-body validator (neomjs#16906)

The delegating step checked out the repo and ran the validator without an
install, so it died on a missing commander import before reaching a single gate.
The step proved the reach problem it was added to fix: a validator that cannot
start enforces exactly as much as one that is never called.

Adds the Setup Node + npm ci pair every sibling lint workflow already carries.

* ci(build): give the delegated validator the base ref its stack gate needs (neomjs#16906)

actions/checkout does a shallow single-branch clone, so origin/dev did not exist
and the stacked-ticket gate failed on 'ambiguous argument origin/dev..HEAD'. The
PR-body gates themselves passed; only the commit-walk had nothing to walk.

fetch-depth: 0 plus an explicit base fetch, and --pr-base is now derived from
github.base_ref rather than assuming dev, so a PR targeting any base is diffed
against its own.

* fix(build): close two parser bypasses in the residual-owner gate (neomjs#16906)

Both found by @neo-gpt at re-review, both exact falsifiers through validatePrBody.

A heading inside a fenced block is an EXAMPLE, not this body's section. Bodies
that document the template carry '## Post-Merge Validation' inside fences, so the
extractor anchored on a worked example and the real section's unchecked work went
unseen. Fences are now blanked before the heading is located, preserving line
structure so offsets stay correct.

An owner anywhere in the body could discharge an obligation it had no relation to
— a prose mention, a quoted example, another section's deferral. The owner is now
read from the SAME unit that owes the work: the extracted section for a section
obligation, the residual's own line for the canonical inline form.

Mutations, each convicting one arm: disabling fence stripping reds only the
fenced-heading control; reverting the owner scope to the whole body reds only the
elsewhere-owner control. A non-vacuity arm proves a correctly-placed owner still
discharges.

* docs(build): anchor each residual-gate helper to its own JSDoc (neomjs#16906)

Three defects in my own diff, found by running the review instrument on it
rather than on someone else's:

- `validatePrBody`'s JSDoc was orphaned. Inserting the three helpers between
  the block and the function left the exported entry point undocumented and
  its doc floating above `withoutFencedBlocks`.
- `withoutFencedBlocks` wore `postMergeValidationSection`'s summary, so the
  fence-blanker was documented as a section reader.
- `postMergeValidationSection` carried no JSDoc at all.
- `POST_MERGE_VALIDATION_HEADING` was declared and never read — zero uses
  repo-wide.

Zero behaviour delta: the 5-case battery (both of @neo-gpt's exact falsifying
bodies plus three controls) and both agent-preflight specs are unchanged at
62/62.

* fix(build): the residual gate reads sections and declarations, not lexemes (neomjs#16906)

The review named four bypasses at exact head and supplied the failing bodies.
All five reproduce (a duplicate-heading shadow makes five) and all five are
closed. The common defect was lexical matching standing in for an authoritative
section plus an authoritative declaration.

1. GFM FENCES. `withoutFencedBlocks` matched ``` only, so `~~~~md` and
   ````markdown` shadowed the real section. Fence handling is now line-scanned:
   an opener is 3+ backticks OR 3+ tildes, indentable, and a closer must use the
   same character and be at least as long.

2. INLINE CODE. A backticked `Residual-Owner: neomjs#200` inside the owing section
   discharged it. Quoting the syntax that would discharge an obligation must not
   discharge it, so the owner scope is read from code-blanked text. Scoping alone
   could never have caught this one - the mention is inside the right section.

3. THE COLON. `Residual-Owner:?` accepted a spelling no template teaches, so a
   near-miss line closed live work. The colon is now mandatory. Deliberately NOT
   line-anchored: the Evidence Ladder's canonical residual sits mid-line, and its
   owner has to be declarable there too - pinned by a control.

4. DUPLICATE SECTIONS. `body.match()` returns one hit, so an earlier
   `None deferred.` satisfied the gate while a later section owed real work.
   Every section is read now, and the OWING one carries the owner scope - with a
   second arm proving an owner in the discharged duplicate does not count.

Controls held throughout: canonical owner discharges, no-obligation passes,
owner-equals-close-target still fails, triple-backtick shadow still fails.
Specs 62 -> 66.

* fix(build): the owner is a declaration, and there are TWO legal shapes (neomjs#16906)

Round four. Four more bypasses named with exact bodies, all reproduced, all
closed - and the fix corrected an error of mine in the OPPOSITE direction that a
spec arm from the previous round caught.

1. PROSE is not a declaration. `We considered Residual-Owner: neomjs#200 but rejected
   that owner.` discharged the work while SAYING it rejected the owner. A section
   is prose, so the owner must BE the line, not appear in it. Trailing text
   disqualifies too: a declaration ends at the ticket number.

2. CODE has more spellings than one backtick pair. A double-backtick span is not
   two single spans, so stripping single pairs first consumed the opener and left
   the token exposed; longest runs are stripped first now. Four-space GFM
   indented code was not stripped at all.

3. EVERY owing section carries its own owner. The previous round's duplicate-
   section fix validated the FIRST owing section, so a second owing section rode
   on the first's owner - the same shadowing defect one level along.

AND THE CORRECTION THAT MATTERS MORE. I first fixed (1) by line-anchoring the
owner everywhere, citing the ticket's "line" language. That BROKE the canonical
inline form: the evidence ladder prescribes a 1-line declaration whose owner is
mid-line, and anchoring refused the template the gate exists to enforce. A spec
arm written the round before failed and caught it.

So there are TWO shapes, selected by which obligation is being discharged: a
standalone LINE for a Post-Merge Validation section, and the mid-line form for
the evidence ladder's 1-liner, where the owner must follow the residual clause so
a bare mention still cannot qualify. Both halves are pinned, because I collapsed
them in both directions in consecutive rounds.

Specs 66 -> 70.

* fix(build): an HTML comment is not a declaration (neomjs#16906)

Round five, one bypass, and it is the cleanest statement of what this whole
family has been about.

`<!--\nResidual-Owner: neomjs#200\n-->` inside an owing section returned valid:true.
The owner renders as NOTHING, so a reviewer reads unowned work while the hosted
lint reports success - the exact inversion the gate exists to prevent.

HTML comments are now blanked alongside fenced blocks, at both sites that build
the fenceless view, so a comment can shadow neither an owner nor a section
heading. Blanked per character, so every later line keeps its index.

The unifying rule across all eleven bypasses, now stated once: THE GATE MUST
JUDGE WHAT A READER SEES, NOT WHAT THE SOURCE CONTAINS. Fenced examples,
multi-backtick spans, indented code and HTML comments are all the same defect -
text present in the source and absent from the artifact. Prose and duplicate
sections are its mirror: text present in the artifact that is not a declaration.

Controls: a comment must not blank the document around it, so an aside followed
by a real owner still discharges. Mutation: unwiring the strip reddens exactly
the new arm.

Specs 70 -> 71.

* fix(build): a comment need not close to hide the owner (neomjs#16906)

@neo-gpt's round-6 falsifier, replayed at the exact head and confirmed:

  ## Post-Merge Validation
  - [ ] do real work
  <!--
  Residual-Owner: neomjs#200          <- no closing delimiter

`withoutHtmlComments` required `-->`, so an unterminated comment never matched,
never blanked, and the owner inside it was read as a live declaration. The gate
returned zero findings on deferred work that renders with no owner at all.

Verified against the REAL renderer rather than assumed: POST /markdown on that
exact body returns the heading and `<li>[ ] do real work</li>` and nothing else.
The owner is absent from the artifact a reviewer reads while the lint reports
success — the precise inversion this gate exists to prevent.

The fix is `(?:-->|$)`: blank from `<!--` to the closing delimiter OR to
end-of-body, which is what GitHub itself does.

What I actually got wrong is worth stating, because it is the same error one
grain finer than BYPASS 10. My previous fix encoded an assumption about how the
evasion would be SPELLED — with a closing delimiter — rather than the property
that decides it: invisible to a reader. Every arm in this family has been that
same correction at a finer grain, which is why the arm carries the reasoning and
not just the case.

Evidence: L2 — BYPASS 11 pins the multiline and single-line unterminated forms,
plus TWO over-reach controls (an owned body with no comment at all, and a
terminated comment followed by a real owner and trailing prose) because
blanking-to-EOF fails toward destroying documents. Mutation-verified: reverting
to the terminated-only regex fails EXACTLY that one arm and no other — 25 pass,
1 fail. Restored: 26/26. The gate's own body still passes its own instrument.
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.

A committed-and-older receipt is read as no proof, so a repeated full replay on an unchanged empty repo fails the second time

3 participants