refactor(sweep): tenacity-based resilience core + hermetic tests (#924, stacked on #933) #936
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 444 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #936"
general
weight: 0.35
shapirov103
Sweep resilience core + module split — #924 (sweep half)
Base
main(#933fix/teardown-sweep-zero-residueis merged). Ready to merge.This is the sweep half of #924: it splits the 1417-line
sweep-workshop-resources.pymonolith into a focused
workshop/scripts/sweep/package and lands a reusableresilience core, without regressing the zero-residue behavior from #933.
What this delivers
+2642 / −1382, 26 files): the entrypoint is now a thinorchestrator over a
sweep/package —resilience.py,context.py,orchestrator.py, and 16 per-service reapers (reapers/: eks, ec2/vpc,eip, ecr, rds, s3, elb, iam, secrets, logs, cloudfront, grafana, amp, verify,
resweep, finalnet). Section order §1–§17 is preserved and the
VPC-ownership safety guards (never touch a
aws:cloudformation:*-tagged /IDE VPC) are carried over intact.
resilience.py— centralized AWS error classification in one place(
classify→gone/access_denied/transient/permanent), plusretry_aws/poll_untilto replace hand-rolledfor i in range(N): … time.sleep(S)loops.the teardown CodeBuild (
amazonlinux2-standard:5.0) whose buildspecinstalls helm/terraform/kubectl/yq but no
pip. This is adestruction-critical path that must never hard-fail on a missing dependency, so
the module bootstraps tenacity and degrades to a stdlib retry shim if it can't.
test_sweep_resilience.py+test_sweep_orchestration.py)— fake boto3, no network, no real sleeping; both the tenacity and stdlib
fallback paths are exercised. 61 test cases pass.
Scope — what tenacity retry does and does NOT cover yet (honest)
Retry/backoff via
retry_awscurrently engages mainly in the new final-netreaper and in the shared
vpc.reap_single_vpcre-drive. The 15 pre-existingsections were relocated, not yet re-wired onto
classify()/retry_aws— thatbroader, section-by-section adoption follows incrementally, which is the right
call on a destruction-critical path. This PR does not claim tenacity is adopted
everywhere; it lands the tested core + the split and wires retry where it earns
its keep first.
Review fixes applied (shapirov103 on this PR)
1.
classify()no longer reports real failures as "already gone" — checkaccess_deniedbeforegone, drop the genericInvalidParameterValuefromGONE_CODES, and apply the message-substring heuristic only when the errorcode is otherwise unrecognised. Closes the #932 mode (a hidden
AccessDenied)and stops counting failed deletes as successes in
finalnet.run.2.
poll_untilfallback parity — the stdlib-fallback branch now wraps thecall in
try/exceptso a raising predicate yields a timeout (False)identically to the tenacity branch; previously it would propagate and silently
skip a whole section in the CodeBuild (no-tenacity) path.
3.
vpc.reap_single_vpc—delete_vpcattempts=1→attempts=3, wait=5,so
retry_awsactually absorbs the transientDependencyViolationwithin apoll iteration, matching its docstring.
4.
logs.reap_log_groups— recordserror_code(e)instead ofe.__class__.__name__(alwaysClientError), making the #932AccessDenieddiagnostic real.
Regression tests added for the misclassification and raising-predicate cases.
Refs #924. Companion to the IDC half in #935.