@voybio/ace-swarm 2.4.3 → 2.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +72 -532
  3. package/assets/agent-state/INTERFACE_REGISTRY.md +2 -2
  4. package/assets/agent-state/MODULES/gates/gate-autonomy.json +4 -2
  5. package/assets/agent-state/MODULES/gates/gate-completeness.json +4 -2
  6. package/assets/agent-state/MODULES/gates/gate-operability.json +4 -2
  7. package/assets/agent-state/MODULES/gates/gate-security.json +3 -1
  8. package/assets/agent-state/MODULES/registry.json +1 -4
  9. package/assets/agent-state/MODULES/roles/capability-build.json +1 -2
  10. package/assets/agent-state/MODULES/roles/capability-eval.json +1 -1
  11. package/assets/agent-state/MODULES/roles/capability-qa.json +1 -2
  12. package/assets/agent-state/QUALITY_GATES.md +25 -9
  13. package/assets/agent-state/TEAL_CONFIG.md +2 -11
  14. package/assets/eval-battery/battery.json +85 -0
  15. package/assets/eval-battery/fixtures/edit-target.js +3 -0
  16. package/assets/scripts/render-mcp-configs.sh +12 -0
  17. package/dist/ace-context.d.ts +18 -0
  18. package/dist/ace-context.js +161 -16
  19. package/dist/ace-server-instructions.js +36 -9
  20. package/dist/astgrep-index.d.ts +7 -1
  21. package/dist/astgrep-index.js +66 -39
  22. package/dist/bridge-trace.d.ts +17 -0
  23. package/dist/bridge-trace.js +23 -0
  24. package/dist/cli.d.ts +9 -1
  25. package/dist/cli.js +619 -10
  26. package/dist/discovery-runtime-wrappers.d.ts +16 -1
  27. package/dist/discovery-runtime-wrappers.js +65 -9
  28. package/dist/eval-harness.d.ts +110 -0
  29. package/dist/eval-harness.js +254 -0
  30. package/dist/experience-reflector.d.ts +13 -0
  31. package/dist/experience-reflector.js +62 -0
  32. package/dist/gate-contract.d.ts +63 -0
  33. package/dist/gate-contract.js +178 -0
  34. package/dist/goal-engine.d.ts +155 -0
  35. package/dist/goal-engine.js +795 -0
  36. package/dist/helpers/store-resolution.js +40 -39
  37. package/dist/hermes/session-manager.d.ts +10 -0
  38. package/dist/hermes/session-manager.js +130 -27
  39. package/dist/job-scheduler.d.ts +58 -0
  40. package/dist/job-scheduler.js +202 -2
  41. package/dist/job-worker.d.ts +87 -0
  42. package/dist/job-worker.js +182 -0
  43. package/dist/local-model-policy.d.ts +8 -2
  44. package/dist/local-model-policy.js +31 -17
  45. package/dist/local-model-runtime.d.ts +6 -0
  46. package/dist/local-model-runtime.js +130 -2
  47. package/dist/measured-classing.d.ts +66 -0
  48. package/dist/measured-classing.js +165 -0
  49. package/dist/model-bridge.d.ts +45 -0
  50. package/dist/model-bridge.js +502 -44
  51. package/dist/orchestrator-supervisor.js +1 -1
  52. package/dist/plan-proposal.d.ts +7 -0
  53. package/dist/plan-proposal.js +74 -4
  54. package/dist/playbook-adaptation.d.ts +37 -0
  55. package/dist/playbook-adaptation.js +159 -0
  56. package/dist/playbook-curator.d.ts +16 -0
  57. package/dist/playbook-curator.js +106 -0
  58. package/dist/playbook-llm-reflector.d.ts +26 -0
  59. package/dist/playbook-llm-reflector.js +157 -0
  60. package/dist/public-surface.d.ts +2 -0
  61. package/dist/public-surface.js +26 -14
  62. package/dist/runtime-executor.js +45 -2
  63. package/dist/runtime-tool-specs.d.ts +8 -1
  64. package/dist/runtime-tool-specs.js +19 -1
  65. package/dist/safe-edit.d.ts +20 -0
  66. package/dist/safe-edit.js +355 -78
  67. package/dist/schemas.js +16 -15
  68. package/dist/server.d.ts +11 -2
  69. package/dist/server.js +55 -5
  70. package/dist/shared.d.ts +12 -0
  71. package/dist/shared.js +13 -1
  72. package/dist/source-mutation-coordinator.d.ts +54 -0
  73. package/dist/source-mutation-coordinator.js +259 -0
  74. package/dist/status-events.d.ts +4 -1
  75. package/dist/status-events.js +41 -6
  76. package/dist/store/ace-packed-store.d.ts +28 -9
  77. package/dist/store/ace-packed-store.js +324 -57
  78. package/dist/store/bgzf.d.ts +4 -0
  79. package/dist/store/bgzf.js +94 -0
  80. package/dist/store/bootstrap-store.d.ts +4 -1
  81. package/dist/store/bootstrap-store.js +87 -9
  82. package/dist/store/cache-workspace.d.ts +8 -0
  83. package/dist/store/cache-workspace.js +67 -1
  84. package/dist/store/crc32.d.ts +2 -0
  85. package/dist/store/crc32.js +16 -0
  86. package/dist/store/fsck.d.ts +16 -0
  87. package/dist/store/fsck.js +240 -0
  88. package/dist/store/gate-contract-migration.d.ts +10 -0
  89. package/dist/store/gate-contract-migration.js +413 -0
  90. package/dist/store/materializers/context-snapshot-materializer.d.ts +1 -0
  91. package/dist/store/materializers/context-snapshot-materializer.js +4 -1
  92. package/dist/store/materializers/projection-manager.d.ts +7 -0
  93. package/dist/store/materializers/projection-manager.js +37 -0
  94. package/dist/store/materializers/scheduler-projection-materializer.js +10 -3
  95. package/dist/store/repositories/goal-repository.d.ts +112 -0
  96. package/dist/store/repositories/goal-repository.js +157 -0
  97. package/dist/store/repositories/playbook-repository.d.ts +107 -0
  98. package/dist/store/repositories/playbook-repository.js +314 -0
  99. package/dist/store/store-artifacts.js +44 -2
  100. package/dist/store/store-authority-audit.js +1 -0
  101. package/dist/store/store-cli.d.ts +30 -0
  102. package/dist/store/store-cli.js +242 -0
  103. package/dist/store/store-snapshot.d.ts +12 -0
  104. package/dist/store/store-snapshot.js +74 -11
  105. package/dist/store/types.d.ts +1 -0
  106. package/dist/store/write-coordinator.d.ts +7 -0
  107. package/dist/store/write-coordinator.js +11 -0
  108. package/dist/todo-state.d.ts +21 -0
  109. package/dist/todo-state.js +150 -53
  110. package/dist/tools-agent.js +86 -22
  111. package/dist/tools-discovery.js +5 -3
  112. package/dist/tools-files.js +107 -23
  113. package/dist/tools-framework.js +146 -40
  114. package/dist/tools-goal.d.ts +11 -0
  115. package/dist/tools-goal.js +108 -0
  116. package/dist/tools-handoff.js +7 -11
  117. package/dist/tools-lifecycle.js +2 -0
  118. package/dist/tools-scheduler.js +44 -1
  119. package/dist/tools-skills.js +3 -2
  120. package/dist/tools-todo.js +64 -3
  121. package/dist/tools.js +2 -0
  122. package/dist/tui/chat.js +4 -0
  123. package/dist/tui/index.js +4 -1
  124. package/dist/tui/ollama.d.ts +2 -0
  125. package/dist/tui/openai-compatible.d.ts +14 -0
  126. package/dist/tui/openai-compatible.js +15 -2
  127. package/dist/tui/provider-discovery.d.ts +1 -0
  128. package/dist/tui/provider-discovery.js +2 -2
  129. package/docs/cli-reference.md +125 -0
  130. package/docs/development.md +46 -0
  131. package/docs/evaluation-safety.md +27 -0
  132. package/docs/experience-playbook.md +35 -0
  133. package/docs/hermes.md +129 -0
  134. package/docs/library-api.md +31 -0
  135. package/docs/mcp-tool-reference.md +290 -0
  136. package/docs/provider-security.md +85 -0
  137. package/docs/state-model.md +113 -0
  138. package/docs/troubleshooting.md +95 -0
  139. package/docs/tui-operator-guide.md +75 -0
  140. package/package.json +5 -1
  141. package/scripts/dev/run_hermes_crispr_live.mjs +212 -0
  142. package/assets/agent-state/MODULES/gates/gate-correctness.json +0 -7
  143. package/assets/agent-state/MODULES/gates/gate-evaluation.json +0 -7
  144. package/assets/agent-state/MODULES/gates/gate-typescript-public-surface.json +0 -7
package/docs/hermes.md ADDED
@@ -0,0 +1,129 @@
1
+ # Hermes Companion Engine
2
+
3
+ > Companion to the [Local Models & Hermes section in the README](../README.md#local-models--hermes). That section explains why the bridge exists; this document covers how to run and operate it.
4
+
5
+ Hermes is an optional, user-supplied companion execution substrate for local models. ACE does not install Hermes, clone it, or make it a package dependency. When the operator explicitly passes `--hermes` or `--engine hermes_local`, Hermes handles local provider quirks and tool-call framing. The local model provider is still Ollama or llama.cpp. ACE remains the system of record — state, evidence, verification, scheduler — and exports a **scoped shadow MCP tool surface** to Hermes so the local model only sees the tools it needs for a given task scope.
6
+
7
+ Hermes-local is opt-in. Without `--hermes` or `--engine hermes_local`, the TUI uses the direct provider path and does not require Python, uv, or Hermes.
8
+
9
+ ## Architecture
10
+
11
+ ```
12
+ ACE TUI (ace tui --hermes / --engine hermes_local)
13
+ │ user input → ChatSession.sendMessage();
14
+ │ ACE owns session identity, policy, state
15
+ ▼
16
+ runLocalModelTask() ← src/local-model-runtime.ts
17
+ │ ACE dispatches, ACE controls the turn
18
+ ▼
19
+ HermesSubprocessExecutor ← Node.js class, src/hermes/session-manager.ts
20
+ │ spawns Python worker; ACE controls lifecycle
21
+ ├── writes hermesHome/config.yaml (provider, model, user-supplied Hermes path, shadow MCP entry)
22
+ ├── pipes ace mcp-shadow --tools <csv> ← scoped tools-only shadow server (stdio)
23
+ │ (ACE-owned; local model sees only allowed tools, not public prompts/resources)
24
+ ▼
25
+ hermes_bridge_worker.py ← Python subprocess
26
+ │ reads config.yaml; calls shadow MCP & local model
27
+ ├── streams framed NDJSON events → HermesBridgeFrameDecoder
28
+ └── calls local model (ollama / llama.cpp)
29
+ │
30
+ ▼ bridge frames validated and applied by ACE
31
+ ACE store (ace-state.ace) ← authoritative output; ACE-owned
32
+ evidence, continuity, run ledger persisted here
33
+ ```
34
+
35
+ ## Bridge protocol (one-shot)
36
+
37
+ Each turn starts one worker process. Node writes one JSON request to stdin and closes stdin; the worker emits newline-delimited JSON events on stdout and exits. This is not a persistent or bidirectional session protocol. Events are decoded as they arrive, but the current TUI displays the result after process exit rather than rendering token deltas live.
38
+
39
+ The request contains the session and turn IDs, task, role, provider, model, base URL, maximum turns, and system prompt. Worker events carry a `type` field:
40
+
41
+ | Frame type | Direction | Purpose |
42
+ |---|---|---|
43
+ | `session_open` | H→N | worker opened the requested session |
44
+ | `turn_run` | H→N | worker began the task turn |
45
+ | `session_close` | H→N | worker closed the session |
46
+ | `status` | H→N | heartbeat / progress |
47
+ | `delta` | H→N | streaming token chunk |
48
+ | `reasoning` | H→N | chain-of-thought (optional) |
49
+ | `assistant_interim` | H→N | partial assistant message |
50
+ | `tool_start` | H→N | tool call initiated |
51
+ | `tool_progress` | H→N | tool call in flight |
52
+ | `tool_complete` | H→N | tool call result |
53
+ | `final` | H→N | complete assistant response |
54
+ | `error` | H→N | fatal bridge error |
55
+
56
+ Frame decoding is handled by `HermesBridgeFrameDecoder` in `src/hermes/bridge-protocol.ts`. The decoder strips control bytes, sanitizes the line, and validates against the event schema before handing frames to the session manager.
57
+
58
+ Exactly one `final` event is required. A missing or duplicate terminal event, malformed frame, child error/nonzero exit, timeout, or output-limit breach fails the turn. `final.completed=false` is preserved as a blocked result. The executor owns cancellation: TUI Ctrl+C sends `SIGTERM`, followed by `SIGKILL` if the worker does not stop. Default limits are 120 seconds and 4 MiB combined stdout/stderr per turn.
59
+
60
+ ## Running with Hermes
61
+
62
+ The operator owns the Hermes and Python setup. ACE only discovers and launches it when asked.
63
+
64
+ ```bash
65
+ # Doctor check with user-supplied Hermes/Python
66
+ ACE_HERMES_ROOT=/path/to/hermes-agent \
67
+ HERMES_PYTHON=/path/to/python \
68
+ ace doctor --llm llama.cpp --base-url http://127.0.0.1:8080/v1 --model gemma-3-4b-it --hermes
69
+
70
+ # TUI session with Hermes
71
+ ACE_HERMES_ROOT=/path/to/hermes-agent \
72
+ HERMES_PYTHON=/path/to/python \
73
+ ace tui --provider llama.cpp --base-url http://127.0.0.1:8080/v1 --model gemma-3-4b-it --hermes
74
+
75
+ # Optional uv-managed Hermes project, still operator supplied
76
+ ACE_HERMES_ROOT=/path/to/hermes-agent \
77
+ ACE_HERMES_UV_PROJECT=/path/to/hermes-agent \
78
+ ace tui --provider llama.cpp --base-url http://127.0.0.1:8080/v1 --model gemma-3-4b-it --hermes
79
+ ```
80
+
81
+ Launch precedence is explicit CLI options, environment, the store-backed `state/runtime/hermes_launch_profile`, then development defaults. Supported environment configuration is:
82
+
83
+ - `ACE_HERMES_ROOT`: operator-supplied Hermes checkout.
84
+ - `HERMES_PYTHON`: Python executable containing Hermes dependencies. If omitted, launch resolution uses `python3`.
85
+ - `ACE_HERMES_UV_PROJECT`: run `uv run --project <path> python`.
86
+ - `ACE_HERMES_COMMAND_JSON`: advanced command override as a JSON string array, for example `["uv","run","python"]`; shell strings are rejected.
87
+
88
+ For llama.cpp, use its OpenAI-compatible API root ending in `/v1` (for example `http://127.0.0.1:8080/v1`). Ollama’s native root (for example `http://127.0.0.1:11434`) is normalized to `/v1` for Hermes.
89
+
90
+ Or select the engine explicitly:
91
+
92
+ ```bash
93
+ ace tui --provider llama.cpp --base-url http://localhost:8080 --engine hermes_local
94
+ # shorthand
95
+ ace tui --provider ollama --model qwen3:8b --hermes
96
+ ```
97
+
98
+ When Hermes is selected, ACE launches the user-supplied Hermes/Python setup for that session and exposes only the scoped shadow MCP tool surface. Tool evidence, not model prose, determines executable mutation.
99
+
100
+ ## Doctor checks
101
+
102
+ `ace doctor` surfaces Hermes-local readiness gates only when `--hermes` is passed:
103
+
104
+ ```bash
105
+ ACE_HERMES_ROOT=/path/to/hermes-agent HERMES_PYTHON=/path/to/python \
106
+ ace doctor --llm llama.cpp --model gemma-3-4b-it --base-url http://localhost:8080 --hermes
107
+ ```
108
+
109
+ Checks performed:
110
+
111
+ - Hermes bridge worker packaged (`scripts/hermes_bridge_worker.py` present)
112
+ - Hermes checkout supplied by the operator (`ACE_HERMES_ROOT` or `--hermes-root`)
113
+ - Python supplied by the operator (`HERMES_PYTHON` or `--hermes-python`)
114
+ - Optional uv project supplied by the operator (`ACE_HERMES_UV_PROJECT` or `--hermes-uv-project`)
115
+ - Shadow MCP command available for scoped tools-only transport
116
+ - Local runtime reachable and model available
117
+
118
+ ```bash
119
+ # Auto-scan common Ollama + llama.cpp endpoints
120
+ ace doctor --scan
121
+ ```
122
+
123
+ ## Evidence model
124
+
125
+ ACE persists tool evidence when the model invokes `write_workspace_file` successfully through the shadow MCP surface. Completion is authorized by tool evidence, not model prose: Hermes results pass through the same forward-pacing verifier as direct results. A mutation-intent `completed` claim is demoted to `blocked` unless persisted evidence exists; callers may additionally supply declared artifacts and required evidence references.
126
+
127
+ The Hermes-final artifact materialization path (`materialized_from_hermes_final`) is provided only as a development diagnostic (`scripts/dev/run_hermes_crispr_live.mjs`); it is not part of the standard Hermes-local runtime.
128
+
129
+ Which local model runs is chosen by the operator at `ace connect` or through the runtime profile.
@@ -0,0 +1,31 @@
1
+ # Package API Boundary
2
+
3
+ `@voybio/ace-swarm` is currently an executable MCP server and CLI package, not a supported JavaScript library SDK.
4
+
5
+ ## Supported entrypoints
6
+
7
+ - Binaries: `ace`, `ace-swarm`, `ace-mcp-server`, and `ace-add`
8
+ - MCP transport: `ace mcp` or `ace serve`
9
+ - Operator CLI: commands documented in [CLI Reference](cli-reference.md)
10
+ - Programmatic protocol: MCP tools, resources, templates, and prompts documented in [MCP Tool Reference](mcp-tool-reference.md)
11
+
12
+ Importing the package root executes the MCP stdio server because `dist/index.js` calls `startStdioServer()` immediately. It does not expose a stable function/class API. Internal files under `dist/` are implementation details and are not package-exported subpaths.
13
+
14
+ ```js
15
+ // Do not use this as a library import: it starts the stdio server.
16
+ import "@voybio/ace-swarm";
17
+ ```
18
+
19
+ ## Integration choices
20
+
21
+ Use one of these stable boundaries:
22
+
23
+ 1. Configure the MCP server in a supported host with `ace mcp-config`.
24
+ 2. Spawn the `ace` CLI and consume its documented stdout/exit contract.
25
+ 3. Use an MCP client and the registered tool/resource schemas.
26
+
27
+ Do not import `dist/store/*`, `dist/tools-*`, or other internal modules from a consumer package. Their paths, types, and side effects may change without a semver API guarantee.
28
+
29
+ ## Future SDK contract
30
+
31
+ A supported library API would require explicit side-effect-free exports, documented lifecycle ownership, stable error/result types, and package-level integration tests. Until such exports appear in `package.json`, the CLI and MCP protocol are the public APIs.
@@ -0,0 +1,290 @@
1
+ # MCP Tool Reference
2
+
3
+ > Companion to the [README](../README.md). The full MCP surface spans **119 registered tools** across 13 domain modules, plus resources and prompts. For premium hosts (Claude Code, Codex), the curated `ace mcp --profile host-min` exposes 22 high-value tools; the rest remain reachable via `run_orchestrator` delegation or `--profile full`.
4
+
5
+ ACE exposes tools through a domain-modular registration system (`src/tools.ts` delegates to 13 domain modules). Tools can be allow-listed at startup; `ace mcp-shadow` uses this to give Hermes a scoped tools-only subset. Public `ace mcp` always exposes the full prompts and resources surface; its visible tool schema depends on `--profile` (119 tools for `full`, 22 for `host-min`). `ace mcp-shadow` instead exposes only its explicitly allow-listed tools and omits prompts and resources.
6
+
7
+ ## Agent & Runtime
8
+
9
+ | Tool | Purpose |
10
+ |---|---|
11
+ | `get_agent_instructions` | Read instruction content for any ACE agent role |
12
+ | `get_agent_manifest` | Read the manifest for a given agent role |
13
+ | `get_all_agents_summary` | List all registered agents with role metadata |
14
+ | `get_kernel_artifact` | Read a named kernel artifact from the store |
15
+ | `get_runtime_profile` | Read the active runtime profile (provider, model, base URL) |
16
+ | `validate_runtime_profile` | Schema-validate the stored runtime profile |
17
+ | `get_transition_log` | Read recent agent state-transition history |
18
+ | `get_capability_snapshot` | Read one session/turn capability snapshot (`session_id`, `turn_number`) |
19
+ | `get_runtime_tool_specs` | Read the tool-spec registry for the active runtime |
20
+ | `validate_runtime_tool_specs` | Schema-validate the tool-spec registry |
21
+ | `list_runtime_tool_specs` | List all registered tool specs |
22
+ | `execute_runtime_tool` | Execute a named runtime tool by spec |
23
+
24
+ ## Orchestration & Planning
25
+
26
+ | Tool | Purpose |
27
+ |---|---|
28
+ | `propose_plan` | Generate a multi-step task plan proposal |
29
+ | `validate_plan` | Validate a plan proposal against acceptance contracts |
30
+ | `run_local_model` | Dispatch a task to the configured local model runtime |
31
+ | `run_orchestrator` | Run an ACE orchestrator session for a given task |
32
+ | `route_task` | Route an incoming task to the appropriate agent role |
33
+ | `bootstrap_state` | Seed or repair the ACE store for the current workspace |
34
+ | `get_framework_status` | Read aggregate framework health and readiness |
35
+ | `validate_framework` | Run the built-in framework self-checks (manifest gates are run by `execute_gates`) |
36
+ | `audit_public_surface` | Audit exact registered tools/resources/prompts, emitted-event registry parity, and parse every bound JSON schema |
37
+ | `audit_store_authority` | Verify store authority and projection consistency |
38
+ | `execute_gates` | Run explicit gate manifest IDs, or the active stage's gates when IDs are omitted. Shipped gates: `gate-autonomy`, `gate-completeness`, `gate-operability`, `gate-security` |
39
+
40
+ ## Handoffs
41
+
42
+ | Tool | Purpose |
43
+ |---|---|
44
+ | `create_handoff` | Create a typed, validated handoff record |
45
+ | `validate_handoff` | Validate a handoff payload against the schema |
46
+ | `get_handoff_template` | Retrieve the single canonical handoff template (no arguments) |
47
+ | `get_handoff_status` | Read the status of a specific handoff |
48
+ | `ack_handoff` | Acknowledge a handoff as received and accepted |
49
+
50
+ Example — creating a handoff from orchestrator to qa:
51
+
52
+ ```text
53
+ # via any MCP client
54
+ create_handoff {
55
+ "from": "orchestrator",
56
+ "to": "qa",
57
+ "title": "Review auth module test coverage",
58
+ "task_type": "engineering",
59
+ "priority": "P1",
60
+ "directive": "Auth module implementation complete; review and extend test coverage",
61
+ "acceptance_criteria": ["All /api/auth endpoints covered by integration tests"],
62
+ "context_pointers": { "engineering_constraint": "src/auth.ts:1" }
63
+ }
64
+ ```
65
+
66
+ ## Scheduler
67
+
68
+ | Tool | Purpose |
69
+ |---|---|
70
+ | `enqueue_job` | Add a job to the queue with priority, deps, and resource locks |
71
+ | `dispatch_jobs` | Tick the scheduler and dispatch ready jobs (runs the heartbeat watchdog) |
72
+ | `dispatch_job_now` | Immediately start a single ready job if deps and resources are clear |
73
+ | `ack_job` | Acknowledge or update job lifecycle (accept/reject/cancel/resume) |
74
+ | `complete_job` | Mark a job done or failed |
75
+ | `heartbeat_job` | Prove worker liveness for a running job so the watchdog does not reap it |
76
+ | `reap_stale_jobs` | Run the heartbeat watchdog once: recover stale running jobs, release locks |
77
+ | `list_jobs` | Read the current job queue and lock-table snapshot |
78
+ | `get_lock_table` | Read active resource locks |
79
+ | `get_scheduler_lease` | Read the current scheduler lease |
80
+
81
+ Example — queuing a blocked job:
82
+
83
+ ```text
84
+ enqueue_job {
85
+ "kind": "handoff.lifecycle",
86
+ "priority": "P1",
87
+ "dependencies": [{ "kind": "handoff", "ref": "HND-20260710-abc12345", "expected": "accepted" }],
88
+ "resource_requirements": ["agent-state/handoff-registry.json"],
89
+ "run_after": "2030-05-08T18:00:00Z"
90
+ }
91
+ ```
92
+
93
+ ## Goals
94
+
95
+ | Tool | Purpose |
96
+ |---|---|
97
+ | `start_goal` | Compile an objective into a validated plan and open a goal record |
98
+ | `get_goal_status` | Read goal status, tick/replan counts, ready steps, and escalations |
99
+ | `resume_goal` | Resume a stopped or escalated goal from its persisted state |
100
+ | `stop_goal` | Operator stop for a running goal |
101
+
102
+ A goal reaches `done` only through evidence-gated success; it otherwise leaves `executing` through budget exhaustion, operator stop, or an escalated blocker. The same loop is available from the CLI as `ace goal start|status|run|resume|stop`.
103
+
104
+ ## Files & Structural Editing
105
+
106
+ | Tool | Purpose |
107
+ |---|---|
108
+ | `read_workspace_file` | Read any file in the workspace |
109
+ | `write_workspace_file` | Write or overwrite a file (evidence-tracked) |
110
+ | `list_workspace` | List one workspace directory (`path`; no glob filtering) |
111
+ | `safe_edit_file` | Edit a file with collision-safe write semantics |
112
+ | `diff_files` | Produce a sequence-aware unified diff; set `mode` explicitly to `content` or `path` |
113
+ | `read_file_lines` | Read a line range from a file |
114
+ | `outline_file` | Extract code declarations using language-oriented declaration patterns (not Markdown headings) |
115
+ | `astgrep_query` | Execute ast-grep directly against a workspace directory |
116
+ | `astgrep_locate` | Locate a specific symbol or construct with ast-grep |
117
+ | `compile_structural_edit` | Compile an ast-grep rewrite to a patch |
118
+ | `preview_structural_edit` | Preview a structural edit without applying |
119
+ | `astgrep_rewrite` | Apply a rewrite to one promoted target; multi-file rewrites are refused |
120
+ | `apply_patch` | Apply a unified diff patch to the workspace |
121
+
122
+ ## Change Intelligence & Drift
123
+
124
+ | Tool | Purpose |
125
+ |---|---|
126
+ | `snapshot_state` | Take a semantic snapshot of the current workspace state |
127
+ | `semantic_diff` | Diff two semantic snapshots |
128
+ | `drift_report` | Produce a drift report between baseline and current state |
129
+ | `list_snapshots` | List available workspace snapshots |
130
+ | `rewrite_targets` | Identify files that are candidates for rewrite based on drift |
131
+
132
+ ## Discovery & Indexing
133
+
134
+ | Tool | Purpose |
135
+ |---|---|
136
+ | `refresh_astgrep_index` | Rebuild the ast-grep structural index |
137
+ | `scan_workspace_delta` | Scan for file changes since the last index pass |
138
+ | `web_research_packet` | Package a web research context for agent consumption |
139
+ | `mcp_ingestion_probe` | Perform a bounded MCP initialize over stdio/Streamable HTTP and list tools, resources, resource templates, and prompts |
140
+ | `codemunch_snapshot` | Take a full codemunch snapshot of the workspace |
141
+ | `codemunch_index` | Index a codemunch snapshot for search |
142
+
143
+ ## Git
144
+
145
+ | Tool | Purpose |
146
+ |---|---|
147
+ | `git_status` | Read working-tree status |
148
+ | `git_commit` | Stage and commit changes with a message |
149
+ | `git_diff` | Diff staged or unstaged changes, optionally restricted by `path` |
150
+ | `git_log` | Read recent commit history |
151
+
152
+ ## Memory & Continuity
153
+
154
+ | Tool | Purpose |
155
+ |---|---|
156
+ | `context_snapshot` | Capture a structured context snapshot for the current session |
157
+ | `build_continuity_packet` | Build a continuity packet for cross-session handoff |
158
+ | `recall_context` | Recall an exact snapshot name, or list all snapshots when no name is supplied |
159
+
160
+ Example — before switching models mid-task:
161
+
162
+ ```text
163
+ build_continuity_packet {
164
+ "snapshot_name": "auth-module-pre-model-switch",
165
+ "source_paths": ["src/auth.ts", "src/auth.test.ts"],
166
+ "max_status_events": 20
167
+ }
168
+ ```
169
+
170
+ ## Lifecycle & Status Events
171
+
172
+ | Tool | Purpose |
173
+ |---|---|
174
+ | `emit_status_event` | Append a typed lifecycle event to `STATUS_EVENTS.ndjson` |
175
+ | `list_status_events` | Read recent lifecycle events with optional filters |
176
+ | `open_circuit_breaker` | Trip a named circuit breaker to halt a failing upstream path |
177
+ | `close_circuit_breaker` | Reset a tripped circuit breaker |
178
+ | `generate_kanban_ui` | Rebuild the kanban board from current state |
179
+
180
+ Example:
181
+
182
+ ```text
183
+ emit_status_event {
184
+ "source_module": "capability-ops",
185
+ "event_type": "TASK_COMPLETE",
186
+ "status": "pass",
187
+ "summary": "Auth integration tests green across all providers"
188
+ }
189
+ ```
190
+
191
+ ## Todo & Run Ledger
192
+
193
+ | Tool | Purpose |
194
+ |---|---|
195
+ | `get_todo` | Read the current todo surface |
196
+ | `get_todo_state` | Read structured todo state from the store |
197
+ | `update_todo` | Update one or more todo items |
198
+ | `get_run_ledger` | Read the run ledger (history of major tool invocations) |
199
+
200
+ ## Vericify (Verification)
201
+
202
+ | Tool | Purpose |
203
+ |---|---|
204
+ | `get_vericify_context` | Get the current verification context packet |
205
+ | `get_vericify_delta` | Get the incremental verification delta |
206
+ | `get_vericify_bridge` | Read the vericify bridge snapshot |
207
+ | `refresh_vericify_bridge` | Refresh the bridge snapshot from test runner output |
208
+ | `validate_vericify_bridge` | Schema-validate the bridge snapshot |
209
+ | `get_vericify_process_posts` | Read the vericify process post log |
210
+ | `append_vericify_process_post` | Append a test result post to the process log |
211
+ | `validate_vericify_process_post_log` | Schema-validate the process post log |
212
+
213
+ ## Tracker Integration
214
+
215
+ | Tool | Purpose |
216
+ |---|---|
217
+ | `get_tracker_snapshot` | Read the cached tracker snapshot (GitHub Issues, Linear, etc.) |
218
+ | `validate_tracker_snapshot` | Schema-validate the tracker snapshot |
219
+ | `list_tracker_adapter_kinds` | List available tracker adapters |
220
+ | `get_tracker_adapter_health` | Check health of the active tracker adapter |
221
+ | `list_tracker_items` | List items from the tracker |
222
+ | `create_tracker_comment` | Post a comment to a tracker item |
223
+ | `update_tracker_item_state` | Update the state of a tracker item |
224
+ | `refresh_tracker_snapshot` | Pull fresh data from the tracker into the snapshot |
225
+
226
+ ## Skills & Tasks
227
+
228
+ | Tool | Purpose |
229
+ |---|---|
230
+ | `skill_catalog_summary` | List all available skills with brief descriptions |
231
+ | `skill_audit` | Audit skill freshness and coverage |
232
+ | `problem_triage` | Triage a problem description against known skills |
233
+ | `list_skills` | List skills in the store |
234
+ | `get_skill_instructions` | Read full instructions for a named skill |
235
+ | `get_task_pack` | Read a named task pack |
236
+ | `get_lessons` | Read lessons (backed by the experience playbook store) |
237
+ | `add_lesson` | Append a lesson as a playbook bullet |
238
+
239
+ ## Workspace Sessions
240
+
241
+ | Tool | Purpose |
242
+ |---|---|
243
+ | `list_workspace_sessions` | List managed workspace sessions |
244
+ | `create_workspace_session` | Create a new managed workspace session |
245
+ | `remove_workspace_session` | Remove a workspace session |
246
+ | `validate_managed_workspace_path` | Validate a workspace path against the session registry |
247
+
248
+ ## Unattended Sessions
249
+
250
+ | Tool | Purpose |
251
+ |---|---|
252
+ | `list_unattended_sessions` | List registered unattended agent sessions |
253
+ | `get_unattended_session` | Read details of a specific unattended session |
254
+ | `start_unattended_session` | Launch an unattended agent session |
255
+ | `stop_unattended_session` | Stop a running unattended session |
256
+ | `wait_for_unattended_session` | Block until a session reaches a terminal state |
257
+ | `validate_unattended_session_registry` | Schema-validate the session registry |
258
+
259
+ ## Framework & Config
260
+
261
+ | Tool | Purpose |
262
+ |---|---|
263
+ | `get_mcp_config` | Read the baked MCP config for a named client |
264
+ | `run_tests` | Auto-detect and run the consumer workspace test suite, or run the supplied command |
265
+ | `get_cli_split` | Read the CLI split configuration |
266
+
267
+ ## Resource and Prompt Catalog
268
+
269
+ The release surface is audited from the compiled registrations: **70 fixed resources**, **2 resource templates**, and **19 prompts**. `audit_public_surface` writes the complete, description-bearing catalog to `agent-state/PUBLIC_SURFACE_REPORT.md` and fails on count drift, an empty production event scan, unregistered emitted events, duplicate registrations, or invalid bound JSON schemas.
270
+
271
+ Fixed resource families:
272
+
273
+ - `ace://agents/{astgrep,builder,coders,docs,eval,memory,observability,ops,orchestrator,planner,qa,release,research,security,skeptic,spec,ui,vos}/{instructions,manifest}` (36)
274
+ - Handoffs: `ace://handoffs/{handoff_example,handoff_example_ui_coders,handoff_example_vos_ui,handoff_template,status}`
275
+ - Discovery and UI: `ace://index`, `ace://index/fingerprints`, `ace://kanban`, `ace://kanban/html`
276
+ - Kernel and execution: `ace://kernel/{agent_registry,directive_kernel}`, `ace://run-ledger`, `ace://runtime/{continuity-packet,executor-sessions,profile,prompt-template,tool-specs,tracker-snapshot,vericify-bridge,vericify-process-posts,workspaces}`
277
+ - Scheduler and skills: `ace://scheduler/{lease,locks,queue}`, `ace://skills`
278
+ - Structural state: `ace://state/{astgrep-commands,astgrep-index/json,astgrep-index/md}`, `ace://status/events`
279
+ - Task state: `ace://tasks/{cli_work_split,lessons,readme,role_tasks,todo}`
280
+
281
+ Resource templates:
282
+
283
+ - `ace-skill-instructions` — read a skill's `SKILL.md` by skill name.
284
+ - `ace-workspace-file` — read a workspace-relative file.
285
+
286
+ Prompts:
287
+
288
+ `ace-astgrep`, `ace-codemunch`, `ace-coders`, `ace-codesnipe`, `ace-eval`, `ace-genesis`, `ace-handoff`, `ace-initiate`, `ace-lessons`, `ace-memory`, `ace-observability`, `ace-orchestrator`, `ace-release`, `ace-runtime-executor`, `ace-security`, `ace-skill`, `ace-skills-index`, `ace-ui`, and `ace-vos`.
289
+
290
+ For schema-exact tool inputs, use MCP `tools/list`; for the release-bound schema files and their surface mappings, run `audit_public_surface`. This avoids maintaining a second hand-copied schema that can silently diverge from the registered Zod contracts.
@@ -0,0 +1,85 @@
1
+ # Provider, Credential, and Trust Boundaries
2
+
3
+ ACE supports local runtimes and hosted/OpenAI-compatible providers. A discovered provider is only a configuration hint; it is not proof of authentication, reachability, model availability, or permission to mutate the workspace.
4
+
5
+ ## Provider configuration
6
+
7
+ Prefer explicit CLI flags for one-off diagnosis and the stored runtime profile for repeatable operation:
8
+
9
+ ```bash
10
+ ace connect ollama --model qwen3:8b --base-url http://127.0.0.1:11434
11
+ ace doctor --llm ollama --model qwen3:8b --base-url http://127.0.0.1:11434
12
+
13
+ ace connect llama-server --model local-model --base-url http://127.0.0.1:8080/v1
14
+ ace doctor --llm llama.cpp --model local-model --base-url http://127.0.0.1:8080/v1
15
+ ```
16
+
17
+ Hosted/OpenAI-compatible providers conventionally use `<PROVIDER>_API_KEY` and `<PROVIDER>_BASE_URL`. Codex/OpenAI discovery also recognizes `OPENAI_API_KEY`; Copilot can use authenticated `gh` state or `GITHUB_TOKEN`. Run `ace doctor` rather than assuming an environment variable is sufficient.
18
+
19
+ ### Hosted provider quick setup
20
+
21
+ Use provider-specific credentials so switching providers does not accidentally reuse a key. ACE supplies the standard OpenAI endpoint for Codex, the Anthropic OpenAI-compatible endpoint for Claude, and the GitHub Models endpoint for Copilot. Gemini requires its OpenAI-compatible endpoint explicitly.
22
+
23
+ | Provider | Default model | Credential and endpoint |
24
+ |---|---|---|
25
+ | Codex | `gpt-5` | `CODEX_API_KEY`; endpoint defaults to `https://api.openai.com/v1` |
26
+ | Claude | `claude-opus-4-8` | `CLAUDE_API_KEY`; endpoint defaults to `https://api.anthropic.com/v1/` |
27
+ | Gemini | `gemini-2.5-pro` | `GEMINI_API_KEY` and `GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/` |
28
+ | Copilot | `copilot/gpt-5-mini` | `GITHUB_TOKEN` or `GH_TOKEN` (or authenticated `gh`); endpoint is `https://models.github.com/v1` |
29
+
30
+ Preflight the exact model before opening the TUI:
31
+
32
+ ```bash
33
+ CODEX_API_KEY=... ace doctor --llm codex --model gpt-5
34
+ CODEX_API_KEY=... ace tui --provider codex --model gpt-5
35
+
36
+ CLAUDE_API_KEY=... ace doctor --llm claude --model claude-opus-4-8
37
+ CLAUDE_API_KEY=... ace tui --provider claude --model claude-opus-4-8
38
+
39
+ GEMINI_API_KEY=... GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/ \
40
+ ace doctor --llm gemini --model gemini-2.5-pro
41
+ GEMINI_API_KEY=... GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/ \
42
+ ace tui --provider gemini --model gemini-2.5-pro
43
+
44
+ GITHUB_TOKEN=... ace doctor --llm copilot --model copilot/gpt-5-mini
45
+ GITHUB_TOKEN=... ace tui --provider copilot --model copilot/gpt-5-mini
46
+ ```
47
+
48
+ Provider discovery and a successful credential check do not prove that the account can use the requested model. Treat the doctor's served-model result as the preflight gate and keep an explicit `--model` when provider aliases or catalogs can change.
49
+
50
+ ## Secret handling
51
+
52
+ - Do not put API keys, bearer tokens, cookies, passwords, or credentials in `TASK.md`, prompts, handoffs, evidence logs, runtime tool arguments, or MCP configuration committed to a repository.
53
+ - Pass secrets through the provider's supported environment or operating-system credential store.
54
+ - `mcp_ingestion_probe` rejects secret-like environment keys and records only allowed configuration metadata.
55
+ - Treat `ace mcp-config` output as executable configuration. Review command paths, working directories, and environment forwarding before installing it globally.
56
+ - Store files and projections can contain task context, tool results, paths, and model output. Protect workspace backups accordingly.
57
+
58
+ ## Local endpoint boundary
59
+
60
+ Ollama and llama.cpp commonly listen on loopback. Do not expose them on a public interface without an authenticated reverse proxy, request limits, and a reviewed model/tool policy. A local model connected to `mcp-shadow` can invoke only its allowed tool scope, but those tools may still read or mutate the workspace.
61
+
62
+ ## MCP trust boundary
63
+
64
+ - `ace mcp --profile host-min` reduces the host-visible tool schema; `--profile full` exposes the complete tool surface.
65
+ - Hermes uses `mcp-shadow --tools <csv>` and refuses an empty scope.
66
+ - A successful configuration validation is not a successful MCP handshake. Use probe results that include protocol initialization plus tool/resource enumeration.
67
+ - External MCP servers are separate trust domains. Review their executable command, URL, arguments, and data-retention policy before connecting.
68
+
69
+ ## Tracker boundary
70
+
71
+ Tracker tools may read items and can create comments or change item state. Keep adapters disabled unless configured intentionally, use least-privilege credentials, and test with read operations before enabling mutations.
72
+
73
+ ## Model output and completion
74
+
75
+ Model prose does not authorize completion or mutation. Mutation-capable runs must be backed by successful tool results and any declared artifacts, evidence refs, and verification commands. A provider returning HTTP 200 or a process exiting 0 is transport evidence only.
76
+
77
+ ## Incident response
78
+
79
+ If a credential may have entered an artifact or trace:
80
+
81
+ 1. Stop active sessions.
82
+ 2. Revoke or rotate the credential at the provider.
83
+ 3. Inspect packed and loose artifacts before sharing or backing up the workspace.
84
+ 4. Record sanitized evidence; do not copy the secret into the incident log.
85
+ 5. Re-run provider doctor checks with the replacement credential.
@@ -0,0 +1,113 @@
1
+ # ACEPACK State Model
2
+
3
+ > Companion to the [ACEPACK summary in the README](../README.md#acepack-state-model). This document describes the implemented v2 format, its authority boundary, and safe maintenance behavior.
4
+
5
+ ACE's canonical generated workflow state is stored in `agent-state/ace-state.ace`. Older workspaces may still contain `.agents/ACE/ace-state.ace`; that path is a read fallback, not a second authority. If both files exist, `ace fsck` reports a dual-store conflict so the operator can migrate deliberately instead of guessing which file to delete.
6
+
7
+ One intentional exception remains: active goal records and plans under `agent-state/goals/` are authoritative loose files so detached goal processes can coordinate without rewriting the packed store. A complete backup therefore includes both `agent-state/ace-state.ace` and `agent-state/goals/` when that directory exists.
8
+
9
+ ## On-disk regions
10
+
11
+ ACEPACK v2 has four regions:
12
+
13
+ ```text
14
+ ace-state.ace
15
+ ├── Header (128 bytes, big-endian)
16
+ │ magic · version · flags
17
+ │ kv_index_offset · kv_index_length · kv_chunk_end
18
+ │ evt_offset · evt_length · evt_count · evt_base_id
19
+ ├── KV Chunk Region
20
+ │ knowledge/agents/{name}/{file} → agent instruction text
21
+ │ knowledge/skills/{name}/{file} → skill content
22
+ │ topology/{kind} → swarm registry, route tables
23
+ │ state/{...} → handoffs, todo, ledger, scheduler
24
+ │ meta/{...} → schema version, project name
25
+ │ each chunk: [uint32 length][bytes]
26
+ ├── Columnar Event Section (rewritten on commit)
27
+ │ uint32 event count
28
+ │ int64[N] timestamps (epoch ms, big-endian)
29
+ │ uint8[N] kinds (EntityKind enum)
30
+ │ uint8[N] sources (ContentSource enum)
31
+ │ uint8[N] flags (0x01 = deleted)
32
+ │ padding to 4-byte alignment
33
+ │ uint32[N] payload offsets (relative to payload pool)
34
+ │ uint32[N] payload lengths
35
+ │ uint32 pool length
36
+ │ bytes[M] payload pool (UTF-8 JSON blobs)
37
+ └── KV Index (JSON, rewritten on every store write)
38
+ key → { offset, length, crc? }
39
+ ```
40
+
41
+ The header field definitions live in `src/store/types.ts`; serialization and bounds checks live in `src/store/ace-packed-store.ts` and `src/store/fsck.ts`.
42
+
43
+ ## KV reads and writes
44
+
45
+ The KV index makes a single-key read an indexed seek plus the selected chunk read: approximately `O(chunk_length)` after the index is loaded. CRC-bearing entries are verified on read, and `ace fsck` also verifies region ordering, length prefixes, bounds, and CRCs.
46
+
47
+ The writer is append-structured, but the file is **not appended in place**:
48
+
49
+ - Synchronous operational writes retain old KV chunks, append replacement chunks in the new KV region, copy the current event section, write a new index, and atomically rename a complete temporary file.
50
+ - Async `AcePackedStore.commit()` rebuilds the live KV region, serializes the complete hot event set, writes a complete temporary file, and atomically renames it.
51
+ - `compact()` similarly rewrites the complete container with only live KV chunks.
52
+
53
+ Consequently, filesystem write cost is proportional to the retained KV bytes plus hot event bytes and the index—not `O(1)`. Atomic rename prevents readers from observing a partially promoted file on supported local filesystems, but it also changes the inode. Writers are serialized through the store write coordinator; bypassing that coordinator is unsupported.
54
+
55
+ ## Columnar events
56
+
57
+ The physical event layout separates fixed-width columns from JSON payloads and uses about 19 fixed bytes per hot event plus payload bytes. The current JavaScript reader eagerly loads and parses hot-event payloads when opening/scanning a store, so the layout's theoretical timestamp/kind-only scan is not yet exposed by the production API. Do not size current scans as 9 bytes per event.
58
+
59
+ Events survive `compact()`. `archive/events/*` may contain older contiguous event batches compressed with BGZF and indexed by `archive/events/__index`; `AcePackedStore.archiveColdEvents()` implements this tier, while the normal CLI does not invoke it automatically.
60
+
61
+ ## Authority and projections
62
+
63
+ The packed store is authoritative for generated operational artifacts, agent instructions, skills, topology, schemas, scheduler state, handoffs, todos, run ledger, and event history. Host-facing files are materialized only through explicit projection allowlists.
64
+
65
+ Exceptions and boundaries:
66
+
67
+ - `agent-state/goals/*.json`, plan JSON, and detached goal logs are authoritative loose goal state.
68
+ - Source code and user-authored project files remain ordinary workspace files.
69
+ - `.agents/ACE/ace-state.ace` is legacy fallback state and should not coexist indefinitely with the canonical file.
70
+ - `ACE_STORE_FIRST=0` is a legacy diagnostic escape hatch; it can expose stale disk projections and is not the normal precedence.
71
+
72
+ ## Maintenance and recovery
73
+
74
+ ### Inspect before changing
75
+
76
+ ```bash
77
+ ace fsck --json
78
+ ace ls agent-state
79
+ ace read agent-state/STATUS.md --source
80
+ ```
81
+
82
+ `ace fsck` diagnoses binary structure, CRCs, stale write leases, orphan temporary files, and dual-store conflicts. `--repair` removes only repairable stale/orphan coordination artifacts; it does not reconstruct corrupt application data.
83
+
84
+ ### Compact
85
+
86
+ ```bash
87
+ ace compact --no-sweep # store rewrite only
88
+ ace compact # store rewrite plus loose generated-artifact sweep
89
+ ```
90
+
91
+ The default command runs a sweep after compaction: eligible loose generated ACE artifacts are ingested into the store and removed from disk. Use `--no-sweep` when only the container rewrite is intended. Back up the store and active goal directory before maintenance on a critical workspace.
92
+
93
+ ### Repair
94
+
95
+ `ace repair` re-bakes packaged assets, repairs known store-backed projections, and restores host files. It is not a general corrupt-ACEPACK byte repair tool. Review every warning and rerun `ace fsck`; recover unrecoverable corruption from a known-good backup or a quarantined pre-write copy.
96
+
97
+ When a write refuses corrupt source bytes, ACE leaves the original in place and writes a timestamped `.corrupt-*` quarantine copy. Do not delete either copy until the cause and recovery source are established.
98
+
99
+ ### Migrate
100
+
101
+ `ace migrate [store-path]` imports the supported legacy ACE state families: handoffs, todos, run-ledger entries, status events, and Vericify posts. It is not an arbitrary workspace-file importer. Verify the resulting canonical store with `ace fsck`, then archive the legacy store rather than leaving both authorities active.
102
+
103
+ ## Backup contract
104
+
105
+ For a recoverable snapshot:
106
+
107
+ 1. Stop active ACE writers and detached goal workers.
108
+ 2. Copy `agent-state/ace-state.ace`.
109
+ 3. Copy `agent-state/goals/` if present.
110
+ 4. Record `ace fsck --json` output and the store checksum.
111
+ 5. Preserve any `.corrupt-*` quarantine until recovery is verified.
112
+
113
+ Restoring only the `.ace` file while omitting active loose goal records is not a complete workspace-state restore.