@victframework/runtime 0.1.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 (115) hide show
  1. package/dist/agent-governance.d.ts +285 -0
  2. package/dist/agent-governance.js +438 -0
  3. package/dist/agent-governance.js.map +1 -0
  4. package/dist/agent-registry.d.ts +103 -0
  5. package/dist/agent-registry.js +758 -0
  6. package/dist/agent-registry.js.map +1 -0
  7. package/dist/agent-types.d.ts +433 -0
  8. package/dist/agent-types.js +480 -0
  9. package/dist/agent-types.js.map +1 -0
  10. package/dist/authority.d.ts +83 -0
  11. package/dist/authority.js +170 -0
  12. package/dist/authority.js.map +1 -0
  13. package/dist/boundary-conformance.d.ts +51 -0
  14. package/dist/boundary-conformance.js +364 -0
  15. package/dist/boundary-conformance.js.map +1 -0
  16. package/dist/control-conformance.d.ts +68 -0
  17. package/dist/control-conformance.js +1131 -0
  18. package/dist/control-conformance.js.map +1 -0
  19. package/dist/control-in-memory.d.ts +257 -0
  20. package/dist/control-in-memory.js +886 -0
  21. package/dist/control-in-memory.js.map +1 -0
  22. package/dist/control-types.d.ts +1017 -0
  23. package/dist/control-types.js +779 -0
  24. package/dist/control-types.js.map +1 -0
  25. package/dist/durable-run.d.ts +73 -0
  26. package/dist/durable-run.js +262 -0
  27. package/dist/durable-run.js.map +1 -0
  28. package/dist/effect-policy.d.ts +22 -0
  29. package/dist/effect-policy.js +45 -0
  30. package/dist/effect-policy.js.map +1 -0
  31. package/dist/errors.d.ts +36 -0
  32. package/dist/errors.js +71 -0
  33. package/dist/errors.js.map +1 -0
  34. package/dist/in-memory-stores.d.ts +16 -0
  35. package/dist/in-memory-stores.js +522 -0
  36. package/dist/in-memory-stores.js.map +1 -0
  37. package/dist/index.d.ts +41 -0
  38. package/dist/index.js +26 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/operator-config.d.ts +141 -0
  41. package/dist/operator-config.js +289 -0
  42. package/dist/operator-config.js.map +1 -0
  43. package/dist/orchestration-activation.d.ts +116 -0
  44. package/dist/orchestration-activation.js +223 -0
  45. package/dist/orchestration-activation.js.map +1 -0
  46. package/dist/orchestration-canary-conformance.d.ts +10 -0
  47. package/dist/orchestration-canary-conformance.js +726 -0
  48. package/dist/orchestration-canary-conformance.js.map +1 -0
  49. package/dist/orchestration-commands.d.ts +47 -0
  50. package/dist/orchestration-commands.js +538 -0
  51. package/dist/orchestration-commands.js.map +1 -0
  52. package/dist/orchestration-conformance.d.ts +59 -0
  53. package/dist/orchestration-conformance.js +594 -0
  54. package/dist/orchestration-conformance.js.map +1 -0
  55. package/dist/orchestration-driver-types.d.ts +163 -0
  56. package/dist/orchestration-driver-types.js +21 -0
  57. package/dist/orchestration-driver-types.js.map +1 -0
  58. package/dist/orchestration-driver.d.ts +48 -0
  59. package/dist/orchestration-driver.js +1030 -0
  60. package/dist/orchestration-driver.js.map +1 -0
  61. package/dist/orchestration-in-memory.d.ts +18 -0
  62. package/dist/orchestration-in-memory.js +1313 -0
  63. package/dist/orchestration-in-memory.js.map +1 -0
  64. package/dist/orchestration-join-conformance.d.ts +20 -0
  65. package/dist/orchestration-join-conformance.js +542 -0
  66. package/dist/orchestration-join-conformance.js.map +1 -0
  67. package/dist/orchestration-plan.d.ts +52 -0
  68. package/dist/orchestration-plan.js +265 -0
  69. package/dist/orchestration-plan.js.map +1 -0
  70. package/dist/orchestration-race-conformance.d.ts +35 -0
  71. package/dist/orchestration-race-conformance.js +1265 -0
  72. package/dist/orchestration-race-conformance.js.map +1 -0
  73. package/dist/orchestration-remediation-conformance.d.ts +54 -0
  74. package/dist/orchestration-remediation-conformance.js +632 -0
  75. package/dist/orchestration-remediation-conformance.js.map +1 -0
  76. package/dist/orchestration-store-types.d.ts +568 -0
  77. package/dist/orchestration-store-types.js +2 -0
  78. package/dist/orchestration-store-types.js.map +1 -0
  79. package/dist/pack-conformance.d.ts +59 -0
  80. package/dist/pack-conformance.js +222 -0
  81. package/dist/pack-conformance.js.map +1 -0
  82. package/dist/pack-install.d.ts +44 -0
  83. package/dist/pack-install.js +126 -0
  84. package/dist/pack-install.js.map +1 -0
  85. package/dist/registry.d.ts +107 -0
  86. package/dist/registry.js +481 -0
  87. package/dist/registry.js.map +1 -0
  88. package/dist/runtime.d.ts +158 -0
  89. package/dist/runtime.js +1341 -0
  90. package/dist/runtime.js.map +1 -0
  91. package/dist/serialization.d.ts +26 -0
  92. package/dist/serialization.js +162 -0
  93. package/dist/serialization.js.map +1 -0
  94. package/dist/store-conformance.d.ts +45 -0
  95. package/dist/store-conformance.js +876 -0
  96. package/dist/store-conformance.js.map +1 -0
  97. package/dist/store-errors.d.ts +49 -0
  98. package/dist/store-errors.js +48 -0
  99. package/dist/store-errors.js.map +1 -0
  100. package/dist/store-types.d.ts +331 -0
  101. package/dist/store-types.js +14 -0
  102. package/dist/store-types.js.map +1 -0
  103. package/dist/store-validation.d.ts +63 -0
  104. package/dist/store-validation.js +164 -0
  105. package/dist/store-validation.js.map +1 -0
  106. package/dist/stream-hub.d.ts +151 -0
  107. package/dist/stream-hub.js +402 -0
  108. package/dist/stream-hub.js.map +1 -0
  109. package/dist/testing.d.ts +25 -0
  110. package/dist/testing.js +19 -0
  111. package/dist/testing.js.map +1 -0
  112. package/dist/types.d.ts +221 -0
  113. package/dist/types.js +2 -0
  114. package/dist/types.js.map +1 -0
  115. package/package.json +45 -0
@@ -0,0 +1,285 @@
1
+ import type { AgentActivationRecord, AgentCredentialPort } from './agent-types.js';
2
+ /**
3
+ * Stage 06A — agent data-protection governance (MSTR-011).
4
+ *
5
+ * This module is the neutral foundation for the local data-protection
6
+ * baseline:
7
+ *
8
+ * - `AgentCredentialPort` — protected-only, just-in-time credential
9
+ * resolution. Values never enter profiles, snapshots, messages, memory,
10
+ * traces, streams, diagnostics, errors, exports, or databases. Provider
11
+ * failures are converted into stable, non-echoing diagnostics; a failed
12
+ * provider read never poisons later invocations; no process-wide cache
13
+ * silently preserves rotated values.
14
+ * - `AgentGovernanceStore` — durable deletion intents, per-step receipts,
15
+ * and persisted activation identity records. In-memory and SQLite
16
+ * implementations share one conformance discipline (idempotent writes,
17
+ * receipt deduplication).
18
+ * - `ConversationDeletionCoordinator` — governed conversation deletion
19
+ * across the VICT application-domain store and the agent-framework memory store.
20
+ * Cross-store atomicity is impossible and is NOT claimed: the
21
+ * coordinator records durable intent, makes each step idempotent,
22
+ * persists progress receipts, resumes safely after failure or process
23
+ * restart, never resurrects deleted data, and reports truthful
24
+ * partial/blocked status.
25
+ * - `ConversationExportService` — explicit, request-scoped export of only
26
+ * the data the classification policy promises; credentials, registry
27
+ * data, and raw protected traces are structurally excluded, and the
28
+ * generated export is never retained or logged by this service.
29
+ */
30
+ /** Stable sanitized credential-failure codes (never provider content). */
31
+ export type AgentCredentialErrorCode = 'VICT_AGENT_CREDENTIAL_UNAVAILABLE';
32
+ /** Error thrown for credential-resolution failures (stable, non-echoing). */
33
+ export declare class AgentCredentialError extends Error {
34
+ readonly code: AgentCredentialErrorCode;
35
+ readonly credentialName: string;
36
+ constructor(credentialName: string);
37
+ }
38
+ /** A credential name: validated against the accepted credential-reference policy. */
39
+ export declare function assertCredentialName(name: string): void;
40
+ /**
41
+ * Wrap a credential provider with the protected-resolution discipline:
42
+ * - names are validated before reaching the provider;
43
+ * - provider exceptions are converted into stable sanitized failures whose
44
+ * messages never include provider content;
45
+ * - values are never cached — every read passes through to the provider, so
46
+ * rotation is observed and a rejected read cannot poison later reads.
47
+ */
48
+ export declare function protectCredentialPort(port: AgentCredentialPort): AgentCredentialPort;
49
+ /** Stable non-echoing failure for a missing required credential. */
50
+ export declare function requireCredential(value: string | undefined, name: string): string;
51
+ /** The durable deletion step a receipt covers. */
52
+ export type AgentDeletionStep = 'application-domain' | 'memory-store';
53
+ /** Deletion-intent lifecycle states. */
54
+ export type AgentDeletionIntentState = 'pending' | 'application-domain-deleted' | 'completed';
55
+ /** One durable per-step receipt. */
56
+ export interface AgentDeletionStepReceipt {
57
+ readonly step: AgentDeletionStep;
58
+ /** Epoch-ms timestamp from the injected clock. */
59
+ readonly at: number;
60
+ }
61
+ /** A durable deletion intent with its recorded progress. */
62
+ export interface AgentDeletionIntentRecord {
63
+ readonly intentId: string;
64
+ readonly conversationId: string;
65
+ readonly actorId: string;
66
+ readonly createdAt: number;
67
+ readonly state: AgentDeletionIntentState;
68
+ readonly receipts: readonly AgentDeletionStepReceipt[];
69
+ }
70
+ /** Durable agent-governance records: activation identity + deletion intents. */
71
+ export interface AgentGovernanceStore {
72
+ /** Persist an activation identity record (idempotent by activationVersion; content collision fails). */
73
+ saveAgentActivation(record: AgentActivationRecord): Promise<void>;
74
+ /** Read one activation identity record. */
75
+ getAgentActivation(activationVersion: string): Promise<AgentActivationRecord | undefined>;
76
+ /** Record a deletion intent (idempotent by intentId; same content is a no-op, conflicting content fails). */
77
+ recordDeletionIntent(record: AgentDeletionIntentRecord): Promise<void>;
78
+ /** Read one deletion intent. */
79
+ getDeletionIntent(intentId: string): Promise<AgentDeletionIntentRecord | undefined>;
80
+ /** List intents that have not reached `completed`. */
81
+ listOpenDeletionIntents(): Promise<readonly AgentDeletionIntentRecord[]>;
82
+ /** Record one step receipt (idempotent per intentId + step: duplicates are no-ops). */
83
+ recordDeletionReceipt(intentId: string, step: AgentDeletionStep, at: number): Promise<void>;
84
+ /** Advance the intent state (forward-only; regressions fail). */
85
+ updateDeletionIntentState(intentId: string, state: AgentDeletionIntentState): Promise<void>;
86
+ /** List ALL deletion intents (open and completed), canonically ordered. */
87
+ listDeletionIntents(): Promise<readonly AgentDeletionIntentRecord[]>;
88
+ /** Close underlying resources, if any (sync or async, per implementation). */
89
+ close?(): Promise<void> | void;
90
+ }
91
+ /**
92
+ * The closed deletion-step domain. Both store adapters (in-memory and
93
+ * SQLite) enforce the SAME receipt-step domain at their API boundary so
94
+ * unknown (e.g. legacy or fabricated) steps are rejected with the same
95
+ * stable, non-echoing error BEFORE any mutation (adapter parity).
96
+ */
97
+ export declare const DELETION_STEP_DOMAIN: ReadonlySet<string>;
98
+ /** The exact stable, non-echoing rejection text shared by every adapter. */
99
+ export declare const DELETION_RECEIPT_STEP_INVALID_MESSAGE = "VICT_AGENT_DELETION_RECEIPT_STEP_INVALID: the deletion receipt step must be a governed durable step.";
100
+ /**
101
+ * Validate one deletion-receipt step against the closed domain (shared by
102
+ * the in-memory and SQLite adapters). Invalid or legacy steps are rejected
103
+ * with the SAME stable, non-echoing error on every adapter, before any
104
+ * durable mutation occurs.
105
+ */
106
+ export declare function assertDeletionReceiptStep(step: unknown): asserts step is AgentDeletionStep;
107
+ /**
108
+ * Shared invariant enforcement for in-memory and SQLite stores.
109
+ *
110
+ * Transitions are forward-only AND stepwise: a state may only move to the
111
+ * IMMEDIATELY next state in the lifecycle. Skipped transitions (for example
112
+ * `pending` directly to `completed`) are rejected — completion always
113
+ * requires both durable step receipts, which a skipped transition would
114
+ * fabricate. Same-state updates are idempotent no-ops.
115
+ */
116
+ export declare function assertDeletionStateTransition(from: AgentDeletionIntentState, to: AgentDeletionIntentState): void;
117
+ /**
118
+ * Receipt-enforced transition validation (shared by in-memory and SQLite
119
+ * stores): a state may only advance when the receipt of the step it
120
+ * ENTERS is durably recorded.
121
+ *
122
+ * - entering `application-domain-deleted` requires the durable
123
+ * `application-domain` receipt;
124
+ * - entering `completed` requires BOTH durable step receipts.
125
+ *
126
+ * The check reads the ACTUAL STORED receipts — the caller must pass the
127
+ * receipts exactly as they exist in the same store, and each store must
128
+ * perform the check and the state update ATOMICALLY (one synchronous
129
+ * critical section in memory; one transaction in SQLite). A receipt-free
130
+ * two-step bypass (`pending → application-domain-deleted → completed`)
131
+ * therefore fails at the FIRST transition and leaves the stored state
132
+ * unchanged.
133
+ */
134
+ export declare function assertDeletionStateTransitionWithReceipts(from: AgentDeletionIntentState, to: AgentDeletionIntentState, receipts: ReadonlyArray<{
135
+ readonly step: AgentDeletionStep;
136
+ }>): void;
137
+ /**
138
+ * Validate a deletion-intent record at the durable boundary (shared by the
139
+ * in-memory and SQLite stores). A NEW intent must start as `pending` with
140
+ * NO receipts — arbitrary initial states and fabricated receipts are
141
+ * rejected.
142
+ */
143
+ export declare function assertDeletionIntentRecord(record: AgentDeletionIntentRecord): void;
144
+ /** In-memory AgentGovernanceStore (tests and non-durable compositions). */
145
+ export declare class InMemoryAgentGovernanceStore implements AgentGovernanceStore {
146
+ #private;
147
+ saveAgentActivation(record: AgentActivationRecord): Promise<void>;
148
+ getAgentActivation(activationVersion: string): Promise<AgentActivationRecord | undefined>;
149
+ recordDeletionIntent(record: AgentDeletionIntentRecord): Promise<void>;
150
+ getDeletionIntent(intentId: string): Promise<AgentDeletionIntentRecord | undefined>;
151
+ listOpenDeletionIntents(): Promise<readonly AgentDeletionIntentRecord[]>;
152
+ listDeletionIntents(): Promise<readonly AgentDeletionIntentRecord[]>;
153
+ recordDeletionReceipt(intentId: string, step: AgentDeletionStep, at: number): Promise<void>;
154
+ updateDeletionIntentState(intentId: string, state: AgentDeletionIntentState): Promise<void>;
155
+ }
156
+ /** The application-domain side of governed conversation deletion. */
157
+ export interface AgentConversationDomainPort {
158
+ /**
159
+ * Delete the VICT application-domain conversation resource. Returns
160
+ * `{ deleted: true }` when a record was deleted and
161
+ * `{ deleted: false }` when it was already absent (idempotent).
162
+ */
163
+ deleteConversation(conversationId: string): Promise<{
164
+ readonly deleted: boolean;
165
+ }>;
166
+ }
167
+ /** The the agent framework-memory side of governed conversation deletion (adapter-owned). */
168
+ export interface AgentMemoryDeletionPort {
169
+ /**
170
+ * Delete the the agent framework thread (and its messages/memory state) bound to the
171
+ * VICT conversation. Idempotent: returns `{ deleted: false }` when the
172
+ * thread was already absent.
173
+ */
174
+ deleteConversationThread(conversationId: string): Promise<{
175
+ readonly deleted: boolean;
176
+ }>;
177
+ }
178
+ /** Result of one governed deletion attempt. */
179
+ export interface AgentDeletionOutcome {
180
+ /** `completed` when every governed step has a durable receipt. */
181
+ readonly status: 'completed' | 'pending';
182
+ readonly intentId: string;
183
+ readonly conversationId: string;
184
+ /** Steps with durable receipts after this attempt, in policy order. */
185
+ readonly completedSteps: readonly AgentDeletionStep[];
186
+ }
187
+ /** Options for the ConversationDeletionCoordinator. */
188
+ export interface ConversationDeletionCoordinatorOptions {
189
+ readonly governance: AgentGovernanceStore;
190
+ readonly domain: AgentConversationDomainPort;
191
+ readonly memory: AgentMemoryDeletionPort;
192
+ /** Injected clock (epoch ms). */
193
+ readonly clock?: () => number;
194
+ }
195
+ /**
196
+ * Governed conversation deletion across stores (amendment §8.1, MSTR-011).
197
+ *
198
+ * Cross-store atomicity is impossible and is never claimed. The
199
+ * coordinator:
200
+ * 1. records the durable deletion intent BEFORE touching either store;
201
+ * 2. deletes the VICT application-domain resource through its governed
202
+ * port and records a durable receipt;
203
+ * 3. deletes the the agent framework thread through the adapter port and records a
204
+ * durable receipt;
205
+ * 4. advances the intent to `completed` only when both receipts exist.
206
+ *
207
+ * Every step is idempotent; receipts deduplicate; `recoverPending()`
208
+ * resumes safely after a crash at ANY boundary without duplicating
209
+ * receipts, losing completions, or resurrecting deleted data.
210
+ */
211
+ export declare class ConversationDeletionCoordinator {
212
+ #private;
213
+ constructor(options: ConversationDeletionCoordinatorOptions);
214
+ /** Deterministic intent id per conversation (idempotent re-deletes). */
215
+ intentIdFor(conversationId: string): string;
216
+ deleteConversation(options: {
217
+ readonly conversationId: string;
218
+ readonly actorId: string;
219
+ }): Promise<AgentDeletionOutcome>;
220
+ /**
221
+ * Resume every open intent (crash recovery, process restart). Each open
222
+ * intent continues from its recorded receipts; completed steps are never
223
+ * re-executed against the stores... the underlying ports are idempotent
224
+ * besides, but receipts are authoritative: a recorded receipt means the
225
+ * step is durable and is NOT re-driven.
226
+ */
227
+ recoverPending(): Promise<{
228
+ readonly resumed: number;
229
+ readonly completed: number;
230
+ readonly pending: number;
231
+ }>;
232
+ }
233
+ /** One exported conversation message (classification-policy fields only). */
234
+ export interface AgentConversationExportMessage {
235
+ readonly seq: number;
236
+ readonly role: 'user' | 'assistant' | 'system';
237
+ /** Epoch-ms creation time from the owning store. */
238
+ readonly createdAt: number;
239
+ /** Message text content (intentionally retained conversation content). */
240
+ readonly text: string;
241
+ }
242
+ /**
243
+ * The export payload: only what the classification policy promises. No
244
+ * credentials, no registry data, no raw traces, no operational history.
245
+ */
246
+ export interface AgentConversationExport {
247
+ readonly conversationId: string;
248
+ readonly actorId: string;
249
+ readonly threadCreatedAt: number | null;
250
+ readonly messages: readonly AgentConversationExportMessage[];
251
+ }
252
+ /** The the agent framework-side export port (adapter-owned). */
253
+ export interface AgentConversationMemoryExportPort {
254
+ exportConversationThread(conversationId: string): Promise<AgentConversationExport | undefined>;
255
+ }
256
+ /** Result of an export request. */
257
+ export interface AgentConversationExportResult {
258
+ /** Deterministic structured export (ordering is meaningful). */
259
+ readonly export: AgentConversationExport;
260
+ /** The export is returned to the requestor and NOT retained anywhere. */
261
+ readonly retained: false;
262
+ }
263
+ /** Stable denial codes for exports. */
264
+ export type AgentConversationExportErrorCode = 'VICT_AGENT_EXPORT_NOT_FOUND' | 'VICT_AGENT_EXPORT_ACTOR_MISMATCH';
265
+ /** Error carrying a stable export denial (never raw content). */
266
+ export declare class AgentConversationExportError extends Error {
267
+ readonly code: AgentConversationExportErrorCode;
268
+ constructor(code: AgentConversationExportErrorCode);
269
+ }
270
+ /**
271
+ * Governed conversation export (MSTR-011). Explicit and request-scoped:
272
+ * the requestor must present the owning actor identity; the export
273
+ * contains only classification-policy data; the result is handed to the
274
+ * caller and never logged or retained by the service.
275
+ */
276
+ export declare class ConversationExportService {
277
+ #private;
278
+ constructor(options: {
279
+ readonly memory: AgentConversationMemoryExportPort;
280
+ });
281
+ export(options: {
282
+ readonly conversationId: string;
283
+ readonly actorId: string;
284
+ }): Promise<AgentConversationExportResult>;
285
+ }