@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
|
@@ -271,6 +271,14 @@ export interface Prepared {
|
|
|
271
271
|
* the `Session` contract instead. */
|
|
272
272
|
session: StoredSession;
|
|
273
273
|
sessionId: string;
|
|
274
|
+
/** The occupant of the session row this leg acquired (`SessionMetadata.incarnation`, read once from {@link session} at
|
|
275
|
+
* prepare); absent = no token (a row written before occupants were minted, or that read failed). With {@link sessionId} it
|
|
276
|
+
* is the leg's session ADDRESS (`task-notification.ts` `SessionAddress`): what its notification lane parks under, drains
|
|
277
|
+
* and registers as. */
|
|
278
|
+
sessionIncarnation?: string;
|
|
279
|
+
/** `true` = that read threw: the leg names no occupant it knows, so the notification store takes it as no admission and drains
|
|
280
|
+
* it nothing (`SessionAddress.unread`); what is kept for the session waits for a leg that reads its occupant. */
|
|
281
|
+
sessionIncarnationUnread?: true;
|
|
274
282
|
/** This leg's task id, minted ONCE at prepare ({@link import("../leg-identity.js").legTaskIdOf}): its identity, frames, events'
|
|
275
283
|
* `sourceTaskId`, trace frames and `TaskResult.taskId` read it here; none re-spells it. */
|
|
276
284
|
taskId: string;
|
|
@@ -573,7 +581,7 @@ export interface Prepared {
|
|
|
573
581
|
/**
|
|
574
582
|
* This session's DURABLE box, present iff this leg mounted the session-box drain (a top-level leg
|
|
575
583
|
* over a cross-process-safe mailbox with a grammatical session id). The notification lane binds it
|
|
576
|
-
* to the park seat ({@link import("../task-notification.js").PendingSessionNotifications.
|
|
584
|
+
* to the park seat ({@link import("../task-notification.js").PendingSessionNotifications.admit})
|
|
577
585
|
* so a child's uplink frame parked for this session while it is idle lands in the box the next run
|
|
578
586
|
* drains — one mount judgment, the drain and the park read it alike. Absent ⇒ in-process parking.
|
|
579
587
|
*/
|
|
@@ -741,11 +749,11 @@ export interface Prepared {
|
|
|
741
749
|
* (they consult it at harvest time themselves — this accessor serves observers/tests).
|
|
742
750
|
*/
|
|
743
751
|
pollution: {
|
|
744
|
-
polluted: () => {
|
|
752
|
+
polluted: () => Promise<{
|
|
745
753
|
at: number;
|
|
746
754
|
reason: string;
|
|
747
755
|
cause?: import("../memory-engine/types.js").MemoryOriginCause;
|
|
748
|
-
} | undefined
|
|
756
|
+
} | undefined>;
|
|
749
757
|
/** `cause` is the structured mechanical fact the mark records (and the
|
|
750
758
|
* origin marker minted off it carries): `"observed"` for a witnessed external event,
|
|
751
759
|
* `"static"` for the capability over-approximation, `"derived"` for recall-taint. Absent
|
|
@@ -766,10 +774,9 @@ export interface Prepared {
|
|
|
766
774
|
* default): an `"off"` deployment keeps the pre-336 accepted-cost posture byte-level.
|
|
767
775
|
*/
|
|
768
776
|
settlement?: {
|
|
769
|
-
/** The WRITE plane's governance store (the settlement / lineage / challenge documents
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
controlDir: string;
|
|
777
|
+
/** The WRITE plane's governance store (the settlement / lineage / challenge documents and the pollution
|
|
778
|
+
* marker a settled delegation's effects reach). */
|
|
779
|
+
governance: import("../memory-engine/types.js").MemoryGovernanceStore;
|
|
773
780
|
sessionId: string;
|
|
774
781
|
provenance: "carry";
|
|
775
782
|
};
|
|
@@ -1051,6 +1058,10 @@ export interface Prepared {
|
|
|
1051
1058
|
lastSentRequest: () => CompactionForkContext | undefined;
|
|
1052
1059
|
/** The leg's advisor-instructions seat (advisor-instructions.ts); absent when the leg neither mounts the advisor nor has told the model of it. */
|
|
1053
1060
|
advisorInstruction?: import("./advisor-instructions.js").AdvisorInstructionSeat;
|
|
1061
|
+
/** #1123 — the memory notices this prepare drained (whole engine reminders, model lane only, no echo): the leg's first
|
|
1062
|
+
* request carries them once, ahead of the user's message — a fresh leg's first user message, a resumed leg's
|
|
1063
|
+
* continuation. Never the system prompt (an event there breaks the cached prefix twice). Absent when nothing drained. */
|
|
1064
|
+
memoryNoticesFrame?: string;
|
|
1054
1065
|
/** The post-compaction restore (`MaybeCompactOptions.workingFileAttachments.restore`): re-reads the candidates through
|
|
1055
1066
|
* the leg's one file reader under the run's synthetic-Read judge — the user attachment's own path read — deduplicated
|
|
1056
1067
|
* against the read state the summary leaves, and mints their attachment frames (`readCompactionRestore`); a file it
|
|
@@ -2063,6 +2074,13 @@ export interface RunInternals {
|
|
|
2063
2074
|
* after a restart those intermediate sessions are dead ends, and a recovery face enumerating
|
|
2064
2075
|
* "everything under this host session" needs the root anchor, not an alias walk. */
|
|
2065
2076
|
rootSessionId?: string;
|
|
2077
|
+
/** The occupant of {@link rootSessionId}'s row (`SessionMetadata.incarnation`) as the tree's root run acquired it — the
|
|
2078
|
+
* other half of the root anchor's ADDRESS, carried beside it by the same fixed point (the spawner passes its own
|
|
2079
|
+
* `ctx.rootSessionIncarnation`; a background spawn persists it on its row, `BackgroundAgentRecord.rootSessionIncarnation`, and a
|
|
2080
|
+
* revival reads it back with the anchor). Absent = unknown: a revival of a row that recorded none and a row written before
|
|
2081
|
+
* occupants were minted; a frame the notification lane escalates to the root anchor is then addressed
|
|
2082
|
+
* to an unknown occupant, which a root holding a token is not. TRUSTED run-scoped channel (never a TaskSpec field). */
|
|
2083
|
+
rootSessionIncarnation?: string;
|
|
2066
2084
|
/** The delegation tree's owner seat ({@link import("./delegation-owner.js").DelegationOwnerSeat}): a fixed point like
|
|
2067
2085
|
* {@link rootSessionId} — the spawning run hands its own seat down by reference (the delegation and workflow lanes), so the tree
|
|
2068
2086
|
* reads its root row's owner once. Absent ⇒ this run is nobody's child here (a top-level run, a revival, a resumed park) and its
|
|
@@ -2991,7 +3009,7 @@ export interface RunnerSelfSeat {
|
|
|
2991
3009
|
*/
|
|
2992
3010
|
export type PrepareTaskFn = (spec: TaskSpec, deps: RunnerDeps, sessions: SessionStore, resume?: PrepareResume, internals?: RunInternals, runnerSelf?: RunnerSelfSeat, runIdSink?: {
|
|
2993
3011
|
runId?: string;
|
|
2994
|
-
}, holdSessionLock?: (sessionId: string) => Promise<void>, legWrites?: LegWrites) => Promise<Prepared>;
|
|
3012
|
+
}, holdSessionLock?: (sessionId: string) => Promise<void>, legWrites?: LegWrites, noticeDestinations?: import("../task-notification.js").NoticeDestinationJudge) => Promise<Prepared>;
|
|
2995
3013
|
/** One leg's view of the Runner's session write ledger (`session-write-ledger.ts`): `issue` starts a write of the leg (`what` = the
|
|
2996
3014
|
* entry type, for a report) or refuses it once `close` ran — the leg's hold ended; a write still in flight is reported when it settles. */
|
|
2997
3015
|
export interface LegWrites {
|
|
@@ -3095,7 +3113,8 @@ export type EndOfTaskCompaction = {
|
|
|
3095
3113
|
*/
|
|
3096
3114
|
export interface NotificationLaneBindings {
|
|
3097
3115
|
harness: AgentHarness | undefined;
|
|
3098
|
-
|
|
3116
|
+
/** The leg's session address (its session id and the occupant it acquired), bound by the identity lane once prepared. */
|
|
3117
|
+
address: import("../task-notification.js").SessionAddress | undefined;
|
|
3099
3118
|
ident: () => {
|
|
3100
3119
|
eventId?: string;
|
|
3101
3120
|
parentToolCallId?: string;
|
|
@@ -24,9 +24,8 @@ export interface DelegationOwnerSeat {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* The seat of a run nobody spawned: the owner of the row it acquired, read by id through its own store's {@link SessionStore.headOf}
|
|
27
|
-
* and taken only while the row's occupant is the one acquired
|
|
28
|
-
*
|
|
29
|
-
* the reading is `null`.
|
|
27
|
+
* and taken only while the row's occupant is the one acquired ({@link sameOccupant} of the head's `incarnation` and the acquired
|
|
28
|
+
* session's metadata's). A store without a by-id read has no owner to read: the reading is `null`.
|
|
30
29
|
*/
|
|
31
30
|
export declare function ownRowDelegationOwner(sessions: Pick<SessionStore, "headOf">, sessionId: string, acquiredIncarnation: () => Promise<string | undefined>): DelegationOwnerSeat;
|
|
32
31
|
/** The refusal of a delegation whose tree owner does not bind ({@link DelegationOwnerReading}): the child is not started and no row is
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sameOccupant } from "../../engine/session/repo-utils.js";
|
|
1
2
|
function ownerCellReading(sessionId, head) {
|
|
2
3
|
const owner = head.owner;
|
|
3
4
|
if (owner === null || typeof owner === "string")
|
|
@@ -14,7 +15,7 @@ export function ownRowDelegationOwner(sessions, sessionId, acquiredIncarnation)
|
|
|
14
15
|
const [head, acquired] = await Promise.all([headOf.call(sessions, sessionId), acquiredIncarnation()]);
|
|
15
16
|
if (head === undefined)
|
|
16
17
|
return { bound: false, reason: `the session ${sessionId} this run acquired has no row any more` };
|
|
17
|
-
if (head.incarnation
|
|
18
|
+
if (!sameOccupant(head.incarnation, acquired))
|
|
18
19
|
return { bound: false, reason: `the session ${sessionId} this run acquired now holds another occupant` };
|
|
19
20
|
return ownerCellReading(sessionId, head);
|
|
20
21
|
};
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* the reminder envelope and the text helpers. Its `import type` edges up to `hooks.ts` name the gate's public
|
|
22
22
|
* contract (`ToolGateInput`, `ToolGateResult`, the observer payload), which stays declared there.
|
|
23
23
|
*/
|
|
24
|
+
import type { RefusalEcho } from "../refusal-echo.js";
|
|
24
25
|
import { type ClassifierDenyCause, type DeniedBy, type GateOutcome, type ModeRefusal, type ModeRelease, type Settlement } from "../gate-outcome.js";
|
|
25
26
|
import type { AllowRuleClearance } from "../allow-rule-shadow.js";
|
|
26
27
|
import type { AutoModeClassifierRound } from "../auto-mode.js";
|
|
@@ -58,6 +59,8 @@ export interface GateExitFacts {
|
|
|
58
59
|
/** The registration whose handler ended the call at the hook layer (its deny answer or its failure) — only beside `deniedBy: "hook"`.
|
|
59
60
|
* As the bus names it: the engine's own origin word is read as no extension at the mint, once. */
|
|
60
61
|
extension?: string;
|
|
62
|
+
/** The literals the refusal's sentence quotes, minted with it — only beside a layer word {@link DENIED_BY_MAY_ECHO} admits. */
|
|
63
|
+
echoed?: readonly RefusalEcho[];
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
63
66
|
* Mint the outcome. A defect here is an ENGINE defect (a refusing site that did not say who refused, a
|
|
@@ -344,6 +347,9 @@ export interface GatePass {
|
|
|
344
347
|
* beside `deniedBy` by that station alone; the exit puts it on the gate result for the loop's error result.
|
|
345
348
|
* OPTIONAL (the `probeUnanswered` form): the dispatch that builds the pass has nothing to declare here. */
|
|
346
349
|
denyDetails?: unknown;
|
|
350
|
+
/** borrowed-mutable — the literals the shell read station's deny sentence quotes, written beside `deniedBy: "read_boundary"` by
|
|
351
|
+
* the sites that apply a refusing verdict; the exit mints `GateDisposition.echoed` from it ({@link DENIED_BY_MAY_ECHO}). */
|
|
352
|
+
denyEchoed?: readonly RefusalEcho[];
|
|
347
353
|
/** borrowed-mutable — the shell read station's containment card behind a standing MANDATED ask (an out-of-root
|
|
348
354
|
* or unestablishable read): when that ask ends as a refusal (a person's no, nobody to ask), the exit puts the
|
|
349
355
|
* card on the gate result, so the refusal's `tool_end` still says WHAT was found (`readonly_out_of_root`) beside
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { screenGateOutcome, SETTLEMENT_IS_REFUSAL } from "../gate-outcome.js";
|
|
1
|
+
import { DENIED_BY_MAY_ECHO, screenGateOutcome, SETTLEMENT_IS_REFUSAL } from "../gate-outcome.js";
|
|
2
2
|
import { askFaceOf, classifyAsk, headlessApprovalRemedy } from "../ask-origin.js";
|
|
3
3
|
import { wireOf } from "../tool-name-readings.js";
|
|
4
4
|
import { isProtectedWrite } from "../tool-registry.js";
|
|
5
5
|
import { attestationOf, decisionText, foldHookAsk, licenseCovers } from "../tool-policy.js";
|
|
6
|
+
import { engineSentenceOf } from "../engine-attestation.js";
|
|
6
7
|
import { pathDenialCardOf } from "../../tools/fs/safety.js";
|
|
7
8
|
import { argsAsTheToolReads } from "../effective-path-target.js";
|
|
8
9
|
import { rewriteRecordOf } from "../rewrite-rejudge.js";
|
|
@@ -24,6 +25,7 @@ export function mintGateOutcome(facts) {
|
|
|
24
25
|
deniedBy: facts.deniedBy,
|
|
25
26
|
...(facts.cause !== undefined ? { cause: facts.cause } : {}),
|
|
26
27
|
...(extension !== undefined ? { extension } : {}),
|
|
28
|
+
...(facts.echoed !== undefined ? { echoed: Object.freeze(facts.echoed.map((e) => Object.freeze({ ...e }))) } : {}),
|
|
27
29
|
...(attribution !== undefined ? { classifier: attribution } : {}),
|
|
28
30
|
...(facts.modeRefusal !== undefined ? { mode: facts.modeRefusal.mode, askClass: facts.modeRefusal.askClass, classes: Object.freeze([...facts.modeRefusal.classes]) } : {}),
|
|
29
31
|
}
|
|
@@ -277,6 +279,12 @@ function unresolvableCauseOfSettlement(gate) {
|
|
|
277
279
|
return "no_approver_wired";
|
|
278
280
|
return undefined;
|
|
279
281
|
}
|
|
282
|
+
function refusalEchoOf(pass, call) {
|
|
283
|
+
const by = pass.deniedBy;
|
|
284
|
+
if (by === undefined || !DENIED_BY_MAY_ECHO[by])
|
|
285
|
+
return undefined;
|
|
286
|
+
return by === "read_boundary" ? pass.denyEchoed : by === "ask_resolution" ? engineSentenceOf(pass.decision, call)?.echoed : undefined;
|
|
287
|
+
}
|
|
280
288
|
export async function exitGate(pass) {
|
|
281
289
|
const { input, toolName, toolCallId, ledger, notifyPermissionDenied } = pass;
|
|
282
290
|
if (pass.decision.action === "deny") {
|
|
@@ -291,7 +299,8 @@ export async function exitGate(pass) {
|
|
|
291
299
|
pass.deniedBy = "mode";
|
|
292
300
|
ledger.supersede();
|
|
293
301
|
}
|
|
294
|
-
const
|
|
302
|
+
const echoed = refusalEchoOf(pass, { toolCallId, toolName });
|
|
303
|
+
const gate = mintGateOutcome({ deniedBy: pass.deniedBy, ...(pass.deniedBy === "hook" && pass.deniedExtension !== undefined ? { extension: pass.deniedExtension } : {}), ...(echoed !== undefined ? { echoed } : {}), ...(pass.denyCause !== undefined ? { cause: pass.denyCause } : {}), ...(ledger.settled !== undefined ? { settled: ledger.settled } : {}), ...(pass.classifierRound !== undefined ? { classifier: pass.classifierRound } : {}), ...(modeRefusal !== undefined ? { modeRefusal: { mode: modeRefusal.mode, askClass: modeRefusal.askClass, classes: modeRefusal.classes } } : {}) });
|
|
295
304
|
const foldCause = attestationOf(pass.decision, { toolCallId, toolName })?.unresolvableCause;
|
|
296
305
|
const unresolvable = foldCause ?? unresolvableCauseOfSettlement(gate);
|
|
297
306
|
const tableSeat = unresolvable !== undefined ? askUnresolvableRemedySeat(unresolvable) : undefined;
|
|
@@ -40,6 +40,8 @@ export interface MemoryConsolidationDriverDeps {
|
|
|
40
40
|
/** Optional per-model auth hook (the TaskSpec-shaped seat) for the role-resolved path. */
|
|
41
41
|
getApiKeyAndHeaders?: TaskSpec["getApiKeyAndHeaders"];
|
|
42
42
|
}
|
|
43
|
+
/** What the seat's reading takes of the deployment: the model catalog, tier bindings and role map — no brain. */
|
|
44
|
+
export type ConsolidationSeatDeps = Omit<MemoryConsolidationDriverDeps, "brain">;
|
|
43
45
|
/**
|
|
44
46
|
* Resolve a deployment's driver options: `{ chat, model }` from the explicit seat or the role
|
|
45
47
|
* chain, plus the deployment knobs (contract / maxCycles / mintRepairBudget) and the protocol
|
|
@@ -56,7 +58,7 @@ export declare function resolveMemoryConsolidationDriver(deps: MemoryConsolidati
|
|
|
56
58
|
* DIFFERENT bad value, caught loudly by the driver's own screen when it runs). False ⇔ the resolve
|
|
57
59
|
* verb would throw its "no model seat" refusal. Pinned against that resolve for drift.
|
|
58
60
|
*/
|
|
59
|
-
export declare function consolidationSeatResolvable(deps:
|
|
61
|
+
export declare function consolidationSeatResolvable(deps: ConsolidationSeatDeps): boolean;
|
|
60
62
|
/**
|
|
61
63
|
* The advisory-to-execution bridge: fire ONE host consolidation run for the
|
|
62
64
|
* recommended `scope`, fire-and-forget. Called from the post-task settle tail (NOT the harvest tail)
|
|
@@ -122,6 +124,6 @@ export declare function scopeHasUnconsumedRecommendation(engine: Pick<Consolidat
|
|
|
122
124
|
* invisible-failure family) cannot ship: a deployment learns at boot, not one silently dropped
|
|
123
125
|
* recommendation later. Lives beside {@link consolidationSeatResolvable}, the one question it asks.
|
|
124
126
|
*/
|
|
125
|
-
export declare function assertAutoConsolidationWirable(deps:
|
|
127
|
+
export declare function assertAutoConsolidationWirable(deps: ConsolidationSeatDeps & {
|
|
126
128
|
autoRunOnRecommendation?: unknown;
|
|
127
129
|
}): void;
|
|
@@ -5,6 +5,10 @@ import { runMemoryConsolidationDriver } from "../memory-engine/consolidation-dri
|
|
|
5
5
|
import { recommendationUnconsumed } from "../memory-engine/consolidation.js";
|
|
6
6
|
import { deliverWriteRefusal } from "./memory-consolidation-write-judge.js";
|
|
7
7
|
import { asThrownError } from "../thrown-value.js";
|
|
8
|
+
const CONSOLIDATION_CHAIN = ["consolidate", "summarize"];
|
|
9
|
+
function consolidationRoleModel(models, roles) {
|
|
10
|
+
return roleModelIfSet(CONSOLIDATION_CHAIN[0], {}, { models, roles }) ?? roleModelIfSet(CONSOLIDATION_CHAIN[1], {}, { models, roles });
|
|
11
|
+
}
|
|
8
12
|
function seatRefusal(message) {
|
|
9
13
|
const e = new Error(message);
|
|
10
14
|
e.code = "config.memory_consolidation_driver";
|
|
@@ -27,9 +31,9 @@ export function resolveMemoryConsolidationDriver(deps) {
|
|
|
27
31
|
}
|
|
28
32
|
else {
|
|
29
33
|
const models = catalogOfDeps(deps);
|
|
30
|
-
const resolved =
|
|
34
|
+
const resolved = consolidationRoleModel(models, deps.roles);
|
|
31
35
|
if (resolved === undefined) {
|
|
32
|
-
throw unheldChainRefusal(
|
|
36
|
+
throw unheldChainRefusal(CONSOLIDATION_CHAIN, models, deps.roles) ?? seatRefusal('memory consolidation has no model seat: configure RunnerDeps.memoryConsolidationDriver.chat (an endpoint triple or a chat function), or declare roles.consolidate / roles.summarize (a tier-expanded catalog\'s "flash" binding also satisfies the summarize hop). The chain deliberately does NOT fall back to the default main model — a whole-library distillation must not silently ride the most expensive seat.');
|
|
33
37
|
}
|
|
34
38
|
if (isAliasModelId(resolved.id)) {
|
|
35
39
|
throw seatRefusal(`the resolved consolidation model id ${JSON.stringify(resolved.id)} is an alias spelling — an alias can be re-pointed upstream and would move the run with no trace in the archive; bind an explicit id.`);
|
|
@@ -65,8 +69,7 @@ export function resolveMemoryConsolidationDriver(deps) {
|
|
|
65
69
|
export function consolidationSeatResolvable(deps) {
|
|
66
70
|
if (deps.memoryConsolidationDriver?.chat !== undefined)
|
|
67
71
|
return true;
|
|
68
|
-
|
|
69
|
-
return (roleModelIfSet("consolidate", {}, { models, roles: deps.roles }) ?? roleModelIfSet("summarize", {}, { models, roles: deps.roles })) !== undefined;
|
|
72
|
+
return consolidationRoleModel(catalogOfDeps(deps), deps.roles) !== undefined;
|
|
70
73
|
}
|
|
71
74
|
export function autoRunConsolidationFromRecommendation(args) {
|
|
72
75
|
const { deps, engine, scope, sessionId, writeJudge, compliance, onNotice, onError } = args;
|
|
@@ -116,6 +119,6 @@ export function assertAutoConsolidationWirable(deps) {
|
|
|
116
119
|
throw autoRunRefusal("RunnerDeps.autoRunOnRecommendation is true but RunnerDeps.memoryConsolidation is absent — the recommendation that would trigger a run is never minted (consolidation is OFF) and the engine's verbs refuse coded, so the trigger can never fire. An armed-but-unrunnable trigger is refused, never folded to off: wire memoryConsolidation, or leave autoRunOnRecommendation unset.");
|
|
117
120
|
}
|
|
118
121
|
if (!consolidationSeatResolvable(deps)) {
|
|
119
|
-
throw unheldChainRefusal(
|
|
122
|
+
throw unheldChainRefusal(CONSOLIDATION_CHAIN, catalogOfDeps(deps), deps.roles) ?? autoRunRefusal("RunnerDeps.autoRunOnRecommendation is true but no consolidation model seat resolves — configure RunnerDeps.memoryConsolidationDriver.chat (an endpoint triple or a chat function), or declare roles.consolidate / roles.summarize. Arming auto-run with no model to run it is refused, never folded to off (a whole-library distillation must not silently ride the default main model).");
|
|
120
123
|
}
|
|
121
124
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cardDisclosureOf } from "../allow-entry.js";
|
|
2
2
|
import { primaryActivityArg } from "../arg-summary.js";
|
|
3
3
|
import { classicEventBase, observeClassic } from "../mods/stations.js";
|
|
4
|
-
import { advertisedWritableRootsSeat, exemptRootsSeat, attest, attestationOf, isLiveApproverSeat,
|
|
4
|
+
import { advertisedWritableRootsSeat, exemptRootsSeat, attest, attestationOf, isLiveApproverSeat, resolveAskFor } from "../tool-policy.js";
|
|
5
5
|
import { exactBoundInputHashOf } from "../canonical-json.js";
|
|
6
6
|
import { composeCallSignal, raceSettlementAgainstSignal } from "./abort-race.js";
|
|
7
7
|
import { failedJudgmentDeny, policyCheckAbortedDeny } from "./policy-throw.js";
|
|
@@ -95,7 +95,7 @@ export function prepareAskLane(input) {
|
|
|
95
95
|
if (grantReuse !== undefined)
|
|
96
96
|
return grantReuse;
|
|
97
97
|
const t0 = now();
|
|
98
|
-
const resolved = await
|
|
98
|
+
const resolved = await resolveAskFor({
|
|
99
99
|
toolName: req.toolName,
|
|
100
100
|
toolCallId: req.toolCallId,
|
|
101
101
|
args: req.args,
|
|
@@ -117,7 +117,7 @@ export function prepareAskLane(input) {
|
|
|
117
117
|
...(decision.action === "ask" && decision.probeCause !== undefined ? { probeCause: decision.probeCause } : {}),
|
|
118
118
|
...(decision.action === "ask" && decision.probeReadRootCandidate !== undefined ? { readRootCandidate: decision.probeReadRootCandidate } : {}),
|
|
119
119
|
...(decision.action === "ask" && decision.ruleEvidence !== undefined ? { ruleEvidence: decision.ruleEvidence } : {}),
|
|
120
|
-
}, onAsk, composedCallSignal(callSignal), lateAskSettlementObserver({ toolName: req.toolName, toolCallId: req.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError }));
|
|
120
|
+
}, onAsk, composedCallSignal(callSignal), lateAskSettlementObserver({ toolName: req.toolName, toolCallId: req.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError }), decision);
|
|
121
121
|
const waitMs = Math.max(0, now() - t0);
|
|
122
122
|
const granting = settleReadRootGrant(resolved.readRootGrant, grantReadRoot, { toolName: req.toolName, toolCallId: req.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, signal: composedCallSignal(callSignal) });
|
|
123
123
|
if (granting !== undefined)
|
|
@@ -57,7 +57,7 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
57
57
|
/** borrowed-readonly — the trusted spawn-side channel; the Workflow mount forwards `rootSessionId`, `placementRoot`,
|
|
58
58
|
* `onTaskNotification`, `workflowDepth`, the capture-floor getter reads `memoryCaptureAncestors`, and the arming reads
|
|
59
59
|
* the chain's auto-mode face (`inheritedGate.autoModeFace`). */
|
|
60
|
-
internals: Pick<RunInternals, "rootSessionId" | "placementRoot" | "onTaskNotification" | "workflowDepth" | "memoryCaptureAncestors" | "workflowParkedResume" | "holder" | "questionFaceStripped" | "inheritedGate"> | undefined;
|
|
60
|
+
internals: Pick<RunInternals, "rootSessionId" | "rootSessionIncarnation" | "placementRoot" | "onTaskNotification" | "workflowDepth" | "memoryCaptureAncestors" | "workflowParkedResume" | "holder" | "questionFaceStripped" | "inheritedGate"> | undefined;
|
|
61
61
|
/** borrowed-readonly — the tree's cross-boundary token (inherited or minted), which the Workflow mount hands to its children. */ crossBoundaryTree: import("../cross-boundary-taint.js").CrossBoundaryTreeToken;
|
|
62
62
|
/** borrowed-readonly — the tree's owner seat, which the Workflow mount hands to its children (by reference). */ delegationOwner: import("./delegation-owner.js").DelegationOwnerSeat;
|
|
63
63
|
/** borrowed-readonly — the acquired session; the classifier leg rebuilds its transcript window from `buildContext`. */
|
|
@@ -147,6 +147,8 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
147
147
|
runnerSelf: RunnerSelfSeat | undefined;
|
|
148
148
|
/** borrowed-readonly — LATE-BOUND: the memory-engine session; the Workflow mount's capture-floor getter reads it at ITS call time. */
|
|
149
149
|
memoryEngineSession: () => Prepared["memoryEngineSession"];
|
|
150
|
+
/** borrowed-readonly — LATE-BOUND: this leg's occupant (the lineage read assigns it); the Workflow mount's root-occupant seat reads it at ITS call time. */
|
|
151
|
+
sessionIncarnation: () => string | undefined;
|
|
150
152
|
/** borrowed-readonly — LATE-BOUND: the adopted center artifact; the Workflow mount's two center getters read it at THEIR call time. */
|
|
151
153
|
centerAdoption: () => {
|
|
152
154
|
artifact: PromptArtifact;
|
|
@@ -331,7 +331,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
331
331
|
scope: taskScope,
|
|
332
332
|
notifier: deps.workflowCompletionNotifier,
|
|
333
333
|
originatingSessionId: sessionId,
|
|
334
|
-
rootSessionId: internals?.rootSessionId ?? sessionId, ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}), crossBoundaryTree: input.crossBoundaryTree, delegationOwner: input.delegationOwner,
|
|
334
|
+
rootSessionId: internals?.rootSessionId ?? sessionId, rootSessionIncarnation: () => (internals?.rootSessionId !== undefined ? internals.rootSessionIncarnation : input.sessionIncarnation()), ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}), crossBoundaryTree: input.crossBoundaryTree, delegationOwner: input.delegationOwner,
|
|
335
335
|
taskRegistry: defaultTaskRegistry,
|
|
336
336
|
taskNotification: internals?.onTaskNotification, ...(taskArtifacts !== undefined ? { taskArtifacts } : {}),
|
|
337
337
|
taskOwner: hostTaskId,
|
|
@@ -359,7 +359,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
359
359
|
...(resolvedInteractionPosture !== undefined ? { parentInteractionPosture: resolvedInteractionPosture } : {}),
|
|
360
360
|
parentMemoryCaptureState: () => {
|
|
361
361
|
const memoryEngineSession = input.memoryEngineSession();
|
|
362
|
-
const ctl = memoryEngineSession?.engine.
|
|
362
|
+
const ctl = memoryEngineSession?.engine.controlPlaneRoot;
|
|
363
363
|
const co = memoryEngineSession?.captureOptOut;
|
|
364
364
|
return assembleParentCaptureState(co?.optedOut() ?? false, co?.indeterminate() ?? false, ctl, [...(internals?.memoryCaptureAncestors ?? []), { sessionId, ...(ctl !== undefined ? { controlDir: ctl } : {}) }]);
|
|
365
365
|
},
|
|
@@ -21,6 +21,7 @@ import { assertRetentionWords } from "../retention.js";
|
|
|
21
21
|
import { resolveModel, resolveTaskModel, roleModelIfSet, screenRoleMap } from "../roles.js";
|
|
22
22
|
import { resolveSkillListingBudget } from "../skill-listing-budget.js";
|
|
23
23
|
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
24
|
+
import { compactionSeatsDefect } from "../context-settings.js";
|
|
24
25
|
import { assertAdvisorModelShape } from "../advisor-verdict.js";
|
|
25
26
|
import { applyToolModelGate, assertRestoreGatedToolsValue } from "../tool-model-gate.js";
|
|
26
27
|
import { resolveUsageWindows } from "../usage-window-store.js";
|
|
@@ -286,6 +287,9 @@ export function configValueDoors(input, enter = ENTER_AS_IS) {
|
|
|
286
287
|
});
|
|
287
288
|
if (spec.classifyAllShell !== undefined && typeof spec.classifyAllShell !== "boolean")
|
|
288
289
|
enter("taskConfig", () => { throw limitConfigError("config.invalid_argument", `TaskSpec.classifyAllShell must be a boolean when present (got ${describeRejectedValue(spec.classifyAllShell)}) — true lets no shell allow entry clear a call in auto mode; omit the key for the default.`); });
|
|
290
|
+
const compactionSeats = typeof spec.compaction === "object" && spec.compaction !== null ? compactionSeatsDefect(spec.compaction, "TaskSpec.compaction") : undefined;
|
|
291
|
+
if (compactionSeats !== undefined)
|
|
292
|
+
enter("taskConfig", () => { throw limitConfigError(compactionSeats.kind === "retired" ? "config.spec_retired_key" : "config.invalid_argument", compactionSeats.sentence); });
|
|
289
293
|
if (spec.toolMaterializeStrategy === "static" && spec.deferSelfResolve === false)
|
|
290
294
|
enter("taskConfig", () => {
|
|
291
295
|
const e = new Error(`toolMaterializeStrategy "static" cannot be combined with deferSelfResolve: false — with the direct-call ` +
|
|
@@ -43,6 +43,9 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
43
43
|
resume: Pick<PrepareResume, "seed"> | undefined;
|
|
44
44
|
/** borrowed-readonly — the acquired session id (the mounts' session axis). */
|
|
45
45
|
sessionId: string;
|
|
46
|
+
/** borrowed-readonly — the leg's own session address (`sessionAddressOf`: the id and the occupant its acquire read): the peer seats
|
|
47
|
+
* name it as the sender's own, so what comes back is for this occupant. */
|
|
48
|
+
sessionAddress: import("../task-notification.js").SessionAddress;
|
|
46
49
|
/** borrowed-readonly — the per-task identity (the mounts' owner axis). */
|
|
47
50
|
hostTaskId: string;
|
|
48
51
|
/** borrowed-readonly — the registry scope the mounts register in. */
|
|
@@ -13,7 +13,7 @@ import { deliverEngineNotice } from "../types.js";
|
|
|
13
13
|
import { RosterBuilder } from "../tool-roster.js";
|
|
14
14
|
import { sendMessageContinuationSeats } from "./send-message-continuation.js";
|
|
15
15
|
export function prepareDelegationSurface(input) {
|
|
16
|
-
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, taskArtifacts, subagentRetain, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat } = input;
|
|
16
|
+
const { spec, deps, internals, resume, sessionId, sessionAddress, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, taskArtifacts, subagentRetain, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat } = input;
|
|
17
17
|
let worktreeSessionRef;
|
|
18
18
|
const delegationSurfaceActive = backgroundTaskToolsActive || workflowToolsActive;
|
|
19
19
|
const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
|
|
@@ -55,7 +55,7 @@ export function prepareDelegationSurface(input) {
|
|
|
55
55
|
...(deps.backgroundAgentStore !== undefined ? { agentStore: deps.backgroundAgentStore } : {}),
|
|
56
56
|
...(deps.mailboxStore !== undefined ? { mailbox: deps.mailboxStore } : {}),
|
|
57
57
|
...(reviveSpawn !== undefined ? { reviveSpawn } : {}),
|
|
58
|
-
...(peerLaneActive ? peerLaneSendMessageSeats({ peerDirectory: deps.peerDirectory, ...(deps.peerChannel !== undefined ? { peerChannel: deps.peerChannel } : {}),
|
|
58
|
+
...(peerLaneActive ? peerLaneSendMessageSeats({ peerDirectory: deps.peerDirectory, ...(deps.peerChannel !== undefined ? { peerChannel: deps.peerChannel } : {}), address: sessionAddress, scope: taskScope, ...(internals?.explicitAgentName !== undefined ? { name: internals.explicitAgentName } : {}), refs: peerLaneRefs, listingMounted: listAgentsMountable({ leaves, specTools: spec.tools ?? [] }) }) : {}),
|
|
59
59
|
onNotifyError: (f) => emitTrace(deps.tracer, () => ({ kind: "observer.notify_failed", version: 1, taskId: hostTaskId, site: f.site, message: f.error.message, ts: Date.now() })),
|
|
60
60
|
onTranscriptIntegrityGap: (handle, scope) => deliverEngineNotice(deps.onNotice, {
|
|
61
61
|
code: "delegation.transcript_integrity",
|
|
@@ -35,6 +35,8 @@ import { type HookEnvCapabilities, type HookInvocationIdentity } from "../hooks.
|
|
|
35
35
|
import type { ToolPolicy } from "../tool-policy.js";
|
|
36
36
|
import { type GateOutcome } from "../gate-outcome.js";
|
|
37
37
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
38
|
+
import type { NoticeRoute } from "../leg-identity.js";
|
|
39
|
+
import type { NoticeDestinationJudge } from "../task-notification.js";
|
|
38
40
|
import { type WiringManifest } from "../wiring-manifest.js";
|
|
39
41
|
import type { WriteProtectionCheck } from "../write-protect.js";
|
|
40
42
|
import type { ShellReadCheck } from "../../tools/fs/shell-read-check.js";
|
|
@@ -152,6 +154,12 @@ export interface PrepareGateStationsInput {
|
|
|
152
154
|
hostTaskId: string;
|
|
153
155
|
/** borrowed-readonly — the acquired session id (the settlement defects' error tag). */
|
|
154
156
|
sessionId: string;
|
|
157
|
+
/** borrowed-readonly — where this station's user-face notices go (`noticeAddressOf`, minted once per leg beside the ask
|
|
158
|
+
* source): the leg's own session on a top-level leg; the delegation tree's root, naming this leg, on a delegated one — every
|
|
159
|
+
* notice below spreads its `address` in place of the bare session id, and is delivered under {@link legNoticeAdmission}. */
|
|
160
|
+
noticeRoute: NoticeRoute;
|
|
161
|
+
/** borrowed-readonly — the Runner's judge of a notice routed to the tree's root (absent outside a Runner). */
|
|
162
|
+
noticeDestinations: NoticeDestinationJudge | undefined;
|
|
155
163
|
/** borrowed-readonly — the hand's live tracked cwd, or undefined; `current` is read per screening / per post seat. Not
|
|
156
164
|
* written here. */
|
|
157
165
|
handsCwdRef: CwdRef | undefined;
|
|
@@ -49,8 +49,16 @@ export function maybeHumanRejectionHalt(input) {
|
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
+
function legNoticeAdmission(route, judge) {
|
|
53
|
+
const { address, destination } = route;
|
|
54
|
+
if (destination === undefined || judge === undefined)
|
|
55
|
+
return undefined;
|
|
56
|
+
return (notice) => judge(destination, { taskId: address.agentId ?? address.sourceSessionId ?? address.sessionId, taskType: notice.code }) !== true;
|
|
57
|
+
}
|
|
52
58
|
export function prepareGateStations(input) {
|
|
53
|
-
const { askLane, parkAsk, tools, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, permissionMode, toolMarkSources, a2aIsolatePeers, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations } = input;
|
|
59
|
+
const { askLane, parkAsk, tools, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, noticeRoute, noticeDestinations, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, permissionMode, toolMarkSources, a2aIsolatePeers, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations } = input;
|
|
60
|
+
const noticeAddress = noticeRoute.address;
|
|
61
|
+
const admitsLegNotice = legNoticeAdmission(noticeRoute, noticeDestinations);
|
|
54
62
|
const releasesAnnounced = new Map();
|
|
55
63
|
const onModeReleased = (info) => {
|
|
56
64
|
const table = info.readUnestablished === true ? input.readDenyInForce(info.toolCallId) : undefined;
|
|
@@ -59,8 +67,8 @@ export function prepareGateStations(input) {
|
|
|
59
67
|
deliverEngineNotice(deps.onNotice, {
|
|
60
68
|
code: "permission.read_deny_unapplied",
|
|
61
69
|
message: `the ${info.release.mode} permission mode released "${info.toolName}" although a read-deny table is in force (${named}): the read boundary could not establish what this command reads, so no row of the table was applied to it`,
|
|
62
|
-
detail: { mode: info.release.mode, toolCallId: info.toolCallId, tiers: [...table.tiers], rows: table.rows.slice(0, 8), rowCount: table.rows.length,
|
|
63
|
-
});
|
|
70
|
+
detail: { mode: info.release.mode, toolCallId: info.toolCallId, tiers: [...table.tiers], rows: table.rows.slice(0, 8), rowCount: table.rows.length, ...noticeAddress, runId },
|
|
71
|
+
}, admitsLegNotice);
|
|
64
72
|
}
|
|
65
73
|
const key = `${info.release.mode}\u0000${info.release.askClass}`;
|
|
66
74
|
const count = (releasesAnnounced.get(key) ?? 0) + 1;
|
|
@@ -70,8 +78,8 @@ export function prepareGateStations(input) {
|
|
|
70
78
|
deliverEngineNotice(deps.onNotice, {
|
|
71
79
|
code: "permission.ask_released_by_mode",
|
|
72
80
|
message: `the ${info.release.mode} permission mode released a ${info.release.askClass} ask on "${info.toolName}" without putting it to anyone (further releases of this pair in this run ride each call's tool_end.gate.disposition.released)`,
|
|
73
|
-
detail: { mode: info.release.mode, askClass: info.release.askClass, ...(info.release.origin !== undefined ? { origin: info.release.origin } : {}), ...(info.release.mandate !== undefined ? { mandate: info.release.mandate } : {}), count, firstToolCallId: info.toolCallId,
|
|
74
|
-
});
|
|
81
|
+
detail: { mode: info.release.mode, askClass: info.release.askClass, ...(info.release.origin !== undefined ? { origin: info.release.origin } : {}), ...(info.release.mandate !== undefined ? { mandate: info.release.mandate } : {}), count, firstToolCallId: info.toolCallId, ...noticeAddress, runId },
|
|
82
|
+
}, admitsLegNotice);
|
|
75
83
|
};
|
|
76
84
|
if (askLane !== undefined && parkAsk !== undefined) {
|
|
77
85
|
const { adjudicate, resolveAskBound, notifyPermissionDenied, notifyHookError } = askLane;
|
|
@@ -140,7 +148,7 @@ export function prepareGateStations(input) {
|
|
|
140
148
|
abortSignal: abortController.signal,
|
|
141
149
|
onHookError: notifyHookError,
|
|
142
150
|
shellGated: tierSeat?.shellGated(shellGatedTools, toolMarkSources) === true,
|
|
143
|
-
...(autoModeDecider.current !== undefined ? { autoMode: { decider: autoModeDecider.current, ...(autoModeDenialTracking.current !== undefined ? { denialTracking: autoModeDenialTracking.current } : {}), unavailable: classifierUnavailableSeat({ station: "leg", ...(autoModeDecider.current.timeoutMs !== undefined ? { budgetMs: autoModeDecider.current.timeoutMs } : {}), route: approvalRouteOf(askRoute), onNotice: deps.onNotice,
|
|
151
|
+
...(autoModeDecider.current !== undefined ? { autoMode: { decider: autoModeDecider.current, ...(autoModeDenialTracking.current !== undefined ? { denialTracking: autoModeDenialTracking.current } : {}), unavailable: classifierUnavailableSeat({ station: "leg", ...(autoModeDecider.current.timeoutMs !== undefined ? { budgetMs: autoModeDecider.current.timeoutMs } : {}), route: approvalRouteOf(askRoute), onNotice: deps.onNotice, admission: admitsLegNotice, ...noticeAddress, runId }) } } : {}),
|
|
144
152
|
permissionMode: () => permissionMode.current, askSeatForm: askRoute.form,
|
|
145
153
|
...(markSources.size > 0 ? { toolMarkSources: markSources } : {}),
|
|
146
154
|
...seatInputsFor(e.toolName, wireOf("gate.skillActivationSeat", call)),
|
|
@@ -149,7 +157,7 @@ export function prepareGateStations(input) {
|
|
|
149
157
|
onModeReleased,
|
|
150
158
|
ancestorArbitrationOf: (toolCallId) => ancestorArbitrations.get(toolCallId),
|
|
151
159
|
onHeadlessDenialLimit: stopForDenialLimit,
|
|
152
|
-
onAskUnresolvable: (info) => deliverEngineNotice(deps.onNotice, askUnresolvableNotice({
|
|
160
|
+
onAskUnresolvable: (info) => deliverEngineNotice(deps.onNotice, askUnresolvableNotice({ ...noticeAddress, ...info }), admitsLegNotice),
|
|
153
161
|
...(permissionRuleLane
|
|
154
162
|
? {
|
|
155
163
|
persistedRules: {
|
|
@@ -331,7 +331,7 @@ export async function prepareHandsMount(input) {
|
|
|
331
331
|
seatOf: () => (handsReadOnly ? "readonly" : "full_shell"),
|
|
332
332
|
boundaryOf: (_tool, _cwd, toolCallId) => readonlyBoundary(toolCallId) ?? shellReadBoundary(toolCallId), rootsCanonical: true,
|
|
333
333
|
homeViews: tables.readDeny.homeViews,
|
|
334
|
-
onAdmissionRefused: (toolCallId) => void input.toolOccurrences.refuse(toolCallId, "read_boundary"),
|
|
334
|
+
onAdmissionRefused: (toolCallId, echoed) => void input.toolOccurrences.refuse(toolCallId, "read_boundary", echoed !== undefined ? { echoed } : undefined),
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
if (!handsReadOnly) {
|
|
@@ -80,7 +80,7 @@ export interface PrepareInheritedGateInput {
|
|
|
80
80
|
/** borrowed-readonly — the trusted spawn-side channel: `inheritedGate` (the LIVE half of the chain fold), `ownOrgAdmissionRef`
|
|
81
81
|
* (the same-session continuation's freeze), `delegationProvenance` (the F-012 stamp), and the identity / peer / notification
|
|
82
82
|
* seats the ctx enrichment forwards. Never mutated. */
|
|
83
|
-
internals: Pick<RunInternals, "inheritedGate" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "insideFork" | "questionFaceStripped"> | undefined;
|
|
83
|
+
internals: Pick<RunInternals, "inheritedGate" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "rootSessionIncarnation" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "insideFork" | "questionFaceStripped"> | undefined;
|
|
84
84
|
/** borrowed-readonly — the resume leg, or undefined on a fresh one: `seed.inheritedGate` is the CHECKPOINT half of the chain
|
|
85
85
|
* fold (the trust floor the live half may only tighten), `seed.readFace` the hands-less re-park's carried section. */
|
|
86
86
|
resume: Pick<PrepareResume, "seed" | "outcome"> | undefined;
|
|
@@ -212,6 +212,8 @@ export interface PrepareInheritedGateInput {
|
|
|
212
212
|
} | undefined;
|
|
213
213
|
/** borrowed-readonly — LATE-BOUND: the memory-engine session (the ctx's capture-floor getters read it at THEIR call time). */
|
|
214
214
|
memoryEngineSession: () => Prepared["memoryEngineSession"];
|
|
215
|
+
/** borrowed-readonly — LATE-BOUND: this leg's occupant (`SessionMetadata.incarnation` of the acquired session; the lineage read assigns it). */
|
|
216
|
+
sessionIncarnation: () => string | undefined;
|
|
215
217
|
}
|
|
216
218
|
export interface PrepareInheritedGateResult {
|
|
217
219
|
/** owned — the LIVE half of the inherited chain as supplied (`internals.inheritedGate`); the durable-gate notice reads it. */
|
|
@@ -190,6 +190,7 @@ export function prepareInheritedGate(input) {
|
|
|
190
190
|
const centerAdoption = input.centerAdoption();
|
|
191
191
|
const agentStations = input.agentStations();
|
|
192
192
|
const sendStation = input.sendStation();
|
|
193
|
+
const rootSessionIncarnation = internals?.rootSessionId !== undefined ? internals.rootSessionIncarnation : input.sessionIncarnation();
|
|
193
194
|
return {
|
|
194
195
|
...ctx,
|
|
195
196
|
delegationEntryCaps: delegationEntryCapsResolved,
|
|
@@ -221,10 +222,10 @@ export function prepareInheritedGate(input) {
|
|
|
221
222
|
return input.memoryEngineSession()?.captureOptOut?.indeterminate() ?? false;
|
|
222
223
|
},
|
|
223
224
|
get memoryCaptureControlDir() {
|
|
224
|
-
return input.memoryEngineSession()?.engine.
|
|
225
|
+
return input.memoryEngineSession()?.engine.controlPlaneRoot;
|
|
225
226
|
},
|
|
226
227
|
get memoryCaptureAncestors() {
|
|
227
|
-
const ctl = input.memoryEngineSession()?.engine.
|
|
228
|
+
const ctl = input.memoryEngineSession()?.engine.controlPlaneRoot;
|
|
228
229
|
return [...(internals?.memoryCaptureAncestors ?? []), { sessionId, ...(ctl !== undefined ? { controlDir: ctl } : {}) }];
|
|
229
230
|
},
|
|
230
231
|
getApiKeyAndHeaders: spec.getApiKeyAndHeaders,
|
|
@@ -253,6 +254,7 @@ export function prepareInheritedGate(input) {
|
|
|
253
254
|
...(internals?.parentTaskId !== undefined ? { parentTaskId: internals.parentTaskId } : {}),
|
|
254
255
|
...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}),
|
|
255
256
|
...(internals?.rootSessionId !== undefined ? { rootSessionId: internals.rootSessionId } : {}), ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}),
|
|
257
|
+
...(rootSessionIncarnation !== undefined ? { rootSessionIncarnation } : {}),
|
|
256
258
|
delegationOwner: input.delegationOwner,
|
|
257
259
|
...(internals?.explicitAgentName !== undefined ? { spawnedAgentName: internals.explicitAgentName } : {}),
|
|
258
260
|
...(internals?.peerSelfRef !== undefined ? { peerSelfRef: internals.peerSelfRef } : {}),
|
|
@@ -30,7 +30,7 @@ export function prepareMemoryEngineSession(input) {
|
|
|
30
30
|
onNotice: deps.onNotice,
|
|
31
31
|
});
|
|
32
32
|
if (memoryEngineSession?.settlement !== undefined) {
|
|
33
|
-
delegationSettlementRef.current = { governance: memoryEngineSession.settlement.governance,
|
|
33
|
+
delegationSettlementRef.current = { governance: memoryEngineSession.settlement.governance, sessionId: memoryEngineSession.settlement.sessionId };
|
|
34
34
|
}
|
|
35
35
|
const recordExternal = () => {
|
|
36
36
|
if (delegationProvenanceChannel !== undefined)
|
|
@@ -198,6 +198,10 @@ export interface MemoryInjectionComposition {
|
|
|
198
198
|
path: string;
|
|
199
199
|
content: string;
|
|
200
200
|
}>;
|
|
201
|
+
/** #1123 — the notices this prepare drained, as whole engine reminders (the engine's `announceBlock`, then the
|
|
202
|
+
* session-scope coda in its own reminder when one is owed): an EVENT, so it never enters `memoryBlock` (the cached
|
|
203
|
+
* prefix) — the leg's first request carries it once, ahead of the user's message. Absent when nothing was drained. */
|
|
204
|
+
noticesFrame?: string;
|
|
201
205
|
}
|
|
202
206
|
export interface PrepareMemoryResult {
|
|
203
207
|
memoryEngineSession: Prepared["memoryEngineSession"];
|