Skip to content

Simplify agent work completion and status classification#204

Open
arjunkomath wants to merge 1 commit into
mainfrom
refactor/code-simplification
Open

Simplify agent work completion and status classification#204
arjunkomath wants to merge 1 commit into
mainfrom
refactor/code-simplification

Conversation

@arjunkomath

Copy link
Copy Markdown
Member

Summary

Implements four items from the code-simplification review, net −35 lines with three duplicated decision points collapsed to one each.

One completion protocol for agent work

Backup and restore now complete through the existing work-item result path (POST /api/v1/agent/status) instead of dedicated callback endpoints:

  • WorkItemResult gains a typed output field; completion side effects for backup_volume (row update + resourceStatusChanged) and restore_volume (restore/migration events) run in completeWorkItemResults, fenced by (serverId, workId, attempt) so stale attempts can't clobber final state.
  • Deleted: backup/complete, backup/failed, restore/complete routes; ReportBackupComplete/ReportBackupFailed/ReportRestoreComplete client methods; the agent's entire reportFailure callback pattern in backup.go.

Typed work-queue payloads

WorkPayloadByType maps every work type to its payload shape and enqueueWork is generic over it. This caught two real issues: a nullable storagePath could reach restore payloads (now guarded), and the autoheal payloads were untyped.

Traefik state compiled once per snapshot

CompiledTraefikState converts and hashes routing data once per expected-state snapshot (memoized by snapshot identity). Drift planning, Traefik application, and routing-sync reporting consume the same compiled snapshot, so no path can compute convergence differently.

Consolidated status classification

Replaced ~12 inline ["healthy", "running"] sets with observedReadyPhases/isObservedReady across workflows, DB queries, and dashboard components. Intentionally-different sets (rollout progress UI, serverless wake handling) left untouched.

Docs

Rewrote AGENT.md (project facts, repo map, verified commands, completed the critical-restrictions section) and symlinked CLAUDE.md to it so agents load it automatically.

Testing

  • web: tsc --noEmit clean, all 290 tests pass, biome clean
  • agent: go build, go vet, go test pass, gofmt clean

🤖 Generated with Claude Code

- Unify backup/restore completion through the work-item result protocol:
  the agent reports terminal outcomes (with typed output) via the status
  endpoint's attempt-fenced completion path, and the dedicated
  backup/complete, backup/failed, and restore/complete callback routes
  are deleted along with the agent's HTTP report methods.
- Add WorkPayloadByType so enqueueWork is compile-time checked per work
  type; fixes a nullable storagePath slipping into restore payloads and
  types the autoheal payloads.
- Compile Traefik desired state (routes, certs, ports, hashes) once per
  expected-state snapshot; drift planning, application, and routing-sync
  reporting now share one immutable compiled snapshot.
- Reuse observedReadyPhases/isObservedReady from deployment-status.ts
  instead of inline ["healthy", "running"] sets across workflows,
  queries, and dashboard components.
- Rewrite AGENT.md (project facts, repo map, verified commands) and
  symlink CLAUDE.md to it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

React Doctor found no issues. 🎉

⚠️ Warning: .github/workflows/react-doctor.yml is configured incorrectly. See below to fix.

React Doctor compares against main to report only the issues this pull request introduces. This run couldn't complete that comparison (usually a shallow CI checkout with no merge base), so it listed every issue in the changed files, including ones that already existed on main.

Add fetch-depth: 0 to the actions/checkout step in .github/workflows/react-doctor.yml so the checkout includes the history React Doctor needs:

 jobs:
   react-doctor:
     steps:
       - uses: actions/checkout@v5
+        with:
+          fetch-depth: 0

       - uses: millionco/react-doctor@v2

To silence this warning, set silence-missing-baseline-warning: true on the React Doctor action.

Reviewed by React Doctor for commit b5d420f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant