@sema-agent/core 7.72.0 → 7.73.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 +319 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +1 -0
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.js +7 -1
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +30 -22
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/governance-codes.d.ts +7 -1
- package/dist/core/governance-codes.js +13 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +33 -5
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +21 -16
- package/dist/core/runner/person-path-rows.js +80 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +12 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +36 -27
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +5 -2
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +3 -0
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/secret-env.d.ts +53 -37
- package/dist/core/secret-env.js +44 -47
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +10 -3
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-mount-facts.d.ts +1 -1
- package/dist/core/tool-mount-facts.js +1 -0
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +6 -0
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +34 -4
- package/dist/index.d.ts +18 -7
- package/dist/index.js +13 -4
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -55
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +96 -14
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +131 -1
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -4,8 +4,8 @@ import { err, FileError, ok } from "../../internal/harness.js";
|
|
|
4
4
|
import { performsIo } from "../remote-env.js";
|
|
5
5
|
import { thrownText } from "../thrown-value.js";
|
|
6
6
|
import { envErrorDetail } from "../../tools/fs/env-error-detail.js";
|
|
7
|
-
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
8
7
|
import { physicalPathOfExisting } from "../physical-path.js";
|
|
8
|
+
import { PROJECT_ID_REGEX } from "../project-seat.js";
|
|
9
9
|
function pathSegmentsDualFamily(p) {
|
|
10
10
|
return p.split(/[\\/]/).filter(Boolean);
|
|
11
11
|
}
|
|
@@ -198,7 +198,7 @@ export function assertScopeContractPlacement(args) {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
export const PROJECT_MARKER_PATH = ".sema/project";
|
|
201
|
-
export
|
|
201
|
+
export { PROJECT_ID_REGEX };
|
|
202
202
|
const UUID_RE = PROJECT_ID_REGEX;
|
|
203
203
|
export function normalizeProjectId(projectId) {
|
|
204
204
|
return projectId.toLowerCase();
|
|
@@ -354,11 +354,8 @@ export function projectMarkerUnreadableOf(fault) {
|
|
|
354
354
|
return undefined;
|
|
355
355
|
return d.reason === "repo_root_unreadable" || d.markerPath === undefined ? { reason: d.reason } : { reason: d.reason, markerPath: d.markerPath };
|
|
356
356
|
}
|
|
357
|
-
export async function resolveSessionProject(fs, taskRoot, declared,
|
|
358
|
-
|
|
359
|
-
throw identityError("config.project_id_invalid", `TaskSpec.projectId must be a project UUID (the id a \`.sema/project\` marker carries), got ${describeRejectedValue(declared)}; the leg is refused rather than filed under no project.`);
|
|
360
|
-
}
|
|
361
|
-
const declaredId = declared !== undefined ? normalizeProjectId(declared) : undefined;
|
|
357
|
+
export async function resolveSessionProject(fs, taskRoot, declared, inherited) {
|
|
358
|
+
const declaredId = declared !== undefined ? normalizeProjectId(declared.id) : undefined;
|
|
362
359
|
let marker;
|
|
363
360
|
try {
|
|
364
361
|
marker = await resolveProjectId(fs, taskRoot);
|
|
@@ -368,16 +365,19 @@ export async function resolveSessionProject(fs, taskRoot, declared, defaultProje
|
|
|
368
365
|
throw e;
|
|
369
366
|
return { root: taskRoot, markerFault: e };
|
|
370
367
|
}
|
|
371
|
-
if (marker !== null) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
`the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
|
|
376
|
-
}
|
|
377
|
-
return { root: taskRoot, project: { id: marker.projectId, source: "marker" } };
|
|
368
|
+
if (marker !== null && declaredId !== undefined && declaredId !== marker.projectId) {
|
|
369
|
+
const markerPath = join(marker.markerDir, PROJECT_MARKER_PATH);
|
|
370
|
+
throw identityError("config.project_identity_mismatch", `TaskSpec.project.id declares ${declaredId}, but this checkout's project marker ${markerPath} carries ${marker.projectId} — ` +
|
|
371
|
+
`the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
|
|
378
372
|
}
|
|
379
|
-
const
|
|
380
|
-
|
|
373
|
+
const verdict = marker !== null ? { id: marker.projectId, source: "marker" }
|
|
374
|
+
: declaredId !== undefined ? { id: declaredId, source: "declared" }
|
|
375
|
+
: inherited !== undefined ? { id: normalizeProjectId(inherited.id), source: "declared" }
|
|
376
|
+
: undefined;
|
|
377
|
+
if (verdict === undefined)
|
|
378
|
+
return { root: taskRoot };
|
|
379
|
+
const owner = declared ?? (inherited !== undefined && normalizeProjectId(inherited.id) === verdict.id ? inherited : undefined);
|
|
380
|
+
return { root: taskRoot, project: verdict, seat: Object.freeze({ ...owner, id: verdict.id }) };
|
|
381
381
|
}
|
|
382
382
|
export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
|
|
383
383
|
const consumesProjectIdentity = [...scopes, ...(writeScope !== null ? [writeScope] : [])]
|
|
@@ -393,10 +393,10 @@ export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
|
|
|
393
393
|
const verdict = sessionProject.project;
|
|
394
394
|
if (verdict === undefined) {
|
|
395
395
|
throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
|
|
396
|
-
`but this leg has no project verdict (no .sema/project marker and no TaskSpec.
|
|
396
|
+
`but this leg has no project verdict (no .sema/project marker and no TaskSpec.project) — refusing a project-scoped write without a project identity.`, { kind: "write_without_verdict", writeScope, writeProjectId: w.projectId });
|
|
397
397
|
}
|
|
398
398
|
if (normalizeProjectId(w.projectId) !== normalizeProjectId(verdict.id)) {
|
|
399
399
|
throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
|
|
400
|
-
`but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.
|
|
400
|
+
`but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.project.id"}) is ${verdict.id} — refusing a mis-addressed write.`, { kind: "write_project_mismatch", writeScope, writeProjectId: w.projectId, verdictProjectId: verdict.id, verdictSource: verdict.source });
|
|
401
401
|
}
|
|
402
402
|
}
|
|
@@ -3,13 +3,14 @@ import { screenInboundEntries } from "./data-plane.js";
|
|
|
3
3
|
import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
|
|
4
4
|
import { MAX_MEMORY_BYTES } from "../memory.js";
|
|
5
5
|
import { reconcileMemoryEntries } from "./sync.js";
|
|
6
|
+
import { memoryDeletionRecords } from "./deletion-record.js";
|
|
6
7
|
import { MEMORY_ORIGIN_CAUSES } from "./types.js";
|
|
7
8
|
import { directoryPinOf, landingPathOf } from "./layout.js";
|
|
8
9
|
import { egressText } from "../untrusted-egress.js";
|
|
9
10
|
import { REDACTION_MARKS, userinfoHolds } from "@sema-agent/primitives";
|
|
10
11
|
import { isReplicableScope } from "./scope-contract.js";
|
|
11
12
|
const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
|
|
12
|
-
"and entries deleted on one side since the last round come back from the other side";
|
|
13
|
+
"and entries deleted on one side since the last round come back from the other side unless that side's store records the deletion and reads it";
|
|
13
14
|
const REFUSAL_ROWS = {
|
|
14
15
|
scope: {
|
|
15
16
|
why: "a cursor is the baseline of one (scope, peer) partition",
|
|
@@ -38,8 +39,8 @@ const REFUSAL_ROWS = {
|
|
|
38
39
|
outs: () => [
|
|
39
40
|
"rebind — when this store holds the entries the baseline was taken over (the same store, moved to this root or bound before " +
|
|
40
41
|
"cursors carried a store), persist the cursor with its store set to this store's identity (memorySyncStoreOf) and sync again",
|
|
41
|
-
"clear — delete the cursor and sync from none, accepting that an entry deleted on either side since the last completed round " +
|
|
42
|
-
"comes back from the other side",
|
|
42
|
+
"clear — delete the cursor and sync from none, accepting that deletions without a baseline no longer cross and an entry deleted on either side since the last completed round " +
|
|
43
|
+
"comes back from the other side unless that side's store records the deletion and reads it (a recorded deletion blocks landing as a conflict and never deletes on the peer)",
|
|
43
44
|
],
|
|
44
45
|
},
|
|
45
46
|
"store-plane": {
|
|
@@ -444,7 +445,26 @@ export async function syncMemoryScope(opts) {
|
|
|
444
445
|
});
|
|
445
446
|
}
|
|
446
447
|
}
|
|
447
|
-
|
|
448
|
+
const heldIds = new Set(fetched.map((e) => e.id));
|
|
449
|
+
const unbaselined = resp.serverEntries.filter((e) => !rejected.has(e.id) && baseRevs[e.id] === undefined && !heldIds.has(e.id));
|
|
450
|
+
const deletionBlocked = new Set();
|
|
451
|
+
if (unbaselined.length > 0) {
|
|
452
|
+
const judged = reconcileMemoryEntries({}, [], unbaselined, { local: await memoryDeletionRecords(backend, unbaselined.map((e) => e.id), scope) });
|
|
453
|
+
for (const c of judged.conflicts) {
|
|
454
|
+
deletionBlocked.add(c.id);
|
|
455
|
+
const record = c.deletion?.record;
|
|
456
|
+
conflicts.push({
|
|
457
|
+
side: "local",
|
|
458
|
+
id: c.id,
|
|
459
|
+
reason: record?.kind === "undecidable"
|
|
460
|
+
? `deletion_record_unreadable: the center offers ${JSON.stringify(c.id)}, which this store does not hold, and whether this store deleted it cannot be read (${record.why}) — not brought back`
|
|
461
|
+
: `deleted_here: this store deleted ${JSON.stringify(c.id)}${c.baseRev !== undefined ? ` at rev ${JSON.stringify(c.baseRev)}` : ""} and the center offers it at rev ${JSON.stringify(c.remote?.rev)} — not brought back (re-judged next round; nothing deleted on the center)`,
|
|
462
|
+
...(c.remote?.rev !== undefined ? { currentRev: c.remote.rev } : {}),
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const landable = (id) => !rejected.has(id) && !deletionBlocked.has(id);
|
|
467
|
+
for (const f of screenInboundEntries(resp.serverEntries.filter((e) => landable(e.id)))) {
|
|
448
468
|
rejected.add(f.id);
|
|
449
469
|
conflicts.push({
|
|
450
470
|
side: "local",
|
|
@@ -491,7 +511,7 @@ export async function syncMemoryScope(opts) {
|
|
|
491
511
|
}
|
|
492
512
|
const patches = [
|
|
493
513
|
...resp.serverEntries
|
|
494
|
-
.filter((e) =>
|
|
514
|
+
.filter((e) => landable(e.id))
|
|
495
515
|
.map((e) => {
|
|
496
516
|
const base = baseRevs[e.id];
|
|
497
517
|
return base !== undefined
|
|
@@ -514,7 +534,7 @@ export async function syncMemoryScope(opts) {
|
|
|
514
534
|
let nextCursor = cursor;
|
|
515
535
|
const warnings = [];
|
|
516
536
|
if (cursorAdvanced) {
|
|
517
|
-
const pulledRevById = new Map(resp.serverEntries.map((e) => [e.id, e.rev]));
|
|
537
|
+
const pulledRevById = new Map(resp.serverEntries.filter((e) => landable(e.id)).map((e) => [e.id, e.rev]));
|
|
518
538
|
const pushedRevById = new Map(request.entries.map((e) => [e.id, e.rev]));
|
|
519
539
|
const serverAppliedIds = new Set(resp.applied.filter((a) => a.op !== "delete").map((a) => a.id));
|
|
520
540
|
const disputedIds = new Set(resp.conflicts.map((c) => c.id));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MemoryEntry, ScoredMemoryEntry } from "./types.js";
|
|
2
|
+
import type { DeletionRecord } from "./deletion-record.js";
|
|
2
3
|
/**
|
|
3
4
|
* design/142 §3 — the per-replica per-scope sync cursor: the COMMON BASELINE a reconciliation run
|
|
4
5
|
* judges divergence against (`id → rev` as of the last completed sync round). This is a NEW
|
|
@@ -36,6 +37,20 @@ export interface MemorySyncConflict {
|
|
|
36
37
|
local?: MemoryEntry;
|
|
37
38
|
remote?: MemoryEntry;
|
|
38
39
|
baseRev?: string;
|
|
40
|
+
/** Present when no baseline answered for the id and the absent side's deletion record blocked it from landing on that
|
|
41
|
+
* side: `record` is that side's answer (`deleted` at any version — `baseRev` carries the deleted version when known —
|
|
42
|
+
* or `undecidable`). A deletion record never emits a delete for the other side. */
|
|
43
|
+
deletion?: {
|
|
44
|
+
side: "local" | "remote";
|
|
45
|
+
record: DeletionRecord;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Each side's deletion records for ids it does not hold (`memoryDeletionRecords`): consulted only for an id present on
|
|
49
|
+
* the other side with no baseline. A side whose records are not given is judged as holding none — the caller holding
|
|
50
|
+
* that side's store passes them (a client's push half leaves the peer's side to the peer, which judges it). */
|
|
51
|
+
export interface MemorySyncDeletions {
|
|
52
|
+
local?: ReadonlyMap<string, DeletionRecord>;
|
|
53
|
+
remote?: ReadonlyMap<string, DeletionRecord>;
|
|
39
54
|
}
|
|
40
55
|
export interface MemorySyncPlan {
|
|
41
56
|
/** Entries the LOCAL side should send to the peer (new here or changed-here-only). 独立轨 F8 —
|
|
@@ -77,10 +92,13 @@ export interface MemorySyncPlan {
|
|
|
77
92
|
* - changed on BOTH sides, or delete-on-one × edit-on-the-other → conflict (caller's ladder);
|
|
78
93
|
* - deleted on one side × UNCHANGED on the other → the delete propagates (deleteLocal/deleteRemote,
|
|
79
94
|
* CAS on baseRev: without this leg removals never cross and the plan livelocks);
|
|
80
|
-
* - present only on one side with NO baseline →
|
|
95
|
+
* - present only on one side with NO baseline → the absent side's deletion record ({@link MemorySyncDeletions}) decides
|
|
96
|
+
* only whether the id may land on that side: `never` (or omitted) ⇒ new entry → propagate; deleted (at any version)
|
|
97
|
+
* or `undecidable` ⇒ conflict carrying `deletion`, never a delete on the present side. Deletions cross only where a
|
|
98
|
+
* baseline exists;
|
|
81
99
|
* - absent on both but present in baseline → cleared (cursor cleanup).
|
|
82
100
|
*/
|
|
83
|
-
export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): MemorySyncPlan;
|
|
101
|
+
export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[], deletions?: MemorySyncDeletions): MemorySyncPlan;
|
|
84
102
|
/** The baseline to persist AFTER a sync round completes: every id both sides now agree on. The
|
|
85
103
|
* caller passes the POST-round entry sets (after applying push/pull and resolving conflicts). */
|
|
86
104
|
export declare function nextSyncBaseline(local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function reconcileMemoryEntries(baseRevs, local, remote) {
|
|
1
|
+
export function reconcileMemoryEntries(baseRevs, local, remote, deletions) {
|
|
2
2
|
const plan = { push: [], pull: [], deleteLocal: [], deleteRemote: [], conflicts: [], cleared: [] };
|
|
3
3
|
const localById = new Map(local.map((e) => [e.id, e]));
|
|
4
4
|
const remoteById = new Map(remote.map((e) => [e.id, e]));
|
|
@@ -20,22 +20,23 @@ export function reconcileMemoryEntries(baseRevs, local, remote) {
|
|
|
20
20
|
plan.pull.push(r);
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
|
-
if (l !== undefined) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
if (l !== undefined || r !== undefined) {
|
|
24
|
+
const present = (l ?? r);
|
|
25
|
+
const side = l !== undefined ? { local: l } : { remote: r };
|
|
26
|
+
if (base !== undefined) {
|
|
27
|
+
if (present.rev !== base)
|
|
28
|
+
plan.conflicts.push({ id, ...side, baseRev: base });
|
|
29
|
+
else
|
|
30
|
+
(l !== undefined ? plan.deleteLocal : plan.deleteRemote).push({ id, baseRev: base });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const absentSide = l !== undefined ? "remote" : "local";
|
|
34
|
+
const record = deletions?.[absentSide]?.get(id);
|
|
35
|
+
if (record === undefined || record.kind === "never")
|
|
36
|
+
(l !== undefined ? plan.push : plan.pull).push(present);
|
|
37
|
+
else
|
|
38
|
+
plan.conflicts.push({ id, ...side, ...(record.kind === "deleted" && record.rev !== undefined ? { baseRev: record.rev } : {}), deletion: { side: absentSide, record } });
|
|
39
|
+
}
|
|
39
40
|
continue;
|
|
40
41
|
}
|
|
41
42
|
plan.cleared.push(id);
|
|
@@ -163,11 +163,15 @@ export declare function createModeGatePolicy(modeRef: {
|
|
|
163
163
|
readonly current: PermissionMode;
|
|
164
164
|
}, seats: ModeGateSeats): ToolPolicy;
|
|
165
165
|
/**
|
|
166
|
-
* The mode a resumed leg REQUESTS: the re-passed spec's word, else the word the checkpoint row
|
|
167
|
-
* resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the
|
|
168
|
-
* pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the word
|
|
169
|
-
* (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the
|
|
170
|
-
*
|
|
166
|
+
* The mode a resumed leg REQUESTS. Without a mode the approval names: the re-passed spec's word, else the word the checkpoint row
|
|
167
|
+
* recorded — except where the resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the
|
|
168
|
+
* one answer the pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the resume's word, else to the
|
|
169
|
+
* word the leg had before it (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the
|
|
170
|
+
* leg's own default). A re-passed `plan` does not keep an approved plan open.
|
|
171
|
+
* The mode the person's approval names (`outcome.permissionMode`, the one the decided row records), on whatever row it decides: a
|
|
172
|
+
* tightening of that mode holds unconditionally; a widening holds only where the ceiling it is folded under is known — the parent's
|
|
173
|
+
* mode with the deployment's cap (the leg's ceilings fold it after). A leg with a parent whose mode this resume was not handed
|
|
174
|
+
* (`parentModeUnknown`) has no known ceiling: the widening is withheld and the leg requests the mode it would without it.
|
|
171
175
|
*/
|
|
172
176
|
export declare function modeRequestAfterResume(seat: PermissionMode | undefined, recorded: {
|
|
173
177
|
readonly permissionMode?: PermissionMode;
|
|
@@ -175,7 +179,18 @@ export declare function modeRequestAfterResume(seat: PermissionMode | undefined,
|
|
|
175
179
|
}, outcome: {
|
|
176
180
|
readonly gate: string;
|
|
177
181
|
readonly decision?: string;
|
|
178
|
-
|
|
182
|
+
readonly permissionMode?: PermissionMode;
|
|
183
|
+
} | undefined, parentModeUnknown?: true): PermissionMode | undefined;
|
|
184
|
+
/** The mode an approval named that {@link modeRequestAfterResume} withholds (a widening with no known ceiling), else `undefined` —
|
|
185
|
+
* the one fact a leg says when it does not take the mode a person approved. */
|
|
186
|
+
export declare function withheldApprovalMode(seat: PermissionMode | undefined, recorded: {
|
|
187
|
+
readonly permissionMode?: PermissionMode;
|
|
188
|
+
readonly prePlanMode?: PermissionMode;
|
|
189
|
+
}, outcome: {
|
|
190
|
+
readonly gate: string;
|
|
191
|
+
readonly decision?: string;
|
|
192
|
+
readonly permissionMode?: PermissionMode;
|
|
193
|
+
} | undefined, parentModeUnknown?: true): PermissionMode | undefined;
|
|
179
194
|
/**
|
|
180
195
|
* The permission MODE's door — two refusals in the pre-first-await stretch, each by name and never a fold back to
|
|
181
196
|
* absence (a mode a caller believes it declared must not silently run as another): a `permissionMode` outside
|
package/dist/core/mode-policy.js
CHANGED
|
@@ -106,11 +106,17 @@ export function createModeGatePolicy(modeRef, seats) {
|
|
|
106
106
|
},
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
export function modeRequestAfterResume(seat, recorded, outcome) {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
export function modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) {
|
|
110
|
+
const approved = outcome !== undefined && outcome.decision !== "reject";
|
|
111
|
+
const unnamed = !approved || !approvalRequestsPlanExit(outcome.gate, recorded.permissionMode) ? (seat ?? recorded.permissionMode) : seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
|
|
112
|
+
const named = approved ? outcome.permissionMode : undefined;
|
|
113
|
+
if (named === undefined)
|
|
114
|
+
return unnamed;
|
|
115
|
+
return parentModeUnknown !== true || clampPermissionMode(named, unnamed ?? "default").effective === named ? named : unnamed;
|
|
116
|
+
}
|
|
117
|
+
export function withheldApprovalMode(seat, recorded, outcome, parentModeUnknown) {
|
|
118
|
+
const named = outcome !== undefined && outcome.decision !== "reject" ? outcome.permissionMode : undefined;
|
|
119
|
+
return named !== undefined && modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) !== named ? named : undefined;
|
|
114
120
|
}
|
|
115
121
|
export function refusePermissionModeDoors(spec) {
|
|
116
122
|
const mode = spec.permissionMode;
|
|
@@ -236,7 +242,10 @@ export class PermissionModeController {
|
|
|
236
242
|
const arming = this.arming;
|
|
237
243
|
if (effective === "auto" && !this.armedForAuto && arming?.armAuto !== undefined) {
|
|
238
244
|
this.armedForAuto = true;
|
|
239
|
-
void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) =>
|
|
245
|
+
void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => {
|
|
246
|
+
this.armedForAuto = false;
|
|
247
|
+
this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault");
|
|
248
|
+
});
|
|
240
249
|
}
|
|
241
250
|
return effective;
|
|
242
251
|
}
|
|
@@ -8,6 +8,12 @@ export function receiptRefusal(message) {
|
|
|
8
8
|
e.code = "config.invalid_argument";
|
|
9
9
|
return e;
|
|
10
10
|
}
|
|
11
|
+
function walkRefusal(message, member) {
|
|
12
|
+
const e = receiptRefusal(message);
|
|
13
|
+
if (member !== undefined)
|
|
14
|
+
e.member = member;
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
11
17
|
export function refuseProxy(given, words) {
|
|
12
18
|
if (types.isProxy(given))
|
|
13
19
|
throw receiptRefusal(`${words.subject} must be a plain object, not a Proxy: its ${words.unit}s are read once off its own descriptors, and a Proxy would run its traps in that read — refused rather than wired through it`);
|
|
@@ -51,12 +57,13 @@ function readCaptured(given, words) {
|
|
|
51
57
|
const received = receive(given, CONFIG_RECEIPT_MODE);
|
|
52
58
|
if (received.ok)
|
|
53
59
|
return received.value;
|
|
54
|
-
const
|
|
60
|
+
const member = received.fault.path[0];
|
|
61
|
+
const name = member ?? "";
|
|
55
62
|
if (received.fault.kind === "getter-threw")
|
|
56
|
-
throw
|
|
63
|
+
throw walkRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`, member);
|
|
57
64
|
if (received.fault.kind === "prototype-moved")
|
|
58
|
-
throw
|
|
59
|
-
throw
|
|
65
|
+
throw walkRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`, member);
|
|
66
|
+
throw walkRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`, member);
|
|
60
67
|
}
|
|
61
68
|
function strayMembersSentence(words, stray, keys) {
|
|
62
69
|
const named = stray.map((k) => {
|
|
@@ -15,8 +15,9 @@ import { type TaskSandboxSettings } from "./command-sandbox.js";
|
|
|
15
15
|
import type { ToolExecuteContext } from "./tool-spec.js";
|
|
16
16
|
import type { FastModeLeg } from "./runner/fast-mode-seat.js";
|
|
17
17
|
import type { TaskSpec } from "./types.js";
|
|
18
|
+
import { type ProjectSeat } from "./project-seat.js";
|
|
18
19
|
/** The fields of a spec the seat carries — one `Pick`, shared by the mint's input and the apply's target. */
|
|
19
|
-
export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "sandbox" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "promptLocale" | "advisorModel" | "attachments" | "language" | "instructionFamily" | "fastMode" | "
|
|
20
|
+
export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "sandbox" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "promptLocale" | "advisorModel" | "attachments" | "language" | "instructionFamily" | "fastMode" | "project">;
|
|
20
21
|
/**
|
|
21
22
|
* The seat a run hands its children. Every member is the parent's own value, frozen at mint (arrays copied and
|
|
22
23
|
* frozen; the facts object copied). Members present iff the parent carries them — an absent member is "nothing to
|
|
@@ -88,11 +89,12 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope"
|
|
|
88
89
|
* word as the stream verb (`TaskStream.setFastMode`) last set it ({@link bindParentSpecSeatFastMode}), the spec's word before a
|
|
89
90
|
* leg is bound — so a toggle reaches every child started after it. Not a clamp: either word travels as written. An ORDINARY
|
|
90
91
|
* member (fill law): a child's own word stands.
|
|
91
|
-
* · `
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
92
|
+
* · `project` — the parent leg's project SEAT: its verdict's id with the texts that belong to it (`SessionProjectVerdict.seat`; a
|
|
93
|
+
* parent judged by its marker alone hands `{ id }`), bound once after `resolveSessionProject` ({@link bindParentSpecSeatProject}).
|
|
94
|
+
* Every spawner hands it on `RunInternals.parentProject` as the child's DEFAULT (its id used only when the child declares no
|
|
95
|
+
* `project` and its own workspace has no marker; its texts only when the child's verdict is its id) — and a waker hands its own
|
|
96
|
+
* to the agent it wakes. Deliberately NOT copied onto `TaskSpec.project` by {@link applyParentSpecSeat}: a declaration is compared
|
|
97
|
+
* with the child's marker, and a child's own workspace marker must beat the inherited default rather than mismatch against it.
|
|
96
98
|
*/
|
|
97
99
|
export interface ParentSpecSeat {
|
|
98
100
|
readonly principal?: string;
|
|
@@ -123,7 +125,7 @@ export interface ParentSpecSeat {
|
|
|
123
125
|
readonly language?: string;
|
|
124
126
|
readonly instructionFamily?: TaskSpec["instructionFamily"];
|
|
125
127
|
readonly fastMode?: boolean;
|
|
126
|
-
readonly
|
|
128
|
+
readonly project?: ProjectSeat;
|
|
127
129
|
}
|
|
128
130
|
/** Refuse (by name, `config.deps_retired_key`) a seat that still carries a retired member. Read at every door a seat enters
|
|
129
131
|
* by hand: the ctx reader, the apply, and the send lane's waker clamps. */
|
|
@@ -131,10 +133,10 @@ export declare function assertParentSpecSeatCurrent(seat: object | undefined): v
|
|
|
131
133
|
/** Bind the seat a leg minted to that leg's fast mode: from now on the seat's `fastMode` is what the leg asks for at the moment it
|
|
132
134
|
* is read — a child started after a toggle is filled with the toggled word. Once per seat, by the leg that minted it. */
|
|
133
135
|
export declare function bindParentSpecSeatFastMode(seat: ParentSpecSeat, leg: Pick<FastModeLeg, "requested">): void;
|
|
134
|
-
/** Bind the seat a leg minted to that leg's resolved project
|
|
135
|
-
* `
|
|
136
|
-
*
|
|
137
|
-
export declare function
|
|
136
|
+
/** Bind the seat a leg minted to that leg's resolved project seat (`sessionProject.seat`): from now on the seat's `project` is the
|
|
137
|
+
* leg's (`undefined` when the leg has no verdict). Bound once per seat, after `resolveSessionProject` runs, so mount validation still
|
|
138
|
+
* runs before the marker walk. */
|
|
139
|
+
export declare function bindParentSpecSeatProject(seat: ParentSpecSeat, project: ProjectSeat | undefined): void;
|
|
138
140
|
/** Mint the seat off the parent's REBOUND spec and its frozen question face (spec over deps — the caller resolves it once,
|
|
139
141
|
* the same value the parent's own question routing reads). Absent fields stay absent; `oneShot` only when `true`. `fastMode` is
|
|
140
142
|
* read when it is read: the bound leg's ask ({@link bindParentSpecSeatFastMode}) — `undefined` while the leg asks for nothing and
|
|
@@ -3,6 +3,7 @@ import { assertNoRetiredKeys } from "./retired-keys.js";
|
|
|
3
3
|
import { mergeChildSandbox, receiveTaskSandbox } from "./command-sandbox.js";
|
|
4
4
|
import { codedRefusal } from "./thrown-value.js";
|
|
5
5
|
import { isolationScopeOf } from "./isolation-scope.js";
|
|
6
|
+
import { screenProjectSeat } from "./project-seat.js";
|
|
6
7
|
function frozenDataCopy(v) {
|
|
7
8
|
if (Array.isArray(v))
|
|
8
9
|
return Object.freeze(Array.from(v, (x) => frozenDataCopy(x)));
|
|
@@ -18,24 +19,27 @@ export function assertParentSpecSeatCurrent(seat) {
|
|
|
18
19
|
assertNoRetiredKeys(seat, RETIRED_PARENT_SPEC_SEAT_KEYS, "ParentSpecSeat");
|
|
19
20
|
}
|
|
20
21
|
const SEAT_FAST_MODE_LEG = new WeakMap();
|
|
21
|
-
const
|
|
22
|
+
const SEAT_PROJECT = new WeakMap();
|
|
22
23
|
export function bindParentSpecSeatFastMode(seat, leg) {
|
|
23
24
|
const cell = SEAT_FAST_MODE_LEG.get(seat);
|
|
24
25
|
if (cell === undefined || cell.leg !== undefined)
|
|
25
26
|
throw new Error("parentSpecSeat: a seat's fast mode is bound once, by the leg that minted it");
|
|
26
27
|
cell.leg = leg;
|
|
27
28
|
}
|
|
28
|
-
export function
|
|
29
|
-
const cell =
|
|
29
|
+
export function bindParentSpecSeatProject(seat, project) {
|
|
30
|
+
const cell = SEAT_PROJECT.get(seat);
|
|
30
31
|
if (cell === undefined || cell.bound)
|
|
31
|
-
throw new Error("parentSpecSeat: a seat's project
|
|
32
|
+
throw new Error("parentSpecSeat: a seat's project is bound once, by the leg that minted it");
|
|
32
33
|
cell.bound = true;
|
|
33
|
-
cell.
|
|
34
|
+
cell.seat = project;
|
|
34
35
|
}
|
|
35
36
|
export function parentSpecSeatOf(spec, frozenOnQuestion) {
|
|
36
37
|
const word = spec.fastMode;
|
|
37
38
|
const cell = {};
|
|
38
|
-
const
|
|
39
|
+
const minted = screenProjectSeat(spec.project, "ParentSpecSeatFields.project");
|
|
40
|
+
if (!minted.ok)
|
|
41
|
+
throw codedRefusal(minted.code, minted.message);
|
|
42
|
+
const projectWord = minted.seat;
|
|
39
43
|
const projectCell = { bound: false };
|
|
40
44
|
const seat = Object.freeze({
|
|
41
45
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
@@ -66,13 +70,13 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
|
|
|
66
70
|
const asked = cell.leg?.requested;
|
|
67
71
|
return asked === undefined || (!asked && word === undefined) ? word : asked;
|
|
68
72
|
},
|
|
69
|
-
get
|
|
70
|
-
return projectCell.bound ? projectCell.
|
|
73
|
+
get project() {
|
|
74
|
+
return projectCell.bound ? projectCell.seat : projectWord;
|
|
71
75
|
},
|
|
72
76
|
...clampFieldSeatsOf(spec),
|
|
73
77
|
});
|
|
74
78
|
SEAT_FAST_MODE_LEG.set(seat, cell);
|
|
75
|
-
|
|
79
|
+
SEAT_PROJECT.set(seat, projectCell);
|
|
76
80
|
return seat;
|
|
77
81
|
}
|
|
78
82
|
export function applyParentSpecSeat(child, seat) {
|
package/dist/core/peer-seat.js
CHANGED
|
@@ -8,7 +8,7 @@ import { optionKeys, strayMembersOf } from "./own-property-receipt.js";
|
|
|
8
8
|
import { readMember, readOwnMembers } from "./thrown-value.js";
|
|
9
9
|
import { assertEndpointBound, httpTrimmed, resolveProtocolHttpHeaders } from "./protocol-http-auth.js";
|
|
10
10
|
import { askCarriedRevocation } from "./protocol-revocation.js";
|
|
11
|
-
import { credentialHeaderValues,
|
|
11
|
+
import { credentialHeaderValues, entryLooksLikeCredential, holdOwnCredentialValues, namesASecret } from "./secret-env.js";
|
|
12
12
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
13
13
|
const PEER_SEAT_MEMBERS = Object.freeze(["answer", "hold", "release"]);
|
|
14
14
|
const RECEIVED = new WeakMap();
|
|
@@ -438,7 +438,7 @@ export class PeerCarrier {
|
|
|
438
438
|
const pieces = read.carry;
|
|
439
439
|
this.holdAnswered(pieces);
|
|
440
440
|
for (const [name, value] of Object.entries(pieces.env ?? {}))
|
|
441
|
-
if (
|
|
441
|
+
if (entryLooksLikeCredential(name, value))
|
|
442
442
|
this.remember(value);
|
|
443
443
|
if (this.lane === "stdio")
|
|
444
444
|
this.expiresAt = pieces.expiresAt;
|
|
@@ -475,7 +475,7 @@ function answeredCredentialValues(answer) {
|
|
|
475
475
|
found.add(credential);
|
|
476
476
|
}
|
|
477
477
|
for (const [name, value] of stringMembers(members["env"]))
|
|
478
|
-
if (
|
|
478
|
+
if (entryLooksLikeCredential(name, value))
|
|
479
479
|
found.add(value);
|
|
480
480
|
return [...found];
|
|
481
481
|
}
|