hiveagents-runtime 0.0.0-stage → 0.1.0-beta.1
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.
- package/LICENSE +202 -0
- package/README.md +85 -2
- package/dist/adapter-kit.d.ts +37 -0
- package/dist/adapter-kit.js +33 -0
- package/dist/adapter-kit.js.map +1 -0
- package/dist/agent-D0HS38G3.d.ts +169 -0
- package/dist/agent-OLSXNGNN.js +23 -0
- package/dist/agent-OLSXNGNN.js.map +1 -0
- package/dist/agent-readiness-V36OJME4.js +19 -0
- package/dist/agent-readiness-V36OJME4.js.map +1 -0
- package/dist/capture-runtime-GP6NZ2ee.d.ts +54 -0
- package/dist/chunk-2RUEC63U.js +1217 -0
- package/dist/chunk-2RUEC63U.js.map +1 -0
- package/dist/chunk-3B3JW4U3.js +291 -0
- package/dist/chunk-3B3JW4U3.js.map +1 -0
- package/dist/chunk-3TIYA3K5.js +55 -0
- package/dist/chunk-3TIYA3K5.js.map +1 -0
- package/dist/chunk-6XIJW65Q.js +52 -0
- package/dist/chunk-6XIJW65Q.js.map +1 -0
- package/dist/chunk-7LDQKJKI.js +248 -0
- package/dist/chunk-7LDQKJKI.js.map +1 -0
- package/dist/chunk-ALLOMOUN.js +810 -0
- package/dist/chunk-ALLOMOUN.js.map +1 -0
- package/dist/chunk-C2DN6KL4.js +853 -0
- package/dist/chunk-C2DN6KL4.js.map +1 -0
- package/dist/chunk-COKYQUTK.js +581 -0
- package/dist/chunk-COKYQUTK.js.map +1 -0
- package/dist/chunk-CPN4DOXH.js +115 -0
- package/dist/chunk-CPN4DOXH.js.map +1 -0
- package/dist/chunk-DBFXFWQZ.js +385 -0
- package/dist/chunk-DBFXFWQZ.js.map +1 -0
- package/dist/chunk-DZFFGUIA.js +81 -0
- package/dist/chunk-DZFFGUIA.js.map +1 -0
- package/dist/chunk-EEUYQFCP.js +106 -0
- package/dist/chunk-EEUYQFCP.js.map +1 -0
- package/dist/chunk-GFVYNPLS.js +118 -0
- package/dist/chunk-GFVYNPLS.js.map +1 -0
- package/dist/chunk-GJ4FTDBJ.js +2910 -0
- package/dist/chunk-GJ4FTDBJ.js.map +1 -0
- package/dist/chunk-GS5U3KUN.js +201 -0
- package/dist/chunk-GS5U3KUN.js.map +1 -0
- package/dist/chunk-HB7FBSH2.js +960 -0
- package/dist/chunk-HB7FBSH2.js.map +1 -0
- package/dist/chunk-HZFZX5A3.js +21 -0
- package/dist/chunk-HZFZX5A3.js.map +1 -0
- package/dist/chunk-J7VAYJKM.js +595 -0
- package/dist/chunk-J7VAYJKM.js.map +1 -0
- package/dist/chunk-NCNSHOF7.js +52 -0
- package/dist/chunk-NCNSHOF7.js.map +1 -0
- package/dist/chunk-RXU2Q2HF.js +49 -0
- package/dist/chunk-RXU2Q2HF.js.map +1 -0
- package/dist/chunk-SRJUZJKV.js +521 -0
- package/dist/chunk-SRJUZJKV.js.map +1 -0
- package/dist/chunk-TG7NTMTR.js +208 -0
- package/dist/chunk-TG7NTMTR.js.map +1 -0
- package/dist/chunk-TIZKGD4R.js +202 -0
- package/dist/chunk-TIZKGD4R.js.map +1 -0
- package/dist/chunk-WMKO5XOE.js +601 -0
- package/dist/chunk-WMKO5XOE.js.map +1 -0
- package/dist/chunk-WOQBVJH5.js +175 -0
- package/dist/chunk-WOQBVJH5.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors-DgehLwqI.d.ts +98 -0
- package/dist/execution-halt-CW0Oi9s9.d.ts +12 -0
- package/dist/execution-types-UJ6gAF48.d.ts +239 -0
- package/dist/host-ledger-VPRWVVOS.js +25 -0
- package/dist/host-ledger-VPRWVVOS.js.map +1 -0
- package/dist/hosted-runtime.d.ts +168 -0
- package/dist/hosted-runtime.js +857 -0
- package/dist/hosted-runtime.js.map +1 -0
- package/dist/index-B86C6VAD.d.ts +41 -0
- package/dist/index.d.ts +327 -0
- package/dist/index.js +8818 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-items-BSTC0_R0.d.ts +28 -0
- package/dist/memory-tools.d.ts +222 -0
- package/dist/memory-tools.js +923 -0
- package/dist/memory-tools.js.map +1 -0
- package/dist/orchestration/dynamic.d.ts +854 -0
- package/dist/orchestration/dynamic.js +3150 -0
- package/dist/orchestration/dynamic.js.map +1 -0
- package/dist/orchestration/graph.d.ts +11 -0
- package/dist/orchestration/graph.js +9 -0
- package/dist/orchestration/graph.js.map +1 -0
- package/dist/orchestration/index.d.ts +2385 -0
- package/dist/orchestration/index.js +6403 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/log.d.ts +301 -0
- package/dist/orchestration/log.js +3058 -0
- package/dist/orchestration/log.js.map +1 -0
- package/dist/orchestration/memory.d.ts +711 -0
- package/dist/orchestration/memory.js +27 -0
- package/dist/orchestration/memory.js.map +1 -0
- package/dist/provider-XCpWjJ6a.d.ts +151 -0
- package/dist/routing/index.d.ts +29 -0
- package/dist/routing/index.js +385 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/learning/index.d.ts +433 -0
- package/dist/routing/learning/index.js +2501 -0
- package/dist/routing/learning/index.js.map +1 -0
- package/dist/runtime-C6Cu2fvw.d.ts +283 -0
- package/dist/runtime-Y72XJFFO.js +18 -0
- package/dist/runtime-Y72XJFFO.js.map +1 -0
- package/dist/store-types-2YdceOMy.d.ts +78 -0
- package/dist/types-BB7KqceP.d.ts +52 -0
- package/dist/types-BBRKjIc7.d.ts +86 -0
- package/dist/types-DTFc1qO6.d.ts +1065 -0
- package/dist/types-DYex3p7_.d.ts +88 -0
- package/docs/licenses/ruflo-memory-MIT.txt +21 -0
- package/docs/releases/0.1.0-beta.1.md +13 -0
- package/package.json +114 -4
|
@@ -0,0 +1,2385 @@
|
|
|
1
|
+
export { DependencyCycleError, dependencyWaves } from './graph.js';
|
|
2
|
+
import { W as WorkflowStore, a as WorkflowDefinition, c as WorkflowRunOptions, d as WorkflowCheckpoint, e as WorkflowRearmOptions, f as WorkflowRearmResult, b as WorkflowLease, J as JsonValue } from '../types-DYex3p7_.js';
|
|
3
|
+
export { g as WorkflowRearmAcknowledgement, h as WorkflowStep, i as WorkflowStepContext, j as WorkflowStepState } from '../types-DYex3p7_.js';
|
|
4
|
+
import { MemoryPersistencePort, MemoryQueryPort, SystemMemoryOptions, MemoryActor, MemoryStatus, ScopedMemoryRecord, MemoryRecordLookup, MemoryRevocation, MemoryQuery, MemoryListQuery, MemoryRecordView, MemoryPromotion, MemoryPromotionResult, MemoryRollback, MemoryGrantRequest, MemoryGrant, MemoryGrantRevocation, RunLogReader, MemoryLogSearch, MemoryLogSearchResult, MemoryScope, MeasureMemoryOptions, MemoryEmbedder, MemoryConditionTally, MemoryGateRefusal } from './memory.js';
|
|
5
|
+
export { AgentDbMcpProfile, AgentDbMcpServerOptions, EmbeddingIdentity, MAX_LESSONS_CEILING, MAX_LESSONS_PER_RECALL, McpRecipeLaunch, McpServerRecipe, MemoryCaptureGate, MemoryCondition, MemoryConditionSummary, MemoryDocument, MemoryGateEvidence, MemoryGateVerdict, MemoryLogMatch, MemoryMeasurementReport, MemoryMeasurementTask, MemoryPorts, MemoryPortsProviderOptions, MemoryProvenance, MemoryRankingOptions, MemoryRecordState, MemoryRunContext, MemoryRunOutcome, MemoryScores, MemoryStoreError, MemoryStoreErrorCode, MemoryTaskOutcome, RankedMemory, RuvectorMcpProfile, RuvectorMcpServerOptions, agentDbMcpServer, claudeMcpConfig, evaluateMemoryGate, isMemoryStoreError, measureMemory, memoryProviderFromPorts, rankMemories, ruvectorMcpServer } from './memory.js';
|
|
6
|
+
export { M as MEMORY_LABEL_MAX, a as MEMORY_OBSERVED_AT_MAX, i as isMemoryLabel, r as recallableMemory } from '../memory-items-BSTC0_R0.js';
|
|
7
|
+
import { R as Runtime } from '../runtime-C6Cu2fvw.js';
|
|
8
|
+
import { d as AgentOptions, a as Turn, q as AgentInput, p as MemoryOption, g as AgentMemoryProvider, h as AgentMemoryScope, U as Usage, A as AgentEvent, S as SessionRef, ar as ConstraintStore, as as TaskMaterial, at as ContextBudget, au as ConstraintExpectation, av as CompiledContext, aw as PinnedChannel } from '../types-DTFc1qO6.js';
|
|
9
|
+
export { ax as ConstraintAuthority, ay as ConstraintAuthorityError, az as ConstraintConflictError, aA as ConstraintIntegrityError, aB as ConstraintRef, aC as ConstraintRevocation, aD as ConstraintStoreCreateOptions, aE as ConstraintStoreOptions, aF as ConstraintVersion, aG as ConstraintWrite, aH as ContextBudgetError, aI as ContextReference, aJ as HistoryEntry, aK as NothingPinnedError, aL as PinnedConstraint, aM as UnverifiedPinnedChannelError } from '../types-DTFc1qO6.js';
|
|
10
|
+
import { A as Agent } from '../agent-D0HS38G3.js';
|
|
11
|
+
import { O as ObservedTaskBudget } from '../index-B86C6VAD.js';
|
|
12
|
+
export { a as ObservedTaskError, b as ObservedTaskHandle, c as ObservedTaskHooks, d as ObservedTaskStarter, r as runObservedTask } from '../index-B86C6VAD.js';
|
|
13
|
+
import { D as DecisionBinding, b as DecisionStore, m as DecisionRunOptions, a as DecisionRecord, c as DecisionLease, n as TraceStore, o as TraceIdentity, p as TraceRecorder, q as TraceEpisode, r as TraceLease, s as DecisionContext, t as DecisionEffectContext, M as ManagedEffectAssociation } from '../execution-types-UJ6gAF48.js';
|
|
14
|
+
export { u as DecisionAuthorization, v as DecisionReceipt, w as TraceEntry, T as TraceEventInput, x as TraceTerminalStatus, y as TraceWriter } from '../execution-types-UJ6gAF48.js';
|
|
15
|
+
import '../types-BB7KqceP.js';
|
|
16
|
+
import '../store-types-2YdceOMy.js';
|
|
17
|
+
import '../capture-runtime-GP6NZ2ee.js';
|
|
18
|
+
import '../provider-XCpWjJ6a.js';
|
|
19
|
+
import '../errors-DgehLwqI.js';
|
|
20
|
+
import '../execution-halt-CW0Oi9s9.js';
|
|
21
|
+
|
|
22
|
+
/** Executes finite dependency waves, holding a single durable run lease through all active work. */
|
|
23
|
+
declare class WorkflowRunner {
|
|
24
|
+
private readonly store;
|
|
25
|
+
constructor(store: WorkflowStore);
|
|
26
|
+
run(input: WorkflowDefinition, options: WorkflowRunOptions): Promise<WorkflowCheckpoint>;
|
|
27
|
+
/**
|
|
28
|
+
* Resets non-completed steps to pending with zero attempts, under the run lease, so a later `run`
|
|
29
|
+
* executes them again. This is the sanctioned way to spend a new attempt after a cooperative
|
|
30
|
+
* cancellation or an exhausted `maxAttempts`; it never touches completed outputs, and the
|
|
31
|
+
* blocked steps that (transitively) depend on a re-armed step are re-armed with it. The
|
|
32
|
+
* acknowledgement is the caller's explicit statement that repeating the work is acceptable.
|
|
33
|
+
*/
|
|
34
|
+
rearm(input: WorkflowDefinition, options: WorkflowRearmOptions): Promise<WorkflowRearmResult>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface WorkflowOwnership {
|
|
38
|
+
runId: string;
|
|
39
|
+
token: string;
|
|
40
|
+
pid: number;
|
|
41
|
+
host: string;
|
|
42
|
+
}
|
|
43
|
+
declare class WorkflowRunLockedError extends Error {
|
|
44
|
+
readonly runId: string;
|
|
45
|
+
readonly lockPath: string;
|
|
46
|
+
constructor(runId: string, lockPath: string);
|
|
47
|
+
}
|
|
48
|
+
/** Local private-directory store; no network filesystem, distributed fencing or automatic expiry. */
|
|
49
|
+
declare class FileWorkflowStore implements WorkflowStore {
|
|
50
|
+
readonly directory: string;
|
|
51
|
+
constructor(directory: string);
|
|
52
|
+
private paths;
|
|
53
|
+
inspectOwnership(runId: string): Promise<WorkflowOwnership | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* Explicit local crash recovery, never based on age. Refuses a live/reused PID,
|
|
56
|
+
* foreign host or changed token. Caller must ensure orphan external work has stopped.
|
|
57
|
+
* A nonempty tombstone is retained so concurrent recovery cannot move a new owner's lock.
|
|
58
|
+
*/
|
|
59
|
+
recoverAbandoned(runId: string, expectedToken: string, acknowledgement: {
|
|
60
|
+
ownerStopped: true;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
acquire(runId: string): Promise<WorkflowLease>;
|
|
63
|
+
private writeSynced;
|
|
64
|
+
private syncDirectory;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Local launch ceilings chosen by the operator, not a provider's remaining quota. */
|
|
68
|
+
interface LaunchBudgetLimits {
|
|
69
|
+
maxConcurrent: number;
|
|
70
|
+
maxLaunchesPerHour: number;
|
|
71
|
+
maxLaunchesPerDay: number;
|
|
72
|
+
quotaCooldownMs: number;
|
|
73
|
+
}
|
|
74
|
+
interface SharedLaunchBudgetOptions {
|
|
75
|
+
/** All cooperating applications must use the same absolute, local SQLite file. */
|
|
76
|
+
databasePath: string;
|
|
77
|
+
/** Explicit keys must identify both provider and account/quota owner. No defaults. */
|
|
78
|
+
providers: Readonly<Record<string, LaunchBudgetLimits>>;
|
|
79
|
+
/** Maximum synchronous SQLite lock wait. Default 1000 ms; zero fails immediately. */
|
|
80
|
+
busyTimeoutMs?: number;
|
|
81
|
+
}
|
|
82
|
+
type BudgetDenialReason = 'unknown-provider' | 'configuration-mismatch' | 'invalid-input' | 'storage-unavailable' | 'closed' | 'clock-rollback' | 'concurrency-limit' | 'hourly-limit' | 'daily-limit' | 'quota-cooldown';
|
|
83
|
+
interface BudgetFailure {
|
|
84
|
+
reason: BudgetDenialReason;
|
|
85
|
+
detail?: string;
|
|
86
|
+
/** Epoch milliseconds. `quota-cooldown`: when the pause ends. `clock-rollback`: the ledger's last
|
|
87
|
+
* observed time; admission resumes once the system clock reaches it or `acknowledgeClock` runs.
|
|
88
|
+
* A refused acknowledgement instead returns when potentially pruned history expires; retrying
|
|
89
|
+
* acknowledgement then is safe, but ordinary admission still respects the observed clock. */
|
|
90
|
+
retryAt?: number;
|
|
91
|
+
/** With `concurrency-limit`: a slot was free, but a waiting launch of higher priority is entitled to it. */
|
|
92
|
+
outranked?: true;
|
|
93
|
+
}
|
|
94
|
+
/** An operator verified the system clock and accepts that nothing is refunded (see `acknowledgeClock`). */
|
|
95
|
+
interface ClockAcknowledgement {
|
|
96
|
+
operatorConfirmed: true;
|
|
97
|
+
}
|
|
98
|
+
interface LaunchReservation {
|
|
99
|
+
/** Bearer token: only release once the operation has actually stopped. */
|
|
100
|
+
token: string;
|
|
101
|
+
providerKey: string;
|
|
102
|
+
owner: string;
|
|
103
|
+
admittedAt: number;
|
|
104
|
+
}
|
|
105
|
+
type LaunchAdmission = {
|
|
106
|
+
allowed: true;
|
|
107
|
+
reservation: LaunchReservation;
|
|
108
|
+
} | ({
|
|
109
|
+
allowed: false;
|
|
110
|
+
} & BudgetFailure);
|
|
111
|
+
type BudgetResult<T> = ({
|
|
112
|
+
ok: true;
|
|
113
|
+
} & T) | ({
|
|
114
|
+
ok: false;
|
|
115
|
+
} & BudgetFailure);
|
|
116
|
+
interface LaunchBudgetStatus {
|
|
117
|
+
providerKey: string;
|
|
118
|
+
limits: LaunchBudgetLimits;
|
|
119
|
+
active: number;
|
|
120
|
+
launchesLastHour: number;
|
|
121
|
+
launchesLastDay: number;
|
|
122
|
+
pausedUntil: number | null;
|
|
123
|
+
/** Includes crashed owners. Verify they stopped before explicitly recovering a token. */
|
|
124
|
+
reservations: LaunchReservation[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Finite launch fuse shared by cooperating processes. Active holds never expire or refund launches. */
|
|
128
|
+
declare class SharedLaunchBudget {
|
|
129
|
+
#private;
|
|
130
|
+
constructor(options: SharedLaunchBudgetOptions);
|
|
131
|
+
reserve(providerKey: string, owner: string): LaunchAdmission;
|
|
132
|
+
release(token: string): BudgetResult<{
|
|
133
|
+
released: boolean;
|
|
134
|
+
}>;
|
|
135
|
+
recordQuotaError(providerKey: string): BudgetResult<{
|
|
136
|
+
pausedUntil: number;
|
|
137
|
+
}>;
|
|
138
|
+
status(providerKey: string): BudgetResult<{
|
|
139
|
+
status: LaunchBudgetStatus;
|
|
140
|
+
}>;
|
|
141
|
+
/** Explicit operator clock recovery never refunds holds/history or reopens pruned windows. */
|
|
142
|
+
acknowledgeClock(providerKey: string, acknowledgement: ClockAcknowledgement): BudgetResult<{
|
|
143
|
+
previousObservedAt: number;
|
|
144
|
+
acknowledgedAt: number;
|
|
145
|
+
}>;
|
|
146
|
+
close(): void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
type HostConcurrency = {
|
|
150
|
+
mode: 'limited';
|
|
151
|
+
maxConcurrent: number;
|
|
152
|
+
} | {
|
|
153
|
+
mode: 'unlimited';
|
|
154
|
+
};
|
|
155
|
+
interface ConcurrencyPolicy {
|
|
156
|
+
revision: number;
|
|
157
|
+
concurrency: HostConcurrency;
|
|
158
|
+
}
|
|
159
|
+
interface ConcurrencyChange {
|
|
160
|
+
expectedRevision: number;
|
|
161
|
+
concurrency: HostConcurrency;
|
|
162
|
+
}
|
|
163
|
+
type HostLaunchBudgetLimits = Omit<LaunchBudgetLimits, 'maxConcurrent'> & {
|
|
164
|
+
concurrency: HostConcurrency;
|
|
165
|
+
};
|
|
166
|
+
type HostLaunchBudgetStatus = Omit<LaunchBudgetStatus, 'limits'> & {
|
|
167
|
+
limits: HostLaunchBudgetLimits;
|
|
168
|
+
};
|
|
169
|
+
interface HostLedgerOptions {
|
|
170
|
+
databasePath?: string;
|
|
171
|
+
concurrency?: HostConcurrency;
|
|
172
|
+
providers?: Readonly<Record<string, HostLaunchBudgetLimits>>;
|
|
173
|
+
busyTimeoutMs?: number;
|
|
174
|
+
}
|
|
175
|
+
type HostLaunchAdmission = LaunchAdmission | {
|
|
176
|
+
allowed: false;
|
|
177
|
+
reason: 'wait-timeout';
|
|
178
|
+
};
|
|
179
|
+
type HostLaunchDenial = Extract<HostLaunchAdmission, {
|
|
180
|
+
allowed: false;
|
|
181
|
+
}>;
|
|
182
|
+
/** `low` is for canaries and evaluation runs: it never takes a slot a waiting `normal` launch is entitled to. */
|
|
183
|
+
type LaunchPriority = 'normal' | 'low';
|
|
184
|
+
interface AcquireOptions {
|
|
185
|
+
maxWaitMs: number;
|
|
186
|
+
signal?: AbortSignal;
|
|
187
|
+
priority?: LaunchPriority;
|
|
188
|
+
}
|
|
189
|
+
interface SlotOptions extends AcquireOptions {
|
|
190
|
+
isQuotaError?: (error: unknown) => boolean;
|
|
191
|
+
}
|
|
192
|
+
/** Trusted host inspection only. Tokens must never cross the worker/model boundary. */
|
|
193
|
+
type HostOwnerReservation = Readonly<LaunchReservation & {
|
|
194
|
+
released: boolean;
|
|
195
|
+
}>;
|
|
196
|
+
interface HostOwnerLookupOptions {
|
|
197
|
+
limit: number;
|
|
198
|
+
}
|
|
199
|
+
interface HostOwnerLookup {
|
|
200
|
+
reservations: readonly HostOwnerReservation[];
|
|
201
|
+
truncated: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** Measured local storage binding only; neither a lease nor permission to release work. */
|
|
204
|
+
interface HostLedgerIdentity {
|
|
205
|
+
readonly format: 1;
|
|
206
|
+
readonly digest: string;
|
|
207
|
+
}
|
|
208
|
+
interface HostRecoveryOptions {
|
|
209
|
+
ownerPrefix: string;
|
|
210
|
+
/** Exact previously inspected bearer tokens; never infer these from a prefix at recovery time. */
|
|
211
|
+
tokens: readonly string[];
|
|
212
|
+
acknowledgement: {
|
|
213
|
+
workStopped: true;
|
|
214
|
+
evidenceDigest: string;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
declare class LaunchRefusedError extends Error {
|
|
218
|
+
readonly admission: HostLaunchDenial;
|
|
219
|
+
constructor(admission: HostLaunchDenial);
|
|
220
|
+
}
|
|
221
|
+
/** A failed durable release is a halt condition, including when the operation also failed. */
|
|
222
|
+
declare class LaunchReleaseError extends Error {
|
|
223
|
+
readonly failure: BudgetFailure;
|
|
224
|
+
constructor(failure: BudgetFailure, cause?: unknown);
|
|
225
|
+
}
|
|
226
|
+
/** The observed provider quota error could not be durably recorded; callers must halt admission. */
|
|
227
|
+
declare class LaunchQuotaRecordError extends Error {
|
|
228
|
+
readonly failure: BudgetFailure;
|
|
229
|
+
constructor(failure: BudgetFailure, cause?: unknown);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface LegacyMigrationSource {
|
|
233
|
+
databasePath: string;
|
|
234
|
+
ownerPrefix: string;
|
|
235
|
+
}
|
|
236
|
+
interface LegacyMigrationOptions extends LegacyMigrationSource {
|
|
237
|
+
expectedDigest: string;
|
|
238
|
+
/** Trusted operator acknowledgement; the ledger cannot prove process termination. */
|
|
239
|
+
sourceStoppedConfirmed: true;
|
|
240
|
+
}
|
|
241
|
+
/** Safe to display: contains counts and a digest, never bearer tokens or run owners. */
|
|
242
|
+
declare function inspectLegacyLaunchBudget(databasePath: string): {
|
|
243
|
+
sourceDigest: string;
|
|
244
|
+
providers: {
|
|
245
|
+
providerKey: string;
|
|
246
|
+
reservations: number;
|
|
247
|
+
active: number;
|
|
248
|
+
}[];
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
declare function hostLaunchLimits(concurrency: HostConcurrency): HostLaunchBudgetLimits;
|
|
252
|
+
declare const HOST_LAUNCH_LIMITS: HostLaunchBudgetLimits;
|
|
253
|
+
declare function hostLedgerPath(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* How long a waiter's declaration counts without being renewed. A waiting `acquire` renews it on
|
|
257
|
+
* every attempt, and attempts are at most 30 seconds apart, so only a process that died or stalled
|
|
258
|
+
* lets it lapse. A lapsed declaration gives up precedence; it never frees or grants a slot.
|
|
259
|
+
*/
|
|
260
|
+
declare const WAITER_LEASE_MS = 90000;
|
|
261
|
+
|
|
262
|
+
/** Trusted local coordination for cooperating processes; this is not a vendor quota or authorization boundary. */
|
|
263
|
+
declare class HostLedger {
|
|
264
|
+
#private;
|
|
265
|
+
constructor(options?: HostLedgerOptions);
|
|
266
|
+
/** One immediate attempt. A `low` priority is refused while a `normal` launch is waiting for the slot. */
|
|
267
|
+
reserve(providerKey: string, owner: string, priority?: LaunchPriority): HostLaunchAdmission;
|
|
268
|
+
release(token: string): BudgetResult<{
|
|
269
|
+
released: boolean;
|
|
270
|
+
}>;
|
|
271
|
+
recordQuotaError(providerKey: string, retryAtMs?: number): BudgetResult<{
|
|
272
|
+
pausedUntil: number;
|
|
273
|
+
}>;
|
|
274
|
+
status(providerKey: string): BudgetResult<{
|
|
275
|
+
status: HostLaunchBudgetStatus;
|
|
276
|
+
}>;
|
|
277
|
+
getConcurrency(providerKey: string): BudgetResult<{
|
|
278
|
+
policy: ConcurrencyPolicy;
|
|
279
|
+
}>;
|
|
280
|
+
setConcurrency(providerKey: string, change: ConcurrencyChange): BudgetResult<{
|
|
281
|
+
policy: ConcurrencyPolicy;
|
|
282
|
+
}>;
|
|
283
|
+
/** Private host evidence discovery, not an authorization or stopped-work proof; default bound detects duplicate owners. */
|
|
284
|
+
lookupOwner(providerKey: string, owner: string, options?: HostOwnerLookupOptions): BudgetResult<HostOwnerLookup>;
|
|
285
|
+
/** Opaque identity of the actual pinned local database, never worker-supplied authority or stopped-work evidence. */
|
|
286
|
+
storageIdentity(): BudgetResult<{
|
|
287
|
+
identity: HostLedgerIdentity;
|
|
288
|
+
}>;
|
|
289
|
+
recover(options: HostRecoveryOptions): BudgetResult<{
|
|
290
|
+
released: number;
|
|
291
|
+
}>;
|
|
292
|
+
verifyLegacyMigration(options: LegacyMigrationSource): BudgetResult<{
|
|
293
|
+
matched: boolean;
|
|
294
|
+
sourceDigest: string;
|
|
295
|
+
}>;
|
|
296
|
+
importLegacy(options: LegacyMigrationOptions): BudgetResult<{
|
|
297
|
+
imported: number;
|
|
298
|
+
sourceDigest: string;
|
|
299
|
+
}>;
|
|
300
|
+
close(): void;
|
|
301
|
+
acquire(providerKey: string, owner: string, options: AcquireOptions): Promise<HostLaunchAdmission>;
|
|
302
|
+
withSlot<T>(providerKey: string, owner: string, options: SlotOptions, operation: () => Promise<T>): Promise<T>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** One active hold, without its bearer token. */
|
|
306
|
+
interface HostHoldView {
|
|
307
|
+
owner: string;
|
|
308
|
+
admittedAt: number;
|
|
309
|
+
}
|
|
310
|
+
interface HostProviderView {
|
|
311
|
+
providerKey: string;
|
|
312
|
+
concurrency: {
|
|
313
|
+
mode: 'limited';
|
|
314
|
+
maxConcurrent: number;
|
|
315
|
+
} | {
|
|
316
|
+
mode: 'unlimited';
|
|
317
|
+
};
|
|
318
|
+
maxLaunchesPerHour: number;
|
|
319
|
+
maxLaunchesPerDay: number;
|
|
320
|
+
launchesLastHour: number;
|
|
321
|
+
launchesLastDay: number;
|
|
322
|
+
/** Epoch ms while a quota pause is running; null otherwise. */
|
|
323
|
+
pausedUntil: number | null;
|
|
324
|
+
active: HostHoldView[];
|
|
325
|
+
/** Launches declared as waiting for a slot of this provider: `normal` is production, `low` is a canary or trial. */
|
|
326
|
+
waiting: {
|
|
327
|
+
normal: number;
|
|
328
|
+
low: number;
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
type HostLedgerView = {
|
|
332
|
+
ok: true;
|
|
333
|
+
readAt: number;
|
|
334
|
+
providers: HostProviderView[];
|
|
335
|
+
} | {
|
|
336
|
+
ok: false;
|
|
337
|
+
reason: 'absent' | 'unrecognized' | 'unavailable';
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* What the shared admission ledger holds right now, for a screen. Opens the file read-only, so it
|
|
341
|
+
* needs no concurrency policy, never creates or migrates the file, never touches the clock mark and
|
|
342
|
+
* can never refuse a launch. Tokens stay inside the ledger.
|
|
343
|
+
*/
|
|
344
|
+
declare function readHostLedgerView(databasePath: string, now?: number): HostLedgerView;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* One system's handle on the shared memory database.
|
|
348
|
+
*
|
|
349
|
+
* What a caller can rely on:
|
|
350
|
+
* - Memory is off until `enable`: reads of memory are empty and writes are
|
|
351
|
+
* refused. The two administrative reads that stay are `status` and the grants
|
|
352
|
+
* the system itself gave (`listGrants`).
|
|
353
|
+
* - A record lives in an exact scope (tenant = system id, namespace, subject) and
|
|
354
|
+
* always carries provenance pointing at its source.
|
|
355
|
+
* - Reads are deny-by-default: another system gets nothing unless the owner
|
|
356
|
+
* granted that exact scope, and a grant shares recall (`query`) only.
|
|
357
|
+
* - An observation is an immutable episode. Only `promote`, with a gate that
|
|
358
|
+
* passed, makes it a lesson that `query` returns; at most a few per recall.
|
|
359
|
+
* - `revoke` and `rollback` are final and take effect on every read at once,
|
|
360
|
+
* for every connection: there is no cache between a read and the database.
|
|
361
|
+
* - A record's `supersedes` takes effect only when the record is promoted: then
|
|
362
|
+
* every lesson it names is invalidated in the same transaction, for good, and
|
|
363
|
+
* `query` never returns it again. A record past its `validUntil` is never
|
|
364
|
+
* returned by `query` and cannot be promoted.
|
|
365
|
+
* - A withdrawal covers the source, not only the record id. When the withdrawn
|
|
366
|
+
* record was taken from a log entry, that entry is withdrawn as a whole:
|
|
367
|
+
* `searchLog` stops returning it, every other record taken from it stops being
|
|
368
|
+
* returned by `query` and `list`, and nothing taken from it can be stored or
|
|
369
|
+
* promoted again.
|
|
370
|
+
*/
|
|
371
|
+
declare class SqliteSystemMemory implements MemoryPersistencePort, MemoryQueryPort {
|
|
372
|
+
#private;
|
|
373
|
+
readonly systemId: string;
|
|
374
|
+
constructor(options: SystemMemoryOptions);
|
|
375
|
+
/** Switches this system's memory on. Recorded with who did it and when. */
|
|
376
|
+
enable(actor: MemoryActor): Promise<void>;
|
|
377
|
+
/** Switches it off: every read of this system's memory, by anyone, is empty at once. Nothing is deleted. */
|
|
378
|
+
disable(actor: MemoryActor): Promise<void>;
|
|
379
|
+
status(): Promise<MemoryStatus>;
|
|
380
|
+
/**
|
|
381
|
+
* Stores an observation as an immutable episode in the owner's exact scope.
|
|
382
|
+
* Storing the same content again is a no-op; different content under the same
|
|
383
|
+
* id is CONFLICT; a withdrawn id, or a log entry whose record was withdrawn,
|
|
384
|
+
* is WITHDRAWN and cannot come back.
|
|
385
|
+
*
|
|
386
|
+
* Provenance is checked for shape, not against its source: this call has no
|
|
387
|
+
* handle on the log, so it cannot tell that the entry exists or says what the
|
|
388
|
+
* text says. A withdrawal can reach the log entry only if the record names it:
|
|
389
|
+
* store what came from `searchLog` with that match's position as `logPosition`.
|
|
390
|
+
*/
|
|
391
|
+
put(record: ScopedMemoryRecord, signal?: AbortSignal): Promise<void>;
|
|
392
|
+
/**
|
|
393
|
+
* The owner's read-back of one record, episode or lesson, as stored: undefined when there is
|
|
394
|
+
* none, it is withdrawn, memory is off, or the scope is another system's (grant or not). For a
|
|
395
|
+
* writer that met CONFLICT on `put`; recall is `query`.
|
|
396
|
+
*/
|
|
397
|
+
get(lookup: MemoryRecordLookup): Promise<ScopedMemoryRecord | undefined>;
|
|
398
|
+
/**
|
|
399
|
+
* Withdraws a record for good. Allowed while memory is off: forgetting never
|
|
400
|
+
* requires switching memory on. Revoking again keeps the first tombstone.
|
|
401
|
+
*/
|
|
402
|
+
revoke(revocation: MemoryRevocation, signal?: AbortSignal): Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Recall: the promoted lessons of one exact scope, ranked against the text.
|
|
405
|
+
* Own scope, or another system's scope through a live grant; anything else is
|
|
406
|
+
* empty. Never more than `maxLessonsPerRecall`, whatever `limit` asks for.
|
|
407
|
+
*/
|
|
408
|
+
query(query: MemoryQuery): Promise<readonly ScopedMemoryRecord[]>;
|
|
409
|
+
/**
|
|
410
|
+
* The owner's view of one exact scope: episodes, lessons, invalidated and expired
|
|
411
|
+
* records, newest first, with the promotion evidence of each lesson and the
|
|
412
|
+
* invalidation of each superseded one. Withdrawn records are not listed. Other
|
|
413
|
+
* systems get nothing, grant or not.
|
|
414
|
+
*/
|
|
415
|
+
list(query: MemoryListQuery): Promise<readonly MemoryRecordView[]>;
|
|
416
|
+
/**
|
|
417
|
+
* Makes an episode recallable, if and only if the gate passed: the evidence must
|
|
418
|
+
* hold both controls, must have measured this record (it names the record's
|
|
419
|
+
* content digest, which binds scope, id and content), and memory must beat the
|
|
420
|
+
* no-memory control. A refusal is a normal result and changes nothing.
|
|
421
|
+
*
|
|
422
|
+
* A record past its `validUntil` is EXPIRED. A record that supersedes others
|
|
423
|
+
* retires them here, in this transaction, at the promotion time; when any of
|
|
424
|
+
* them is not a live lesson of this scope the promotion is INVALID_SUPERSESSION
|
|
425
|
+
* and nothing changes. A retried promotion returns the first one.
|
|
426
|
+
*/
|
|
427
|
+
promote(promotion: MemoryPromotion): Promise<MemoryPromotionResult>;
|
|
428
|
+
/**
|
|
429
|
+
* Reverses a promotion after a measured regression. Final, like a revocation:
|
|
430
|
+
* no read path returns the lesson again and it cannot be promoted again.
|
|
431
|
+
* Allowed while memory is off.
|
|
432
|
+
*/
|
|
433
|
+
rollback(rollback: MemoryRollback): Promise<void>;
|
|
434
|
+
/**
|
|
435
|
+
* Lets another system recall this system's lessons in one exact scope. Recorded
|
|
436
|
+
* with who granted it and when. Granting a scope that is already granted returns
|
|
437
|
+
* the live grant.
|
|
438
|
+
*/
|
|
439
|
+
grant(request: MemoryGrantRequest): Promise<MemoryGrant>;
|
|
440
|
+
/** Ends a grant this system gave. The grantee's next read is empty. Final; grant again to share again. */
|
|
441
|
+
revokeGrant(revocation: MemoryGrantRevocation): Promise<void>;
|
|
442
|
+
/**
|
|
443
|
+
* Grant metadata: no memory text, but namespace and subject are names the owner chose.
|
|
444
|
+
* - Every grant this system gave, live or revoked, whether its memory is on or
|
|
445
|
+
* off: its own administrative record, needed to revoke a grant while off.
|
|
446
|
+
* - The grants it received that it can use right now: live, and with both
|
|
447
|
+
* systems' memory on. A revoked grant, or either switch off, hides them.
|
|
448
|
+
*/
|
|
449
|
+
listGrants(): Promise<readonly MemoryGrant[]>;
|
|
450
|
+
/**
|
|
451
|
+
* Plain-text search over this system's own run log, the first form of recall.
|
|
452
|
+
* Each match carries its log position, ready to be a record's provenance.
|
|
453
|
+
* Empty while memory is off, for a log of another system, and for any entry
|
|
454
|
+
* whose memory record was revoked or rolled back.
|
|
455
|
+
*
|
|
456
|
+
* One call reads one window of the log (`maxScanned` entries) and returns its
|
|
457
|
+
* best `limit` matches. When the window held more, the result says so
|
|
458
|
+
* (`truncated`, `found`): see `MemoryLogSearchResult` for how to get the rest.
|
|
459
|
+
*/
|
|
460
|
+
searchLog(log: RunLogReader, search: MemoryLogSearch): Promise<MemoryLogSearchResult>;
|
|
461
|
+
close(): void;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** The shared memory file of the machine: `OAR_HOST_MEMORY`, or `memory.sqlite` beside the ledger. */
|
|
465
|
+
declare function hostMemoryPath(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
|
|
466
|
+
/** One grant as a screen shows it: `other` is the system on the far side. Names only, never memory text. */
|
|
467
|
+
interface MemoryGrantLine {
|
|
468
|
+
id: string;
|
|
469
|
+
other: string;
|
|
470
|
+
namespace: string;
|
|
471
|
+
subject: string;
|
|
472
|
+
at: number;
|
|
473
|
+
by: string;
|
|
474
|
+
/** True while it can be used: not revoked and both systems have memory on. */
|
|
475
|
+
active: boolean;
|
|
476
|
+
revokedAt?: number;
|
|
477
|
+
}
|
|
478
|
+
interface MemorySystemView {
|
|
479
|
+
systemId: string;
|
|
480
|
+
enabled: boolean;
|
|
481
|
+
/** Records still readable (not withdrawn), episodes and lessons together, invalidated and expired ones included. */
|
|
482
|
+
observations: number;
|
|
483
|
+
/**
|
|
484
|
+
* What recall can return right now: promoted records that no newer promoted record has
|
|
485
|
+
* invalidated and whose `validUntil` has not passed at the view's `now`. A file without the
|
|
486
|
+
* temporal columns (never opened by a build that knows them) has neither, so every promoted
|
|
487
|
+
* record there counts.
|
|
488
|
+
*/
|
|
489
|
+
lessons: number;
|
|
490
|
+
given: MemoryGrantLine[];
|
|
491
|
+
received: MemoryGrantLine[];
|
|
492
|
+
/** Epoch ms of the last change of the switch; absent when nobody ever switched it. */
|
|
493
|
+
changedAt?: number;
|
|
494
|
+
changedBy?: string;
|
|
495
|
+
}
|
|
496
|
+
type MemoryView = {
|
|
497
|
+
ok: true;
|
|
498
|
+
readAt: number;
|
|
499
|
+
systems: MemorySystemView[];
|
|
500
|
+
} | {
|
|
501
|
+
ok: false;
|
|
502
|
+
reason: 'absent' | 'unrecognized' | 'unavailable';
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* What the shared memory holds per system, for a screen: switch, counts and grants, never any
|
|
506
|
+
* memory text. Opens the file read-only; never creates, migrates or changes it.
|
|
507
|
+
*/
|
|
508
|
+
declare function readMemoryView(databasePath: string, now?: number): MemoryView;
|
|
509
|
+
|
|
510
|
+
type StopReason = 'aborted' | 'deadline';
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* The curator journal's entries and their validation: journals hold untrusted data, so every
|
|
514
|
+
* entry read or written is checked here (JOURNAL_INVALID otherwise).
|
|
515
|
+
*/
|
|
516
|
+
/** The counts of a pending candidate's first measurement: no text. */
|
|
517
|
+
interface CuratorPendingTally {
|
|
518
|
+
/** Digest of the first measurement report. */
|
|
519
|
+
digest: string;
|
|
520
|
+
/** Content digest of the record measured: a confirmation of another content is not pooled with it. */
|
|
521
|
+
contentDigest: string;
|
|
522
|
+
noMemory: {
|
|
523
|
+
passed: number;
|
|
524
|
+
total: number;
|
|
525
|
+
};
|
|
526
|
+
memory: {
|
|
527
|
+
passed: number;
|
|
528
|
+
total: number;
|
|
529
|
+
};
|
|
530
|
+
fullHistory: {
|
|
531
|
+
passed: number;
|
|
532
|
+
total: number;
|
|
533
|
+
};
|
|
534
|
+
discordant: {
|
|
535
|
+
memoryOnly: number;
|
|
536
|
+
noMemoryOnly: number;
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
interface CuratorJournalEntry {
|
|
540
|
+
/** Last decision for this key. */
|
|
541
|
+
outcome: 'refused' | 'promoted' | 'rolled-back' | 'pending';
|
|
542
|
+
/** ISO time it was recorded. */
|
|
543
|
+
at: string;
|
|
544
|
+
/** Candidate keys: the refusal code. */
|
|
545
|
+
reason?: string;
|
|
546
|
+
/** Episode keys: ids of the promoted candidates that cite this episode. */
|
|
547
|
+
promoted?: string[];
|
|
548
|
+
/** Episode keys: those of `promoted` found withdrawn (rolled back or revoked) since. */
|
|
549
|
+
rolledBack?: string[];
|
|
550
|
+
/** Episode keys: the episode is not offered to `distill` before this ISO time. */
|
|
551
|
+
cooldownUntil?: string;
|
|
552
|
+
/** Budget keys: ISO times of the scope's promotions (reserved before the store is asked) less than a day old, later ones included. */
|
|
553
|
+
promotedAt?: string[];
|
|
554
|
+
/** Measurement budget keys: ISO times of the scope's measurements (reserved before each runs) less than a day old. */
|
|
555
|
+
measuredAt?: string[];
|
|
556
|
+
/** Candidate keys: the sketch of the candidate's text, so a withdrawal can cool down its paraphrases. */
|
|
557
|
+
sketch?: string;
|
|
558
|
+
/** Pending candidate keys: the first measurement. */
|
|
559
|
+
tally?: CuratorPendingTally;
|
|
560
|
+
/** Pending candidate keys: refused as CONFIRMATION_EXPIRED when not confirmed by this ISO time. */
|
|
561
|
+
pendingUntil?: string;
|
|
562
|
+
/** Pending index keys: ids of the scope's pending candidates, oldest first. */
|
|
563
|
+
pending?: string[];
|
|
564
|
+
/** Rejection index keys: sketches of recently refused or withdrawn candidates, and when each stops holding paraphrases back. */
|
|
565
|
+
rejected?: {
|
|
566
|
+
until: string;
|
|
567
|
+
sketch: string;
|
|
568
|
+
}[];
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* The curator's journal: what earlier passes decided, so a later pass does not retry it.
|
|
573
|
+
*
|
|
574
|
+
* Seven kinds of key, none holding text: a candidate (`candidate:<candidate id>`, which already
|
|
575
|
+
* binds scope and text), a source episode by id (`episode:<digest of scope and episode id>`), a
|
|
576
|
+
* source episode by content (`content:<digest of scope and normalized text>`), shared by every
|
|
577
|
+
* episode of that text, a scope's promotion budget (`promotions:<digest of scope>`), its
|
|
578
|
+
* measurement budget (`measurements:<digest of scope>`), its pending candidates
|
|
579
|
+
* (`pending:<digest of scope>`) and its recent rejections (`rejected:<digest of scope>`), kept as
|
|
580
|
+
* sketches: sorted, truncated hashes of the normalized words of each text, salted by the scope.
|
|
581
|
+
* A sketch, like a candidate id, holds no text, but a dictionary of likely words can be tested
|
|
582
|
+
* against it: keep the journal as private as the store.
|
|
583
|
+
* A journal lost or reset only loses retry protection; it never promotes anything by itself.
|
|
584
|
+
*
|
|
585
|
+
* File format 2 adds the pending, measurement and rejection entries; format 1 files are read as they are.
|
|
586
|
+
*/
|
|
587
|
+
interface CuratorJournal {
|
|
588
|
+
get(key: string): Promise<CuratorJournalEntry | undefined>;
|
|
589
|
+
set(key: string, entry: CuratorJournalEntry): Promise<void>;
|
|
590
|
+
/**
|
|
591
|
+
* Optional: replaces the entry with `change(current entry)` as one step. The curator uses it for
|
|
592
|
+
* the scope-wide entries (budgets, pending and rejection indexes) when present; a file journal
|
|
593
|
+
* applies it under its lock on the entry it has just re-read, so passes in separate processes
|
|
594
|
+
* do not lose each other's reservations. Without it the curator reads, then sets.
|
|
595
|
+
*/
|
|
596
|
+
update?(key: string, change: (entry: CuratorJournalEntry | undefined) => CuratorJournalEntry): Promise<CuratorJournalEntry>;
|
|
597
|
+
}
|
|
598
|
+
interface CuratorJournalOptions {
|
|
599
|
+
/**
|
|
600
|
+
* Entries kept; past it the least recently written go first. Default 10 000, at most 200 000. A file journal
|
|
601
|
+
* also drops its least recently written entries while the file would exceed 64 MiB, the most it reads back.
|
|
602
|
+
*/
|
|
603
|
+
maxEntries?: number;
|
|
604
|
+
}
|
|
605
|
+
/** A journal held in memory: it lasts as long as the object. */
|
|
606
|
+
declare function memoryCuratorJournal(options?: CuratorJournalOptions): CuratorJournal;
|
|
607
|
+
/**
|
|
608
|
+
* A journal kept in one JSON file, so retry protections survive restarts. Every `set` rewrites
|
|
609
|
+
* the file atomically (a temporary file in the same directory, then a rename) with mode 0600,
|
|
610
|
+
* dropping the least recently written entries while the file would exceed 64 MiB (the most a
|
|
611
|
+
* read accepts). An unreadable or invalid file fails every call with JOURNAL_INVALID
|
|
612
|
+
* (fail-closed: fix or delete it).
|
|
613
|
+
*
|
|
614
|
+
* Journals opened on one path in one process share one state (keyed by the resolved path) and
|
|
615
|
+
* one write queue. Every `set` takes an advisory lock file (`<path>.lock`, created exclusively),
|
|
616
|
+
* re-reads the file if anything else wrote it, applies its entry and writes the result, so
|
|
617
|
+
* writers in separate processes merge instead of overwriting each other. A lock older than 30 s
|
|
618
|
+
* is taken as abandoned and broken; a `set` that cannot take the lock within 5 s fails with
|
|
619
|
+
* JOURNAL_LOCKED and changes nothing, and so at once does one that finds anything but a regular
|
|
620
|
+
* file at `<path>.lock` (a symlink, even a dangling one, is refused, never followed or broken). `get` re-reads the file when its identity, size or mtime
|
|
621
|
+
* changed. The lock is advisory: a writer that ignores it can still lose entries.
|
|
622
|
+
*/
|
|
623
|
+
declare function fileCuratorJournal(path: string, options?: CuratorJournalOptions): CuratorJournal;
|
|
624
|
+
|
|
625
|
+
/** Provenance `source` of every candidate the curator stores. */
|
|
626
|
+
declare const CURATOR_SOURCE = "curator";
|
|
627
|
+
declare const CURATOR_DEFAULT_MAX_CANDIDATES = 3;
|
|
628
|
+
declare const CURATOR_MAX_CANDIDATES_CEILING = 8;
|
|
629
|
+
declare const CURATOR_DEFAULT_MAX_TEXT = 1000;
|
|
630
|
+
/** Half of `MEMORY_DEFAULT_MAX_BYTES`: a lesson fits the default recall budget with room for its header. */
|
|
631
|
+
declare const CURATOR_MAX_TEXT_CEILING = 4096;
|
|
632
|
+
/**
|
|
633
|
+
* What the curator needs from a store, structurally: `SqliteSystemMemory` and the
|
|
634
|
+
* vector stores of `hiveagents-runtime-agentdb-memory` both have it. `list` must
|
|
635
|
+
* report each record's `contentDigest` as the store's `promote` checks it, newest first,
|
|
636
|
+
* and leave out withdrawn (revoked, rolled back) records.
|
|
637
|
+
*/
|
|
638
|
+
interface CuratableStore {
|
|
639
|
+
list(query: MemoryListQuery): Promise<readonly MemoryRecordView[]>;
|
|
640
|
+
put(record: ScopedMemoryRecord, signal?: AbortSignal): Promise<void>;
|
|
641
|
+
promote(promotion: MemoryPromotion): Promise<MemoryPromotionResult>;
|
|
642
|
+
}
|
|
643
|
+
/** One unpromoted episode as `distill` sees it. Its text is untrusted data. */
|
|
644
|
+
interface CuratorEpisode {
|
|
645
|
+
readonly id: string;
|
|
646
|
+
readonly text: string;
|
|
647
|
+
readonly source: string;
|
|
648
|
+
readonly observedAt: string;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* A lesson `distill` proposes; `sources` are ids of the episodes it was drawn from.
|
|
652
|
+
* A `title` is checked (a memory label) but never stored: recall would render it, and the
|
|
653
|
+
* gate measures the text alone.
|
|
654
|
+
*/
|
|
655
|
+
interface CuratorProposal {
|
|
656
|
+
readonly text: string;
|
|
657
|
+
readonly title?: string;
|
|
658
|
+
readonly sources: readonly string[];
|
|
659
|
+
}
|
|
660
|
+
interface CuratorDistillContext {
|
|
661
|
+
readonly scope: MemoryScope;
|
|
662
|
+
/** Aborts on the caller's signal or the pass deadline; the pass stops waiting either way. */
|
|
663
|
+
readonly signal: AbortSignal;
|
|
664
|
+
/** At most this many proposals are considered. */
|
|
665
|
+
readonly maxCandidates: number;
|
|
666
|
+
}
|
|
667
|
+
type CuratorDistill = (episodes: readonly CuratorEpisode[], context: CuratorDistillContext) => Promise<readonly CuratorProposal[]>;
|
|
668
|
+
interface CurateMemoryOptions {
|
|
669
|
+
store: CuratableStore;
|
|
670
|
+
scope: MemoryScope;
|
|
671
|
+
distill: CuratorDistill;
|
|
672
|
+
/** Recorded as `provenance.sourceVersion` of each candidate: which distiller (model, prompt revision) wrote it. */
|
|
673
|
+
distillerId: string;
|
|
674
|
+
/** Exactly what `measureMemory` takes; each candidate is the only memory of the `memory` condition. */
|
|
675
|
+
tasks: MeasureMemoryOptions['tasks'];
|
|
676
|
+
run: MeasureMemoryOptions['run'];
|
|
677
|
+
history: MeasureMemoryOptions['history'];
|
|
678
|
+
/** Recorded as the promoter. Default: `curator`. */
|
|
679
|
+
by?: string;
|
|
680
|
+
/** Needed by a store that refuses records without a vector, such as the agentdb-memory stores. */
|
|
681
|
+
embedder?: MemoryEmbedder;
|
|
682
|
+
/** Candidates measured per pass: default 3, at most 8. */
|
|
683
|
+
maxCandidates?: number;
|
|
684
|
+
/** Newest eligible episodes handed to `distill`: default 32, at most 256. */
|
|
685
|
+
maxEpisodes?: number;
|
|
686
|
+
/** Longest candidate text, in characters: default 1000, at most 4096. */
|
|
687
|
+
maxTextChars?: number;
|
|
688
|
+
/** Whole-pass deadline in milliseconds. Default: 30 minutes. */
|
|
689
|
+
deadlineMs?: number;
|
|
690
|
+
/**
|
|
691
|
+
* Fewer tasks than this: every candidate is refused as INSUFFICIENT_EVIDENCE, unmeasured. Default 5, at most 1024.
|
|
692
|
+
* Candidates are also refused so, unmeasured, when even a clean sweep of every task (twice with `confirm`) could
|
|
693
|
+
* not pass the sign test at `alpha`: 7 tasks at 0.01 without `confirm`, 5 at 0.05 (`report.acceptance.minWins`).
|
|
694
|
+
*/
|
|
695
|
+
minTasks?: number;
|
|
696
|
+
/**
|
|
697
|
+
* Discordant tasks the candidate must win beyond those it loses (`memoryOnly - noMemoryOnly`; BELOW_MARGIN
|
|
698
|
+
* otherwise). Default 2, at least 1.
|
|
699
|
+
*/
|
|
700
|
+
minMargin?: number;
|
|
701
|
+
/**
|
|
702
|
+
* Significance level of the one-sided exact sign test over the discordant tasks (NOT_SIGNIFICANT above it):
|
|
703
|
+
* the most a lesson with no effect may be promoted per measured candidate. Default 0.01, from above 0 to 0.5.
|
|
704
|
+
* With `confirm` it applies to the pooled evidence of both measurements.
|
|
705
|
+
*/
|
|
706
|
+
alpha?: number;
|
|
707
|
+
/**
|
|
708
|
+
* Two-stage confirmation. Default true. A candidate whose first measurement passes the store gate, the margin
|
|
709
|
+
* and the sign test at `pendingAlpha` is not promoted: it is journaled `pending` with its counts and measured
|
|
710
|
+
* again, with fresh runs, by a later pass (pending candidates go before new ones). It is promoted only when the
|
|
711
|
+
* POOLED discordant tasks of both measurements pass the store gate, the margin and the sign test at `alpha`, so
|
|
712
|
+
* a lesson with no effect is still promoted at most `alpha` of the times it is measured. False: one measurement
|
|
713
|
+
* at `alpha` decides, as before.
|
|
714
|
+
*/
|
|
715
|
+
confirm?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* With `confirm`: the sign-test level a first measurement must reach to become pending (NOT_SIGNIFICANT above
|
|
718
|
+
* it). Default 0.25 (or `alpha`, when higher), from `alpha` to 0.5. It only decides which candidates earn a
|
|
719
|
+
* second measurement; the promotion itself rests on the pooled test at `alpha`.
|
|
720
|
+
*/
|
|
721
|
+
pendingAlpha?: number;
|
|
722
|
+
/**
|
|
723
|
+
* With `confirm`: how long a pending candidate waits for its confirming measurement; past it, it is refused as
|
|
724
|
+
* CONFIRMATION_EXPIRED. Default 3 days, from 1 ms to 30 days.
|
|
725
|
+
*/
|
|
726
|
+
confirmWithinMs?: number;
|
|
727
|
+
/**
|
|
728
|
+
* Measurements (first or confirming) in this scope over any rolling 24 hours, reserved in the journal before
|
|
729
|
+
* each one runs; past it candidates are held (MEASUREMENT_BUDGET), unmeasured. Default 6, at most 64. It bounds
|
|
730
|
+
* how often the scope draws on the sign test's `alpha`, however often passes run.
|
|
731
|
+
*/
|
|
732
|
+
maxMeasurementsPerDay?: number;
|
|
733
|
+
/**
|
|
734
|
+
* Token-set similarity (Jaccard over the normalized words of the text) at or above which a candidate is a
|
|
735
|
+
* paraphrase of one refused, screened out or rolled back within `episodeCooldownMs`: it is held
|
|
736
|
+
* (PARAPHRASE_COOLDOWN), unmeasured. Default 0.8, from 0.5 to 1. `episodeCooldownMs: 0` disables it, as does
|
|
737
|
+
* `remeasureRefused`.
|
|
738
|
+
*/
|
|
739
|
+
paraphraseSimilarity?: number;
|
|
740
|
+
/**
|
|
741
|
+
* The application's safety screen, asked about each new candidate before it is stored or measured. The gate
|
|
742
|
+
* measures usefulness, not safety: a lesson with no effect on the tasks (and some with an effect) that carries
|
|
743
|
+
* an injected instruction passes it as often as any other. A refused candidate is journaled as SCREENED (its
|
|
744
|
+
* episodes cool down) and never stored, measured or promoted; a screen that throws or answers anything but
|
|
745
|
+
* `{ allow: boolean }` is an `error` at stage `screen`: the candidate is not measured and a later pass asks again.
|
|
746
|
+
*/
|
|
747
|
+
screen?: CuratorScreen;
|
|
748
|
+
/** Candidates promoted in one pass; the rest are held (PROMOTION_BUDGET), unmeasured. Default 1, at most 8. */
|
|
749
|
+
maxPromotionsPerPass?: number;
|
|
750
|
+
/**
|
|
751
|
+
* Candidates promoted in this scope over any rolling 24 hours, counted in the journal; past it candidates are
|
|
752
|
+
* held (PROMOTION_BUDGET), unmeasured. Default 3, at most 64.
|
|
753
|
+
*/
|
|
754
|
+
maxPromotionsPerDay?: number;
|
|
755
|
+
/**
|
|
756
|
+
* Where refusals, promotions and episode cooldowns are kept between passes. Default: an
|
|
757
|
+
* in-memory journal per store object, which lasts only as long as this process: without a
|
|
758
|
+
* persistent journal (`fileCuratorJournal`), every retry protection is per process.
|
|
759
|
+
*/
|
|
760
|
+
journal?: CuratorJournal;
|
|
761
|
+
/** Measure again a candidate the journal records as refused. Default false. */
|
|
762
|
+
remeasureRefused?: boolean;
|
|
763
|
+
/**
|
|
764
|
+
* How long an episode that produced a refused, rolled-back or pending candidate is not offered to
|
|
765
|
+
* `distill`, nor any episode with the same normalized text; also how long a refused, screened-out or
|
|
766
|
+
* rolled-back candidate holds its paraphrases back. Default 7 days; 0 disables both cooldowns.
|
|
767
|
+
*/
|
|
768
|
+
episodeCooldownMs?: number;
|
|
769
|
+
/** Promoted candidates that may cite one episode, or episodes of one normalized text, ever: default 1, at most 16. */
|
|
770
|
+
maxPromotionsPerEpisode?: number;
|
|
771
|
+
signal?: AbortSignal;
|
|
772
|
+
/** Clock of cooldowns, and of `observedAt` when no cited episode has a usable one. Default: the system clock. */
|
|
773
|
+
now?: () => Date;
|
|
774
|
+
}
|
|
775
|
+
type CuratorInvalidReason = 'SHAPE' | 'TEXT' | 'TITLE' | 'SOURCES' | 'DUPLICATE' | 'OVER_LIMIT';
|
|
776
|
+
/** Why the application's screen refused a candidate. Anything else it answers is recorded as POLICY. */
|
|
777
|
+
type CuratorScreenReason = 'INSTRUCTION_OVERRIDE' | 'EXFILTRATION' | 'SECRET' | 'PERSONAL_DATA' | 'HARMFUL' | 'POLICY';
|
|
778
|
+
interface CuratorScreenVerdict {
|
|
779
|
+
allow: boolean;
|
|
780
|
+
reason?: CuratorScreenReason;
|
|
781
|
+
}
|
|
782
|
+
/** What the screen sees: the candidate's text (untrusted model output) and the episodes it cites. */
|
|
783
|
+
interface CuratorScreenCandidate {
|
|
784
|
+
readonly id: string;
|
|
785
|
+
readonly text: string;
|
|
786
|
+
readonly sources: readonly string[];
|
|
787
|
+
}
|
|
788
|
+
type CuratorScreen = (candidate: CuratorScreenCandidate, context: {
|
|
789
|
+
readonly scope: MemoryScope;
|
|
790
|
+
readonly signal: AbortSignal;
|
|
791
|
+
}) => Promise<CuratorScreenVerdict>;
|
|
792
|
+
/**
|
|
793
|
+
* Why a candidate was not promoted: the store gate's reason, BELOW_MARGIN (it won fewer than
|
|
794
|
+
* `minMargin` discordant tasks beyond those it lost), NOT_SIGNIFICANT (the sign test's p-value is
|
|
795
|
+
* above `alpha`, or above `pendingAlpha` on a first measurement under `confirm`),
|
|
796
|
+
* INSUFFICIENT_EVIDENCE (fewer than `minTasks` tasks, or too few for the sign test to ever pass:
|
|
797
|
+
* not measured, not stored, not journaled), SCREENED (the application's screen refused it:
|
|
798
|
+
* never stored or measured), CONFIRMATION_EXPIRED (pending longer than `confirmWithinMs`) or
|
|
799
|
+
* TASKS_CHANGED (pending, and the task set no longer has the first measurement's task count: the
|
|
800
|
+
* two are not pooled).
|
|
801
|
+
* Under `confirm`, a refusal that carries `pooled` was decided on both measurements.
|
|
802
|
+
*/
|
|
803
|
+
type CuratorRefusal = MemoryGateRefusal | 'BELOW_MARGIN' | 'NOT_SIGNIFICANT' | 'INSUFFICIENT_EVIDENCE' | 'SCREENED' | 'CONFIRMATION_EXPIRED' | 'TASKS_CHANGED';
|
|
804
|
+
/**
|
|
805
|
+
* Why a candidate was not measured: the journal records it as refused (`REFUSED_EARLIER`) or
|
|
806
|
+
* rolled back (`ROLLED_BACK`), it cites an episode that is cooling down after a refusal
|
|
807
|
+
* (`EPISODE_COOLDOWN`) or that already backs `maxPromotionsPerEpisode` promotions (`EPISODE_LIMIT`),
|
|
808
|
+
* the pass or the scope's rolling day already promoted its budget (`PROMOTION_BUDGET`), the
|
|
809
|
+
* scope's rolling day already ran `maxMeasurementsPerDay` measurements (`MEASUREMENT_BUDGET`), its
|
|
810
|
+
* text is a near-duplicate of a candidate refused or rolled back within the cooldown
|
|
811
|
+
* (`PARAPHRASE_COOLDOWN`), it is already pending confirmation (`PENDING`), the scope already
|
|
812
|
+
* holds the most pending candidates it may (`PENDING_LIMIT`), or a pending candidate is not in the
|
|
813
|
+
* store listing (`NOT_LISTED`). A held candidate is not journaled: a later pass may measure it.
|
|
814
|
+
*/
|
|
815
|
+
type CuratorHoldReason = 'REFUSED_EARLIER' | 'ROLLED_BACK' | 'EPISODE_COOLDOWN' | 'EPISODE_LIMIT' | 'PROMOTION_BUDGET' | 'MEASUREMENT_BUDGET' | 'PARAPHRASE_COOLDOWN' | 'PENDING' | 'PENDING_LIMIT' | 'NOT_LISTED';
|
|
816
|
+
/** The evidence of both measurements of a confirmed candidate, pooled: counts only. */
|
|
817
|
+
interface CuratorPooledEvidence {
|
|
818
|
+
/** Measurements pooled: 2. */
|
|
819
|
+
measurements: number;
|
|
820
|
+
/** Tasks run under each condition, over both measurements. */
|
|
821
|
+
tasks: number;
|
|
822
|
+
discordant: {
|
|
823
|
+
memoryOnly: number;
|
|
824
|
+
noMemoryOnly: number;
|
|
825
|
+
};
|
|
826
|
+
pValue: number;
|
|
827
|
+
/** Digests of the two measurement reports, first one first. */
|
|
828
|
+
digests: [string, string];
|
|
829
|
+
}
|
|
830
|
+
/** The acceptance rule a pass applied, so the application can see what its task set can detect. */
|
|
831
|
+
interface CuratorAcceptance {
|
|
832
|
+
/** Tasks in one measurement. */
|
|
833
|
+
tasks: number;
|
|
834
|
+
alpha: number;
|
|
835
|
+
minMargin: number;
|
|
836
|
+
confirm: boolean;
|
|
837
|
+
/** With `confirm`: the level a first measurement must reach to become pending. */
|
|
838
|
+
pendingAlpha?: number;
|
|
839
|
+
/**
|
|
840
|
+
* The fewest discordant tasks, all won by the candidate, with which the sign test can pass at
|
|
841
|
+
* `alpha` (5 at 0.05, 7 at 0.01). A measurement rarely makes more than a third to a half of its
|
|
842
|
+
* tasks discordant, so a task set much smaller than a few times this detects only large effects.
|
|
843
|
+
*/
|
|
844
|
+
minWins: number;
|
|
845
|
+
/** False when `tasks` (twice, with `confirm`) is below `minTasks` or `minWins`: every candidate is INSUFFICIENT_EVIDENCE. */
|
|
846
|
+
possible: boolean;
|
|
847
|
+
}
|
|
848
|
+
/** The measured comparison behind a decision: counts only, no text. */
|
|
849
|
+
interface CuratorMeasurement {
|
|
850
|
+
id: string;
|
|
851
|
+
digest: string;
|
|
852
|
+
noMemory: MemoryConditionTally;
|
|
853
|
+
memory: MemoryConditionTally;
|
|
854
|
+
fullHistory: MemoryConditionTally;
|
|
855
|
+
/** The paired tasks the decision rests on: those exactly one of memory and no memory passed. */
|
|
856
|
+
discordant: {
|
|
857
|
+
memoryOnly: number;
|
|
858
|
+
noMemoryOnly: number;
|
|
859
|
+
};
|
|
860
|
+
/** One-sided exact sign test over `discordant`: the chance of a result this good from a lesson with no effect. */
|
|
861
|
+
pValue: number;
|
|
862
|
+
}
|
|
863
|
+
type CuratorCandidateOutcome =
|
|
864
|
+
/** `pooled` is present when `confirm` promoted it on two measurements; `measurement` is then the second. */
|
|
865
|
+
{
|
|
866
|
+
id: string;
|
|
867
|
+
status: 'promoted';
|
|
868
|
+
promotedAt: string;
|
|
869
|
+
measurement: CuratorMeasurement;
|
|
870
|
+
pooled?: CuratorPooledEvidence;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* `measurement` is absent for INSUFFICIENT_EVIDENCE, SCREENED and CONFIRMATION_EXPIRED; `pooled` is present for a
|
|
874
|
+
* refusal decided on two measurements; `screen` is the screen's reason for SCREENED.
|
|
875
|
+
*/
|
|
876
|
+
| {
|
|
877
|
+
id: string;
|
|
878
|
+
status: 'refused';
|
|
879
|
+
reason: CuratorRefusal;
|
|
880
|
+
measurement?: CuratorMeasurement;
|
|
881
|
+
pooled?: CuratorPooledEvidence;
|
|
882
|
+
screen?: CuratorScreenReason;
|
|
883
|
+
}
|
|
884
|
+
/** First measurement passed under `confirm`: journaled, measured again by a later pass before `until`. */
|
|
885
|
+
| {
|
|
886
|
+
id: string;
|
|
887
|
+
status: 'pending';
|
|
888
|
+
measurement: CuratorMeasurement;
|
|
889
|
+
until: string;
|
|
890
|
+
} | {
|
|
891
|
+
id: string;
|
|
892
|
+
status: 'held';
|
|
893
|
+
reason: CuratorHoldReason;
|
|
894
|
+
}
|
|
895
|
+
/** Stored by an earlier pass and no longer an episode: never measured or promoted again. */
|
|
896
|
+
| {
|
|
897
|
+
id: string;
|
|
898
|
+
status: 'existing';
|
|
899
|
+
state: 'lesson' | 'invalidated' | 'expired';
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Fail-closed: the candidate was not promoted, and no decision about it was journaled, so a
|
|
903
|
+
* later pass may measure it. `journal`: its promotion could not be reserved, so the store was
|
|
904
|
+
* not asked and the pass stops (`failure`). `promote`: the store refused or failed after the
|
|
905
|
+
* reservation, which is kept: the slot of the day and the count of its episodes stay used.
|
|
906
|
+
* `error` is a code or class name, never a message.
|
|
907
|
+
*/
|
|
908
|
+
| {
|
|
909
|
+
id: string;
|
|
910
|
+
status: 'error';
|
|
911
|
+
stage: 'screen' | 'store' | 'measure' | 'journal' | 'promote';
|
|
912
|
+
error: string;
|
|
913
|
+
}
|
|
914
|
+
/** The pass stopped before this candidate. */
|
|
915
|
+
| {
|
|
916
|
+
id: string;
|
|
917
|
+
status: 'skipped';
|
|
918
|
+
};
|
|
919
|
+
/** JSON-serializable; holds ids, counts and codes, never episode or candidate text. */
|
|
920
|
+
interface CuratorReport {
|
|
921
|
+
format: 1;
|
|
922
|
+
scope: MemoryScope;
|
|
923
|
+
distillerId: string;
|
|
924
|
+
/** Episodes handed to `distill`. */
|
|
925
|
+
episodes: number;
|
|
926
|
+
/** Unpromoted episodes left out because they are cooling down or at their promotion limit. */
|
|
927
|
+
episodesHeld: number;
|
|
928
|
+
/** Unpromoted episodes left out because a newer one with the same normalized text was offered instead. */
|
|
929
|
+
episodesMerged: number;
|
|
930
|
+
/** Entries `distill` returned. */
|
|
931
|
+
proposed: number;
|
|
932
|
+
/** Pending candidates' confirmations first, then this pass's candidates in proposal order. */
|
|
933
|
+
candidates: CuratorCandidateOutcome[];
|
|
934
|
+
invalid: {
|
|
935
|
+
index: number;
|
|
936
|
+
reason: CuratorInvalidReason;
|
|
937
|
+
}[];
|
|
938
|
+
promoted: number;
|
|
939
|
+
refused: number;
|
|
940
|
+
held: number;
|
|
941
|
+
errors: number;
|
|
942
|
+
/** Candidates that became pending in this pass. */
|
|
943
|
+
pending: number;
|
|
944
|
+
/** Measurements this pass reserved against `maxMeasurementsPerDay` (first and confirming). */
|
|
945
|
+
measured: number;
|
|
946
|
+
acceptance: CuratorAcceptance;
|
|
947
|
+
/**
|
|
948
|
+
* `list` or `distill`: the pass could not list the scope or `distill` failed, and nothing was
|
|
949
|
+
* stored. `journal`: the journal could not be read or written; the pass stopped there and the
|
|
950
|
+
* candidates after it are `skipped`.
|
|
951
|
+
*/
|
|
952
|
+
failure?: {
|
|
953
|
+
stage: 'list' | 'distill' | 'journal';
|
|
954
|
+
error: string;
|
|
955
|
+
};
|
|
956
|
+
stopped?: StopReason;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* One-sided exact sign test: `P(X >= memoryOnly)` for `X ~ Binomial(memoryOnly + noMemoryOnly, 1/2)`.
|
|
961
|
+
* 1 when there is no discordant task. Computed exactly in integers, `sum of C(n, k) for k >= memoryOnly`
|
|
962
|
+
* over `2^n`, and rounded once at the end, so a p-value that is exactly `alpha` compares equal to it.
|
|
963
|
+
* At most 2048 discordant tasks: two pooled measurements of the most tasks a measurement takes.
|
|
964
|
+
*/
|
|
965
|
+
declare function signTestPValue(memoryOnly: number, noMemoryOnly: number): number;
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Runs one curation pass over one scope:
|
|
969
|
+
*
|
|
970
|
+
* 1. lists the scope's unpromoted episodes (newest first), leaving out the curator's own
|
|
971
|
+
* candidates and every episode the journal holds back: cooling down after it produced a
|
|
972
|
+
* refused or rolled-back candidate, or already cited by `maxPromotionsPerEpisode` promoted
|
|
973
|
+
* ones. The journal keys an episode by its id AND by its normalized text, so a fresh id that
|
|
974
|
+
* carries the same text (a persistent injection lands in every turn) is held back too; of
|
|
975
|
+
* several eligible episodes with one normalized text only the newest is offered
|
|
976
|
+
* (`episodesMerged` counts the rest). A promoted candidate missing from the listing was
|
|
977
|
+
* withdrawn (rolled back or revoked): its episodes start a cooldown and it is journaled as
|
|
978
|
+
* rolled back. At most `maxEpisodes`;
|
|
979
|
+
* 2. asks `distill` for lessons and keeps at most `maxCandidates` valid ones: text within
|
|
980
|
+
* bounds that the agent would carry unchanged (no NUL, no invisible tag characters), an
|
|
981
|
+
* optional title that is a memory label (checked, never stored), and `sources` that all
|
|
982
|
+
* name episodes of this pass. Anything else is reported in `invalid`;
|
|
983
|
+
* 3. first measures again, with `confirm`, the scope's pending candidates (oldest first), and
|
|
984
|
+
* decides each on the pooled evidence of both measurements (step 7); one pending longer than
|
|
985
|
+
* `confirmWithinMs` is refused as CONFIRMATION_EXPIRED;
|
|
986
|
+
* 4. holds back (`held`) a candidate the journal records as refused (unless `remeasureRefused`),
|
|
987
|
+
* rolled back or pending, one citing an episode that a decision earlier in this pass held back,
|
|
988
|
+
* one whose text is a near-duplicate of a candidate refused or rolled back within the cooldown
|
|
989
|
+
* (`paraphraseSimilarity`), and every candidate once the pass promoted `maxPromotionsPerPass`,
|
|
990
|
+
* the scope's rolling 24 hours hold `maxPromotionsPerDay` promotions or `maxMeasurementsPerDay`
|
|
991
|
+
* measurements, or (with `confirm`) the scope holds 16 pending candidates;
|
|
992
|
+
* refuses every candidate as INSUFFICIENT_EVIDENCE when the task set cannot pass the test
|
|
993
|
+
* (`report.acceptance.possible`); asks `screen`, when given, and refuses as SCREENED, unstored
|
|
994
|
+
* and unmeasured, a candidate it refuses;
|
|
995
|
+
* 5. stores each candidate as an EPISODE with provenance `source: 'curator'`, `sourceVersion:
|
|
996
|
+
* distillerId`, the newest `observedAt` of its sources, an `inputHash` over its text and
|
|
997
|
+
* sources, and metadata `{ sources }`. Its id is derived from the scope and the text, so a
|
|
998
|
+
* re-run proposing the same lesson finds it instead of storing it twice;
|
|
999
|
+
* 6. measures each candidate ALONE with `measureMemory`: its text is the whole context of the
|
|
1000
|
+
* `memory` condition, and the evidence names only its digest. A run that errored under
|
|
1001
|
+
* no-memory or memory makes the candidate an `error`, never a refusal or a promotion;
|
|
1002
|
+
* Each measurement is first reserved against `maxMeasurementsPerDay`;
|
|
1003
|
+
* 7. accepts it only when the store gate passes AND, over the paired tasks exactly one condition
|
|
1004
|
+
* passed, memory wins at least `minMargin` more than it loses AND the one-sided exact sign test
|
|
1005
|
+
* gives a p-value of at most `alpha`. Without `confirm` that one measurement promotes it. With
|
|
1006
|
+
* `confirm` (the default) a first measurement that passes at `pendingAlpha` makes it `pending`,
|
|
1007
|
+
* and only the pooled evidence of a second measurement in a later pass, at `alpha`, promotes
|
|
1008
|
+
* it: a lesson with no effect is promoted at most `alpha` of the times it is measured either
|
|
1009
|
+
* way, and the journal measures it once (twice when pending).
|
|
1010
|
+
*
|
|
1011
|
+
* The gate measures usefulness, not safety: a lesson that carries an injected instruction and
|
|
1012
|
+
* leaves the tasks unchanged is promoted exactly as often as any neutral one. Give a `screen`,
|
|
1013
|
+
* run passes at most daily unless measurements are budgeted tighter, and review what is promoted.
|
|
1014
|
+
*
|
|
1015
|
+
* Refusals and promotions are journaled; errors are not, so a candidate whose measurement never
|
|
1016
|
+
* finished is measured by a later pass. A promotion is reserved in the journal (the pass, the
|
|
1017
|
+
* scope's rolling day, the cited episodes) before the store is asked: a reservation that cannot be
|
|
1018
|
+
* written stops the pass at stage `journal` unpromoted, and one whose promotion the store then
|
|
1019
|
+
* refuses or fails is kept (fail-closed). A stored candidate that is a lesson, invalidated or
|
|
1020
|
+
* expired is reported `existing` and never measured again. Raw episodes are never promoted. The
|
|
1021
|
+
* pass stops at `deadlineMs` or when `signal` aborts and returns the report with `stopped` set;
|
|
1022
|
+
* candidates it did not reach are `skipped`. A pass never rejects for a store, distiller, journal
|
|
1023
|
+
* or runner failure; it throws only for invalid options.
|
|
1024
|
+
*
|
|
1025
|
+
* Run one pass per scope at a time.
|
|
1026
|
+
*/
|
|
1027
|
+
declare function curateMemory(input: CurateMemoryOptions): Promise<CuratorReport>;
|
|
1028
|
+
/** Derived from the scope and the text only, so the same lesson proposed again lands on the same id. */
|
|
1029
|
+
declare function candidateId(scope: MemoryScope, text: string): string;
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* A `distill` for `curateMemory` built on an SDK Agent.
|
|
1033
|
+
*
|
|
1034
|
+
* The distiller builds its own Agent for each call and closes it afterwards. It forces:
|
|
1035
|
+
* `permissions: { mode: 'analyze' }`, the exec transport, `context: { profile: 'clean',
|
|
1036
|
+
* memory: 'off' }` (no discovered instructions, skills, hooks, plugins or provider memory),
|
|
1037
|
+
* `memory: false` (a Runtime memory default never recalls into it), no application tools, no
|
|
1038
|
+
* pinned constraints, and for Claude `providerOptions.claude = { tools: [], strictMcpConfig: true }`
|
|
1039
|
+
* (`--tools ""` and `--strict-mcp-config` with no MCP config: no built-in tool and no MCP
|
|
1040
|
+
* server). Options that would change any of that are refused with a TypeError. Claude is the
|
|
1041
|
+
* only provider it can make tool-less: any other provider is refused unless the caller passes
|
|
1042
|
+
* `allowProviderReadTools: true`, acknowledging that the CLI keeps its read tools (Codex in its
|
|
1043
|
+
* read-only sandbox still reads files and runs read-only commands in `cwd`).
|
|
1044
|
+
*
|
|
1045
|
+
* Episode text reaches the model as untrusted data: each episode is labelled by the distiller
|
|
1046
|
+
* (`E1`, `E2`, ...; never by its stored id), every one of its lines is indented, and the prompt
|
|
1047
|
+
* says that nothing inside the block is an instruction. The reply must be strict JSON: the
|
|
1048
|
+
* structured output channel (`outputSchema`) when `structuredOutput` is on, otherwise the whole
|
|
1049
|
+
* turn text parsed as JSON, with no prose and no code fence around it.
|
|
1050
|
+
*
|
|
1051
|
+
* The Agent class is loaded on the first call, so importing this module does not load the runtime.
|
|
1052
|
+
*/
|
|
1053
|
+
/** The Agent options a distiller may set; everything that grants tools, permissions, context or memory is excluded. */
|
|
1054
|
+
type DistillerAgentOptions = Omit<AgentOptions, 'tools' | 'permissions' | 'memory' | 'pinned' | 'instructions' | 'providerOptions' | 'transport' | 'context'> & {
|
|
1055
|
+
/** Only `exec`, which is forced anyway. */
|
|
1056
|
+
transport?: 'exec';
|
|
1057
|
+
/** Only the clean profile with provider memory off, which is forced anyway. */
|
|
1058
|
+
context?: {
|
|
1059
|
+
profile?: 'clean';
|
|
1060
|
+
memory?: 'off';
|
|
1061
|
+
};
|
|
1062
|
+
};
|
|
1063
|
+
interface AgentDistillerOptions {
|
|
1064
|
+
agent: DistillerAgentOptions;
|
|
1065
|
+
/** Runtime the distiller's Agents run on. Default: the SDK's default runtime. */
|
|
1066
|
+
runtime?: Runtime;
|
|
1067
|
+
/** Application guidance appended to the fixed instructions, e.g. the domain the lessons are for. */
|
|
1068
|
+
instructions?: string;
|
|
1069
|
+
/** Turn deadline in milliseconds. Default: 120 000. */
|
|
1070
|
+
timeoutMs?: number;
|
|
1071
|
+
/** Ask for the reply through `outputSchema`. Default: true. False parses the turn text strictly instead. */
|
|
1072
|
+
structuredOutput?: boolean;
|
|
1073
|
+
/** Characters of each episode shown to the model: default 2000. */
|
|
1074
|
+
maxEpisodeChars?: number;
|
|
1075
|
+
/** Characters of all episodes together: default 24 000. Episodes past it are not offered. */
|
|
1076
|
+
maxPromptChars?: number;
|
|
1077
|
+
/** Longest lesson the schema asks for. Default: `CURATOR_DEFAULT_MAX_TEXT`. */
|
|
1078
|
+
maxLessonChars?: number;
|
|
1079
|
+
/**
|
|
1080
|
+
* Required for a provider other than Claude: the distiller cannot remove that CLI's read tools,
|
|
1081
|
+
* so the model can read what the provider's read-only mode allows. Default false.
|
|
1082
|
+
*/
|
|
1083
|
+
allowProviderReadTools?: boolean;
|
|
1084
|
+
}
|
|
1085
|
+
declare const DISTILLER_INSTRUCTIONS: string;
|
|
1086
|
+
/** The prompt of one distill turn; exported so an application can review exactly what the model receives. */
|
|
1087
|
+
declare function distillerPrompt(episodes: readonly CuratorEpisode[], maxLessons: number, options?: {
|
|
1088
|
+
maxEpisodeChars?: number;
|
|
1089
|
+
maxPromptChars?: number;
|
|
1090
|
+
}): {
|
|
1091
|
+
prompt: string;
|
|
1092
|
+
labels: ReadonlyMap<string, string>;
|
|
1093
|
+
};
|
|
1094
|
+
declare function agentDistiller(input: AgentDistillerOptions): CuratorDistill;
|
|
1095
|
+
/** Strict: one JSON object `{ lessons: [...] }` and nothing else. Lesson fields are checked by the curator. */
|
|
1096
|
+
declare function parseLessons(turn: Turn, structured: boolean, labels: ReadonlyMap<string, string>): CuratorProposal[];
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* The ablation suite's verdict rule, on its own so it can be checked against synthetic runs.
|
|
1100
|
+
*
|
|
1101
|
+
* It is a paired test over tasks, the same rule family as the curator's acceptance: every task
|
|
1102
|
+
* ran under every condition, so per task the conditions' pass rates are compared, and a one-sided
|
|
1103
|
+
* exact sign test over the discordant tasks (`signTestPValue`) gives the chance of a result at
|
|
1104
|
+
* least this lopsided from noise alone. Concordant tasks say nothing about memory and are left
|
|
1105
|
+
* out. An effect also needs the one-task margin on the pooled pass rates, so a significant but
|
|
1106
|
+
* negligible difference (one run in many repeats) is still no effect.
|
|
1107
|
+
*/
|
|
1108
|
+
type AblationCondition = 'off' | 'on' | 'irrelevant';
|
|
1109
|
+
type AblationVerdict = 'helps' | 'hurts' | 'no-effect' | 'inconclusive';
|
|
1110
|
+
type AblationVerdictReason = 'TOO_FEW_TASKS' | 'NO_RUNS' | 'TOO_MANY_ERRORS' | 'UNBALANCED_ERRORS' | 'GAIN' | 'GAIN_NOT_ABOVE_IRRELEVANT' | 'LOSS' | 'WITHIN_ONE_TASK' | 'NOT_SIGNIFICANT';
|
|
1111
|
+
interface AblationRule {
|
|
1112
|
+
minTasks: number;
|
|
1113
|
+
maxErrorRate: number;
|
|
1114
|
+
/** One task's worth of pass rate: `1 / tasks`. A difference of pooled pass rates smaller than this is no difference. */
|
|
1115
|
+
margin: number;
|
|
1116
|
+
/** Significance level of the one-sided exact sign tests. */
|
|
1117
|
+
alpha: number;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* One paired comparison of `on` with another condition, over the tasks that have an answered run
|
|
1121
|
+
* under both: `better` tasks where `on` had the higher pass rate, `worse` the lower, `ties` equal.
|
|
1122
|
+
* `pBetter` is the one-sided sign test's p-value for "on is better", `pWorse` for "on is worse";
|
|
1123
|
+
* both are 1 without a discordant task.
|
|
1124
|
+
*/
|
|
1125
|
+
interface AblationSignTest {
|
|
1126
|
+
better: number;
|
|
1127
|
+
worse: number;
|
|
1128
|
+
ties: number;
|
|
1129
|
+
pBetter: number;
|
|
1130
|
+
pWorse: number;
|
|
1131
|
+
}
|
|
1132
|
+
interface AblationSignTests {
|
|
1133
|
+
onVsOff: AblationSignTest;
|
|
1134
|
+
onVsIrrelevant: AblationSignTest;
|
|
1135
|
+
}
|
|
1136
|
+
/** What the rule reads of a run: which task, which condition, and whether it passed or errored. */
|
|
1137
|
+
interface AblationOutcome {
|
|
1138
|
+
task: string;
|
|
1139
|
+
condition: AblationCondition;
|
|
1140
|
+
passed: boolean;
|
|
1141
|
+
/** Present when the run errored: an infrastructure failure, not an answer. */
|
|
1142
|
+
error?: unknown;
|
|
1143
|
+
}
|
|
1144
|
+
interface AblationVerdictResult {
|
|
1145
|
+
verdict: AblationVerdict;
|
|
1146
|
+
reason: AblationVerdictReason;
|
|
1147
|
+
/** The sign tests over pass rates of answered runs (errored runs left out), whatever the verdict. */
|
|
1148
|
+
tests: AblationSignTests;
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* The verdict over the runs of one suite (`MemoryAblationReport.runs`, or synthetic ones). Pass
|
|
1152
|
+
* rates are taken over the runs that did not error: an errored run is an infrastructure failure,
|
|
1153
|
+
* not a wrong answer, and must not make another condition look better.
|
|
1154
|
+
* 1. fewer than `minTasks` tasks: `inconclusive` (TOO_FEW_TASKS);
|
|
1155
|
+
* 2. a condition without a single run that did not error: `inconclusive` (NO_RUNS);
|
|
1156
|
+
* 3. any condition with errored runs above `maxErrorRate`: `inconclusive` (TOO_MANY_ERRORS);
|
|
1157
|
+
* 4. `on` better than `off` by the sign test at `alpha` (default 0.05) and by at least one
|
|
1158
|
+
* task's worth of pooled pass rate (`1 / tasks`): `helps` when `on` also beats `irrelevant`
|
|
1159
|
+
* the same way, otherwise `inconclusive` (GAIN_NOT_ABOVE_IRRELEVANT: any context of that
|
|
1160
|
+
* shape did about as well, so the gain is not this memory's);
|
|
1161
|
+
* 5. `on` worse than `off` the same way: `hurts` (LOSS);
|
|
1162
|
+
* 6. a pooled difference under one task's worth: `no-effect` (WITHIN_ONE_TASK);
|
|
1163
|
+
* 7. otherwise `no-effect` (NOT_SIGNIFICANT: a difference noise alone makes often enough).
|
|
1164
|
+
*
|
|
1165
|
+
* When any run errored, steps 4 to 7 are taken again with every errored run counted as a failure
|
|
1166
|
+
* (rates over all runs). Errors concentrated in one condition can then decide the verdict either
|
|
1167
|
+
* way (a memory whose wrong answers time out looks perfect over its answered runs), so if the two
|
|
1168
|
+
* readings disagree the verdict is `inconclusive` (UNBALANCED_ERRORS). Before, any difference of
|
|
1169
|
+
* a task's worth of errors between conditions was already `inconclusive`; that voided clear
|
|
1170
|
+
* effects over a single infrastructure error, and simulation showed it added no protection the
|
|
1171
|
+
* second reading does not give (`scripts/simulation/memory/ablation.mjs`).
|
|
1172
|
+
*
|
|
1173
|
+
* Before format 2 the rule took aggregate tallies, `ablationVerdict(tasks, conditions, rule)`, and
|
|
1174
|
+
* needed no significance: a one-task difference was an effect. That form is refused with a TypeError.
|
|
1175
|
+
*/
|
|
1176
|
+
declare function ablationVerdict(runs: readonly AblationOutcome[], rule: Pick<AblationRule, 'minTasks' | 'maxErrorRate'> & {
|
|
1177
|
+
alpha?: number;
|
|
1178
|
+
}): AblationVerdictResult;
|
|
1179
|
+
|
|
1180
|
+
interface AblationTask {
|
|
1181
|
+
id: string;
|
|
1182
|
+
input: AgentInput;
|
|
1183
|
+
/** Whether the turn solved the task. A throw or a non-boolean counts as an error, not a pass. */
|
|
1184
|
+
check(turn: Turn): boolean | Promise<boolean>;
|
|
1185
|
+
}
|
|
1186
|
+
/** What the suite needs from an Agent; a real `Agent` has it. */
|
|
1187
|
+
type AblationAgent = Pick<Agent, 'send' | 'close'>;
|
|
1188
|
+
interface AblationRunContext {
|
|
1189
|
+
readonly condition: AblationCondition;
|
|
1190
|
+
readonly taskId: string;
|
|
1191
|
+
readonly repeat: number;
|
|
1192
|
+
}
|
|
1193
|
+
interface MemoryAblationOptions {
|
|
1194
|
+
id: string;
|
|
1195
|
+
tasks: readonly AblationTask[];
|
|
1196
|
+
/** The memory under test. Every condition runs it with `capture: false`: an ablation never writes memory. */
|
|
1197
|
+
memory: MemoryOption;
|
|
1198
|
+
/**
|
|
1199
|
+
* Builds a fresh Agent for one run; it must pass `memory` unchanged as `AgentOptions.memory`
|
|
1200
|
+
* (`false` under `off`). The suite closes every Agent it gets, whatever happens.
|
|
1201
|
+
*/
|
|
1202
|
+
makeAgent(memory: MemoryOption | false, context: AblationRunContext): AblationAgent | Promise<AblationAgent>;
|
|
1203
|
+
/** The `irrelevant` condition's provider: returns plausible items that do not bear on the tasks. */
|
|
1204
|
+
irrelevantProvider?: AgentMemoryProvider;
|
|
1205
|
+
/**
|
|
1206
|
+
* Instead of `irrelevantProvider`: a different scope of the same store. The built-in decoy asks
|
|
1207
|
+
* `memory.provider` to recall from this scope, so the items have the store's own shape and
|
|
1208
|
+
* size but come from unrelated work. Exactly one of the two is required. It must name the same
|
|
1209
|
+
* tenant as `memory.scope` (another tenant is refused); its items reach the model of every
|
|
1210
|
+
* `irrelevant` run, so pick a namespace or subject whose memory may be shown to these tasks.
|
|
1211
|
+
*/
|
|
1212
|
+
irrelevantScope?: AgentMemoryScope;
|
|
1213
|
+
/** Runs per task and condition: default 1, at most 16. */
|
|
1214
|
+
repeats?: number;
|
|
1215
|
+
/** Runs in flight at once: default 1 (sequential), at most 8. */
|
|
1216
|
+
concurrency?: number;
|
|
1217
|
+
/** Deadline of one run (agent build, turn and check) in milliseconds. Default: 600 000. */
|
|
1218
|
+
timeoutMs?: number;
|
|
1219
|
+
/** Fewer tasks than this is `inconclusive`. Default 5. */
|
|
1220
|
+
minTasks?: number;
|
|
1221
|
+
/** A condition with a larger share of errored runs makes the verdict `inconclusive`. Default 0.25. */
|
|
1222
|
+
maxErrorRate?: number;
|
|
1223
|
+
/**
|
|
1224
|
+
* Significance level of the one-sided exact sign tests over tasks (see `ablationVerdict`): the
|
|
1225
|
+
* most often a memory with no effect is reported as `helps`. Default 0.05, above 0, at most 0.5.
|
|
1226
|
+
*/
|
|
1227
|
+
alpha?: number;
|
|
1228
|
+
/**
|
|
1229
|
+
* Aborting rejects the suite with the signal's reason, after every Agent it built was closed;
|
|
1230
|
+
* an Agent still being built is awaited (at most `min(timeoutMs, 10 s)`) and closed too.
|
|
1231
|
+
*/
|
|
1232
|
+
signal?: AbortSignal;
|
|
1233
|
+
}
|
|
1234
|
+
type AblationRunError = 'make-agent' | 'turn' | 'check' | 'timeout';
|
|
1235
|
+
/** What memory did on a run: ids, sources and sizes, never the recalled text. */
|
|
1236
|
+
type AblationMemoryNote = {
|
|
1237
|
+
status: 'recalled';
|
|
1238
|
+
items: {
|
|
1239
|
+
id: string;
|
|
1240
|
+
source: string;
|
|
1241
|
+
bytes: number;
|
|
1242
|
+
}[];
|
|
1243
|
+
omitted: number;
|
|
1244
|
+
bytes: number;
|
|
1245
|
+
} | {
|
|
1246
|
+
status: 'empty';
|
|
1247
|
+
} | {
|
|
1248
|
+
status: 'failed';
|
|
1249
|
+
};
|
|
1250
|
+
interface AblationUsage {
|
|
1251
|
+
inputTokens?: number;
|
|
1252
|
+
outputTokens?: number;
|
|
1253
|
+
cachedInputTokens?: number;
|
|
1254
|
+
cacheCreationTokens?: number;
|
|
1255
|
+
reportedCostUsd?: number;
|
|
1256
|
+
}
|
|
1257
|
+
interface AblationRun {
|
|
1258
|
+
task: string;
|
|
1259
|
+
condition: AblationCondition;
|
|
1260
|
+
repeat: number;
|
|
1261
|
+
passed: boolean;
|
|
1262
|
+
error?: AblationRunError;
|
|
1263
|
+
/** Code or class name of the failure; never its message. */
|
|
1264
|
+
errorName?: string;
|
|
1265
|
+
status?: Turn['status'];
|
|
1266
|
+
/** Wall time of the turn, in whole milliseconds. */
|
|
1267
|
+
latencyMs?: number;
|
|
1268
|
+
usage?: AblationUsage;
|
|
1269
|
+
memory?: AblationMemoryNote;
|
|
1270
|
+
}
|
|
1271
|
+
interface AblationConditionSummary {
|
|
1272
|
+
runs: number;
|
|
1273
|
+
passed: number;
|
|
1274
|
+
/** `passed` over the runs that did not error; 0 when every run errored. Errored runs are infrastructure, not answers. */
|
|
1275
|
+
passRate: number;
|
|
1276
|
+
errors: number;
|
|
1277
|
+
recalledItems: number;
|
|
1278
|
+
recalledBytes: number;
|
|
1279
|
+
latencyMs: number;
|
|
1280
|
+
inputTokens: number;
|
|
1281
|
+
outputTokens: number;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* JSON-serializable evidence. Task ids, provider id, counts and sizes only: no prompt, no recalled text.
|
|
1285
|
+
* Format 2: the verdict is a paired sign test over tasks, `rule.alpha` and `tests` are new. A format 1
|
|
1286
|
+
* report's verdict compared pooled pass rates with a one-task margin only, and is not comparable.
|
|
1287
|
+
*/
|
|
1288
|
+
interface MemoryAblationReport {
|
|
1289
|
+
format: 2;
|
|
1290
|
+
id: string;
|
|
1291
|
+
provider: string;
|
|
1292
|
+
tasks: string[];
|
|
1293
|
+
repeats: number;
|
|
1294
|
+
conditions: Record<AblationCondition, AblationConditionSummary>;
|
|
1295
|
+
deltas: {
|
|
1296
|
+
onVsOff: number;
|
|
1297
|
+
irrelevantVsOff: number;
|
|
1298
|
+
onVsIrrelevant: number;
|
|
1299
|
+
};
|
|
1300
|
+
rule: AblationRule;
|
|
1301
|
+
verdict: AblationVerdict;
|
|
1302
|
+
reason: AblationVerdictReason;
|
|
1303
|
+
/** The paired sign tests over pass rates of answered runs, with their p-values. */
|
|
1304
|
+
tests: AblationSignTests;
|
|
1305
|
+
runs: AblationRun[];
|
|
1306
|
+
digest: string;
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Runs every task under `off`, `on` and `irrelevant`, `repeats` times each, in that order per
|
|
1310
|
+
* task (sequentially unless `concurrency` says otherwise), and reports pass rates, their
|
|
1311
|
+
* differences and a verdict (see `ablationVerdict`). Every run gets its own Agent from
|
|
1312
|
+
* `makeAgent`, so no session carries over between conditions; the Agent is closed after the run.
|
|
1313
|
+
* A failed build, turn or check, and a run past `timeoutMs`, are errored runs: reported by kind,
|
|
1314
|
+
* never passed, left out of the pass rates, and they never reject the suite. Only invalid options
|
|
1315
|
+
* (a TypeError or RangeError) and the caller's abort reject. No condition carries the provider's
|
|
1316
|
+
* profile: the suite measures recalled items only.
|
|
1317
|
+
*/
|
|
1318
|
+
declare function runMemoryAblation(input: MemoryAblationOptions): Promise<MemoryAblationReport>;
|
|
1319
|
+
|
|
1320
|
+
declare const decisionHash: (value: JsonValue) => string;
|
|
1321
|
+
/** Snapshot app inputs; authority stays private and only its identity is persisted. */
|
|
1322
|
+
declare function bindDecision(options: {
|
|
1323
|
+
input: JsonValue;
|
|
1324
|
+
authority: JsonValue;
|
|
1325
|
+
inputVersion: string;
|
|
1326
|
+
authorityVersion: string;
|
|
1327
|
+
}): DecisionBinding;
|
|
1328
|
+
declare function sameDecisionBinding(left: Omit<DecisionBinding, 'input'>, right: Omit<DecisionBinding, 'input'>): boolean;
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* A durable wait/decision around one app-owned effect, not a business workflow.
|
|
1332
|
+
* Recovered intents require owner reconciliation; this runner never replays an
|
|
1333
|
+
* ambiguous effect. Give reconciled replacement work its own id and authority.
|
|
1334
|
+
*/
|
|
1335
|
+
declare class DecisionRunner {
|
|
1336
|
+
private readonly store;
|
|
1337
|
+
constructor(store: DecisionStore);
|
|
1338
|
+
run(options: DecisionRunOptions): Promise<DecisionRecord>;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/** Reuse an existing WorkflowStore's exclusive lease and atomic persistence. */
|
|
1342
|
+
declare class WorkflowDecisionStore implements DecisionStore {
|
|
1343
|
+
private readonly store;
|
|
1344
|
+
constructor(store: WorkflowStore);
|
|
1345
|
+
acquire(id: string): Promise<DecisionLease>;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
declare function openTraceEpisode(store: TraceStore, identity: TraceIdentity): Promise<TraceRecorder>;
|
|
1349
|
+
declare function readTraceEpisode(store: TraceStore, episodeId: string): Promise<TraceEpisode | undefined>;
|
|
1350
|
+
|
|
1351
|
+
/** Versioned data envelope over a trusted WorkflowStore's exclusive, durable lease. */
|
|
1352
|
+
declare class WorkflowTraceStore implements TraceStore {
|
|
1353
|
+
private readonly store;
|
|
1354
|
+
constructor(store: WorkflowStore);
|
|
1355
|
+
acquire(episodeId: string): Promise<TraceLease>;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
interface EvaluationCase {
|
|
1359
|
+
id: string;
|
|
1360
|
+
input: JsonValue;
|
|
1361
|
+
expected: JsonValue;
|
|
1362
|
+
}
|
|
1363
|
+
interface EvaluationSuite {
|
|
1364
|
+
id: string;
|
|
1365
|
+
version: string;
|
|
1366
|
+
cases: readonly EvaluationCase[];
|
|
1367
|
+
}
|
|
1368
|
+
interface EvaluationProfile {
|
|
1369
|
+
id: string;
|
|
1370
|
+
version: string;
|
|
1371
|
+
sourceDigest: string;
|
|
1372
|
+
provider?: string;
|
|
1373
|
+
model?: string;
|
|
1374
|
+
transport?: string;
|
|
1375
|
+
optionsDigest?: string;
|
|
1376
|
+
}
|
|
1377
|
+
/** Compatible with the tracing module's minimal TraceWriter port. */
|
|
1378
|
+
interface EvaluationTraceWriter {
|
|
1379
|
+
append(event: {
|
|
1380
|
+
type: string;
|
|
1381
|
+
phaseId?: string;
|
|
1382
|
+
status?: string;
|
|
1383
|
+
code?: string;
|
|
1384
|
+
count?: number;
|
|
1385
|
+
}): Promise<void>;
|
|
1386
|
+
observe?(event: AgentEvent): Promise<void>;
|
|
1387
|
+
}
|
|
1388
|
+
interface EvaluationAttemptContext {
|
|
1389
|
+
attemptId: string;
|
|
1390
|
+
caseId: string;
|
|
1391
|
+
repetition: number;
|
|
1392
|
+
signal: AbortSignal;
|
|
1393
|
+
/** Epoch milliseconds; includes admission, tracing, execution and verification. */
|
|
1394
|
+
deadline: number;
|
|
1395
|
+
recordEvent(event: AgentEvent): Promise<void>;
|
|
1396
|
+
}
|
|
1397
|
+
interface EvaluationScore {
|
|
1398
|
+
value: number;
|
|
1399
|
+
passed: boolean;
|
|
1400
|
+
code?: string;
|
|
1401
|
+
}
|
|
1402
|
+
interface EvaluationScorer {
|
|
1403
|
+
id: string;
|
|
1404
|
+
version: string;
|
|
1405
|
+
score(output: JsonValue, expected: JsonValue, context: EvaluationAttemptContext): EvaluationScore | Promise<EvaluationScore>;
|
|
1406
|
+
}
|
|
1407
|
+
interface RunEvaluationOptions {
|
|
1408
|
+
id: string;
|
|
1409
|
+
suite: EvaluationSuite;
|
|
1410
|
+
profile: EvaluationProfile;
|
|
1411
|
+
repetitions?: number;
|
|
1412
|
+
timeoutMs?: number;
|
|
1413
|
+
signal?: AbortSignal;
|
|
1414
|
+
budget?: ObservedTaskBudget;
|
|
1415
|
+
trace?: EvaluationTraceWriter;
|
|
1416
|
+
execute(input: JsonValue, context: EvaluationAttemptContext): {
|
|
1417
|
+
output: JsonValue;
|
|
1418
|
+
usage?: Usage;
|
|
1419
|
+
} | Promise<{
|
|
1420
|
+
output: JsonValue;
|
|
1421
|
+
usage?: Usage;
|
|
1422
|
+
}>;
|
|
1423
|
+
scorers: readonly EvaluationScorer[];
|
|
1424
|
+
}
|
|
1425
|
+
type EvaluationAttemptStatus = 'passed' | 'failed' | 'error' | 'denied' | 'cancelled' | 'timed-out';
|
|
1426
|
+
type EvaluationFailurePhase = 'admission' | 'execution' | 'verification';
|
|
1427
|
+
interface EvaluationAttempt {
|
|
1428
|
+
id: string;
|
|
1429
|
+
caseId: string;
|
|
1430
|
+
repetition: number;
|
|
1431
|
+
status: EvaluationAttemptStatus;
|
|
1432
|
+
passed: boolean;
|
|
1433
|
+
admitted: boolean;
|
|
1434
|
+
durationMs: number;
|
|
1435
|
+
outputDigest?: string;
|
|
1436
|
+
/** Preserves an observed budget rejection if terminal tracing later times out or is cancelled. */
|
|
1437
|
+
budgetDenied?: true;
|
|
1438
|
+
scores: readonly (EvaluationScore & {
|
|
1439
|
+
scorerId: string;
|
|
1440
|
+
})[];
|
|
1441
|
+
failure?: {
|
|
1442
|
+
phase: EvaluationFailurePhase;
|
|
1443
|
+
code: string;
|
|
1444
|
+
};
|
|
1445
|
+
usage?: Usage;
|
|
1446
|
+
}
|
|
1447
|
+
interface EvaluationCoverage {
|
|
1448
|
+
known: number;
|
|
1449
|
+
total: number | null;
|
|
1450
|
+
}
|
|
1451
|
+
interface EvaluationUsage {
|
|
1452
|
+
attempts: number;
|
|
1453
|
+
inputTokens: EvaluationCoverage;
|
|
1454
|
+
outputTokens: EvaluationCoverage;
|
|
1455
|
+
cachedInputTokens: EvaluationCoverage;
|
|
1456
|
+
cacheCreationTokens: EvaluationCoverage;
|
|
1457
|
+
reportedCostUsd: readonly (EvaluationCoverage & {
|
|
1458
|
+
costMeaning: Usage['costMeaning'];
|
|
1459
|
+
})[];
|
|
1460
|
+
}
|
|
1461
|
+
interface EvaluationMetrics {
|
|
1462
|
+
total: number;
|
|
1463
|
+
passed: number;
|
|
1464
|
+
firstPassRate: number;
|
|
1465
|
+
/** One entry per deliberate repetition, each measured over the entire corpus. */
|
|
1466
|
+
repetitionPassRates: readonly number[];
|
|
1467
|
+
/** Fraction of cases with all repetitions observed and exactly one output digest. */
|
|
1468
|
+
consistencyRate: number;
|
|
1469
|
+
durationMs: {
|
|
1470
|
+
p50: number;
|
|
1471
|
+
p95: number;
|
|
1472
|
+
};
|
|
1473
|
+
/** Counts evaluation admission, not native provider launches. */
|
|
1474
|
+
admissions: number;
|
|
1475
|
+
denials: number;
|
|
1476
|
+
}
|
|
1477
|
+
interface EvaluationReport {
|
|
1478
|
+
format: 1;
|
|
1479
|
+
id: string;
|
|
1480
|
+
suite: {
|
|
1481
|
+
id: string;
|
|
1482
|
+
version: string;
|
|
1483
|
+
caseIds: readonly string[];
|
|
1484
|
+
};
|
|
1485
|
+
suiteDigest: string;
|
|
1486
|
+
scorers: readonly {
|
|
1487
|
+
id: string;
|
|
1488
|
+
version: string;
|
|
1489
|
+
}[];
|
|
1490
|
+
scorerDigest: string;
|
|
1491
|
+
profile: EvaluationProfile;
|
|
1492
|
+
profileDigest: string;
|
|
1493
|
+
repetitions: number;
|
|
1494
|
+
timeoutMs: number;
|
|
1495
|
+
startedAt: number;
|
|
1496
|
+
completedAt: number;
|
|
1497
|
+
attempts: readonly EvaluationAttempt[];
|
|
1498
|
+
metrics: EvaluationMetrics;
|
|
1499
|
+
usage: EvaluationUsage;
|
|
1500
|
+
digest: string;
|
|
1501
|
+
}
|
|
1502
|
+
interface EvaluationComparison {
|
|
1503
|
+
comparable: true;
|
|
1504
|
+
baselineId: string;
|
|
1505
|
+
candidateId: string;
|
|
1506
|
+
baselineProfileDigest: string;
|
|
1507
|
+
candidateProfileDigest: string;
|
|
1508
|
+
baselineSourceDigest: string;
|
|
1509
|
+
candidateSourceDigest: string;
|
|
1510
|
+
deltas: {
|
|
1511
|
+
passRate: number;
|
|
1512
|
+
firstPassRate: number;
|
|
1513
|
+
consistencyRate: number;
|
|
1514
|
+
durationP50Ms: number;
|
|
1515
|
+
durationP95Ms: number;
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
/** Sequential, explicitly repeated evaluations. No implicit retries or provider launches. */
|
|
1520
|
+
declare function runEvaluation(input: RunEvaluationOptions): Promise<EvaluationReport>;
|
|
1521
|
+
|
|
1522
|
+
/** Validate a serialized report before using any measurements in a comparison. */
|
|
1523
|
+
declare function validateEvaluationReport(value: unknown): EvaluationReport;
|
|
1524
|
+
declare function compareEvaluations(baseline: EvaluationReport, candidate: EvaluationReport): EvaluationComparison;
|
|
1525
|
+
|
|
1526
|
+
/** One entry of a system manifest's `postconditions` list. */
|
|
1527
|
+
interface PostconditionDeclaration {
|
|
1528
|
+
id: string;
|
|
1529
|
+
description: string;
|
|
1530
|
+
}
|
|
1531
|
+
/** What a verifier may look at. The agent's final message is deliberately not part of it. */
|
|
1532
|
+
interface PostconditionContext {
|
|
1533
|
+
/** Where the run left its results, as reported by the harness: a path, a row id, a record key. */
|
|
1534
|
+
state: JsonValue;
|
|
1535
|
+
input: JsonValue;
|
|
1536
|
+
expected: JsonValue;
|
|
1537
|
+
caseId: string;
|
|
1538
|
+
attemptId: string;
|
|
1539
|
+
repetition: number;
|
|
1540
|
+
signal: AbortSignal;
|
|
1541
|
+
/** Epoch milliseconds. */
|
|
1542
|
+
deadline: number;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* `verified` needs evidence of what was observed: a non-blank text, or a list or object with at
|
|
1546
|
+
* least one text, number or boolean inside. A verdict without it counts as failed.
|
|
1547
|
+
*/
|
|
1548
|
+
type PostconditionVerdict = {
|
|
1549
|
+
status: 'verified';
|
|
1550
|
+
evidence: JsonValue;
|
|
1551
|
+
} | {
|
|
1552
|
+
status: 'failed';
|
|
1553
|
+
evidence: JsonValue;
|
|
1554
|
+
code?: string;
|
|
1555
|
+
};
|
|
1556
|
+
/** Inspects the state a run left behind and says whether the postcondition holds. */
|
|
1557
|
+
interface PostconditionVerifier {
|
|
1558
|
+
/** The declared postcondition this verifier answers for. */
|
|
1559
|
+
id: string;
|
|
1560
|
+
/** Change it whenever the check or its meaning changes; recorded baselines are bound to it. */
|
|
1561
|
+
version: string;
|
|
1562
|
+
/**
|
|
1563
|
+
* Should stop when `context.signal` aborts. If it does not, the gate stops waiting for it at that
|
|
1564
|
+
* moment and ignores its answer.
|
|
1565
|
+
*/
|
|
1566
|
+
verify(context: PostconditionContext): PostconditionVerdict | Promise<PostconditionVerdict>;
|
|
1567
|
+
}
|
|
1568
|
+
/** One verifier's answer for one attempt, as it is recorded in a promotion decision. */
|
|
1569
|
+
interface PostconditionResult {
|
|
1570
|
+
id: string;
|
|
1571
|
+
status: 'verified' | 'failed';
|
|
1572
|
+
/** Symbolic reason for a failure: the verifier's own, or one of the gate's. */
|
|
1573
|
+
code?: string;
|
|
1574
|
+
evidence: JsonValue;
|
|
1575
|
+
}
|
|
1576
|
+
/** Longest evidence, as JSON text, that one verdict may carry into a decision. */
|
|
1577
|
+
declare const POSTCONDITION_EVIDENCE_LIMIT = 16384;
|
|
1578
|
+
/** Verifiers by postcondition id. A declared postcondition with no entry here cannot be verified. */
|
|
1579
|
+
declare class PostconditionRegistry {
|
|
1580
|
+
#private;
|
|
1581
|
+
/** Throws when the verifier is malformed or its id is already taken. */
|
|
1582
|
+
register(verifier: PostconditionVerifier): this;
|
|
1583
|
+
get(id: string): PostconditionVerifier | undefined;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
type PromotionChange = 'harness' | 'model' | 'prompt';
|
|
1587
|
+
/** What one run hands back. `state` says where to look; `claim` is what the agent said. */
|
|
1588
|
+
interface PromotionRunResult {
|
|
1589
|
+
state: JsonValue;
|
|
1590
|
+
/** The agent's final message. Recorded as a digest and never shown to a verifier. */
|
|
1591
|
+
claim?: string;
|
|
1592
|
+
usage?: Usage;
|
|
1593
|
+
}
|
|
1594
|
+
/** One version of a system: its harness and model (the profile), its prompt, and how to run it. */
|
|
1595
|
+
interface PromotionSubject {
|
|
1596
|
+
profile: EvaluationProfile;
|
|
1597
|
+
/** SHA-256 of the prompt text this version runs with. */
|
|
1598
|
+
promptDigest: string;
|
|
1599
|
+
/**
|
|
1600
|
+
* Must stop its work and settle when `context.signal` aborts. The gate waits for it to settle
|
|
1601
|
+
* before it gives the attempt's admission slot back, because the run may still have a provider
|
|
1602
|
+
* process alive: a run that ignores the signal keeps the gate pending and its slot held.
|
|
1603
|
+
*/
|
|
1604
|
+
run(input: JsonValue, context: EvaluationAttemptContext): PromotionRunResult | Promise<PromotionRunResult>;
|
|
1605
|
+
}
|
|
1606
|
+
/** The `candidate` of an earlier decision that was promoted, reused instead of running it again. */
|
|
1607
|
+
interface RecordedBaseline {
|
|
1608
|
+
report: EvaluationReport;
|
|
1609
|
+
promptDigest: string;
|
|
1610
|
+
}
|
|
1611
|
+
interface PromotionGateOptions {
|
|
1612
|
+
id: string;
|
|
1613
|
+
/** The manifest's declared postconditions. Every one needs a registered verifier. */
|
|
1614
|
+
postconditions: readonly PostconditionDeclaration[];
|
|
1615
|
+
verifiers: PostconditionRegistry;
|
|
1616
|
+
suite: EvaluationSuite;
|
|
1617
|
+
baseline: PromotionSubject | RecordedBaseline;
|
|
1618
|
+
candidate: PromotionSubject;
|
|
1619
|
+
repetitions?: number;
|
|
1620
|
+
/**
|
|
1621
|
+
* Per attempt, and it includes the wait for admission: size it for a canary that queues. At the
|
|
1622
|
+
* deadline the attempt's signal aborts. A verifier is cut off right then; a `run` is waited for.
|
|
1623
|
+
*/
|
|
1624
|
+
timeoutMs?: number;
|
|
1625
|
+
signal?: AbortSignal;
|
|
1626
|
+
/** Admission for every attempt. Use `canaryBudget` so these runs yield to production. */
|
|
1627
|
+
budget?: ObservedTaskBudget;
|
|
1628
|
+
trace?: EvaluationTraceWriter;
|
|
1629
|
+
}
|
|
1630
|
+
type PromotionBlock = {
|
|
1631
|
+
code: 'NO_POSTCONDITIONS';
|
|
1632
|
+
} | {
|
|
1633
|
+
code: 'VERIFIER_MISSING';
|
|
1634
|
+
postconditionId: string;
|
|
1635
|
+
} | {
|
|
1636
|
+
code: 'BASELINE_INCOMPARABLE';
|
|
1637
|
+
} | {
|
|
1638
|
+
code: 'BASELINE_INCOMPLETE' | 'CANDIDATE_INCOMPLETE';
|
|
1639
|
+
planned: number;
|
|
1640
|
+
completed: number;
|
|
1641
|
+
} | {
|
|
1642
|
+
code: 'POSTCONDITION_FAILED';
|
|
1643
|
+
postconditionId: string;
|
|
1644
|
+
failedAttempts: number;
|
|
1645
|
+
regression: boolean;
|
|
1646
|
+
};
|
|
1647
|
+
type PostconditionStanding = 'verified' | 'failed' | 'not-verified' | 'unverifiable';
|
|
1648
|
+
interface PromotionAttemptEvidence {
|
|
1649
|
+
attemptId: string;
|
|
1650
|
+
caseId: string;
|
|
1651
|
+
repetition: number;
|
|
1652
|
+
status: EvaluationAttemptStatus;
|
|
1653
|
+
claimDigest?: string;
|
|
1654
|
+
postconditions: readonly PostconditionResult[];
|
|
1655
|
+
}
|
|
1656
|
+
interface PromotionSide {
|
|
1657
|
+
profileDigest: string;
|
|
1658
|
+
promptDigest: string;
|
|
1659
|
+
report: EvaluationReport;
|
|
1660
|
+
/** Per-attempt evidence. Empty for a recorded baseline, whose evidence is in its own decision. */
|
|
1661
|
+
attempts: readonly PromotionAttemptEvidence[];
|
|
1662
|
+
}
|
|
1663
|
+
interface PromotionDecision {
|
|
1664
|
+
format: 1;
|
|
1665
|
+
id: string;
|
|
1666
|
+
/** `unchanged`: harness, model and prompt are the same, so nothing was run. */
|
|
1667
|
+
decision: 'promote' | 'block' | 'unchanged';
|
|
1668
|
+
changed: readonly PromotionChange[];
|
|
1669
|
+
/** Every reason promotion is blocked. Empty unless `decision` is `block`. */
|
|
1670
|
+
blocks: readonly PromotionBlock[];
|
|
1671
|
+
postconditions: readonly {
|
|
1672
|
+
id: string;
|
|
1673
|
+
description: string;
|
|
1674
|
+
verifierVersion: string | null;
|
|
1675
|
+
baseline: PostconditionStanding;
|
|
1676
|
+
candidate: PostconditionStanding;
|
|
1677
|
+
}[];
|
|
1678
|
+
baseline?: PromotionSide;
|
|
1679
|
+
candidate?: PromotionSide;
|
|
1680
|
+
comparison?: EvaluationComparison;
|
|
1681
|
+
decidedAt: number;
|
|
1682
|
+
/** SHA-256 of everything above: detects a corrupted record, it does not authenticate one. */
|
|
1683
|
+
digest: string;
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Decides whether a changed harness, model or prompt may replace the baseline.
|
|
1687
|
+
*
|
|
1688
|
+
* "Done" is a verified postcondition: each declared postcondition is checked by its registered
|
|
1689
|
+
* verifier against the state every run left behind, for every case and repetition. Promotion is
|
|
1690
|
+
* blocked when one fails, when one has no verifier, when the system declares none, or when the
|
|
1691
|
+
* evaluation could not be completed or compared. The agent's final message decides nothing.
|
|
1692
|
+
*
|
|
1693
|
+
* A run is spent only when it can change the answer: an unchanged candidate, a missing verifier
|
|
1694
|
+
* and an incomparable recorded baseline are decided without running anything, and the candidate is
|
|
1695
|
+
* not run when the baseline could not be completed. Malformed input throws. The returned decision
|
|
1696
|
+
* is frozen JSON the caller can record as is.
|
|
1697
|
+
*/
|
|
1698
|
+
declare function runPromotionGate(input: PromotionGateOptions): Promise<PromotionDecision>;
|
|
1699
|
+
|
|
1700
|
+
/** The part of the shared admission ledger a canary needs. */
|
|
1701
|
+
type CanaryLedger = Pick<HostLedger, 'acquire' | 'release'>;
|
|
1702
|
+
interface CanaryBudgetOptions {
|
|
1703
|
+
/** The provider account whose slots the evaluated system uses. */
|
|
1704
|
+
providerKey: string;
|
|
1705
|
+
/** Shown as the holder of the slot, for example `my-system:canary`. */
|
|
1706
|
+
owner: string;
|
|
1707
|
+
/** How long one attempt may wait for a slot. It counts against the attempt's own timeout. */
|
|
1708
|
+
maxWaitMs: number;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Admission for evaluation attempts at the ledger's lowest priority. Each attempt takes one slot
|
|
1712
|
+
* and gives it back when it settles; while a production launch is waiting, the attempt waits behind
|
|
1713
|
+
* it. A refused admission rejects with `LaunchRefusedError`, which the evaluation runner records as
|
|
1714
|
+
* a budget denial. The evaluated `run` must not take a second slot for the same turn.
|
|
1715
|
+
*/
|
|
1716
|
+
declare function canaryBudget(ledger: CanaryLedger, options: CanaryBudgetOptions): ObservedTaskBudget;
|
|
1717
|
+
|
|
1718
|
+
interface HandoffTarget {
|
|
1719
|
+
readonly id: string;
|
|
1720
|
+
readonly version: string;
|
|
1721
|
+
readonly provider?: string;
|
|
1722
|
+
readonly model?: string;
|
|
1723
|
+
}
|
|
1724
|
+
interface TaskHandoffDraft {
|
|
1725
|
+
id: string;
|
|
1726
|
+
goal: string;
|
|
1727
|
+
requirements: readonly string[];
|
|
1728
|
+
context: JsonValue;
|
|
1729
|
+
source: {
|
|
1730
|
+
id: string;
|
|
1731
|
+
version: string;
|
|
1732
|
+
digest: string;
|
|
1733
|
+
episodeId?: string;
|
|
1734
|
+
};
|
|
1735
|
+
destination: HandoffTarget;
|
|
1736
|
+
/** Provenance only. Never passed to an implicit Agent or native resume operation. */
|
|
1737
|
+
sourceSession?: SessionRef;
|
|
1738
|
+
evidence: readonly {
|
|
1739
|
+
id: string;
|
|
1740
|
+
digest: string;
|
|
1741
|
+
}[];
|
|
1742
|
+
artifacts: readonly {
|
|
1743
|
+
uri: string;
|
|
1744
|
+
digest: string;
|
|
1745
|
+
}[];
|
|
1746
|
+
pending: readonly string[];
|
|
1747
|
+
unresolvedEffects: readonly string[];
|
|
1748
|
+
}
|
|
1749
|
+
interface TaskHandoff extends Readonly<TaskHandoffDraft> {
|
|
1750
|
+
readonly source: Readonly<TaskHandoffDraft['source']>;
|
|
1751
|
+
readonly sourceSession?: Readonly<SessionRef>;
|
|
1752
|
+
readonly evidence: readonly Readonly<TaskHandoffDraft['evidence'][number]>[];
|
|
1753
|
+
readonly artifacts: readonly Readonly<TaskHandoffDraft['artifacts'][number]>[];
|
|
1754
|
+
readonly format: 1;
|
|
1755
|
+
readonly digest: string;
|
|
1756
|
+
}
|
|
1757
|
+
/** Trusted application port; save must atomically reject an existing id with different content. */
|
|
1758
|
+
interface HandoffStore {
|
|
1759
|
+
save(handoff: TaskHandoff): Promise<void>;
|
|
1760
|
+
load(id: string): Promise<TaskHandoff | undefined>;
|
|
1761
|
+
}
|
|
1762
|
+
interface HandoffContext extends DecisionContext {
|
|
1763
|
+
readonly handoff: TaskHandoff;
|
|
1764
|
+
readonly target: HandoffTarget;
|
|
1765
|
+
}
|
|
1766
|
+
interface HandoffEffectContext extends DecisionEffectContext {
|
|
1767
|
+
readonly handoff: TaskHandoff;
|
|
1768
|
+
readonly target: HandoffTarget;
|
|
1769
|
+
}
|
|
1770
|
+
interface HandoffRunOptions {
|
|
1771
|
+
id: string;
|
|
1772
|
+
handoffId: string;
|
|
1773
|
+
store: HandoffStore;
|
|
1774
|
+
decisionStore: DecisionStore;
|
|
1775
|
+
target: HandoffTarget;
|
|
1776
|
+
sourceDigest: string;
|
|
1777
|
+
authority: {
|
|
1778
|
+
id: string;
|
|
1779
|
+
version: string;
|
|
1780
|
+
};
|
|
1781
|
+
authorize(context: HandoffContext): ReturnType<DecisionRunOptions['authorize']>;
|
|
1782
|
+
isCurrent(context: HandoffContext): boolean;
|
|
1783
|
+
execute(context: HandoffEffectContext): ReturnType<DecisionRunOptions['execute']>;
|
|
1784
|
+
verify(result: JsonValue, context: HandoffEffectContext): ReturnType<DecisionRunOptions['verify']>;
|
|
1785
|
+
signal?: AbortSignal;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/** Selected context and provenance are data only; no generated timestamp enters the identity. */
|
|
1789
|
+
declare function createTaskHandoff(draft: TaskHandoffDraft): TaskHandoff;
|
|
1790
|
+
|
|
1791
|
+
/** Adapts the existing exclusive workflow lease; same-id content is immutable. */
|
|
1792
|
+
declare class WorkflowHandoffStore implements HandoffStore {
|
|
1793
|
+
private readonly store;
|
|
1794
|
+
constructor(store: WorkflowStore);
|
|
1795
|
+
save(handoff: TaskHandoff): Promise<void>;
|
|
1796
|
+
load(id: string): Promise<TaskHandoff | undefined>;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
/** One application effect, exclusively executed by DecisionRunner. References never grant authority. */
|
|
1800
|
+
declare function runHandoff(options: HandoffRunOptions): Promise<DecisionRecord>;
|
|
1801
|
+
|
|
1802
|
+
/** Validate durable state without authorizing, dispatching, verifying, or saving a decision. */
|
|
1803
|
+
declare function readHandoffDecision(options: {
|
|
1804
|
+
id: string;
|
|
1805
|
+
handoffId: string;
|
|
1806
|
+
store: HandoffStore;
|
|
1807
|
+
decisionStore: DecisionStore;
|
|
1808
|
+
}): Promise<DecisionRecord | undefined>;
|
|
1809
|
+
|
|
1810
|
+
interface CompileRequest {
|
|
1811
|
+
/** The store itself, not a stand-in: its rows are the only source of pinned text. */
|
|
1812
|
+
constraints: ConstraintStore;
|
|
1813
|
+
scopes: readonly string[];
|
|
1814
|
+
task: TaskMaterial;
|
|
1815
|
+
budget: ContextBudget;
|
|
1816
|
+
/**
|
|
1817
|
+
* What the caller knows the store must hold: the `seen` of its previous call, entries from
|
|
1818
|
+
* the system's manifest, or both. Every scope named here must be among `scopes`. When the
|
|
1819
|
+
* store holds less, the call throws `ConstraintIntegrityError`.
|
|
1820
|
+
*
|
|
1821
|
+
* It has no default. `[]` means the caller has nothing to compare with, and then a store
|
|
1822
|
+
* that lost its newest versions, or all of them, compiles as if nothing had happened.
|
|
1823
|
+
*/
|
|
1824
|
+
require: readonly ConstraintExpectation[];
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Builds the context of one call.
|
|
1828
|
+
*
|
|
1829
|
+
* The pinned constraints go to `pinned`, whole, and never into `prompt`: whatever is later
|
|
1830
|
+
* done to the conversation (selection here, a summary elsewhere) cannot remove them. The
|
|
1831
|
+
* task instructions are kept whole too, as the caller wrote them. References are added in
|
|
1832
|
+
* order while they fit, then the most recent history; their text is indented under its own
|
|
1833
|
+
* heading or speaker, so it cannot add a section or an entry to the prompt.
|
|
1834
|
+
*
|
|
1835
|
+
* Throws `ContextBudgetError` rather than trim a constraint or the instructions, and
|
|
1836
|
+
* `ConstraintIntegrityError` when a stored row does not verify or the store holds less than
|
|
1837
|
+
* `require` states. The store cannot notice by itself that its newest versions are gone;
|
|
1838
|
+
* `require` is how the caller notices: the previous call's `seen`, the manifest's list, or both.
|
|
1839
|
+
*/
|
|
1840
|
+
declare function compileContext(request: CompileRequest): CompiledContext;
|
|
1841
|
+
|
|
1842
|
+
interface SystemConstraintStoreOptions {
|
|
1843
|
+
/** Absolute directory under which every system keeps its own folder. */
|
|
1844
|
+
root: string;
|
|
1845
|
+
/** The system's name, as the host calls it (`grow`, `strategy`). One folder per system. */
|
|
1846
|
+
system: string;
|
|
1847
|
+
/** Public half of the owner's authority. */
|
|
1848
|
+
publicKey: string;
|
|
1849
|
+
/** The id the host recorded for this system's store, when it keeps one. */
|
|
1850
|
+
storeId?: string;
|
|
1851
|
+
}
|
|
1852
|
+
/** Where the store of one system lives: `<root>/<system>/constraints.sqlite`. */
|
|
1853
|
+
declare function systemConstraintStorePath(root: string, system: string): string;
|
|
1854
|
+
/**
|
|
1855
|
+
* Opens the constraint store of one system for reading, to hand to the `pinned` option of an
|
|
1856
|
+
* Agent. It never creates anything: a missing, empty or foreign file fails with
|
|
1857
|
+
* `ConstraintIntegrityError`. Making the store is the owner's act (`ConstraintStore.create`).
|
|
1858
|
+
*/
|
|
1859
|
+
declare function openSystemConstraintStore(options: SystemConstraintStoreOptions): ConstraintStore;
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* Codex CLI versions whose `developer_instructions` delivery was measured on the wire
|
|
1863
|
+
* (scripts/contexto-canal-probe, receipt in docs/validation). Another version is not claimed
|
|
1864
|
+
* until the probe is run against it.
|
|
1865
|
+
*/
|
|
1866
|
+
declare const CODEX_PROBED_VERSIONS: readonly string[];
|
|
1867
|
+
interface PinnedDeliveryRequest {
|
|
1868
|
+
/** The options the caller would have used. They are copied, never changed. */
|
|
1869
|
+
options: AgentOptions;
|
|
1870
|
+
/** The `pinned` of a compiled context. Nothing else is accepted. */
|
|
1871
|
+
pinned: PinnedChannel;
|
|
1872
|
+
/** `fresh` starts a provider session; `resume` continues one (a fork counts as `resume`). */
|
|
1873
|
+
turn: 'fresh' | 'resume';
|
|
1874
|
+
/** The installed CLI version, as `agent.ready()` or `--version` reports it. Needed for Codex. */
|
|
1875
|
+
cliVersion?: string;
|
|
1876
|
+
}
|
|
1877
|
+
interface PinnedChannelInfo {
|
|
1878
|
+
id: 'claude-append-system-prompt' | 'codex-developer-instructions';
|
|
1879
|
+
/**
|
|
1880
|
+
* `cli-flag`: the CLI's own system-prompt flag, passed by the core on every invocation.
|
|
1881
|
+
* `wire-probe`: seen in the request body, in the developer role, for the probed versions.
|
|
1882
|
+
*/
|
|
1883
|
+
evidence: 'cli-flag' | 'wire-probe';
|
|
1884
|
+
}
|
|
1885
|
+
/** Options that carry the constraints on a channel outside the conversation. */
|
|
1886
|
+
interface PinnedDelivered {
|
|
1887
|
+
status: 'pinned';
|
|
1888
|
+
provider: string;
|
|
1889
|
+
channel: PinnedChannelInfo;
|
|
1890
|
+
/**
|
|
1891
|
+
* Valid for one send. Compile and deliver again for the next one: a `Session` keeps the
|
|
1892
|
+
* options it was opened with, so a second `send` on it would not carry a newer version.
|
|
1893
|
+
*
|
|
1894
|
+
* `transport` is always `'exec'` here, also when the caller left it unset: delivery was
|
|
1895
|
+
* examined for exec only, and `'auto'` could pick the control transport.
|
|
1896
|
+
*/
|
|
1897
|
+
options: AgentOptions;
|
|
1898
|
+
/**
|
|
1899
|
+
* True for Codex. Use the options with `Agent.run` only, never with `openSession`: the
|
|
1900
|
+
* second send of a session is a `codex exec resume`, where the CLI does not send constraints.
|
|
1901
|
+
*/
|
|
1902
|
+
oneShotOnly: boolean;
|
|
1903
|
+
carried: PinnedChannel['carried'];
|
|
1904
|
+
digest: string;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* No constraint is active in the requested scopes, so nothing was attached. This is also what a
|
|
1908
|
+
* lost store or a mistyped scope looks like; `requirePinned` refuses it unless told otherwise.
|
|
1909
|
+
*/
|
|
1910
|
+
interface PinnedNothing {
|
|
1911
|
+
status: 'nothing-pinned';
|
|
1912
|
+
provider: string;
|
|
1913
|
+
/** A copy of the caller's options, unchanged. */
|
|
1914
|
+
options: AgentOptions;
|
|
1915
|
+
carried: PinnedChannel['carried'];
|
|
1916
|
+
digest: string;
|
|
1917
|
+
}
|
|
1918
|
+
/** There is no verified channel for this turn. The constraints were not attached to anything. */
|
|
1919
|
+
interface PinnedUnverified {
|
|
1920
|
+
status: 'unverified-channel';
|
|
1921
|
+
provider: string;
|
|
1922
|
+
reason: string;
|
|
1923
|
+
}
|
|
1924
|
+
type PinnedDelivery = PinnedDelivered | PinnedNothing | PinnedUnverified;
|
|
1925
|
+
/**
|
|
1926
|
+
* Attaches the compiled constraints to the provider's instruction channel for one turn.
|
|
1927
|
+
*
|
|
1928
|
+
* Claude exec: `instructions`, which the core passes as `--append-system-prompt` on every
|
|
1929
|
+
* invocation, new or resumed. Codex exec, new session only: `instructions` too, which the core
|
|
1930
|
+
* passes as `--config developer_instructions=…` and the CLI sends in the developer role. A
|
|
1931
|
+
* resumed Codex session replays the value it started with and ignores a new one, so that case, the control transport, an unprobed Codex version
|
|
1932
|
+
* and any other provider return `unverified-channel` and no options at all.
|
|
1933
|
+
*
|
|
1934
|
+
* `turn` is the caller's word; nothing here can see what the caller does with the options.
|
|
1935
|
+
* For Codex the result is marked `oneShotOnly`. With no active constraint the result is
|
|
1936
|
+
* `nothing-pinned`, never `pinned`.
|
|
1937
|
+
*/
|
|
1938
|
+
declare function deliverPinned(request: PinnedDeliveryRequest): PinnedDelivery;
|
|
1939
|
+
/**
|
|
1940
|
+
* The delivery a turn may run with. Throws `UnverifiedPinnedChannelError` when there is no
|
|
1941
|
+
* verified channel, and `NothingPinnedError` when no constraint was active, unless the caller
|
|
1942
|
+
* passes `{ allowEmpty: true }` because it knows this system has none.
|
|
1943
|
+
*/
|
|
1944
|
+
declare function requirePinned(delivery: PinnedDelivery): PinnedDelivered;
|
|
1945
|
+
declare function requirePinned(delivery: PinnedDelivery, allow: {
|
|
1946
|
+
allowEmpty: boolean;
|
|
1947
|
+
}): PinnedDelivered | PinnedNothing;
|
|
1948
|
+
|
|
1949
|
+
/** Strict JSON, as stored. No undefined, no functions, no class instances. */
|
|
1950
|
+
type InboxJson = null | boolean | number | string | readonly InboxJson[] | {
|
|
1951
|
+
readonly [key: string]: InboxJson;
|
|
1952
|
+
};
|
|
1953
|
+
type InboxJsonObject = {
|
|
1954
|
+
readonly [key: string]: InboxJson;
|
|
1955
|
+
};
|
|
1956
|
+
/**
|
|
1957
|
+
* `pending` waits for a person. `approved` may be used exactly once, until its deadline. The other
|
|
1958
|
+
* four are final: `consumed` (the approval was used), `rejected` (a person said no, or took back
|
|
1959
|
+
* an approval nobody had used yet), `expired` (nobody answered, or the approval was not used in
|
|
1960
|
+
* time) and `withdrawn` (the system no longer needs it).
|
|
1961
|
+
*/
|
|
1962
|
+
type InboxStatus = 'pending' | 'approved' | 'rejected' | 'expired' | 'withdrawn' | 'consumed';
|
|
1963
|
+
/**
|
|
1964
|
+
* One line of the card: a label and the place in the payload the value is read from. A system
|
|
1965
|
+
* declares its lines once per action kind when it opens the inbox; a request cannot bring its own.
|
|
1966
|
+
* The value itself always comes from the exact payload the approval is bound to.
|
|
1967
|
+
*/
|
|
1968
|
+
interface InboxDisplayField {
|
|
1969
|
+
label: string;
|
|
1970
|
+
/** Keys (or array indexes, as decimal strings) from the payload root to the value. */
|
|
1971
|
+
path: readonly string[];
|
|
1972
|
+
}
|
|
1973
|
+
/** The exact thing a person approves. Any difference in any field is a different action. */
|
|
1974
|
+
interface InboxAction {
|
|
1975
|
+
systemId: string;
|
|
1976
|
+
/** One of the irreversible actions the system declared. */
|
|
1977
|
+
actionKind: string;
|
|
1978
|
+
payload: InboxJsonObject;
|
|
1979
|
+
/** The effect in the neutral log this action will run as: run identity and idempotency key. */
|
|
1980
|
+
effect?: ManagedEffectAssociation;
|
|
1981
|
+
}
|
|
1982
|
+
interface InboxRequestInput {
|
|
1983
|
+
actionKind: string;
|
|
1984
|
+
payload: InboxJsonObject;
|
|
1985
|
+
/** Who files it, for the record: for example `grow:run-12`. It is never drawn on the card. */
|
|
1986
|
+
requestedBy: string;
|
|
1987
|
+
effect?: ManagedEffectAssociation;
|
|
1988
|
+
/** Epoch ms after which an unanswered request expires. Omit for no deadline. */
|
|
1989
|
+
expiresAt?: number;
|
|
1990
|
+
}
|
|
1991
|
+
interface InboxConsumeInput {
|
|
1992
|
+
requestId: string;
|
|
1993
|
+
/** The action about to be executed, rebuilt by the caller at execution time. */
|
|
1994
|
+
actionKind: string;
|
|
1995
|
+
payload: InboxJsonObject;
|
|
1996
|
+
effect?: ManagedEffectAssociation;
|
|
1997
|
+
/** Who executes, for the record. */
|
|
1998
|
+
by: string;
|
|
1999
|
+
}
|
|
2000
|
+
interface InboxApproveInput {
|
|
2001
|
+
requestId: string;
|
|
2002
|
+
/** The hash of the action the person was shown. It must match the stored one. */
|
|
2003
|
+
actionHash: string;
|
|
2004
|
+
by: string;
|
|
2005
|
+
/**
|
|
2006
|
+
* Epoch ms after which an unused approval expires, at most thirty days ahead. Omit for the
|
|
2007
|
+
* inbox's default lifetime: no approval is open-ended.
|
|
2008
|
+
*/
|
|
2009
|
+
expiresAt?: number;
|
|
2010
|
+
}
|
|
2011
|
+
interface InboxRejectInput {
|
|
2012
|
+
requestId: string;
|
|
2013
|
+
by: string;
|
|
2014
|
+
/** The person's own words, kept for the record. */
|
|
2015
|
+
reason?: string;
|
|
2016
|
+
}
|
|
2017
|
+
interface InboxWithdrawInput {
|
|
2018
|
+
requestId: string;
|
|
2019
|
+
by: string;
|
|
2020
|
+
reason?: string;
|
|
2021
|
+
}
|
|
2022
|
+
type InboxRefusal = 'invalid-input'
|
|
2023
|
+
/** The action kind is not one of the system's declared irreversible actions. */
|
|
2024
|
+
| 'undeclared-action'
|
|
2025
|
+
/** The system already has as many open requests as it is allowed. */
|
|
2026
|
+
| 'queue-full'
|
|
2027
|
+
/** The system filed as many requests in the last hour as it is allowed. Nothing was stored. */
|
|
2028
|
+
| 'rate-limited' | 'unknown-request'
|
|
2029
|
+
/** The action presented differs from the one the approval is bound to. */
|
|
2030
|
+
| 'action-changed' | 'not-pending' | 'not-approved'
|
|
2031
|
+
/** The approval was already used once. */
|
|
2032
|
+
| 'already-used' | 'rejected' | 'expired' | 'withdrawn'
|
|
2033
|
+
/** A stored request no longer matches its own hash. */
|
|
2034
|
+
| 'integrity'
|
|
2035
|
+
/** Another process held the file for longer than `busyTimeoutMs`. Nothing changed: try again. */
|
|
2036
|
+
| 'busy' | 'storage-unavailable' | 'closed';
|
|
2037
|
+
interface InboxFailure {
|
|
2038
|
+
ok: false;
|
|
2039
|
+
reason: InboxRefusal;
|
|
2040
|
+
detail?: string;
|
|
2041
|
+
/** The request's status when the refusal depends on it. */
|
|
2042
|
+
status?: InboxStatus;
|
|
2043
|
+
}
|
|
2044
|
+
type InboxResult<T> = ({
|
|
2045
|
+
ok: true;
|
|
2046
|
+
} & T) | InboxFailure;
|
|
2047
|
+
/** One recorded change of state: what changed, who did it and when. */
|
|
2048
|
+
interface InboxTransition {
|
|
2049
|
+
sequence: number;
|
|
2050
|
+
from: InboxStatus | null;
|
|
2051
|
+
to: InboxStatus;
|
|
2052
|
+
by: string;
|
|
2053
|
+
at: number;
|
|
2054
|
+
note?: string;
|
|
2055
|
+
}
|
|
2056
|
+
/** The last attempt to use an approval that was refused. Refusals never change the state. */
|
|
2057
|
+
interface InboxRefusedUse {
|
|
2058
|
+
at: number;
|
|
2059
|
+
by: string;
|
|
2060
|
+
reason: InboxRefusal;
|
|
2061
|
+
}
|
|
2062
|
+
/** Everything stored about one request. */
|
|
2063
|
+
interface InboxItem {
|
|
2064
|
+
requestId: string;
|
|
2065
|
+
systemId: string;
|
|
2066
|
+
actionKind: string;
|
|
2067
|
+
actionHash: string;
|
|
2068
|
+
payload: InboxJsonObject;
|
|
2069
|
+
display: readonly InboxDisplayField[];
|
|
2070
|
+
effect?: ManagedEffectAssociation;
|
|
2071
|
+
status: InboxStatus;
|
|
2072
|
+
requestedAt: number;
|
|
2073
|
+
expiresAt: number | null;
|
|
2074
|
+
approvalExpiresAt: number | null;
|
|
2075
|
+
refusedUses: number;
|
|
2076
|
+
lastRefusedUse?: InboxRefusedUse;
|
|
2077
|
+
transitions: readonly InboxTransition[];
|
|
2078
|
+
}
|
|
2079
|
+
interface InboxFiled {
|
|
2080
|
+
requestId: string;
|
|
2081
|
+
actionHash: string;
|
|
2082
|
+
status: InboxStatus;
|
|
2083
|
+
/** False when the same action already had an open request, which is returned instead. */
|
|
2084
|
+
created: boolean;
|
|
2085
|
+
}
|
|
2086
|
+
interface InboxConsumed {
|
|
2087
|
+
consumedAt: number;
|
|
2088
|
+
approvedBy: string;
|
|
2089
|
+
approvedAt: number;
|
|
2090
|
+
approvalExpiresAt: number | null;
|
|
2091
|
+
}
|
|
2092
|
+
interface InboxApproved {
|
|
2093
|
+
status: 'approved';
|
|
2094
|
+
/** When the approval stops being usable if nobody used it. */
|
|
2095
|
+
approvalExpiresAt: number;
|
|
2096
|
+
}
|
|
2097
|
+
interface InboxRejected {
|
|
2098
|
+
status: 'rejected';
|
|
2099
|
+
/** True when this took back an approval that had been given and not used. */
|
|
2100
|
+
wasApproved: boolean;
|
|
2101
|
+
}
|
|
2102
|
+
interface InboxWaitOptions {
|
|
2103
|
+
/** Zero answers at once with the current status. */
|
|
2104
|
+
maxWaitMs: number;
|
|
2105
|
+
signal?: AbortSignal;
|
|
2106
|
+
}
|
|
2107
|
+
interface InboxCommonOptions {
|
|
2108
|
+
/** Absolute path of the shared file. Defaults to `hostInboxPath()`. */
|
|
2109
|
+
databasePath?: string;
|
|
2110
|
+
/** Longest synchronous wait for another process's write. Default 1000 ms. */
|
|
2111
|
+
busyTimeoutMs?: number;
|
|
2112
|
+
/** Clock in epoch ms. Defaults to `Date.now`. */
|
|
2113
|
+
now?: () => number;
|
|
2114
|
+
}
|
|
2115
|
+
interface SystemInboxOptions extends InboxCommonOptions {
|
|
2116
|
+
systemId: string;
|
|
2117
|
+
/** The irreversible actions this system declared in its manifest. Nothing else can be filed. */
|
|
2118
|
+
irreversibleActions: readonly string[];
|
|
2119
|
+
/**
|
|
2120
|
+
* The card of each declared action: one to eight lines, each a short visible label and the
|
|
2121
|
+
* place in the payload its value is read from. Every declared action needs its lines, and they
|
|
2122
|
+
* are fixed here, by the system's code: no request can word its own card.
|
|
2123
|
+
*/
|
|
2124
|
+
display: Readonly<Record<string, readonly InboxDisplayField[]>>;
|
|
2125
|
+
/** Most requests this system may have open (pending or approved) at once. Default 100. */
|
|
2126
|
+
maxOpenRequests?: number;
|
|
2127
|
+
/**
|
|
2128
|
+
* Most new requests this system may file in any hour, open or closed. Default 200. It bounds
|
|
2129
|
+
* how fast a system stuck in a loop can grow the shared file.
|
|
2130
|
+
*/
|
|
2131
|
+
maxFiledPerHour?: number;
|
|
2132
|
+
}
|
|
2133
|
+
interface OwnerInboxOptions extends InboxCommonOptions {
|
|
2134
|
+
/**
|
|
2135
|
+
* How long an approval stays usable when the person gives no deadline. Default one hour, from
|
|
2136
|
+
* one second to thirty days. A system that was down for longer has to ask again.
|
|
2137
|
+
*/
|
|
2138
|
+
approvalLifetimeMs?: number;
|
|
2139
|
+
}
|
|
2140
|
+
/** A line of a card, already resolved to text. */
|
|
2141
|
+
interface InboxCardField {
|
|
2142
|
+
label: string;
|
|
2143
|
+
value: string;
|
|
2144
|
+
/** Set when the value was too long to show in full. */
|
|
2145
|
+
cut?: true;
|
|
2146
|
+
}
|
|
2147
|
+
/** What a person needs to decide, built only from stored structured fields. */
|
|
2148
|
+
interface InboxCard {
|
|
2149
|
+
requestId: string;
|
|
2150
|
+
systemId: string;
|
|
2151
|
+
actionKind: string;
|
|
2152
|
+
actionHash: string;
|
|
2153
|
+
requestedAt: number;
|
|
2154
|
+
requestedBy: string;
|
|
2155
|
+
expiresAt: number | null;
|
|
2156
|
+
fields: readonly InboxCardField[];
|
|
2157
|
+
/** Single values of the payload, at any depth, that no line of the card shows. */
|
|
2158
|
+
hiddenFields: number;
|
|
2159
|
+
/** Lines whose value was too long and is shown cut. */
|
|
2160
|
+
cutFields: number;
|
|
2161
|
+
/** Where to find the effect in the neutral log, when the request names one. */
|
|
2162
|
+
effect?: {
|
|
2163
|
+
runId: string;
|
|
2164
|
+
agentId: string;
|
|
2165
|
+
effectKey: string;
|
|
2166
|
+
};
|
|
2167
|
+
}
|
|
2168
|
+
/** A request that no longer waits for a person, with its last change. */
|
|
2169
|
+
interface InboxOutcome extends InboxCard {
|
|
2170
|
+
status: Exclude<InboxStatus, 'pending'>;
|
|
2171
|
+
at: number;
|
|
2172
|
+
by: string;
|
|
2173
|
+
note?: string;
|
|
2174
|
+
/** True when a person approved it at some point, whatever happened afterwards. */
|
|
2175
|
+
wasApproved: boolean;
|
|
2176
|
+
/** When the approval runs out or ran out; null when it was never approved. */
|
|
2177
|
+
approvalExpiresAt: number | null;
|
|
2178
|
+
}
|
|
2179
|
+
type InboxView = {
|
|
2180
|
+
ok: true;
|
|
2181
|
+
readAt: number;
|
|
2182
|
+
/** Every system's pending requests in one list, oldest first. */
|
|
2183
|
+
pending: readonly InboxCard[];
|
|
2184
|
+
/** How many are pending in total; larger than `pending.length` when the list was cut. */
|
|
2185
|
+
pendingTotal: number;
|
|
2186
|
+
/** Latest changes first. */
|
|
2187
|
+
recent: readonly InboxOutcome[];
|
|
2188
|
+
/** Stored requests that no longer match their own hash and are therefore not shown. */
|
|
2189
|
+
damaged: number;
|
|
2190
|
+
} | {
|
|
2191
|
+
ok: false;
|
|
2192
|
+
reason: 'absent' | 'unrecognized' | 'unavailable';
|
|
2193
|
+
};
|
|
2194
|
+
interface InboxViewOptions {
|
|
2195
|
+
now?: number;
|
|
2196
|
+
/** Default 100, at most 500. */
|
|
2197
|
+
pendingLimit?: number;
|
|
2198
|
+
/** Default 20, at most 200. */
|
|
2199
|
+
recentLimit?: number;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
/**
|
|
2203
|
+
* Where the machine's one decision inbox lives: next to the shared admission ledger, so every
|
|
2204
|
+
* system and the console find the same file. `OAR_HOST_INBOX` overrides it with an absolute path.
|
|
2205
|
+
*/
|
|
2206
|
+
declare function hostInboxPath(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
|
|
2207
|
+
/** A file that is rewritten whenever the inbox changes. Watch it instead of polling the inbox. */
|
|
2208
|
+
declare function inboxBellPath(databasePath: string): string;
|
|
2209
|
+
/**
|
|
2210
|
+
* A system's side of the inbox: it asks, waits and uses approvals, and can do nothing else.
|
|
2211
|
+
* It cannot approve, and it cannot see or touch another system's requests.
|
|
2212
|
+
*
|
|
2213
|
+
* This coordinates cooperating local processes. It is not a security boundary against a process
|
|
2214
|
+
* that can write the file directly; keeping agents away from the file is the containment's job.
|
|
2215
|
+
*
|
|
2216
|
+
* Every call answers with a result. `busy` means another process held the file for longer than
|
|
2217
|
+
* `busyTimeoutMs` and nothing changed: the caller decides when to try again.
|
|
2218
|
+
*/
|
|
2219
|
+
declare class SystemInbox {
|
|
2220
|
+
#private;
|
|
2221
|
+
readonly systemId: string;
|
|
2222
|
+
/** Throws `TypeError` for a configuration mistake, before creating any file. */
|
|
2223
|
+
constructor(options: SystemInboxOptions);
|
|
2224
|
+
/**
|
|
2225
|
+
* Asks a person to allow one irreversible action. The card shows the lines this system declared
|
|
2226
|
+
* for that action kind, each read from this payload; a payload that lacks one of them is
|
|
2227
|
+
* refused. Asking again for an action that already has an open request returns that request, so
|
|
2228
|
+
* a retry after a crash never adds a second card.
|
|
2229
|
+
*/
|
|
2230
|
+
request(input: InboxRequestInput): InboxResult<InboxFiled>;
|
|
2231
|
+
/**
|
|
2232
|
+
* Uses the approval for the action about to be executed, at most once across every process.
|
|
2233
|
+
* Call it immediately before executing, with the action rebuilt from what will really run:
|
|
2234
|
+
* if it differs in any field from the approved one, the answer is `action-changed`.
|
|
2235
|
+
* After `ok`, the approval is spent even if the caller then fails to execute.
|
|
2236
|
+
*/
|
|
2237
|
+
consume(input: InboxConsumeInput): InboxResult<InboxConsumed>;
|
|
2238
|
+
/** Gives up a request this system no longer needs. */
|
|
2239
|
+
withdraw(input: InboxWithdrawInput): InboxResult<{
|
|
2240
|
+
status: 'withdrawn';
|
|
2241
|
+
}>;
|
|
2242
|
+
/**
|
|
2243
|
+
* Everything stored about one of this system's requests, including who changed it and when.
|
|
2244
|
+
* Like every call here it takes the file's write lock for a moment (it records due expiries),
|
|
2245
|
+
* so it can answer `busy`: nothing changed, ask again.
|
|
2246
|
+
*/
|
|
2247
|
+
inspect(requestId: string): InboxResult<{
|
|
2248
|
+
item: InboxItem;
|
|
2249
|
+
}>;
|
|
2250
|
+
/**
|
|
2251
|
+
* Resolves as soon as the request stops being pending (a person answered, the system withdrew
|
|
2252
|
+
* it, or its own deadline passed), or with `pending` once `maxWaitMs` have passed. It sleeps on
|
|
2253
|
+
* the inbox's change hint and wakes by itself only at the request's deadline, not on a polling
|
|
2254
|
+
* timer. While another process holds the file it looks again every quarter of a second, and
|
|
2255
|
+
* answers `busy` only if the file is still held when the time is up. Rejects only if `signal`
|
|
2256
|
+
* aborts.
|
|
2257
|
+
*/
|
|
2258
|
+
waitForDecision(requestId: string, options: InboxWaitOptions): Promise<InboxResult<{
|
|
2259
|
+
status: InboxStatus;
|
|
2260
|
+
}>>;
|
|
2261
|
+
close(): void;
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* The person's side of the inbox: approve or reject what the systems asked. The console's main
|
|
2265
|
+
* process holds it; no system process should.
|
|
2266
|
+
*/
|
|
2267
|
+
declare class OwnerInbox {
|
|
2268
|
+
#private;
|
|
2269
|
+
/** Throws `TypeError` for a configuration mistake, before creating any file. */
|
|
2270
|
+
constructor(options?: OwnerInboxOptions);
|
|
2271
|
+
/**
|
|
2272
|
+
* Approves exactly the action whose hash is given, for one use and for a limited time: until
|
|
2273
|
+
* `expiresAt`, or for the inbox's default lifetime (one hour unless configured). A hash other
|
|
2274
|
+
* than the stored one approves nothing: the person can only approve what they were shown.
|
|
2275
|
+
*/
|
|
2276
|
+
approve(input: InboxApproveInput): InboxResult<InboxApproved>;
|
|
2277
|
+
/**
|
|
2278
|
+
* Rejects a pending request for good, or takes back an approval that was given and not used
|
|
2279
|
+
* yet. If a system already used the approval, the answer is `already-used`.
|
|
2280
|
+
*/
|
|
2281
|
+
reject(input: InboxRejectInput): InboxResult<InboxRejected>;
|
|
2282
|
+
/** Everything stored about one request of any system. */
|
|
2283
|
+
inspect(requestId: string): InboxResult<{
|
|
2284
|
+
item: InboxItem;
|
|
2285
|
+
}>;
|
|
2286
|
+
/** Records as expired every request whose deadline has passed. */
|
|
2287
|
+
sweep(): InboxResult<{
|
|
2288
|
+
expired: number;
|
|
2289
|
+
}>;
|
|
2290
|
+
close(): void;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
/**
|
|
2294
|
+
* The hash an approval is bound to. Two actions have the same hash only when the system, the
|
|
2295
|
+
* action kind, every payload value and the effect reference are all equal; key order is irrelevant.
|
|
2296
|
+
*/
|
|
2297
|
+
declare function inboxActionHash(action: InboxAction): string;
|
|
2298
|
+
|
|
2299
|
+
type Unreadable = 'absent' | 'unrecognized' | 'unavailable';
|
|
2300
|
+
/**
|
|
2301
|
+
* What the decision inbox holds right now, for a screen: the pending requests of every system in
|
|
2302
|
+
* one list, oldest first, and the latest outcomes. It opens the file read-only, so it can never
|
|
2303
|
+
* approve, expire or change anything, and it answers `absent`, `unrecognized` or `unavailable`
|
|
2304
|
+
* instead of throwing when the file is missing, is not an inbox or cannot be read.
|
|
2305
|
+
*
|
|
2306
|
+
* A request whose deadline has passed is shown as expired even if no writer has recorded it yet.
|
|
2307
|
+
* Throws `TypeError` only for a programming error: a relative path, or a time or limit that is
|
|
2308
|
+
* not a non-negative integer.
|
|
2309
|
+
*/
|
|
2310
|
+
declare function readInboxView(databasePath: string, options?: InboxViewOptions): InboxView;
|
|
2311
|
+
/**
|
|
2312
|
+
* One request in full, for a detail panel: the whole payload and every recorded transition.
|
|
2313
|
+
* Read-only, and it never throws for a missing or foreign file.
|
|
2314
|
+
*/
|
|
2315
|
+
declare function readInboxItem(databasePath: string, requestId: string): {
|
|
2316
|
+
ok: true;
|
|
2317
|
+
item: InboxItem;
|
|
2318
|
+
} | {
|
|
2319
|
+
ok: false;
|
|
2320
|
+
reason: Unreadable | 'unknown-request' | 'integrity';
|
|
2321
|
+
};
|
|
2322
|
+
|
|
2323
|
+
/** One line of plain text: no control or invisible characters, single spaces, bounded length. */
|
|
2324
|
+
declare function inboxPlainText(text: string, maxLength?: number): string;
|
|
2325
|
+
/** How a payload value reads on a card. Text is data: it is cleaned and cut, never interpreted. */
|
|
2326
|
+
declare function inboxDisplayValue(value: InboxJson): string;
|
|
2327
|
+
/**
|
|
2328
|
+
* The lines of a card. Every value is read from the payload the approval is bound to, at the
|
|
2329
|
+
* place the display line names. `hiddenFields` counts every single value of the payload, at any
|
|
2330
|
+
* depth, that no line shows; `cutFields` counts the lines whose value did not fit and was cut.
|
|
2331
|
+
* Together they say how much of what is being approved the card leaves out.
|
|
2332
|
+
*/
|
|
2333
|
+
declare function inboxCardFields(payload: InboxJsonObject, display: readonly InboxDisplayField[]): {
|
|
2334
|
+
fields: InboxCardField[];
|
|
2335
|
+
hiddenFields: number;
|
|
2336
|
+
cutFields: number;
|
|
2337
|
+
};
|
|
2338
|
+
/** The card of a stored request. A pure function of its structured fields; no model is involved. */
|
|
2339
|
+
declare function inboxCard(item: InboxItem): InboxCard;
|
|
2340
|
+
|
|
2341
|
+
/**
|
|
2342
|
+
* Every sentence the decision inbox shows, in the words of the person who answers it.
|
|
2343
|
+
* Pure functions: data in, text out. Nothing here is written by a model, and text that came from
|
|
2344
|
+
* a system is only ever placed as a value, after `inboxPlainText`.
|
|
2345
|
+
*/
|
|
2346
|
+
/** Turns an instant into the short text shown for it. */
|
|
2347
|
+
type InboxClock = (at: number) => string;
|
|
2348
|
+
/** Display names the console knows. Anything missing is shown by its identifier. */
|
|
2349
|
+
interface InboxNames {
|
|
2350
|
+
/** System id to the name the person knows it by. */
|
|
2351
|
+
systems?: Readonly<Record<string, string>>;
|
|
2352
|
+
/** Action kind to a verb phrase that completes "X quiere …", for example "enviar un email". */
|
|
2353
|
+
actions?: Readonly<Record<string, string>>;
|
|
2354
|
+
}
|
|
2355
|
+
/** The hour and minute, with day and month when the instant is not on the same day as `now`. */
|
|
2356
|
+
declare function inboxClock(now?: number): InboxClock;
|
|
2357
|
+
declare function inboxSystemName(systemId: string, names?: InboxNames): string;
|
|
2358
|
+
/** "Grow quiere enviar un email", or the plain identifiers when no name is known. */
|
|
2359
|
+
declare function inboxCardTitle(card: Pick<InboxCard, 'systemId' | 'actionKind'>, names?: InboxNames): string;
|
|
2360
|
+
declare function inboxHeadline(view: Extract<InboxView, {
|
|
2361
|
+
ok: true;
|
|
2362
|
+
}>): string;
|
|
2363
|
+
/** The lines under a card's values: when it was asked, when it expires, what is hidden or cut. */
|
|
2364
|
+
declare function inboxCardLines(card: InboxCard, now: number, clock?: InboxClock): string[];
|
|
2365
|
+
declare function inboxOutcomeLine(outcome: InboxOutcome, clock?: InboxClock): string;
|
|
2366
|
+
/** Why the inbox cannot be shown. */
|
|
2367
|
+
declare function inboxNotice(reason: Extract<InboxView, {
|
|
2368
|
+
ok: false;
|
|
2369
|
+
}>['reason']): string;
|
|
2370
|
+
/** What to tell the person right after they approved, rejected or took an approval back. */
|
|
2371
|
+
declare function inboxDecisionSentence(result: InboxResult<{
|
|
2372
|
+
status: 'approved' | 'rejected';
|
|
2373
|
+
approvalExpiresAt?: number | null;
|
|
2374
|
+
wasApproved?: boolean;
|
|
2375
|
+
}>, clock?: InboxClock): string;
|
|
2376
|
+
|
|
2377
|
+
declare function escapeInboxHtml(text: string): string;
|
|
2378
|
+
interface InboxRenderOptions {
|
|
2379
|
+
clock?: InboxClock;
|
|
2380
|
+
names?: InboxNames;
|
|
2381
|
+
}
|
|
2382
|
+
/** The whole inbox: what waits for the person, in one list, and the latest outcomes below it. */
|
|
2383
|
+
declare function renderInbox(view: InboxView, now: number, options?: InboxRenderOptions): string;
|
|
2384
|
+
|
|
2385
|
+
export { type AblationAgent, type AblationCondition, type AblationConditionSummary, type AblationMemoryNote, type AblationOutcome, type AblationRule, type AblationRun, type AblationRunContext, type AblationRunError, type AblationSignTest, type AblationSignTests, type AblationTask, type AblationUsage, type AblationVerdict, type AblationVerdictReason, type AblationVerdictResult, type AcquireOptions, type AgentDistillerOptions, type BudgetDenialReason, type BudgetFailure, type BudgetResult, CODEX_PROBED_VERSIONS, CURATOR_DEFAULT_MAX_CANDIDATES, CURATOR_DEFAULT_MAX_TEXT, CURATOR_MAX_CANDIDATES_CEILING, CURATOR_MAX_TEXT_CEILING, CURATOR_SOURCE, type CanaryBudgetOptions, type CanaryLedger, type ClockAcknowledgement, type CompileRequest, CompiledContext, type ConcurrencyChange, type ConcurrencyPolicy, ConstraintExpectation, ConstraintStore, ContextBudget, type CuratableStore, type CurateMemoryOptions, type CuratorAcceptance, type CuratorCandidateOutcome, type CuratorDistill, type CuratorDistillContext, type CuratorEpisode, type CuratorHoldReason, type CuratorInvalidReason, type CuratorJournal, type CuratorJournalEntry, type CuratorJournalOptions, type CuratorMeasurement, type CuratorPendingTally, type CuratorPooledEvidence, type CuratorProposal, type CuratorRefusal, type CuratorReport, type CuratorScreen, type CuratorScreenCandidate, type CuratorScreenReason, type CuratorScreenVerdict, DISTILLER_INSTRUCTIONS, DecisionBinding, DecisionContext, DecisionEffectContext, DecisionLease, DecisionRecord, DecisionRunOptions, DecisionRunner, DecisionStore, type DistillerAgentOptions, type EvaluationAttempt, type EvaluationAttemptContext, type EvaluationAttemptStatus, type EvaluationCase, type EvaluationComparison, type EvaluationCoverage, type EvaluationFailurePhase, type EvaluationMetrics, type EvaluationProfile, type EvaluationReport, type EvaluationScore, type EvaluationScorer, type EvaluationSuite, type EvaluationTraceWriter, type EvaluationUsage, FileWorkflowStore, HOST_LAUNCH_LIMITS, type HandoffContext, type HandoffEffectContext, type HandoffRunOptions, type HandoffStore, type HandoffTarget, type HostConcurrency, type HostHoldView, type HostLaunchAdmission, type HostLaunchBudgetLimits, type HostLaunchBudgetStatus, type HostLaunchDenial, HostLedger, type HostLedgerIdentity, type HostLedgerOptions, type HostLedgerView, type HostOwnerLookup, type HostOwnerLookupOptions, type HostOwnerReservation, type HostProviderView, type HostRecoveryOptions, type InboxAction, type InboxApproveInput, type InboxApproved, type InboxCard, type InboxCardField, type InboxClock, type InboxConsumeInput, type InboxConsumed, type InboxDisplayField, type InboxFailure, type InboxFiled, type InboxItem, type InboxJson, type InboxJsonObject, type InboxNames, type InboxOutcome, type InboxRefusal, type InboxRefusedUse, type InboxRejectInput, type InboxRejected, type InboxRenderOptions, type InboxRequestInput, type InboxResult, type InboxStatus, type InboxTransition, type InboxView, type InboxViewOptions, type InboxWaitOptions, type InboxWithdrawInput, JsonValue, type LaunchAdmission, type LaunchBudgetLimits, type LaunchBudgetStatus, type LaunchPriority, LaunchQuotaRecordError, LaunchRefusedError, LaunchReleaseError, type LaunchReservation, type LegacyMigrationOptions, type LegacyMigrationSource, MeasureMemoryOptions, type MemoryAblationOptions, type MemoryAblationReport, MemoryActor, MemoryConditionTally, MemoryEmbedder, MemoryGateRefusal, MemoryGrant, type MemoryGrantLine, MemoryGrantRequest, MemoryGrantRevocation, MemoryListQuery, MemoryLogSearch, MemoryLogSearchResult, MemoryPersistencePort, MemoryPromotion, MemoryPromotionResult, MemoryQuery, MemoryQueryPort, MemoryRecordLookup, MemoryRecordView, MemoryRevocation, MemoryRollback, MemoryScope, MemoryStatus, type MemorySystemView, type MemoryView, ObservedTaskBudget, OwnerInbox, type OwnerInboxOptions, POSTCONDITION_EVIDENCE_LIMIT, PinnedChannel, type PinnedChannelInfo, type PinnedDelivered, type PinnedDelivery, type PinnedDeliveryRequest, type PinnedNothing, type PinnedUnverified, type PostconditionContext, type PostconditionDeclaration, PostconditionRegistry, type PostconditionResult, type PostconditionStanding, type PostconditionVerdict, type PostconditionVerifier, type PromotionAttemptEvidence, type PromotionBlock, type PromotionChange, type PromotionDecision, type PromotionGateOptions, type PromotionRunResult, type PromotionSide, type PromotionSubject, type RecordedBaseline, type RunEvaluationOptions, RunLogReader, ScopedMemoryRecord, SharedLaunchBudget, type SharedLaunchBudgetOptions, type SlotOptions, SqliteSystemMemory, type SystemConstraintStoreOptions, SystemInbox, type SystemInboxOptions, SystemMemoryOptions, type TaskHandoff, type TaskHandoffDraft, TaskMaterial, TraceEpisode, TraceIdentity, TraceLease, TraceRecorder, TraceStore, WAITER_LEASE_MS, WorkflowCheckpoint, WorkflowDecisionStore, WorkflowDefinition, WorkflowHandoffStore, WorkflowLease, type WorkflowOwnership, WorkflowRearmOptions, WorkflowRearmResult, WorkflowRunLockedError, WorkflowRunOptions, WorkflowRunner, WorkflowStore, WorkflowTraceStore, ablationVerdict, agentDistiller, bindDecision, canaryBudget, candidateId, compareEvaluations, compileContext, createTaskHandoff, curateMemory, decisionHash, deliverPinned, distillerPrompt, escapeInboxHtml, fileCuratorJournal, hostInboxPath, hostLaunchLimits, hostLedgerPath, hostMemoryPath, inboxActionHash, inboxBellPath, inboxCard, inboxCardFields, inboxCardLines, inboxCardTitle, inboxClock, inboxDecisionSentence, inboxDisplayValue, inboxHeadline, inboxNotice, inboxOutcomeLine, inboxPlainText, inboxSystemName, inspectLegacyLaunchBudget, memoryCuratorJournal, openSystemConstraintStore, openTraceEpisode, parseLessons, readHandoffDecision, readHostLedgerView, readInboxItem, readInboxView, readMemoryView, readTraceEpisode, renderInbox, requirePinned, runEvaluation, runHandoff, runMemoryAblation, runPromotionGate, sameDecisionBinding, signTestPValue, systemConstraintStorePath, validateEvaluationReport };
|