refactor: idiomatic file/test reorg (21 services) + DynamoDB deadlock/panic fixes#2385
Merged
Conversation
Collaborator
Author
📊 Code Coverage Report
Tip This project maintains a minimum coverage threshold of 85%. Maintain or improve coverage on new code to ensure long-term stability. Last updated: Thu, 16 Jul 2026 15:23:46 GMT |
Pure reorganization, behavior identical. handler.go (6229) + backend.go (3791) + batch2/new_ops files split into ~53 idiomatically-named files by op family (models.go, errors.go, backend_<family>.go, handler_<family>.go, handler_paths.go, handler_dispatch.go; max 983 LOC, no giants). 11 sequence-tagged test files (parity_*/batch2/audit/refinement2/new_ops/accuracy_batch2) consolidated into 24 handler_<family>_test.go + backend_test.go etc. Refactored GetSupportedOperations to drop its //nolint:funlen. Whole package green (build/test-race/vet/fix/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical. handler_stubs.go (5852) + backend.go (2856) + batch2/new_ops/accuracy files split into 75 idiomatic files by op family (models.go, backend_<family>.go, handler_<family>.go, handler_ops_table.go data table; max 1264 LOC). 23 sequence-tagged test files (parity_pass*/batch2-4/audit*/refinement*/new_ops/stubs) consolidated into 56 handler_<family>_test.go / backend_<family>_test.go (all 322 test funcs preserved). Refactored 4 nolint:funlen/gocognit/cyclop sites (GetSupportedOperations +buildOps via op-binding data table; partition_expr tokenize/parsePrimary via helpers). Removed one pre-existing dead const (inert on main) exposed by the split. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical. backend.go (5321) + handler.go (4088) + handler_stubs split into 33 idiomatic files by op family (models.go, errors.go, backend_<family>.go, handler_<family>.go, event_source_mapping.go; largest new file 767). 11 sequence-tagged test files (batch1-3/audit_*/new_ops/parity_*/comprehensive) consolidated into op-family-named test files + shared test_helpers_test.go. 3 tests converted table-driven. No forbidden nolints (none pre-existed). Whole package green (build/test-race/vet/fix/gofmt/ lint 0 issues). Pre-existing 944-line event_source_poller.go left as-is (unmodified, cohesive). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical. backend_memory.go (4546), bucket_ops.go (2500),
object_ops.go (1906), select_sql.go (1985), janitor.go (1106) split by op family into
~60 idiomatic files (backend_<family>.go, bucket_ops_<family>.go, object_ops_<family>.go,
select_sql_{tokenizer,parser,expr,exec}.go, janitor_lifecycle.go; max 810 LOC). 10
sequence-tagged test files (parity_*/batch7/garnet/audit2/accuracy_batch2/coverage*)
consolidated into 14 descriptive files. ~25 tests folded into 8 table-driven tests. No
funlen/gocyclo nolints (none existed; 6 nolint:dupl added where per-family splits exposed
boilerplate-CRUD whole-file clones). Whole package green (build/test-race/vet/fix/gofmt/lint).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical (go doc byte-identical, zero API change). backend.go (4025) + handler.go (3874) + batch/refinement files split into 73 idiomatic files by op family (models.go, errors.go, backend_<family>.go, handler_<family>.go, handler_dispatch.go; max 912). 28 sequence-tagged test files (parity_*/batch1-3/ refinement*/new_operations/accuracy/audit_rds/coverage) consolidated into 35 op-family test files + test_helpers_test.go. Field-range validation folded table-driven. No funlen/gocyclo nolints (none existed). Whole package green (build/test-race/vet/fix/gofmt/lint). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical. backend.go (4332) + handler.go (2140) + delivery.go (1261) split into idiomatic op-family files (models.go, store.go, backend_<family>.go, handler_<family>.go, delivery_<family>.go; max 716). 12 sequence-tagged test files (parity_*/batch2_audit/refinement*/accuracy_audit/coverage/schemas_batch2) consolidated into 28 per-source test files; stripped goofy Test-func prefixes. Refactored scheduler processTick to drop //nolint:gocognit. Zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical. handler.go (4668) + backend.go (2070) + backend_batch1/parity files split into idiomatic op-family files (models.go, errors.go, backend_<family>.go, handler_<family>.go; max 873). Sequence/category-tagged test files (parity_a/batch1-3/batch2_audit/backend_parity/*_coverage) consolidated into 25 op-family test files + helpers_test.go; stripped TestBatch1_ prefixes. Refactored GetSupportedOperations into per-family helpers to drop //nolint:funlen. Zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical. handler.go (4954) + backend.go (3057) split into 68 idiomatic op-family files (models.go, errors.go, backend_<family>.go, handler_<family>.go; max non-test 586). Goofy test files (backend_coverage/handler_audit2/parity_c) split into per-family test files; stripped TestRefinement1_/TestAudit2_/TestParityC_ prefixes. Refactored buildOps + GetSupportedOperations (computed from op keys) to drop 2 //nolint:funlen. Zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… names Pure reorganization, behavior identical. backend.go (4492) + handler.go (1981) split into idiomatic op-family files (models.go, errors.go, backend_<family>.go, handler_<family>.go; max non-test 738). Giant handler_test.go (5369) + 9 sequence/category-tagged test files (accuracy*/parity_b*/audit/refinement1/region) split+consolidated into 20 op-family test files (max 996); stripped TestIssueN_/TestParityB_/TestAudit_/TestRefinement1_ prefixes. KMS-validation tests folded table-driven. No funlen/gocyclo nolints (none existed); zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… names Pure reorganization, behavior identical (crypto untouched). backend.go (4178) + handler.go (1220) split into idiomatic op-family files (store.go, errors.go, backend_<family>.go, handler_<family>.go; max non-test 916). 13 sequence/category-tagged test files incl. giant handler_test.go (3490) split+consolidated into 27 op-family test files (max 1364); stripped TestAudit_/TestBatch2_/TestRefinement1_/TestOps2_ prefixes; consolidated duplicate helpers into helpers_test.go. No funlen/gocyclo nolints (none existed); zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…destub (pass 1) Pure reorganization, behavior identical; race-fix RO-store-twin discipline preserved. backend.go (3724) split into models.go/store*.go/backend_<family>.go. Removed all 6 funlen/gocyclo/cyclop nolints via real helper extraction (constructor/Reset init helpers, GetSupportedOperations, batch2/3+accuracy4 dispatchers). Eliminated backend_misc_destub.go / handler_misc_destub.go (distributed to families). Goofy test files (parity_a/b/c, batch2_ accuracy, refinement1, destub_round, coverage) routed to family test files. Zero new nolint. Whole package green. NOTE: pre-existing sequence-tagged giant files (batch2/3, accuracy2-4, new_ops) still to split in pass 2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…olint (pass 1) Pure reorganization, behavior identical. 18 sequence-tagged source files (batch1-5, refinement2/3, accuracy, parity_final; ~13k lines) split into ~60 op-family backend_<family>.go / handler_<family>.go files (max new ~700). All 20 goofy test files split into per-family test files; stripped TestBatchN_/TestRefinementN_/TestAccuracy_/ TestParity_ prefixes (331 renames). Removed all 4 funlen/gocyclo/cyclop/gocognit nolints (GetSupportedOperations/buildOps via registrar slices; persistence Restore via restoreMapField generic). Zero new nolint. Whole package green (build/test-race/vet/fix/ gofmt/lint). NOTE: pre-existing large descriptively-named files (handler_ext 2588, backend_iface 1962, advanced_networking, backend/handler.go) deferred to pass 2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ass 2) Pure reorganization, behavior identical; RO-store-twin race discipline preserved (race-clean). Eliminated all remaining sequence-tagged files: backend_batch2/3 (1992/2436), backend_accuracy/ 2/3/4, backend_new_ops + handler counterparts -> op-family files (backend_<family>.go / handler_<family>.go). Also split oversized stateful_ops (1612/1582) + handler.go (1942) by family. Test files renamed to per-family. Zero sequence-tagged files remain (source or test); max non-test 944, max test 1385. dupl handled by merging cohesive HyperPod configs (no new nolint). Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nolint Pure reorganization, behavior identical (policy-eval/ARN logic untouched; wire types verified vs git HEAD). 14 sequence-tagged source files (accuracy/comprehensive/new_ops/ refinement/refinement2 across backend_/handler_/models_) eliminated -> op-family files. backend.go 2746->828, handler.go 2115->871, models.go split by family. Removed 3 funlen/gocognit nolints (GetSupportedOperations, server-cert/ssh dispatchers) + 3 pre-existing dupl (generic resourceTagDispatch). 19 goofy/giant test files -> 30 family test files; stripped goofy Test prefixes. Zero sequence-tagged files remain; max non-test 871, max test 1465. Zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lelize tests Pure reorganization, behavior identical (docker-runtime skips preserved). 13 sequence-tagged source files (parity/parity2/ops2/batch3/refinement1/new_ops/comprehensive/stubs/ext) split into op-family files (models.go, errors.go, backend_<family>.go, handler_<family>.go); backend.go 1938->243, handler.go 1880->446 (max source 820). 17 goofy test files split into family test files; giant service/task/taskdef test files halved (max 1248); stripped goofy Test prefixes. ~30 tests folded table-driven; made 21 tests parallel-safe (dropped paralleltest nolints). Zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nolint Pure reorganization, behavior identical (verbatim moves). 9 sequence-tagged source files (batch2/3/4, new_ops, stubs) + final_ops split into 63 op-family files (backend_<family>.go, handler_<family>.go, errors.go, op_names.go; max 878). Removed all funlen/gocyclo/cyclop nolints across 11 functions (GetSupportedOperations, resolveOperation, dispatchBatchN, resolve*Ops) via real helper extraction + a dispatchFirstMatch data-driven helper. 11 goofy test files -> 20+ family test files; stripped goofy Test prefixes; split handler_test vs backend_test. Zero new nolint (fixed a fieldalignment govet too). Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). (backend_audit/handler_audit = real IoT Device Defender Audit family, not a tag.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical (verbatim moves, wire shapes byte-identical). backend_batch1/2/3 + handler_batch1/2/3 + handler.go (2466) split into op-family files (models.go, errors.go, backend_<family>.go, handler_<family>.go; max 746). 9 goofy test files (batch1-4/coverage/refinement1/parity_pass5-7) consolidated into per-family test files (154->154 tests, 156->156 subtests preserved); stripped goofy Test prefixes. No funlen/gocyclo nolints (none existed); zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical (verbatim moves). 7 sequence-tagged source files (audit1/batch2/new_ops/ops2) split into 25 op-family files (models.go, errors.go, backend_<family>.go, handler_<family>.go; max 956); backend.go 2067->161, handler.go 1988->428. 11 goofy test files -> 30 family test files (~250 tests preserved); stripped goofy Test prefixes; consolidated duplicate coverage. No funlen/gocyclo nolints (none existed); zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…drop nolint Pure reorganization, behavior identical (verbatim moves). 6 sequence-tagged source files (audit1/2, refinement2/3, completeness) split into 24 op-family files; backend.go 1108->309, backend_serverless.go 1014->141, handler.go 1527->937; models.go + errors.go extracted. 9 goofy test files (parity_a-d/coverage/new_ops/refinement1-3/audit1-2) -> 20 family test files (261 tests preserved); stripped 22 TestParity_ prefixes. Refactored serverless ExtractOperation/dispatch (2 nolint:gocognit/cyclop/gocyclo/funlen) into per-family helpers + generic dispatchCRUD. Zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…aces Real -race-confirmed concurrency bugs in the db.mu/table.mu discipline (same area the post-v15 store rewrite touched): - TransactWriteItems.executeTransactWrite held every target table.mu (write) then acquired db.mu.Lock to commit the idempotency token — REVERSE of the backend's db.mu->table.mu order, deadlocking against TaggedTables / ListContributorInsights (which hold db.mu.RLock then nest table.mu.RLock). Fix: release all table locks before touching db.mu. - DeleteTable read table.Items/GlobalSecondaryIndexes without table.mu while Put/BatchWrite mutate them under table.mu -> data race. Fix: snapshot under table.mu.RLock. - buildCreateTableOutput read t.Status without table.mu, racing the activation timer. Fix: RLock. - PutItem/DeleteItem/UpdateItem released table.mu via manual calls at each early return (lock leak on panic) -> refactored to *Locked helpers with a single defer Unlock. +concurrent_table_lifecycle_test.go regression test (fails pre-fix, passes post-fix, -race). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nolint Pure reorganization, behavior identical (verbatim moves). 4 sequence-tagged + several giant source files (backend.go 3105, backend_stubs 1961, backend_ops 1647, backend_batch2 1620) split into 30+ op-family files (models_<family>.go, errors.go, backend_<family>.go, handler_<family>.go; max 997). 24 goofy test files -> 20 family test files (468->468 tests); stripped 127 goofy Test prefixes. Refactored GetSupportedOperations (maps.Keys of dispatch) + ssmStubOps (generic jsonOp helper) to drop 2 nolint:funlen/gocognit. Zero new nolint. Named maintenance_window (singular) to avoid the _windows.go GOOS build-constraint suffix. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure reorganization, behavior identical (verbatim AST moves). backend.go (2873) + handler.go (4036) split into op-family files (models.go, errors.go, backend_<family>.go, handler_<family>.go; max source 660). 10 goofy test files (batch2/3/audit1/2/4/refinement1/ accuracy_batch2/parity_b/coverage) + oversized handler_test.go split into family test files (219 tests preserved); stripped goofy Test prefixes. ~8 test clusters folded table-driven. No funlen/gocyclo nolints (none existed); zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, drop nolint Pure reorganization, behavior identical (verbatim AST moves; auth/crypto/token logic untouched; 4-tier dispatch override chain preserved). 6 sequence-tagged + completeness source files split; backend.go 2509->176, handler.go 1956->468 -> 68 op-family files (models_<family>, errors.go, backend_<family>, handler_<family>; max 649). 8 goofy test files -> family test files + testhelpers_test.go (320 tests preserved); stripped 132 goofy Test prefixes. Refactored GetSupportedOperations + tokenIssuer.Issue to drop 2 nolint:funlen/gocognit. Zero new nolint. Whole package green (build/test-race/vet/fix/gofmt/lint 0 issues). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ck sites panic-safe Root cause of the reported PutItem hang: stopTableTimers (store.go) iterated table.GlobalSecondaryIndexes WITHOUT holding table.mu, called from DeleteTable + the background janitor's runTableCleaner, racing a concurrent GSI-delete (UpdateTable) that shrinks that slice under table.mu -> for-range re-reads the shrunk header -> index-out-of- range panic. The HTTP panicRecoveryMiddleware recovers it as a 500 (the user's 14 PanicRecovery worker errors), but the in-flight table.mu was left orphaned -> the next PutItem on that table blocks forever. Fix: stopTableTimers now holds table.mu.Lock/defer. Hardening: converted ALL ~97 remaining manual .Unlock()/.RUnlock()-at-each-return sites across 17 files to defer (extracting defer-scoped helpers where work continues after an intentional early release) so no recovered panic can EVER leak a lock. Lock order unchanged (db.mu->table.mu); re-audited all ~142 sites, no ABBA / recursive-RLock remains. +TestStopTableTimers_ConcurrentGSIDelete_NoPanic (fails pre-fix, passes post-fix, -race). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # services/dynamodb/transact_ops.go
…lity) github-code-quality flagged 'off-by-one comparison against length' on 5 List* paginators (auth_events/devices/groups x2/webauthn). The all[limit] access was already guarded by a separate 'if limit < len(all)', so no actual OOB occurred, but limit>len(all) vs limit>=len(all) are behaviorally identical here (both return all items + empty nextToken when limit==len(all)). Switched to >= for clarity + to silence the scanner. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
agbishop
enabled auto-merge (squash)
July 16, 2026 15:01
| if err != nil { | ||
| return fmt.Errorf("create file %q: %w", destPath, err) | ||
| } | ||
| defer outFile.Close() |
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.
Idiomatic file/test reorganization (21 services) + DynamoDB concurrency fixes
Pure-reorganization refactor pass (behavior identical, verbatim code moves) plus real DynamoDB deadlock/panic fixes discovered along the way.
Refactor — 21 services
Each service: giant files split into idiomatically-named op-family parts (
models.go,errors.go,backend_<family>.go,handler_<family>.go); every sequence/category-tagged file (*_batch2,*_refinement3,*_accuracy,*_parity,*_new_ops,*_stubs,*_audit1…) eliminated — source and test; goofyTest<Batch2/Parity/Refinement>_func prefixes stripped; tests consolidated per source/op-family (all cases preserved); tables +t.Parallel()where reasonable; and all//nolint:funlen/gocyclo/cyclop/gocognitremoved by actual refactoring (zero new nolint).Services: cloudfront, glue, lambda, s3, rds, eventbridge, backup, dms, sns, kms, sagemaker, ec2, iam, ecs, iot, s3control, elasticache, redshift, ssm, opensearch, cognitoidp.
Every service verified whole-package green:
go build·go test -race·go vet·go fix -diff·golangci-lint(0 issues) ·gofmt.DynamoDB concurrency fixes (real bugs)
stopTableTimersiteratedGlobalSecondaryIndexeswithouttable.mu, racing a concurrent GSI-delete that shrinks the slice → index-out-of-range panic → recovered by the HTTP panic-recovery middleware (the observed "14 PanicRecovery worker errors") → orphanedtable.mu→ next PutItem blocks forever. Fixed by locking the iteration.table.muthen acquireddb.mu(reverse of thedb.mu → table.muorder) → deadlock vsdb.mu-then-table.mureaders. Fixed by releasing table locks beforedb.mu(reconciled with fix(dynamodb): fix lock inversion in TransactWriteItems #2389).Unlock/RUnlock-at-each-return sites converted todeferso no recovered panic can ever leak a lock.-racedata races (DeleteTable/CreateTable field reads withouttable.mu) fixed; full lock-order re-audit (no remaining ABBA / recursive-RLock).concurrent_table_lifecycle_test.go,TestStopTableTimers_ConcurrentGSIDelete_NoPanic.Follow-ups (filed in bd)
🤖 Generated with Claude Code