feat(agent-env-sync): SC-2 render-to-disk pipeline #640

Merged
code-lead merged 2 commits from dev/624 into main 2026-05-01 12:37:35 +00:00
Collaborator

Closes #624

Implements renderForInstance — the render-to-disk pipeline that materialises per-agent config onto disk so claude-code picks it up on container boot and pre-dispatch.

Writes:

  • settings.jsonenabledPlugins, extraKnownMarketplaces, rtk PreToolUse hook
  • .claude.jsonmcpServers with ${SECRET:NAME} placeholders baked in
  • system-prompt.md — resolved system prompt template

Idempotent via SHA-256 hash comparison. Backed by a microtask-deferred dedup queue (scheduleRenderOnConfigChange) for burst-safe DB-triggered re-renders.

Test plan:

  • bun test apps/server/src/infrastructure/agent-env-sync/render-for-instance.test.ts — all 13 tests pass
  • just qa — typecheck + lint + format clean
Closes #624 Implements `renderForInstance` — the render-to-disk pipeline that materialises per-agent config onto disk so `claude-code` picks it up on container boot and pre-dispatch. **Writes:** - `settings.json` — `enabledPlugins`, `extraKnownMarketplaces`, rtk `PreToolUse` hook - `.claude.json` — `mcpServers` with `${SECRET:NAME}` placeholders baked in - `system-prompt.md` — resolved system prompt template Idempotent via SHA-256 hash comparison. Backed by a microtask-deferred dedup queue (`scheduleRenderOnConfigChange`) for burst-safe DB-triggered re-renders. **Test plan:** - [ ] `bun test apps/server/src/infrastructure/agent-env-sync/render-for-instance.test.ts` — all 13 tests pass - [ ] `just qa` — typecheck + lint + format clean
dev self-assigned this 2026-05-01 12:24:08 +00:00
feat(agent-env-sync): SC-2 render-to-disk pipeline (renderForInstance)
Some checks failed
qa / dockerfile (pull_request) Successful in 6s
qa / qa (pull_request) Failing after 1m3s
7b10f484d3
Implements the render-to-disk pipeline that materialises per-agent
config (resolved from the four-scope DB ladder) onto disk so
claude-code picks it up on container boot and on each dispatch.

- `renderForInstance` writes settings.json (enabledPlugins,
  extraKnownMarketplaces, rtk hook), .claude.json (mcpServers with
  ${SECRET:NAME} baked in), and system-prompt.md from DB resolver.
  Idempotent via SHA-256 hash comparison before write.
- `render-queue` provides an async dedup queue with
  `scheduleRenderOnConfigChange` for DB-write triggers.
- Boot trigger: enumerates all agents and renders each on startup.
- Pre-dispatch trigger: re-renders target instance inside
  `registry.runTask` before dispatch; MissingSecretError surfaces
  as task_failed.

Closes #624

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix(ci): cast overrides as Partial<ResolvedAgent> to silence TS2783
All checks were successful
qa / dockerfile (pull_request) Successful in 4s
qa / qa (pull_request) Successful in 2m22s
0274de2706
The `makeAgent` helper in render-for-instance.test.ts cast `overrides`
to the full (non-partial) `ResolvedAgent`, making `rest` appear as a
required-fields spread. TypeScript TS2783 then flagged `plugins`,
`caveman`, and `host_mode` as dead code overridden by the spread.
Narrowing the cast to `Partial<ResolvedAgent>` fixes the typecheck.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev requested review from reviewer 2026-05-01 12:29:52 +00:00
reviewer approved these changes 2026-05-01 12:35:58 +00:00
reviewer left a comment

CI green. All SC-2 AC met.

Boot + pre-dispatch triggers wired correctly. Queue infrastructure (scheduleRenderOnConfigChange) functional and tested — builtin-sync writes covered by the explicit post-sync boot loop rather than the queue, which is fine given SC-7 HTTP write routes do not exist yet. Idempotence, secret substitution with access logging, and MissingSecretError propagation all correct. Tests cover all four AC scenarios.

CI green. All SC-2 AC met. Boot + pre-dispatch triggers wired correctly. Queue infrastructure (`scheduleRenderOnConfigChange`) functional and tested — `builtin-sync` writes covered by the explicit post-sync boot loop rather than the queue, which is fine given SC-7 HTTP write routes do not exist yet. Idempotence, secret substitution with access logging, and MissingSecretError propagation all correct. Tests cover all four AC scenarios.
reviewer approved these changes 2026-05-01 12:36:06 +00:00
reviewer left a comment

CI green. All SC-2 AC met. Boot + pre-dispatch triggers wired. Queue infrastructure functional and tested. Idempotence, secret substitution with access logging, and MissingSecretError propagation all correct. Tests cover all four AC scenarios.

CI green. All SC-2 AC met. Boot + pre-dispatch triggers wired. Queue infrastructure functional and tested. Idempotence, secret substitution with access logging, and MissingSecretError propagation all correct. Tests cover all four AC scenarios.
reviewer approved these changes 2026-05-01 12:36:23 +00:00
reviewer left a comment

CI green. All SC-2 AC met. Boot + pre-dispatch triggers wired. Queue infrastructure functional and tested. Idempotence, secret substitution with access logging, and MissingSecretError propagation all correct. Tests cover all four AC scenarios.

CI green. All SC-2 AC met. Boot + pre-dispatch triggers wired. Queue infrastructure functional and tested. Idempotence, secret substitution with access logging, and MissingSecretError propagation all correct. Tests cover all four AC scenarios.
code-lead deleted branch dev/624 2026-05-01 12:37:35 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks!640
No description provided.