osuite 2.11.2 → 2.13.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.
@@ -0,0 +1,652 @@
1
+ # Matoi Controlled Transfers
2
+
3
+ **Available starting in `osuite@2.12.0`.** This additive entry is not present in
4
+ `osuite@2.11.2`. Confirm the chosen registry version with
5
+ `npm view osuite@2.12.0 version`. Version 2.12.0 was released with the server profile disabled by default;
6
+ SDK publication does not enroll a workspace or qualify a customer deployment.
7
+ A matching server, explicit operator setup and deployment acceptance are still
8
+ required before customer rollout.
9
+
10
+ The additive ESM entry `osuite/controlled-transfers` speaks the
11
+ `matoi.controlled-transfer.v1` semantic profile to the resource-owned **controlled ledger**.
12
+ Its default full lease remains v1; the SDK also reads explicitly requested
13
+ compact `matoi.controlled-transfer.lease.v2` leases, as described below.
14
+ It requires **Node 24**. The ordinary SDK exports, Hook, runtime requirements,
15
+ installation settings and signing transport are unchanged.
16
+
17
+ Installing this package does **not** establish full-stack deployment protection.
18
+ The profile must be enabled and configured on the server, with actual native
19
+ Studio review and a resource-enforcing owner. This entry is not an external bank,
20
+ blockchain, arbitrary tool wrapper or local transfer callback. Deployment
21
+ qualification requires separate acceptance evidence; `not-qualified` and
22
+ `integrated-tested` are not `deployment-qualified`.
23
+
24
+ ## Resource Operator Setup
25
+
26
+ This is explicit operator configuration, not an automatic SDK installation
27
+ step. Use a test deployment and synthetic balances until deployment qualification
28
+ is complete. Initial ledger balances do not represent an actual bank deposit.
29
+
30
+ 1. Install the matching Studio server with its normal schema, authentication,
31
+ workspace membership, SDK/MCP enrollment and approval configuration. Use
32
+ `DASHCLAW_DB_DRIVER=postgres` and a writable interactive PostgreSQL connection.
33
+ The mock driver and Neon HTTP-only query adapter cannot provide this profile's
34
+ transaction boundary.
35
+ 2. Provision `OSUITE_MATOI_TRANSFER_ENABLED=true`, an explicit JSON array of
36
+ activated workspace IDs in `OSUITE_MATOI_TRANSFER_WORKSPACES`, and
37
+ `OSUITE_MATOI_ISSUER_PRIVATE_KEY_B64` (base64-encoded Ed25519 PKCS8 PEM) through
38
+ the server's secret management. Keep both the issuer private key and database
39
+ credentials away from agent hosts. Distribute the corresponding public key
40
+ through a trusted channel for client pinning. Missing, malformed, empty or
41
+ nonmatching workspace scope never enables new execution. Removing a workspace
42
+ from the scope leaves authenticated historical reads and administrator
43
+ revocation available; it does not erase receipts or grant a safe retry.
44
+ 3. From a current workspace owner/admin session, POST configuration to
45
+ `/api/matoi/transfers/configuration`. This endpoint does not accept an agent
46
+ API key as administrative approval. It validates membership and records the
47
+ mutation with its audit event. Browser requests must be same-origin.
48
+ 4. Initialize storage, provision source/destination accounts, then register a
49
+ finite grant for the actual enrolled agent/key. Initialization creates six
50
+ profile tables and authority-serialization triggers on existing Studio tables;
51
+ rehearse this migration and required database privileges before production.
52
+ Missing/disabled triggers or incomplete setup leave capability unavailable.
53
+ 5. Run the explicit doctor probe, prepare one allowed operation, complete its
54
+ real Studio review, execute and verify its receipt, then test rejection and
55
+ recovery. Doctor success reports configuration, not deployment certification.
56
+
57
+ **Fresh self-host operator prerequisite:** a successful local-password dashboard
58
+ login or SDK/MCP enrollment does not itself create a current workspace
59
+ owner/admin membership. Configuration can therefore return
60
+ `403 HUMAN_ADMINISTRATOR_REQUIRED` after those earlier steps succeed. The
61
+ current workspace bootstrap/creation APIs are SaaS-only; the fresh self-host
62
+ first-owner path still needs a documented and qualified provisioning procedure.
63
+ Do not bypass the check, insert an invented reviewer, or mistake a token's admin
64
+ label for membership. Keep the profile disabled until an eligible operator and
65
+ the complete resource-side workflow have been verified. This does not prevent
66
+ ordinary SDK/MCP connection setup, but it prevents claiming this profile is
67
+ turnkey on the local-password-only installation path.
68
+
69
+ Configuration requests have the following exact fields. Tenant and administrator
70
+ identity come from the authenticated session, never these JSON bodies.
71
+
72
+ | `kind` | Additional body fields | Purpose |
73
+ | --- | --- | --- |
74
+ | `initialize` | None | Create the profile's schema and workspace authority |
75
+ | `account` | `accountId`, `asset`, `network`, `decimals`, `balanceMinor`, `debitLimitMinor` | Provision a controlled account with exact integer-string amounts |
76
+ | `grant` | `agent_id`, `keyId`, `grantId`, `workflow`, `state`, `allowedEffects`, `budgetMinor`, `expiresAt` | Bind the enrolled principal, finite workflow, exact coupled effects, total budget and expiry |
77
+ | `authority` | `grantId`, `active`, and optionally `allowedEffects`, `budgetMinor` | Revoke/reactivate or update current authority without widening the original boundary |
78
+ | `state` | `grantId`, `state` | Update owner-controlled workflow state; relevant changes require reassessment |
79
+
80
+ Expiry is an integer Unix time in milliseconds, at most 24 hours ahead; prepared
81
+ leases last at most five minutes and cannot outlive the grant. An operator must
82
+ source each allowed `paymentId` from its business records, not let the agent mint
83
+ new authorized payments. A deployment must also prevent direct access to the
84
+ underlying ledger; this configuration API alone does not prove route coverage.
85
+
86
+ ### Single-Transfer Operator Example
87
+
88
+ After completing the prerequisites above, use a fresh, owned test ledger for
89
+ this example. From a current owner/admin session, send these **three separate POST requests**
90
+ in order to `/api/matoi/transfers/configuration`, each with
91
+ `Content-Type: application/json`. Keep browser requests same-origin; do not use
92
+ an agent API key or put workspace/administrator identity in the request body.
93
+
94
+ First initialize storage:
95
+
96
+ <!-- controlled-transfer-initialize:start -->
97
+ ```json
98
+ {"kind":"initialize"}
99
+ ```
100
+ <!-- controlled-transfer-initialize:end -->
101
+
102
+ Then provision the source account with 250 synthetic minor units:
103
+
104
+ <!-- controlled-transfer-source-account:start -->
105
+ ```json
106
+ {
107
+ "kind": "account", "accountId": "treasury",
108
+ "asset": "USD", "network": "internal-ledger", "decimals": 2,
109
+ "balanceMinor": "250", "debitLimitMinor": "250"
110
+ }
111
+ ```
112
+ <!-- controlled-transfer-source-account:end -->
113
+
114
+ Provision the distinct destination account; its zero debit limit permits receipt,
115
+ not spending:
116
+
117
+ <!-- controlled-transfer-destination-account:start -->
118
+ ```json
119
+ {
120
+ "kind": "account", "accountId": "vendor-a",
121
+ "asset": "USD", "network": "internal-ledger", "decimals": 2,
122
+ "balanceMinor": "0", "debitLimitMinor": "0"
123
+ }
124
+ ```
125
+ <!-- controlled-transfer-destination-account:end -->
126
+
127
+ These create new accounts; they are not account resets or top-ups. Do not repeat
128
+ provisioning to restore spent capacity. Do not retry configuration POSTs automatically;
129
+ after a timeout or unclear response, stop and have the operator verify existing
130
+ configuration and audit history before deciding what to do next.
131
+
132
+ The following JSON is the finite `plan`, not a complete configuration request.
133
+ It needs only one `transfer` node and empty `state`; each operand uses `literal`.
134
+ `allowedEffects` repeats the exact resolved effect with `operation: "transfer"`
135
+ instead of the workflow's `op`. Amounts and budgets are integer strings; decimals
136
+ is an integer. Use an owner-authorized payment ID and change both occurrences
137
+ consistently. Both accounts must match the effect's asset, network and decimals.
138
+
139
+ <!-- controlled-transfer-plan:start -->
140
+ ```json
141
+ {
142
+ "workflow": {
143
+ "version": 1,
144
+ "body": {
145
+ "op": "transfer",
146
+ "paymentId": { "literal": "payment-42" },
147
+ "sourceAccount": { "literal": "treasury" },
148
+ "destination": { "literal": "vendor-a" },
149
+ "asset": { "literal": "USD" },
150
+ "network": { "literal": "internal-ledger" },
151
+ "amountMinor": { "literal": "250" },
152
+ "decimals": { "literal": 2 }
153
+ }
154
+ },
155
+ "state": {},
156
+ "allowedEffects": [{
157
+ "operation": "transfer", "paymentId": "payment-42",
158
+ "sourceAccount": "treasury", "destination": "vendor-a",
159
+ "asset": "USD", "network": "internal-ledger",
160
+ "amountMinor": "250", "decimals": 2
161
+ }],
162
+ "budgetMinor": "250"
163
+ }
164
+ ```
165
+ <!-- controlled-transfer-plan:end -->
166
+
167
+ Parse that JSON as `plan` in your operator script. Set `enrolledAgentId` and
168
+ `enrolledKeyId` to the actual current SDK/MCP enrollment's agent ID and active
169
+ key ID, not invented labels or the raw API-key secret. Construct the grant just
170
+ before sending so `expiresAt` is a fresh numeric Unix-millisecond timestamp,
171
+ strictly in the future and no more than 24 hours ahead of the server clock:
172
+
173
+ ```js
174
+ const grant = {
175
+ ...plan,
176
+ kind: 'grant',
177
+ agent_id: enrolledAgentId,
178
+ keyId: enrolledKeyId,
179
+ grantId: 'owner-grant-42',
180
+ expiresAt: Date.now() + 10 * 60 * 1000,
181
+ };
182
+ ```
183
+
184
+ Send `JSON.stringify(grant)` as one further POST body to the same configuration
185
+ route through the authenticated administrator flow. Registration neither enrolls
186
+ the agent nor approves or executes a payment. Next use the SDK configuration and
187
+ `prepare('invoice-batch-42', 'owner-grant-42')` example below, retain its original
188
+ operation ID/preparation, complete the **real native Studio review** with the
189
+ required eligible people, and only then deliberately request ordinal 0 execution.
190
+ A pending review is not authorization. A lost execution acknowledgement requires
191
+ `status`-only recovery, not an automatic resend or a new operation/payment ID.
192
+
193
+ One independently confirmed commit changes these fresh balances to treasury `0`
194
+ and vendor-a `250`, with grant spend `250` and one payment receipt. Verify the
195
+ exact effect/receipt and resource state; approval or a derived view alone is not
196
+ completion. This recipe does not complete product qualification, establish
197
+ customer onboarding success, or cover a bank, blockchain or another resource.
198
+
199
+ ## Configuration
200
+
201
+ ```js
202
+ import { createControlledTransfers } from 'osuite/controlled-transfers';
203
+
204
+ const transfers = createControlledTransfers({
205
+ config: {
206
+ baseUrl: process.env.OSUITE_BASE_URL,
207
+ apiKey: process.env.OSUITE_API_KEY,
208
+ privateKeyBase64: process.env.OSUITE_PRIVATE_KEY_BASE64,
209
+ orgId: process.env.OSUITE_ORG_ID,
210
+ agentId: process.env.OSUITE_AGENT_ID,
211
+ signatureMode: 'required',
212
+ guardFailureMode: 'block',
213
+ // Optional: pin the server's Ed25519 public key as SPKI PEM.
214
+ // issuerPublicKey: trustedIssuerPublicKey,
215
+ // Optional: explicit historical Ed25519 public roots, never private keys.
216
+ // trustedIssuerPublicKeys: [previousIssuerPublicKey],
217
+ // Optional: assert the authenticated credential's exact key ID.
218
+ // keyId: credentialKeyId,
219
+ timeoutMs: 2500,
220
+ },
221
+ });
222
+ ```
223
+
224
+ `baseUrl` uses the existing runtime configuration spelling. HTTPS or HTTP on
225
+ `localhost`, `127.0.0.1` or `[::1]` is required. Credentials in URLs, queries,
226
+ fragments, non-loopback HTTP, missing tenant/agent identity, missing or non-RSA
227
+ private keys, optional signing and fail-open modes are rejected before network
228
+ I/O. `allowInsecureHttp` cannot weaken this profile. `timeoutMs` is an integer
229
+ from 1 to 30000. There is no fetch override, raw execute callback, automatic
230
+ approval, timer-driven polling or mutation retry option.
231
+
232
+ The RSA PEM is base64 encoded for `privateKeyBase64`, as in the existing SDK.
233
+ All requests authenticate with `x-api-key`. POST requests use the unchanged
234
+ `runtime/protocol.mjs` client to attach an RSA `_signature` over canonical JSON.
235
+
236
+ For key rotation, provision up to eight previous Ed25519 SPKI public keys as the
237
+ server's `OSUITE_MATOI_TRUSTED_ISSUER_PUBLIC_KEYS_B64` (base64 of a JSON array of
238
+ PEM strings) and the client's `trustedIssuerPublicKeys`. The strict CLI accepts
239
+ the same environment field in its one selected credential bundle. Historical
240
+ keys verify original preparations and receipts during status recovery; fresh
241
+ prepare/execute authority still requires the current issuer. No key embedded in
242
+ a response is automatically accepted as a historical root. An existing client
243
+ pinned to the retired key must be reconfigured explicitly. Unknown or conflicting
244
+ history stays unknown and does not authorize a resend.
245
+
246
+ Historical signature verification alone does not fence an old writer or detect a
247
+ database rewind. Rotation/restore activation must also follow the tested resource
248
+ owner fencing and recovery procedure, preserving authoritative payment history.
249
+
250
+ `CONTROLLED_TRANSFER_MAX_ENVELOPE_BYTES`, exported by `osuite/controlled-transfers`,
251
+ is 1,048,576 (1 MiB). Only this profile's HTTP client, including the doctor probe,
252
+ overrides the existing transport's response limit. Ordinary SDK/Hook limits are
253
+ unchanged. Defensive snapshots allow at most 65,536 nodes, depth 24, and 1 MiB of
254
+ canonical JSON, covering a 64-effect status with its signed original preparation,
255
+ per-effect native passes and receipts. Over-limit responses remain unavailable or
256
+ `OUTCOME_UNKNOWN`, never proof of non-execution or permission to resend.
257
+
258
+ ## Workflow
259
+
260
+ ```js
261
+ const capability = await transfers.capabilities();
262
+ console.log(capability.qualification.status); // A server report, not an SDK guarantee.
263
+
264
+ // Retain the operation ID and preparation in your application's durable store.
265
+ const prepared = await transfers.prepare('invoice-batch-42', 'owner-grant-42');
266
+ console.log(prepared.state, prepared.actionId, prepared.reviewUrl);
267
+ ```
268
+
269
+ `capabilities()` performs one authenticated GET. It validates the profile,
270
+ scope and capability schema, but may report `configured: false` and
271
+ `issuerPublicKey: null`. Every new prepare or execute send requires a fresh
272
+ capability response with `installed`, `configured` and `resourceEnforced` true,
273
+ scope `controlled-ledger`, and a usable Ed25519 issuer key. Qualification remains
274
+ an independent server report, not a boolean inferred from installation.
275
+
276
+ `prepare(operationId, grantId)` performs at most one prepare POST per operation
277
+ in this client instance. It returns an immutable, verified preparation and the
278
+ existing Studio `actionId` and `reviewUrl`, with `retryAutomatically: false`.
279
+ `awaiting_approval` is **not** authorization. If the server is still `preparing`
280
+ with no action bound, the review URL is null; do not invent a review or resend
281
+ to create another one. Repeated/concurrent calls reuse the same preparation.
282
+ Changing the grant under an existing operation ID is a conflict. A native-policy
283
+ `denied` preparation remains a refusal and cannot be executed by this client.
284
+
285
+ ### Optional Compact Leases
286
+
287
+ Use only a newly qualified SDK/server pair supporting this option. Older JavaScript
288
+ clients can ignore an extra argument, so adding an option to an old installation
289
+ does not guarantee compact issuance. Default two-argument calls, MCP and CLI
290
+ callers continue requesting full leases; there is no automatic negotiation or
291
+ fallback to a different representation.
292
+
293
+ ```js
294
+ const prepared = await transfers.prepare('invoice-batch-43', 'owner-grant-43', {
295
+ leaseFormat: 'matoi.controlled-transfer.lease.v2',
296
+ });
297
+ ```
298
+
299
+ The new format signs an ordered commitment to every original Action Pass. At the
300
+ existing final gate, the owner reconstructs only the selected step and verifies
301
+ its complete pass hash, ID and action fingerprint. Issuance still builds the real
302
+ passes once. Current authority, native approval/quorum, expiry, monetary limits,
303
+ predecessors and atomic consumption are unchanged. Financial actions still use
304
+ the approved slow lane; compact storage is not permission to bypass review or a
305
+ claim of measured end-to-end speed.
306
+
307
+ An authenticated capability response adds `leaseFormats` with exact
308
+ `supported: ['matoi.controlled-transfer.v1', 'matoi.controlled-transfer.lease.v2']`,
309
+ `default: 'matoi.controlled-transfer.v1'` and a boolean `compactIssuanceEnabled`.
310
+ An absent `leaseFormats` object means legacy full-only support with compact
311
+ issuance disabled. A present object with missing or invalid members is rejected
312
+ as `INVALID_CAPABILITY`.
313
+ Support describes this reader, not current authorization or fleet readiness.
314
+
315
+ For operators, first qualify **all** owner, projection, status, SDK and evidence
316
+ readers with `OSUITE_MATOI_COMPACT_LEASE_ISSUANCE` absent or `0`. Only then enable
317
+ new compact issuance with exact `1`; any other value makes the owner unavailable.
318
+ The flag is not agent-controlled. Closing it prevents new compact preparations
319
+ but does not revoke existing leases, erase history or cancel transactions already
320
+ preparing. Verify/drain every writer rather than assuming the switch is atomic
321
+ across a fleet. Roll back to a qualified dual-reader build, never a full-only
322
+ reader while compact preparations or history remain. Use normal authority
323
+ revocation when existing admission must stop.
324
+
325
+ The format is immutable for an operation ID. Same-format calls return the original
326
+ preparation; a different format is `LEASE_FORMAT_CONFLICT`, not a replacement.
327
+ Before sending, a new compact request can fail with `LEASE_FORMAT_UNSUPPORTED`
328
+ or `COMPACT_LEASE_ISSUANCE_DISABLED`. After a POST, **any** non-2xx response or
329
+ invalid response binding retains `OUTCOME_UNKNOWN`, even if the HTTP response is
330
+ 400 or 409. Recover with `status(operationId)`, not another POST or a new ID.
331
+ A cold client seeking an existing compact record while issuance is off also uses
332
+ status. An old SDK encountering that record must be upgraded; do not strip fields
333
+ or present it as a full lease. Original v1 history remains readable.
334
+
335
+ ### Execute And Recover
336
+
337
+ Only after the actual Studio review, deliberately invoke:
338
+
339
+ ```js
340
+ const result = await transfers.execute(prepared, 0);
341
+ console.log(result.state, result.code, result.newlyCommitted);
342
+ ```
343
+
344
+ `execute(prepared, ordinal = 0)` sends a signed POST with the selected ordinal
345
+ and either the full signed `lease` or, when fresh capabilities advertise
346
+ `executionTransport: 'bound-reference-v1'`, the verified `preparationDigest`.
347
+ The server resolves that reference against the authenticated workspace, actor,
348
+ key and original operation, then verifies the stored signed lease. In either
349
+ transport, the SDK verifies the original preparation and any commitment receipt;
350
+ the server checks current authority and native Studio approval. The SDK never
351
+ runs a local side effect or executes remaining ordinals for you. An HTTP 200
352
+ `denied` decision, including `AWAITING_APPROVAL`, is returned unchanged with the
353
+ same review link; it is never treated as a commitment or automatically retried.
354
+ A deliberate later call after human review performs fresh capability checks.
355
+
356
+ A `committed` response is accepted only with a verified receipt matching the
357
+ current operation, action/fingerprint, preparation, epochs, evidence and exact
358
+ effect. `newlyCommitted: true` describes that acknowledged request only.
359
+ `already_committed` may return an earlier operation's receipt, including its
360
+ original ordinal, but its tenant, actor, grant and exact signed effect must
361
+ still match the current authorization. It always has `newlyCommitted: false`.
362
+ Re-reading an already verified result in this client never resends execution.
363
+
364
+ ### Derived Evidence Freshness
365
+
366
+ `execute()` results and every returned `status()` result include a separate,
367
+ immutable `projection` observation. MCP tool results expose the same normalized
368
+ public shape. Its profile is `matoi.controlled-transfer.projection.v1`, its scope
369
+ is always `derived-view`, and `authorizesExecution` is always `false`.
370
+
371
+ The view state is `current`, `pending_reconciliation`, `stale`, `failed`, or
372
+ `unavailable`. This is independent of the resource's `state`, signed receipt and
373
+ `newlyCommitted` flag. A pending, failed or unavailable view never invalidates a
374
+ verified `committed` or `already_committed` receipt and never permits a resend.
375
+ Even `current` is only a server-reported derived-view observation, not a new
376
+ authorization decision, independent proof validation or external settlement.
377
+
378
+ The remaining fields are always present, with missing optional values as null:
379
+
380
+ - `incarnation` and `artifactIncarnation`: lowercase UUID strings.
381
+ - `requestedGeneration`, `projectedGeneration`, and `artifactGeneration`:
382
+ canonical nonnegative decimal strings, at most PostgreSQL's signed bigint
383
+ maximum `9223372036854775807`. They never pass through JavaScript Number.
384
+ - `generatedAt` and `observedAt`: canonical 24-character UTC ISO timestamps.
385
+ - `lastError`: a machine code of at most 64 uppercase letters, digits or
386
+ underscores, starting with a letter, not arbitrary diagnostic text.
387
+
388
+ Absent legacy metadata, an unknown profile/scope/state, or malformed fields
389
+ produce `state: 'unavailable'` with null identities, generations, timestamps and
390
+ error. No observation time is invented. Arbitrary graph/debug extensions are
391
+ omitted. A known non-unavailable state requires an `observedAt` timestamp.
392
+ Additionally, `current` requires nonnull equal incarnation and artifact
393
+ incarnation, three equal positive generation strings, and nonnull canonical
394
+ timestamps with `generatedAt <= observedAt`. Inconsistent current claims become
395
+ unavailable before any cached downgrade to stale. These checks establish only
396
+ internal wire consistency, not cryptographic proof of server freshness.
397
+ Only this additive metadata is normalized; receipt signatures and the existing
398
+ unknown-outcome fences remain unchanged. The HTTP response limit and resource
399
+ snapshot limits remain unchanged, with the separately bounded projection
400
+ attached after resource snapshot validation.
401
+
402
+ A cached execute replay conservatively changes a previous `current` view to
403
+ `stale`, preserving its original `observedAt`, `generatedAt` and generations.
404
+ Other view states remain as previously observed. This does not trigger a GET or
405
+ POST. Explicit status reads, including GET-only recovery of an evicted receipt,
406
+ can return a new server observation; subsequent cached replays are stale again.
407
+
408
+ ## Unknown Outcomes And Recovery
409
+
410
+ A timeout, lost connection, unsuccessful HTTP response or malformed post-send
411
+ reply raises `ControlledTransferError` with `code: 'OUTCOME_UNKNOWN'`, the
412
+ original `operationId`, `retryAutomatically: false`, and `recovery.method:
413
+ 'status'`. A missing, invalid or substituted receipt is also unknown, **not**
414
+ proof that nothing executed. Even HTTP 400/401/503 after a POST is conservatively
415
+ unknown: a proxy or a lost response cannot prove the resource did not commit.
416
+
417
+ ```js
418
+ try {
419
+ await transfers.execute(prepared, 0);
420
+ } catch (error) {
421
+ if (error.code !== 'OUTCOME_UNKNOWN') throw error;
422
+ const observed = await transfers.status(error.operationId);
423
+ console.log(observed.state, observed.code);
424
+ // Stop here. Do not resend, generate another operation ID, or auto-approve.
425
+ }
426
+ ```
427
+
428
+ `status(operationId)` uses only authenticated GET requests with `operationId`
429
+ and `agent_id`. It never prepares, consumes approval or executes. It returns
430
+ `committed`, `partially_committed`, `denied`, `awaiting_approval`, `ready`, or `unknown`.
431
+ `ready` reports the owner's current native approval, not a local authorization
432
+ or an instruction to execute. Pending and denied native votes remain distinct.
433
+ All status results have `newlyCommitted: false`. Committed effects must carry
434
+ verified receipts; noncommitted observations are not permission to retry.
435
+ Outages, 404s, wrong scope, invalid receipts and malformed replies return
436
+ `state: 'unknown', code: 'OUTCOME_UNKNOWN'`, never a fabricated negative result.
437
+
438
+ An unknown outcome fences further mutations for that operation in this client,
439
+ even after a status read succeeds. The fence is **in memory**, not a durable
440
+ exactly-once claim. Applications must durably retain operation IDs, preparations
441
+ and uncertainty markers. After restart, recover through status, not by creating
442
+ a new client or ID to bypass uncertainty. A saved preparation may be supplied
443
+ to an intentional first execution; it is fully reverified before sending.
444
+
445
+ Each long-lived client keeps at most 16 hot operation payloads (preparations and
446
+ receipts), with active preparation, execution and recovery calls pinned against
447
+ eviction. Compact grant, preparation-binding, effect-count and receipt-digest
448
+ records, including every uncertainty fence, remain for up to 65,536 operation
449
+ IDs. A new ID at that limit, or a call needing a hot slot when all 16 are active,
450
+ fails with `CLIENT_CAPACITY_EXCEEDED` before sending a request; existing fences
451
+ are never evicted to admit new work. Preparing an evicted recorded ID recovers
452
+ its original preparation through authenticated GET, never another prepare POST.
453
+ Replaying an evicted locally acknowledged completion likewise verifies the
454
+ original preparation and receipt digests through GET and returns
455
+ `already_committed`, `newlyCommitted: false`, without an execution POST. Missing
456
+ or inconsistent history becomes `OUTCOME_UNKNOWN`; successful later status
457
+ reads do not clear that fence. Settled preparation promises and cold payloads
458
+ are released without resetting the client. These limits cover SDK-owned state,
459
+ not payloads retained by callers, and do not provide persistence across restart.
460
+
461
+ An optional `prepared` field in status is verified against the issuer, tenant,
462
+ actor/key, operation, grant, effect list and any retained preparation. Current
463
+ receipts must bind to that preparation. The verified immutable field exposes
464
+ the original lease and review link after restart or a lost preparation response,
465
+ without repeating approval creation. It does not clear an uncertainty fence.
466
+ Reading an expired original lease is permitted; sending it for execution is not.
467
+
468
+ With a retained or status-recovered preparation, status can also bind historical
469
+ payment receipts to its signed effect list. A cold client can verify receipts
470
+ for the requested current operation. A historical receipt without the current
471
+ preparation cannot prove the intended current effect and remains unknown. If no
472
+ issuer is pinned or previously learned, receipt/preparation-bearing status also
473
+ reads capabilities to obtain an authenticated key. A known/pinned key permits
474
+ status verification even when fresh action capabilities are unavailable.
475
+
476
+ ## Verification Contract
477
+
478
+ Lease and receipt signatures use Ed25519 over recursively sorted canonical JSON,
479
+ with canonical 86-character base64url signatures. `issuer` is SHA-256 of SPKI DER.
480
+ An explicit `issuerPublicKey` pin takes precedence; otherwise the authenticated
481
+ capability key is pinned for the lifetime of the client. A later key substitution
482
+ is rejected, not silently trusted.
483
+
484
+ Financial effects have exactly `operation`, `paymentId`, `sourceAccount`,
485
+ `destination`, `asset`, `network`, `amountMinor`, and `decimals`. Amounts are
486
+ positive canonical decimal integer strings of at most 38 digits; they never
487
+ pass through Number. Decimals are integers from 0 to 18. At most 64 effects are
488
+ accepted and payment IDs must be unique within the signed preparation.
489
+
490
+ The finance profile defines the effect digest as
491
+ `SHA256(canonicalJson(["matoi.controlled-transfer.v1", "effect", effect]))`.
492
+ The SDK uses this solely to verify the expected effect against the signed lease
493
+ at its ordinal and against a signed resource receipt. It does not produce
494
+ financial workflow evidence or substitute for the resource's independent check.
495
+ `preparationDigest` is SHA-256 of the canonical lease payload. The client allows
496
+ 30 seconds of forward clock skew for issuance/commitment timestamps; current
497
+ commitments must fall within their signed lease lifetime. Expired leases cannot
498
+ be used for a new send, but historical status remains verifiable.
499
+
500
+ Native approval fingerprints use `apfp_<64 lowercase hex>`; unprefixed fixture
501
+ fingerprints are also accepted. Exact values are compared, never normalized.
502
+ Optional per-effect `lease.payload.passes` remain signed CAVA/ZeroGate evidence,
503
+ not local execution permission. Financial actions stay high-risk and require
504
+ the slow-approved native review route; there is no fast-path latency promise.
505
+
506
+ For receipts bound to a compact source preparation, the signed `gate` is
507
+ mandatory; legacy full-source receipts without it remain accepted. When present,
508
+ it must use `lane: 'slow-approved'` and a canonical decimal-string
509
+ `admissionSequence`. Its actual ZeroGate receipt must retain the
510
+ `slow`/`review`/`risk_exceeds_fast_lane` result, correct hash, source ordinal and
511
+ timestamp. It binds to that original source preparation's pass commitment (or
512
+ full pass when available), not to a later operation's position for the payment.
513
+ The enclosing signed owner receipt, not that review receipt alone, acknowledges
514
+ commitment. If an earlier source preparation is unavailable, historical signature
515
+ and effect checks alone do not establish its pass commitment. Auxiliary
516
+ `projection` metadata is normalized separately by the client and is not financial
517
+ commitment evidence.
518
+
519
+ When its original source preparation is known, a receipt must also use that
520
+ source lease's issuer. Trusting both an old and a current public key does not
521
+ allow the current key to re-sign the old lease's receipt as if it were the
522
+ original. Valid old-key receipts remain verifiable after rotation; unknown
523
+ source history retains the narrower signature/effect-only guarantee above.
524
+
525
+ ## Doctor Integration
526
+
527
+ The doctor module exports these functions, with no import-time I/O:
528
+
529
+ ```js
530
+ import { probeMatoiStatus, formatMatoiStatus } from './matoiDoctor.mjs';
531
+
532
+ const status = await probeMatoiStatus({ config });
533
+ const output = formatMatoiStatus(status);
534
+ ```
535
+
536
+ The prober performs at most one capability GET and never mutates. It separates
537
+ `installed`, `localConfigured`, `configured`, `serverConfigured`,
538
+ `capabilityAvailable`, `resourceEnforced`, and the server's `qualification`.
539
+ Unavailable qualification is null and displays as unknown; valid qualifications
540
+ are explicitly labeled server-reported. Configuration failures are returned as
541
+ diagnostic codes without exposing credentials.
542
+
543
+ ```sh
544
+ osuite doctor --controlled-transfers
545
+ osuite doctor --require-controlled-transfers
546
+ osuite doctor --controlled-transfers --runtime mcp
547
+ ```
548
+
549
+ Both strict flags run only this diagnostic, not the ordinary health/Hook probes
550
+ or opt-in onboarding measurements. Exit zero requires strict local configuration
551
+ and authenticated, configured resource enforcement. It does not certify deployment
552
+ qualification; `not-qualified` remains visible. Ordinary `osuite doctor` adds a
553
+ non-gating Matoi diagnostic: lack of this optional profile does not fail an
554
+ otherwise healthy old SDK installation or change ordinary Hook behavior.
555
+
556
+ Strict commands select exactly one protected credential bundle: `.osuite/.env`
557
+ for SDK doctor, or `.osuite/mcp/.env` for MCP and `doctor --runtime mcp`. They never
558
+ load `.codex/.env`, `.claude/.env`, `.cursor/.env` or the project's root `.env`.
559
+ The bundle must provide `OSUITE_BASE_URL`, `OSUITE_API_KEY`,
560
+ `OSUITE_PRIVATE_KEY_BASE64`, `OSUITE_ORG_ID`, `OSUITE_AGENT_ID`,
561
+ `OSUITE_SIGNATURE_MODE=required`, `OSUITE_GUARD_FAILURE_MODE=block`, and the matching
562
+ `OSUITE_RUNTIME_ADAPTER_ID` (`sdk`, `framework_sdk`, `inline_sdk`, or `mcp` for MCP).
563
+ An optional `OSUITE_AGENT_KEY_ID` asserts the credential key identity.
564
+
565
+ A complete explicit shell configuration is usable when the selected bundle is
566
+ absent. With a bundle present, explicit shell configuration must agree with it;
567
+ partial bundles cannot borrow missing keys or identities from another source.
568
+ Conflicting `OSUITE_*`/`DASHCLAW_*` aliases and duplicate assignments are rejected.
569
+ Optional `OSUITE_MATOI_TIMEOUT_MS` sets the bounded request timeout;
570
+ `OSUITE_MATOI_ISSUER_PUBLIC_KEY_BASE64` pins base64-encoded Ed25519 SPKI PEM.
571
+
572
+ Unsafe, tracked, non-ignored, symlinked or non-owner-only credential files are
573
+ refused using the existing credential inspector. A selected connect journal or
574
+ lock, or any pending SDK/MCP migration marker, blocks strict commands. They do
575
+ not repair files, resume enrollment, merge identities, or print secrets.
576
+
577
+ ## Controlled MCP
578
+
579
+ ```js
580
+ import { createControlledTransferMcpServer } from 'osuite/controlled-transfers';
581
+
582
+ const server = createControlledTransferMcpServer(config);
583
+ const { tools } = server.listTools();
584
+ // The CLI uses server.handleRequest(jsonRpcRequest).
585
+ // Embedded callers may explicitly use server.callTool(name, argumentsObject).
586
+ ```
587
+
588
+ Only `osuite_transfer_prepare(operationId, grantId)`,
589
+ `osuite_transfer_execute(prepared, ordinal = 0)`, and
590
+ `osuite_transfer_status(operationId)` are exposed. They delegate to the real
591
+ client; there is no local payment function, automatic approval, or generic MCP
592
+ execution gateway. Tool arguments reject extra keys. Results preserve pending,
593
+ refusal and unknown states. `effect_executed` is true only for a newly verified
594
+ commitment, false for `already_committed`, pending, refusals and read-only known
595
+ observations, and null for unknown outcomes. Status never claims a new effect.
596
+ Results include only the bounded public freshness fields under `projection`,
597
+ not configuration, arbitrary server debug data or full projection graphs.
598
+
599
+ ```sh
600
+ osuite mcp --controlled-transfers
601
+ ```
602
+
603
+ This explicit lane uses `sdk/controlled-transfers-stdio.mjs`, not the ordinary
604
+ runtime MCP bridge. It accepts UTF-8 NDJSON, limits an input frame to 1 MiB and
605
+ buffered input to 2 MiB, and awaits each request and output before the next. The
606
+ frame limit uses `CONTROLLED_TRANSFER_MAX_ENVELOPE_BYTES`. Stdout contains
607
+ JSON-RPC only. Invalid JSON/UTF-8 or oversized framing emits a bounded protocol
608
+ error and stops rather than dispatching queued mutations. Initialization and
609
+ tool listing do not contact the server or change files. No arbitrary-MCP safety
610
+ or full-stack deployment protection is implied.
611
+
612
+ ## Local Contract Tests
613
+
614
+ Run with Node 24:
615
+
616
+ ```sh
617
+ node --test sdk/controlled-transfers/test/*.test.mjs
618
+ node node_modules/vitest/vitest.mjs run __tests__/unit/matoi-cli.test.js
619
+ ```
620
+
621
+ Tests use ephemeral loopback HTTP servers, real local RSA/Ed25519 signatures and
622
+ offline package inspection. Fixture receipts test client verification only;
623
+ they are not evidence of real financial writes, native Studio review, or
624
+ deployment qualification. Owner/PostgreSQL/live route acceptance is a separate
625
+ integration gate.
626
+
627
+ ## Transport And Rotation Since 2.12.0
628
+
629
+ The published `2.12.0` client does not by itself establish a qualified
630
+ server deployment. When fresh capabilities advertise
631
+ `executionTransport: 'bound-reference-v1'`, the execute POST sends the verified
632
+ `preparationDigest` instead of repeating the complete signed `lease`. The client
633
+ still verifies the original preparation, selected ordinal and returned receipt;
634
+ the reference is not a new approval or an unsigned local execution shortcut.
635
+ Without that advertisement, the existing full-lease request format is retained.
636
+ No timeout, transport fallback or oversized response authorizes a resend.
637
+
638
+ For rotation, explicitly pin the current Ed25519 issuer and retain only reviewed
639
+ previous public roots in `trustedIssuerPublicKeys`. Status may verify the
640
+ original historical preparation and receipt with those roots, without replacing
641
+ their signatures or making a POST. A retired issuer cannot authorize a fresh
642
+ preparation or execution, even when trusted for historical reads. Fence old
643
+ writers and preserve authoritative payment history before activating a rotated
644
+ or restored owner; missing history remains quarantine, not fresh spend capacity.
645
+
646
+ In the standalone public source export, run `npm run test:controlled-transfers`
647
+ on Node 24 for the transport, client contract, rotation, doctor, package and
648
+ strict CLI checks. The existing Node 24 `test:governed-tools` CI gate also runs
649
+ this command. The exported `source-manifest.json` records the five exact-name
650
+ private-owner test exclusions and their reason. The full repository commands
651
+ above retain those tests; no private owner implementation is exported. Ordinary
652
+ SDK compatibility remains a separate unchanged `npm run test:compat` gate.
package/GOVERNED_TOOLS.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Native Tool Compatibility And Recovery
2
2
 
3
3
  This opt-in API is introduced in 2.11.0; it is not part of 2.10.2. Confirm the
4
- chosen version with `npm view osuite@2.11.2 version` before installing. A source
4
+ chosen version with `npm view osuite@2.12.0 version` before installing. A source
5
5
  checkout alone does not establish npm availability or server compatibility;
6
6
  consult the verified release record before enabling it for a workspace.
7
7