Skip to content

Mark the operation count, so it stops being six hand-maintained copies - #686

Merged
jeremy merged 2 commits into
upload-versions-apifrom
operation-count-marker
Aug 7, 2026
Merged

Mark the operation count, so it stops being six hand-maintained copies#686
jeremy merged 2 commits into
upload-versions-apifrom
operation-count-marker

Conversation

@jeremy

@jeremy jeremy commented Aug 7, 2026

Copy link
Copy Markdown
Member

Stacked on #683 — base is upload-versions-api, because the spans this marks are the very lines #683 changes. Retarget to main after #683 merges.

Why

250 is one jq away from openapi.json, and it was restated in prose six times across four files. Adding a single operation left five of them stale, and reconciling took three rounds of review on #683 — each round surfacing copies the previous round hadn't been shown:

round found
1 SPEC §2 retry distribution (44 → 45)
2 SPEC §2 operation counts (166 → 167) — after I'd claimed "only that count moves"
3 P1 — SECURITY.md (249→250, 41→42) and a script comment, in files I hadn't swept

That's the failure mode spec/doc-constants.json already exists to retire, for the bc3 pin and the API version. This adds the operation count to it.

What

@operation-count joins @api-version, @bc3-pin and @assertion-types in the existing machinery: make sync-api-version rewrites every marked span from the source, make doc-constants-check fails on drift, and markerCounts pins six — so deleting one fails the gate rather than silencing it.

The span must state the count as a backticked integer, and exactly one. These sentences are full of other numbers — SECURITY.md names 125 GETs and 83 mutations in the same breath as the total — so a checker reading bare prose integers would fail on numbers it has no source for. Backticks are how the prose says this one is the derived constant, the device @bc3-pin already uses for the SHA. A line needing a second backticked integer can't carry the marker, and the error says so rather than guessing.

Counting is (path, HTTP method) pairs, with the verb list explicit — path items also carry parameters, summary and servers, so "every key" would over-count.

Derivation is lazy. The gate's own fixtures are minimal OpenAPI documents with no .paths; computing eagerly turned every one into an error about a constant it never mentions.

Verification

Six new self-test cases, each shown to fail against the un-built feature:

neutered cases that go red
check_operation_count returns [] drifted / no-backticks / two-backticks (3 cases)
rewrite_line's arm writer-restores-the-count
count every path-item key path-item-keys-are-not-operations

The fixture's real operations live in the --openapi source with a five-operation decoy in the checkout, so a gate reading the wrong file reports 5 against a span that says 3 — the same device DECOY_API_VER uses.

End-to-end on the real repo: drifting all six spans to 999 flags exactly six errors, and make sync-api-version restores all three files byte-identical to their pre-drift state.

make passes clean.

Note

This does not mark MIGRATING.md's counts, deliberately. Those are as-of facts about shipped releases (247 → 249 for v0.13.0) and must never be rewritten — the same distinction writerExcludes and unmarkedPinCitations draw for the pin.


Summary by cubic

Adds @operation-count as a doc constant and marks six prose mentions so the total stays synced with openapi.json. The writer now refuses ambiguous spans to avoid corrupting other numbers.

  • New Features

    • Added @operation-count to scripts/sync-doc-constants.rb; counts path × HTTP method using an explicit verb list; derived lazily from --openapi.
    • Rewrites only the single backticked integer in marked spans; prints the count in the summary when present.
    • Marked AGENTS.md, SECURITY.md, and SPEC.md with backticked 250; pinned six citations in spec/doc-constants.json so deletions fail.
    • Tests cover drift, non-operation path-item keys, reading from --openapi (with a decoy in-repo file), and writer behavior.
    • Authoring: write the total as a single backticked integer and add <!-- @operation-count -->.
  • Bug Fixes

    • Writer refuses spans with multiple backticked integers and leaves them unchanged; --check then fails with a clear error.
    • Checker and writer share one helper that finds the sole backticked integer (counts occurrences, not distinct values) to prevent mismatches and silent corruption.

Written for commit 32f454e. Summary will update on new commits.

Review in cubic

250 is one jq away from openapi.json and was restated in prose six times
across four files. Adding one operation left five of them stale, and it
took three rounds of review on #683 to reconcile — each round finding the
copies the previous round had not been shown.

@operation-count joins @api-version, @bc3-pin and @assertion-types in
spec/doc-constants.json's existing machinery: `make sync-api-version`
rewrites every marked span from the source, and `make doc-constants-check`
fails on any that drifted. markerCounts pins six, so deleting one fails
the gate rather than silencing it.

The span must state the count as a BACKTICKED integer, and exactly one.
Those sentences are full of other numbers — SECURITY.md names 125 GETs and
83 mutations beside the total — and a checker that read bare prose integers
as the claim would fail on numbers it has no source for. Backticks are how
the prose says "this is the derived constant", which is the device @bc3-pin
already uses for the SHA. A line needing a second backticked integer cannot
carry the marker, and the error says so.

Counting is (path, HTTP method) pairs. Path items also carry parameters,
summary and servers, so the verb list is explicit rather than "every key".

Derived lazily. The gate's own fixtures are minimal OpenAPI documents with
no .paths, and computing eagerly turned each into an error about a constant
it never mentions.

Six self-test cases, each shown to fail against the un-built feature:
neutering the checker fails the three negative cases, neutering the
rewriter fails the writer case, and counting every path-item key fails the
positive control. The fixture's real operations live in the --openapi
source with a five-operation decoy in the checkout, so a gate reading the
wrong file reports 5 against a span that says 3.

End-to-end: drifting all six spans to 999 flags six errors, and the writer
restores all three files byte-identical.
Copilot AI balanced review requested due to automatic review settings August 7, 2026 17:02
@github-actions github-actions Bot added the spec Changes to the Smithy spec or OpenAPI label Aug 7, 2026

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@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: 34437ebade

ℹ️ 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/sync-doc-constants.rb Outdated
…n it

Codex found a real hole, and it was the dangerous kind: the writer
corrupted data and the checker then certified the corruption.

--write returns before the per-kind checkers run. So a blanket gsub over
every backticked integer on the marked line ran FIRST, and the later check
— comparing values that were by then all identical, because it deduplicated
— went green over the damage.

Reproduced on the real sentence before fixing. Backticking SECURITY.md's
125 GETs and 83 mutations, then `--write`:

  before: all `250` operations: the `125` GETs ... and `83` mutations
  after:  all `250` operations: the `250` GETs ... and `250` mutations
  check:  passes

Two changes. The count is now found by one helper both the checker and the
writer call, so they cannot disagree about which integer is the claim; and
that helper counts OCCURRENCES rather than distinct values, because two
spans both reading `250` today would both be rewritten the day the count
moves and only one of them is the count.

An ambiguous span is now left exactly as written. That is deliberate rather
than a silent skip: untouched, it fails the next --check with a message
naming the integers it found and what to do about them.

The self-test drives --write over an ambiguous span, asserts the other
integer survived, and then runs --check in the same directory to assert the
span is still rejected. Restoring the blanket gsub fails it.
Copilot AI review requested due to automatic review settings August 7, 2026 17:30
@jeremy

jeremy commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 32f454e3d0

ℹ️ 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".

@jeremy
jeremy merged commit f3fa374 into main Aug 7, 2026
41 of 42 checks passed
@jeremy
jeremy deleted the operation-count-marker branch August 7, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spec Changes to the Smithy spec or OpenAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants