@arnilo/prism 0.6.0 → 0.8.0

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 (178) hide show
  1. package/CHANGELOG.md +79 -5
  2. package/README.md +12 -11
  3. package/dist/agent-approval.d.ts +4 -0
  4. package/dist/agent-approval.js +5 -1
  5. package/dist/agent-definitions.js +1 -0
  6. package/dist/agent-run-lifecycle.js +39 -4
  7. package/dist/agent-run-state.d.ts +18 -0
  8. package/dist/agent-run-state.js +39 -9
  9. package/dist/agent-session/helpers.js +6 -1
  10. package/dist/agent-session/session/assemble.js +159 -7
  11. package/dist/agent-session/session/persist.d.ts +16 -0
  12. package/dist/agent-session/session/persist.js +64 -4
  13. package/dist/agent-session/session/provider-round.d.ts +3 -3
  14. package/dist/agent-session/session/provider-round.js +12 -6
  15. package/dist/agent-session/session/tool-round.js +5 -1
  16. package/dist/agent-session/session/types.d.ts +22 -1
  17. package/dist/agent-session/session.d.ts +16 -0
  18. package/dist/agent-session/session.js +42 -3
  19. package/dist/artifacts.d.ts +39 -1
  20. package/dist/artifacts.js +73 -0
  21. package/dist/attention-compiler.d.ts +121 -0
  22. package/dist/attention-compiler.js +479 -0
  23. package/dist/checkpoints.js +7 -11
  24. package/dist/cli-init.js +20 -6
  25. package/dist/context-budget.d.ts +20 -1
  26. package/dist/context-budget.js +10 -1
  27. package/dist/contracts-core/agent.d.ts +7 -0
  28. package/dist/contracts-core/attention.d.ts +66 -0
  29. package/dist/contracts-core/attention.js +2 -0
  30. package/dist/contracts-core/compaction.d.ts +59 -0
  31. package/dist/contracts-core/compaction.js +77 -1
  32. package/dist/contracts-core/content.d.ts +5 -0
  33. package/dist/contracts-core/loop.d.ts +42 -0
  34. package/dist/contracts-core/provider.d.ts +4 -0
  35. package/dist/contracts-core/run-limits.d.ts +2 -0
  36. package/dist/contracts-core.d.ts +1 -0
  37. package/dist/contracts-core.js +1 -0
  38. package/dist/contracts-protocol.d.ts +44 -3
  39. package/dist/contracts-run-state.d.ts +32 -5
  40. package/dist/evidence-grounding.d.ts +29 -0
  41. package/dist/evidence-grounding.js +162 -0
  42. package/dist/host-composition.d.ts +91 -0
  43. package/dist/host-composition.js +279 -0
  44. package/dist/index.d.ts +13 -6
  45. package/dist/index.js +7 -4
  46. package/dist/input.d.ts +13 -1
  47. package/dist/input.js +40 -1
  48. package/dist/provider-events.d.ts +3 -1
  49. package/dist/provider-events.js +2 -2
  50. package/dist/providers/transport.d.ts +3 -1
  51. package/dist/providers/transport.js +36 -0
  52. package/dist/redaction.js +18 -2
  53. package/dist/run-bundle.d.ts +89 -0
  54. package/dist/run-bundle.js +149 -0
  55. package/dist/secure-agent.d.ts +2 -0
  56. package/dist/secure-agent.js +6 -1
  57. package/dist/testing/state-concurrency-conformance.js +5 -12
  58. package/dist/tool-result-fold.d.ts +12 -0
  59. package/dist/tool-result-fold.js +13 -6
  60. package/dist/tools.d.ts +10 -0
  61. package/dist/tools.js +41 -0
  62. package/docs/acp-agent.md +42 -11
  63. package/docs/acp.md +2 -1
  64. package/docs/ag-ui.md +10 -3
  65. package/docs/agent-definitions.md +9 -1
  66. package/docs/agent-events.md +4 -1
  67. package/docs/agent-loops.md +33 -0
  68. package/docs/agent-session-runtime.md +8 -7
  69. package/docs/attention-compiler.md +272 -0
  70. package/docs/cli-rpc.md +4 -2
  71. package/docs/coding-agent-tools.md +1 -1
  72. package/docs/coding-security.md +6 -3
  73. package/docs/coding-tools.md +0 -1
  74. package/docs/coding-workspaces.md +22 -0
  75. package/docs/compaction-and-retry.md +36 -4
  76. package/docs/compaction-observational-memory.md +63 -10
  77. package/docs/connected-apps.md +116 -0
  78. package/docs/context-and-skills.md +17 -2
  79. package/docs/conversations.md +1 -1
  80. package/docs/core.md +1 -1
  81. package/docs/dev-inspector.md +4 -0
  82. package/docs/device-adapters.md +1 -0
  83. package/docs/diagrams.md +6 -6
  84. package/docs/document-reader.md +18 -10
  85. package/docs/documents.md +40 -11
  86. package/docs/durable-runs.md +87 -0
  87. package/docs/enterprise-postgres-state.md +6 -2
  88. package/docs/evaluations.md +168 -4
  89. package/docs/execution-timeline.md +186 -0
  90. package/docs/guardrails.md +33 -0
  91. package/docs/history/0.7.0-primitive-review.md +254 -0
  92. package/docs/history/079-messaging-primitive-review.md +391 -0
  93. package/docs/history/080-messaging-followon-primitive-review.md +234 -0
  94. package/docs/history/081-connected-apps-primitive-review.md +74 -0
  95. package/docs/history/083-prism-work-primitive-review.md +84 -0
  96. package/docs/history/084-primitive-review.md +96 -0
  97. package/docs/history/085-honesty-and-cut-primitive-review.md +91 -0
  98. package/docs/history/README.md +5 -0
  99. package/docs/history/migration-0.0.md +2 -2
  100. package/docs/history/release-handoffs.md +75 -1
  101. package/docs/host-compositions.md +149 -0
  102. package/docs/host-security.md +2 -2
  103. package/docs/hosted-sandboxes.md +94 -0
  104. package/docs/index.md +82 -45
  105. package/docs/input-and-prompt-assembly.md +1 -0
  106. package/docs/knowledge-sync.md +84 -0
  107. package/docs/language-intelligence.md +1 -1
  108. package/docs/live-testing.md +8 -3
  109. package/docs/mcp-tools.md +3 -1
  110. package/docs/memory-fabric.md +416 -0
  111. package/docs/messaging-channel-operations.md +166 -0
  112. package/docs/messaging-channels.md +150 -0
  113. package/docs/migrate-to-0.5.md +1 -1
  114. package/docs/migrate-to-0.6.md +1 -0
  115. package/docs/migrate-to-0.7.md +345 -0
  116. package/docs/migrate-to-0.8.md +124 -0
  117. package/docs/migration.md +43 -1
  118. package/docs/model-registry.md +12 -2
  119. package/docs/model-routing.md +79 -4
  120. package/docs/multi-agent-patterns.md +20 -6
  121. package/docs/observability.md +52 -1
  122. package/docs/openapi-tools.md +1 -1
  123. package/docs/operations.md +14 -4
  124. package/docs/options-index.md +47 -3
  125. package/docs/peer-dependencies.md +12 -10
  126. package/docs/postgres-persistence.md +1 -1
  127. package/docs/process-sessions.md +3 -1
  128. package/docs/prompt-registry.md +1 -1
  129. package/docs/provider-caching.md +4 -2
  130. package/docs/provider-conformance.md +1 -1
  131. package/docs/provider-layer.md +2 -2
  132. package/docs/provider-packages.md +22 -22
  133. package/docs/providers/bedrock.md +71 -7
  134. package/docs/providers/neuralwatt.md +5 -1
  135. package/docs/providers/openai.md +1 -1
  136. package/docs/rag.md +24 -8
  137. package/docs/realtime-voice.md +87 -0
  138. package/docs/release-and-install.md +53 -45
  139. package/docs/run-bundle.md +92 -0
  140. package/docs/runs-and-usage.md +17 -2
  141. package/docs/server.md +7 -3
  142. package/docs/sheets.md +9 -9
  143. package/docs/signal-channel.md +112 -0
  144. package/docs/speech.md +7 -1
  145. package/docs/sqlite-persistence.md +1 -1
  146. package/docs/supervisors.md +33 -5
  147. package/docs/telegram-channel.md +157 -0
  148. package/docs/testing.md +2 -2
  149. package/docs/thinking-and-reasoning.md +3 -1
  150. package/docs/tools.md +6 -5
  151. package/docs/web-tools.md +2 -1
  152. package/docs/wiki.md +1 -1
  153. package/docs/work-artifacts-and-review.md +14 -4
  154. package/docs/work-connectors.md +12 -10
  155. package/docs/work-sandbox.md +115 -0
  156. package/docs/work-tools.md +50 -18
  157. package/docs/workflows.md +69 -1
  158. package/docs/working-and-semantic-memory.md +25 -14
  159. package/package.json +5 -3
  160. package/templates/README.md +2 -0
  161. package/templates/business-worker/README.md.tmpl +19 -0
  162. package/templates/business-worker/env.example.tmpl +1 -0
  163. package/templates/business-worker/gitignore.tmpl +11 -0
  164. package/templates/business-worker/manifest.json +12 -0
  165. package/templates/business-worker/package.json.tmpl +23 -0
  166. package/templates/business-worker/src/agent.ts.tmpl +92 -0
  167. package/templates/business-worker/src/index.ts.tmpl +13 -0
  168. package/templates/business-worker/src/tests/agent.test.ts.tmpl +77 -0
  169. package/templates/business-worker/tsconfig.json.tmpl +15 -0
  170. package/templates/personal-assistant/README.md.tmpl +18 -0
  171. package/templates/personal-assistant/env.example.tmpl +1 -0
  172. package/templates/personal-assistant/gitignore.tmpl +11 -0
  173. package/templates/personal-assistant/manifest.json +11 -0
  174. package/templates/personal-assistant/package.json.tmpl +23 -0
  175. package/templates/personal-assistant/src/agent.ts.tmpl +65 -0
  176. package/templates/personal-assistant/src/index.ts.tmpl +13 -0
  177. package/templates/personal-assistant/src/tests/agent.test.ts.tmpl +28 -0
  178. package/templates/personal-assistant/tsconfig.json.tmpl +15 -0
@@ -0,0 +1,186 @@
1
+ # Execution Timeline
2
+
3
+ ## What it does
4
+
5
+ `ExecutionTimeline` is a frozen, JSON-serializable view-model that reconstructs what an agent or workflow run did: initial input, each step with optional input/output, and the terminal result. One type powers both host cockpit waterfalls and trajectory evaluation scorers.
6
+
7
+ APIs in `@arnilo/prism-core/governance/observability`:
8
+
9
+ - `projectAgentTimeline(events, options)` — fold live `AgentEvent[]` into a timeline
10
+ - `projectTraceTimeline(trace, options)` — fold an `EvaluationTrace` (from persistence) into a timeline
11
+ - `projectWorkflowTimeline(events, options)` — fold `WorkflowEvent[]` + optional checkpoint into a timeline
12
+ - `createTimelineFolder(options)` — incremental folder for SSE/cockpit live updates
13
+ - `createWorkflowTimelineFolder(options)` — incremental folder for workflow events
14
+ - `summarizeTimeline(timeline)` — fast cockpit summary (duration, tool counts capped at 64, tokens, cost)
15
+ - `summarizeSession(timelines)` — multi-run conversation/session rollups without double counting
16
+
17
+ ## When to use it
18
+
19
+ Use `projectAgentTimeline` when you have a completed run's events in memory and need to render a waterfall, score a trajectory, or serialize for audit.
20
+
21
+ Use `createTimelineFolder` when you are streaming events from `session.subscribe()` and need live updates — push events one at a time and call `snapshot()` to get the current timeline.
22
+
23
+ Use `projectTraceTimeline` when you have an `EvaluationTrace` from `createPersistenceTraceResolver` and want the same timeline shape as a live fold.
24
+
25
+ Use `projectWorkflowTimeline` when you have workflow events and optionally a checkpoint — node outputs from the checkpoint are joined into workflow node steps when the content policy allows I/O.
26
+
27
+ Do not use the dev inspector folding logic (`packages/prism-coding-tools/src/dev/ui/inspector.ts`) for production — it is a composition-only browser asset, not an exported projector.
28
+
29
+ ## Inputs / request
30
+
31
+ ### Content-capture policy
32
+
33
+ | Mode | Timeline contains | Default |
34
+ | --- | --- | --- |
35
+ | `"metadata"` | kinds, names, status, timings, usage, error codes | ✅ |
36
+ | `"redacted_io"` | input/output after `SecretRedactor`, byte-capped per step | |
37
+ | `"full_io"` | redactor still runs (secrets never pass); host accepts residual content | |
38
+
39
+ ### Projection options
40
+
41
+ ```ts
42
+ interface TimelineProjectionOptions {
43
+ readonly content?: TimelineContentPolicy; // default "metadata"
44
+ readonly redactor?: SecretRedactor; // required when content ≠ "metadata"
45
+ readonly maxSteps?: number; // default 1,000; hard 10,000
46
+ readonly maxStepIoBytes?: number; // default 16,384; hard 262,144
47
+ readonly traceId?: string; // explicit OTel trace ID to attach
48
+ readonly instrumentation?: { traceId(runId: string): string | undefined }; // auto-resolve traceId from OTel handle
49
+ }
50
+ ```
51
+
52
+ ### Workflow projection options
53
+
54
+ ```ts
55
+ interface WorkflowTimelineProjectionOptions extends TimelineProjectionOptions {
56
+ readonly checkpoint?: WorkflowCheckpointValue;
57
+ }
58
+ ```
59
+
60
+ ## Outputs / result
61
+
62
+ ### `ExecutionTimeline`
63
+
64
+ ```ts
65
+ interface ExecutionTimeline {
66
+ readonly schemaVersion: 1;
67
+ readonly runId: string;
68
+ readonly sessionId?: string;
69
+ readonly workflowId?: string;
70
+ readonly workflowRevision?: string;
71
+ readonly traceId?: string;
72
+ readonly status: string;
73
+ readonly stopReason?: AgentFinishReason;
74
+ readonly stopDetail?: string;
75
+ readonly startedAt: string;
76
+ readonly finishedAt?: string;
77
+ readonly input?: unknown;
78
+ readonly result?: unknown;
79
+ readonly usage?: Usage;
80
+ readonly steps: readonly ExecutionStep[];
81
+ readonly redacted: boolean;
82
+ readonly content: TimelineContentPolicy;
83
+ }
84
+ ```
85
+
86
+ ### `ExecutionStep`
87
+
88
+ ```ts
89
+ interface ExecutionStep {
90
+ readonly id: string;
91
+ readonly parentId?: string;
92
+ readonly kind: ExecutionStepKind;
93
+ readonly name: string;
94
+ readonly order: number;
95
+ readonly status: ExecutionStepStatus;
96
+ readonly startedAt: string;
97
+ readonly finishedAt?: string;
98
+ readonly durationMs?: number;
99
+ readonly input?: unknown;
100
+ readonly output?: unknown;
101
+ readonly error?: ErrorInfo;
102
+ readonly usage?: Usage;
103
+ readonly metadata?: Readonly<Record<string, unknown>>;
104
+ }
105
+ ```
106
+
107
+ Step kinds: `"run"`, `"turn"`, `"provider"`, `"tool"`, `"guardrail"`, `"delegation"`, `"compaction"`, `"attention"`, `"retry"`, `"hitl"`, `"artifact"`, `"workflow_node"`, `"loop_iteration"`, `"nested_workflow"`.
108
+
109
+ `attention_compiled` folds into a one-step `"attention"` entry (status `succeeded`) whose metadata carries the measured counts (`used`, `usedAfter`, `inputCap`, `triggerRatio`, `droppedThinkingTurns`, `stubbedToolResults`, `stubbedBytes`, `truncated`); under-ratio turns emit no event, so they add no step.
110
+
111
+ Step statuses: `"running"`, `"succeeded"`, `"failed"`, `"blocked"`, `"skipped"`, `"suspended"`, `"denied"`, `"aborted"`.
112
+
113
+ Tree structure: steps are a flat ordered array. Tree via `parentId` (run → turn → provider/tool). Scorers iterate the flat array; UIs that need nesting walk `parentId`.
114
+
115
+ ## Examples
116
+
117
+ ### Live cockpit fold
118
+
119
+ ```ts
120
+ import { createTimelineFolder, summarizeTimeline } from "@arnilo/prism-core/governance/observability";
121
+
122
+ const folder = createTimelineFolder({ content: "metadata" });
123
+ for await (const event of session.subscribe()) {
124
+ folder.push(event);
125
+ const timeline = folder.snapshot();
126
+ renderWaterfall(timeline.steps); // host UI
127
+ }
128
+ ```
129
+
130
+ ### Offline trace fold
131
+
132
+ ```ts
133
+ import { projectTraceTimeline } from "@arnilo/prism-core/governance/observability";
134
+
135
+ const trace = await traceResolver({ ownership, sessionId, runId });
136
+ const timeline = projectTraceTimeline(trace, {
137
+ content: "redacted_io",
138
+ redactor: createSecretRedactor(secrets),
139
+ });
140
+ // timeline.steps.map(s => [s.order, s.kind, s.name, s.status])
141
+ ```
142
+
143
+ ### Workflow fold with checkpoint outputs
144
+
145
+ ```ts
146
+ import { projectWorkflowTimeline } from "@arnilo/prism-core/governance/observability";
147
+
148
+ const timeline = projectWorkflowTimeline(workflowEvents, {
149
+ content: "redacted_io",
150
+ checkpoint: await checkpoints.load({ workflowId, runId, ownership }),
151
+ });
152
+ // Node outputs appear on workflow_node steps when checkpoint is provided.
153
+ ```
154
+
155
+ See runnable host demo in `examples/execution-timeline.ts` for offline workflow timeline projection, cockpit summary, and Mermaid diagram export.
156
+
157
+ ### Stop reasons
158
+
159
+ Run-level `stopReason` mirrors `agent_finished.finishReason` when the loop stopped on a ceiling or a host turn policy (`"host_policy"`); `status` reads `finished:<stopReason>` for those runs and `succeeded` for a natural end. `stopDetail` carries the host's `turnPolicy.stop` reason, bounded to 256 bytes and redacted at the runtime boundary. See [Runs and usage ledger § Clean stops and stop reasons](runs-and-usage.md#clean-stops-and-stop-reasons).
160
+
161
+ ## Bounds
162
+
163
+ | Dimension | Default | Hard cap |
164
+ | --- | --- | --- |
165
+ | Max steps | 1,000 | 10,000 |
166
+ | Per-step I/O bytes | 16 KiB | 256 KiB |
167
+ | Total timeline bytes | 4 MiB | 32 MiB (eval trace envelope) |
168
+
169
+ Exceeding `maxSteps` throws `TimelineError` with code `ERR_PRISM_TIMELINE_BOUNDS`. Oversize I/O per step is truncated with a marker string, not thrown.
170
+
171
+ ## Security and performance notes
172
+
173
+ - Default `"metadata"` content policy emits zero prompts, tool arguments, tool results, or node payloads.
174
+ - `"redacted_io"` and `"full_io"` always run `SecretRedactor` — secrets never survive into the timeline.
175
+ - Oversize I/O is truncated; unredactable steps omit I/O and set `redacted: true`.
176
+ - Ownership is not checked in the projector — callers must supply already-authorized events. `projectTraceTimeline` consumes traces from `createPersistenceTraceResolver`, which already enforces ownership.
177
+ - Low-cardinality metadata only; `metadata` on steps must not contain free-text, session IDs, or credentials.
178
+ - Incremental `push` is O(1) per event aside from I/O redaction. No O(n²) rebuilds.
179
+
180
+ ## Related APIs
181
+
182
+ - [Observability](observability.md): OTel span hierarchy and provider capture policy.
183
+ - [Agent events](agent-events.md): full `AgentEvent` union and subscriber semantics.
184
+ - [Evaluations](evaluations.md): trajectory scorers consume `ScorerInput.timeline`.
185
+ - [Workflows](workflows.md): `WorkflowEvent` stream, `WorkflowCheckpointValue` for node outputs, and `WorkflowGraphRunView` for DAG topology/status overlay (graph overlays carry status/timing only; full I/O payloads remain on `ExecutionTimeline`).
186
+ - [Runs and usage ledger](runs-and-usage.md): `EvaluationTrace` persistence path.
@@ -70,6 +70,39 @@ const agent = createAgent({ model, provider, guardrails: { input: [pii], output:
70
70
  await agent.createSession().run("Draft reply", { guardrails: { toolInput: [commandGuard] } });
71
71
  ```
72
72
 
73
+ ## Claim grounding
74
+
75
+ `createClaimGroundingGuardrail(options: ClaimGroundingGuardrailOptions)` is a deterministic output guardrail for quantitative claims. It scans assistant text once, then attributes each number to a completed host tool result from **this run** or to a host-governed figure. It never calls a model, store, or network service.
76
+
77
+ ```ts
78
+ import { createClaimGroundingGuardrail } from "@arnilo/prism";
79
+
80
+ const grounding = createClaimGroundingGuardrail({
81
+ requireEvidenceForNumbers: true,
82
+ evidenceSources: "tool_results", // default
83
+ onViolation: "block", // default; "flag" records but permits output
84
+ });
85
+
86
+ const agent = createAgent({ model, provider, guardrails: { output: [grounding] } });
87
+ ```
88
+
89
+ Numbers in an assistant text block pass when their exact numeric value occurs in a same-run successful tool result. The default is strict: `4,320.50` matches `4320.5`; `~4.3k` does not. Set `tolerance: "rounded"` to accept half the final printed unit, so `~4.3k` can match `4320.5`.
90
+
91
+ A host can supply governed figures without giving this package a storage dependency:
92
+
93
+ ```ts
94
+ const grounding = createClaimGroundingGuardrail({
95
+ requireEvidenceForNumbers: true,
96
+ evidenceSources: ({ metadata }) =>
97
+ metadata.metric === "revenue-q2" ? [{ value: 4320.5, ref: "metric:revenue-q2" }] : [],
98
+ });
99
+ // `Revenue is 999 [evidence:metric:revenue-q2]` cites that governed source.
100
+ ```
101
+
102
+ An explicit citation is `[evidence:<ref>]`, immediately after its claim (within 96 characters). Tool-result refs are `tool:<toolCallId>`; extractor refs may contain only letters, digits, `.`, `_`, `:`, and `-` (1–128 chars). A citation must name an evidence ref the guardrail received; arbitrary labels do not pass.
103
+
104
+ With `onViolation: "block"`, the standard `GuardrailError` has `reason: "claim_ungrounded"` and bounded metadata `{ claim, contentIndex, start, end }` — never a full response body. `"flag"` returns `action: "allow"` plus that same metadata and `violation: true`, so the response stays visible while the normal `guardrail_decision` event and run ledger preserve the flag. Strict mode treats every standalone number (including dates, percentages, and versions) as a claim; use the option only where that law is wanted.
105
+
73
106
  ## Extension and configuration notes
74
107
 
75
108
  Guardrails are callbacks supplied by the host. Prism does not discover, load, retry, or persist callback code. `createSecureAgent()` keeps configured guardrails and only appends run-level checks; it never lets a run remove secure defaults. Custom loops receive guarded `LoopContext.generate()` and `LoopContext.dispatchToolCall()`; host code that directly calls a provider or `ToolDefinition.execute()` is outside the runtime boundary.
@@ -0,0 +1,254 @@
1
+ # Release 0.7.0 — Primitive, Compatibility, and Integration-Boundary Review
2
+
3
+ Plan: [073-Release-0-7-0-Host-Completeness.md](../../plans/073-Release-0-7-0-Host-Completeness.md) Task 1
4
+ Baseline: Released `0.6.0`
5
+ Target: Release `0.7.0` (Host Completeness, Evidence, and Capability Boundaries)
6
+ Date: 2026-09-13
7
+
8
+ ---
9
+
10
+ ## 1. Executive Summary & Review Scope
11
+
12
+ This review freezes the architectural primitives, compatibility contracts, performance budgets, and security boundaries for Release **0.7.0**.
13
+
14
+ The release addresses the **three integration traps** identified in 0.6.0 (Traps A, B, C) and delivers the **fourteen P0–P2 host completeness recommendations** (R01–R06, R08–R14), integrating:
15
+ - **R07 / R15** from [Plan 072 — Host Eval and Observability Cockpit](../../plans/072-Host-Eval-And-Observability-Cockpit.md) (frozen in [`docs/_evidence/phase72-primitive-review.md`](../_evidence/phase72-primitive-review.md)),
16
+ - **R16** from [Plan 077 — Work-Scope Memory Index](../../plans/077-Work-Scope-Memory-Index.md) (`WorkScope` / `projectWorkMemory`),
17
+ - **R17** from [Plan 074 — Attention Compiler](../../plans/074-Attention-Compiler.md) (`assembleTurn`, cache-stable attention ratio gate, sticky stubs).
18
+
19
+ ### Universal Invariants Upheld
20
+
21
+ 1. **Fail closed at trust boundaries**: Identity validation, tenant scoping, document authorization, and sandbox isolation fail closed. Never weaken fail-closed assertions.
22
+ 2. **No new dependencies without explicit plan authorization**: Root remains zero runtime dependencies. Optional SDKs live strictly as optional peer dependencies within owning integration packages, never loaded at import or module evaluation time.
23
+ 3. **No second agent loops or duplicated control planes**: Reuse existing core primitives (`Agent`, `AIProvider`, `ModelRouter`, `CheckpointStore`, `LeaseStore`, `ToolEffectStore`, `RunLedger`, `ProcessSessions`, `DeviceAdapter`).
24
+ 4. **Byte hard caps preserved**: All process-safety limits (`maxRequestBytes`, `maxResponseBytes`, `maxEventBytes`, `maxResultBytes`) remain immutable ceilings.
25
+ 5. **Truth in capability and state**: No simulated or mock-only claims for production infrastructure. Unobserved or ambiguous external mutations remain explicitly `unknown`, never fabricated as succeeded or zero-cost.
26
+
27
+ ---
28
+
29
+ ## 2. Coverage Ledger & Primitive Mapping
30
+
31
+ Every review row is mapped below to its reusable baseline primitives, implementation owner, generic capability gap, dependencies, and required release evidence.
32
+
33
+ | ID | Title | Reusable Baseline Primitives | Implementation Owner | Generic Capability Gap | Dependencies | Release Evidence |
34
+ |---|---|---|---|---|---|---|
35
+ | **Trap A** | Parsed ACP MCP destination allow-list | `packages/acp-agent/src/index.ts`, `selectMcpServers` | `packages/acp-agent/src/` | URL-parsed origin and strict path-segment subtree matching | None (Node `URL`) | Origin lookalike rejection, traversal/separator refusal, port/scheme validation |
36
+ | **Trap B** | Router sync facade fail-loud governance | `createModelRouter`, `providerSource` | `packages/prism-core/src/governance/model-router/` | Fast synchronous check throwing `ERR_PRISM_MODEL_ROUTER_ASYNC_REQUIRED` when budget/circuit/rateLimit configured | None | Sync bypass rejection on budget/circuit, async `resolve` passes |
37
+ | **Trap C** | ACP real model/provider configuration | `PrismAcpAgentConfig`, `createSpawnableAgent` | `packages/acp-agent/src/` | Validated `model` + `credentialRef` config parsing, explicit mock opt-in | `@arnilo/prism-providers` | Direct provider invocation via ACP, unknown provider refusal, credential canary check |
38
+ | **R01** | Governed provider invocation & aggregate accounting | `ModelRouter.resolve`, `recordUsage`, `AIProvider` | `packages/prism-core/src/governance/model-router/` | `GovernedAIProvider` adapter wrapping select, reserve, request policy, invoke, settle | None | Zero-budget denial, stream settlement, duplicate settlement idempotency |
39
+ | **R01** | Aggregate task/tenant accounting | `PostgresModelRouterStateStore`, `stateKey` | `packages/prism-core/src/enterprise/postgres/model-router/` | Cross-call aggregate task/tenant dimensions; reservation renewal & fencing | PostgreSQL driver | Concurrent 32-attempt allocation under cap, non-session tool/embedding charging |
40
+ | **R02** | Durable business-action drafts & review | `WorkIdempotencyStore`, `ArtifactBodyStore` | `packages/prism-core/src/integrations/work/` | Revision-bound draft state machine, payload digest verification, expiry | Persistence backends | Draft edit invalidates prior approval, resume executes exact revision, unknown outcome logged |
41
+ | **R02** | Editable durable approvals (AG-UI/server) | `RunDecision`, `approveWithEdits`, AG-UI handler | `packages/ag-ui/src/`, `packages/prism-core/src/runtime/server/` | `approveWithEdits` protocol capability, CAS expectedVersion validation | `@arnilo/prism-ag-ui` | Edited approval round-trip, invalid schema denial, quorum invalidation |
42
+ | **R03** | Docker process sessions & workspace coherence | `DockerSandboxSession`, `createProcessSessions` | `packages/prism-coding-tools/src/security/`, `agent/process/` | `startProcess` on `DockerSandboxSession`, attested container reattach | Docker CLI | Watcher I/O, kill/signal, registry restart recovery without duplicate spawn |
43
+ | **R03** | Hosted sandbox (E2B) | `DisposableSandbox`, `ProcessSandboxBackend` | `packages/prism-coding-tools/src/security/e2b-sandbox.ts` | E2B adapter implementing `DisposableSandbox` + `startProcess` + snapshot resume | `@e2b/code-interpreter` (optional peer) | E2B execution, pause/resume, snapshot integrity, cleanup on abort |
44
+ | **R04** | Document authorization in RAG | `retrieveContext`, `VectorStore`, `lexicalQuery` | `packages/memory/src/rag/`, `packages/memory/src/postgres.ts` | Principal/group ACL constraint injected into vector/lexical query legs | None / pgvector | Pre-ranking candidate exclusion, post-topK non-starvation, ACL update revocation |
45
+ | **R04** | Incremental enterprise-source sync (Drive) | `RagStore`, `Chunker`, `VectorMemory` | `packages/memory/src/rag/sync.ts`, `connectors/google-drive.ts` | Change-token pagination (`newStartPageToken`), tombstone deletion, ACL sync | Google Drive API / `@googleapis/drive` | Incremental change ingestion, tombstone deletion, stale-token recovery |
46
+ | **R05** | Validated host compositions | `createSecureAgent`, `createAgent` | `templates/personal-assistant/`, `templates/business-worker/` | Validated production wiring templates & static composition inspection | Internal packages | Packed npm install smoke, unredacted secret check, memory-persistence refusal |
47
+ | **R06** | Fair background admission & drain | `createWorkflowCoordinator`, `PrismDrainController` | `packages/prism-core/src/runtime/server/drain.ts`, `workflows/coordinator.ts` | Multi-tenant fair queuing, graceful drain deadline, active run tracking | None | 503 on drain admit, queue fairness across tenants, clean in-flight completion |
48
+ | **R07** | Behavioral & trajectory evaluation | `EvaluationTrace`, `runExperiment` (Plan 072) | `packages/prism-coding-tools/src/dev/` (inspector wiring) | Wiring 072 trajectory & scenario eval into inspector UI and release gates | Plan 072 artifacts | Scenario gate pass, trajectory deviation scoring, inspector run visualization |
49
+ | **R15** | Execution timeline & workflow graph | `ExecutionTimeline`, `serializeWorkflowGraph` (Plan 072) | Plan 072 implementation | Consumed by 0.7.0 release journeys and Dev Inspector | Plan 072 artifacts | Timeline step rendering, node overlay, trace aggregation |
50
+ | **R16** | Work-scope session memory index | `WorkScope`, `projectWorkMemory` (Plan 077) | Plan 077 implementation | Parallel session memory index; task isolation until explicit promote | Plan 077 artifacts | Task isolation test, promotion round-trip, scope boundary enforcement |
51
+ | **R17** | Attention compiler & compaction trigger | `assembleTurn`, ratio gate (Plan 074) | Plan 074 implementation | Cache-stable prompt assembly, sticky stub compaction | Plan 074 artifacts | Ratio gate no-op under ceiling, sticky stubs above ceiling |
52
+ | **R08** | Cross-layer memory correction & provenance | `ObservationalMemory`, `VectorMemory` | `packages/memory/src/memory.ts`, `compaction/observational-memory/` | Point correction, tombstoning, cross-layer provenance lineage, sharing grant | None / Postgres | Correct memory update, tombstone tombstoning in search, lineage query |
53
+ | **R09** | External coding runtime delegation | `Supervisor`, `SubagentTool` | `packages/prism-coding-tools/src/agent/delegated/` | Typed adapters for Codex, Claude, Copilot, Gemini CLI, Cursor | Optional vendor SDKs | Approval interception, tool call containment, session resume |
54
+ | **R10** | Semantic artifact diffs & evidence citations | `ArtifactBodyStore`, `patchDocument` | `packages/office/src/documents/diff.ts`, `packages/web-tools/src/evidence.ts` | Structural document diffs, evidence citation attestation and OCR grounding | None | Semantic diff visualization, citation verification, tampering rejection |
55
+ | **R10** | Scanned document layout & OCR (Mistral) | `DocumentReader`, `parseDocument` | `packages/prism-coding-tools/src/document-reader/mistral-ocr.ts` | External layout analysis and OCR extraction adapter | Mistral AI API | PDF table extraction, layout preservation, fallback handling |
56
+ | **R11** | Per-run tool narrowing & capability invalidation | `createToolRegistry`, `RunOptions` | `src/contracts-protocol.ts`, `src/tools.ts`, `packages/mcp/` | `RunOptions.toolAllowList`, dynamic tool filtering, remote capability cache refresh | None | Hidden tool schema, rejection of unauthorized tool call, MCP change invalidation |
57
+ | **R12** | Native Bedrock Converse & ConverseStream | `bedrockProvider` (0.6.0 wraps `/openai/v1`) | `packages/prism-providers/src/bedrock/` | Native AWS Bedrock Converse & ConverseStream protocol adapter with SigV4 | `@aws-sdk/client-bedrock-runtime` | Native Converse tool round, ConverseStream event decode, token counting |
58
+ | **R13** | Native Vertex Gemini with workload identity | `vertexProvider` (0.6.0 wraps OpenAI-compat) | `packages/prism-providers/src/vertex/` | Native Google Vertex Gemini `generateContent` & `streamGenerateContent` | `@google-cloud/vertexai` | Native content parts, tool round, Google ADC credential rotation |
59
+ | **R13** | Thin Python & .NET remote clients | `PrismServer` HTTP / SSE routes | `clients/python/`, `clients/dotnet/` | Remote typed clients for run execution, SSE stream consumption, and approval | Python stdlib, .NET HttpClient | Stream framing, reconnection with Last-Event-ID, edited approval payload |
60
+ | **R13** | Authenticated Slack & Teams recipes | `PrismServer` webhooks & decision routes | `examples/channels/slack/`, `examples/channels/teams/` | Webhook verification (Slack HMAC, Teams JWT), interactive review cards | Optional Bot SDKs | Forged signature denial, interactive card approval, draft re-review |
61
+ | **R14** | Governed realtime voice orchestration | `RealtimeSession`, `DeviceAdapter` | `packages/prism-core/src/runtime/realtime/`, `packages/prism-providers/src/openai/realtime.ts` | Realtime tool calling bridge, microphone admission, barge-in cancellation | None (WebSocket) | Mic admission check, interruption cancellation, audio privacy retention |
62
+ | **Release** | Integrated journeys, truth & publish | Release tooling, packaging, gates | `scripts/`, `docs/`, `packages/*/` | Lockstep 0.7.0 cut, generated package truth, live matrix evidence | Node 22/24 | Clean build, packaging gate pass, live matrix green, dry-run publish |
63
+
64
+ ---
65
+
66
+ ## 3. Reference Integration Matrix & Version-Selection Rules
67
+
68
+ Prism adheres strictly to a zero-eager-dependency policy: optional third-party integrations must never bloat package install size or trigger unreviewed imports.
69
+
70
+ | Domain | Selected Reference Implementation | Vendor / Package Identifier | Pinning & Version Selection Rule | Operational Role & Boundary |
71
+ |---|---|---|---|---|
72
+ | **Hosted Sandbox** | E2B | `@e2b/code-interpreter` | Pinned to `^1.0.0` as optional peer in `@arnilo/prism-coding-tools`. Evaluated only when host passes `createE2bSandbox`. | Untrusted ephemeral execution environment with filesystem snapshotting. Network strictly egress-controlled. |
73
+ | **Enterprise Source** | Google Drive | `@googleapis/drive` (or native fetch REST v3) | Google Drive API v3. Optional peer or direct REST fetch in `@arnilo/prism-memory`. | Document knowledge source. Sync uses `changes.list` with `startPageToken` and ACL sync. |
74
+ | **Layout / OCR** | Mistral OCR | `@mistralai/mistralai` (or native fetch) | Mistral Document AI API (`mistral-ocr-latest`). Optional peer in `@arnilo/prism-coding-tools`. | Scanned PDF / complex image layout parser. Output ingested as structured Markdown blocks. |
75
+ | **Delegation: OpenAI** | OpenAI Codex | `@openai/codex` (or direct app-server) | Official OpenAI Codex thread SDK. Pinned peer in `@arnilo/prism-coding-tools`. | Cloud coding agent delegation via `startThread` / `resumeThread`. Tool execution approvals intercepted. |
76
+ | **Delegation: Anthropic** | Claude Code / Agent SDK | `@anthropic-ai/claude-code` | Stable Agent SDK V1 (`query`, `canUseTool`, `options.resume`). No unstable V2. | Local/cloud coding agent delegation with explicit tool permission callbacks. |
77
+ | **Delegation: GitHub** | GitHub Copilot | `@github/copilot-sdk` | Official Copilot Workspace/CLI SDK. Optional peer in `@arnilo/prism-coding-tools`. | Repo-scoped coding delegation. Enforces GitHub enterprise auth & token boundary. |
78
+ | **Delegation: Google** | Google Gemini CLI | `@google-gemini/gemini-cli` | Official Gemini CLI SDK. Pinned peer in `@arnilo/prism-coding-tools`. | Local workspace CLI agent delegation. |
79
+ | **Delegation: Cursor** | Cursor SDK | `@cursor/sdk` (or local CLI engine) | Cursor TypeScript SDK / local engine. Pinned peer in `@arnilo/prism-coding-tools`. | Editor-bound workspace task delegation. |
80
+ | **Cloud Provider: AWS** | AWS Bedrock | `@aws-sdk/client-bedrock-runtime` | Pinned `^3.700.0` optional peer in `@arnilo/prism-providers`. | Native Converse & ConverseStream endpoints. Uses SigV4 request signing and AWS event streams. |
81
+ | **Cloud Provider: GCP** | Google Vertex AI | `@google-cloud/vertexai` | Pinned `^1.9.0` optional peer in `@arnilo/prism-providers` (or direct REST). | Native Gemini `generateContent` & `streamGenerateContent` with Google ADC credentials. |
82
+ | **Remote Client: Python** | `prism-agent-client` | `clients/python` | Target Python `>= 3.10`. Zero runtime dependencies outside Python standard library (`urllib.request`, `json`). | Remote client for starting runs, streaming SSE events, and submitting edited approvals. |
83
+ | **Remote Client: .NET** | `Prism.Client` | `clients/dotnet` | Target `.NET 8.0+` LTS. Pure `System.Net.Http` and `System.Text.Json`. | Remote C# client for Prism Server communication. |
84
+ | **Channel: Slack** | Slack Webhook Recipe | `examples/channels/slack` | Uses raw Node HTTP HMAC verification or optional `@slack/bolt`. | Webhook receiver verifying `X-Slack-Signature` and rendering Block Kit editable approval cards. |
85
+ | **Channel: Teams** | Teams Bot Recipe | `examples/channels/teams` | Uses Bot Framework JWT verification or `@microsoft/teamsfx`. | Bot Framework webhook receiver validating Microsoft tenant and rendering Adaptive Cards. |
86
+ | **Realtime Voice** | OpenAI Realtime | Native WebSocket | Pinned to OpenAI Realtime API (`gpt-4o-realtime-preview`). Pure WebSocket transport in `@arnilo/prism-providers`. | Governed bidirectional audio streaming with microphone device admission and barge-in cancellation. |
87
+
88
+ ---
89
+
90
+ ## 4. Performance, Startup, and Package Budgets
91
+
92
+ All implementations in 0.7.0 must adhere to established performance ceilings recorded in `scripts/budgets.json`.
93
+
94
+ ### 4.1 Package Size & File Count Budgets
95
+
96
+ | Package | Packed Bytes Baseline (±5%) | Unpacked Bytes Baseline (±5%) | File Count Baseline (±5%) | Public Export Count Ceiling |
97
+ |---|---|---|---|---|
98
+ | `@arnilo/prism` (root) | 1,098,881 | 3,690,682 | 441 | 1,287 |
99
+ | `@arnilo/prism-acp-agent` | — | — | — | 11 |
100
+ | `@arnilo/prism-ag-ui` | — | — | — | 312 |
101
+ | `@arnilo/prism-mcp` | — | — | — | 134 |
102
+ | `@arnilo/prism-memory` | — | — | — | 638 |
103
+ | `@arnilo/prism-office` | — | — | — | 230 |
104
+ | `@arnilo/prism-coding-tools` | — | — | — | 955 |
105
+ | `@arnilo/prism-core` | — | — | — | 1,333 |
106
+ | `@arnilo/prism-providers` | — | — | — | 506 |
107
+ | `@arnilo/prism-web-tools` | — | — | — | 303 |
108
+
109
+ *Rule:* Any increase in root packed bytes or file count must be justified in `scripts/budgets.json`. Export ceilings fail closed under `scripts/budget-gate.test.mjs`.
110
+
111
+ ### 4.2 Startup Time Budgets
112
+
113
+ - **Cold-Process `import('@arnilo/prism')` Wall Time**:
114
+ - Baseline: `38 ms`
115
+ - Hard Ceiling: `250 ms`
116
+ - **Machine-Relative Startup Ratio (`importMs / processStartMs`)**:
117
+ - Baseline Ratio: `3.3`
118
+ - Idle Ceiling Ratio: `8.0`
119
+ - Under-Load Ceiling Ratio (`loadavg >= 1.5` per CPU): `20.0`
120
+
121
+ *Enforcement:* No optional provider, tool, database, or SDK dependency may evaluate at package import time. All heavy imports are deferred to dynamic `await import()` upon explicit host activation.
122
+
123
+ ### 4.3 Workload Bounds & Hard Caps
124
+
125
+ - **Request / Response Safety Caps**:
126
+ - `DEFAULT_MAX_REQUEST_BYTES`: `4 MiB` (hard ceiling `32 MiB`)
127
+ - `DEFAULT_MAX_RESPONSE_BYTES`: `4 MiB` (hard ceiling `32 MiB`)
128
+ - `HARD_CHUNK_SIZE_CAP` (RAG): `64 KiB`
129
+ - **Event Streaming Caps**:
130
+ - Ring buffer size: `100` items default, `10,000` hard max
131
+ - SSE message size: `64 KiB` max per frame
132
+ - **Concurrency & Conformance Bounds**:
133
+ - Max concurrent distributed coordinator claims: `4` default, `16` max
134
+ - Router concurrent reservation stress: `32` concurrent workers across `>= 2` models
135
+
136
+ ---
137
+
138
+ ## 5. Architectural Invariants & Shared Contracts
139
+
140
+ To maintain code quality and prevent divergence across packages:
141
+
142
+ ### 5.1 No Duplicated Primitives
143
+ - **Agent Loop**: Single execution loop in `src/agent-session/session.ts`. No secondary loop in ACP, supervisor, or delegated wrappers.
144
+ - **Approval Store**: Approvals managed strictly through `RunDecision` and `CheckpointStore`. No standalone approval database.
145
+ - **Scheduler**: Workflow execution managed by `createWorkflowCoordinator` with `LeaseStore`. No secondary cron or background queue daemon.
146
+ - **Tool Registry**: Single `ToolRegistry` implementation in `src/tools.ts`. Per-run narrowing filters the registry dynamically; it does not instantiate a separate registry.
147
+
148
+ ### 5.2 Genuinely Shared Contracts
149
+ 1. **Governed Provider Invocation**:
150
+ ```ts
151
+ export interface GovernedInvocationOptions {
152
+ readonly router: ModelRouter;
153
+ readonly model: ModelConfig;
154
+ readonly identity: AgentIdentity;
155
+ readonly maxCostUsd?: number;
156
+ }
157
+ ```
158
+ Wraps `AIProvider.generate()` / `generateStream()` with atomic reservation, request policy injection, response metering, and commit/release.
159
+ 2. **Durable Action Draft & Revision Reference**:
160
+ ```ts
161
+ export interface ActionDraftRevision {
162
+ readonly draftId: string;
163
+ readonly revision: number;
164
+ readonly payloadDigest: string; // sha256 of canonical payload
165
+ readonly policyRevision: string;
166
+ readonly createdAt: string;
167
+ }
168
+ ```
169
+ Ensures that any edit to a draft changes its digest and invalidates prior approvals.
170
+ 3. **RAG Access Constraint**:
171
+ ```ts
172
+ export interface RagAccessConstraint {
173
+ readonly principalId: string;
174
+ readonly groupIds: readonly string[];
175
+ readonly tenantId: string;
176
+ }
177
+ ```
178
+ Passed down to both vector search and lexical query legs to enforce pre-ranking exclusion.
179
+
180
+ ---
181
+
182
+ ## 6. Threat Model & Security Enforcement
183
+
184
+ | Threat Domain | Threat Vector | Mitigation & Fail-Closed Enforcement | Visibility & Audit |
185
+ |---|---|---|---|
186
+ | **Identity & Tenant Scope** | Cross-tenant access, spoofed userId in distributed calls | Identity active and ownership matching verified via `assertIdentityMatchesOwnership`. Cross-tenant budget or session access throws `ERR_PRISM_SECURITY_TENANT_MISMATCH`. | OTel trace tenant tag; `AgentEvent.agent_denied` emitted on mismatch. |
187
+ | **Source ACLs (RAG)** | Unauthorized document exposure via vector similarity or lexical search | Predicate pushdown into SQL / vector queries. Unauthorized candidates never enter candidate list or top-K ranking. Revocation invalidates cached candidates. | Audit log records query principal and accessed document IDs. Text is never logged. |
188
+ | **Durable Approvals** | Approval replay, editing payload after approval, unauthorized approver | `expectedVersion` CAS on resume. Approved digest must match current draft digest. Edits invalidate approval and increment revision. Separation-of-duties requires distinct approver. | `RunDecision` records approver identity, timestamp, and payload digest. |
189
+ | **Credentials & Secrets** | Leaked provider tokens in logs, event streams, or process argv | Credential references (`credentialRef`) used in configs. Secrets resolved only at provider edge. `SecretRedactor` scrubs all ledgers and event streams. | Canary strings tested across all event streams, logs, and artifacts. |
190
+ | **Execution Containment** | Malicious shell execution, sandbox breakout, directory traversal | Docker sandbox with `network: "none"` or audited proxy; non-root user; workspace root confinement via realpath traversal checks. E2B uses isolated cloud VMs. | Container ID, image digest, and execution policy audited per session. |
191
+ | **Durable Resume & Fencing** | Split-brain execution, duplicate side-effect replay upon network failure | Distributed lease acquisition with fencing tokens. External mutations record `ToolEffectStore` idempotent keys. Ambiguous outcomes stay `unknown`. | Lease records in PostgreSQL with TTL; unknown effects surfaced in run status. |
192
+ | **Budget & Cost Exhaustion** | Runaway LLM loops, unmetered tool/compaction calls | Atomic budget reservation before model call. Strict budget mode rejects calls without known pricing. Background compaction and embeddings charged against task budget. | Aggregated usage records linked to `taskId` and `tenantId`. |
193
+ | **Remote Runtime Delegation** | Prompt injection via delegated agents (Codex/Claude/Cursor) | All external agent tool requests route through Prism's `ExecutionPolicy`. Approval interception preserves host control. External session state kept isolated. | Delegated agent steps logged as `delegated_agent_step` events with token usage. |
194
+
195
+ ---
196
+
197
+ ## 7. Plan 072, 074, 077 Boundary Freeze
198
+
199
+ To maintain strict modularity across concurrent plans:
200
+ - **Plan 072 Freeze (Eval & Observability)**:
201
+ - `ExecutionTimeline`, `projectAgentTimeline`, `projectTraceTimeline`, `projectWorkflowTimeline` are owned by Plan 072.
202
+ - `WorkflowGraphView` and `serializeWorkflowGraph` are owned by Plan 072.
203
+ - Trajectory scorers (`createToolCallMatchScorer`) and scenario runners are owned by Plan 072.
204
+ - Task 15 of Plan 073 strictly wires these surfaces into Dev Inspector and Release Gates; it **does not** create duplicate timeline projectors.
205
+ - **Plan 077 Freeze (Work-Scope Memory Index)**:
206
+ - `WorkScope`, `projectWorkMemory`, session memory isolation are owned by Plan 077.
207
+ - Plan 073 assumes work-scope isolation in its coding journeys without reimplementing the index.
208
+ - **Plan 074 Freeze (Attention Compiler)**:
209
+ - `assembleTurn`, ratio gates, and sticky stub compaction triggers are owned by Plan 074.
210
+ - Plan 073 does not introduce a competing prompt assembly or compaction trigger.
211
+
212
+ ---
213
+
214
+ ## 8. Resolution of File Lists & Barrels (Tasks 2–29)
215
+
216
+ Below are the exact resolved file paths and implementation splits for all tasks where tentative or proposed filenames appeared in the plan:
217
+
218
+ | Task | Capability | Resolved Implementation & Test Files | Export / Barrel Location |
219
+ |---|---|---|---|
220
+ | **Task 4** | Real-provider ACP launcher | `packages/acp-agent/src/config.ts`, `packages/acp-agent/src/index.ts`, `packages/acp-agent/bin/prism-acp-agent.ts`, `packages/acp-agent/src/__tests__/agent.test.ts` | `packages/acp-agent/src/index.ts` |
221
+ | **Task 5** | Host composition templates | `templates/personal-assistant/src/index.ts`, `templates/personal-assistant/package.json`, `templates/business-worker/src/index.ts`, `templates/business-worker/package.json`, `packages/prism-coding-tools/src/dev/inspector.ts` | `templates/README.md`, `packages/prism-coding-tools/src/dev/index.ts` |
222
+ | **Task 6** | Governed provider invocation | `packages/prism-core/src/governance/model-router/invocation.ts`, `packages/prism-core/src/governance/model-router/__tests__/invocation.test.ts` | `packages/prism-core/src/governance/model-router/index.ts` |
223
+ | **Task 7** | Aggregate task accounting | `packages/prism-core/src/enterprise/postgres/model-router/reservations.ts`, `packages/prism-core/src/enterprise/postgres/model-router/state-store.ts`, `packages/prism-core/src/enterprise/postgres/migrations.ts` | `packages/prism-core/src/enterprise/postgres/index.ts` |
224
+ | **Task 8** | Durable draft review | `packages/prism-core/src/integrations/work/drafts.ts`, `packages/prism-core/src/integrations/work/tools.ts`, `packages/prism-core/src/integrations/work/google-workspace.ts`, `packages/prism-core/src/integrations/work/microsoft365.ts`, `packages/prism-core/src/integrations/work/__tests__/drafts.test.ts` | `packages/prism-core/src/integrations/work/index.ts` |
225
+ | **Task 9** | AG-UI editable approvals | `packages/ag-ui/src/handler.ts`, `packages/ag-ui/src/types.ts`, `packages/ag-ui/src/projection.ts`, `packages/prism-core/src/runtime/server/handler/core.ts`, `packages/prism-core/src/runtime/server/handler/readers.ts` | `packages/ag-ui/src/index.ts` |
226
+ | **Task 10** | Docker process sessions | `packages/prism-coding-tools/src/security/docker-sandbox.ts`, `packages/prism-coding-tools/src/security/docker-cli.ts`, `packages/prism-coding-tools/src/agent/process/sessions-spawn.ts`, `packages/prism-coding-tools/src/agent/process/sessions-recovery.ts` | `packages/prism-coding-tools/src/security/index.ts` |
227
+ | **Task 11** | Document authorization in RAG | `packages/memory/src/rag/retrieve.ts`, `packages/memory/src/rag/types.ts`, `packages/memory/src/postgres.ts`, `packages/memory/src/__tests__/rag-acl.test.ts` | `packages/memory/src/rag/index.ts` |
228
+ | **Task 12** | Google Drive incremental sync | `packages/memory/src/rag/sync.ts`, `packages/memory/src/connectors/google-drive.ts`, `packages/memory/src/__tests__/sync.test.ts` | `packages/memory/src/index.ts` |
229
+ | **Task 13** | Hosted sandbox (E2B) | `packages/prism-coding-tools/src/security/e2b-sandbox.ts`, `packages/prism-coding-tools/src/security/__tests__/e2b-sandbox.test.ts` | `packages/prism-coding-tools/src/security/index.ts` |
230
+ | **Task 14** | Fair background admission & drain | `packages/prism-core/src/runtime/server/drain.ts`, `packages/prism-core/src/runtime/workflows/coordinator.ts`, `packages/prism-core/src/runtime/server/__tests__/drain.test.ts` | `packages/prism-core/src/runtime/server/index.ts` |
231
+ | **Task 15** | Inspector eval/journey wiring | `packages/prism-coding-tools/src/dev/ui/inspector.ts`, `packages/prism-coding-tools/src/dev/server.ts`, `packages/prism-coding-tools/src/dev/__tests__/inspector.test.ts` | `packages/prism-coding-tools/src/dev/index.ts` |
232
+ | **Task 16** | Cross-layer memory correction | `packages/memory/src/memory.ts`, `packages/memory/src/lineage.ts`, `packages/memory/src/compaction/observational-memory/runtime.ts`, `packages/memory/src/compaction/observational-memory/ledger.ts` | `packages/memory/src/index.ts` |
233
+ | **Task 17** | Delegated runtimes (Codex/Claude) | `packages/prism-coding-tools/src/agent/delegated/codex.ts`, `packages/prism-coding-tools/src/agent/delegated/claude.ts`, `packages/prism-coding-tools/src/agent/delegated/types.ts`, `packages/prism-coding-tools/src/agent/delegated/index.ts` | `packages/prism-coding-tools/src/index.ts` |
234
+ | **Task 18** | Delegated runtimes (Copilot/Gemini/Cursor) | `packages/prism-coding-tools/src/agent/delegated/copilot.ts`, `packages/prism-coding-tools/src/agent/delegated/gemini-cli.ts`, `packages/prism-coding-tools/src/agent/delegated/cursor.ts` | `packages/prism-coding-tools/src/agent/delegated/index.ts` |
235
+ | **Task 19** | Semantic artifact diffs & evidence | `packages/office/src/documents/diff.ts`, `packages/prism-core/src/runtime/server/artifacts-service.ts`, `packages/web-tools/src/evidence.ts` | `packages/office/src/index.ts`, `packages/web-tools/src/index.ts` |
236
+ | **Task 20** | Scanned document OCR (Mistral) | `packages/office/src/documents/parse.ts`, `packages/prism-coding-tools/src/document-reader/mistral-ocr.ts` | `packages/prism-coding-tools/src/document-reader/index.ts` |
237
+ | **Task 21** | Per-run tool narrowing | `src/contracts-protocol.ts` (`RunOptions.toolAllowList`), `src/tools.ts`, `src/agent-session/session/provider-round.ts`, `packages/mcp/src/bridge.ts`, `packages/mcp/src/capabilities.ts` | `src/index.ts`, `packages/mcp/src/index.ts` |
238
+ | **Task 22** | Native Bedrock Converse | `packages/prism-providers/src/bedrock/converse.ts`, `packages/prism-providers/src/bedrock/converse-stream.ts`, `packages/prism-providers/src/bedrock/provider.ts` | `packages/prism-providers/src/bedrock/index.ts` |
239
+ | **Task 23** | Native Vertex Gemini | `packages/prism-providers/src/vertex/native.ts`, `packages/prism-providers/src/vertex/provider.ts` | `packages/prism-providers/src/vertex/index.ts` |
240
+ | **Task 24** | Python & .NET remote clients | `clients/python/prism_client/{__init__.py,client.py}`, `clients/dotnet/Prism.Client/{PrismClient.cs,Prism.Client.csproj}` | Standalone client directories (excluded from npm root) |
241
+ | **Task 25** | Slack & Teams channel recipes | `examples/channels/slack/{index.ts,package.json}`, `examples/channels/teams/{index.ts,package.json}` | `examples/channels/` |
242
+ | **Task 26** | Governed realtime voice | `packages/prism-core/src/runtime/realtime/index.ts`, `packages/prism-core/src/runtime/realtime/session.ts`, `packages/prism-providers/src/openai/realtime.ts` | `packages/prism-core/src/runtime/index.ts`, `packages/prism-providers/src/index.ts` |
243
+
244
+ ---
245
+
246
+ ## 8. Evidence Checklist
247
+
248
+ Every capability delivered under 0.7.0 must satisfy this verification matrix:
249
+
250
+ - [ ] **Positive Verification**: Proves expected behavior on compliant inputs.
251
+ - [ ] **Refusal & Fail-Closed**: Proves rejected state on lookalike, malformed, unauthenticated, or cross-tenant inputs.
252
+ - [ ] **Restart & Recovery**: Proves state durability across process restarts without duplicate execution or state corruption.
253
+ - [ ] **Bounds & Limits**: Proves strict adherence to byte caps, timeout limits, and concurrency ceilings.
254
+ - [ ] **Documentation & Migration**: Proves accurate contract documentation in `/docs` and migration guidance in `docs/migrate-to-0.7.md`.