Repository navigation
tooling(#756): the bookkeeping-field inventory, taken and ratcheted - #1219
Merged
Merged
Conversation
Substrate persists five fields of its own — AccountID, Region, CreatedAt, UpdatedAt, EverTagged — and AWS publishes none of them on any shape, so a handler that marshals a persisted record straight into an AWSResponse.Body ships members the service does not have. The rule one wants is "no bookkeeping field reaches an AWSResponse.Body", which no grep can state: deciding it means telling a marshal into a response from one into state.Set, through 500-plus bare json.Marshal(x) calls and 60-odd per-plugin response helpers, and substrate depends on neither golang.org/x/tools nor any vendored analysis. That is why this issue never moved. So the reachability question was answered by observation instead — every plugin's HandleRequest temporarily instrumented with a deferred hook over the body it was about to return, then the suite run: 213 wire-visible observations across 31 services and 97 operations, of which 194 across 25 services and 86 operations are members AWS publishes nowhere. That is a floor, not a ceiling, and the instrumentation was deliberately not committed. The inventory is on the issue. What CI can assert exactly is the declaration surface, which is the upper bound: 330 fields across 146 struct types in 67 files, correcting the estimate of 343 across ~40. check-wire-bookkeeping.sh diffs that against a checked-in baseline and fails both on a field missing from it and on a baseline line the tree no longer has, because the baseline is an inventory of defects rather than a suppression list — every line is expected to be deleted, so a fix must shrink it. It runs in CI as well as in make: discarded-unmarshal-check is a make-only target no workflow runs, and a baseline nothing executes is a TODO list, not a ratchet. Two exclusions, both recorded in the script: a test file's decode target reads CreateAccountStatus.AccountId, which AWS publishes; and both ELB generations publish CreatedTime as a real member, so a field of that name is the service's data. Ten AWS pages were read to separate a leak from a published member — EFS is the sharpest, spelling CreatedAt where FileSystemDescription publishes CreationTime. Fixing the services the inventory names is v0.121.0 work. Also adds the missing tag-releases-check to .PHONY.
accountRegionRequest.AccountID decodes the AccountId that Account's own operations publish as an input, so it cannot leak. There is no lexical way to tell a request struct from a response struct, and excluding by name suffix would be a heuristic that silently drops real surface, so it stays in the baseline and is named in the script instead.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Takes the inventory #756 has been blocked on since it was filed, and turns it into a ratchet.
Substrate persists five fields of its own —
AccountID,Region,CreatedAt,UpdatedAt,EverTagged— and AWS publishes none of them on any shape. A handler that marshals a persisted recordstraight into an
AWSResponse.Bodytherefore ships members the service does not have.Why this needed more than a grep
The rule one wants is "no bookkeeping field reaches an
AWSResponse.Body", and deciding it meanstelling a marshal into a response from a marshal into
state.Set— through 500-plus barejson.Marshal(x)calls and 60-odd per-plugin response helpers. That is a type-and-dataflow question,and substrate depends on neither
golang.org/x/toolsnor any vendored analysis, so answering itprecisely would mean adding a dependency to serve one check. That is why this issue never moved.
So it was answered by observation: every plugin's
HandleRequestwas temporarily instrumented witha deferred hook over the body it was about to return, and the suite was run. 213 wire-visible
observations across 31 services and 97 operations, of which 194 — across 25 services and 86 operations
— are members AWS publishes nowhere. The instrumentation is deliberately not in this PR; it is a
measurement, not a fixture. Per-plugin rather than at
PluginRegistry.RouteRequest, because that isthe only non-plugin caller of
HandleRequestand most tests bypass it.That pass is a floor, not a ceiling — it sees only what the suite exercises. The full inventory,
service by service with JSON pointers, is on the issue.
ECR calibrates it. After #1090, ECR's only remaining bookkeeping-named wire member is
createdAt,which
API_Repositorypublishes — and the pass reports exactly that and nothing else.What is committed
scripts/check-wire-bookkeeping.sh+scripts/wire-bookkeeping-baseline.txt, in the shape ofcheck-discarded-unmarshal.sh, wired asmake wire-bookkeeping-checkbeside it — and as a CI job.The CI wiring is the part that matters:
discarded-unmarshal-checkis amake-only target no workflowruns, and a baseline nothing executes is a TODO list rather than a ratchet, which is how this inventory
stayed untaken.
It asserts the declaration surface, which is the exactly-decidable upper bound: 330 fields across
146 struct types in 67 files, correcting the planned estimate of 343 across ~40 files.
The baseline is an inventory of defects, not a suppression list — the one place this departs from
ALLOWED_FILES, whose entries each argue for their own retention. Here every line is expected to bedeleted, so the check fails in both directions: a field missing from the baseline is new leak
surface, and a baseline line the tree no longer has is a stale record. A fix must shrink the file in the
same commit. Both directions were verified to fail before the check was committed.
Keyed
file → type → Go field → rendered tag, with no line numbers — citations in this repo driftconstantly, and file+type+field survives every edit that is not the fix itself.
Provenance
Ten AWS pages were read so a leak is not confused with a published member, because a wrong "published"
call hides a real one. Genuinely published: ECR
Repository.createdAt, ECSService.createdAt, BatchJobDetail.createdAt, ACMCertificateDetail.CreatedAt, FirehoseDeliveryStreamDescription.CreateTimestamp, Redshift DataDescribeStatement.CreatedAt/UpdatedAt,Organizations
CreateAccountStatus.AccountId, SSOAccountAssignment.AccountId, EC2SpotPlacementScore.region, HealthEvent.region.The same reads settled the co-located members the other way — Firehose publishes no
AccountIdorRegion, ACM noAccountIDorRegion, AppSync'sGraphqlApineitheraccountIdnorregion, SESv2's
GetEmailIdentitynone of its three. EFS is the sharpest:FileSystemDescriptionpublishesCreationTimewhere substrate emitsCreatedAt, so the leak is a near-miss of a real member.Two exclusions, both recorded in the script:
organizations_account_test.go's decode target reads amember AWS publishes, and both ELB generations publish
CreatedTimeas a real member, so a field ofthat name is the service's data. (
CloudFrontDistribution.CreatedTimeis a divergence — CloudFrontpublishes
LastModifiedTime— but that is a wrong member, not a bookkeeping leak.)One unverified and flagged as such on the issue: Budgets' trio, whose API reference page is not
machine-retrievable.
Compatibility
No behavioural change and no Go file is touched, so no response body moves and coverage cannot shift.
Adds one CI job (
Wire Bookkeeping Drift), so a PR now sees one more check than before. Contributorsadding or removing a bookkeeping field must run
make wire-bookkeeping-writeand commit the baseline.Also adds the missing
tag-releases-checkto theMakefile's.PHONYlist.Scope
AC1 and AC4 of #756 are met; AC2 and AC3 are v0.121.0 work and #756 stays open. The issue's
second group — substrate-concept members like DynamoDB's
TTLAttributeandTagsonTableDescription— is not caught by a five-name field ratchet and is called out on the issue so thisis not mistaken for complete coverage.