feat(agent-config): schema + builtin-sync for agent_type / service_config / label_catalog #761

Merged
charles merged 1 commit from code-lead/743 into main 2026-05-02 18:11:00 +00:00
Collaborator

Foundation tables + builtin-sync passes for the config-to-DB migration (AT-1 / SVC-1 / LBL-1).

Test plan

  • Migrations 004/005/006 idempotent across reboots; IF NOT EXISTS everywhere.
  • syncAgentTypeBuiltins upserts identity / container / routing rows; re-run is all-unchanged; vanished types shadowed (enabled=0).
  • syncServiceConfigBuiltin upserts the single builtin row; global override on container_image survives a builtin re-sync; webhook secret bytes migrate into the SC-6 secret table.
  • syncLabelCatalogBuiltin upserts one row per label; repo scope shadows global shadows builtin.
  • getAgentType joins identity + container + routing across the scope ladder; instance-scope routing row resolves correctly.
  • bun x turbo run typecheck lint test — 3100 tests pass, no new lint findings.

Closes #743 #750 #754

Foundation tables + builtin-sync passes for the config-to-DB migration (AT-1 / SVC-1 / LBL-1). ## Test plan - [x] Migrations 004/005/006 idempotent across reboots; `IF NOT EXISTS` everywhere. - [x] `syncAgentTypeBuiltins` upserts identity / container / routing rows; re-run is all-unchanged; vanished types shadowed (`enabled=0`). - [x] `syncServiceConfigBuiltin` upserts the single builtin row; global override on `container_image` survives a builtin re-sync; webhook secret bytes migrate into the SC-6 secret table. - [x] `syncLabelCatalogBuiltin` upserts one row per label; `repo` scope shadows `global` shadows `builtin`. - [x] `getAgentType` joins identity + container + routing across the scope ladder; instance-scope routing row resolves correctly. - [x] `bun x turbo run typecheck lint test` — 3100 tests pass, no new lint findings. Closes #743 #750 #754
feat(agent-config): schema + builtin-sync for agent_type / service_config / label_catalog
All checks were successful
qa / dockerfile (pull_request) Successful in 5s
qa / qa (pull_request) Successful in 2m46s
60943bbf5c
Foundation tables + builtin-sync passes for the config-to-DB migration:
- migrations 004/005/006 lay agent_type, agent_type_container,
  agent_type_routing, service_config, and label_catalog with the scope
  ladder + UNIQUE constraints from specs/config-to-db.md § Architecture.
- builtin-sync grows syncAgentTypeBuiltins, syncServiceConfigBuiltin,
  and syncLabelCatalogBuiltin — idempotent mirrors of agents.json,
  service.json, and labels.json into scope='builtin' rows. Removed
  agent types are shadowed (enabled=0), not deleted.
- resolver grows getAgentType (joined identity + container + routing),
  getServiceConfig, and getLabelCatalogForRepo. Operator overrides at
  global / agent_type / repo / instance scope shadow builtins.
- Webhook secret bytes now move into the SC-6 secret table on first
  boot (one-shot), with the file renamed to .<basename>.migrated.bak.

Closes #743 #750 #754

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
reviewer approved these changes 2026-05-02 18:04:32 +00:00
reviewer left a comment

CI green (run #2864). All AT-1 / SVC-1 / LBL-1 AC met.

  • Migrations 004/005/006 idempotent, scopes + UNIQUE constraints match spec.
  • syncAgentTypeBuiltins: upsert + shadow pattern (enabled=0) correct; container/routing rows wired.
  • syncServiceConfigBuiltin: webhook-secret one-shot migration path correct; global override preserved across re-sync.
  • syncLabelCatalogBuiltin: repo > global > builtin ladder correct.
  • getAgentType / getServiceConfig / getLabelCatalogForRepo scope ladders all correct.
  • Tests cover idempotent sync, scope ladder merge, shadow pattern, global-override preservation, and end-to-end via syncBuiltinsFromRepo.

nit (non-blocking): upsertAgentTypeRoutingRow returns early (skips the upsert) when all routing fields are absent or empty-array, but does not clear an existing builtin routing row — so a type that had routing and then clears all fields will leave a stale row in the DB. Not in AC scope for AT-1 (no consumer yet), but worth a comment or test in AT-2 before the resolver is wired.

nit: three inline require("node:fs") calls in the test file (lines 229 / 359 / 469) — top-level import is already there.

CI green (run #2864). All AT-1 / SVC-1 / LBL-1 AC met. - Migrations 004/005/006 idempotent, scopes + UNIQUE constraints match spec. - `syncAgentTypeBuiltins`: upsert + shadow pattern (enabled=0) correct; container/routing rows wired. - `syncServiceConfigBuiltin`: webhook-secret one-shot migration path correct; global override preserved across re-sync. - `syncLabelCatalogBuiltin`: repo > global > builtin ladder correct. - `getAgentType` / `getServiceConfig` / `getLabelCatalogForRepo` scope ladders all correct. - Tests cover idempotent sync, scope ladder merge, shadow pattern, global-override preservation, and end-to-end via `syncBuiltinsFromRepo`. nit (non-blocking): `upsertAgentTypeRoutingRow` returns early (skips the upsert) when all routing fields are absent or empty-array, but does not clear an existing builtin routing row — so a type that had routing and then clears all fields will leave a stale row in the DB. Not in AC scope for AT-1 (no consumer yet), but worth a comment or test in AT-2 before the resolver is wired. nit: three inline `require("node:fs")` calls in the test file (lines 229 / 359 / 469) — top-level import is already there.
charles deleted branch code-lead/743 2026-05-02 18:11:01 +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!761
No description provided.