Repository navigation
Description
#865 made MemoryStateManager.List return keys in lexicographic order and put the guarantee in StateManager.List's doc comment, so all 124 non-test .List( sites are now deterministic. That fixed the run-to-run instability. It did not establish that lexicographic is the order AWS documents at each site, and only the sites reaching a response body under a cursor were audited individually.
This issue is the remaining audit: for each listing that still inherits lexicographic order by default, confirm against the operation's own API reference page whether AWS publishes a different order — and where it does, sort into it at the call site rather than relying on the default.
What #865 audited, and how
Three provenance tiers were established and recorded in docs/services.md:
- Documented by AWS —
API_ListMultipartUploadspublishes a "Sorting of multipart uploads in response" section (ascending object key, then ascending initiation time for uploads sharing a key). Substrate's previous order was a citable violation, andlistMultipartUploadsnow sorts into it explicitly. - Required by the operation's own cursor —
API_ListObjectVersions(NextKeyMarkeris "the first key not returned that satisfies the search criteria"), RGTAGetResources(PaginationToken), and the four ELBv2 Describes (Marker/PageSize). A cursor over an unstable order can skip or repeat, so these are correct now by construction. - Undocumented —
API_ListBucketssays nothing about bucket order andAPI_DescribeRulesstates none. Lexicographic there is substrate's reading, resting on the replay promise, and it is written up that way rather than as matching AWS.
The remaining sites fall in tier 3 by assumption, not by having been checked. That assumption is what needs testing.
The sites to audit
Roughly sixty, concentrated in these files (counts are non-test .List( sites, not distinct operations):
| File | Sites | Notes |
|---|---|---|
ec2_plugin.go |
23 | the largest set; several Describes publish no order, but DescribeSnapshots/DescribeImages and the paginated Describes need checking individually |
iam_plugin.go, iam_list_policies.go, iam_account_authorization_details.go |
12 | already routed through paginateIAMKeys, which sorts — so these are believed fine and need confirming, not fixing |
s3_plugin.go |
9 | three audited in #865; the rest not |
rds_plugin.go |
5 | |
elasticache_plugin.go |
4 | :163 clusters, :383 replication groups, :563 subnet groups, :662 parameter groups — all four under Marker/MaxRecords cursors, so tier 2 at minimum |
lambda_plugin.go |
3 | :517 and :838 over function:, :1281 over esm: — ListFunctions publishes a FunctionVersion/Marker pair worth checking |
apigateway_plugin.go |
2 | :702, :1321 — both take a computed prefix, so the effective order depends on the key layout as much as the sort |
cloudwatch_plugin.go |
1 | :481, computed prefix |
ssm_plugin.go |
1 | :954 — lists EC2 instances from ec2Namespace, a cross-service read worth noting on its own |
| remainder | ~12 | ce_plugin.go, bedrock_runtime_ctrl.go, ec2_snapshot_control.go, timestream_ctrl.go, tagging_plugin.go's sixteen scanners (audited as one cursor in #865) |
Not every site is a listing — some are internal scans whose order never reaches a caller, and those can be dismissed with a line each rather than researched. Separating those out is most of the work.
Acceptance criteria
- Every non-test
.List(site is classified: reaches a response body (needs an order decision) or internal scan (does not). The count of each is recorded on the issue. - For each site in the first class, the operation's AWS API reference page is consulted and the site assigned one of the three tiers above. A tier-1 finding — AWS publishes an order substrate does not produce — is a defect, and each one gets a fix plus a test.
- Any site under a pagination cursor whose key order does not match the cursor's comparison basis is a defect even if AWS documents no order, for the same reason
NextKeyMarkerwas: the cursor can skip or repeat.elasticache_plugin.go's four are the first candidates. -
docs/services.mdrecords the tier-1 findings by operation, and states for the tier-3 remainder that lexicographic is substrate's reading — as state: MemoryStateManager.List returns keys in Go map order, so 111 call sites answer differently run to run #865 did forListBuckets. - Any test that was silently passing on the old order and had to be adjusted is recorded on the issue as a finding, not quietly relaxed.
The audit itself does not have to land in one PR; a per-service sweep with the classification table kept up to date on this issue is fine, and probably better.
Follow-up to #865.
Activity
scttfrdmn commentedon Sep 16, 2026
Audit complete — the inventory, the tier assignments, and two corrections to this issue's own body
PR #914 carries the one defect the audit found. This comment is the record AC 1 asks for.
Inventory
128 non-test
.List(call sites across 46 files — not the ~60 this issue estimated. Classified by whether the order is observable:By subsystem:
tagging_plugin.goce_plugin.go,replay.go, control endpoints)The
tagging_plugin.goblock is the largest class C by far: twenty scanners feedgetResources, whose ARN sort (tagging_plugin.go:111-113) discards their order entirely.Tier assignments — no new tier-1 operation exists
Eleven further AWS pages were read this pass: RDS
DescribeDBInstancesandDescribeDBClusters; ElastiCacheDescribeCacheClusters,DescribeReplicationGroupsandDescribeCacheSubnetGroups; API GatewayGetRestApis; CloudWatchDescribeAlarmsandListMetrics; SSMDescribeParametersandGetParametersByPath; and EC2's Query request page. None publishes an ordering statement.ListMultipartUploads(fixed in #865) remains the only documented order in the codebase.EC2 is settled by a blanket disclaimer rather than per operation, on
Query-Requests.html:All 30 EC2-family sites are therefore tier 3, and substrate's lexicographic order is a stronger guarantee than AWS gives — which is the right direction, but must not be read as matching AWS.
Tier 2 needed care to draw correctly. A cursor alone does not make an operation tier 2; the cursor has to have positional semantics:
Marker. Documented positionally: "the response includes only records beyond the marker, up to the value specified byMaxRecords". A record cannot be beyond another without an order. An offset cursor therefore diverges from a published contract. This is the defect, at exactly three sites.position, CloudWatchNextToken, SSMNextToken. Documented as opaque, with no positional semantics stated. Substrate's base64-offset implementations there are substrate's reading, not defects — though see the finding below about what they do with a token they did not issue.Two corrections to this issue's body
Marker/MaxRecordscursors" is wrong. OnlydescribeCacheClustersimplements pagination.describeReplicationGroups(elasticache_plugin.go:383),describeCacheSubnetGroups(:563) anddescribeCacheParameterGroups(:662) implement none at all — they return the whole listing and noMarker, and ignoreMaxRecords. Filed separately.Adjusted test, recorded here rather than quietly relaxed (AC 5)
TestElastiCachePlugin_CacheClusterPagination(emulator/elasticache_plugin_test.go) failed against the fix, and it deserved to. It created five clusters, asserted page one contained a<Marker>, then requested page two with a hand-written"Marker": "2"— the offset the old cursor happened to emit — and ended with_ = body. It never asserted anything about page two's contents. That is exactly why it passed while the cursor was capable of dropping a record: the only thing it checked was that a marker existed. It now walks the marker page one actually returned and asserts page two's records and that they do not repeat page one's.No other test in the tree paged either family, so this was the only adjustment.
Verified correct, recorded so the claim is not overstated
s3_plugin.go:2180 loadUploadPartsalready sorts numerically, with the reason written down: "State keys sort lexicographically, which puts part 10 before part 2."ec2_describetags.goalready sorts, validatesMaxResultsagainst its own min/max, and refuses aNextTokenit did not issue — its:300comment already states the argument this issue is about: "an offset-based NextToken over an unordered list could…".state.Putwith a numeric key component (fmt.Sprintf("part:%s/%d", …)), so no other listing can hit the 1/10/11/2 trap.listObjectVersions' newest-first ordering is safe: bothsaveVersionIDscall sites (s3_plugin.go:928,:1200) prepend, so the stored list is newest-first by construction. It rests on two call sites agreeing rather than on anything stated, which is worth a doc comment but is not a defect.Out of scope, filed rather than folded in
MaxRecordsoutside the documented 20–100 range is honoured, and an unusable one is silently rewritten to 100.DescribeAlarms, both SSM listings andlistObjectsV2, where AWS publishesInvalidNextToken/400. Same class as defect 2 here, different services.MaxResults/NextTokenat all.lambda_plugin.go:1281ListEventSourceMappingsandapigateway_plugin.go:1321GetBasePathMappingsare unpaginated.scttfrdmn commentedon Sep 16, 2026
The out-of-scope findings above are now filed: #913 (
MaxRecordsoutside the documented 20–100 range), #915 (a pagination token substrate never issued is answered with page one — CloudWatchDescribeAlarms, both SSM listings, S3ListObjectsV2;InvalidNextToken/400 is published for the first three), #916 (six RDS/ElastiCache describes publishMarker/MaxRecordsand implement neither), #917 (EC2's describes implement noMaxResults/NextToken, plus LambdaListEventSourceMappingsand API GatewayGetBasePathMappings). All four are on milestone v0.118.0.fix(rds,elasticache): refuse a MaxRecords outside the published range (…
feat(pagination): the two cursors outside EC2 that published both hal…
fix(#1086): five sites refuse a token substrate never issued, and the…
fix(#1086): ListSchedules refuses a token it could not have issued (#…
fix(#1086): Batch's three describes refuse a token they could not hav…
fix(#1224): a log group that does not exist is not an empty log group (…