@sema-agent/core 7.63.0 → 7.65.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/CHANGELOG.md +725 -0
- package/dist/agents/cc-peer-directory.js +1 -0
- package/dist/agents/cc-peer-wire.d.ts +4 -0
- package/dist/agents/cc-peer-wire.js +1 -0
- package/dist/agents/cc-uds-peer-channel.js +5 -0
- package/dist/agents/cross-session-judge.d.ts +3 -1
- package/dist/agents/cross-session-judge.js +4 -1
- package/dist/agents/peer-directory.d.ts +8 -0
- package/dist/agents/peer-directory.js +4 -0
- package/dist/agents/peer-held-queue.d.ts +9 -3
- package/dist/agents/peer-held-queue.js +12 -9
- package/dist/agents/peer-idle.d.ts +20 -1
- package/dist/agents/peer-idle.js +23 -12
- package/dist/agents/peer-notice-route.d.ts +16 -5
- package/dist/agents/peer-notice-route.js +11 -9
- package/dist/agents/peer-notices.d.ts +25 -8
- package/dist/agents/peer-notices.js +6 -1
- package/dist/agents/peer-session-drain.d.ts +32 -6
- package/dist/agents/peer-session-drain.js +100 -26
- package/dist/agents/send-message-tool.d.ts +7 -0
- package/dist/agents/send-message-tool.js +18 -6
- package/dist/agents/subagent.js +25 -5
- package/dist/core/allow-entry.d.ts +4 -0
- package/dist/core/ask-origin.d.ts +1 -1
- package/dist/core/ask-origin.js +2 -2
- package/dist/core/ask-unresolvable-notice.d.ts +13 -4
- package/dist/core/ask-unresolvable-notice.js +10 -3
- package/dist/core/auto-compaction.d.ts +7 -5
- package/dist/core/auto-promote.d.ts +3 -2
- package/dist/core/background-agent-store.d.ts +14 -0
- package/dist/core/background-agent-store.js +3 -0
- package/dist/core/checkpoint-queries.d.ts +9 -6
- package/dist/core/checkpoint-queries.js +8 -3
- package/dist/core/checkpoint-store.d.ts +7 -4
- package/dist/core/context-settings.d.ts +39 -9
- package/dist/core/context-settings.js +32 -10
- package/dist/core/engine-attestation.d.ts +26 -6
- package/dist/core/engine-attestation.js +5 -1
- package/dist/core/engine-notice.d.ts +37 -2
- package/dist/core/engine-notice.js +3 -1
- package/dist/core/extension-requester.d.ts +9 -0
- package/dist/core/extension-requester.js +7 -0
- package/dist/core/file-history-store.d.ts +30 -2
- package/dist/core/file-history-store.js +48 -9
- package/dist/core/fs-write-gate-policy.js +1 -1
- package/dist/core/gate-fold.js +5 -1
- package/dist/core/gate-lanes.js +2 -0
- package/dist/core/gate-outcome.d.ts +39 -2
- package/dist/core/gate-outcome.js +20 -1
- package/dist/core/governance-codes.d.ts +8 -4
- package/dist/core/governance-codes.js +8 -3
- package/dist/core/leg-identity.d.ts +35 -1
- package/dist/core/leg-identity.js +10 -0
- package/dist/core/mailbox-store.d.ts +39 -4
- package/dist/core/mailbox-store.js +14 -2
- package/dist/core/memory-engine/consolidation.d.ts +13 -6
- package/dist/core/memory-engine/consolidation.js +26 -0
- package/dist/core/memory-engine/control-objects.d.ts +58 -0
- package/dist/core/memory-engine/control-objects.js +273 -0
- package/dist/core/memory-engine/control-plane-adoption.d.ts +51 -0
- package/dist/core/memory-engine/control-plane-adoption.js +161 -0
- package/dist/core/memory-engine/delegation-settlement.d.ts +73 -40
- package/dist/core/memory-engine/delegation-settlement.js +271 -107
- package/dist/core/memory-engine/dual-root.d.ts +3 -2
- package/dist/core/memory-engine/dual-root.js +7 -3
- package/dist/core/memory-engine/engine.d.ts +54 -33
- package/dist/core/memory-engine/engine.js +150 -157
- package/dist/core/memory-engine/file-backend.d.ts +58 -76
- package/dist/core/memory-engine/file-backend.js +111 -268
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +135 -50
- package/dist/core/memory-engine/layout.js +214 -89
- package/dist/core/memory-engine/memory-age.d.ts +12 -0
- package/dist/core/memory-engine/memory-age.js +17 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +10 -3
- package/dist/core/memory-engine/memory-backend-contract.js +159 -2
- package/dist/core/memory-engine/memory-deployment.d.ts +12 -4
- package/dist/core/memory-engine/memory-deployment.js +31 -6
- package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
- package/dist/core/memory-engine/origin-clearance.js +64 -9
- package/dist/core/memory-engine/session-write-home.d.ts +34 -1
- package/dist/core/memory-engine/session-write-home.js +37 -10
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +7 -7
- package/dist/core/memory-engine/types.d.ts +55 -12
- package/dist/core/memory-engine/types.js +2 -1
- package/dist/core/memory-vector.d.ts +6 -14
- package/dist/core/memory.d.ts +0 -462
- package/dist/core/memory.js +0 -333
- package/dist/core/mode-policy.js +3 -3
- package/dist/core/mods/agent-stations.d.ts +18 -0
- package/dist/core/mods/agent-stations.js +8 -6
- package/dist/core/mods/extension-call.d.ts +4 -0
- package/dist/core/mods/extension-call.js +8 -0
- package/dist/core/mods/tool-call.js +3 -4
- package/dist/core/parent-spec-seat.d.ts +2 -2
- package/dist/core/peer-channel.d.ts +5 -0
- package/dist/core/permission-rule-consent.d.ts +64 -22
- package/dist/core/permission-rule-consent.js +106 -58
- package/dist/core/permission-rule-store.d.ts +56 -21
- package/dist/core/permission-rule-store.js +2 -0
- package/dist/core/refusal-echo.d.ts +20 -0
- package/dist/core/refusal-echo.js +33 -0
- package/dist/core/retention.d.ts +175 -10
- package/dist/core/retention.js +44 -0
- package/dist/core/retired-keys.d.ts +5 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/rule-offer-read.d.ts +0 -4
- package/dist/core/rule-offer-read.js +2 -18
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +4 -2
- package/dist/core/runner/compact-session.js +10 -7
- package/dist/core/runner/compaction-call-options.d.ts +7 -7
- package/dist/core/runner/compaction-call-options.js +3 -2
- package/dist/core/runner/contracts.d.ts +28 -9
- package/dist/core/runner/delegation-owner.d.ts +2 -3
- package/dist/core/runner/delegation-owner.js +2 -1
- package/dist/core/runner/gate-exit.d.ts +6 -0
- package/dist/core/runner/gate-exit.js +11 -2
- package/dist/core/runner/memory-consolidation-driver.d.ts +4 -2
- package/dist/core/runner/memory-consolidation-driver.js +8 -5
- package/dist/core/runner/prepare-ask-lane.js +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -2
- package/dist/core/runner/prepare-config-doors.js +4 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +2 -2
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -0
- package/dist/core/runner/prepare-gate-stations.js +15 -7
- package/dist/core/runner/prepare-hands-readface.js +1 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +3 -1
- package/dist/core/runner/prepare-inherited-gate.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +4 -0
- package/dist/core/runner/prepare-memory.js +22 -28
- package/dist/core/runner/prepare-policy-chain.js +18 -10
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-task.d.ts +5 -1
- package/dist/core/runner/prepare-task.js +16 -11
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/resume-admission.d.ts +2 -2
- package/dist/core/runner/resume-admission.js +2 -23
- package/dist/core/runner/role-resolution-table.d.ts +98 -0
- package/dist/core/runner/role-resolution-table.js +62 -0
- package/dist/core/runner/run-compaction-machinery.js +2 -2
- package/dist/core/runner/run-identity-wiring.js +12 -9
- package/dist/core/runner/run-leg.js +8 -4
- package/dist/core/runner/run-notification-lane.js +23 -23
- package/dist/core/runner/run-recovery-lanes.js +3 -3
- package/dist/core/runner/run-terminal-adoption.js +1 -1
- package/dist/core/runner/run-turn-boundary.js +14 -15
- package/dist/core/runner/runtask.js +1 -1
- package/dist/core/runner/sub-agent-deny-lists.d.ts +19 -0
- package/dist/core/runner/sub-agent-deny-lists.js +25 -0
- package/dist/core/runner/tool-occurrence.d.ts +4 -2
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/secret-env.d.ts +2 -2
- package/dist/core/secret-env.js +6 -20
- package/dist/core/session-checkout.d.ts +63 -3
- package/dist/core/session-checkout.js +152 -58
- package/dist/core/session-store.d.ts +6 -6
- package/dist/core/session-store.js +3 -3
- package/dist/core/shell-read-silence.js +8 -0
- package/dist/core/store-contracts/background-agent-store-contract.js +13 -0
- package/dist/core/store-contracts/peer-directory-contract.js +8 -1
- package/dist/core/task-event.d.ts +9 -5
- package/dist/core/task-notification.d.ts +137 -31
- package/dist/core/task-notification.js +198 -100
- package/dist/core/task-registry-agent.d.ts +11 -0
- package/dist/core/task-registry-agent.js +12 -3
- package/dist/core/task-registry-shared.d.ts +11 -0
- package/dist/core/task-registry.d.ts +18 -0
- package/dist/core/task-registry.js +27 -8
- package/dist/core/task-spec.d.ts +7 -2
- package/dist/core/tool-errors.d.ts +17 -9
- package/dist/core/tool-errors.js +1 -1
- package/dist/core/tool-policy.d.ts +18 -1
- package/dist/core/tool-policy.js +16 -7
- package/dist/core/tool-result-store.d.ts +20 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/trace.d.ts +3 -2
- package/dist/core/workflow-journal-store.d.ts +11 -0
- package/dist/core/workflow-journal-store.js +7 -0
- package/dist/core/workflow-run-store.d.ts +9 -0
- package/dist/core/workflow-run-store.js +6 -0
- package/dist/core/write-protect.d.ts +16 -0
- package/dist/core/write-protect.js +10 -0
- package/dist/engine/compaction/compaction.d.ts +2 -1
- package/dist/engine/harness/types.d.ts +1 -0
- package/dist/engine/session/repo-utils.d.ts +14 -4
- package/dist/engine/session/repo-utils.js +5 -4
- package/dist/engine/session/session.d.ts +7 -1
- package/dist/engine/session/session.js +5 -2
- package/dist/index.d.ts +13 -11
- package/dist/index.js +13 -11
- package/dist/orchestration/run-workflow-tool.d.ts +4 -0
- package/dist/orchestration/run-workflow-tool.js +7 -0
- package/dist/orchestration/workflow-types.d.ts +2 -1
- package/dist/orchestration/workflow.d.ts +3 -0
- package/dist/orchestration/workflow.js +2 -1
- package/dist/prompts/default.d.ts +1 -2
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/stores/file/adoption/adopt.d.ts +1 -1
- package/dist/stores/file/checkpoint-store.d.ts +6 -0
- package/dist/stores/file/checkpoint-store.js +4 -1
- package/dist/stores/file/file-history-store.d.ts +13 -0
- package/dist/stores/file/file-history-store.js +75 -13
- package/dist/stores/file/index.d.ts +12 -16
- package/dist/stores/file/index.js +7 -25
- package/dist/stores/file/permission-rule-store.d.ts +34 -0
- package/dist/stores/file/permission-rule-store.js +104 -9
- package/dist/stores/file/session-store.js +1 -1
- package/dist/stores/file/tool-result-store.d.ts +14 -0
- package/dist/stores/file/tool-result-store.js +39 -2
- package/dist/stores/file/workflow-journal-store.d.ts +4 -0
- package/dist/stores/file/workflow-journal-store.js +17 -0
- package/dist/stores/file/workflow-run-store.d.ts +3 -0
- package/dist/stores/file/workflow-run-store.js +15 -0
- package/dist/tools/fs/read-deny.d.ts +15 -2
- package/dist/tools/fs/read-deny.js +10 -2
- package/dist/tools/fs/shell-read-check.d.ts +8 -2
- package/dist/tools/fs/shell-read-check.js +7 -7
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +71 -73
- package/wire-changes/core-stores-sql@7.64.0.json +30 -0
- package/wire-changes/core-stores-sql@7.65.0.json +30 -0
- package/wire-changes/core@7.64.0.json +2653 -0
- package/wire-changes/core@7.65.0.json +1650 -0
- package/wire-changes/mods-kernel@7.64.0.json +30 -0
- package/wire-changes/mods-kernel@7.65.0.json +30 -0
- package/wire-changes/primitives@7.64.0.json +30 -0
- package/wire-changes/primitives@7.65.0.json +337 -0
- package/dist/core/memory-recall.d.ts +0 -208
- package/dist/core/memory-recall.js +0 -136
- package/dist/stores/file/memory-store.d.ts +0 -124
- package/dist/stores/file/memory-store.js +0 -353
|
@@ -523,6 +523,21 @@ export interface FileHistoryStore {
|
|
|
523
523
|
* reference — the arm the commit paths already validate for.
|
|
524
524
|
*/
|
|
525
525
|
reap(scope: string, keepEntryIds: string[]): Promise<number>;
|
|
526
|
+
/**
|
|
527
|
+
* Erase the WHOLE scope — every boundary, every version record INCLUDING the v1 pristine baselines `reap` keeps while a scope
|
|
528
|
+
* lives, its consumed-id ledger — and the blobs no other scope references: the session-tree cascade's leg for a deleted session
|
|
529
|
+
* (the scope is the session id; {@link import("./retention.js").RETENTION_CASCADE}). Answers how many boundaries and version
|
|
530
|
+
* records it removed (a damaged record is erased all the same and counts once; a scope with no history answers 0, so a repeat
|
|
531
|
+
* is harmless). The scope then reads as one that never had
|
|
532
|
+
* history: an id registered again later starts a new one. Refused (thrown, `conflict`) while THIS store runs a write of the scope
|
|
533
|
+
* — a capture, a first-touch record, a retraction or an import, counted from the call, so one parked before its first record is
|
|
534
|
+
* counted — since a cascade runs on a session with no leg running; another process's writes are the caller's precondition to
|
|
535
|
+
* hold. A store fault throws: a deletion face that cannot delete is loud, never a quiet 0 — the blob pass included, so a backend
|
|
536
|
+
* that cannot collect every blob only the scope referenced (another scope's history it cannot judge, a blob that will not unlink)
|
|
537
|
+
* throws after the records are gone, and a repeat runs that pass again. OPTIONAL: absent ⇒ this store cannot complete a session
|
|
538
|
+
* deletion (only `reap` remains, which keeps the baselines), and the deployment owns that gap.
|
|
539
|
+
*/
|
|
540
|
+
deleteBySession?(scope: string): Promise<number>;
|
|
526
541
|
/**
|
|
527
542
|
* Cross-session carry (CC copyFileHistoryForResume): make `toScope` see `fromScope`'s boundaries
|
|
528
543
|
* + versions (content-addressed backends copy references, zero bytes). Same-scope call is a
|
|
@@ -624,8 +639,8 @@ export interface FileHistoryBlobExchange {
|
|
|
624
639
|
/**
|
|
625
640
|
* The store's blob exchange, read as one capability: `undefined` when the store carries no `blobExchange`; its three
|
|
626
641
|
* members, bound, when it carries the whole group; a refusal (`config.invalid_argument`) when the group is not an
|
|
627
|
-
* object or a member is missing or not a function.
|
|
628
|
-
*
|
|
642
|
+
* object or a member is missing or not a function. The group is the only reading: no other member of the store says
|
|
643
|
+
* anything about the capability.
|
|
629
644
|
*/
|
|
630
645
|
export declare function fileHistoryBlobExchangeOf(store: FileHistoryStore): FileHistoryBlobExchange | undefined;
|
|
631
646
|
/**
|
|
@@ -882,6 +897,9 @@ export declare class InMemoryFileHistoryStore implements FileHistoryStore {
|
|
|
882
897
|
* (adversarial round): two concurrent captures can lease the same new hash, and the first
|
|
883
898
|
* attempt's release must not strip the second attempt's liveness. */
|
|
884
899
|
private readonly inFlightBlobs;
|
|
900
|
+
/** Per scope, the history writes (`trackEdit`, `annulTrack`, `snapshot`, `importHistory`) this store is running, from call to
|
|
901
|
+
* settle: `deleteBySession` refuses while a scope has one, an import still fetching its blobs included. */
|
|
902
|
+
private readonly writers;
|
|
885
903
|
constructor(options?: InMemoryFileHistoryStoreOptions);
|
|
886
904
|
/**
|
|
887
905
|
* The RETENTION pass, run after a boundary commits (design/381 §片2 — see {@link FileHistoryStore.reap}
|
|
@@ -902,22 +920,32 @@ export declare class InMemoryFileHistoryStore implements FileHistoryStore {
|
|
|
902
920
|
/** PROTECTED COMMIT SEAM (fault-injectable): publish a captured boundary in ONE synchronous step
|
|
903
921
|
* — version records + mapping become visible together or not at all (atomic visibility). */
|
|
904
922
|
protected publishBoundary(scope: string, entryId: string, staged: Map<string, StagedFileCapture>): void;
|
|
923
|
+
/** One history write of `scope`, counted in {@link writers} for its whole run. */
|
|
924
|
+
private writing;
|
|
905
925
|
trackEdit(scope: string, absPath: string, env: ExecutionEnv, root: string, signal?: AbortSignal): Promise<FileHistoryTrackResult>;
|
|
926
|
+
private trackEditCounted;
|
|
906
927
|
annulTrack(scope: string, absPath: string, root: string, verify?: {
|
|
907
928
|
env: ExecutionEnv;
|
|
908
929
|
signal?: AbortSignal;
|
|
909
930
|
}): Promise<FileHistoryResult>;
|
|
931
|
+
private annulTrackCounted;
|
|
910
932
|
snapshot(scope: string, entryId: string, env: ExecutionEnv, root: string, signal?: AbortSignal): Promise<FileHistoryResult>;
|
|
933
|
+
private snapshotCounted;
|
|
911
934
|
restore(scope: string, entryId: string, env: ExecutionEnv, root: string, signal?: AbortSignal): Promise<FileHistoryRestoreResult>;
|
|
912
935
|
canRestore(scope: string, entryId: string): Promise<boolean>;
|
|
913
936
|
diffStats(scope: string, entryId: string, env: ExecutionEnv, root: string): Promise<FileHistoryDiffStats | null>;
|
|
914
937
|
reap(scope: string, keepEntryIds: string[]): Promise<number>;
|
|
938
|
+
deleteBySession(scope: string): Promise<number>;
|
|
939
|
+
/** Blob GC: live = referenced by ANY scope's retained version records, or in-flight. Synchronous (no await), so it runs
|
|
940
|
+
* atomically vs an in-flight capture parked at an await. */
|
|
941
|
+
private collectBlobs;
|
|
915
942
|
adoptScope(fromScope: string, toScope: string): Promise<FileHistoryResult>;
|
|
916
943
|
exportHistory(scope: string): Promise<FileHistoryExportResult>;
|
|
917
944
|
/** The export projection as a SYNCHRONOUS function — the import's final claim needs to compare a
|
|
918
945
|
* target's identity without yielding (see the publish step). */
|
|
919
946
|
private exportOf;
|
|
920
947
|
importHistory(scope: string, data: FileHistoryExport, srcGetBlob: (hash: string) => Promise<Uint8Array | undefined>): Promise<FileHistoryResult>;
|
|
948
|
+
private importHistoryCounted;
|
|
921
949
|
/** The import body inside the blob lease (see {@link importHistory}). */
|
|
922
950
|
private importStaged;
|
|
923
951
|
}
|
|
@@ -249,17 +249,13 @@ function judgeFileHistoryEnvelope(data) {
|
|
|
249
249
|
const BLOB_EXCHANGE_MEMBERS = Object.freeze(["put", "get", "has"]);
|
|
250
250
|
export function fileHistoryBlobExchangeOf(store) {
|
|
251
251
|
const owner = "FileHistoryStore.blobExchange";
|
|
252
|
-
let marker;
|
|
253
252
|
let group;
|
|
254
253
|
try {
|
|
255
|
-
marker = Reflect.get(store, "syncBlobFaces");
|
|
256
254
|
group = store.blobExchange;
|
|
257
255
|
}
|
|
258
256
|
catch (cause) {
|
|
259
257
|
throw invalidBlobExchange(`${owner} could not be read (${thrownText(cause)}).`);
|
|
260
258
|
}
|
|
261
|
-
if (marker !== undefined)
|
|
262
|
-
throw invalidBlobExchange(`FileHistoryStore carries the retired syncBlobFaces marker — the blob exchange is the ${owner} group (put / get / has): present means the capability, absent means none.`);
|
|
263
259
|
if (group === undefined)
|
|
264
260
|
return undefined;
|
|
265
261
|
if (typeof group !== "object" || group === null)
|
|
@@ -445,6 +441,7 @@ export class InMemoryFileHistoryStore {
|
|
|
445
441
|
boundaryKeep;
|
|
446
442
|
blobs = new Map();
|
|
447
443
|
inFlightBlobs = new Map();
|
|
444
|
+
writers = new Map();
|
|
448
445
|
constructor(options) {
|
|
449
446
|
const opts = receiveOptions(options, "InMemoryFileHistoryStore", IN_MEMORY_FILE_HISTORY_STORE_OPTION_KEYS);
|
|
450
447
|
this.boundaryKeep = resolveFileHistoryRetention("InMemoryFileHistoryStore", opts.retention);
|
|
@@ -513,7 +510,23 @@ export class InMemoryFileHistoryStore {
|
|
|
513
510
|
}
|
|
514
511
|
sc.boundaries.set(entryId, mapping);
|
|
515
512
|
}
|
|
516
|
-
async
|
|
513
|
+
async writing(scope, write) {
|
|
514
|
+
this.writers.set(scope, (this.writers.get(scope) ?? 0) + 1);
|
|
515
|
+
try {
|
|
516
|
+
return await write();
|
|
517
|
+
}
|
|
518
|
+
finally {
|
|
519
|
+
const left = (this.writers.get(scope) ?? 1) - 1;
|
|
520
|
+
if (left === 0)
|
|
521
|
+
this.writers.delete(scope);
|
|
522
|
+
else
|
|
523
|
+
this.writers.set(scope, left);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
trackEdit(scope, absPath, env, root, signal) {
|
|
527
|
+
return this.writing(scope, () => this.trackEditCounted(scope, absPath, env, root, signal));
|
|
528
|
+
}
|
|
529
|
+
async trackEditCounted(scope, absPath, env, root, signal) {
|
|
517
530
|
try {
|
|
518
531
|
const { key, ...keyDesc } = describeTrackKey(root, absPath);
|
|
519
532
|
const sc = this.scope(scope);
|
|
@@ -562,7 +575,10 @@ export class InMemoryFileHistoryStore {
|
|
|
562
575
|
return { ok: false, error: { code: "track_failed", message: `first-touch record for ${absPath} could not be persisted: ${thrownText(err)}`, ...caughtFault(err) } };
|
|
563
576
|
}
|
|
564
577
|
}
|
|
565
|
-
|
|
578
|
+
annulTrack(scope, absPath, root, verify) {
|
|
579
|
+
return this.writing(scope, () => this.annulTrackCounted(scope, absPath, root, verify));
|
|
580
|
+
}
|
|
581
|
+
async annulTrackCounted(scope, absPath, root, verify) {
|
|
566
582
|
try {
|
|
567
583
|
const key = trackKeyOf(root, absPath);
|
|
568
584
|
const sc = this.scopes.get(scope);
|
|
@@ -602,7 +618,10 @@ export class InMemoryFileHistoryStore {
|
|
|
602
618
|
return { ok: false, error: { code: "track_failed", message: `annulling the first-touch record for ${absPath} failed: ${thrownText(err)}`, ...caughtFault(err) } };
|
|
603
619
|
}
|
|
604
620
|
}
|
|
605
|
-
|
|
621
|
+
snapshot(scope, entryId, env, root, signal) {
|
|
622
|
+
return this.writing(scope, () => this.snapshotCounted(scope, entryId, env, root, signal));
|
|
623
|
+
}
|
|
624
|
+
async snapshotCounted(scope, entryId, env, root, signal) {
|
|
606
625
|
const sc = this.scope(scope);
|
|
607
626
|
if (sc.boundaries.has(entryId))
|
|
608
627
|
return { ok: true };
|
|
@@ -824,6 +843,24 @@ export class InMemoryFileHistoryStore {
|
|
|
824
843
|
const refs = referenced.get(key);
|
|
825
844
|
t.versions = t.versions.filter((v) => v.version === 1 || (refs?.has(v.version) ?? false));
|
|
826
845
|
}
|
|
846
|
+
this.collectBlobs();
|
|
847
|
+
return removed;
|
|
848
|
+
}
|
|
849
|
+
async deleteBySession(scope) {
|
|
850
|
+
if (this.writers.has(scope)) {
|
|
851
|
+
throw Object.assign(new Error(`file history scope "${scope}" has a write in flight in this store (a capture, a first-touch record, a retraction or an import) — a session's history is erased when no leg of it runs`), { code: "conflict" });
|
|
852
|
+
}
|
|
853
|
+
const sc = this.scopes.get(scope);
|
|
854
|
+
if (sc === undefined)
|
|
855
|
+
return 0;
|
|
856
|
+
let removed = sc.boundaries.size;
|
|
857
|
+
for (const t of sc.tracked.values())
|
|
858
|
+
removed += t.versions.length;
|
|
859
|
+
this.scopes.delete(scope);
|
|
860
|
+
this.collectBlobs();
|
|
861
|
+
return removed;
|
|
862
|
+
}
|
|
863
|
+
collectBlobs() {
|
|
827
864
|
const live = new Set(this.inFlightBlobs.keys());
|
|
828
865
|
for (const s of this.scopes.values()) {
|
|
829
866
|
for (const t of s.tracked.values())
|
|
@@ -834,7 +871,6 @@ export class InMemoryFileHistoryStore {
|
|
|
834
871
|
for (const h of [...this.blobs.keys()])
|
|
835
872
|
if (!live.has(h))
|
|
836
873
|
this.blobs.delete(h);
|
|
837
|
-
return removed;
|
|
838
874
|
}
|
|
839
875
|
async adoptScope(fromScope, toScope) {
|
|
840
876
|
try {
|
|
@@ -886,7 +922,10 @@ export class InMemoryFileHistoryStore {
|
|
|
886
922
|
.map(([entryId, mapping]) => ({ entryId, files: [...mapping.entries()].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([relOrAbsPath, version]) => ({ relOrAbsPath, version })) })),
|
|
887
923
|
};
|
|
888
924
|
}
|
|
889
|
-
|
|
925
|
+
importHistory(scope, data, srcGetBlob) {
|
|
926
|
+
return this.writing(scope, () => this.importHistoryCounted(scope, data, srcGetBlob));
|
|
927
|
+
}
|
|
928
|
+
async importHistoryCounted(scope, data, srcGetBlob) {
|
|
890
929
|
try {
|
|
891
930
|
const shaped = validateFileHistoryExport(data);
|
|
892
931
|
if (!shaped.ok)
|
|
@@ -134,7 +134,7 @@ export function createFsWriteGatePolicy(opts) {
|
|
|
134
134
|
if (note !== undefined)
|
|
135
135
|
return ask(`approve write to "${path}"?${note}`);
|
|
136
136
|
const generic = `approve write to "${path}"?`;
|
|
137
|
-
return attest(ask(generic), req, {
|
|
137
|
+
return attest(ask(generic), req, { sentence: { text: generic, generic: true, echoed: [Object.freeze({ kind: "path", value: path })] } });
|
|
138
138
|
},
|
|
139
139
|
};
|
|
140
140
|
}
|
package/dist/core/gate-fold.js
CHANGED
|
@@ -5,7 +5,7 @@ import { normalizeReadRootCandidate } from "./read-root-candidate.js";
|
|
|
5
5
|
import { engineFailClosedExit, hookDenyExit, settledScreenExit, takeInheritedScreen } from "./runner/gate-exit.js";
|
|
6
6
|
import { noteRewrite, POLICY_AUTHOR, readRejudge, screenRewrite } from "./rewrite-rejudge.js";
|
|
7
7
|
import { traceHookCrash } from "./gate-crash-trace.js";
|
|
8
|
-
import { writeProtectionMandated, writeProtectionReachOf, writeProtectionTightenDecision } from "./write-protect.js";
|
|
8
|
+
import { askWithTableSentence, writeProtectionMandated, writeProtectionReachOf, writeProtectionTightenDecision } from "./write-protect.js";
|
|
9
9
|
import { createGateDeadline, awaitWriteProtectionJudgment, gateWaitFailureOf, withGateTimeout } from "./gate-bounded-await.js";
|
|
10
10
|
import { shellReadFaceWords } from "../tools/fs/shell-read-face.js";
|
|
11
11
|
import { failedJudgmentDeny } from "./runner/policy-throw.js";
|
|
@@ -183,6 +183,8 @@ export async function runGateFold(pass) {
|
|
|
183
183
|
else
|
|
184
184
|
pass.deniedBy = "write_protection";
|
|
185
185
|
}
|
|
186
|
+
else if (decision?.action === "ask" && decision.message !== undefined && pass.decision.action === "ask")
|
|
187
|
+
pass.decision = askWithTableSentence(pass.decision, decision.message, { toolCallId, toolName });
|
|
186
188
|
}
|
|
187
189
|
if (pass.decision.action !== "deny" && input.crossBoundaryCheck?.obligation({ toolName, args: pass.policyRewrite !== undefined ? pass.policyRewrite : pass.currentInput, toolCallId }).mandate === true) {
|
|
188
190
|
const marks = { requiresRealApproval: true, crossBoundaryMandated: true };
|
|
@@ -225,6 +227,8 @@ function applyShellReadVerdict(pass, answer, toolName, shellGated) {
|
|
|
225
227
|
pass.deniedBy = "read_boundary";
|
|
226
228
|
if (verdict.details !== undefined)
|
|
227
229
|
pass.denyDetails = verdict.details;
|
|
230
|
+
if (verdict.echoed !== undefined)
|
|
231
|
+
pass.denyEchoed = verdict.echoed;
|
|
228
232
|
return;
|
|
229
233
|
}
|
|
230
234
|
if (reading.kind === "silence") {
|
package/dist/core/gate-lanes.js
CHANGED
|
@@ -839,6 +839,8 @@ export async function runGateLanes(pass) {
|
|
|
839
839
|
pass.deniedBy = "read_boundary";
|
|
840
840
|
if (reading.verdict.details !== undefined)
|
|
841
841
|
pass.denyDetails = reading.verdict.details;
|
|
842
|
+
if (reading.verdict.echoed !== undefined)
|
|
843
|
+
pass.denyEchoed = reading.verdict.echoed;
|
|
842
844
|
}
|
|
843
845
|
}
|
|
844
846
|
}
|
|
@@ -11,6 +11,7 @@ import { type AskClass, type AskOrigin, type AssertAllKeysHandled, type ModeRele
|
|
|
11
11
|
import { type AutoModeClassifierRound, type AutoModeFallbackCause } from "./auto-mode.js";
|
|
12
12
|
import { type AllowRuleClearance } from "./allow-rule-shadow.js";
|
|
13
13
|
import type { ResolvedOutcome } from "./checkpoint-store.js";
|
|
14
|
+
import { type RefusalEcho } from "./refusal-echo.js";
|
|
14
15
|
/**
|
|
15
16
|
* How the wait an ask was in ENDED — the closed set. One word per way a wait can end; the `who` on the
|
|
16
17
|
* record says which party ended it and is fixed BY the word (see {@link Settlement}).
|
|
@@ -402,6 +403,24 @@ export declare const DENIED_BY_MAY_NAME_EXTENSION: {
|
|
|
402
403
|
};
|
|
403
404
|
/** Compile-time fence: `never` while every deny layer has an extension-naming row. */
|
|
404
405
|
export type ExtensionTableCoversEveryDeniedBy = AssertAllKeysHandled<Exclude<DeniedBy, keyof typeof DENIED_BY_MAY_NAME_EXTENSION>>;
|
|
406
|
+
/** Which deny layers may carry the literals their refusal sentence quotes ({@link GateDisposition}'s `echoed`): the read station,
|
|
407
|
+
* whose deny sentence is minted with them from one finding; an ask's resolution, whose refusal sentence quotes the question the
|
|
408
|
+
* engine composed with its literals. The mint reads it as the producer and the screen (invariant I13) as the archive: one table,
|
|
409
|
+
* two readers. Module-level only; not part of the package root. */
|
|
410
|
+
export declare const DENIED_BY_MAY_ECHO: {
|
|
411
|
+
readonly policy: false;
|
|
412
|
+
readonly hook: false;
|
|
413
|
+
readonly org: false;
|
|
414
|
+
readonly persisted_rule: false;
|
|
415
|
+
readonly classifier: false;
|
|
416
|
+
readonly compliance: false;
|
|
417
|
+
readonly write_protection: false;
|
|
418
|
+
readonly ask_resolution: true;
|
|
419
|
+
readonly read_boundary: true;
|
|
420
|
+
readonly mode: false;
|
|
421
|
+
};
|
|
422
|
+
/** Compile-time fence: `never` while every deny layer has an echo row. */
|
|
423
|
+
export type EchoTableCoversEveryDeniedBy = AssertAllKeysHandled<Exclude<DeniedBy, keyof typeof DENIED_BY_MAY_ECHO>>;
|
|
405
424
|
/** The final disposition of a gate pass. `cause` is present exactly when the deny came out of an auto-mode
|
|
406
425
|
* classifier round that did not RULE ({@link ClassifierDenyCause}); a ruling block and every non-classifier
|
|
407
426
|
* deny carry none. Invariant I5 ({@link screenGateOutcome}): a cause stands only beside a layer word in
|
|
@@ -436,7 +455,21 @@ export type ExtensionTableCoversEveryDeniedBy = AssertAllKeysHandled<Exclude<Den
|
|
|
436
455
|
* refusing handler's registration is known; ABSENT beside every other layer word (an ancestor leg's screening reaches a
|
|
437
456
|
* descendant as a `policy` refusal, and a refusal an inherited installation's question settled is that question's), and beside
|
|
438
457
|
* a `hook` refusal that names no registration (the engine's own failed raise, a cancel). A display and audit fact: the call is
|
|
439
|
-
* refused whatever the name. Additive. Invariant I12 ({@link screenGateOutcome}) screens its shape.
|
|
458
|
+
* refused whatever the name. Additive. Invariant I12 ({@link screenGateOutcome}) screens its shape.
|
|
459
|
+
*
|
|
460
|
+
* `echoed` — on the denied arm only: the literals the refusal's sentence quotes — the path (with its canonical target where the
|
|
461
|
+
* sentence names one), the view of it the deny row actually matched when that is another spelling, and the pattern — in the order
|
|
462
|
+
* the sentence quotes them, each whole (the sentence elides the middle of a long one, this list never does). Minted with the
|
|
463
|
+
* sentence from one finding, so a consumer reads WHICH path, command or pattern was refused from here and never by taking the
|
|
464
|
+
* sentence apart. Present when `deniedBy` is `read_boundary` and the refusal is a deny-row hit, and when `deniedBy` is
|
|
465
|
+
* `ask_resolution` and the refusal quotes a question the engine composed with its literals (a write gate's or the plan mode's
|
|
466
|
+
* generic question about a path: the list then holds that path as the call spells it — not a canonical one) while the refusal's
|
|
467
|
+
* sentence is still the one the resolver composed ({@link DENIED_BY_MAY_ECHO}). ABSENT beside every other layer word, on a
|
|
468
|
+
* read-boundary refusal that quotes no deny row (a containment or identity finding), and on a resolution refusal whose question
|
|
469
|
+
* was anyone else's words or was rewritten or appended to on the way (a hook's, a persisted rule's, a card's added sentence): the
|
|
470
|
+
* sentence is then the whole account, and a consumer that finds the member absent reads it as it always did — what was asked is
|
|
471
|
+
* the call's own arguments. The member's presence says nothing about the layer: read the layer off `deniedBy`. Additive.
|
|
472
|
+
* Invariant I13 ({@link screenGateOutcome}) screens its shape. */
|
|
440
473
|
export type GateDisposition = {
|
|
441
474
|
kind: "allowed";
|
|
442
475
|
classifier?: AutoModeClassifierRound;
|
|
@@ -451,6 +484,7 @@ export type GateDisposition = {
|
|
|
451
484
|
askClass?: AskClass;
|
|
452
485
|
classes?: readonly AskClass[];
|
|
453
486
|
extension?: string;
|
|
487
|
+
echoed?: readonly RefusalEcho[];
|
|
454
488
|
};
|
|
455
489
|
/**
|
|
456
490
|
* A permission MODE released a surviving ask — the allowed disposition's account of the question it did not put
|
|
@@ -511,6 +545,9 @@ export interface ModeRefusal {
|
|
|
511
545
|
* I10 `settlement.when` present ⇒ a finite number (epoch ms — the moment the wait ended is a value a reader can order);
|
|
512
546
|
* I12 `disposition.extension` present ⇒ the denied arm, a layer word {@link DENIED_BY_MAY_NAME_EXTENSION} admits (the hook layer),
|
|
513
547
|
* and a non-empty string (a registration's name);
|
|
548
|
+
* I13 `disposition.echoed` present ⇒ the denied arm, a layer word {@link DENIED_BY_MAY_ECHO} admits (the read station, an ask's resolution), and a
|
|
549
|
+
* non-empty list of echoes ({@link refusalEchoDefects}): a kind of the closed set, a non-empty `value`, and a `canonical`
|
|
550
|
+
* only on a path;
|
|
514
551
|
* I11 a winner's `decision` stated beside the record (the caller reads a durable row: `winnerDecision`) ⇒ a word a winner holds,
|
|
515
552
|
* and its direction (allow: `allow` / `approve` / `edit`; refusal: `deny` / `reject`) is the direction of the record's
|
|
516
553
|
* settlement ({@link SETTLEMENT_IS_REFUSAL}) and of its disposition (`allowed` / `denied`) — one decision, one direction.
|
|
@@ -582,7 +619,7 @@ export declare function isRetiredMember<S extends MemberSet>(set: S, word: unkno
|
|
|
582
619
|
*/
|
|
583
620
|
export declare function releasePolicyDefects(g: unknown): string[];
|
|
584
621
|
/** The members only the denied arm of a {@link GateDisposition} carries. */
|
|
585
|
-
declare const DENY_ONLY_MEMBERS: readonly ["deniedBy", "cause", "mode", "askClass", "classes", "extension"];
|
|
622
|
+
declare const DENY_ONLY_MEMBERS: readonly ["deniedBy", "cause", "mode", "askClass", "classes", "extension", "echoed"];
|
|
586
623
|
type DenyOnlyMember = Exclude<keyof Extract<GateDisposition, {
|
|
587
624
|
kind: "denied";
|
|
588
625
|
}>, keyof Extract<GateDisposition, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isAskClass, isAskOrigin, isModeReleaseReason, isPermissionMode, isPersistedRuleMandate, ASK_FACES, releasableAskClassesFor } from "./ask-origin.js";
|
|
2
2
|
import { isAutoModeFallbackCause } from "./auto-mode.js";
|
|
3
3
|
import { ALLOW_RULE_MEMBERS } from "./allow-rule-shadow.js";
|
|
4
|
+
import { refusalEchoDefects } from "./refusal-echo.js";
|
|
4
5
|
export const SETTLEMENT_KINDS = Object.freeze([
|
|
5
6
|
"human_allowed",
|
|
6
7
|
"human_refused",
|
|
@@ -141,6 +142,18 @@ export const DENIED_BY_MAY_NAME_EXTENSION = {
|
|
|
141
142
|
read_boundary: false,
|
|
142
143
|
mode: false,
|
|
143
144
|
};
|
|
145
|
+
export const DENIED_BY_MAY_ECHO = {
|
|
146
|
+
policy: false,
|
|
147
|
+
hook: false,
|
|
148
|
+
org: false,
|
|
149
|
+
persisted_rule: false,
|
|
150
|
+
classifier: false,
|
|
151
|
+
compliance: false,
|
|
152
|
+
write_protection: false,
|
|
153
|
+
ask_resolution: true,
|
|
154
|
+
read_boundary: true,
|
|
155
|
+
mode: false,
|
|
156
|
+
};
|
|
144
157
|
const retired = (word, retiredIn) => Object.freeze({ word, retiredIn });
|
|
145
158
|
export const RETIRED_MEMBERS = Object.freeze({
|
|
146
159
|
askClass: Object.freeze([retired("write_protection_unresolved", "7.49.0"), retired("governance_unavailable", "7.51.0")]),
|
|
@@ -211,7 +224,7 @@ function clearanceDefects(v, settled, released) {
|
|
|
211
224
|
}
|
|
212
225
|
return out;
|
|
213
226
|
}
|
|
214
|
-
const DENY_ONLY_MEMBERS = Object.freeze(["deniedBy", "cause", "mode", "askClass", "classes", "extension"]);
|
|
227
|
+
const DENY_ONLY_MEMBERS = Object.freeze(["deniedBy", "cause", "mode", "askClass", "classes", "extension", "echoed"]);
|
|
215
228
|
function objectOf(v) {
|
|
216
229
|
return typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
|
|
217
230
|
}
|
|
@@ -331,6 +344,12 @@ export function screenGateOutcome(g, opts) {
|
|
|
331
344
|
if (layer && !(isDeniedBy(denied.deniedBy) && DENIED_BY_MAY_NAME_EXTENSION[denied.deniedBy]))
|
|
332
345
|
defects.push(`I12: an extension cannot be named beside deniedBy "${String(denied.deniedBy)}"`);
|
|
333
346
|
}
|
|
347
|
+
if (denied.echoed !== undefined) {
|
|
348
|
+
for (const defect of refusalEchoDefects(denied.echoed))
|
|
349
|
+
defects.push(`I13: disposition.${defect}`);
|
|
350
|
+
if (layer && !(isDeniedBy(denied.deniedBy) && DENIED_BY_MAY_ECHO[denied.deniedBy]))
|
|
351
|
+
defects.push(`I13: quoted literals cannot be filed beside deniedBy "${String(denied.deniedBy)}"`);
|
|
352
|
+
}
|
|
334
353
|
if (denied.askClass !== undefined && !member("askClass", denied.askClass))
|
|
335
354
|
defects.push(outside("disposition.askClass", "askClass", denied.askClass));
|
|
336
355
|
if (denied.classes !== undefined && !classList(denied.classes))
|
|
@@ -23,9 +23,9 @@ export declare const GOVERNANCE_CODES: {
|
|
|
23
23
|
};
|
|
24
24
|
export type GovernanceCode = keyof typeof GOVERNANCE_CODES;
|
|
25
25
|
/**
|
|
26
|
-
* `memory.*` error codes DELIBERATELY outside governance:
|
|
27
|
-
*
|
|
28
|
-
* mechanical faults and
|
|
26
|
+
* `memory.*` error codes DELIBERATELY outside governance: engine incident codes (announce /
|
|
27
|
+
* partition incidents, tail truncation, consolidation outcomes) —
|
|
28
|
+
* mechanical faults and disclosures, not per-principal policy verdicts; they classify
|
|
29
29
|
* as `logic`. The gate test forces every `memory.*` literal minted in src/ to appear EITHER in
|
|
30
30
|
* {@link GOVERNANCE_CODES} or here — a new code gets NAMED and dispositioned, never silently
|
|
31
31
|
* classified.
|
|
@@ -145,7 +145,7 @@ export type NoticeAudience = "user" | "operator";
|
|
|
145
145
|
* the union's catalog ({@link EngineNotice.code}). The groups below say only which family a row joins,
|
|
146
146
|
* so the catalog is not written a second time here and the two cannot drift.
|
|
147
147
|
*/
|
|
148
|
-
export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "session.lineage_rerooted", "instructions.source_changed", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
|
|
148
|
+
export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "config.legacy_tool_name", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "delegation.delivery_discarded", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "session.lineage_rerooted", "instructions.source_changed", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
|
|
149
149
|
/** A catalogued code (see {@link ENGINE_NOTICE_CODES}); {@link NOTICE_MINTER} says who mints it. NOT the type of
|
|
150
150
|
* `EngineNotice.code`, which stays `string` — a host forwarding its own notices through the same
|
|
151
151
|
* sink is a supported shape, and narrowing that field would break it. */
|
|
@@ -198,6 +198,7 @@ declare const NOTICE_AUDIENCE_TABLE: {
|
|
|
198
198
|
readonly "permission.rule_store_unavailable": "user";
|
|
199
199
|
readonly "permission.rule_row_dropped": "user";
|
|
200
200
|
readonly "config.session_rules_earlier_grammar": "user";
|
|
201
|
+
readonly "config.legacy_tool_name": "user";
|
|
201
202
|
readonly "permission.allowed_tool_not_granted": "user";
|
|
202
203
|
readonly "mods.registration_refused": "user";
|
|
203
204
|
readonly "memory.capture_opted_out": "user";
|
|
@@ -239,6 +240,7 @@ declare const NOTICE_AUDIENCE_TABLE: {
|
|
|
239
240
|
readonly "peer.idle_subscription": "user";
|
|
240
241
|
readonly "delegation.transcript_integrity": "operator";
|
|
241
242
|
readonly "delegation.resume_lane_missing": "operator";
|
|
243
|
+
readonly "delegation.delivery_discarded": "operator";
|
|
242
244
|
readonly "checkpoint.execution_outcome_unrecorded": "operator";
|
|
243
245
|
readonly "mcp.injection_dropped": "user";
|
|
244
246
|
readonly "mcp.revocation_probe_failed": "operator";
|
|
@@ -344,6 +346,7 @@ declare const NOTICE_MINTER_TABLE: {
|
|
|
344
346
|
readonly "permission.rule_store_unavailable": "engine";
|
|
345
347
|
readonly "permission.rule_row_dropped": "engine";
|
|
346
348
|
readonly "config.session_rules_earlier_grammar": "engine";
|
|
349
|
+
readonly "config.legacy_tool_name": "engine";
|
|
347
350
|
readonly "permission.allowed_tool_not_granted": "engine";
|
|
348
351
|
readonly "mods.registration_refused": "engine";
|
|
349
352
|
readonly "peer.inbound_disposition": "engine";
|
|
@@ -359,6 +362,7 @@ declare const NOTICE_MINTER_TABLE: {
|
|
|
359
362
|
readonly "delegation.transcript_integrity": "engine";
|
|
360
363
|
readonly "delegation.ask_unresolvable": "engine";
|
|
361
364
|
readonly "delegation.resume_lane_missing": "engine";
|
|
365
|
+
readonly "delegation.delivery_discarded": "engine";
|
|
362
366
|
readonly "mcp.injection_dropped": "engine";
|
|
363
367
|
readonly "mcp.revocation_probe_failed": "engine";
|
|
364
368
|
readonly "mcp.server_redialed": "engine";
|
|
@@ -12,8 +12,6 @@ export const GOVERNANCE_CODES = {
|
|
|
12
12
|
"memory.capture_optout_denied": "terminal",
|
|
13
13
|
};
|
|
14
14
|
export const NON_GOVERNANCE_MEMORY_CODES = new Set([
|
|
15
|
-
"memory.secret_detected",
|
|
16
|
-
"memory.promotable_ungated",
|
|
17
15
|
"memory.announce_failed",
|
|
18
16
|
"memory.announcement_withheld",
|
|
19
17
|
"memory.partition_adopt_failed",
|
|
@@ -43,7 +41,6 @@ export const NON_GOVERNANCE_MEMORY_CODES = new Set([
|
|
|
43
41
|
"memory.consolidation_withheld",
|
|
44
42
|
"memory.restore_withheld",
|
|
45
43
|
"memory.project_scope_absent",
|
|
46
|
-
"memory.projection_failed",
|
|
47
44
|
"memory.observation_settlement_unavailable",
|
|
48
45
|
"memory.consolidation_disabled",
|
|
49
46
|
"memory.consolidation_gated",
|
|
@@ -62,6 +59,7 @@ export const NON_GOVERNANCE_MEMORY_CODES = new Set([
|
|
|
62
59
|
"memory.control_plane_not_corrupt",
|
|
63
60
|
"memory.control_plane_rebuild_unsupported",
|
|
64
61
|
"memory.governance_doc_unknown",
|
|
62
|
+
"memory.control_object_unknown",
|
|
65
63
|
"memory.erasure_evidence_unavailable",
|
|
66
64
|
"memory.erasure_selector_mismatch",
|
|
67
65
|
"memory.erasure_census_incomplete",
|
|
@@ -96,6 +94,7 @@ export const NON_GOVERNANCE_MEMORY_CODES = new Set([
|
|
|
96
94
|
"memory.capture_optout_sweep_failed",
|
|
97
95
|
"memory.target_outside_store",
|
|
98
96
|
"memory.scope_home_not_directory",
|
|
97
|
+
"memory.control_plane_links_unsupported",
|
|
99
98
|
"memory.root_anchor_backfilled",
|
|
100
99
|
"memory.root_reanchored",
|
|
101
100
|
]);
|
|
@@ -166,6 +165,7 @@ export const ENGINE_NOTICE_CODES = Object.freeze([
|
|
|
166
165
|
"permission.rule_store_unavailable",
|
|
167
166
|
"permission.rule_row_dropped",
|
|
168
167
|
"config.session_rules_earlier_grammar",
|
|
168
|
+
"config.legacy_tool_name",
|
|
169
169
|
"permission.allowed_tool_not_granted",
|
|
170
170
|
"mods.registration_refused",
|
|
171
171
|
"peer.inbound_disposition",
|
|
@@ -181,6 +181,7 @@ export const ENGINE_NOTICE_CODES = Object.freeze([
|
|
|
181
181
|
"delegation.transcript_integrity",
|
|
182
182
|
"delegation.ask_unresolvable",
|
|
183
183
|
"delegation.resume_lane_missing",
|
|
184
|
+
"delegation.delivery_discarded",
|
|
184
185
|
"mcp.injection_dropped",
|
|
185
186
|
"mcp.revocation_probe_failed",
|
|
186
187
|
"mcp.server_redialed",
|
|
@@ -281,6 +282,7 @@ const NOTICE_AUDIENCE_TABLE = {
|
|
|
281
282
|
"permission.rule_store_unavailable": "user",
|
|
282
283
|
"permission.rule_row_dropped": "user",
|
|
283
284
|
"config.session_rules_earlier_grammar": "user",
|
|
285
|
+
"config.legacy_tool_name": "user",
|
|
284
286
|
"permission.allowed_tool_not_granted": "user",
|
|
285
287
|
"mods.registration_refused": "user",
|
|
286
288
|
"memory.capture_opted_out": "user",
|
|
@@ -322,6 +324,7 @@ const NOTICE_AUDIENCE_TABLE = {
|
|
|
322
324
|
"peer.idle_subscription": "user",
|
|
323
325
|
"delegation.transcript_integrity": "operator",
|
|
324
326
|
"delegation.resume_lane_missing": "operator",
|
|
327
|
+
"delegation.delivery_discarded": "operator",
|
|
325
328
|
"checkpoint.execution_outcome_unrecorded": "operator",
|
|
326
329
|
"mcp.injection_dropped": "user",
|
|
327
330
|
"mcp.revocation_probe_failed": "operator",
|
|
@@ -408,6 +411,7 @@ const NOTICE_MINTER_TABLE = {
|
|
|
408
411
|
"permission.rule_store_unavailable": "engine",
|
|
409
412
|
"permission.rule_row_dropped": "engine",
|
|
410
413
|
"config.session_rules_earlier_grammar": "engine",
|
|
414
|
+
"config.legacy_tool_name": "engine",
|
|
411
415
|
"permission.allowed_tool_not_granted": "engine",
|
|
412
416
|
"mods.registration_refused": "engine",
|
|
413
417
|
"peer.inbound_disposition": "engine",
|
|
@@ -423,6 +427,7 @@ const NOTICE_MINTER_TABLE = {
|
|
|
423
427
|
"delegation.transcript_integrity": "engine",
|
|
424
428
|
"delegation.ask_unresolvable": "engine",
|
|
425
429
|
"delegation.resume_lane_missing": "engine",
|
|
430
|
+
"delegation.delivery_discarded": "engine",
|
|
426
431
|
"mcp.injection_dropped": "engine",
|
|
427
432
|
"mcp.revocation_probe_failed": "engine",
|
|
428
433
|
"mcp.server_redialed": "engine",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A leg's
|
|
2
|
+
* A leg's identity readings, as pure functions with no runtime imports — so a store's projection reads them exactly as
|
|
3
3
|
* the prepare mint and the stations do (one predicate each, never a second spelling at a reader that cannot reach the
|
|
4
4
|
* mods layer).
|
|
5
5
|
*/
|
|
6
6
|
import type { HookInvocationIdentity } from "./hooks.js";
|
|
7
|
+
import type { SessionAddress } from "./task-notification.js";
|
|
7
8
|
import type { AskSourceIdentity } from "./tool-policy.js";
|
|
8
9
|
/**
|
|
9
10
|
* The id a delegated leg's events carry as `agentId`: the leg's task id ({@link legTaskIdOf}) — for a background child, the
|
|
@@ -60,3 +61,36 @@ export interface AskSourceFacts {
|
|
|
60
61
|
* refusal texts speak the right posture (parent thread: stop and wait for the user; delegated child: adapt or report).
|
|
61
62
|
*/
|
|
62
63
|
export declare function mintAskSourceIdentity(leg: AskSourceFacts): AskSourceIdentity;
|
|
64
|
+
/** Where a leg's user-face notice is addressed: {@link noticeAddressOf}. Spread into the notice's detail as-is. */
|
|
65
|
+
export interface NoticeAddress {
|
|
66
|
+
/** The session the notice routes to (lifted onto the typed key at the one throat): the leg's own on a top-level leg, the
|
|
67
|
+
* delegation tree's root on a delegated one. */
|
|
68
|
+
readonly sessionId: string;
|
|
69
|
+
/** Present exactly on a delegated leg: the leg whose call the notice is about (its ask source's session). */
|
|
70
|
+
readonly sourceSessionId?: string;
|
|
71
|
+
/** Present on a delegated leg that carries one ({@link agentIdOf}): the agent id the leg's events and its spawner's card name. */
|
|
72
|
+
readonly agentId?: string;
|
|
73
|
+
}
|
|
74
|
+
/** Where a leg's user-face notice goes ({@link noticeAddressOf}): the keys it carries, and the session address it is for. */
|
|
75
|
+
export interface NoticeRoute {
|
|
76
|
+
/** The keys the notice carries — spread into its detail as-is. */
|
|
77
|
+
readonly address: NoticeAddress;
|
|
78
|
+
/** The session address a notice routed away from the leg's own session is for: on a delegated leg addressed to its tree's
|
|
79
|
+
* root, the root's id and the root occupant the tree was born under (absent = unknown). A delivery to it is judged like any
|
|
80
|
+
* frame addressed there (`PendingSessionNotifications.discardsStaleNotice`). Never spread into a notice: an occupant token
|
|
81
|
+
* is an addressing fact, not a word the wire carries. Absent when the notice goes to the leg's own session. */
|
|
82
|
+
readonly destination?: SessionAddress;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The address of a leg's user-face notice — one rule: a user-face notice goes to the end of the delegation tree a person
|
|
86
|
+
* watches, and says which leg it came from. A top-level leg's notice is addressed to its own session and carries no source
|
|
87
|
+
* keys. A delegated leg's notice is addressed to the tree's root session (`internals.rootSessionId`: an intermediate parent
|
|
88
|
+
* at depth ≥ 2 has no host leg of its own to read it on) and carries the delegated leg's session and agent id — the shape a
|
|
89
|
+
* subagent's permission denial takes upstream (the top-level session id plus the agent id). The root is a session address
|
|
90
|
+
* like every other destination: its id and its occupant (`internals.rootSessionIncarnation`), so a notice of a tree whose
|
|
91
|
+
* root was deleted and created again is not delivered to the root's later occupant.
|
|
92
|
+
*/
|
|
93
|
+
export declare function noticeAddressOf(askSource: AskSourceIdentity, root: {
|
|
94
|
+
readonly rootSessionId?: string;
|
|
95
|
+
readonly rootSessionIncarnation?: string;
|
|
96
|
+
} | undefined): NoticeRoute;
|
|
@@ -16,3 +16,13 @@ export function mintAskSourceIdentity(leg) {
|
|
|
16
16
|
...(leg.isDelegatedChild ? { isDelegatedChild: true } : {}),
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
+
export function noticeAddressOf(askSource, root) {
|
|
20
|
+
const own = askSource.sourceSessionId;
|
|
21
|
+
if (own === undefined || own.length === 0)
|
|
22
|
+
throw new TypeError("noticeAddressOf: the leg's ask source carries no session");
|
|
23
|
+
if (askSource.isDelegatedChild !== true)
|
|
24
|
+
return { address: { sessionId: own } };
|
|
25
|
+
const rootId = root?.rootSessionId !== undefined && root.rootSessionId.length > 0 ? root.rootSessionId : undefined;
|
|
26
|
+
const address = { sessionId: rootId ?? own, sourceSessionId: own, ...(askSource.agentId !== undefined ? { agentId: askSource.agentId } : {}) };
|
|
27
|
+
return rootId !== undefined && rootId !== own ? { address, destination: { sessionId: rootId, occupant: root?.rootSessionIncarnation } } : { address };
|
|
28
|
+
}
|