Skip to content

feat(scripts): add a requirement ID ledger and CI check - #415

Open
brendanjryan wants to merge 3 commits into
coverage/core-chargefrom
feat/requirement-id-ledger
Open

brendanjryan wants to merge 3 commits into
coverage/core-chargefrom
feat/requirement-id-ledger

Conversation

@brendanjryan

@brendanjryan brendanjryan commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Adds specs/requirements.lock, a ledger of every requirement ID ever issued, and a blocking CI check that makes IDs work like protobuf field numbers: once issued, an ID is never renumbered, reused or deleted. Stacked on #414, and its ledger already holds the IDs tagged through #414.

The ledger has one line per ID: req-core-012 active 3f2a9c1b7e4d0a51, giving its status (active or retired) and a hash of the rendered statement. scripts/check_requirement_ledger.py renders the drafts the way lint_requirements.py does, then compares them with the ledger, and the ledger with the base branch's ledger. It fails when:

  • an ID on the base is missing from the ledger, or a retired ID becomes active again (the reserved rule);
  • a draft uses a retired ID or an ID the ledger doesn't list;
  • the ledger lists an active ID that no draft uses;
  • a statement's text no longer matches its hash;
  • a new ID isn't above every number its draft already issued on the base;
  • an ID now tags a statement another ID tagged on the base, which catches renumbering even after --update.

--update rewrites the ledger: new IDs are added, removed ones become retired, and edited statements get their new hash. A changed hash therefore shows up in the ledger's diff, and CI prints a note for each one, so reviewers see every rule whose text changed. Per STYLE.md, a wording change keeps its ID, and a change of meaning retires the ID and takes the next free number. The hash includes cross-reference targets, so pointing a rule at another section changes it; whitespace and line wrapping don't. Renumbering is detected within a draft only, so another draft may state the same rule under its own ID. Naming drafts (check_requirement_ledger.py <draft>) checks and updates only their IDs. A statement ending in a colon includes the list after it ("Clients MUST verify before authorizing payment:" and its items).

Ledger contents: 199 active IDs (core 001–100, intent-charge 001–016, stripe-charge 001–022, tempo-charge 001–061 from #407), none retired.

CI: a new Check requirement ID ledger step in pr-check.yml reads the base branch's ledger with git show (when there isn't one yet, it compares against an empty ledger). Unlike the requirement lint, it blocks the PR. Drafts with no IDs yet don't affect it. Also added to make lint, STYLE.md and AGENTS.md.

Checks: pytest test_check_requirement_ledger.py test_lint_requirements.py (150 passed), check_requirement_ledger.py --base <its own ledger> passes, ruff and zizmor clean. Run locally with kramdown-rfc 1.7.39 from Gemfile.lock rather than the Docker image, which couldn't build offline here.

Written with AI assistance (Pyramid).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T23:33:53.830570Z eab9b4e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eab9b4eea0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/check_requirement_ledger.py Outdated
Comment on lines +121 to +124
text = collapse("".join(el.itertext()))
following = children[index + 1] if index + 1 < len(children) else None
if text.endswith(":") and following is not None and is_list(following):
text += " " + collapse("".join(following.itertext()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve reference targets in statement hashes

When a tagged statement changes only a cross-reference, itertext() drops the change because RFC XML stores the destination in the target attribute of an empty <xref> element. For example, changing {{credential-header}} in req-core-001 to another section leaves the hash unchanged. The blocking check therefore accepts a changed requirement without a ledger update or reviewer note. Include reference targets in the statement representation before hashing, including references within an introduced list.

AGENTS.md reference: AGENTS.md:L40-L40

Useful? React with 👍 / 👎.

Comment thread scripts/check_requirement_ledger.py Outdated
Comment on lines +279 to +281
if args.update:
ledger, errors = update(ledger, drafts)
args.ledger.write_text(format_ledger(ledger), encoding="utf-8")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Limit partial updates to the drafts being processed

When the supported positional paths select one draft, running --update passes only that draft's IDs to update() but still rewrites the entire shared ledger. Every active ID belonging to an unselected draft becomes retired, and the command exits successfully because its subsequent check uses the same incomplete draft set. A later full update refuses to reactivate those IDs, so the ledger must be manually restored. Either reject partial updates to the shared ledger, always read all drafts when updating it, or preserve entries outside the selected scope.

AGENTS.md reference: AGENTS.md:L40-L40

Useful? React with 👍 / 👎.

Comment thread scripts/check_requirement_ledger.py Outdated
Comment on lines +225 to +226
for other in sorted(base, key=sort_key):
if other != req_id and base[other].digest == value and drafts.get(other) != value:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope renumbering comparisons to the same draft

When a rule is retired in one draft and identical wording is added to another, this global hash comparison rejects the new draft's correctly namespaced ID as renumbering. Using the committed ledger, retiring req-tempo-charge-038 and adding req-new-charge-001 with its text reproduces the failure, even though req-stripe-charge-012 already independently uses that same text. The suggested remedy, retaining the Tempo ID in the new draft, is itself rejected by read_drafts() as belonging to another draft. Restrict renumbering comparisons to the same draft namespace so independent methods can adopt shared requirement wording without blocking CI.

AGENTS.md reference: AGENTS.md:L40-L40

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

Spec Preview

Spec Changed Artifacts
draft-card-charge-00 Yes HTML · TXT · XML · PDF
draft-evm-charge-00 Yes HTML · TXT · XML · PDF
draft-evm-session-00 Yes HTML · TXT · XML · PDF
draft-hedera-charge-00 Yes HTML · TXT · XML · PDF
draft-hedera-session-00 Yes HTML · TXT · XML · PDF
draft-httpauth-payment-01 Yes HTML · TXT · XML · PDF
draft-lightning-charge-00 Yes HTML · TXT · XML · PDF
draft-lightning-session-00 Yes HTML · TXT · XML · PDF
draft-nearintents-charge-01 Yes HTML · TXT · XML · PDF
draft-nearintents-session-00 Yes HTML · TXT · XML · PDF
draft-payment-discovery-01 Yes HTML · TXT · XML · PDF
draft-payment-intent-charge-00 Yes HTML · TXT · XML · PDF
draft-payment-intent-subscription-00 Yes HTML · TXT · XML · PDF
draft-payment-transport-mcp-00 Yes HTML · TXT · XML · PDF
draft-solana-charge-00 Yes HTML · TXT · XML · PDF
draft-solana-session-00 Yes HTML · TXT · XML · PDF
draft-solana-subscription-00 Yes HTML · TXT · XML · PDF
draft-stellar-charge-00 Yes HTML · TXT · XML · PDF
draft-stripe-charge-00 Yes HTML · TXT · XML · PDF
draft-stripe-subscription-00 Yes HTML · TXT · XML · PDF
draft-tempo-charge-00 Yes HTML · TXT · XML · PDF
draft-tempo-session-00 Yes HTML · TXT · XML · PDF
draft-tempo-subscription-00 Yes HTML · TXT · XML · PDF
draft-usdc-charge-00 Yes HTML · TXT · XML · PDF
draft-xrpl-charge-00 Yes HTML · TXT · XML · PDF
draft-xrpl-session-00 Yes HTML · TXT · XML · PDF

Browse preview release assets

@claude claude 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.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread scripts/check_requirement_ledger.py Resolved
Comment thread .github/workflows/pr-check.yml Resolved
Comment thread scripts/check_requirement_ledger.py Resolved

@claude claude 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.

I re-reviewed after the latest push and found no new bugs. A human look is still worthwhile because this adds a blocking CI gate, and specs/requirements.lock falls under a CODEOWNERS entry.

What was reviewed:

  • My three earlier inline points look fixed in the code. The renumbering loop now skips retired base IDs. The new-ID check reads issued.get(draft, 0) once, so an ID numbered 000 gets an error message, not a traceback. On pull_request the workflow reads the base ledger from HEAD^1.
  • I also re-read the deletion, reactivation, retired-reuse, active-but-unused and new-ID-ordering checks in check(), plus the empty-ledger fallback in pr-check.yml.
  • The tests and the ledger check were not run as part of this review.
Extended reasoning...

The change adds a new 337-line ledger checker with tests, a 202-line specs/requirements.lock, a blocking step in pr-check.yml, and doc updates in STYLE.md and AGENTS.md. It touches no auth, crypto or data-exposure code. The CI step only reads the base ledger with git show and mounts it read-only into the container. I deferred instead of approving because /specs/ is covered by a CODEOWNERS entry and the change sets a new blocking repository policy that a person should sign off on. Whether the three Codex inline comments were addressed can't be confirmed from the metadata.

This branch has not been deployed

No deployments
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