chore: remove dead code, scratch artifacts, and harden deploy infra (#782) - #890
Conversation
…782) - Remove no-op by_day field + TODO from MetricsTracker.get_token_usage_stats - Delete orphaned IssueGenerator planning module and its tests - Remove dead expressions and unread BatchRun.isolate field from conductor - Drop unused claude-agent-sdk dependency (uv.lock regenerated) - Delete tracked .py.backup and tests/debug scratch files - .gitignore: add generic *.backup and *.log, drop stale/redundant entries - systemd health-check timer: single 02:00 schedule (was firing at 00:00 too) - deploy.yml: least-privilege permissions block; pinned SSH_KNOWN_HOSTS secret replaces live ssh-keyscan TOFU in both deploy jobs
|
Claude finished @frankbria's task in 4m 40s —— View job GLM precision bug-hunting reviewScope: concrete defects only (logic errors, crashes, data loss, security, contract breaks, leaks). Style/coverage is out of scope — a general review handles those. ✅ GLM review: no defects found. I verified each removal/behavior-change against the checked-out code, not just the diff: Dead-code removals — confirmed zero product-code consumers:
Infra changes — checked for real failure scenarios:
No defect could be stated with a concrete failure scenario, so nothing is reported. |
Demo: acceptance criteria → outcome evidenceAll commands run against the PR branch working tree. 1. Each dead item removed, packages still import 2. 3. SSH_KNOWN_HOSTS pinned (no live keyscan) Plus a fail-fast guard when the secret is unset (lines 73/325). 4. 5. Backup/scratch/placeholder tests deleted 6. Quality gates: ruff clean, strict mypy clean, CodeRabbit CLI 0 findings, opencode (GLM) cross-family review: no Critical/Major (its one Minor — empty-secret guard — is included in this PR). |
Deploy has failed on every main push since #890 (2026-07-24) because that PR replaced live ssh-keyscan TOFU with a pinned host key from the SSH_KNOWN_HOSTS secret — but the secret was never populated, so the 'Add server to known hosts' step exits 1 on both the staging and production jobs. The real fix is operational (set the secret from a trusted machine after verifying the host fingerprint out-of-band). This change just makes the guard emit the exact command instead of pointing at a comment, matching the AUTH_SECRET guard already in this file.
Deploy has failed on every main push since #890 (2026-07-24) because that PR replaced live ssh-keyscan TOFU with a pinned host key from the SSH_KNOWN_HOSTS secret — but the secret was never populated, so the 'Add server to known hosts' step exits 1 on both the staging and production jobs. The real fix is operational (set the secret from a trusted machine after verifying the host fingerprint out-of-band). This change just makes the guard emit the exact command instead of pointing at a comment, matching the AUTH_SECRET guard already in this file.
…ing, pm2 env) (#1002) * fix(ci): make Deploy's missing SSH_KNOWN_HOSTS error actionable Deploy has failed on every main push since #890 (2026-07-24) because that PR replaced live ssh-keyscan TOFU with a pinned host key from the SSH_KNOWN_HOSTS secret — but the secret was never populated, so the 'Add server to known hosts' step exits 1 on both the staging and production jobs. The real fix is operational (set the secret from a trusted machine after verifying the host fingerprint out-of-band). This change just makes the guard emit the exact command instead of pointing at a comment, matching the AUTH_SECRET guard already in this file. * ci(deploy): reach the staging/prod box over Tailscale, not public :22 The VPS firewalls SSH off the public internet, so GitHub runners time out connecting to port 22 (they aren't on the box's allowlist). Add a Tailscale connect step to both deploy jobs so the runner joins the tailnet and reaches sshd privately — port 22 stays closed to the world. Requires (documented in deploy/README.md): TS_OAUTH_CLIENT_ID/SECRET secrets, the box on the tailnet with 'ufw allow in on tailscale0 to any port 22', a tag:ci ACL, HOST repointed to the tailnet name/IP, and SSH_KNOWN_HOSTS relabelled to that HOST. * fix(deploy): cold-start pm2 from ecosystem so new .env vars propagate The inline deploy script restarted the backend with `pm2 restart <name> --update-env`, which refreshes env from the deploy shell — but the shell never sources .env.staging, so vars ADDED to the env file (WORKSPACE_ROOT, CODEFRAME_DEPLOYMENT_MODE from #896) never reached the process. Only a fresh `pm2 start <ecosystem>` runs the ecosystem's dotenv.config() that loads the file. With the process already online it took the restart branch every time, so the backend crash-looped on startup ('WORKSPACE_ROOT must be set') and the health check failed — the last hidden breakage behind the deploy failures. Delete the codeframe apps by name (not `pm2 delete all`, which would kill unrelated apps on this shared VPS) and start fresh from the ecosystem, which re-reads .env every deploy. Same fix applied to the production job, which had the more basic `pm2 restart <name>` with no env refresh at all.
Closes #782
Summary
Batch cleanup from the SaaS launch-readiness audit (P3.11) — every flagged dead item is removed (none had product-code consumers), plus the two infra nits.
Dead code removed
MetricsTracker.get_token_usage_stats: always-emptyby_daykey, its docstring entry, and the TODO (real day aggregation lives inget_token_usage_timeseries)codeframe/planning/issue_generator.py(IssueGenerator,parse_prd_features,assign_priority) + its orphaned test module;planning/__init__.pytrimmedconductor.py: two no-op expression statements (completed_count + failed_count + blocked_count) and the unreadBatchRun.isolatefield /start_batch(isolate=)param (superseded byisolation; never persisted — no DB column, so existing databases are unaffected)claude-agent-sdkdependency (declared, never imported);uv.lockregenerated — exactly one package removedRepo hygiene
tests/*.py.backup(2) andtests/debug/scratch tests (2).gitignore: generic*.backupand*.logrules added; staletests/test_new_feature.pyentry and now-redundant specific log entries droppedInfra hardening
systemd/codeframe-health-check.timer: singleOnCalendar=*-*-* 02:00:00— multipleOnCalendar=lines are additive, so it was firing at both 00:00 and 02:00.github/workflows/deploy.yml: top-levelpermissions: contents: read(verified sufficient for the reusabletest.ymlit calls); both deploy jobs now write a pinnedSSH_KNOWN_HOSTSsecret instead of livessh-keyscan(TOFU), with a fail-fast guard when the secret is unsetCreate the
SSH_KNOWN_HOSTSrepo secret or the next deploy fails fast at "Add server to known hosts". From a trusted session:Verification
ruff check .clean; strictmypy codeframe/cleantest_worktrees.py,test_conductor.py,tests/planning/); two timing-flaky conductor tests failed only under heavy parallel load and pass in isolation — unrelated to this diff (conductor changes are behavior-neutral removals)Known limitations
get_token_usage_statsitself has no callers — out of scope here (issue names onlyby_day); candidate for a future cleanup issueSSH_KNOWN_HOSTSsecret must be rotated manually if the VPS host key changes