Skip to content

chore(#1609): comment rule, history and doc-link gates, wrong comments fixed, 22 files trimmed - #1671

Merged
scttfrdmn merged 8 commits into
mainfrom
chore/v0132-comment-diet
Nov 24, 2026
Merged

scttfrdmn merged 8 commits into
mainfrom
chore/v0132-comment-diet

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Part of #1609 (part 2: comments). What remains is the per-family trim batches, tracked in #1669 (v0.137.0).

  • Rule. CLAUDE.md, under Code conventions: comments describe the code as it is. History narration ("before/until/since #N", "used to", "previously", "this fix", notes where a deleted function used to be) goes in git, the PR and the CHANGELOG. A trailing (#N), AWS citations and TODO(#N) are fine.
  • make comment-history-check (scripts/check-comment-history.sh).
    • It reads only the Go lines a branch adds (git diff -U0 "${BASE:-origin/main}"...HEAD -- '*.go'), and of those only the comment text: a // line, or the part after a // that is outside a string literal.
    • Narrow pattern: (before|until|since|after) ?#N, pre-#N, used to (be|treat|report|answer|return|refuse|accept|drop|mint|store), and before (this|the) fix.
    • Exempt: the passive "is/are/was/… used to" and the participle ", used to"; "recorded/written/persisted/stored/minted/registered/made/created/exported/saved before #N" and "a record/recording/stream from before #N", which state facts about old data the code still reads; and any comment carrying history-ok:.
    • --self-test runs 13 known-bad and 20 known-good lines, among them "previously-tagged", "is used to return" and "AWS no longer publishes".
    • CI: a step in the Wire Bookkeeping Drift job, with fetch-depth: 0 and BASE=origin/${{ github.base_ref }}. It runs on pull requests only. main is PR-only, so every push to it is a squash of a PR that already passed this step against the same base, and diffing HEAD~1 would add nothing.
    • On the whole current tree it would flag 1,011 existing comment lines, which is why it gates added lines only. In samples, every "used to" hit (104) was narration. Among the #N hits, the false positives were compat facts about older records, and the data exemption above covers the forms the tree uses. I found nothing else that is not narration.
  • make doc-links-check (cmd/check-doc-links).
    • It fails on a doc link [Name], [Type.Member] or [pkg.Name…] in any Go comment that resolves to nothing.
    • go/doc/comment only links exported names, and the tree links unexported ones, so the tool matches the bracket syntax itself, with go/doc's boundary rule. It skips Markdown links, tab-indented code blocks, brackets inside quotations ("a parameter [that] exceeds") and [Text] with a [Text]: URL definition in the file.
    • Resolution covers package-level declarations, methods and fields (qualified or not), predeclared names, imported and standard-library packages (major-version suffixes handled), and other packages in this repo. A package and its _test package share a scope.
    • CI: a step in the Service Reference Drift job, which has the Go toolchain. A test runs it over the repo, so make test catches a dangling link too. Coverage is 92.6%.
    • On v0.131.0 it found 23 dangling links. That is the triage's 11 plus 12 more: [Server.resolveCallerPrincipal] ×2, [AuthController.addResourceTags], [EC2Plugin.resourceTags], [ec2NatGatewayProgression.failureMessage], [cfnStampFixture.configRuleARNFor], [ec2_tags.go], AWS shape names with no link definition ([TagKeyOnly] ×2, [FailureInfo], [UnknownOperationException]), and a third [operationNameResolvers]. It finds no other false positives on the tree. All 23 are fixed.
  • Wrong comments fixed.
    • replay.go stateSnapshotHash: IDs come from the request's IDMint, not crypto/rand.
    • ec2_instance_profile.go and its test: the dead randomHex references.
    • ec2_types.go: the "randomHex is deleted" tombstone is removed. The 18 EC2 generate*ID docs said "random" and gave wrong lengths ("17"/"8" hex for Hex(8), which is 16), and now match the code.
    • kms_types.go: EC2 key material is derived, not random (A replayed CreateKeyPair answers different key material and a different fingerprint #1296).
    • replay_pipeline_test.go: the comment claimed that identifiers are minted from crypto/rand and that the replay diverges in response bodies. The replay now shows zero differences, so the comment is corrected.
    • replay_control_plane_seed_test.go: the "EC2 create could not replay" claim.
    • cfn_deployer.go: "last caller of the shared crypto/rand helper", and the deleted WithDeployerPrincipal, now WithDeployerAttribution.
    • types.go: "what every mint site did before".
    • ec2_snapshots.go: it claimed ec2CheckSecurityGroups swallows read errors, but it propagates them.
    • iam_eval.go: the dead evaluateConditionKey reference, now conditionKeyMatches.
    • Pinned counts: "67 plugins" in cmd/gen-operation-catalog, "~22 services" in cfn_deployer.go, "18 services" in operation_names_test.go (the map has 19).
    • KMS cancelKeyDeletion: the claim that setKeyState "checks nothing".
    • ELB elbXMLNS: the RDS/ElastiCache https:// claim. Both constants are http://.
  • Trimmed 22 files (history-phrased comment lines, before → after). Most of what remains is AWS quotations ("was used to encrypt"), facts about records older builds wrote, and present-tense English the counter also catches.
    • ec2_plugin.go 79 → 13. Its tagging region is left for W2b. "as of #N" and "through v0.N" are also cleared from it.
    • kms_plugin.go 32 → 8; kms_key_metadata.go 11 → 1; kms_errors.go 10 → 3.
    • invalid_body_inventory_test.go 18 → 1.
    • iam_plugin.go 14 → 5; iam_types.go 12 → 9 (compat facts).
    • msk_plugin.go 13 → 2; redshift_plugin.go 13 → 1; sns_plugin.go 12 → 2.
    • ec2_describe_filters_test.go 13 → 0; cfn_rollback.go 12 → 9 (compat facts); ec2_instancetypes.go 11 → 1; ec2_launchtemplate_versions.go 10 → 0.
    • elb_plugin.go 10 → 1; elb_tags.go 10 → 4 ("previously-tagged" is the domain term).
    • secretsmanager_plugin.go 9 → 2; backup_plugin.go 9 → 4 (compat facts); scheduler_plugin.go 9 → 2; ec2_block_devices.go 9 → 1.
    • transfer_plugin.go 8 → 0; ids.go 4 → 0, with its past-tense narration as well.
    • Total: 328 → 69. Excluded until W1, W2a and W2b merge: lambda_*, rds_*, spawn_*, replay*, config.go, server.go, s3_plugin.go, export_test.go, cfn_resources_v* and the files citing them, tagging_*, the EC2 and S3 tagging files, plugins.go, types.go. cfn_deployer.go (42) is also left out because of its size and the regrouping going on around it. It heads the cfn_* batch in Comment diet: trim issue-history narration from the remaining file families #1669. The few one-line link and wrong-comment fixes inside excluded files are deliberate.
  • Proof that only comments changed. For each of the 48 modified .go files, a scratch tool parsed the v0.131.0 version and the branch version with go/parser without ParseComments, printed both with go/printer, and byte-compared them: all 48 are identical. The only new Go code is cmd/check-doc-links. gofmt -l is clean. Every edit was hand-written per site. A words-preserving re-fill at width 100 was used only on paragraphs an edit left over-long.
  • Catalog: no routed-operation change.
  • Gates run locally:
    • make lint (0 issues), test, e2e, and iac-e2e (Terraform and CDK, SUBSTRATE_IAC=1).
    • Both drift sets: operation-catalog-check docs-reference-check docs-headings-check operation-docs-check authz-reference-check cfn-schema-check doc-links-check and wire-bookkeeping-check discarded-unmarshal-check discarded-marshal-check discarded-state-check nondeterminism-check comment-history-check.
    • docs-versions, docs-counts-check, and the VitePress build.
  • Follow-up: Comment diet: trim issue-history narration from the remaining file families #1669, the remaining per-family batches with counts, plus the forms neither the counter nor the gate sees ("through vX.Y.Z", "as of #N", plain past tense).

This merges last of the v0.132.0 PRs. After W1, W2a, W4 and W2b land, I'll rebase, re-run both gates, and the rule then applies to these trims too.

@scttfrdmn scttfrdmn added this to the v0.132.0 milestone Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.61074% with 25 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/check-doc-links/main.go 91.86% 24 Missing ⚠️
emulator/cfn_rollback.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

Copy link
Copy Markdown
Owner Author

Queued for this PR after the rebase onto W1 (#1668), W2a (#1667), W4 (#1670) and W2b. Comments and docs only:

  1. services.md references. About 90 Go comments in emulator/ name docs/services.md, and emulator/doc.go:162 calls the page "generated". After docs(#1610): split services.md into a page per plugin, redirect old anchors, terse CHANGELOG rule #1670 splits it, each one is repointed to its docs/reference/<plugin>.md or docs/reference/concepts/*.md page. Generic mentions point to the index.

  2. Lambda ESM "wall-clock" claims. These are wrong against the code. Since A Lambda ESM polls on the wall clock and records nothing, so its effect on state is neither frozen nor replayable #1292, ESM polling is driven by the ClockDrivenPlugin path: LambdaPlugin.RunDue polls once per esmPollInterval of simulated time, the cursor lives in state at esm_poll:{uuid}, and a "poller" is just an entry in the in-memory esmActive set. There is no goroutine and no ticker. The stale text:

    • docs/contributing.md, the "polls on a wall-clock ticker" bullet and the "a poll happens on a wall-clock tick" sentence;
    • lambda_plugin.go, the Shutdown doc and the ResetForRun doc ("goroutine … one-second wall-clock ticker for the life of the process");
    • lambda_esm_clock.go:23, a history note about "substrate's goroutine poller".

    I'll check the poller mentions in replay.go, server.go, testing.go and replay_plugin_reset_test.go on the rebased tree, because W1 edits those lists.

@scttfrdmn
scttfrdmn force-pushed the chore/v0132-comment-diet branch from 2cbc306 to f4f9cbe Compare November 24, 2026 04:14
@scttfrdmn

Copy link
Copy Markdown
Owner Author

Rebased onto origin/main at 37ce954, after W1 (#1668), W2a (#1667), W4 (#1670) and W2b (#1673).

Conflicts. There were two:

  • Makefile .PHONY: kept docs-anchor-fixtures and added both new targets.
  • CHANGELOG.md: kept both sides, in the terse form.

Every comment fix applied cleanly at its new location.

Queued items, now done:

  1. docs/services.md references.
    • 93 references in 71 files now point at the page that holds the statement. That is docs/reference/<plugin>.md, or a concept page: concepts/seeds-and-replay.md for "How a progression is seeded" and the minted-ID audit, concepts/errors.md for the invalid-body inventory, and concepts/listing-order.md for tag order.
    • 4 references stay on the index: the coverage matrix, go:generate, a string literal, and doc.go.
    • doc.go:162 now says the index's coverage matrix is generated, and links to the per-service pages.
    • Repointed in cmd/: gen-authz-reference (to elasticloadbalancing.md) and a gen-operation-catalog test (to cloudfront.md).
    • Rewritten rather than repointed, because the old comments narrated the doc's own history: cfn_elb_classic_test.go, cfn_deployer.go and tagging_tag_quota.go.
    • kinesis_tag_quota.go: it claimed the tagging API does not enforce the Kinesis quota. It has since tagging: TagResources bypasses the Kinesis per-stream tag quota, and no service's quota is enforced on that path #1000, through taggingCheckTagQuota.
  2. Lambda ESM "wall-clock" claims. Polling runs on the simulated clock, through RunDue and a cursor in state. A "poller" is an entry in the in-memory esmActive set; there is no goroutine and no ticker. Fixed:
    • docs/contributing.md: the bullet, and the reason given for asserting the set's size;
    • lambda_plugin.go: the Shutdown and ResetForRun docs;
    • lambda_esm_clock.go and clock_driven.go: narration;
    • replay.go, server.go and replay_plugin_reset_test.go: wording;
    • testing.go: it still listed warm Lambda containers and RDS containers, both removed by W1;
    • rds_tags.go: "container handle" ×2, also removed by W1.
    • The assertion message strings in replay_plugin_reset_test.go ("it polls the queue the next run recreates…") are code, so I left them. The stale set is harmless: a missing record makes RunDue a no-op. Worth a one-line follow-up if wanted.
  3. The rule applied to what the other PRs added. Run over 6f045e7..origin/main, the history matcher flagged 16 lines, mostly functions W2a moved into cfn_resources_ec2.go and cfn_resources_ecr.go. The others are in ec2_tags.go, cloudwatch_tags.go, kms_plugin_test.go, secretsmanager_plugin_test.go, cfn_deployer_test.go and cfn_getatt_coverage_test.go. All are now in the present tense, and the matcher is clean on that range.
    • kms_plugin_test.go: the TestKMSPlugin_KeyPolicy doc no longer calls its document the default policy, which it is not.

Checks:

  • doc-links-check is clean on the whole tree. The other PRs added no dangling links.
  • BASE=origin/main make comment-history-check passes.
  • Comment-only proof: 129 modified .go files have the same code as origin/main once comments are stripped (go/parser without comments, go/printer, byte compare). The only new Go code is cmd/check-doc-links.
  • Also passing:
    • make lint (0 issues), test, e2e, and iac-e2e (Terraform and CDK);
    • both drift sets;
    • docs-versions, docs-counts-check, docs-headings-check, cfn-schema-check;
    • the VitePress build.

@scttfrdmn
scttfrdmn merged commit 6002f86 into main Nov 24, 2026
20 checks passed
@scttfrdmn
scttfrdmn deleted the chore/v0132-comment-diet branch November 24, 2026 04:20
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