@happyvertical/smrt-chat 0.60.17 → 0.61.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 (86) hide show
  1. package/AGENTS.md +16 -22
  2. package/README.md +78 -0
  3. package/agents/owner-approvals.md +161 -0
  4. package/agents/runtime-exposure.md +28 -0
  5. package/agents/runtime-report-tools.md +26 -0
  6. package/agents/token-streaming.md +6 -0
  7. package/agents/tool-loop.md +13 -0
  8. package/agents/tool-summaries.md +155 -0
  9. package/agents/turn-drivers.md +293 -0
  10. package/dist/assistant-approvals.d.ts +45 -0
  11. package/dist/assistant-approvals.d.ts.map +1 -0
  12. package/dist/assistant-approvals.js +83 -0
  13. package/dist/assistant-approvals.js.map +1 -0
  14. package/dist/assistant-turn-driver.d.ts +73 -0
  15. package/dist/assistant-turn-driver.d.ts.map +1 -0
  16. package/dist/assistant-turn-events.d.ts +28 -1
  17. package/dist/assistant-turn-events.d.ts.map +1 -1
  18. package/dist/assistant-turn-events.js +2 -2
  19. package/dist/assistant-turn.d.ts +24 -37
  20. package/dist/assistant-turn.d.ts.map +1 -1
  21. package/dist/chunks/{ChatService-BGBAqmZq.js → ChatService-C1UBz0MR.js} +684 -657
  22. package/dist/chunks/ChatService-C1UBz0MR.js.map +1 -0
  23. package/dist/chunks/{assistant-turn-events-BbZUf-Ju.js → assistant-turn-events-DwdCZzQ0.js} +15 -2
  24. package/dist/chunks/assistant-turn-events-DwdCZzQ0.js.map +1 -0
  25. package/dist/chunks/chat-stream-mTbNV3kt.js +3571 -0
  26. package/dist/chunks/chat-stream-mTbNV3kt.js.map +1 -0
  27. package/dist/engines.d.ts +34 -0
  28. package/dist/engines.d.ts.map +1 -0
  29. package/dist/engines.js +260 -0
  30. package/dist/engines.js.map +1 -0
  31. package/dist/index.d.ts +4 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +8 -6
  34. package/dist/index.js.map +1 -1
  35. package/dist/internal/agent-runtime.js +1 -1
  36. package/dist/manifest.json +3 -1
  37. package/dist/persona-conversation.d.ts.map +1 -1
  38. package/dist/runtime-report-tools.d.ts.map +1 -1
  39. package/dist/services/ChatService.d.ts +3 -13
  40. package/dist/services/ChatService.d.ts.map +1 -1
  41. package/dist/smrt-knowledge.json +46 -9
  42. package/dist/smrt-knowledge.okf.md +29 -4
  43. package/dist/svelte/components/assistant/AssistantApprovalCard.svelte +198 -0
  44. package/dist/svelte/components/assistant/AssistantApprovalCard.svelte.d.ts +34 -0
  45. package/dist/svelte/components/assistant/AssistantApprovalCard.svelte.d.ts.map +1 -0
  46. package/dist/svelte/components/assistant/AssistantComposer.svelte +6 -3
  47. package/dist/svelte/components/assistant/AssistantComposer.svelte.d.ts +2 -0
  48. package/dist/svelte/components/assistant/AssistantComposer.svelte.d.ts.map +1 -1
  49. package/dist/svelte/components/assistant/AssistantDock.svelte +66 -17
  50. package/dist/svelte/components/assistant/AssistantDock.svelte.d.ts +2 -0
  51. package/dist/svelte/components/assistant/AssistantDock.svelte.d.ts.map +1 -1
  52. package/dist/svelte/components/assistant/assistant-http-client.d.ts +2 -0
  53. package/dist/svelte/components/assistant/assistant-http-client.d.ts.map +1 -1
  54. package/dist/svelte/components/assistant/assistant-http-client.js +28 -1
  55. package/dist/svelte/components/assistant/assistant-transport.d.ts +18 -1
  56. package/dist/svelte/components/assistant/assistant-transport.d.ts.map +1 -1
  57. package/dist/svelte/components/assistant/assistant-transport.js +2 -0
  58. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts +5 -1
  59. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts.map +1 -1
  60. package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.js +80 -4
  61. package/dist/svelte/i18n.d.ts +14 -0
  62. package/dist/svelte/i18n.d.ts.map +1 -1
  63. package/dist/svelte/i18n.js +14 -0
  64. package/dist/svelte/i18n.messages.d.ts +13 -0
  65. package/dist/svelte/i18n.messages.d.ts.map +1 -1
  66. package/dist/svelte/i18n.messages.js +13 -0
  67. package/dist/svelte/index.d.ts +2 -1
  68. package/dist/svelte/index.d.ts.map +1 -1
  69. package/dist/svelte/index.js +1 -0
  70. package/dist/sveltekit.d.ts +72 -4
  71. package/dist/sveltekit.d.ts.map +1 -1
  72. package/dist/sveltekit.js +439 -21
  73. package/dist/sveltekit.js.map +1 -1
  74. package/dist/tool-loop.d.ts +36 -3
  75. package/dist/tool-loop.d.ts.map +1 -1
  76. package/dist/tool-summary.d.ts +15 -0
  77. package/dist/tool-summary.d.ts.map +1 -0
  78. package/dist/tool-summary.js +95 -0
  79. package/dist/tool-summary.js.map +1 -0
  80. package/dist/work-profile.d.ts +64 -0
  81. package/dist/work-profile.d.ts.map +1 -0
  82. package/package.json +37 -23
  83. package/dist/chunks/ChatService-BGBAqmZq.js.map +0 -1
  84. package/dist/chunks/assistant-turn-events-BbZUf-Ju.js.map +0 -1
  85. package/dist/chunks/chat-stream-Cl_kkuiU.js +0 -2743
  86. package/dist/chunks/chat-stream-Cl_kkuiU.js.map +0 -1
package/AGENTS.md CHANGED
@@ -112,28 +112,13 @@ stored-facts integration when that serializer exposes `DocumentTax` rows.
112
112
 
113
113
  ## Runtime report tools (#3711)
114
114
 
115
- `createRuntimeReportTools()` (`runtime-report-tools.ts`) returns four
116
- `PrincipalTool`s for the persona `extraTools` seam: `reports.runtime.sources`,
117
- `reports.runtime.define` (`preview` / `apply`), `reports.runtime.list`, and
118
- `reports.runtime.run`. The model supplies only a declarative
119
- `RuntimeReportSpec` from `@happyvertical/smrt-reports`; sources are a
120
- server-owned allow-list gated by `run.assertOperation(collection, 'read')`, and
121
- field policy, `readPermission`, and tenancy are enforced by the compiler against
122
- the live run on every compile and every stored-report run. `apply` needs the
123
- `specHash` of the previewed spec plus an app-owned `confirmation` host that
124
- resolves only after a human approved that exact spec; with no host apply returns an `awaiting_confirmation` proposal for the
125
- same-origin browser confirm route and stores nothing and a model-supplied `confirmed` flag is ignored. Saving also needs
126
- `create` on the `RuntimeReport` collection, and `list`/`run` need `read`; the
127
- default `reportsCollection` is the `RuntimeReport` class itself, which resolves
128
- to the catalog slug. A string `collection`/`reportsCollection` is used verbatim
129
- as a catalog slug (never a class name); tests must run the tools under the real
130
- `assertOperationPermission` guard so a wrong slug fails. A stored report is
131
- written only by this confirmed `apply`: the model layer refuses every other
132
- insert/spec change, and the generic manifest tools (`buildManifestToolCatalog`,
133
- `invokeManifestTool`) never offer or run a `RuntimeReport` write. Stored-report
134
- reads/saves run under the principal's tenant (`withPrincipalTenant`), refuse a
135
- mismatching ambient tenant (checked before `confirmSave`), and filter by the principal tenant explicitly. Contract and authority model:
136
- [`packages/reports/agents/runtime-reports.md`](../reports/agents/runtime-reports.md).
115
+ `createRuntimeReportTools()` (`runtime-report-tools.ts`) returns the
116
+ `reports.runtime.*` `PrincipalTool`s for the persona `extraTools` seam. Sources
117
+ are a server-owned allow-list; `apply` needs the previewed `specHash` plus a
118
+ human `confirmation` host (a model-supplied `confirmed` flag is ignored); a
119
+ string `collection` is a catalog slug, never a class name; reads and saves run
120
+ under the principal's tenant. Read before editing:
121
+ [agents/runtime-report-tools.md](agents/runtime-report-tools.md).
137
122
 
138
123
  ## Overview tools (#3727)
139
124
 
@@ -188,6 +173,14 @@ Svelte dock imports it). The dock decides whether a browser call runs or waits
188
173
  for the user from the page registry, never the server's echo; destructive
189
174
  always waits. Details: [`docs/assistant-dock.md`](../../docs/assistant-dock.md).
190
175
 
176
+ ## Assistant seams
177
+
178
+ External turn drivers (`turnDriver`, `resolveTurnDriver`; chat keeps authorization,
179
+ authoring, SSE and cancellation): [agents/turn-drivers.md](agents/turn-drivers.md).
180
+ Durable owner approvals of destructive server tools: [agents/owner-approvals.md](agents/owner-approvals.md).
181
+ Tool summaries and inference engine adapters: [agents/tool-summaries.md](agents/tool-summaries.md).
182
+ Live cookbook exposure of manifest tools: [agents/runtime-exposure.md](agents/runtime-exposure.md).
183
+
191
184
  ## AssistantDock (#2904)
192
185
 
193
186
  `AssistantDock` (`svelte/components/assistant/`, exported from `./svelte`)
@@ -234,3 +227,4 @@ shell widget, an `llm` provider, runtime `both`; help in
234
227
  - **Session expiry**: check `isActive()` before allowing messages (expiresAt or limit-based)
235
228
  - **DM identity**: derived from the deterministic per-tenant `canonicalDmRoomId()` and the authoritative `chat_participants` join, not client metadata; concurrent creates upsert onto one row.
236
229
  - **Tenant-bound lookups**: membership/session/DM lookups REQUIRE `tenantId` and always bind it into the WHERE clause (`findActiveMembership`/`isActiveMember`/`findActiveSession` take a required `tenantId`; AgentSession's `null` tenant is an explicit bound scope, not "any tenant") so they can never resolve a row from another tenant.
230
+
package/README.md CHANGED
@@ -8,6 +8,41 @@ Chat rooms, DMs, threads, and agent conversations for the s-m-r-t framework. Sup
8
8
  pnpm add @happyvertical/smrt-chat
9
9
  ```
10
10
 
11
+ ## Assistant turn drivers
12
+
13
+ The assistant uses its existing model/tool loop by default. Supply an `ai`
14
+ client or per-request factory for a model adapter, or a `turnDriver` for an
15
+ external agent that owns its loop:
16
+
17
+ ```ts
18
+ import { mountAssistantRoutes } from '@happyvertical/smrt-chat/sveltekit';
19
+
20
+ export const { GET, POST } = mountAssistantRoutes({
21
+ turnDriver: {
22
+ async run(context, progress) {
23
+ // A host adapter forwards the agent's callbacks and AbortSignal.
24
+ context.signal.throwIfAborted();
25
+ progress.text('Hello from your agent.');
26
+ progress.done({ text: 'Hello from your agent.' });
27
+ },
28
+ },
29
+ allowedTools: [],
30
+ });
31
+ ```
32
+
33
+ `resolveTurnDriver(ctx)` selects a driver per authenticated request/user.
34
+ Chat keeps thread/message persistence, tool allow-lists, the dock's streaming
35
+ format and stop behavior. Drivers receive history, the new user message,
36
+ system guidance, thread identity, principal, offered server tools and an abort
37
+ signal. Await tool-call/result callbacks to author their transcript. The
38
+ `approvalNeeded` callback and `waitForApproval` host hook reserve the durable
39
+ owner-approval integration; without a hook approval is denied. Durable approval
40
+ storage and UI are not implemented by this seam.
41
+
42
+ See [turn-driver contracts and callback example](agents/turn-drivers.md),
43
+ including MCP authorization responsibilities, engine status, and browser
44
+ continuation limits.
45
+
11
46
  ## Data-surface bridge security
12
47
 
13
48
  The `./data-surface-bridge` entry point is the server half of the browser data-
@@ -393,3 +428,46 @@ the voice helpers.
393
428
 
394
429
  See [`AGENTS.md`](./AGENTS.md) for package architecture, invariants, validation,
395
430
  and contributor guidance.
431
+
432
+ ### Durable approvals for server tools
433
+
434
+ `mountAssistantRoutes` holds destructive server calls by default (delete/remove/
435
+ destroy/purge/drop/truncate, including extra tools). A built-in turn persists a
436
+ pending approval in its thread, streams `approval_needed`, and ends with
437
+ `stoppedReason: 'approval'`. It makes no further model call. Approve executes the
438
+ saved tool with its original principal and arguments after live permission and
439
+ offering checks, then authors the result. Deny authors a refusal. Model-supplied
440
+ `approved` values have no effect on this gate.
441
+
442
+ The default authority uses app-runtime's SQLite envelope adapter over the existing
443
+ smrt-approvals ledger; include its models in normal database migrations. Supply
444
+ `approvals` for another store/host authority. `approvalPolicy.tools` and
445
+ `approvalPolicy.operations` explicitly override the default per tool or canonical
446
+ operation; e.g. `{ tools: { 'invoices.update': true } }` also holds updates.
447
+ Direct `runAssistantTurn` callers supply `createAssistantApprovalBridge`; a
448
+ protected call without one fails closed. This does not change low-level
449
+ `runToolLoop` or persona conversation policy, which remain host integration APIs.
450
+
451
+ Owner-only routes: `GET approvals` (tenant-wide pending summaries), `GET threads/:threadId/approvals` and
452
+ `POST approvals/:id/decide` with `{ approve: boolean }`, under the same mount.
453
+ Thread reads keep their ownership checks; owner decision uses the saved requester's thread binding and cannot read arbitrary thread history. Tenant and mutation-origin checks match the
454
+ other routes. They return only the public approval projection. The default owner
455
+ check requires the active user's active direct membership in the canonical system
456
+ owner role. A second decision is 409. A failed consumed effect cannot be replayed.
457
+
458
+ `createAssistantHttpTransport` supplies the approval methods; `AssistantDock`
459
+ automatically renders `AssistantApprovalCard` for persisted holds, with translated,
460
+ keyboard-accessible Approve/Deny controls and persisted outcomes. External drivers
461
+ use their existing `approvalNeeded` callback: chat creates the canonical request,
462
+ persists/streams it, and waits for the same authority before returning approval.
463
+ Drivers must honor denial and execute through the original principal's live,
464
+ permission-bound host/MCP adapter. See [approval details](agents/owner-approvals.md).
465
+
466
+ Runtime cookbook gating is opt-in through
467
+ [smrt-core runtime exposure](../core/agents/runtime-exposure.md). Generated
468
+ manifest operations keep their AOT declarations, but live offerings and calls
469
+ must also pass the current tenant's cookbook and host preference gate.
470
+
471
+ Saved manifest calls recheck runtime exposure when approved. A disabled or
472
+ unreadable model gate records a terminal refused result without running the tool;
473
+ approval lists retain only the original public hold summary.
@@ -0,0 +1,161 @@
1
+ # Durable assistant approvals
2
+
3
+ Read `src/assistant-approvals.ts` for policy and the adapter over app-runtime's
4
+ `OwnerApprovalAuthority`. Reuse the typed approval wire contract and existing
5
+ external driver callbacks, tool-loop execution seam, ChatService authoring gate,
6
+ route auth/origin/thread checks, HTTP transport and smrt-ui Button/Card/i18n.
7
+ No duplicate approval model, ledger, generated CRUD route or provider integration.
8
+
9
+ Default policy uses canonical manifest action / extra-tool slug; destructive
10
+ arguments on a multiplexed tool can only add a hold, never downgrade a destructive
11
+ slug. Host per-tool override precedes per-operation override. Client declarations,
12
+ engine-selected approval ids and summaries, or `approved` arguments never grant
13
+ permission. External requests are rebuilt from the pending, offered canonical
14
+ call and host summary. Explicit `waitForApproval` without `approvals` preserves the
15
+ legacy trusted host callback contract; it must itself supply durability/owner auth.
16
+ The default bridge uses the app-runtime authority, including across processes.
17
+
18
+ Built-in holds stop after the tool round (`approval`). The envelope saves the
19
+ original actor, tenant, allow-list, permission ceiling, session, thread and origin
20
+ message. Decide re-resolves offerings and permissions and intersects the saved
21
+ ceiling; it never substitutes the deciding owner as executor. It consumes once
22
+ before execution, completes before authoring, and writes a tool result/refusal to
23
+ the same thread. A tenant owner may decide another requester's hold without receiving their thread history. A crash after consumption cannot safely be retried automatically;
24
+ `executing` is an explicit unknown-outcome state for reconciliation. Pending
25
+ requests survive restart; external engine processes do not resume automatically.
26
+ A restored pending external hold may be denied/expire, but approval without its
27
+ live driver cannot restart that driver. The low-level engine/MCP adapter still
28
+ owns enforcement of live tool permissions for external effects.
29
+
30
+ The SQLite default uses migrated smrt-approvals application schema plus a runtime
31
+ system envelope table. Do not create approval model schema on request. Other
32
+ storage engines require a host authority/store integration and its own tests.
33
+
34
+ ## Test design
35
+
36
+ Commands: package `test`, `typecheck`, filtered dependency `build`; root `lint`,
37
+ `format-check`, `knowledge:check --strict`. All new tests are Node/SQLite plus
38
+ jsdom components, scripted models, fake external drivers, no provider/container.
39
+
40
+ | Behavior/invariant | Reachable trigger | Positive case | Negative/failure | Actor/context | Executor/transaction | Runtime/dialect | External edge | Level | Command |
41
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
42
+ | Built-in hold | Model calls server delete | Persisted/streamed pending; no execution | Model approved flag cannot bypass | Original principal/owned thread | Existing tool-loop principal context + canonical authority | Node/SQLite | Tool call + SSE | Route integration | Package test |
43
+ | Decision/resumption | Owner posts decision | Original args/principal run once; result authored | Deny, repeat, malformed, foreign origin/tenant/non-owner | Owner × owned/foreign thread × tenant | Authority consume before executeAsPrincipal; ChatService author | Node/SQLite | HTTP decision | Route integration | Package test |
44
+ | Permission ceiling | Decision after grants/offer changes | Live intersection preserves allowed action | Revoked tool/permission cannot run | Original actor, never decider | Existing PermissionResolver + execution gate | Node/SQLite | Host extra tools | Route integration | Package test |
45
+ | External wait | Driver requests approval | Same durable authority releases wait | Denial/abort never grants approval | Bound driver principal/call | Canonical gate + live host execution contract | Node/SQLite | Driver callbacks | Route integration | Package test |
46
+ | UI projection | Persisted tool call mounted | Accessible translated controls/outcome; reload terminal status | No verified pending state: disabled; HTTP failure alert | Authenticated browser/owned thread | HTTP transport; no browser decision authority | jsdom | Transport optional methods | Component | Package test |
47
+ | Default regressions | Ordinary read/no driver | Existing suites remain green | Existing browser/loop failure gates | Existing fixtures | Existing transactions | Existing package runtimes | Existing SSE/driver contract | Regression | Full package test |
48
+
49
+ Reuse search evidence: MCP `review_smrt_project` on app-runtime and chat;
50
+ `build_context` architecture query for durable owner approvals/holds/cards; intent
51
+ index `Human approval steps`; name and purpose `rg` searches across smrt-ui,
52
+ smrt-svelte, chat, core, app-runtime, approvals and app-shell. Existing generic
53
+ `ApprovalService` and primitives were reused. ConfirmDialog is modal and cannot
54
+ represent a durable inline thread card; app-shell's ApprovalCard is tied to shell
55
+ object/action/draft types and shell styling, so the shared chat card composes the
56
+ existing primitives while shell remains untouched.
57
+
58
+ The integration rebase audit repeated MCP package-specialist context for
59
+ `approvals` and the architecture query for a reusable Svelte decision card,
60
+ then inspected package exports and all approval/decision/confirmation Svelte
61
+ sources. `smrt-approvals` exports the gate/ledger and no Svelte UI.
62
+ Projects' ApprovalActions/PreviewApprovalPanel require project workflow states
63
+ or preview identities; timesheets' queue requires time-entry rows; commerce's
64
+ PricingVersionDecision requires a pricing version; reports' ReportConfirmation
65
+ requires a report proposal and save operation. Those domain contracts cannot
66
+ represent a server-tool hold without fabricating domain data. Card/Button remain
67
+ the reusable UI layer for AssistantApprovalCard.
68
+
69
+ | New production file | Reuse search and result |
70
+ | --- | --- |
71
+ | `app-runtime/src/owner-approvals.ts` | MCP review/context + intent index; `rg` approval/hold/owner/decision in runtime, approvals, users, core and shell. Extends ApprovalService with tool execution envelopes; uses canonical owner-role membership APIs. No new approval model. |
72
+ | `chat/src/assistant-approvals.ts` | MCP review/context; `rg` approval/policy/destructive/wait in chat, runtime, shell and inference. Adapts the existing tool/driver callbacks to OwnerApprovalAuthority; no existing host-neutral durable tool adapter fit. |
73
+ | `chat/src/svelte/components/assistant/AssistantApprovalCard.svelte` | MCP review, architecture and approvals specialist context; `rg` by approval/decision/confirmation names and purpose across packages. Reuses smrt-ui Card/Button/i18n; domain widgets above do not accept tool holds. |
74
+
75
+ The browser-free `./assistant-approvals` entry exports `observeAssistantApproval`
76
+ for hosts that already execute approved actions. It observes the same authority
77
+ until completion, with abort/timeout cleanup, without consuming or executing.
78
+ `AssistantApprovalCard` optionally accepts a host-authorized `presentation` and
79
+ `detail` snippet for an existing decision endpoint and server-loaded view.
80
+ Tricia supplies its builder/draft preview through that snippet; the shared card
81
+ owns headings, status, controls and messages. The normal transport-verified card
82
+ keeps its existing behavior and polling.
83
+ ## Holds outside a thread
84
+
85
+ Pass `approvalContinuations` alongside the same `approvals` authority to
86
+ `mountAssistantRoutes`. The existing owner approvals list includes persisted
87
+ non-thread records and outcomes. Its same-origin decision route delegates only
88
+ records with a trusted continuation binding; ordinary thread holds retain their
89
+ existing thread/session checks. `AssistantApprovalCard` accepts no `threadId` for
90
+ this owner list, reusing the existing HTTP transport. No parallel approval route
91
+ or UI is added. The template host tests exercise the real decision route after
92
+ recreating the host and its authority, including an external MCP delete and a
93
+ native cookbook disable.
94
+
95
+ Authenticated thread message reads also project native continuation approvals
96
+ through the existing `AssistantApprovalCard` wire shape. The message and
97
+ approval-list routes share one owned-thread reader: tenant, requesting user,
98
+ trusted human profile and thread must all match, and the authority rechecks
99
+ live ownership. Missing/malformed principal bindings are excluded. A revoked
100
+ owner can still read their ordinary conversation, without native hold projections.
101
+ Synthetic message ids are `approval:<public approval id>`; timestamps come from
102
+ the canonical record. Persisted cards are deduplicated by approval id. Native
103
+ public views use that same public id for `callId` and omit arguments, recovery
104
+ context/keys and raw results; decisions still use the existing continuation rail.
105
+ Generic tool presentation uses a fixed safe caption unless the trusted async
106
+ `presentApproval(record)` callback derives a business preview from the canonical
107
+ hold. That caption appears in both the public summary and explicit presentation;
108
+ the generic card never promotes a raw stored/model summary. See
109
+ [turn presentation](turn-drivers.md) for private pass provenance and public paging.
110
+ Projection is enabled by either an explicit approval authority or configured
111
+ continuations using the default database-backed live-owner authority. Ordinary
112
+ chat without either option does not query the owner ledger.
113
+
114
+ The existing message route has no cursor: it loads at most 200 persisted messages.
115
+ Recent terminal native references share a 200-item historical bound with those
116
+ messages and are excluded when older than the persisted page. Unsettled native
117
+ holds remain visible even when older, then the merged response is chronological.
118
+ The underlying owner authority list remains unbounded; this projection does not
119
+ introduce a second store or claim storage pagination. Route recreation and thread
120
+ switches reconstruct the same ids and current canonical status without writes.
121
+
122
+ The existing route suite covers real SQLite native holds, malformed/foreign
123
+ user/profile/tenant/thread bindings, revoked owner access, persisted-card dedupe,
124
+ reload, safe succeeded/denied outcomes, and the 201-message boundary. Existing
125
+ built-in holds retain their correlation ids and authored transcript behavior.
126
+
127
+ D1 second-rebase compatibility: transport mode also works without `threadId`,
128
+ using the existing transport's owner-list endpoint. It still verifies persisted
129
+ state before enabling controls and reports failures. Presentation/detail mode
130
+ keeps precedence, exact legacy labels and no transport polling. The card's
131
+ parameterized DOM cases cover thread and owner-list success/refusal; restoring
132
+ the old thread-only render/poll guards makes both owner-list cases fail. The
133
+ unchanged app-shell suites exercise Tricia's presentation/detail and connection
134
+ contracts. No duplicate card or decision route is introduced.
135
+
136
+ Overlapping browser reads use the public browser-safe
137
+ `reconcileAssistantApprovalView(current, next)` beside the existing wire type.
138
+ Same-hold presentation advances pending → approved → executing → terminal; equal
139
+ or forward active views take current canonical data, while the first terminal
140
+ view is retained. Different hold ids never merge. AssistantApprovalCard, cookbook
141
+ client completion observation and Settings reuse this one policy so a delayed
142
+ pending poll cannot re-enable buttons after a newer decision. Verification and
143
+ execution authority remain server-owned. Tests release an actual deferred card
144
+ poll after approved/executing/terminal decision responses and preserve the
145
+ newer caption, status and disabled decision state.
146
+
147
+ ## Owner removal preference
148
+
149
+ `AssistantApprovalPolicy.allowRemovalsInChat` is trusted host input, resolved per authenticated turn, never from model arguments. Default is a hold. A true value waives only a canonical manifest `delete` with a nonempty single-record `id` and trusted host `annotations.recordDeletion: true`. The host may declare this only for an app-data record, never identity, credentials, roles, tenants, settings or installation objects. Names and model arguments cannot supply this classification; unclassified manifest tools, extra/custom tools, design-class tools, purge/drop/truncate/destroy and unknown destructive hints remain held. Canonical security/control package identities (including registered ancestry and replacement provenance) and declared `sensitive` models cannot receive the setting waiver even if incorrectly marked. The cookbook host marks only canonical deletes for its placed app-data lists. Other hosts must explicitly classify their data tools or retain the hold. Native cookbook tools retain their own authority and independent design-preview checks. The host must never pass the opt-out for an outside MCP/plugin/local-credential request. The normal dispatch and change-history paths still execute; the preference is not an approval decision. Tests cover forged tool flags, purge effects and the CLI host's chat/outside distinction.
150
+
151
+ In-flight removal settings: the MCP boundary honors both the current owner preference and the running turn's existing `requiresApproval` gate. Tightening can add a hold immediately; relaxing never waives a hold already bound to that request. This prevents an effect from running and then being rejected by result authoring. CLI host tests flip the preference just before MCP execution and still require the original owner decision exactly once.
152
+
153
+ Review regression evidence: before the fix, name-only security/custom deletions with the opt-out failed the negative test. Head tests cover explicit record metadata with destructive hints, missing/invalid ids, forged argument metadata, design metadata, security/unknown names and bulk/custom operations. Real SQLite built-in turns prove the opt-out deletes a declared business record and emits the existing principal audit event, while the default preserves the record and ledger hold; route tests preserve a hold for unclassified extra-tool deletion. The existing real CLI host cases cover both engines/modes, audited chat deletion, outside MCP holds and mid-turn policy tightening/relaxing.
154
+
155
+ | Review behavior/invariant | Reachable trigger and positive case | Negative/failure case | Actor/context | Executor/transaction; runtime | External edge and level | Validation |
156
+ | --- | --- | --- | --- | --- | --- | --- |
157
+ | Structural approval floor | Call removeField/removeList/undo/recipe disable on either surface or durable Apply; native pending hold | Four setting combinations and permissive host policy cannot mutate or append history | Existing live owner, tenant-bound native context; existing suites retain non-owner/foreign-tenant refusal | Existing editor/approval executor and journal; SQLite (same regression file supports optional PGlite) | MCP/assistant/native Apply; integration | core full test |
158
+ | Record-only waiver | Opted-out owner deletes one explicitly classified business record | Default on, unknown/security/control/sensitive/derived model, design metadata, invalid id, bulk/custom tool or forged classification stays held | Original in-app principal; trusted tool metadata, never model args | Existing principal dispatch and audit sink; real SQLite | Built-in turn + canonical policy; integration/unit | chat full test |
159
+ | CLI/outside parity | Existing real host fixture deletes app record and records change feed with opt-out | Outside MCP and policy change while a turn runs still hold and execute once after decision | Same live owner/grant ceiling; protected/native engine states | Existing host MCP, scoped token, approval continuation and SQLite | Both stub CLI engines; host integration | template-sveltekit full test |
160
+
161
+ Token exposure documentation was verified against command construction, credentials, the host's offered/scoped binding and the local-token verifier. No live CLI/provider call or credential read was needed for this review.
@@ -0,0 +1,28 @@
1
+ # Runtime cookbook exposure
2
+
3
+ See [the owning core contract](../../core/agents/runtime-exposure.md) for the
4
+ opt-in gate, trusted tenant selection, failure behavior, notification lifecycle
5
+ and AOT/startup limits. This package reuses that gate in its existing dispatcher;
6
+ it does not implement a second cookbook engine or operation execution path.
7
+
8
+ The manifest tool loop filters the offered catalog under `principal.tenantId`
9
+ and checks again before executing either the normal dispatcher or an injected
10
+ executor. `invokeManifestTool` independently rechecks using the principal run's
11
+ tenant. The AOT permission catalog remains intact for typo validation. External
12
+ drivers and CLI adapters reuse the same manifest identity check on
13
+ initial offerings, live tool callbacks and approval acceptance. Their MCP host
14
+ must independently gate execution under the original principal: callbacks can
15
+ arrive after an effect. Extra tools and browser tools remain host integrations
16
+ and must use core's gate when they expose model operations.
17
+
18
+ Durably held manifest calls re-enter the same dispatcher on owner approval; a
19
+ model disabled in the meantime (or an unreadable enabled set) refuses execution.
20
+ The existing ledger records terminal `failed` with `result.status: 'refused'`,
21
+ and the transcript records `status: 'refused'`. It cannot be retried by approving
22
+ again. Approval lists keep their original saved public projection, without
23
+ arguments, recovery context, results or current model metadata. The SQLite
24
+ mounted-route regression covers both disabling and store-read failure.
25
+
26
+ If a chat-owned external approval has already been consumed when exposure closes,
27
+ the bridge records terminal `failed` / `result.status: 'refused'` before returning
28
+ a denied decision. A host-owned CLI observer never mutates that host's ledger.
@@ -0,0 +1,26 @@
1
+ # Runtime report tools (#3711)
2
+
3
+ Moved from `packages/chat/AGENTS.md` to keep the instruction chain under the 32 KB cap.
4
+
5
+ `createRuntimeReportTools()` (`runtime-report-tools.ts`) returns four
6
+ `PrincipalTool`s for the persona `extraTools` seam: `reports.runtime.sources`,
7
+ `reports.runtime.define` (`preview` / `apply`), `reports.runtime.list`, and
8
+ `reports.runtime.run`. The model supplies only a declarative
9
+ `RuntimeReportSpec` from `@happyvertical/smrt-reports`; sources are a
10
+ server-owned allow-list gated by `run.assertOperation(collection, 'read')`, and
11
+ field policy, `readPermission`, and tenancy are enforced by the compiler against
12
+ the live run on every compile and every stored-report run. `apply` needs the
13
+ `specHash` of the previewed spec plus an app-owned `confirmation` host that
14
+ resolves only after a human approved that exact spec; with no host apply returns an `awaiting_confirmation` proposal for the
15
+ same-origin browser confirm route and stores nothing and a model-supplied `confirmed` flag is ignored. Saving also needs
16
+ `create` on the `RuntimeReport` collection, and `list`/`run` need `read`; the
17
+ default `reportsCollection` is the `RuntimeReport` class itself, which resolves
18
+ to the catalog slug. A string `collection`/`reportsCollection` is used verbatim
19
+ as a catalog slug (never a class name); tests must run the tools under the real
20
+ `assertOperationPermission` guard so a wrong slug fails. A stored report is
21
+ written only by this confirmed `apply`: the model layer refuses every other
22
+ insert/spec change, and the generic manifest tools (`buildManifestToolCatalog`,
23
+ `invokeManifestTool`) never offer or run a `RuntimeReport` write. Stored-report
24
+ reads/saves run under the principal's tenant (`withPrincipalTenant`), refuse a
25
+ mismatching ambient tenant (checked before `confirmSave`), and filter by the principal tenant explicitly. Contract and authority model:
26
+ [`packages/reports/agents/runtime-reports.md`](../../reports/agents/runtime-reports.md).
@@ -11,3 +11,9 @@ Reference linked from [../AGENTS.md](../AGENTS.md). This contract was moved from
11
11
  - **`SmrtChatBackend` (`@happyvertical/smrt-chat/client`)** — the consume side of the same contract: a browser SSE client (`src/client.ts`) that POSTs the conversation and dispatches `token`/`emotion`/`done`/`error` frames to streaming handlers, tolerating heartbeat comments and frames split across chunks. The subpath is BROWSER-SAFE and dependency-free (no server runtime, no workspace imports — keep it that way), and its widget-facing types are structurally identical to `@happyvertical/animation`'s `ChatBackend` contract so an instance plugs straight into the floating chat widget. `src/client.contract.ts` carries the compile-time locks pinning it to `chat-stream.ts`'s `ChatStreamEvent`/`ChatStreamSession` — a NON-test module precisely so `pnpm typecheck` actually enforces them (`tsconfig.typecheck.json` excludes `.test.ts` files, and Vitest transpiles without typechecking). A clean close without a `done` frame surfaces as an error (never an empty reply), and a settled turn cancels the reader so the connection is released promptly.
12
12
  - **Persona path reuses the harness's own gates unchanged** — persona principal, fail-closed `allowedTools` offer+execution gates, tenant binding. `onToken` is best-effort telemetry threaded through `runToolLoop`; it never changes what the loop persists or authorizes.
13
13
  - **Custom tools stream via `binding.extraTools`** — the persona binding threads an optional `extraTools?: PrincipalTool[]` down to `runPersonaConversationTurn`, so a *streamed* persona chat can offer non-manifest, service-backed tools (the persona messaging tool `messages.send`, or an assistance-request/lead-ticket tool wrapping a `@smrt({ api:false, mcp:false })` service) and thus *act*, not only answer — matching the non-streaming persona path. It is resolved server-side by `authorize` (trusted), never from request input, and stays fully gated: each tool is filtered by the persona's `allowedTools` (offer gate) and re-asserts the bound principal's authority in `execute` (execution gate). Offering a tool is not authorizing it.
14
+
15
+ The PostgreSQL post-handler transaction regression expects all persisted public
16
+ turn rows: user, tool result, assistant reply. It checks the tool call identity,
17
+ success state, reply linkage and tenant alongside the reply and idempotent retry.
18
+ Ordinary tool results remain visible in conversation history; only trusted
19
+ internal-turn provenance is filtered out.
@@ -287,3 +287,16 @@ carries the error's message, its stable `code` when it has one (e.g.
287
287
  `DATA_SURFACE_QUERY_FAILED`), and the fixed `TOOL_EXECUTION_ERROR_HINT`:
288
288
  the failure is the server's, so the model should not resend the same call
289
289
  but answer with what it has or tell the user (#4378).
290
+
291
+ A trusted host may set `ManifestTool.functionName` to its app-facing vocabulary.
292
+ `manifestToolToAITool` and the loop use that provider-safe alias for discovery,
293
+ call resolution and browser-tool collision protection. The canonical `slug`
294
+ continues to govern permissions, approval envelopes, transcripts and dispatch;
295
+ an alias grants no operation. The real SQLite alias test retains the negative
296
+ allow-list control and the canonical invocation record.
297
+
298
+ Manifest read operations request the collection's existing displayLabel projection
299
+ for point and list reads, matching REST's inline contact/display contract. This
300
+ uses the original principal and ordinary public JSON filtering; it does not load
301
+ identity lists as extra tools. The host regression creates a typed contact, then
302
+ checks name/email/phone in actual item and list tool observations.
@@ -0,0 +1,155 @@
1
+ # Tool summaries and engine adapters
2
+
3
+ `describeAssistantTool` / `toolSummary` own human tool words moved from shell.
4
+ The existing `describeTool(name, args?, outcome?)` seam now receives completed
5
+ `{ ok, observation }` results. Existing two-argument host callbacks still work.
6
+ Both built-in and external turns use it for result step labels and the default
7
+ persisted tool message (`toolCallData.label` too). Successful built-in results
8
+ are now authored by default; `authorInvocation` can still replace or suppress
9
+ them. Failure diagnostics and their collapse policy remain intact. The dock
10
+ renders existing labels/content; no new event type or rendering stack exists.
11
+ Only a short name/title, bounded list count or safe explicit summary enters a
12
+ label. Raw payloads, JSON, machine paths, SQL and credential-shaped text never
13
+ belong in a chip. Arguments are not used as record names. Unknown offered tools
14
+ get generic words; unoffered calls retain the existing unknown-tool gate.
15
+
16
+ `@happyvertical/smrt-chat/engines` is Node-only. Chat → inference is acyclic
17
+ (`pnpm check:package-dag`). `createChatGPTAssistantAI(options)` wraps inference's
18
+ `createChatGPTModel` as the SDK `chat` subset accepted by the loop. Tools/raw
19
+ provider calls, signal, text and total usage survive; inference sends only
20
+ `chat` + `onProgress`, with no sampling/token/reasoning/stream options or key
21
+ fallback. `createInferenceAssistantAdapters({ binding, status, cli, chatgpt,
22
+ api? })` returns `{ resolveTurnDriver, ai }` for `mountAssistantRoutes`. The host
23
+ reads the authenticated user's stored binding, never `requestContext`. Selection
24
+ and status are cached only for that Request; missing binding selects the existing
25
+ configured API factory. An unavailable/invalid selected engine refuses before
26
+ writing and never falls back to another billing path.
27
+
28
+ `createAgentCliTurnDriver({ tool, bind })` adapts `runAgentTurn`. `bind(context)`
29
+ returns the host's MCP endpoint, token mint/revoke, private state directory,
30
+ lookup dependencies, exact tool policy and owner/turn-filtered approval observer.
31
+ The MCP endpoint MUST enforce the original principal, tenant, permission ceiling,
32
+ allow-list and durable approval policy on execution: stream inspection happens
33
+ later and cannot authorize an effect. Inference retains loopback restrictions,
34
+ key stripping, private empty working directory, built-in-tool lockdown and process
35
+ and credential cleanup. Chat authors text/tool rows exactly once. Each CLI turn
36
+ starts fresh with chat history as untrusted context; no credential or CLI session
37
+ store is added. Full arguments come from inference's append callback rather than
38
+ its intentionally clipped display event. Summaries are computed before result
39
+ clipping and passed through the existing describe result argument; the CLI owns
40
+ the raw model observation. Optional `canonicalToolName` maps MCP wire aliases to
41
+ chat's offered slugs, while `allowTool` still gates the MCP wire name. A mapper
42
+ returning undefined denies; aliases never broaden the offered set.
43
+
44
+ The driver's optional `waitForApproval` uses the existing trusted host-waiter
45
+ contract: it OBSERVES the MCP host's existing durable hold, never creates another
46
+ ledger, decides, consumes or executes it. Mounting uses that waiter unless an
47
+ explicit chat approval bridge is configured; do not combine two authorities.
48
+ A pending result is never authored as a successful effect. The driver awaits the
49
+ owner's decision, then asks for a new turn; it cannot automatically restart the
50
+ exited CLI process. Abort releases observation, removes listeners and never grants
51
+ approval. The host must expose its authenticated decision/status endpoint to the
52
+ existing approval card (or supply its own existing card through the dock slot).
53
+
54
+ ## Validation design
55
+
56
+ All tests use Node/SQLite, fake models and inference's stub CLI. No provider,
57
+ container or real login is required. No new database schema, SQL executor,
58
+ transaction or dialect behavior is introduced.
59
+
60
+ | Behavior/invariant | Trigger | Positive | Failure | Actor/context | Executor/transaction | Runtime/dialect | Edge | Level | Command |
61
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
62
+ | Summary parity | Built-in/external CRUD/list/unknown | Same step and persisted label | Payload/path/SQL/secret omitted; existing offer gates | Authenticated owned thread | Existing ChatService turn lifetime | Node/SQLite | Model/driver callbacks → existing SSE | Route integration/unit | chat test |
63
+ | CLI adapter | Stub text/tool/hold | Ordered persisted callbacks, full args, shared labels | Abort, failure, unoffered tool; no held success | Bound principal and host owner observer | Existing chat author; MCP host executes | Node/SQLite; subprocess OS | Inference runAgentTurn + token lifetime | Integration | chat test |
64
+ | ChatGPT factory | Fake plan model | Raw calls, progress, usage and signal | No unsupported options or API fallback | Per-request connection | No database writes | Node | Inference createChatGPTModel | Unit | chat test |
65
+ | Per-user selection | Stored binding/status | Each user gets their selected engine | Missing/unknown/unready refused, no fallback | Authenticated Request | Refusal before ChatService writes | Node | Existing resolver hooks | Unit/route regressions | chat test |
66
+
67
+ ## Rebase interaction validation
68
+
69
+ | Behavior | Positive | Negative | Principal / executor | Boundary / check |
70
+ | --- | --- | --- | --- | --- |
71
+ | External manifest exposure | Enabled tools retain shared summaries | Disabled/unreadable models absent; a live closure refuses callbacks and approval acceptance | Original authenticated tenant; MCP endpoint remains effect authority | Driver bridge and real CLI stubs; chat suite |
72
+ | Saved owner approval | One execution after restart authors the shared outcome label | Refused/denied holds keep diagnostics and cannot replay | Captured principal/permission ceiling; existing durable authority and dispatcher | SQLite mounted routes; chat suite |
73
+ | App replacement and STI | Canonical provider identity gates the effective app class; explicit create subtype survives summary generation | Closed gate prevents dispatch | Original tenant; registry collection dispatcher | Tool-loop integration; chat suite |
74
+
75
+ Connect AI has no record/reference-picker dependency. It configures inference
76
+ before model offerings exist; reference picker source and screen composition are
77
+ unchanged. No artificial picker adapter is introduced.
78
+
79
+ ## Reuse check
80
+
81
+ Configured MCP `review_smrt_project` reviewed chat and smrt-svelte; `build_context`
82
+ architecture query searched tool descriptions, engine adapters and connection
83
+ composition. The server exposes architecture/model listings but no standalone
84
+ component/intent/recipe search. Read the intent index and used `rg` name AND purpose
85
+ searches over smrt-ui, smrt-svelte, chat, core, inference and app-shell for
86
+ `toolSummary`, `summary`, `describeTool`, `ConnectAi`, `connect AI`, sign-in,
87
+ `runAgentTurn`, model factories, approvals, recipes and onboarding/settings.
88
+
89
+ New `src/tool-summary.ts` extends existing describe/label events, moving shell's
90
+ summary purpose to chat; reuses ToolInvocation's result shape. New `src/engines.ts`
91
+ reuses inference's engines, types and fake CLI fixtures, existing turn callbacks,
92
+ ChatService, route resolver/factory and trusted approval waiter. No new model,
93
+ route or tool is registered. Its internal serialization queue only adapts the
94
+ synchronous inference emitter to awaited chat callbacks. New tests extend the
95
+ existing SQLite route fixtures, with isolated engine fakes in engines.test.ts.
96
+ No equivalent shared adapter or summary generator existed in the owning packages.
97
+
98
+ Rebase reuse search: MCP `review_smrt_project` on chat/smrt-svelte and `rg`
99
+ `isManifestToolEnabled|isToolEnabled` plus exposure purpose searches in core,
100
+ chat, smrt-ui and smrt-svelte found core's `isRuntimeModelEnabled` and the four
101
+ existing chat dispatcher checks. `isManifestToolEnabled` consolidates those
102
+ checks in their existing owning module; external drivers reuse it. No new file.
103
+
104
+ Manifest create offerings and execution
105
+ now use core's public `ObjectRegistry.getCreateTargets` / `resolveCreateTarget`
106
+ API ([contract](../../core/agents/generators.md#public-collection-create-targets-a1b)).
107
+ `createType` is an optional qualified create target; `_meta_type` is a compatible alias.
108
+ The model's `type` field remains business data, including on STI families.
109
+ Selection occurs before filtering and uses the selected model's writable policy;
110
+ selectors are not persisted fields. Offerings and execution both use the original
111
+ principal's live runtime exposure context. The Profile/Bot assistant canary and
112
+ `src/create-targets.test.ts` cover all four dispatch paths, replacement, labels,
113
+ readonly fields, malformed/foreign choices and gated children on SQLite.
114
+
115
+ `./tool-summary` is a browser-safe entry. The optional fourth `toolSummary`
116
+ argument supports `recordLabels: 'generic'` and `plainTextSummary: true` for
117
+ saved-product wording/replay. All safety guards remain shared; default labels
118
+ are unchanged. Tricia is a thin policy adapter over these options.
119
+
120
+ ## Live-engine failures (R7/R8)
121
+
122
+ ### Next live round: behavior contract
123
+
124
+ | Behavior / trigger | Positive | Refusal/control | Actor, executor and runtime | Evidence |
125
+ | --- | --- | --- | --- | --- |
126
+ | CLI offerings | Named Customer create exposes inline contact fields and recipe vocabulary | Dependency-only identities and API-only deletes absent; revoked/gated offers cannot resume | Captured user/tenant, original ceiling; existing MCP dispatcher; Node/SQLite | Real host + inference stub, then bounded built-app Claude turn |
127
+ | Held CLI delete | Existing continuation binds thread, original arguments and principal; owner decides once | Repeated decision, revoked offer/permission, foreign owner/tenant and abort cannot replay | Existing OwnerApprovalContinuations/authority CAS, existing collection executor; Node/SQLite | Host route fixture + live exposed-list delete |
128
+ | Capability words | Introduction and model guidance follow selected engine's offered operations | No blanket deletion claim when any named list omits it | Authenticated host; no effect executor | Host introduction and built browser |
129
+ | Startup readiness | Only an explicit successful preflight is ready | Missing/false preflight, signed out, absent CLI and unsupported tool host refuse | CLI's own status, sanitized environment; no model request | Inference/Connect tests + built app |
130
+ | Active stop | Abort while a real app tool is in flight leaves no CLI child and a stopped thread | Never report a pending hold or an interrupted effect as completed | Existing child tree cleanup and ChatService turn state | Stub abort + bounded live read/tool turn |
131
+
132
+ Reuse: repeated MCP `review_smrt_project` on chat, inference, runtime, Svelte and
133
+ template; `build_context` searched turn-bound continuations, hidden prerequisite
134
+ offerings and recipe labels. Intent index and name/purpose `rg` searches across
135
+ UI/Svelte/chat/core/runtime found OwnerApprovalContinuations, buildCookbookShell,
136
+ the existing describe callback and live MCP identity map. Extend those paths;
137
+ no new approval store, dispatcher, model, route or component is introduced.
138
+
139
+ Engine binding and unexpected driver failures use inference's safe correlated
140
+ server diagnostic before replacing exceptions with fixed user words and a
141
+ reference. External failures preserve real partial output but do not persist a
142
+ second generic error bubble. The existing pending-send entry owns the transport
143
+ error and retry. AssistantDock suppresses only the matching duplicate banner and
144
+ tells AssistantComposer to restore the draft without a second send alert;
145
+ standalone composers retain their default alert and other dock errors stay visible.
146
+ The same status line also renders the controller's existing idle `Stopped`
147
+ label after cancellation; it does not duplicate transport errors or invent a
148
+ completed reply for an interrupted turn. A mounted active-tool cancellation
149
+ test verifies the stopped line, aborted signal, no retry and no error alert.
150
+ Tests drive the mounted dock, preserve draft/retry/a11y, and launch both inference
151
+ stub engines under the exact desktop `buildSidecarEnv` composition. No desktop
152
+ production environment policy changed. Reuse the desktop environment helper via
153
+ a test-only import; no duplicate environment builder is introduced.
154
+
155
+ S1: canonical dotted `app.describe`, `app.history`, `recipes.search` and `recipes.describe` names use the existing person-facing summary table, including durable design steps. Unknown tool payloads remain hidden. ChatGPT failures pass their cause to inference's existing correlated failure reporter; only allow-listed codes and bounded `req_` or UUID request ids are logged, never exception messages or accounts.