Repository navigation
fix(lambda): add an opt-in cleanup sweep - #986
Conversation
Add enable_cleanup_schedule (default false) and cleanup_schedule to the Lambda module and the AWS environment, a cleanup entry in sweep_tasks (rule name <stack>-sweep-cleanup, clear of the unconsumed cleanup-lambda module's <stack>-cleanup), tftest assertions for the default and opt-in runs, and drop cleanup from the aws-lambda knownGaps. The server cleanup task deletes expired sessions and, via CleanupOldExecutions(30), completed executions (scheduled_date), canceled executions (updated_at) and executions outside failed/canceled (expires_at) older than 30 days, so it stays opt-in: the first run deletes the whole backlog. Part of #712 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
State the exact CleanupOldExecutions(30) retention in DEPLOYMENT.md and add the AWS Lambda opt-in variables. In known_issues/33 correct the Status (retention is unscheduled by default on AWS, GCP and CFN), fix the handler line reference and note the Lambda opt-in. Part of #712 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The old pattern also matched an unterminated "false and values such as falsey. Add a negative fixture for both. Part of #712 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 9 billable files and costs up to $2.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 46 minutes for your next included review. View limit details
Comment |
Independent review verdict: CLEAN at d58ec6eReviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. The PR body was treated as a claim. No cloud credentials were used, and no plan or apply was run against a real backend. Coordinator: claude-cc-reviewer. Blocking findings: none. Default dev apply should be a no-op:
When enabled:
Docs match the SQL (
The first-run backlog warning is in DEPLOYMENT.md, both variable descriptions and known_issues/33. What was attacked and how:
Gate:
|
|
Merge driver status (claude-cc-pr-merge, 2026-10-17T15:25:27Z): code gate met, merge BLOCKED on @cristim's explicit OK for the dev deploy. Merging to main runs the existing deploy workflows (Terraform apply to dev), and merge-driver sessions are not permitted to trigger that, so a maintainer must merge or approve it (the review expects a no-op apply with defaults). |
|
Gate record for d58ec6e (claude-cc-pr-merge-2):
|
Part of #712. This adds an opt-in cleanup sweep on AWS Lambda ("A1b2" in the #712 plan) and corrects the retention docs.
Changes
terraform/modules/compute/aws/lambdaenable_cleanup_schedule(default false) andcleanup_schedule(rate(1 day)).cleanupentry insweep_tasks, which creates<stack>-sweep-cleanup. That name does not collide with the unconsumedaws/cleanup-lambdamodule's<stack>-cleanuprule.terraform/environments/aws: the same variable pair, passed tomodule "compute_lambda"only.tests/sweeps.tftest.hcl: cleanup is absent in the defaults run and present in the opt-in run, with the same name, schedule and input assertions as the other sweeps.scheduled_task_coverage_test.go: theaws-lambdaknownGaps entry, which held onlycleanup, is removed. A missing cleanup sweep or pass-through now fails the test.scheduled_task_env_test.go:tfvarsOffRenow matches exactlyfalseor"false", optionally followed by a#or//comment. It no longer matches an unterminated"falseorfalsey. New fixtures cover both.docs/DEPLOYMENT.md, "Database Cleanup Jobs"CleanupOldExecutions(30)exactly.known_issues/33_executions_retention_cleanup.mdWhy opt-in
The owner decided this after the retention finding.
cleanupdeletes expired sessions and, throughCleanupOldExecutions(30):scheduled_dateis more than 30 days old;updated_atis more than 30 days old;expires_atis more than 30 days past.Failed executions are kept. Nothing has ever run cleanup on AWS, so the first enabled run deletes the whole backlog. Operators enable it per environment after deciding whether to keep that history.
Deploy note
Merging triggers
deploy-aws-lambda.ymlto dev, because it touchesterraform/environments/aws/**and the lambda module. The default is off, so the dev apply creates no new rule and changes no behaviour.Verification (macOS)
Terraform 1.10.5 (CI's pin) and 1.14.7, on the lambda module:
init -backend=false -lockfile=readonly,fmt -check -recursive,validateandtestall pass (2 runs).terraform/environments/awsvalidates.Go:
go test ./terraform/modules/compute ./internal/server -count=3 -shuffle=onpasses.go vet ./...is clean.make lint(go1.26.9) reports 0 issues.Mutation probes (each reverted, each makes a test fail):
compute.tf: "undocumented gap: cleanup";sweep_tasks;tfvarsOffRerestored: the new fixture fails;#-only comment handling restored: the// notefixture fails.A scratch tfvars containing
enable_finalize_revocations_schedule = false // xis now caught.The retention text was checked against
internal/config/store_postgres.go(CleanupOldExecutions),types.go(HealthScoredExecutionStatuses) andinternal/server/handler.go:272.Not verified: a real AWS run of cleanup. It stays off until an operator enables it.
Review
A non-author adversarial reviewer ran two passes. Pass 1 found three low-severity issues, all fixed: stale known_issues wording, the
//comment regression, and the Azure wording. Pass 2 had no actionable findings.The rebase onto main after #949 merged is clean: range-diff
=on all three commits. A fresh independent gate review at the head SHA is still needed.🤖 Generated with Claude Code