Skip to content

feat(ci): a deferred ledger annotation, enforced so it cannot retire work - #812

Merged
athvin merged 3 commits into
mainfrom
issue/810-deferred-vocabulary
Nov 7, 2026
Merged

athvin merged 3 commits into
mainfrom
issue/810-deferred-vocabulary

Conversation

@athvin

@athvin athvin commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Closes #810

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

The second half of #810: a third ledger annotation, deferred — #<ticket>, with
a check so it cannot become a way to make work disappear. The first half — the
promotion — is already done: pull request contract is now the 15th required
context.

Why

#809's ledger was the first one ever closed, and the #756 sweep it recorded fit
neither annotation: n/a was false (the work was real) and blocked was false
(nothing blocked it — another ticket owned it). It got n/a, which blurs the
one invariant the mechanism rests on: an empty box means exactly one thing.

Proof

make pr-contract-check → 29 assertions, 0 failed, 7 of them new. The regrouped
scan reproduces #809's real closed ledger exactly: 12 boxes, 0 unticked, 0
loose. workflow-shell-check, scripts-home-check, actionlint and
skills-check green; regen produced no diff.

Risk & rollback

Risk is confined to the classifier's box-counting, which the audit and the gate
both read. The real-ledger regression above is the mitigation: a grouping bug
would have changed #809's numbers. Rollback: revert — the annotation is additive,
and nothing in the tree requires it.

Post-merge ledger

Closed by: agent · session 4bc5a8d3-968f-421f-97af-274d64ddb944 on brians-MacBook-Pro · 2026-11-07T21:57:10Z

Specific to this change

  • the first pull request contract merge as a REQUIRED context — it
    gated rather than merely reported: pull request contract is index 14
    of the 15 required contexts, and its latest check-run on 64a47342
    concluded success. The PR loop's own exit condition confirms the other
    side — missing=[] was computed by diffing the satisfied set against the
    live 15-context required set, so the new context had to be satisfied for
    the loop to exit at all.
  • re-ran pr-ledger-audit.sh against the SHIPPED classifier — not the
    local copy. Extracted scripts/ci/pr-contract.sh from origin/main at
    2ea5021e and scanned feat(ci): a pull request contract — a ticket, and a post-merge ledger #809's real closed ledger with it:
    boxes=12 unticked=0 loose=0 status=ok — identical to the pre-change
    reading. That is the regression that mattered, since this PR rewrote the
    box-counting both the gate and the audit depend on.
Context — plan, discoveries, measurements, files

Plan

  1. Promote pull request contract to required (done before this PR — not a
    code change, so it could not be part of one).
  2. Add deferred — #<ticket> to land-pr Phase 4, the template comment and
    CLAUDE.md, with the tick/empty asymmetry stated rather than implied.
  3. Make it checkable: group each box with its continuation lines, count ticked
    deferrals that name no ticket, surface them in the audit as LOOSE-DEFER.
  4. Correct every "not required yet" claim in the tree.

Discoveries

  • The sweep precondition resolved itself. The refactor(dispatcher): delete the legacy in-process dispatch arm (#645) #756 session added a ledger
    after being notified rather than needing its body rewritten, and ci(bluegreen): run the two-colour cutover acceptance criterion in ci (#656) #811 was
    opened straight from the template — so both open PRs passed before the
    promotion, and I confirmed it per-PR with the classifier rather than assuming.
  • mergeStateStatus cannot tell you what blocks a PR. Both open PRs read
    BLOCKED immediately after the PATCH; neither was blocked by the new context
    — each was waiting on its own Rust jobs. Only diffing the satisfied set
    against the required set answers it.
  • The required_status_checks endpoint replaces the list. The 14 existing
    contexts had to be read, kept with their app_id, and re-sent; the script
    asserted the old set was preserved verbatim before PATCHing.
  • A short read hides a new field. Adding loose as the scan's fifth
    output silently folded it into the fourth variable, breaking a self-test
    assertion rather than any code. Every caller now reads five, and the function
    doc says why.

Measurements

Files

File Role
scripts/ci/pr-contract.sh box grouping; pr_ledger_loose_deferrals
scripts/ci/pr-contract-test.sh 7 new assertions, incl. the wrapped-line cases
scripts/ci/pr-ledger-audit.sh reports LOOSE-DEFER (k) beside OPEN (k)
.claude/skills/land-pr/SKILL.md Phase 4's annotations, and why only one leaves a box empty
.claude/skills/ci-and-supply-chain/SKILL.md the promotion order, as the reusable part
.github/pull_request_template.md the three annotations, in the agent-facing comment
.github/workflows/pr-contract.yml the header no longer claims it is unrequired
CLAUDE.md the convention, corrected

…e work

Found by USING the ledger rather than reading it: #809's was the first one ever
closed, and the #756 sweep it recorded fitted neither annotation. `n/a` was
false (the work was real) and `blocked` was false (nothing blocked it — another
ticket owned it). It got `n/a` with the reason spelled out, which blurred the
distinction the whole mechanism rests on: an empty box means exactly one thing,
and that is only true while every other outcome has somewhere else to go.

So there are three annotations now, and the asymmetry is the design:

  n/a — <why>            ticks   the item does not apply
  deferred — #<ticket>   ticks   real work, owned by a filed ticket
  blocked — <why>        EMPTY   could not be established; goes in the report

`deferred` is the only one with a syntactic requirement, and it needs one: it
TICKS the box, so a deferral naming no ticket would be the way to retire an
item into nothing — strictly worse than the unticked box it replaces.
`pr_ledger_scan` therefore counts them, and `pr-ledger-audit.sh` reports
`LOOSE-DEFER (k)` separately from `OPEN (k)` because the remedy differs: file
the ticket, do not do the work.

Making that checkable needed the scan to group each box with its CONTINUATION
LINES, since the annotation usually lands on a wrapped line — a per-line test
would see the tick and the ticket separately and could not relate them. The
regrouped scan reproduces #809's real ledger exactly (12 boxes, 0 unticked, 0
loose, and its one ticked box containing the word "deferred" passes because it
names #810).

The self-test earned its place twice here. It caught that adding a fifth field
to the scan broke an assertion through a short `read` folding the trailing
fields into one variable — so every caller now reads all five, and the function
doc says why.

Also corrects what is now false everywhere it was stated: `pull request
contract` IS a required context as of today. The order that made it safe —
report on real PRs, observe it failing, confirm no open PR would be blocked,
then append — is recorded in ci-and-supply-chain as the reusable part, with the
two mechanics that cost care: the endpoint REPLACES the context list, and
`mergeStateStatus` cannot tell you what blocks a PR (both open ones read
BLOCKED straight after the PATCH, neither by the new context).
@athvin athvin changed the title docs(land-pr): a deferred annotation, so an empty ledger box keeps one meaning feat(ci): a deferred ledger annotation, enforced so it cannot retire work Nov 7, 2026
@athvin
athvin marked this pull request as ready for review November 7, 2026 21:29
…-line cap

`agent skills (lint + drift)` went red on this PR with
`ci-and-supply-chain: SKILL.md body is 508 lines (max 500)` — my section had
pushed it past the authoring cap. The cap is the economy rule: a SKILL.md is the
routing layer, and detail belongs in `references/`.

So the detail moves to `references/pr-contract.md` — what the check asserts and
what it deliberately does not, the exemption table, the promotion order, and the
rollup finding — and SKILL.md keeps a 23-line summary pointing at it. Body is
460 lines now. Every `references/*.md` must be linked from SKILL.md in the exact
`](references/x.md)` form or the same gate errors on an unreachable reference,
so the pointer is load-bearing rather than courtesy.

Worth recording why this reached CI at all: I ran `scripts/skills-check.sh
regen`, saw "generated references are current", and took it as the gate. Regen
is one stage — it does not lint. The gate is `make skills-check`, which runs the
regression test and then `all`.
@athvin
athvin merged commit 2ea5021 into main Nov 7, 2026
43 checks passed
athvin pushed a commit that referenced this pull request Nov 7, 2026
`skills-check.sh` ended with one unconditional `echo "skills-check: ok"` that
every subcommand fell through to — including `regen`, which rewrites the
generated blocks and asserts **nothing**. So the output of a run that checked
nothing was indistinguishable from the gate passing:

    $ bash scripts/skills-check.sh regen
    skills-check: regen
      regenerated 18 generated files
    skills-check: ok          <- checked nothing

Measured cost: a red `agent skills (lint + drift)` on #812. I ran `regen`, read
that line, and pushed a SKILL.md eight lines past the 500-line body cap — a
`lint` error `regen` never looks for. There is a second reader too:
`generated-artifact-healer`'s allow-list includes `skills-check.sh regen`, so
the false verdict was being served to an autonomous agent as well as to me.

The fix is a verdict that cannot over-claim, because it enumerates what it
covered:

    skills-check: ok (drift, lint, overrides, generators)     # all
    skills-check: ok (overrides)                              # overrides
    skills-check: regen done — NOTHING WAS CHECKED. The gate is 'make skills-check'.

Each dispatch arm declares the stages that actually assert something; `regen`
declares none, and the empty list is what selects the second message. Nothing
in the tree parses the old line — checked across workflows, the Makefile and
the scripts — so this is output-only.

The self-test covers both directions, and the slow half is **stubbed rather
than skipped**: `regen` was measured at 113s on this repo, so the suite copies
the real script with only `run_regen` replaced, leaving the dispatcher and the
verdict — the logic under test — intact. The insertion is asserted to have
happened exactly once, because an anchor that stopped matching would silently
run the real 113s regen and pass having proved nothing. Runs in 0.59s.

Mutation-tested against the real pre-fix file from `origin/main` rather than a
hand-built mutant: that file fails three of the new assertions, including the
load-bearing one. My first hand-built mutant passed it, which was the test
being inconclusive rather than the code being right — it died on `set -u`
before reaching the verdict.

My first draft of that assertion was itself wrong in this file's own documented
way: `… | grep -cFx '…' | grep -qx 0` reported a failure against correct
output, because `grep -c` exits 1 when it counts zero and `pipefail` promotes
that to the pipeline's status — with `grep -q` behind a pipe on top of it. It
now counts into a variable with `|| true` and compares numerically, which is
the idiom the rest of the file already uses.
athvin added a commit that referenced this pull request Nov 7, 2026
* wip: claim #818 — regen must not print a verdict it did not earn

* fix(skills): regen must not print a verdict it did not earn

`skills-check.sh` ended with one unconditional `echo "skills-check: ok"` that
every subcommand fell through to — including `regen`, which rewrites the
generated blocks and asserts **nothing**. So the output of a run that checked
nothing was indistinguishable from the gate passing:

    $ bash scripts/skills-check.sh regen
    skills-check: regen
      regenerated 18 generated files
    skills-check: ok          <- checked nothing

Measured cost: a red `agent skills (lint + drift)` on #812. I ran `regen`, read
that line, and pushed a SKILL.md eight lines past the 500-line body cap — a
`lint` error `regen` never looks for. There is a second reader too:
`generated-artifact-healer`'s allow-list includes `skills-check.sh regen`, so
the false verdict was being served to an autonomous agent as well as to me.

The fix is a verdict that cannot over-claim, because it enumerates what it
covered:

    skills-check: ok (drift, lint, overrides, generators)     # all
    skills-check: ok (overrides)                              # overrides
    skills-check: regen done — NOTHING WAS CHECKED. The gate is 'make skills-check'.

Each dispatch arm declares the stages that actually assert something; `regen`
declares none, and the empty list is what selects the second message. Nothing
in the tree parses the old line — checked across workflows, the Makefile and
the scripts — so this is output-only.

The self-test covers both directions, and the slow half is **stubbed rather
than skipped**: `regen` was measured at 113s on this repo, so the suite copies
the real script with only `run_regen` replaced, leaving the dispatcher and the
verdict — the logic under test — intact. The insertion is asserted to have
happened exactly once, because an anchor that stopped matching would silently
run the real 113s regen and pass having proved nothing. Runs in 0.59s.

Mutation-tested against the real pre-fix file from `origin/main` rather than a
hand-built mutant: that file fails three of the new assertions, including the
load-bearing one. My first hand-built mutant passed it, which was the test
being inconclusive rather than the code being right — it died on `set -u`
before reaching the verdict.

My first draft of that assertion was itself wrong in this file's own documented
way: `… | grep -cFx '…' | grep -qx 0` reported a failure against correct
output, because `grep -c` exits 1 when it counts zero and `pipefail` promotes
that to the pipeline's status — with `grep -q` behind a pipe on top of it. It
now counts into a variable with `|| true` and compares numerically, which is
the idiom the rest of the file already uses.

---------

Co-authored-by: bmoore813 <[email protected]>
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.

Promote 'pull request contract' to a required status check (sweep #756 first)

2 participants