feat(agents): per-instance container reconciliation (startup + CRUD) #110
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!110
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "boss/52"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds
src/container-reconcile.ts— the diff-and-apply layer between the SQLiteagentstable and the set of runningclaude-hooks-<instance>Docker containers. Two entry points:reconcileAll()for the service-startup andjust agents-syncpaths;reconcileOne(name)for the dashboard CRUD endpoints (A6) to call after a row mutation commits.main.tsruns reconcile afterloadWebhookConfigand beforestartSweeper, logging one line per class (created/removed/unchanged).just agents-syncrecipe +import.meta.mainCLI in the module invoke the same path; systemd'sExecStartPrenow calls it instead ofcontainers-up, so the fleet converges before the service even starts.just containers-rebuild:docker run -dwith named state volume (claude-hooks-<instance>-state), directory-mount credentials, env-file-fed Forgejo token. Drift on image orcredentials_host_dirtriggers stop+rm+run (volume survives). Orphans are removed.container.enabled: false, remove on DB delete, and the "non-existent name" no-op.Test plan
bun test src/container-reconcile.test.ts— 15 new tests covering the decision matrix, name/volume derivation edge cases (hyphens, digits, invalid chars), reconcileAll with orphans, reconcileAll with matching containers, resolveImage precedence.bun test— full suite 367/367 green.bunx tsc --noEmitclean.bunx biome check src/+biome format src/clean.Closes #52.
🔴 REQUEST_CHANGES — reviewer bot
CI: ✅ green (run #1656, 2m51s)
The overall design is solid — pluggable
DockerRunner, clean decision matrix, correct temp-envfile lifecycle (mode 0600,finally-unlinked), and the right startup ordering (loadWebhookConfig→ reconcile →startSweeper). One acceptance-criterion gap in test coverage blocks approval.Must fix
Missing test: credentials-dir drift must trigger recreation
File:
src/container-reconcile.test.ts,reconcileOnedescribe blockAC (issue #52, Lifecycle rules): "Config change (image, credentials path): recreate the container"
matchesDesiredincontainer-reconcile.tschecks bothsnap.image !== imageandmountedAt !== credsDir, so the code is correct. But only image drift is exercised in tests. Add a parallel test for the credentials-dir path:Informational (no change required)
just containers-rebuildcreates type-named containers (claude-hooks-boss, notclaude-hooks-boss-default). Afteragents-syncruns these become orphans and get torn down — which is the correct migration path, but could surprise operators who still reach forcontainers-rebuild. A short deprecation note on that recipe would prevent confusion. Not blocking.ensureTmpdiris exported but never imported by the test file (the export comment says "for test symmetry" but the tests don't use it)./tmpalways exists on Linux so the function is a no-op in production. Dead export — harmless, remove at leisure. Not blocking.Escalating the reviewer bot's change request into a formal review so the
address-reviewwebhook fires.See the full feedback in issuecomment-6067 — single must-fix:
Missing test: credentials-dir drift must trigger recreation (
src/container-reconcile.test.ts). The code path inmatchesDesiredchecksmountedAt !== credsDir, but only the image-drift branch is exercised. Add the parallel test the reviewer drafted (code already written in the comment, paste as-is).The two "informational" items (containers-rebuild deprecation note, unused
ensureTmpdirexport) are non-blocking — operator call whether to fold them in.Follow-up: the reviewer skill should post pull-reviews via
create_pull_reviewwithstate: REQUEST_CHANGES, not plain issue comments, so the webhook dispatch works end-to-end without this manual escalation step. Tracked separately.Addressed in
7d9577d. All three items folded in:recreates when the running container's credentials dir driftedtest insrc/container-reconcile.test.ts, pasted as drafted. 368/368 green.containers-rebuildconfusion — added a deprecation block-comment directing operators tojust agents-syncand explaining the type-vs-instance naming drift that leaves orphans.ensureTmpdirexport — removed, along with the now-unusedmkdirimport.bun x tsc --noEmit+bun x biome check src/clean.7d9577d0cc6bac8f5609