diff --git a/CLAUDE.md b/CLAUDE.md index dd8c7a79..bf10679a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -216,7 +216,7 @@ OPENAI_API_KEY=... bash scripts/test-team-e2e.sh # E2E: Multi-template ### Unit Tests ```bash -cd platform && go test -race ./... # 731 Go tests (handlers, registry, provisioner, CLI, delegation, org, channels, wsauth — sqlmock + miniredis; +2 on 2026-04-14 tick-4 for TestSetGlobal_* / TestDeleteGlobal_* auto-restart branches (#64); +4 on 2026-04-14 tick-4 for TestRestartContext_* covering the synthetic restart-context A2A message (#65); +5 on 2026-04-14 tick-6 for TestPlugins_* covering the new UNION + `!`/`-` opt-out semantics in org.go mergePlugins (#71, resolves issue #68); raw PASS-line count is higher due to table-driven subtests) +cd platform && go test -race ./... # 740 Go tests (handlers, registry, provisioner, CLI, delegation, org, channels, wsauth — sqlmock + miniredis; +2 on 2026-04-14 tick-4 for TestSetGlobal_* / TestDeleteGlobal_* auto-restart branches (#64); +4 on 2026-04-14 tick-4 for TestRestartContext_* covering the synthetic restart-context A2A message (#65); +5 on 2026-04-14 tick-6 for TestPlugins_* covering the new UNION + `!`/`-` opt-out semantics in org.go mergePlugins (#71, resolves issue #68); +9 on 2026-04-14 tick-7 for TestCategoryRouting_* / TestAppendYAMLBlock_* (#75) + TestRuntimeSchedule_HasSourceRuntime / TestImport_OrgScheduleSQLShape / TestList_IncludesSourceColumn (#76); raw PASS-line count is higher due to table-driven subtests) cd canvas && npm test # 357 Vitest tests (store, components, hydration, buildTree, secrets API, org template import, ConfirmDialog singleButton + 7 native-dialog replacements) cd workspace-template && python -m pytest -v # 1140 pytest tests (adds platform_auth token store for Phase 30.1, memory_write activity logging) cd sdk/python && python -m pytest -v # 132 SDK tests (agentskills.io spec validator, CLI, AgentskillsAdaptor round-trip, workspace/org/channel validators, RemoteAgentClient Phase 30 flows) @@ -410,7 +410,7 @@ Agents can auto-execute a prompt on startup before any user interaction. Configu ## Database -16 migration files in `platform/migrations/`. Key tables: `workspaces` (core entity with status, runtime, agent_card JSONB, heartbeat columns, current_task, awareness_namespace, workspace_dir), `canvas_layouts` (x/y position), `structure_events` (append-only event log), `activity_logs` (A2A communications, task updates, agent logs, errors), `workspace_schedules` (cron tasks with expression, timezone, prompt, run history), `workspace_channels` (social channel integrations — Telegram, Slack, etc., with JSONB config and allowlist), `agents`, `workspace_secrets`, `global_secrets`, `agent_memories` (HMA scoped memory), `approvals`. +23 migration files in `platform/migrations/` (up to `022_workspace_schedules_source` — 2026-04-14 tick-7, PR #76). Key tables: `workspaces` (core entity with status, runtime, agent_card JSONB, heartbeat columns, current_task, awareness_namespace, workspace_dir), `canvas_layouts` (x/y position), `structure_events` (append-only event log), `activity_logs` (A2A communications, task updates, agent logs, errors), `workspace_schedules` (cron tasks with expression, timezone, prompt, run history, and `source` — `'template'` for org/import-seeded, `'runtime'` for Canvas/API-created; org/import is additive and only refreshes template-source rows on re-import), `workspace_channels` (social channel integrations — Telegram, Slack, etc., with JSONB config and allowlist), `agents`, `workspace_secrets`, `global_secrets`, `agent_memories` (HMA scoped memory), `approvals`. The platform auto-discovers and runs migrations on startup from several candidate paths. diff --git a/PLAN.md b/PLAN.md index e1ee3066..52b9d061 100644 --- a/PLAN.md +++ b/PLAN.md @@ -239,6 +239,11 @@ point for "what else is out there." - **GitHub issue #15** — Provisioner: auto-refresh `CLAUDE_CODE_OAUTH_TOKEN` from `global_secrets` on workspace restart → **DONE** via PR #64 (`SetGlobal` / `DeleteGlobal` now fan out `RestartByID` to every affected workspace). - **GitHub issue #19 Layer 1** — Platform-generated restart context → **DONE** via PR #65 (synthetic A2A `message/send` with `metadata.kind=restart_context`, `system:restart-context` caller prefix, 30s re-register wait). Layer 2 deferred to issue #66 (see Backlog item 15 above). +### Recently launched (2026-04-14 tick-7) +- **GitHub issue #24** — Runtime-added workspace_schedules drift on org re-import → **DONE** via PR #76 (new `source` column on `workspace_schedules` via migration `022`; org/import now upserts with `ON CONFLICT (workspace_id, name) DO UPDATE ... WHERE source='template'`, so runtime-added rows survive re-imports; legacy rows backfilled to `'template'`; +3 tests). +- **GitHub issue #51** — PM hardcoded audit-category routing → **DONE** via PR #75 (generic `category_routing:` block in `org-templates//org.yaml` `defaults` + per-workspace override; rendered into each workspace's `config.yaml` via `renderCategoryRoutingYAML` using `yaml.Node` + `yaml.Marshal` for safe escaping; PM prompt replaced with generic config-lookup; +6 tests). +- **PR #74** — `org-templates/molecule-dev/org.yaml` role overrides shrunk to just the deltas now that UNION semantics (PR #71) are in effect — removes verbose re-listing of defaults across PM, Research Lead, Research sub-roles, Security Auditor, UIUX Designer. + ### Recently launched (2026-04-14 tick-6) - **GitHub issue #68** — Per-workspace `plugins:` REPLACE semantics caveat → **DONE** via PR #71 (`mergePlugins` helper in `platform/internal/handlers/org.go` now UNIONs per-workspace with `defaults.plugins`; `!plugin` or `-plugin` prefix on a per-workspace entry opts a default out; +5 `TestPlugins_*` tests). Role overrides in `org-templates/*/org.yaml` can now declare just the delta instead of restating every default. diff --git a/docs/edit-history/2026-04-14.md b/docs/edit-history/2026-04-14.md index b12a6a04..32525732 100644 --- a/docs/edit-history/2026-04-14.md +++ b/docs/edit-history/2026-04-14.md @@ -389,3 +389,76 @@ tick-5 section of this file (see above). Nothing to re-sync here. - `README.md` / `README.zh-CN.md` — no change (semantics are internal to org-template resolution). + +## Summary — tick-7: DB-authoritative schedules (#76), generic category_routing (#75), template cleanup (#74) + +Four merges this tick: PR #73 (docs sync tick-6), PR #74 (template plugin +cleanup), PR #75 (category_routing for #51), PR #76 (schedules source column +for #24). The latter two close GitHub issues #51 and #24. + +### PR #76 — `fix(org): DB-authoritative schedules; additive org/import (#24)` +Merge commit `07a5ca3c`. Closes #24. +- New migration `022_workspace_schedules_source.{up,down}.sql` adds a `source` + TEXT column (`'template'` | `'runtime'`) with a CHECK constraint and a + unique `(workspace_id, name)` index. Legacy rows are backfilled to + `'template'` before the column is flipped `NOT NULL DEFAULT 'runtime'`. +- Import SQL is extracted to `const orgImportScheduleSQL` in `org.go` and + upserts with `ON CONFLICT (workspace_id, name) DO UPDATE ... WHERE + workspace_schedules.source = 'template'` — runtime-added schedules with + colliding names survive re-imports. +- `schedules.Create` writes `source='runtime'` explicitly; `schedules.List` + returns the field (with `json:",omitempty"` so old clients don't see + an empty string). +- +3 tests: `TestRuntimeSchedule_HasSourceRuntime`, + `TestImport_OrgScheduleSQLShape` (asserts against the const directly, + no file-scraping), `TestList_IncludesSourceColumn`. + +### PR #75 — `feat(platform): generic category_routing replaces hardcoded audit dispatch (#51)` +Merge commit `dee5322d`. Closes #51. +- `OrgDefaults` + `OrgWorkspace` gain `CategoryRouting map[string][]string`. + Merge semantics: workspace keys replace defaults' value for the same key + (empty list drops the key); new keys are added. +- `renderCategoryRoutingYAML` builds a deterministic YAML block via + `yaml.Node` + `yaml.Marshal` (sorted keys; YAML library handles escaping + of role names with reserved chars). +- New `appendYAMLBlock` helper guarantees a newline boundary when + concatenating YAML fragments into `config.yaml`; applied to both the + `category_routing` and `initial_prompt` appends. +- `org-templates/molecule-dev/org.yaml` gets a `defaults.category_routing` + block; `pm/system-prompt.md` replaces the hardcoded role-mapping table + with a generic config-lookup pattern ("read `/configs/config.yaml`, + look up `category_routing[]`"). +- +6 tests covering parse, union-with-defaults, integration into workspace + config, YAML-specials escaping, empty-renders-nothing, and the newline + guard. + +### PR #74 — `chore(template): simplify per-role plugin lists using #71 union semantics` +Merge commit `20068196`. Follow-up to PR #71. +- `org-templates/molecule-dev/org.yaml` PM, Research Lead + 3 sub-roles, + Security Auditor, UIUX Designer role overrides shrunk to just the + deltas (e.g. PM goes from 11 entries to `[molecule-workflow-triage, + molecule-workflow-retro]`; Research roles go from 10 entries to + `[browser-automation]`). +- No platform changes; relies on UNION semantics landed in PR #71 (tick-6). + +### PR #73 — `docs: sync documentation with 2026-04-14 tick-6 merges (#71, #72)` +Merge commit `911580c6`. Routine docs sync for the prior tick. + +### File deltas +- `CLAUDE.md` — Go test count 731 → 740; migration count 16 → 23; added + `workspace_schedules.source` note in the Database section. +- `PLAN.md` — new "Recently launched (2026-04-14 tick-7)" section. +- `platform/internal/handlers/org.go` — `OrgDefaults.CategoryRouting`, + `OrgWorkspace.CategoryRouting`, `mergeCategoryRouting`, + `renderCategoryRoutingYAML`, `appendYAMLBlock`, `orgImportScheduleSQL` + const, schedules upsert wired to the const. +- `platform/internal/handlers/schedules.go` — `scheduleResponse.Source`, + `Create` inserts with `source='runtime'`, `List` reads `source`. +- `platform/internal/handlers/schedules_test.go` — new file. +- `platform/internal/handlers/org_test.go` — `TestCategoryRouting_*` + + `TestAppendYAMLBlock_NewlineGuard`. +- `platform/migrations/022_workspace_schedules_source.{up,down}.sql` — new. +- `org-templates/molecule-dev/org.yaml` — `defaults.category_routing` + added; per-role plugin lists trimmed to deltas. +- `org-templates/molecule-dev/pm/system-prompt.md` — hardcoded category + table replaced with generic config-lookup instructions.