@obversa/api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/accepted-result-support.d.ts +1 -0
- package/dist/accepted-result-support.js +5 -0
- package/dist/accepted-result-support.js.map +1 -0
- package/dist/action-decision.d.ts +15 -0
- package/dist/approval-support.d.ts +1 -0
- package/dist/approval-support.js +5 -0
- package/dist/approval-support.js.map +1 -0
- package/dist/artifacts/conformance.d.ts +20 -0
- package/dist/artifacts/store.d.ts +30 -0
- package/dist/budget.d.ts +36 -0
- package/dist/callback/approval.d.ts +80 -0
- package/dist/callback/client-contract.d.ts +81 -0
- package/dist/callback/gate.d.ts +49 -0
- package/dist/callback/stored-client.d.ts +22 -0
- package/dist/chunk-6NA4RDQ4.js +81 -0
- package/dist/chunk-6NA4RDQ4.js.map +1 -0
- package/dist/chunk-6NAMCSPJ.js +331 -0
- package/dist/chunk-6NAMCSPJ.js.map +1 -0
- package/dist/chunk-6ZP73HZN.js +293 -0
- package/dist/chunk-6ZP73HZN.js.map +1 -0
- package/dist/chunk-AJ353QD5.js +157 -0
- package/dist/chunk-AJ353QD5.js.map +1 -0
- package/dist/chunk-VWZKI7AG.js +552 -0
- package/dist/chunk-VWZKI7AG.js.map +1 -0
- package/dist/chunk-WGLWWKF3.js +135 -0
- package/dist/chunk-WGLWWKF3.js.map +1 -0
- package/dist/contracts.d.ts +122 -0
- package/dist/engine-conformance.d.ts +80 -0
- package/dist/environment.d.ts +53 -0
- package/dist/error.d.ts +36 -0
- package/dist/events/conformance.d.ts +20 -0
- package/dist/events/envelope.d.ts +26 -0
- package/dist/events/store.d.ts +15 -0
- package/dist/graph-commands.d.ts +23 -0
- package/dist/graph-contract.d.ts +48 -0
- package/dist/graph-executor.d.ts +61 -0
- package/dist/graph-kernel.d.ts +2 -0
- package/dist/graph-plan.d.ts +140 -0
- package/dist/graph-type.d.ts +45 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +806 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +14 -0
- package/dist/memory-conformance.d.ts +17 -0
- package/dist/memory-types.d.ts +127 -0
- package/dist/model-identity.d.ts +28 -0
- package/dist/node-data-context.d.ts +11 -0
- package/dist/preflight-result.d.ts +17 -0
- package/dist/proof/acceptance.d.ts +60 -0
- package/dist/proof/artifact.d.ts +2 -0
- package/dist/proof/cache.d.ts +46 -0
- package/dist/reasoning-record-contract.d.ts +52 -0
- package/dist/result-contract.d.ts +16 -0
- package/dist/result.d.ts +30 -0
- package/dist/run-definition-support.d.ts +1 -0
- package/dist/run-definition-support.js +5 -0
- package/dist/run-definition-support.js.map +1 -0
- package/dist/run-definition.d.ts +73 -0
- package/dist/storage/error.d.ts +7 -0
- package/dist/storage/id.d.ts +2 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +1745 -0
- package/dist/testing.js.map +1 -0
- package/dist/workspace/conformance.d.ts +30 -0
- package/dist/workspace/policy.d.ts +6 -0
- package/dist/workspace/provider.d.ts +132 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contracts.ts","../src/memory-types.ts","../src/graph-executor.ts","../src/graph-plan.ts","../src/events/store.ts","../src/callback/client-contract.ts"],"names":["fail","record","exactFields"],"mappings":";;;;;;;;;;;;;AA8FO,IAAM,cAAA,GAAiB,CAAC,MAAA,EAAQ,OAAA,EAAS,MAAM;AAC/C,IAAM,qBAAA,GAAwB,CAAC,MAAA,EAAQ,OAAO;AAwB9C,SAAS,iBACd,OAAA,EACM;AACN,EAAA,IAAI,QAAQ,aAAA,KAAkB,MAAA,IAAA,CAAW,QAAQ,KAAA,EAAO,MAAA,IAAU,OAAO,CAAA,EAAG;AAC1E,IAAA,MAAM,IAAI,UAAU,oDAAoD,CAAA;AAAA,EAC1E;AACF;AA2CO,SAAS,SAAS,KAAA,EAAiC;AACxD,EAAA,OACE,OAAO,KAAA,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M,aAAA,KAAkB,QAAA,IAAY,CAAC,eAAA,CAAgB,IAAA,CAAK,KAAA,CAAM,aAAa,CAAA,EAAG;AACzF,QAAA,MAAM,IAAI,UAAU,2DAA2D,CAAA;AAAA,MACjF;AACA,MAAAA,YAAAA,CAAY,OAAO,CAAC,MAAA,EAAQ,aAAa,eAAA,EAAiB,UAAA,EAAY,UAAU,CAAC,CAAA;AACjF,MAAA,YAAA,CAAa,KAAA,CAAM,WAAW,WAAW,CAAA;AACzC,MAAA,YAAA,CAAa,KAAA,CAAM,UAAU,UAAU,CAAA;AACvC,MAAA;AAAA,IACF,KAAK,mBAAA;AACH,MAAAA,aAAY,KAAA,EAAO,CAAC,QAAQ,WAAA,EAAa,UAAA,EAAY,QAAQ,CAAC,CAAA;AAC9D,MAAA,YAAA,CAAa,KAAA,CAAM,WAAW,WAAW,CAAA;AACzC,MAAA,YAAA,CAAa,KAAA,CAAM,UAAU,UAAU,CAAA;AACvC,MAAA,YAAA,CAAa,KAAA,CAAM,QAAQ,QAAQ,CAAA;AACnC,MAAA;AAAA,IACF,KAAK,qBAAA;AACH,MAAAA,aAAY,KAAA,EAAO,CAAC,MAAA,EAAQ,WAAA,EAAa,cAAc,CAAC,CAAA;AACxD,MAAA,YAAA,CAAa,KAAA,CAAM,WAAW,WAAW,CAAA;AACzC,MAAA,YAAA,CAAa,KAAA,CAAM,cAAc,cAAc,CAAA;AAC/C,MAAA;AAAA,IACF;AACE,MAAA,MAAM,IAAI,UAAU,6CAA6C,CAAA;AAAA;AAErE,EAAA,OAAO,KAAA;AACT","file":"index.js","sourcesContent":["/** Provider-neutral values and behavior shared by runtimes and engine plugins. */\n\nimport type { JsonValue } from './json.js';\n\nexport type {\n JsonObject,\n JsonPrimitive,\n JsonValue,\n Sha256Digest,\n} from './json.js';\nexport {\n JsonValueError,\n canonicalJson,\n cloneFrozenJson,\n digestJson,\n} from './json.js';\n\nexport interface AttemptMetadata {\n leaf: boolean;\n runId?: string;\n attemptId?: string;\n leafId: string;\n path: string[];\n label: string;\n iteration: number;\n}\n\nexport interface Usage {\n /** Total input, including cache creation and cache reads where reported. */\n inputTokens: number;\n outputTokens: number;\n cacheCreationInputTokens?: number;\n cacheReadInputTokens?: number;\n}\n\nexport type UsageReceipt =\n | { readonly kind: 'unknown' }\n | ({ readonly kind: 'reported' } & Usage);\n\nexport type AgentResultPart =\n | {\n readonly kind: 'assistant';\n readonly text: string;\n readonly final: boolean;\n }\n | {\n readonly kind: 'structured';\n readonly value: JsonValue;\n readonly final: true;\n };\n\nexport interface EngineSelectionRecord {\n readonly adapter: string;\n readonly adapterVersion: string | null;\n readonly provider: string | null;\n readonly modelFamily: string | null;\n readonly model: string | null;\n readonly executable: string | null;\n readonly capabilities: readonly string[];\n}\n\nexport interface ExecutionTarget {\n readonly adapter: string;\n readonly provider: string;\n readonly modelFamily: string;\n readonly model: string;\n readonly tools: readonly string[];\n}\n\nexport interface TeamSeat {\n readonly engine: Engine;\n readonly identity: ExecutionTarget;\n}\n\nexport type EngineFailureKind =\n | 'auth'\n | 'billing'\n | 'missing-cli'\n | 'model-unavailable'\n | 'invalid-config'\n | 'rate-limit'\n | 'quota'\n | 'transient'\n | 'timeout'\n | 'aborted'\n | 'unknown';\n\nexport interface EngineTransportFailure {\n readonly kind: EngineFailureKind;\n readonly message: string;\n readonly exitCode: number | null;\n}\n\n/** Tools used by supported agent hosts to dispatch sub-agents. */\nexport const SUBAGENT_TOOLS = ['Task', 'Agent', 'task'];\nexport const CLAUDE_SUBAGENT_TOOLS = ['Task', 'Agent'];\n\nexport interface AgentRequest {\n prompt: string;\n purpose?: 'preflight';\n system?: string;\n systemMode?: 'append' | 'replace';\n model?: string;\n maxTokens?: number;\n jsonSchema?: JsonValue;\n tools?: string[];\n allowedTools?: string[];\n workspaceMode?: 'none' | 'read' | 'write';\n cwd?: string;\n env?: Record<string, string>;\n timeoutMs?: number;\n timeoutGraceMs?: number;\n maxOutputBytes?: number;\n maxMemoryBytes?: number;\n attempt?: AttemptMetadata;\n leaf?: boolean;\n}\n\n/** A read-only workspace must expose at least one tool that can read it. */\nexport function assertReadAccess(\n request: Pick<AgentRequest, 'tools' | 'workspaceMode'>,\n): void {\n if (request.workspaceMode === 'read' && (request.tools?.length ?? 0) === 0) {\n throw new TypeError('read workspace requires at least one declared tool');\n }\n}\n\nexport interface AgentResult {\n /** Ordered assistant continuations with exactly one marked final part. */\n readonly parts: readonly AgentResultPart[];\n readonly usage: UsageReceipt;\n readonly requested: EngineSelectionRecord;\n readonly effective: EngineSelectionRecord;\n readonly stopReason?: string;\n readonly transportFailure?: EngineTransportFailure;\n readonly raw?: unknown;\n}\n\nexport type EngineIncompleteResultEvidence = Omit<AgentResult, 'parts'> & {\n readonly parts: readonly AgentResultPart[];\n};\n\nexport type EngineStreamEvent =\n | { type: 'text'; delta: string }\n | { type: 'thinking'; delta: string }\n | { type: 'tool'; name: string; phase: 'use' | 'result' }\n | { type: 'usage'; usage: UsageReceipt; model: string };\n\nexport type EngineEventSink = (event: EngineStreamEvent) => void;\n\nexport interface Engine {\n readonly name: string;\n admit?(\n request: Omit<AgentRequest, 'prompt'>,\n signal: AbortSignal,\n expectedSelection?: EngineSelectionRecord,\n ): Promise<EngineSelectionRecord>;\n run(\n request: AgentRequest,\n onEvent: EngineEventSink,\n signal: AbortSignal,\n ): Promise<AgentResult>;\n}\n\nexport type EngineRef = string | Engine;\n\nexport type EngineName = string;\n\nexport function isEngine(value: unknown): value is Engine {\n return (\n typeof value === 'object'\n && value !== null\n && typeof (value as Engine).name === 'string'\n && typeof (value as Engine).run === 'function'\n );\n}\n","export const MEMORY_ROOT = '/memories' as const;\n\nexport type MemoryPath = typeof MEMORY_ROOT | `${typeof MEMORY_ROOT}/${string}`;\n\nexport type MemoryCommandName =\n | 'view'\n | 'create'\n | 'str_replace'\n | 'insert'\n | 'delete'\n | 'rename';\n\nexport interface MemoryViewCommand {\n readonly command: 'view';\n readonly path: MemoryPath;\n readonly viewRange?: readonly [startLine: number, endLine: number | -1];\n}\n\nexport interface MemoryCreateCommand {\n readonly command: 'create';\n readonly path: MemoryPath;\n readonly text: string;\n}\n\nexport interface MemoryStrReplaceCommand {\n readonly command: 'str_replace';\n readonly path: MemoryPath;\n readonly oldText: string;\n readonly newText: string;\n}\n\nexport interface MemoryInsertCommand {\n readonly command: 'insert';\n readonly path: MemoryPath;\n readonly insertLine: number;\n readonly text: string;\n}\n\nexport interface MemoryDeleteCommand {\n readonly command: 'delete';\n readonly path: MemoryPath;\n}\n\nexport interface MemoryRenameCommand {\n readonly command: 'rename';\n readonly oldPath: MemoryPath;\n readonly newPath: MemoryPath;\n}\n\nexport type MemoryCommand =\n | MemoryViewCommand\n | MemoryCreateCommand\n | MemoryStrReplaceCommand\n | MemoryInsertCommand\n | MemoryDeleteCommand\n | MemoryRenameCommand;\n\nexport interface MemoryDirectoryEntry {\n readonly name: string;\n readonly path: MemoryPath;\n readonly kind: 'file' | 'directory';\n}\n\nexport interface MemoryDirectoryView {\n readonly kind: 'directory';\n readonly path: MemoryPath;\n readonly entries: readonly MemoryDirectoryEntry[];\n}\n\nexport interface MemoryFileView {\n readonly kind: 'file';\n readonly path: MemoryPath;\n readonly text: string;\n readonly byteLength: number;\n readonly lines: {\n readonly start: number;\n readonly end: number;\n readonly total: number;\n };\n}\n\nexport type MemoryView = MemoryDirectoryView | MemoryFileView;\n\nexport interface MemoryCreateReceipt {\n readonly path: MemoryPath;\n readonly byteLength: number;\n readonly evicted: readonly MemoryPath[];\n readonly overwritten: boolean;\n}\n\nexport interface MemoryWriteReceipt {\n readonly path: MemoryPath;\n readonly byteLength: number;\n readonly evicted: readonly MemoryPath[];\n}\n\nexport interface MemoryDeleteReceipt {\n readonly path: MemoryPath;\n readonly kind: 'file' | 'directory';\n readonly deletedFiles: number;\n readonly freedBytes: number;\n}\n\nexport interface MemoryRenameReceipt {\n readonly oldPath: MemoryPath;\n readonly newPath: MemoryPath;\n readonly kind: 'file' | 'directory';\n readonly movedFiles: number;\n}\n\nexport type MemoryErrorCode =\n | 'INVALID_COMMAND'\n | 'INVALID_ARGUMENT'\n | 'INVALID_PATH'\n | 'ROOT_PROTECTED'\n | 'INVALID_EXTENSION'\n | 'NOT_FOUND'\n | 'ALREADY_EXISTS'\n | 'PATH_CONFLICT'\n | 'INVALID_RANGE'\n | 'MATCH_NOT_FOUND'\n | 'MATCH_NOT_UNIQUE'\n | 'LIMIT_EXCEEDED'\n | 'CONFLICT'\n | 'UNSAFE_STORAGE'\n | 'STORAGE_ERROR';\n\nexport interface MemoryError {\n readonly code: MemoryErrorCode;\n readonly message: string;\n readonly path?: string;\n readonly details?: Readonly<Record<string, string | number | boolean>>;\n}\n\nexport type MemorySuccess =\n | { readonly ok: true; readonly command: 'view'; readonly value: MemoryView }\n | { readonly ok: true; readonly command: 'create'; readonly value: MemoryCreateReceipt }\n | { readonly ok: true; readonly command: 'str_replace'; readonly value: MemoryWriteReceipt }\n | { readonly ok: true; readonly command: 'insert'; readonly value: MemoryWriteReceipt }\n | { readonly ok: true; readonly command: 'delete'; readonly value: MemoryDeleteReceipt }\n | { readonly ok: true; readonly command: 'rename'; readonly value: MemoryRenameReceipt };\n\nexport interface MemoryFailure {\n readonly ok: false;\n readonly command: string;\n readonly error: MemoryError;\n}\n\nexport type MemoryResult = MemorySuccess | MemoryFailure;\n\nexport interface MemoryLimits {\n readonly maxFileBytes: number;\n readonly maxTotalBytes: number;\n readonly maxFiles: number;\n}\n\nexport interface Memory {\n readonly scope: string;\n execute(command: MemoryCommand): Promise<MemoryResult>;\n}\n","import type { Memory } from './memory-types.js';\nimport type { GraphCommand } from './graph-commands.js';\nimport type { CompiledGraphType } from './graph-type.js';\nimport type { JsonObject, JsonValue } from './json.js';\nimport type { ExecutionTarget, AgentResultPart, EngineSelectionRecord, Engine } from './contracts.js';\nimport type { AttemptBudgetPolicy, TokenBudget } from './budget.js';\nimport type { NodeDataContext } from './node-data-context.js';\nimport type { ResultContract } from './result-contract.js';\nimport type { RunStorageBinding } from './run-definition.js';\nimport type { NodeWorkspacePolicy } from './workspace/policy.js';\nimport type { ActionDecision } from './action-decision.js';\nimport type { PreflightPauseResult, PreflightFailureResult } from './preflight-result.js';\n\nexport type GraphExecutionErrorCode =\n | 'ABORTED'\n | 'DUPLICATE_POSITION'\n | 'EMPTY_DECISION'\n | 'ENGINE_IDENTITY_UNRESOLVED'\n | 'INVALID_EVENT'\n | 'INVALID_PREFLIGHT_CONFIG'\n | 'MISSING_ENGINE_BINDING'\n | 'MISSING_MEMORY'\n | 'MISSING_NODE_BINDING'\n | 'PROTOCOL'\n | 'RESUME_EVENT_MISMATCH'\n | 'STORED_GRAPH_MISMATCH';\n\nexport class GraphExecutionError extends Error {\n readonly code: GraphExecutionErrorCode;\n\n constructor(code: GraphExecutionErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'GraphExecutionError';\n this.code = code;\n }\n}\n\nexport interface GraphNodeBinding {\n readonly prompt: ((input: JsonValue) => string) | null;\n readonly scratchDirectory: string;\n readonly workspace: NodeWorkspacePolicy;\n readonly trustedCaller: JsonObject;\n readonly permissions: readonly string[];\n readonly policy: AttemptBudgetPolicy;\n readonly resultContract: ResultContract | null;\n readonly runData: ((context: NodeDataContext) => Promise<JsonValue>) | null;\n readonly parseResult:\n | ((part: AgentResultPart, parts: readonly AgentResultPart[]) => JsonValue)\n | null;\n readonly tokenBudget: TokenBudget | null;\n /** Whether node code may run again after a crash leaves its outcome unknown. */\n readonly retrySafe?: boolean;\n decideAction(): Promise<ActionDecision>;\n}\n\nexport interface GraphEngineBinding {\n readonly target: ExecutionTarget;\n readonly selection: EngineSelectionRecord;\n readonly engine: Engine;\n readonly hardTokenLimitEnforceable: boolean;\n}\n\nexport interface GraphExecutorOptions {\n readonly runId: string;\n readonly graph: CompiledGraphType;\n readonly storage: RunStorageBinding;\n readonly nodes: Readonly<Record<string, GraphNodeBinding>>;\n readonly engines: readonly GraphEngineBinding[];\n readonly preflightScratchDirectory?: string;\n readonly bindings?: {\n readonly memory?: Memory;\n };\n}\n\nexport type GraphExecutorResult =\n | Extract<GraphCommand, { readonly kind: 'pause' | 'complete' | 'fail' }>\n | PreflightPauseResult\n | PreflightFailureResult\n | {\n readonly kind: 'waiting';\n readonly positions: readonly string[];\n };\n\nexport interface GraphExecutor {\n run(signal: AbortSignal): Promise<GraphExecutorResult>;\n resume(target: string | { readonly preflightEventId: string }, signal: AbortSignal): Promise<GraphExecutorResult>;\n}\n","import { isDeepStrictEqual } from 'node:util';\nimport type { ExecutionTarget } from './contracts.js';\nexport type { ExecutionTarget } from './contracts.js';\n\nimport { GraphValidationError, type GraphValidationIssue, type EdgeId, type GraphId, type NodeId } from './graph-contract.js';\nimport {\n canonicalJson,\n cloneFrozenJson,\n digestJson,\n JsonValueError,\n type JsonValue,\n type Sha256Digest,\n} from './json.js';\n\nexport interface PermissionDescriptor {\n readonly name: string;\n readonly scope: JsonValue;\n}\n\nexport interface ExecutionLaneDescription {\n readonly id: string;\n readonly requested: ExecutionTarget;\n readonly knownSubstitutions: readonly ExecutionTarget[];\n}\n\nexport interface GraphPhaseDescription {\n readonly id: string;\n readonly name: string;\n readonly nodeIds: readonly NodeId[];\n}\n\nexport interface GraphNodeDescription {\n readonly id: NodeId;\n readonly phaseId: string;\n readonly inputContract: JsonValue;\n readonly outputContract: JsonValue;\n readonly laneId: string | null;\n}\n\nexport interface GraphEdgeDescription {\n readonly id: EdgeId;\n readonly source: NodeId;\n readonly target: NodeId;\n}\n\nexport type PlanBound =\n | { readonly kind: 'known'; readonly value: number }\n | { readonly kind: 'unknown'; readonly reason: string };\n\nexport interface GraphBounds {\n readonly dispatches: {\n readonly min: PlanBound;\n readonly max: PlanBound;\n };\n readonly maxConcurrency: PlanBound;\n readonly maxFanOut: PlanBound;\n}\n\nexport interface GraphPolicyDescription {\n readonly retry: JsonValue;\n readonly stop: JsonValue;\n readonly concurrency: JsonValue;\n readonly write: JsonValue;\n readonly budget: JsonValue;\n readonly action: JsonValue;\n}\n\nexport interface GraphRequirements {\n readonly memory: 'required' | 'unused';\n}\n\nexport interface GraphDescriptionInput {\n readonly inputContract: JsonValue;\n readonly outputContract: JsonValue;\n readonly phases: readonly GraphPhaseDescription[];\n readonly nodes: readonly GraphNodeDescription[];\n readonly policies: GraphPolicyDescription;\n readonly executionLanes: readonly ExecutionLaneDescription[];\n readonly requestedPermissions: readonly PermissionDescriptor[];\n readonly bounds: GraphBounds;\n}\n\nexport interface GraphDescription extends GraphDescriptionInput {\n readonly schemaVersion: 1;\n readonly graph: {\n readonly id: GraphId;\n readonly definitionVersion: number;\n readonly kind: string;\n readonly typeVersion: number;\n readonly definitionDigest: Sha256Digest;\n };\n readonly edges: readonly GraphEdgeDescription[];\n readonly requirements: GraphRequirements;\n}\n\nexport interface GraphPackageIdentity {\n readonly source: string;\n readonly version: string;\n readonly digest: Sha256Digest;\n}\n\nexport interface GraphPackageAdmission {\n readonly package: GraphPackageIdentity;\n readonly permissions: readonly PermissionDescriptor[];\n}\n\nexport interface ExecutionLaneResolution {\n readonly id: string;\n readonly effective: ExecutionTarget;\n readonly fallbacks?: readonly ExecutionTarget[];\n}\n\nexport interface RunPreflightPolicy {\n readonly timeoutMs: number;\n readonly lanes: readonly {\n readonly laneId: string;\n readonly live: 'required' | 'skip';\n readonly unsupportedStatic: 'block' | 'allow';\n }[];\n}\n\nexport interface PlanResolution {\n readonly package: GraphPackageIdentity;\n readonly admission: GraphPackageAdmission;\n readonly executionLanes: readonly ExecutionLaneResolution[];\n readonly preflight?: RunPreflightPolicy;\n}\n\nexport interface ResolvedExecutionLane extends ExecutionLaneDescription {\n readonly effective: ExecutionTarget;\n readonly fallbacks: readonly ExecutionTarget[];\n}\n\nexport interface ResolvedPlan {\n readonly schemaVersion: 1;\n readonly graph: GraphDescription['graph'];\n readonly package: GraphPackageIdentity;\n readonly inputContract: JsonValue;\n readonly outputContract: JsonValue;\n readonly phases: readonly GraphPhaseDescription[];\n readonly nodes: readonly GraphNodeDescription[];\n readonly edges: readonly GraphEdgeDescription[];\n readonly policies: GraphPolicyDescription;\n readonly executionLanes: readonly ResolvedExecutionLane[];\n readonly preflight?: RunPreflightPolicy;\n readonly permissions: {\n readonly requested: readonly PermissionDescriptor[];\n readonly admitted: readonly PermissionDescriptor[];\n };\n readonly bounds: GraphBounds;\n readonly requirements: GraphRequirements;\n}\n\nexport interface ResolvedPlanSnapshot {\n readonly plan: ResolvedPlan;\n readonly canonicalJson: string;\n readonly digest: Sha256Digest;\n}\n\nfunction issue(code: string, path: string, message: string): GraphValidationIssue {\n return { code, path, message };\n}\n\nfunction fail(code: string, path: string, message: string): never {\n throw new GraphValidationError(`Invalid graph plan: ${message}`, [\n issue(code, path, message),\n ]);\n}\n\nfunction record(\n value: unknown,\n path: string,\n label: string,\n): Readonly<Record<string, JsonValue>> {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n fail('INVALID_SHAPE', path, `${label} must be an object.`);\n }\n return value as Readonly<Record<string, JsonValue>>;\n}\n\nfunction list(value: unknown, path: string, label: string): readonly JsonValue[] {\n if (!Array.isArray(value)) {\n fail('INVALID_SHAPE', path, `${label} must be an array.`);\n }\n return value;\n}\n\nfunction requireFields(\n value: Readonly<Record<string, JsonValue>>,\n fields: readonly string[],\n path: string,\n): void {\n for (const field of fields) {\n if (!Object.hasOwn(value, field)) {\n fail(\n 'MISSING_FIELD',\n `${path}/${field}`,\n `Required field \"${field}\" is missing.`,\n );\n }\n }\n}\n\nfunction exactFields(\n value: Readonly<Record<string, JsonValue>>,\n fields: readonly string[],\n path: string,\n): void {\n requireFields(value, fields, path);\n const expected = new Set(fields);\n for (const field of Object.keys(value)) {\n if (!expected.has(field)) {\n fail(\n 'UNKNOWN_FIELD',\n `${path}/${field}`,\n `Unknown field \"${field}\" is not allowed.`,\n );\n }\n }\n}\n\nfunction json(value: unknown, path: string): JsonValue {\n try {\n return cloneFrozenJson(value as JsonValue);\n } catch (error) {\n if (!(error instanceof JsonValueError)) throw error;\n fail('INVALID_JSON_VALUE', `${path}${error.path}`, error.message);\n }\n}\n\nfunction text(value: unknown, path: string, label: string): string {\n if (\n typeof value !== 'string'\n || value.trim().length === 0\n || /[\\u0000-\\u001f\\u007f]/.test(value)\n ) {\n fail('INVALID_TEXT', path, `${label} must be a non-empty string without control characters.`);\n }\n return value;\n}\n\nfunction identifier(value: unknown, path: string, label: string): string {\n if (\n typeof value !== 'string'\n || value.length === 0\n || value !== value.trim()\n || /[\\u0000-\\u001f\\u007f]/.test(value)\n ) {\n fail(\n 'INVALID_ID',\n path,\n `${label} must be a non-empty trimmed string without control characters.`,\n );\n }\n return value;\n}\n\nfunction positiveVersion(value: unknown, path: string): number {\n if (!Number.isSafeInteger(value) || (value as number) < 1) {\n fail('INVALID_VERSION', path, 'Version must be a positive safe integer.');\n }\n return value as number;\n}\n\nfunction digest(value: unknown, path: string): Sha256Digest {\n if (typeof value !== 'string' || !/^sha256:[0-9a-f]{64}$/.test(value)) {\n fail('INVALID_DIGEST', path, 'Digest must be lowercase sha256 followed by 64 hex characters.');\n }\n return value as Sha256Digest;\n}\n\nfunction unique(values: readonly string[], path: string, label: string): void {\n const seen = new Set<string>();\n for (let index = 0; index < values.length; index += 1) {\n const value = text(values[index], `${path}/${index}`, label);\n if (seen.has(value)) fail('DUPLICATE_ID', `${path}/${index}`, `Duplicate ${label} \"${value}\".`);\n seen.add(value);\n }\n}\n\nfunction target(value: ExecutionTarget, path: string): void {\n const item = record(value, path, 'Execution target');\n requireFields(item, ['adapter', 'provider', 'modelFamily', 'model', 'tools'], path);\n text(value.adapter, `${path}/adapter`, 'adapter');\n text(value.provider, `${path}/provider`, 'provider');\n text(value.modelFamily, `${path}/modelFamily`, 'modelFamily');\n text(value.model, `${path}/model`, 'model');\n unique(list(value.tools, `${path}/tools`, 'tools') as readonly string[], `${path}/tools`, 'tool');\n}\n\nfunction bound(value: PlanBound, path: string): void {\n const item = record(value, path, 'Plan bound');\n requireFields(item, ['kind'], path);\n if (value.kind === 'known') {\n requireFields(item, ['value'], path);\n if (!Number.isSafeInteger(value.value) || value.value < 0) {\n fail('INVALID_BOUND', `${path}/value`, 'A known bound must be a non-negative safe integer.');\n }\n return;\n }\n if (value.kind === 'unknown') {\n requireFields(item, ['reason'], path);\n text(value.reason, `${path}/reason`, 'unknown-bound reason');\n return;\n }\n fail('INVALID_BOUND', `${path}/kind`, 'Bound kind must be known or unknown.');\n}\n\nfunction permission(value: PermissionDescriptor, path: string): void {\n const item = record(value, path, 'Permission');\n requireFields(item, ['name', 'scope'], path);\n text(value.name, `${path}/name`, 'permission name');\n json(value.scope, `${path}/scope`);\n}\n\nfunction packageIdentity(value: GraphPackageIdentity, path: string): void {\n const item = record(value, path, 'Package identity');\n requireFields(item, ['source', 'version', 'digest'], path);\n text(value.source, `${path}/source`, 'package source');\n text(value.version, `${path}/version`, 'package version');\n digest(value.digest, `${path}/digest`);\n}\n\nfunction strictTarget(value: unknown, path: string): void {\n const item = record(value, path, 'Execution target');\n exactFields(item, ['adapter', 'provider', 'modelFamily', 'model', 'tools'], path);\n target(item as unknown as ExecutionTarget, path);\n}\n\nfunction strictPermission(value: unknown, path: string): void {\n const item = record(value, path, 'Permission');\n exactFields(item, ['name', 'scope'], path);\n permission(item as unknown as PermissionDescriptor, path);\n}\n\nfunction strictBound(value: unknown, path: string): void {\n const item = record(value, path, 'Plan bound');\n bound(item as unknown as PlanBound, path);\n exactFields(\n item,\n item.kind === 'known' ? ['kind', 'value'] : ['kind', 'reason'],\n path,\n );\n}\n\nfunction preflightPolicy(value: unknown, laneIds: readonly string[]): RunPreflightPolicy {\n const root = record(value, '/preflight', 'Preflight policy');\n exactFields(root, ['timeoutMs', 'lanes'], '/preflight');\n if (!Number.isSafeInteger(root.timeoutMs)\n || (root.timeoutMs as number) < 1\n || (root.timeoutMs as number) > 2_147_483_647) {\n fail('INVALID_BOUND', '/preflight/timeoutMs', 'Preflight timeout must be an integer from 1 to 2147483647 milliseconds.');\n }\n const remaining = new Set(laneIds);\n const lanes = list(root.lanes, '/preflight/lanes', 'Preflight lanes');\n for (let index = 0; index < lanes.length; index += 1) {\n const path = `/preflight/lanes/${index}`;\n const lane = record(lanes[index], path, 'Preflight lane');\n exactFields(lane, ['laneId', 'live', 'unsupportedStatic'], path);\n const laneId = identifier(lane.laneId, `${path}/laneId`, 'lane id');\n if (!remaining.delete(laneId)) {\n fail('INVALID_LANE_RESOLUTION', `${path}/laneId`, 'Preflight lane is unknown or duplicated.');\n }\n if (lane.live !== 'required' && lane.live !== 'skip') {\n fail('INVALID_SHAPE', `${path}/live`, 'Preflight live policy must be required or skip.');\n }\n if (lane.unsupportedStatic !== 'block' && lane.unsupportedStatic !== 'allow') {\n fail('INVALID_SHAPE', `${path}/unsupportedStatic`, 'Unsupported static policy must be block or allow.');\n }\n }\n if (remaining.size !== 0) {\n fail('INVALID_LANE_RESOLUTION', '/preflight/lanes', 'Every resolved lane needs one preflight policy.');\n }\n return root as unknown as RunPreflightPolicy;\n}\n\n/** Validate and freeze a resolved plan read from storage. */\nexport function validateResolvedPlan(value: unknown): ResolvedPlan {\n const raw = json(value, '');\n const root = record(raw, '', 'Resolved plan');\n exactFields(root, [\n 'schemaVersion',\n 'graph',\n 'package',\n 'inputContract',\n 'outputContract',\n 'phases',\n 'nodes',\n 'edges',\n 'policies',\n 'executionLanes',\n 'permissions',\n 'bounds',\n 'requirements',\n ...(Object.hasOwn(root, 'preflight') ? ['preflight'] : []),\n ], '');\n\n const graph = record(root.graph, '/graph', 'Graph metadata');\n exactFields(graph, [\n 'id', 'definitionVersion', 'kind', 'typeVersion', 'definitionDigest',\n ], '/graph');\n\n const packageValue = record(root.package, '/package', 'Package identity');\n exactFields(packageValue, ['source', 'version', 'digest'], '/package');\n\n const phases = list(root.phases, '/phases', 'Phases');\n phases.forEach((phase, index) => {\n const item = record(phase, `/phases/${index}`, 'Phase');\n exactFields(item, ['id', 'name', 'nodeIds'], `/phases/${index}`);\n });\n\n const nodes = list(root.nodes, '/nodes', 'Nodes');\n nodes.forEach((node, index) => {\n const item = record(node, `/nodes/${index}`, 'Node description');\n exactFields(item, [\n 'id', 'phaseId', 'inputContract', 'outputContract', 'laneId',\n ], `/nodes/${index}`);\n });\n\n const edges = list(root.edges, '/edges', 'Edges');\n edges.forEach((edge, index) => {\n const item = record(edge, `/edges/${index}`, 'Edge description');\n exactFields(item, ['id', 'source', 'target'], `/edges/${index}`);\n });\n\n const policies = record(root.policies, '/policies', 'Policies');\n exactFields(policies, [\n 'retry', 'stop', 'concurrency', 'write', 'budget', 'action',\n ], '/policies');\n\n const lanes = list(root.executionLanes, '/executionLanes', 'Execution lanes');\n lanes.forEach((lane, index) => {\n const path = `/executionLanes/${index}`;\n const item = record(lane, path, 'Resolved execution lane');\n exactFields(item, [\n 'id', 'requested', 'knownSubstitutions', 'effective', 'fallbacks',\n ], path);\n strictTarget(item.requested, `${path}/requested`);\n list(\n item.knownSubstitutions,\n `${path}/knownSubstitutions`,\n 'Known substitutions',\n ).forEach((targetValue, targetIndex) => {\n strictTarget(\n targetValue,\n `${path}/knownSubstitutions/${targetIndex}`,\n );\n });\n strictTarget(item.effective, `${path}/effective`);\n list(item.fallbacks, `${path}/fallbacks`, 'Fallbacks')\n .forEach((targetValue, targetIndex) => {\n strictTarget(targetValue, `${path}/fallbacks/${targetIndex}`);\n });\n });\n\n const permissions = record(root.permissions, '/permissions', 'Permissions');\n exactFields(permissions, ['requested', 'admitted'], '/permissions');\n list(permissions.requested, '/permissions/requested', 'Requested permissions')\n .forEach((item, index) => {\n strictPermission(item, `/permissions/requested/${index}`);\n });\n list(permissions.admitted, '/permissions/admitted', 'Admitted permissions')\n .forEach((item, index) => {\n strictPermission(item, `/permissions/admitted/${index}`);\n });\n\n const bounds = record(root.bounds, '/bounds', 'Bounds');\n exactFields(bounds, [\n 'dispatches', 'maxConcurrency', 'maxFanOut',\n ], '/bounds');\n const dispatches = record(\n bounds.dispatches,\n '/bounds/dispatches',\n 'Dispatch bounds',\n );\n exactFields(dispatches, ['min', 'max'], '/bounds/dispatches');\n strictBound(dispatches.min, '/bounds/dispatches/min');\n strictBound(dispatches.max, '/bounds/dispatches/max');\n strictBound(bounds.maxConcurrency, '/bounds/maxConcurrency');\n strictBound(bounds.maxFanOut, '/bounds/maxFanOut');\n\n const requirements = record(root.requirements, '/requirements', 'Requirements');\n exactFields(requirements, ['memory'], '/requirements');\n\n const plan = root as unknown as ResolvedPlan;\n const description = validateGraphDescription({\n schemaVersion: plan.schemaVersion,\n graph: plan.graph,\n inputContract: plan.inputContract,\n outputContract: plan.outputContract,\n phases: plan.phases,\n nodes: plan.nodes,\n edges: plan.edges,\n policies: plan.policies,\n executionLanes: plan.executionLanes.map((lane) => ({\n id: lane.id,\n requested: lane.requested,\n knownSubstitutions: lane.knownSubstitutions,\n })),\n requestedPermissions: plan.permissions.requested,\n bounds: plan.bounds,\n requirements: plan.requirements,\n });\n const rebuilt = resolveGraphPlan(description, {\n package: plan.package,\n admission: {\n package: plan.package,\n permissions: plan.permissions.admitted,\n },\n executionLanes: plan.executionLanes.map((lane) => ({\n id: lane.id,\n effective: lane.effective,\n fallbacks: lane.fallbacks,\n })),\n ...(Object.hasOwn(root, 'preflight') ? { preflight: plan.preflight } : {}),\n }).plan;\n if (!isDeepStrictEqual(plan, rebuilt)) {\n fail(\n 'RESOLVED_PLAN_MISMATCH',\n '',\n 'Resolved plan does not match its graph description and host resolution.',\n );\n }\n return rebuilt;\n}\n\n/** Validate and freeze the stable data returned by a graph type. */\nexport function validateGraphDescription(\n value: unknown,\n): GraphDescription {\n const raw = json(value, '');\n const root = record(raw, '', 'Graph description');\n requireFields(root, [\n 'schemaVersion',\n 'graph',\n 'inputContract',\n 'outputContract',\n 'phases',\n 'nodes',\n 'edges',\n 'policies',\n 'executionLanes',\n 'requestedPermissions',\n 'bounds',\n 'requirements',\n ], '');\n const graph = record(root.graph, '/graph', 'Graph metadata');\n requireFields(graph, [\n 'id', 'definitionVersion', 'kind', 'typeVersion', 'definitionDigest',\n ], '/graph');\n const phaseValues = list(root.phases, '/phases', 'Phases');\n const nodeValues = list(root.nodes, '/nodes', 'Nodes');\n const edgeValues = list(root.edges, '/edges', 'Edges');\n const laneValues = list(root.executionLanes, '/executionLanes', 'Execution lanes');\n const permissionValues = list(\n root.requestedPermissions,\n '/requestedPermissions',\n 'Requested permissions',\n );\n const policies = record(root.policies, '/policies', 'Policies');\n requireFields(policies, [\n 'retry', 'stop', 'concurrency', 'write', 'budget', 'action',\n ], '/policies');\n const bounds = record(root.bounds, '/bounds', 'Bounds');\n requireFields(bounds, [\n 'dispatches', 'maxConcurrency', 'maxFanOut',\n ], '/bounds');\n const dispatchBounds = record(bounds.dispatches, '/bounds/dispatches', 'Dispatch bounds');\n requireFields(dispatchBounds, ['min', 'max'], '/bounds/dispatches');\n const requirements = record(root.requirements, '/requirements', 'Requirements');\n requireFields(requirements, ['memory'], '/requirements');\n phaseValues.forEach((phase, index) => {\n const item = record(phase, `/phases/${index}`, 'Phase');\n requireFields(item, ['id', 'name', 'nodeIds'], `/phases/${index}`);\n list(item.nodeIds, `/phases/${index}/nodeIds`, 'Phase nodeIds');\n });\n nodeValues.forEach((node, index) => {\n const item = record(node, `/nodes/${index}`, 'Node description');\n requireFields(item, [\n 'id', 'phaseId', 'inputContract', 'outputContract', 'laneId',\n ], `/nodes/${index}`);\n });\n edgeValues.forEach((edge, index) => {\n const item = record(edge, `/edges/${index}`, 'Edge description');\n requireFields(item, ['id', 'source', 'target'], `/edges/${index}`);\n });\n laneValues.forEach((lane, index) => {\n const item = record(lane, `/executionLanes/${index}`, 'Execution lane');\n requireFields(item, [\n 'id', 'requested', 'knownSubstitutions',\n ], `/executionLanes/${index}`);\n list(\n item.knownSubstitutions,\n `/executionLanes/${index}/knownSubstitutions`,\n 'Known substitutions',\n );\n });\n permissionValues.forEach((item, index) => {\n record(item, `/requestedPermissions/${index}`, 'Permission');\n });\n const description = root as unknown as GraphDescription;\n if (description.schemaVersion !== 1) {\n fail('INVALID_SCHEMA_VERSION', '/schemaVersion', 'Graph description schemaVersion must be 1.');\n }\n identifier(description.graph.id, '/graph/id', 'graph id');\n positiveVersion(description.graph.definitionVersion, '/graph/definitionVersion');\n text(description.graph.kind, '/graph/kind', 'graph kind');\n positiveVersion(description.graph.typeVersion, '/graph/typeVersion');\n digest(description.graph.definitionDigest, '/graph/definitionDigest');\n\n description.phases.forEach((phase, index) => {\n identifier(phase.id, `/phases/${index}/id`, 'phase id');\n });\n description.nodes.forEach((node, index) => {\n identifier(node.id, `/nodes/${index}/id`, 'node id');\n });\n description.edges.forEach((edge, index) => {\n identifier(edge.id, `/edges/${index}/id`, 'edge id');\n });\n description.executionLanes.forEach((lane, index) => {\n identifier(lane.id, `/executionLanes/${index}/id`, 'lane id');\n });\n description.phases.forEach((phase, phaseIndex) => {\n phase.nodeIds.forEach((nodeId, nodeIndex) => {\n identifier(nodeId, `/phases/${phaseIndex}/nodeIds/${nodeIndex}`, 'node id');\n });\n });\n description.nodes.forEach((node, index) => {\n identifier(node.phaseId, `/nodes/${index}/phaseId`, 'phase id');\n if (node.laneId !== null) {\n identifier(node.laneId, `/nodes/${index}/laneId`, 'lane id');\n }\n });\n description.edges.forEach((edge, index) => {\n identifier(edge.source, `/edges/${index}/source`, 'node id');\n identifier(edge.target, `/edges/${index}/target`, 'node id');\n });\n\n unique(description.phases.map((phase) => phase.id), '/phases', 'phase id');\n unique(description.nodes.map((node) => node.id), '/nodes', 'node id');\n unique(description.edges.map((edge) => edge.id), '/edges', 'edge id');\n unique(description.executionLanes.map((lane) => lane.id), '/executionLanes', 'lane id');\n unique(description.requestedPermissions.map((item) => item.name), '/requestedPermissions', 'permission name');\n\n const phaseIds = new Set(description.phases.map((phase) => phase.id));\n const nodeIds = new Set(description.nodes.map((node) => node.id));\n const laneIds = new Set(description.executionLanes.map((lane) => lane.id));\n const assignedNodes: string[] = [];\n const assignedPhaseByNode = new Map<NodeId, string>();\n for (let index = 0; index < description.phases.length; index += 1) {\n const phase = description.phases[index]!;\n text(phase.name, `/phases/${index}/name`, 'phase name');\n unique(phase.nodeIds, `/phases/${index}/nodeIds`, 'node id');\n for (const nodeId of phase.nodeIds) {\n if (!nodeIds.has(nodeId)) {\n fail('UNKNOWN_NODE', `/phases/${index}/nodeIds`, `Phase refers to unknown node \"${nodeId}\".`);\n }\n assignedNodes.push(nodeId);\n assignedPhaseByNode.set(nodeId, phase.id);\n }\n }\n if (\n assignedNodes.length !== nodeIds.size\n || new Set(assignedNodes).size !== nodeIds.size\n ) {\n fail('INVALID_PHASE_ASSIGNMENT', '/phases', 'Every node must appear in exactly one phase.');\n }\n\n for (let index = 0; index < description.nodes.length; index += 1) {\n const node = description.nodes[index]!;\n if (!phaseIds.has(node.phaseId)) {\n fail('UNKNOWN_PHASE', `/nodes/${index}/phaseId`, `Node refers to unknown phase \"${node.phaseId}\".`);\n }\n if (assignedPhaseByNode.get(node.id) !== node.phaseId) {\n fail(\n 'INVALID_PHASE_ASSIGNMENT',\n `/nodes/${index}/phaseId`,\n `Node \"${node.id}\" claims phase \"${node.phaseId}\" but is listed in phase \"${assignedPhaseByNode.get(node.id)}\".`,\n );\n }\n if (node.laneId !== null && !laneIds.has(node.laneId)) {\n fail('UNKNOWN_LANE', `/nodes/${index}/laneId`, `Node refers to unknown lane \"${node.laneId}\".`);\n }\n }\n\n for (let index = 0; index < description.edges.length; index += 1) {\n const edge = description.edges[index]!;\n if (!nodeIds.has(edge.source) || !nodeIds.has(edge.target)) {\n fail('UNKNOWN_NODE', `/edges/${index}`, 'Edge refers to an unknown node.');\n }\n }\n\n for (let index = 0; index < description.executionLanes.length; index += 1) {\n const lane = description.executionLanes[index]!;\n target(lane.requested, `/executionLanes/${index}/requested`);\n const substitutions = new Set<string>();\n for (let item = 0; item < lane.knownSubstitutions.length; item += 1) {\n const substitution = lane.knownSubstitutions[item]!;\n target(substitution, `/executionLanes/${index}/knownSubstitutions/${item}`);\n const key = canonicalJson(substitution as unknown as JsonValue);\n if (substitutions.has(key)) {\n fail('DUPLICATE_SUBSTITUTION', `/executionLanes/${index}/knownSubstitutions/${item}`, 'Execution substitution is duplicated.');\n }\n substitutions.add(key);\n }\n }\n\n for (let index = 0; index < description.requestedPermissions.length; index += 1) {\n permission(description.requestedPermissions[index]!, `/requestedPermissions/${index}`);\n }\n\n bound(description.bounds.dispatches.min, '/bounds/dispatches/min');\n bound(description.bounds.dispatches.max, '/bounds/dispatches/max');\n bound(description.bounds.maxConcurrency, '/bounds/maxConcurrency');\n bound(description.bounds.maxFanOut, '/bounds/maxFanOut');\n const min = description.bounds.dispatches.min;\n const max = description.bounds.dispatches.max;\n if (min.kind === 'known' && max.kind === 'known' && min.value > max.value) {\n fail('INVALID_BOUND', '/bounds/dispatches', 'Minimum dispatches cannot exceed maximum dispatches.');\n }\n if (description.requirements.memory !== 'required' && description.requirements.memory !== 'unused') {\n fail('INVALID_REQUIREMENT', '/requirements/memory', 'Memory must be required or unused.');\n }\n\n return description;\n}\n\n/** Bind a pure plan description to host admission and effective engines. */\nexport function resolveGraphPlan(\n value: GraphDescription,\n input: PlanResolution,\n): ResolvedPlanSnapshot {\n const description = validateGraphDescription(value);\n const raw = json(input, '');\n const root = record(raw, '', 'Plan resolution');\n requireFields(root, ['package', 'admission', 'executionLanes'], '');\n const admission = record(root.admission, '/admission', 'Package admission');\n requireFields(admission, ['package', 'permissions'], '/admission');\n list(admission.permissions, '/admission/permissions', 'Admitted permissions')\n .forEach((item, index) => {\n record(item, `/admission/permissions/${index}`, 'Permission');\n });\n list(root.executionLanes, '/executionLanes', 'Lane resolutions')\n .forEach((item, index) => {\n const lane = record(item, `/executionLanes/${index}`, 'Lane resolution');\n requireFields(lane, ['id', 'effective'], `/executionLanes/${index}`);\n list(\n lane.fallbacks ?? [],\n `/executionLanes/${index}/fallbacks`,\n 'Fallbacks',\n );\n });\n const resolution = root as unknown as PlanResolution;\n packageIdentity(resolution.package, '/package');\n packageIdentity(resolution.admission.package, '/admission/package');\n if (!isDeepStrictEqual(resolution.package, resolution.admission.package)) {\n fail('PACKAGE_NOT_ADMITTED', '/admission/package', 'Host admission does not match the requested package.');\n }\n\n unique(resolution.executionLanes.map((lane) => lane.id), '/executionLanes', 'lane resolution id');\n const resolutions = new Map(resolution.executionLanes.map((lane) => [lane.id, lane]));\n if (resolutions.size !== description.executionLanes.length) {\n fail('INVALID_LANE_RESOLUTION', '/executionLanes', 'Every described lane needs exactly one resolution.');\n }\n const resolvedLanes: ResolvedExecutionLane[] = [];\n for (let index = 0; index < description.executionLanes.length; index += 1) {\n const lane = description.executionLanes[index]!;\n const resolved = resolutions.get(lane.id);\n if (!resolved) {\n fail('INVALID_LANE_RESOLUTION', '/executionLanes', `Lane \"${lane.id}\" has no resolution.`);\n }\n target(resolved.effective, `/executionLanes/${index}/effective`);\n const allowed = [lane.requested, ...lane.knownSubstitutions];\n if (!allowed.some((candidate) => isDeepStrictEqual(candidate, resolved.effective))) {\n fail('UNKNOWN_SUBSTITUTION', `/executionLanes/${index}/effective`, `Lane \"${lane.id}\" uses an undeclared substitution.`);\n }\n const fallbacks = resolved.fallbacks ?? [];\n const fallbackKeys = new Set<string>();\n for (let fallbackIndex = 0; fallbackIndex < fallbacks.length; fallbackIndex += 1) {\n const fallback = fallbacks[fallbackIndex]!;\n const path = `/executionLanes/${index}/fallbacks/${fallbackIndex}`;\n target(fallback, path);\n if (!allowed.some((candidate) => isDeepStrictEqual(candidate, fallback))) {\n fail('UNKNOWN_SUBSTITUTION', path, `Lane \"${lane.id}\" uses an undeclared fallback.`);\n }\n if (isDeepStrictEqual(fallback, resolved.effective)) {\n fail('DUPLICATE_SUBSTITUTION', path, 'A fallback cannot repeat the effective target.');\n }\n const key = canonicalJson(fallback as unknown as JsonValue);\n if (fallbackKeys.has(key)) {\n fail('DUPLICATE_SUBSTITUTION', path, 'Execution fallback is duplicated.');\n }\n fallbackKeys.add(key);\n }\n resolvedLanes.push({\n ...lane,\n effective: resolved.effective,\n fallbacks,\n });\n resolutions.delete(lane.id);\n }\n if (resolutions.size > 0) {\n fail('INVALID_LANE_RESOLUTION', '/executionLanes', 'Resolution contains an unknown lane.');\n }\n const preflight = Object.hasOwn(root, 'preflight')\n ? preflightPolicy(root.preflight, resolvedLanes.map((lane) => lane.id))\n : undefined;\n\n const admittedByName = new Map<string, PermissionDescriptor>();\n for (let index = 0; index < resolution.admission.permissions.length; index += 1) {\n const item = resolution.admission.permissions[index]!;\n permission(item, `/admission/permissions/${index}`);\n if (admittedByName.has(item.name)) {\n fail('DUPLICATE_PERMISSION', `/admission/permissions/${index}`, `Permission \"${item.name}\" is duplicated.`);\n }\n admittedByName.set(item.name, item);\n }\n for (let index = 0; index < description.requestedPermissions.length; index += 1) {\n const requested = description.requestedPermissions[index]!;\n const admitted = admittedByName.get(requested.name);\n if (!admitted || canonicalJson(admitted.scope) !== canonicalJson(requested.scope)) {\n fail('PERMISSION_NOT_ADMITTED', `/requestedPermissions/${index}`, `Permission \"${requested.name}\" is outside host admission.`);\n }\n }\n\n const plan = cloneFrozenJson({\n schemaVersion: 1,\n graph: description.graph,\n package: resolution.package,\n inputContract: description.inputContract,\n outputContract: description.outputContract,\n phases: description.phases,\n nodes: description.nodes,\n edges: description.edges,\n policies: description.policies,\n executionLanes: resolvedLanes,\n ...(preflight === undefined ? {} : { preflight }),\n permissions: {\n requested: description.requestedPermissions,\n admitted: resolution.admission.permissions,\n },\n bounds: description.bounds,\n requirements: description.requirements,\n } as unknown as JsonValue) as unknown as ResolvedPlan;\n const canonical = canonicalJson(plan as unknown as JsonValue);\n return Object.freeze({\n plan,\n canonicalJson: canonical,\n digest: digestJson(plan as unknown as JsonValue),\n });\n}\n","import {\n cloneFrozenJson,\n JsonValueError,\n type JsonObject,\n type JsonValue,\n} from '../json.js';\nimport { StorageError } from '../storage/error.js';\nimport { validateStorageId } from '../storage/id.js';\nimport {\n validateNewDomainEvent,\n type DomainEventEnvelope,\n type EventStreamRef,\n type NewDomainEvent,\n type StreamRevision,\n} from './envelope.js';\n\nexport type DomainEventBatch = readonly [\n NewDomainEvent,\n ...NewDomainEvent[],\n];\n\nexport interface EventStore {\n preflightAppend(\n stream: EventStreamRef,\n expectedRevision: StreamRevision,\n events: DomainEventBatch,\n ): Promise<void>;\n\n read(\n stream: EventStreamRef,\n afterRevision?: StreamRevision,\n ): AsyncIterable<DomainEventEnvelope>;\n\n append(\n stream: EventStreamRef,\n expectedRevision: StreamRevision,\n events: DomainEventBatch,\n ): Promise<StreamRevision>;\n}\n\nfunction fail(message: string, path: string): never {\n throw new StorageError('INVALID_STORED_VALUE', message, { path });\n}\n\nexport { validateStorageId } from '../storage/id.js';\n\nexport function validateEventStreamRef(value: unknown): EventStreamRef {\n let safe: JsonValue;\n try {\n safe = cloneFrozenJson(value as JsonValue);\n } catch (error) {\n if (!(error instanceof JsonValueError)) throw error;\n fail(error.message, error.path);\n }\n if (safe === null || typeof safe !== 'object' || Array.isArray(safe)) {\n fail('Event stream reference must be an object.', '');\n }\n const record = safe as JsonObject;\n const fields = Object.keys(record).sort();\n if (\n fields.length !== 2\n || fields[0] !== 'namespace'\n || fields[1] !== 'streamId'\n ) {\n fail(\n 'Event stream reference must contain exactly namespace and streamId.',\n '',\n );\n }\n validateStorageId(record.namespace, '/namespace');\n validateStorageId(record.streamId, '/streamId');\n return record as unknown as EventStreamRef;\n}\n\nexport function validateStreamRevision(\n value: unknown,\n path: string,\n): StreamRevision {\n if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) {\n fail('Stream revision must be a non-negative safe integer.', path);\n }\n return value;\n}\n\nexport function validateDomainEventBatch(value: unknown): DomainEventBatch {\n let safe: JsonValue;\n try {\n safe = cloneFrozenJson(value as JsonValue);\n } catch (error) {\n if (!(error instanceof JsonValueError)) throw error;\n fail(error.message, `/events${error.path}`);\n }\n if (!Array.isArray(safe) || safe.length === 0) {\n fail('An append batch must contain at least one event.', '/events');\n }\n const events = safe.map((event) => validateNewDomainEvent(event));\n return Object.freeze(events) as unknown as DomainEventBatch;\n}\n\nfunction jsonContains(value: JsonValue, needle: string): boolean {\n if (typeof value === 'string') return value.includes(needle);\n if (value === null || typeof value !== 'object') return false;\n if (Array.isArray(value)) {\n return value.some((item) => jsonContains(item, needle));\n }\n return Object.entries(value).some(([key, item]) => (\n key.includes(needle) || jsonContains(item, needle)\n ));\n}\n\nexport function findKnownSecretInEvents(\n knownSecrets: readonly string[],\n serializedBytes: string,\n events: readonly NewDomainEvent[],\n): string | undefined {\n return knownSecrets.find((secret) => (\n serializedBytes.includes(secret)\n || events.some((event) => jsonContains(event as unknown as JsonValue, secret))\n ));\n}\n","import { validateCallbackRequest, type CallbackRequest } from './gate.js';\nimport { cloneFrozenJson, type JsonObject, type JsonValue } from '../json.js';\n\nexport type CallbackEvent =\n | { readonly kind: 'callback-requested'; readonly request: CallbackRequest }\n | { readonly kind: 'callback-claimed'; readonly requestId: string; readonly routerId: string; readonly claimToken: string }\n | { readonly kind: 'callback-released'; readonly requestId: string; readonly routerId: string }\n | { readonly kind: 'callback-submitted'; readonly requestId: string; readonly requestDigest: string; readonly routerId: string; readonly response: JsonValue }\n | { readonly kind: 'callback-rejected'; readonly requestId: string; readonly routerId: string; readonly reason: string }\n | { readonly kind: 'callback-superseded'; readonly requestId: string; readonly supersededBy: string };\n\nconst CALLBACK_DIGEST = /^[0-9a-f]{64}$/u;\n\nfunction callbackObject(value: unknown): JsonObject {\n const stored = cloneFrozenJson(value as JsonValue);\n if (stored === null || typeof stored !== 'object' || Array.isArray(stored)) {\n throw new TypeError('a stored callback event must be an object');\n }\n return stored as JsonObject;\n}\n\nfunction exactFields(value: JsonObject, fields: readonly string[]): void {\n const actual = Object.keys(value).sort();\n const expected = [...fields].sort();\n if (actual.length !== expected.length\n || actual.some((field, index) => field !== expected[index])) {\n throw new TypeError('a stored callback event has missing or unknown fields');\n }\n}\n\nfunction callbackText(value: JsonValue | undefined, field: string): string {\n if (typeof value !== 'string' || value.length === 0) {\n throw new TypeError(`a stored callback event needs ${field}`);\n }\n return value;\n}\n\n/** Validate one callback event before it can affect replayed state. */\nexport function validateCallbackEvent(value: unknown): CallbackEvent {\n const event = callbackObject(value);\n switch (event.kind) {\n case 'callback-requested':\n exactFields(event, ['kind', 'request']);\n validateCallbackRequest(event.request);\n break;\n case 'callback-claimed':\n exactFields(event, ['kind', 'requestId', 'routerId', 'claimToken']);\n callbackText(event.requestId, 'requestId');\n callbackText(event.routerId, 'routerId');\n callbackText(event.claimToken, 'claimToken');\n break;\n case 'callback-released':\n exactFields(event, ['kind', 'requestId', 'routerId']);\n callbackText(event.requestId, 'requestId');\n callbackText(event.routerId, 'routerId');\n break;\n case 'callback-submitted':\n if (typeof event.requestDigest !== 'string' || !CALLBACK_DIGEST.test(event.requestDigest)) {\n throw new TypeError('a stored callback submission has an invalid requestDigest');\n }\n exactFields(event, ['kind', 'requestId', 'requestDigest', 'routerId', 'response']);\n callbackText(event.requestId, 'requestId');\n callbackText(event.routerId, 'routerId');\n break;\n case 'callback-rejected':\n exactFields(event, ['kind', 'requestId', 'routerId', 'reason']);\n callbackText(event.requestId, 'requestId');\n callbackText(event.routerId, 'routerId');\n callbackText(event.reason, 'reason');\n break;\n case 'callback-superseded':\n exactFields(event, ['kind', 'requestId', 'supersededBy']);\n callbackText(event.requestId, 'requestId');\n callbackText(event.supersededBy, 'supersededBy');\n break;\n default:\n throw new TypeError('a stored callback event has an unknown kind');\n }\n return event as unknown as CallbackEvent;\n}\n\nexport interface ClaimOk {\n readonly ok: true;\n readonly claimToken: string;\n}\n\nexport interface ClaimRefused {\n readonly ok: false;\n readonly kind: 'missing' | 'claimed' | 'answered' | 'superseded';\n readonly routerId: string | null;\n}\n\nexport type ClaimResult = ClaimOk | ClaimRefused;\n\nexport interface SubmitOk {\n readonly ok: true;\n readonly response: JsonValue;\n}\n\nexport interface SubmitRefused {\n readonly ok: false;\n readonly kind: 'missing' | 'not-claimed' | 'not-owner' | 'stale' | 'invalid';\n readonly reason: string;\n}\n\nexport type SubmitResult = SubmitOk | SubmitRefused;\n\nexport interface ReleaseOk {\n readonly ok: true;\n}\n\nexport interface ReleaseRefused {\n readonly ok: false;\n readonly kind: 'missing' | 'not-owner';\n}\n\nexport type ReleaseResult = ReleaseOk | ReleaseRefused;\n\nexport interface CallbackClient {\n /** Record a gate's request and make it pending. Observation only. */\n post(request: CallbackRequest): void;\n /** The pending requests, without starting any effect. */\n listPending(): readonly CallbackRequest[];\n /** Atomically assign a request to one router. */\n claim(requestId: string, routerId: string): ClaimResult;\n /**\n * Validate and record a structured response. The assignment binds the\n * response schema and the request digest: a submit whose digest does\n * not match the posted request is stale.\n */\n submit(\n requestId: string,\n claimToken: string,\n routerId: string,\n requestDigest: string,\n response: JsonValue,\n ): SubmitResult;\n /** Give a claimed request back so another router can take it. */\n release(requestId: string, claimToken: string): ReleaseResult;\n /** Mark a request superseded by a newer one from the same gate. */\n supersede(requestId: string, supersededBy: string): void;\n /** The full history, optionally for one request. */\n history(requestId?: string): readonly CallbackEvent[];\n}\n\nexport type Responder = (request: CallbackRequest) => Promise<JsonObject> | JsonObject;\n"]}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type JsonPrimitive = null | boolean | number | string;
|
|
2
|
+
export type JsonObject = {
|
|
3
|
+
readonly [key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
export type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
|
|
6
|
+
export type Sha256Digest = `sha256:${string}`;
|
|
7
|
+
export declare class JsonValueError extends TypeError {
|
|
8
|
+
readonly code: 'INVALID_JSON_VALUE';
|
|
9
|
+
readonly path: string;
|
|
10
|
+
constructor(path: string, reason: string);
|
|
11
|
+
}
|
|
12
|
+
export declare function cloneFrozenJson<Value extends JsonValue>(value: Value): Value;
|
|
13
|
+
export declare function canonicalJson(value: JsonValue): string;
|
|
14
|
+
export declare function digestJson(value: JsonValue): Sha256Digest;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Memory, MemoryLimits } from './memory-types.js';
|
|
2
|
+
export interface MemoryConformanceOptions {
|
|
3
|
+
readonly scope: string;
|
|
4
|
+
readonly limits?: Partial<MemoryLimits>;
|
|
5
|
+
}
|
|
6
|
+
export type MemoryConformanceFactory = (options: MemoryConformanceOptions) => Memory | Promise<Memory>;
|
|
7
|
+
export interface MemoryConformanceFailure {
|
|
8
|
+
readonly case: string;
|
|
9
|
+
readonly message: string;
|
|
10
|
+
}
|
|
11
|
+
export interface MemoryConformanceReport {
|
|
12
|
+
readonly ok: boolean;
|
|
13
|
+
readonly cases: number;
|
|
14
|
+
readonly failures: readonly MemoryConformanceFailure[];
|
|
15
|
+
}
|
|
16
|
+
export declare function runMemoryConformance(factory: MemoryConformanceFactory): Promise<MemoryConformanceReport>;
|
|
17
|
+
export declare function assertMemoryConformance(factory: MemoryConformanceFactory): Promise<void>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export declare const MEMORY_ROOT: '/memories';
|
|
2
|
+
export type MemoryPath = typeof MEMORY_ROOT | `${typeof MEMORY_ROOT}/${string}`;
|
|
3
|
+
export type MemoryCommandName = 'view' | 'create' | 'str_replace' | 'insert' | 'delete' | 'rename';
|
|
4
|
+
export interface MemoryViewCommand {
|
|
5
|
+
readonly command: 'view';
|
|
6
|
+
readonly path: MemoryPath;
|
|
7
|
+
readonly viewRange?: readonly [startLine: number, endLine: number | -1];
|
|
8
|
+
}
|
|
9
|
+
export interface MemoryCreateCommand {
|
|
10
|
+
readonly command: 'create';
|
|
11
|
+
readonly path: MemoryPath;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MemoryStrReplaceCommand {
|
|
15
|
+
readonly command: 'str_replace';
|
|
16
|
+
readonly path: MemoryPath;
|
|
17
|
+
readonly oldText: string;
|
|
18
|
+
readonly newText: string;
|
|
19
|
+
}
|
|
20
|
+
export interface MemoryInsertCommand {
|
|
21
|
+
readonly command: 'insert';
|
|
22
|
+
readonly path: MemoryPath;
|
|
23
|
+
readonly insertLine: number;
|
|
24
|
+
readonly text: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MemoryDeleteCommand {
|
|
27
|
+
readonly command: 'delete';
|
|
28
|
+
readonly path: MemoryPath;
|
|
29
|
+
}
|
|
30
|
+
export interface MemoryRenameCommand {
|
|
31
|
+
readonly command: 'rename';
|
|
32
|
+
readonly oldPath: MemoryPath;
|
|
33
|
+
readonly newPath: MemoryPath;
|
|
34
|
+
}
|
|
35
|
+
export type MemoryCommand = MemoryViewCommand | MemoryCreateCommand | MemoryStrReplaceCommand | MemoryInsertCommand | MemoryDeleteCommand | MemoryRenameCommand;
|
|
36
|
+
export interface MemoryDirectoryEntry {
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly path: MemoryPath;
|
|
39
|
+
readonly kind: 'file' | 'directory';
|
|
40
|
+
}
|
|
41
|
+
export interface MemoryDirectoryView {
|
|
42
|
+
readonly kind: 'directory';
|
|
43
|
+
readonly path: MemoryPath;
|
|
44
|
+
readonly entries: readonly MemoryDirectoryEntry[];
|
|
45
|
+
}
|
|
46
|
+
export interface MemoryFileView {
|
|
47
|
+
readonly kind: 'file';
|
|
48
|
+
readonly path: MemoryPath;
|
|
49
|
+
readonly text: string;
|
|
50
|
+
readonly byteLength: number;
|
|
51
|
+
readonly lines: {
|
|
52
|
+
readonly start: number;
|
|
53
|
+
readonly end: number;
|
|
54
|
+
readonly total: number;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export type MemoryView = MemoryDirectoryView | MemoryFileView;
|
|
58
|
+
export interface MemoryCreateReceipt {
|
|
59
|
+
readonly path: MemoryPath;
|
|
60
|
+
readonly byteLength: number;
|
|
61
|
+
readonly evicted: readonly MemoryPath[];
|
|
62
|
+
readonly overwritten: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface MemoryWriteReceipt {
|
|
65
|
+
readonly path: MemoryPath;
|
|
66
|
+
readonly byteLength: number;
|
|
67
|
+
readonly evicted: readonly MemoryPath[];
|
|
68
|
+
}
|
|
69
|
+
export interface MemoryDeleteReceipt {
|
|
70
|
+
readonly path: MemoryPath;
|
|
71
|
+
readonly kind: 'file' | 'directory';
|
|
72
|
+
readonly deletedFiles: number;
|
|
73
|
+
readonly freedBytes: number;
|
|
74
|
+
}
|
|
75
|
+
export interface MemoryRenameReceipt {
|
|
76
|
+
readonly oldPath: MemoryPath;
|
|
77
|
+
readonly newPath: MemoryPath;
|
|
78
|
+
readonly kind: 'file' | 'directory';
|
|
79
|
+
readonly movedFiles: number;
|
|
80
|
+
}
|
|
81
|
+
export type MemoryErrorCode = 'INVALID_COMMAND' | 'INVALID_ARGUMENT' | 'INVALID_PATH' | 'ROOT_PROTECTED' | 'INVALID_EXTENSION' | 'NOT_FOUND' | 'ALREADY_EXISTS' | 'PATH_CONFLICT' | 'INVALID_RANGE' | 'MATCH_NOT_FOUND' | 'MATCH_NOT_UNIQUE' | 'LIMIT_EXCEEDED' | 'CONFLICT' | 'UNSAFE_STORAGE' | 'STORAGE_ERROR';
|
|
82
|
+
export interface MemoryError {
|
|
83
|
+
readonly code: MemoryErrorCode;
|
|
84
|
+
readonly message: string;
|
|
85
|
+
readonly path?: string;
|
|
86
|
+
readonly details?: Readonly<Record<string, string | number | boolean>>;
|
|
87
|
+
}
|
|
88
|
+
export type MemorySuccess = {
|
|
89
|
+
readonly ok: true;
|
|
90
|
+
readonly command: 'view';
|
|
91
|
+
readonly value: MemoryView;
|
|
92
|
+
} | {
|
|
93
|
+
readonly ok: true;
|
|
94
|
+
readonly command: 'create';
|
|
95
|
+
readonly value: MemoryCreateReceipt;
|
|
96
|
+
} | {
|
|
97
|
+
readonly ok: true;
|
|
98
|
+
readonly command: 'str_replace';
|
|
99
|
+
readonly value: MemoryWriteReceipt;
|
|
100
|
+
} | {
|
|
101
|
+
readonly ok: true;
|
|
102
|
+
readonly command: 'insert';
|
|
103
|
+
readonly value: MemoryWriteReceipt;
|
|
104
|
+
} | {
|
|
105
|
+
readonly ok: true;
|
|
106
|
+
readonly command: 'delete';
|
|
107
|
+
readonly value: MemoryDeleteReceipt;
|
|
108
|
+
} | {
|
|
109
|
+
readonly ok: true;
|
|
110
|
+
readonly command: 'rename';
|
|
111
|
+
readonly value: MemoryRenameReceipt;
|
|
112
|
+
};
|
|
113
|
+
export interface MemoryFailure {
|
|
114
|
+
readonly ok: false;
|
|
115
|
+
readonly command: string;
|
|
116
|
+
readonly error: MemoryError;
|
|
117
|
+
}
|
|
118
|
+
export type MemoryResult = MemorySuccess | MemoryFailure;
|
|
119
|
+
export interface MemoryLimits {
|
|
120
|
+
readonly maxFileBytes: number;
|
|
121
|
+
readonly maxTotalBytes: number;
|
|
122
|
+
readonly maxFiles: number;
|
|
123
|
+
}
|
|
124
|
+
export interface Memory {
|
|
125
|
+
readonly scope: string;
|
|
126
|
+
execute(command: MemoryCommand): Promise<MemoryResult>;
|
|
127
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider and model family a harness reports for the model it was given.
|
|
3
|
+
* `provider` is present only when the string carried one (`provider/model`);
|
|
4
|
+
* a harness that runs one provider's models supplies its own.
|
|
5
|
+
*/
|
|
6
|
+
export interface ModelIdentity {
|
|
7
|
+
readonly provider?: string;
|
|
8
|
+
readonly modelFamily: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Read the provider and the model family from a model string.
|
|
12
|
+
*
|
|
13
|
+
* A harness that runs other providers' models (OpenCode today, Devin next)
|
|
14
|
+
* must report the identity of the model it was given, never its own name,
|
|
15
|
+
* or two seats on one model wearing different tool names pass the
|
|
16
|
+
* distinct-family check. Every such harness, and the teams gate that reads
|
|
17
|
+
* recorded models back, derives the identity through this one function.
|
|
18
|
+
*
|
|
19
|
+
* `provider/model` yields both parts; a bare `model` yields the family alone.
|
|
20
|
+
* A second separator, or whitespace anywhere inside, is refused rather than
|
|
21
|
+
* read as part of a name.
|
|
22
|
+
* The family is the model name up to its first hyphen, lowercased, so
|
|
23
|
+
* `claude-sonnet-4-5` and `claude-opus-4-1` are one family and `gpt-5.6-luna`
|
|
24
|
+
* another. A string that names no readable family, including the `unknown`
|
|
25
|
+
* placeholder some adapters emit, is refused with an `invalid-config` engine
|
|
26
|
+
* error rather than reported as a family called `unknown`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function modelIdentity(model: string): ModelIdentity;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Memory } from './memory-types.js';
|
|
2
|
+
import type { JsonObject, JsonValue } from './json.js';
|
|
3
|
+
export interface NodeDataContext {
|
|
4
|
+
readonly input: JsonValue;
|
|
5
|
+
readonly memory: Memory | null;
|
|
6
|
+
readonly scratchDirectory: string;
|
|
7
|
+
readonly workspaceDirectory: string | null;
|
|
8
|
+
readonly trustedCaller: JsonObject;
|
|
9
|
+
readonly permissions: readonly string[];
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PreflightPauseResult {
|
|
2
|
+
readonly kind: 'pause';
|
|
3
|
+
readonly code: 'PREFLIGHT_PAUSED';
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
readonly preflightEventId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PreflightFailureResult {
|
|
8
|
+
readonly kind: 'fail';
|
|
9
|
+
readonly code: 'PREFLIGHT_FAILED';
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RunPreflightState {
|
|
13
|
+
readonly phase: 'disabled' | 'pending' | 'admitted' | 'paused' | 'failed';
|
|
14
|
+
readonly pause: PreflightPauseResult | null;
|
|
15
|
+
readonly resumedPreflightEventId: string | null;
|
|
16
|
+
readonly unfinishedProbeEventId: string | null;
|
|
17
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { NewDomainEvent } from '../events/envelope.js';
|
|
2
|
+
import { type JsonObject, type JsonValue, type Sha256Digest } from '../json.js';
|
|
3
|
+
import type { WorkspaceAnchor } from '../workspace/provider.js';
|
|
4
|
+
import type { ProofArtifactReference } from './artifact.js';
|
|
5
|
+
export interface AcceptedResultGraph extends JsonObject {
|
|
6
|
+
readonly definitionDigest: Sha256Digest;
|
|
7
|
+
readonly typeVersion: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AcceptedResultBindingInput {
|
|
10
|
+
readonly inputHashes: Readonly<Record<string, Sha256Digest>>;
|
|
11
|
+
readonly proofScope: JsonObject;
|
|
12
|
+
readonly proofArtifact: ProofArtifactReference;
|
|
13
|
+
readonly graph: AcceptedResultGraph;
|
|
14
|
+
readonly workspaceAnchor: WorkspaceAnchor;
|
|
15
|
+
readonly reviewerIdentity: JsonObject;
|
|
16
|
+
}
|
|
17
|
+
export interface AcceptedResultBinding extends JsonObject {
|
|
18
|
+
readonly inputHashes: Readonly<Record<string, Sha256Digest>>;
|
|
19
|
+
readonly proofScope: JsonObject;
|
|
20
|
+
readonly proofArtifact: ProofArtifactReference;
|
|
21
|
+
readonly graph: AcceptedResultGraph;
|
|
22
|
+
readonly workspaceAnchor: WorkspaceAnchor;
|
|
23
|
+
readonly reviewerIdentity: JsonObject;
|
|
24
|
+
readonly reviewerFingerprint: Sha256Digest;
|
|
25
|
+
}
|
|
26
|
+
export interface AcceptedResultRecord extends JsonObject {
|
|
27
|
+
readonly schemaVersion: 1;
|
|
28
|
+
readonly result: JsonValue;
|
|
29
|
+
readonly resultDigest: Sha256Digest;
|
|
30
|
+
readonly binding: AcceptedResultBinding;
|
|
31
|
+
readonly bindingDigest: Sha256Digest;
|
|
32
|
+
}
|
|
33
|
+
export interface AcceptedResultEventPayload extends JsonObject {
|
|
34
|
+
readonly position: string;
|
|
35
|
+
readonly record: AcceptedResultRecord;
|
|
36
|
+
}
|
|
37
|
+
export type NewAcceptedResultEvent = NewDomainEvent<'proof:result-accepted', 1, AcceptedResultEventPayload>;
|
|
38
|
+
export interface CreateAcceptedResultRecordInput extends AcceptedResultBindingInput {
|
|
39
|
+
readonly result: JsonValue;
|
|
40
|
+
}
|
|
41
|
+
export type AcceptedResultResolution = Readonly<{
|
|
42
|
+
readonly kind: 'accepted';
|
|
43
|
+
readonly record: AcceptedResultRecord;
|
|
44
|
+
}> | Readonly<{
|
|
45
|
+
readonly kind: 'wait';
|
|
46
|
+
readonly reason: string;
|
|
47
|
+
}>;
|
|
48
|
+
declare function isObject(value: unknown): value is JsonObject;
|
|
49
|
+
declare function hasExactFields(value: JsonObject, fields: readonly string[]): boolean;
|
|
50
|
+
declare function bindingFrom(input: AcceptedResultBindingInput): AcceptedResultBinding;
|
|
51
|
+
export declare function validateAcceptedResultRecord(value: unknown): AcceptedResultRecord;
|
|
52
|
+
export declare function acceptedResultMatches(record: AcceptedResultRecord, current: AcceptedResultBindingInput): boolean;
|
|
53
|
+
declare function acceptedResultMatchesBinding(record: AcceptedResultRecord, current: AcceptedResultBinding): boolean;
|
|
54
|
+
export declare const acceptedResultSupport: Readonly<{
|
|
55
|
+
isObject: typeof isObject;
|
|
56
|
+
hasExactFields: typeof hasExactFields;
|
|
57
|
+
bindingFrom: typeof bindingFrom;
|
|
58
|
+
acceptedResultMatchesBinding: typeof acceptedResultMatchesBinding;
|
|
59
|
+
}>;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue, Sha256Digest } from '../json.js';
|
|
2
|
+
import type { RunStorageBinding } from '../run-definition.js';
|
|
3
|
+
import type { AcceptedResultBindingInput, AcceptedResultResolution } from './acceptance.js';
|
|
4
|
+
import type { ProofArtifactReference } from './artifact.js';
|
|
5
|
+
/** Read-only sources must change their revision on every change, without reusing old revisions. */
|
|
6
|
+
export interface ProofSource {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
revision(): Promise<string>;
|
|
9
|
+
/** Return the full JSON value at this revision, bounded by its encoded UTF-8 size. */
|
|
10
|
+
read(expectedRevision: string, maxBytes: number): Promise<JsonValue>;
|
|
11
|
+
}
|
|
12
|
+
export interface ProofJob {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly mode: 'read-only' | 'effectful';
|
|
15
|
+
readonly sourceIds: readonly string[];
|
|
16
|
+
readonly proofScope: JsonObject;
|
|
17
|
+
}
|
|
18
|
+
export interface ProofPacketSource extends JsonObject {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly revision: string;
|
|
21
|
+
readonly digest: Sha256Digest;
|
|
22
|
+
readonly content: JsonValue;
|
|
23
|
+
}
|
|
24
|
+
export interface ProofPacket extends JsonObject {
|
|
25
|
+
readonly schemaVersion: 1;
|
|
26
|
+
readonly sources: readonly ProofPacketSource[];
|
|
27
|
+
}
|
|
28
|
+
export interface CachedProofPacket {
|
|
29
|
+
readonly packet: ProofPacket;
|
|
30
|
+
readonly inputHashes: Readonly<Record<string, Sha256Digest>>;
|
|
31
|
+
readonly proofArtifact: ProofArtifactReference;
|
|
32
|
+
readonly proofScope: JsonObject;
|
|
33
|
+
}
|
|
34
|
+
export interface ProofCacheOptions {
|
|
35
|
+
readonly storage: RunStorageBinding;
|
|
36
|
+
readonly runId: string;
|
|
37
|
+
readonly sources: readonly ProofSource[];
|
|
38
|
+
readonly proofJobs: readonly ProofJob[];
|
|
39
|
+
readonly maxPacketBytes: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ProofCache {
|
|
42
|
+
packet(jobId: string): Promise<CachedProofPacket>;
|
|
43
|
+
resolveAccepted(jobId: string, position: string, current: ProofCacheCurrentBinding): Promise<AcceptedResultResolution>;
|
|
44
|
+
}
|
|
45
|
+
/** The host supplies the current graph, verified workspace anchor and reviewer identity. */
|
|
46
|
+
export type ProofCacheCurrentBinding = Omit<AcceptedResultBindingInput, 'inputHashes' | 'proofScope' | 'proofArtifact'>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a reasoning record offers a run, named once so that the runtime can
|
|
3
|
+
* consume it without knowing which adapter supplies it.
|
|
4
|
+
*
|
|
5
|
+
* The record does not commit. A stage that opts in is already run in its own
|
|
6
|
+
* worktree and committed there before its work is merged back; that commit is
|
|
7
|
+
* the one carrying the change, so it is the one that should carry the reason
|
|
8
|
+
* the change exists. The record watches the stage work and, when the stage
|
|
9
|
+
* passes, offers a subject and a body for that commit.
|
|
10
|
+
*
|
|
11
|
+
* A stage that changed nothing produces no commit, so it produces no body:
|
|
12
|
+
* the caller asks for one only when there is something to write it on.
|
|
13
|
+
*/
|
|
14
|
+
/** The shape a record reads out of a run's event stream. Structural, so the
|
|
15
|
+
* runtime's own event type fits it without either side importing the other. */
|
|
16
|
+
export interface ReasoningEvent {
|
|
17
|
+
readonly kind: string;
|
|
18
|
+
readonly path?: readonly string[];
|
|
19
|
+
readonly delta?: string;
|
|
20
|
+
}
|
|
21
|
+
/** What a stage ended as, in the words the record composes from. */
|
|
22
|
+
export interface ReasoningOutcome {
|
|
23
|
+
readonly status: string;
|
|
24
|
+
readonly summary?: string;
|
|
25
|
+
}
|
|
26
|
+
/** A commit message: one line, then the reasoning under it. */
|
|
27
|
+
export interface ReasoningMessage {
|
|
28
|
+
readonly subject: string;
|
|
29
|
+
readonly body: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ReasoningRecorder {
|
|
32
|
+
/**
|
|
33
|
+
* Feed the run's events. A recorder keeps only what belongs to the stage it
|
|
34
|
+
* was opened for, and only the turns that carry a writer's words.
|
|
35
|
+
*/
|
|
36
|
+
observe(event: ReasoningEvent): void;
|
|
37
|
+
/**
|
|
38
|
+
* The message for the commit that carries this stage's change. Composition
|
|
39
|
+
* that fails or has nothing to say still returns a message built from the
|
|
40
|
+
* outcome, so an iteration that did work never leaves a commit that says
|
|
41
|
+
* nothing about why.
|
|
42
|
+
*/
|
|
43
|
+
message(outcome: ReasoningOutcome): Promise<ReasoningMessage>;
|
|
44
|
+
/**
|
|
45
|
+
* The commit the message landed on. A recorder that is asked for a message
|
|
46
|
+
* and never told the commit succeeded keeps what it captured, so a commit
|
|
47
|
+
* that failed can be tried again from the same turns; told the commit
|
|
48
|
+
* exists, it starts the next iteration empty rather than explaining one
|
|
49
|
+
* change with another's reasoning.
|
|
50
|
+
*/
|
|
51
|
+
committed(commit: string): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue, Sha256Digest } from './json.js';
|
|
2
|
+
export interface ResultContractRecord extends JsonObject {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly version: number;
|
|
5
|
+
readonly schemaDigest: Sha256Digest;
|
|
6
|
+
}
|
|
7
|
+
export interface ResultContract<Schema extends JsonValue = JsonValue, Result extends JsonValue = JsonValue> {
|
|
8
|
+
readonly record: ResultContractRecord;
|
|
9
|
+
readonly schema: Schema;
|
|
10
|
+
validate(value: unknown): Result;
|
|
11
|
+
}
|
|
12
|
+
export interface ResultContractDefinition<Schema extends JsonValue, Result extends JsonValue> {
|
|
13
|
+
readonly record: ResultContractRecord;
|
|
14
|
+
readonly schema: Schema;
|
|
15
|
+
readonly validate: (value: unknown) => Result;
|
|
16
|
+
}
|