Skip to content

tooling(#756): the bookkeeping-field inventory, taken and ratcheted - #1219

Merged
scttfrdmn merged 2 commits into
mainfrom
tooling/756-bookkeeping-reachability
Sep 20, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
tooling/756-bookkeeping-reachability

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

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 record
straight into an AWSResponse.Body therefore 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 means
telling a marshal into a response from a marshal into state.Set — through 500-plus bare
json.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/tools nor any vendored analysis, so answering it
precisely 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 HandleRequest was temporarily instrumented with
a 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 is
the only non-plugin caller of HandleRequest and 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_Repository publishes — 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 of
check-discarded-unmarshal.sh, wired as make wire-bookkeeping-check beside it — and as a CI job.
The CI wiring is the part that matters: discarded-unmarshal-check is a make-only target no workflow
runs, 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 be
deleted, 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 drift
constantly, 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, ECS Service.createdAt, Batch
JobDetail.createdAt, ACM CertificateDetail.CreatedAt, Firehose
DeliveryStreamDescription.CreateTimestamp, Redshift Data DescribeStatement.CreatedAt/UpdatedAt,
Organizations CreateAccountStatus.AccountId, SSO AccountAssignment.AccountId, EC2
SpotPlacementScore.region, Health Event.region.

The same reads settled the co-located members the other way — Firehose publishes no AccountId or
Region, ACM no AccountID or Region, AppSync's GraphqlApi neither accountId nor region, SES
v2's GetEmailIdentity none of its three. EFS is the sharpest: FileSystemDescription publishes
CreationTime where substrate emits CreatedAt, 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 a
member AWS publishes, and both ELB generations publish CreatedTime as a real member, so a field of
that name is the service's data. (CloudFrontDistribution.CreatedTime is a divergence — CloudFront
publishes 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. Contributors
adding or removing a bookkeeping field must run make wire-bookkeeping-write and commit the baseline.

Also adds the missing tag-releases-check to the Makefile's .PHONY list.

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 TTLAttribute and Tags on
TableDescription — is not caught by a five-name field ratchet and is called out on the issue so this
is not mistaken for complete coverage.

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

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 3981b5a into main Sep 20, 2026
15 checks passed
@scttfrdmn
scttfrdmn deleted the tooling/756-bookkeeping-reachability branch September 20, 2026 01:18
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