@sema-agent/core 7.62.0 → 7.64.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 +936 -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-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.js +102 -54
- package/dist/brain/route-adjudicator.js +9 -4
- package/dist/core/allow-entry.d.ts +4 -0
- package/dist/core/approval-object.js +1 -1
- package/dist/core/arg-summary.js +1 -1
- package/dist/core/ask-origin.d.ts +1 -1
- package/dist/core/ask-origin.js +2 -2
- package/dist/core/ask-question.d.ts +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/background-agent-store.d.ts +7 -0
- package/dist/core/background-agent-store.js +3 -0
- package/dist/core/canonical-json.d.ts +23 -13
- package/dist/core/canonical-json.js +4 -4
- package/dist/core/checkpoint-queries.d.ts +50 -4
- package/dist/core/checkpoint-queries.js +42 -17
- package/dist/core/checkpoint-requirements.d.ts +3 -3
- package/dist/core/checkpoint-requirements.js +2 -1
- package/dist/core/checkpoint-row-verdict.d.ts +15 -4
- package/dist/core/checkpoint-row-verdict.js +22 -2
- package/dist/core/checkpoint-store.d.ts +28 -11
- package/dist/core/checkpoint-store.js +45 -4
- package/dist/core/compliance.d.ts +6 -2
- package/dist/core/compliance.js +3 -3
- package/dist/core/context-settings.d.ts +40 -9
- package/dist/core/context-settings.js +32 -10
- package/dist/core/engine-attestation.d.ts +27 -7
- package/dist/core/engine-attestation.js +5 -1
- package/dist/core/engine-notice.d.ts +43 -5
- 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 +28 -0
- package/dist/core/file-history-store.js +48 -5
- package/dist/core/fs-write-gate-policy.js +1 -1
- package/dist/core/gate-fold.js +2 -0
- 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/git-worktree-env.d.ts +62 -3
- package/dist/core/git-worktree-env.js +91 -30
- package/dist/core/governance-codes.d.ts +9 -3
- package/dist/core/governance-codes.js +17 -3
- package/dist/core/leg-identity.d.ts +19 -1
- package/dist/core/leg-identity.js +12 -0
- package/dist/core/mailbox-store.d.ts +39 -4
- package/dist/core/mailbox-store.js +14 -2
- package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
- package/dist/core/memory-engine/consolidation-driver.js +99 -98
- package/dist/core/memory-engine/consolidation.d.ts +74 -10
- package/dist/core/memory-engine/consolidation.js +183 -11
- package/dist/core/memory-engine/control-objects.d.ts +25 -0
- package/dist/core/memory-engine/control-objects.js +151 -0
- package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
- package/dist/core/memory-engine/control-plane-adoption.js +159 -0
- package/dist/core/memory-engine/data-plane.d.ts +8 -4
- package/dist/core/memory-engine/data-plane.js +11 -6
- package/dist/core/memory-engine/delegation-settlement.d.ts +58 -40
- package/dist/core/memory-engine/delegation-settlement.js +270 -85
- package/dist/core/memory-engine/dual-root.d.ts +12 -6
- package/dist/core/memory-engine/dual-root.js +11 -7
- package/dist/core/memory-engine/engine.d.ts +136 -58
- package/dist/core/memory-engine/engine.js +491 -394
- package/dist/core/memory-engine/entry-scan.d.ts +8 -0
- package/dist/core/memory-engine/entry-scan.js +3 -0
- package/dist/core/memory-engine/file-backend.d.ts +62 -60
- package/dist/core/memory-engine/file-backend.js +122 -198
- package/dist/core/memory-engine/index.d.ts +8 -7
- package/dist/core/memory-engine/index.js +7 -6
- package/dist/core/memory-engine/landing-admission.d.ts +5 -3
- package/dist/core/memory-engine/landing-admission.js +3 -3
- package/dist/core/memory-engine/layout.d.ts +127 -46
- package/dist/core/memory-engine/layout.js +264 -109
- package/dist/core/memory-engine/memory-backend-contract.d.ts +26 -1
- package/dist/core/memory-engine/memory-backend-contract.js +476 -0
- package/dist/core/memory-engine/memory-deployment.d.ts +42 -11
- package/dist/core/memory-engine/memory-deployment.js +54 -15
- package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
- package/dist/core/memory-engine/origin-clearance.js +68 -9
- package/dist/core/memory-engine/scope-contract.d.ts +52 -11
- package/dist/core/memory-engine/scope-contract.js +68 -19
- package/dist/core/memory-engine/session-write-home.d.ts +37 -2
- package/dist/core/memory-engine/session-write-home.js +38 -11
- package/dist/core/memory-engine/sync-client.d.ts +3 -1
- package/dist/core/memory-engine/sync-client.js +7 -0
- package/dist/core/memory-engine/sync-report.d.ts +3 -2
- package/dist/core/memory-engine/sync-report.js +6 -2
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +10 -10
- package/dist/core/memory-engine/types.d.ts +155 -19
- package/dist/core/memory-engine/types.js +2 -0
- package/dist/core/memory.js +15 -6
- 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/stations.d.ts +20 -1
- package/dist/core/mods/stations.js +21 -2
- package/dist/core/mods/tool-call.js +3 -4
- package/dist/core/parent-spec-seat.d.ts +2 -2
- package/dist/core/park-selfcheck.js +2 -2
- package/dist/core/pause-registry.d.ts +2 -0
- package/dist/core/pause-registry.js +3 -0
- package/dist/core/peer-channel.d.ts +5 -0
- package/dist/core/permission-rule-consent.d.ts +26 -8
- package/dist/core/permission-rule-consent.js +76 -36
- package/dist/core/permission-rule-store.d.ts +72 -13
- package/dist/core/permission-rule-store.js +29 -8
- package/dist/core/read-only-shell.js +3 -2
- package/dist/core/redaction-marks.d.ts +8 -0
- package/dist/core/redaction-marks.js +6 -0
- package/dist/core/refusal-echo.d.ts +20 -0
- package/dist/core/refusal-echo.js +33 -0
- package/dist/core/remote-env.d.ts +12 -1
- package/dist/core/remote-env.js +3 -0
- package/dist/core/retention.d.ts +180 -10
- package/dist/core/retention.js +45 -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/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/classifier-ladder.d.ts +7 -1
- 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 +39 -11
- package/dist/core/runner/delegation-owner.d.ts +10 -3
- package/dist/core/runner/delegation-owner.js +4 -1
- package/dist/core/runner/gate-exit.d.ts +6 -0
- package/dist/core/runner/gate-exit.js +13 -4
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.d.ts +10 -5
- package/dist/core/runner/memory-consolidation-driver.js +12 -9
- package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
- package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
- package/dist/core/runner/person-path-rows.d.ts +8 -3
- package/dist/core/runner/person-path-rows.js +5 -1
- package/dist/core/runner/placement-fence.d.ts +12 -0
- package/dist/core/runner/placement-fence.js +20 -6
- package/dist/core/runner/prepare-ask-lane.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +7 -4
- 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-execution-env.js +17 -6
- package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
- package/dist/core/runner/prepare-gate-stations.js +5 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
- package/dist/core/runner/prepare-hands-readface.js +5 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +13 -9
- package/dist/core/runner/prepare-inherited-gate.js +12 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
- package/dist/core/runner/prepare-memory-engine-session.js +4 -4
- package/dist/core/runner/prepare-memory.d.ts +7 -2
- package/dist/core/runner/prepare-memory.js +41 -39
- package/dist/core/runner/prepare-park-ask.js +4 -3
- package/dist/core/runner/prepare-policy-chain.js +7 -7
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-task.js +26 -18
- 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/prepare-workspace-restore.js +3 -6
- 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 +9 -5
- package/dist/core/runner/run-notification-lane.js +22 -22
- package/dist/core/runner/run-recovery-lanes.js +3 -3
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- 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/terminal-account.js +1 -1
- 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 +7 -3
- package/dist/core/secret-env.d.ts +1 -1
- package/dist/core/secret-env.js +4 -4
- package/dist/core/session-checkout.d.ts +168 -0
- package/dist/core/session-checkout.js +579 -0
- package/dist/core/session-store.d.ts +12 -4
- package/dist/core/session-store.js +23 -3
- package/dist/core/session.d.ts +16 -2
- package/dist/core/session.js +3 -0
- package/dist/core/shell-read-silence.js +8 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
- package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
- package/dist/core/store-contracts/peer-directory-contract.js +8 -1
- package/dist/core/store-contracts/session-store-contract.js +39 -0
- package/dist/core/task-event.d.ts +30 -5
- package/dist/core/task-notification.d.ts +119 -32
- package/dist/core/task-notification.js +186 -100
- package/dist/core/task-registry-agent.d.ts +25 -2
- package/dist/core/task-registry-agent.js +56 -22
- package/dist/core/task-registry-shared.d.ts +33 -11
- package/dist/core/task-registry.d.ts +33 -9
- package/dist/core/task-registry.js +36 -18
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +27 -2
- package/dist/core/tool-errors.d.ts +14 -6
- package/dist/core/tool-errors.js +1 -1
- package/dist/core/tool-policy.d.ts +32 -13
- package/dist/core/tool-policy.js +27 -17
- package/dist/core/tool-result-store.d.ts +20 -0
- package/dist/core/tool-spec.d.ts +42 -19
- package/dist/core/trace.d.ts +3 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +15 -4
- package/dist/core/untrusted-egress.js +23 -22
- 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/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/compaction/compaction.d.ts +2 -1
- package/dist/engine/harness/types.d.ts +67 -1
- package/dist/engine/harness/types.js +108 -0
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +30 -1
- package/dist/engine/session/session.js +48 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.js +12 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +8 -1
- package/dist/orchestration/run-workflow-tool.js +8 -0
- package/dist/orchestration/workflow-types.d.ts +2 -1
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +5 -2
- 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 +11 -1
- package/dist/stores/file/index.js +7 -11
- package/dist/stores/file/permission-rule-store.d.ts +23 -0
- package/dist/stores/file/permission-rule-store.js +75 -7
- package/dist/stores/file/session-store.js +2 -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/bash-program-position.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +34 -10
- package/dist/tools/fs/program-read-model.js +37 -7
- package/dist/tools/fs/program-read-model.rows.js +13 -2
- package/dist/tools/fs/read-deny.d.ts +28 -3
- package/dist/tools/fs/read-deny.js +18 -2
- package/dist/tools/fs/removal-targets.js +3 -3
- package/dist/tools/fs/safety.d.ts +2 -0
- package/dist/tools/fs/safety.js +1 -1
- package/dist/tools/fs/shell-read-argv.d.ts +8 -1
- package/dist/tools/fs/shell-read-argv.js +34 -29
- package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
- package/dist/tools/fs/shell-read-bindings.js +5 -1
- package/dist/tools/fs/shell-read-brace.d.ts +18 -0
- package/dist/tools/fs/shell-read-brace.js +79 -0
- package/dist/tools/fs/shell-read-check.d.ts +8 -2
- package/dist/tools/fs/shell-read-check.js +16 -14
- package/dist/tools/fs/shell-read-establish.js +23 -16
- package/dist/tools/fs/shell-read-judge.d.ts +11 -0
- package/dist/tools/fs/shell-read-judge.js +3 -3
- package/dist/tools/fs/shell-read-plan.d.ts +10 -0
- package/dist/tools/fs/shell-read-plan.js +189 -93
- package/dist/tools/fs/shell-read-start.d.ts +19 -9
- package/dist/tools/fs/shell-read-start.js +20 -12
- package/dist/tools/fs/shell-read-word.d.ts +10 -0
- package/dist/tools/fs/shell-read-word.js +9 -5
- package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
- package/dist/tools/fs/shell-read-workdir.js +73 -12
- package/dist/tools/fs/shell-read-write-targets.js +13 -8
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +7 -35
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +135 -11
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core-stores-sql@7.64.0.json +30 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/core@7.64.0.json +2653 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/mods-kernel@7.64.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/wire-changes/primitives@7.64.0.json +30 -0
- package/dist/core/credential-vocabulary.d.ts +0 -176
- package/dist/core/credential-vocabulary.js +0 -190
- package/dist/core/redaction-passes.d.ts +0 -82
- package/dist/core/redaction-passes.js +0 -377
|
@@ -2,7 +2,8 @@ import { uuidv7 } from "../../internal/harness.js";
|
|
|
2
2
|
import { firstSentence } from "../memory.js";
|
|
3
3
|
import { computeEntryRev, parseEntryFile, serializeEntryFile, UNCLOSED_MEMORY_FILE_REASON } from "./frontmatter.js";
|
|
4
4
|
import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
|
|
5
|
-
import { MEMORY_INDEX_FILENAME } from "./entry-scan.js";
|
|
5
|
+
import { MEMORY_INDEX_FILENAME, carriesEntry } from "./entry-scan.js";
|
|
6
|
+
import { deletionFuseCeiling } from "./consolidation.js";
|
|
6
7
|
import { scopeDirName } from "./layout.js";
|
|
7
8
|
export const REMOTE_HARVEST_PER_FILE_BYTES = 100 * 1024;
|
|
8
9
|
export const REMOTE_MASS_DELETION_FUSE_RATIO = 0.5;
|
|
@@ -33,7 +34,8 @@ export function harvestFilesToPatches(baseline, files, opts = {}) {
|
|
|
33
34
|
const writeScope = baseline.writeScope;
|
|
34
35
|
if (writeScope === null)
|
|
35
36
|
return out;
|
|
36
|
-
const
|
|
37
|
+
const carried = files.filter((f) => carriesEntry(f.content));
|
|
38
|
+
const byRel = new Map(carried.map((f) => [f.relPath, f]));
|
|
37
39
|
const baseByRel = new Map(baseline.files.map((b) => [b.relPath, b]));
|
|
38
40
|
const basePathById = new Map(baseline.files.filter((b) => !b.readonly).map((b) => [b.id, b.relPath]));
|
|
39
41
|
const readonlyPrefixes = new Set();
|
|
@@ -70,7 +72,7 @@ export function harvestFilesToPatches(baseline, files, opts = {}) {
|
|
|
70
72
|
}
|
|
71
73
|
const presentIds = new Set();
|
|
72
74
|
const parsedByRel = new Map();
|
|
73
|
-
for (const f of
|
|
75
|
+
for (const f of carried) {
|
|
74
76
|
if (baseByRel.get(f.relPath)?.readonly)
|
|
75
77
|
continue;
|
|
76
78
|
const p = parseEntryFile(f.content);
|
|
@@ -81,16 +83,19 @@ export function harvestFilesToPatches(baseline, files, opts = {}) {
|
|
|
81
83
|
const writable = baseline.files.filter((b) => !b.readonly);
|
|
82
84
|
const missingWritable = writable.filter((b) => !byRel.has(b.relPath) && !presentIds.has(b.id));
|
|
83
85
|
out.missing.push(...missingWritable.map((b) => b.relPath));
|
|
84
|
-
|
|
86
|
+
const ceiling = deletionFuseCeiling(writable.length, fuseRatio);
|
|
87
|
+
if (missingWritable.length > ceiling) {
|
|
85
88
|
out.incident = {
|
|
86
89
|
kind: "mass_deletion",
|
|
87
|
-
detail: `${missingWritable.length}/${writable.length} materialized memory files are missing from the read-back set —
|
|
90
|
+
detail: `${missingWritable.length}/${writable.length} materialized memory files are missing from the read-back set — more than one harvest may remove (${ceiling}), judged an accident: harvest refused, no patches`,
|
|
88
91
|
};
|
|
89
92
|
out.patches = [];
|
|
90
93
|
return out;
|
|
91
94
|
}
|
|
95
|
+
for (const b of missingWritable)
|
|
96
|
+
out.patches.push({ op: "delete", id: b.id, baseRev: b.rev });
|
|
92
97
|
let kept = 0;
|
|
93
|
-
for (const f of
|
|
98
|
+
for (const f of carried) {
|
|
94
99
|
const base = baseByRel.get(f.relPath);
|
|
95
100
|
if (base?.readonly)
|
|
96
101
|
continue;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { MemoryOriginCause } from "./types.js";
|
|
2
|
-
export declare const DELEGATION_SETTLEMENT_FILE = "delegation-settlement.json";
|
|
1
|
+
import type { MemoryGovernanceDocs, MemoryOriginCause } from "./types.js";
|
|
3
2
|
/** A row's FIRST-WRITE status. Rows are immutable after their first write — every later transition
|
|
4
3
|
* is an append-only event ({@link SettlementEvent}); the effective status is the fold. */
|
|
5
4
|
export type SettlementRowStatus = "pending" | "unattestable";
|
|
@@ -45,12 +44,12 @@ export declare function syncSettleId(sessionId: string, toolCallId: string): str
|
|
|
45
44
|
* or corrupt ledger — the launch site fails the launch loudly (a delegation that cannot be
|
|
46
45
|
* accounted must not run: the whole point is that no child exists outside the account).
|
|
47
46
|
*/
|
|
48
|
-
export declare function registerDelegationLaunch(
|
|
47
|
+
export declare function registerDelegationLaunch(docs: MemoryGovernanceDocs, input: {
|
|
49
48
|
settleId: string;
|
|
50
49
|
sessionId: string;
|
|
51
50
|
now: () => number;
|
|
52
51
|
toolUseId?: string;
|
|
53
|
-
}): void
|
|
52
|
+
}): Promise<void>;
|
|
54
53
|
/**
|
|
55
54
|
* §3.5 (r5-3) — the SYNC lane's unattestable row: a synchronous delegation delivered with a
|
|
56
55
|
* missing/unknown attestation under the "attested-only" evidence standard. The row is a durable
|
|
@@ -59,11 +58,11 @@ export declare function registerDelegationLaunch(controlDir: string, input: {
|
|
|
59
58
|
* throw here as "deliver an error instead" (fail-closed — unattested content must not ride into
|
|
60
59
|
* the transcript of a session whose account could not record the fact).
|
|
61
60
|
*/
|
|
62
|
-
export declare function recordSyncUnattestable(
|
|
61
|
+
export declare function recordSyncUnattestable(docs: MemoryGovernanceDocs, input: {
|
|
63
62
|
sessionId: string;
|
|
64
63
|
toolCallId: string;
|
|
65
64
|
now: () => number;
|
|
66
|
-
}): void
|
|
65
|
+
}): Promise<void>;
|
|
67
66
|
/**
|
|
68
67
|
* §3.3 settle — append one observed terminal (idempotent per eventId; the default eventId keys on
|
|
69
68
|
* (settleId, status) so an at-least-once observer replays into one event). Transition legality is
|
|
@@ -71,13 +70,13 @@ export declare function recordSyncUnattestable(controlDir: string, input: {
|
|
|
71
70
|
* after `expired`) still lands — as an event row the fold reads as an annotation-grade fact — so
|
|
72
71
|
* the account never loses an observation (事件不丢), it just doesn't let it rewrite history.
|
|
73
72
|
*/
|
|
74
|
-
export declare function settleDelegation(
|
|
73
|
+
export declare function settleDelegation(docs: MemoryGovernanceDocs, input: {
|
|
75
74
|
settleId: string;
|
|
76
75
|
status: "clean" | "external" | "expired" | "void" | "unattestable";
|
|
77
76
|
now: () => number;
|
|
78
77
|
eventId?: string;
|
|
79
78
|
note?: string;
|
|
80
|
-
}): void
|
|
79
|
+
}): Promise<void>;
|
|
81
80
|
/**
|
|
82
81
|
* §3.3 host valve — `resolveSettlement(settleId, "clean"|"external", requestId)`. Advisory, same
|
|
83
82
|
* trust plane as the host API family; `requestId` is the audit anchor and is REQUIRED (a
|
|
@@ -85,12 +84,12 @@ export declare function settleDelegation(controlDir: string, input: {
|
|
|
85
84
|
* semantics live in the fold: an admin `clean` flips the EFFECTIVE state (releases post-expiry)
|
|
86
85
|
* but never the history bit, and a LATER observed `external` overrides it (观测证据>admin 裁决).
|
|
87
86
|
*/
|
|
88
|
-
export declare function resolveSettlementRecord(
|
|
87
|
+
export declare function resolveSettlementRecord(docs: MemoryGovernanceDocs, input: {
|
|
89
88
|
settleId: string;
|
|
90
89
|
to: "clean" | "external";
|
|
91
90
|
requestId: string;
|
|
92
91
|
now: () => number;
|
|
93
|
-
}): void
|
|
92
|
+
}): Promise<void>;
|
|
94
93
|
/** One settlement's folded (effective) view. */
|
|
95
94
|
export interface EffectiveSettlement {
|
|
96
95
|
row: DelegationSettlementRow;
|
|
@@ -104,9 +103,9 @@ export interface EffectiveSettlement {
|
|
|
104
103
|
terminalEventId?: string;
|
|
105
104
|
}
|
|
106
105
|
/** Lock-less folded read of the whole ledger (journal-aware, fail-closed on corruption). */
|
|
107
|
-
export declare function effectiveSettlements(
|
|
106
|
+
export declare function effectiveSettlements(docs: MemoryGovernanceDocs): Promise<EffectiveSettlement[]>;
|
|
108
107
|
/** One session's folded rows (the harvest classifier's input). */
|
|
109
|
-
export declare function sessionSettlements(
|
|
108
|
+
export declare function sessionSettlements(docs: MemoryGovernanceDocs, sessionId: string): Promise<EffectiveSettlement[]>;
|
|
110
109
|
/**
|
|
111
110
|
* §3.1 — the session exposure classifier over the settlement account (the durable pollution marker
|
|
112
111
|
* is the OTHER input; the caller ORs them). `exposed` ⇔ any {external, unattestable, expired}
|
|
@@ -123,10 +122,10 @@ export declare function classifySessionSettlements(rows: readonly EffectiveSettl
|
|
|
123
122
|
* §3.3-4 — expire overdue pending rows (reconciliation's first leg). Every expiry is an event
|
|
124
123
|
* (idempotent by (settleId, "expired") key); returns the settleIds newly expired this pass.
|
|
125
124
|
*/
|
|
126
|
-
export declare function expireOverdueSettlements(
|
|
125
|
+
export declare function expireOverdueSettlements(docs: MemoryGovernanceDocs, input: {
|
|
127
126
|
timeoutMs: number;
|
|
128
127
|
now: () => number;
|
|
129
|
-
}): string[]
|
|
128
|
+
}): Promise<string[]>;
|
|
130
129
|
/**
|
|
131
130
|
* §3.3-2 — replay the EXTERNAL rows' side effects (账先落、副作用可重放): ensure the durable
|
|
132
131
|
* pollution marker is in place (wx, first-write-wins) and the retroaction challenge sweep has
|
|
@@ -136,14 +135,13 @@ export declare function expireOverdueSettlements(controlDir: string, input: {
|
|
|
136
135
|
* `carry` scopes the sweep domain exactly like the engine's own sweeps (marked rows carry their
|
|
137
136
|
* account under "carry"; the "off" width challenges everything).
|
|
138
137
|
*/
|
|
139
|
-
export declare function replayExternalSettlementEffects(controlDir: string, input: {
|
|
138
|
+
export declare function replayExternalSettlementEffects(docs: MemoryGovernanceDocs, controlDir: string, input: {
|
|
140
139
|
carry: boolean;
|
|
141
140
|
now: () => number;
|
|
142
|
-
}): Array<{
|
|
141
|
+
}): Promise<Array<{
|
|
143
142
|
settleId: string;
|
|
144
143
|
sessionId: string;
|
|
145
|
-
}
|
|
146
|
-
export declare const SESSION_ACCOUNTS_FILE = "session-accounts.json";
|
|
144
|
+
}>>;
|
|
147
145
|
/** One member of the sticky set: the ledger form `(scope, rel)` — `rel` relative to the scope's
|
|
148
146
|
* home, `/`-separated. Location-free, so a home move never re-keys the membership. */
|
|
149
147
|
export interface UnattributedMember {
|
|
@@ -183,11 +181,14 @@ export interface SessionAccountRow {
|
|
|
183
181
|
}
|
|
184
182
|
/** The one-time v1 key-form conversions of the three engine sidecars, in one call (each in its own
|
|
185
183
|
* lock, each idempotent). The layout adoption runs this before any later scope registration can
|
|
186
|
-
* change what a v1 key's first segment names.
|
|
184
|
+
* change what a v1 key's first segment names. A step of the File layout's own upgrade: it converts
|
|
185
|
+
* the hold ledger (a control-plane file, beside its custody) and the session-account document the File
|
|
186
|
+
* store keeps under `controlDir`, in place (a store that keeps documents elsewhere never held the v1
|
|
187
|
+
* form); the reads below convert the same way on first touch. */
|
|
187
188
|
export declare function convertV1SidecarKeys(controlDir: string): void;
|
|
188
189
|
/** The dangling-trigger read: open rows (and unadjudicated closes) belonging to OTHER sessions.
|
|
189
190
|
* These are what arm the unattributed residue classification at a session's materialize. */
|
|
190
|
-
export declare function foreignDanglingSessionAccounts(controlDir: string, selfSessionId: string): SessionAccountRow[]
|
|
191
|
+
export declare function foreignDanglingSessionAccounts(docs: MemoryGovernanceDocs, controlDir: string, selfSessionId: string): Promise<SessionAccountRow[]>;
|
|
191
192
|
/** The live writers of the store's layers, as the account knows them: every row other than the one
|
|
192
193
|
* held by `selfLeg` (the asking mount's own leg — another leg of the same session is another
|
|
193
194
|
* writer) whose session's leg has not ended (no `terminatedAt` — running, or ended without
|
|
@@ -196,20 +197,20 @@ export declare function foreignDanglingSessionAccounts(controlDir: string, selfS
|
|
|
196
197
|
* whether the leg ended) reads as before: live while never closed, counted in `unscoped` — a
|
|
197
198
|
* writer of an unknown layer. Sessions that open no row (no session id, provenance "off", an
|
|
198
199
|
* adoption-restricted mount) are not visible here. */
|
|
199
|
-
export declare function openLayerWriters(controlDir: string, selfLeg: string | undefined): {
|
|
200
|
+
export declare function openLayerWriters(docs: MemoryGovernanceDocs, controlDir: string, selfLeg: string | undefined): Promise<{
|
|
200
201
|
scopes: Set<string>;
|
|
201
202
|
unscoped: number;
|
|
202
|
-
}
|
|
203
|
+
}>;
|
|
203
204
|
/** The leg that holds `sessionId`'s account row (undefined ⇔ no row, or a row without one). */
|
|
204
|
-
export declare function sessionAccountLeg(controlDir: string, sessionId: string): string | undefined
|
|
205
|
+
export declare function sessionAccountLeg(docs: MemoryGovernanceDocs, controlDir: string, sessionId: string): Promise<string | undefined>;
|
|
205
206
|
/** The write scope `sessionId`'s account row records — the scope its newest account-opening mount wrote
|
|
206
207
|
* under (the value that mount's handle carries as `writeScope`), whether that leg is still live or has
|
|
207
208
|
* ended. Undefined ⇔ no row, a row written before the field, or a v1 ledger (whose rows predate it —
|
|
208
209
|
* answered without the conversion, so this read writes nothing). Throws on a corrupt ledger. */
|
|
209
|
-
export declare function sessionAccountWriteHome(
|
|
210
|
+
export declare function sessionAccountWriteHome(docs: MemoryGovernanceDocs, sessionId: string): Promise<{
|
|
210
211
|
writeScope: string;
|
|
211
212
|
openedAt: number;
|
|
212
|
-
} | undefined
|
|
213
|
+
} | undefined>;
|
|
213
214
|
/** The membership question the harvest asks per file: is `(scope, rel)` in the session's sticky
|
|
214
215
|
* set? A session carrying members the conversion could not attribute answers yes for every seat. */
|
|
215
216
|
export interface SessionUnattributedSet {
|
|
@@ -220,15 +221,15 @@ export interface SessionUnattributedSet {
|
|
|
220
221
|
export declare function emptyUnattributedSet(): SessionUnattributedSet;
|
|
221
222
|
/** Open (or re-open, on a same-session resume) the session's account row, persisting the sticky
|
|
222
223
|
* unattributed classification frozen at THIS materialize. */
|
|
223
|
-
export declare function openSessionAccount(controlDir: string, input: {
|
|
224
|
+
export declare function openSessionAccount(docs: MemoryGovernanceDocs, controlDir: string, input: {
|
|
224
225
|
sessionId: string;
|
|
225
226
|
now: () => number;
|
|
226
227
|
unattributed: readonly UnattributedMember[];
|
|
227
228
|
writeScope?: string;
|
|
228
229
|
leg?: string;
|
|
229
|
-
}): void
|
|
230
|
+
}): Promise<void>;
|
|
230
231
|
/** The current session's sticky unattributed set (the harvest's residue-arm input). */
|
|
231
|
-
export declare function sessionUnattributedSet(controlDir: string, sessionId: string): SessionUnattributedSet
|
|
232
|
+
export declare function sessionUnattributedSet(docs: MemoryGovernanceDocs, controlDir: string, sessionId: string): Promise<SessionUnattributedSet>;
|
|
232
233
|
/** Close the session's account row — called ONLY after a FULL-domain harvest (zero BUDGET-deferred
|
|
233
234
|
* files, i.e. `HarvestReport.degraded` absent): a partial harvest's close would launder the deferred
|
|
234
235
|
* residue window (§3.6 序则②). A normal full close also clears every standing `unadjudicated` flag
|
|
@@ -243,32 +244,34 @@ export declare function sessionUnattributedSet(controlDir: string, sessionId: st
|
|
|
243
244
|
* Returns what happened ({@link SessionAccountWrite}): `"absent"` (a session that never opened an
|
|
244
245
|
* account — e.g. an adoption-restricted materialize — has no close, and the caller's disclosure
|
|
245
246
|
* must not claim one), or `"stale"` when `leg` names a mount that no longer holds the row. */
|
|
246
|
-
export declare function closeSessionAccount(controlDir: string, input: {
|
|
247
|
+
export declare function closeSessionAccount(docs: MemoryGovernanceDocs, controlDir: string, input: {
|
|
247
248
|
sessionId: string;
|
|
248
249
|
now: () => number;
|
|
249
250
|
leg?: string;
|
|
250
|
-
}): SessionAccountWrite
|
|
251
|
+
}): Promise<SessionAccountWrite>;
|
|
251
252
|
/** What a close / leg end did: wrote the row, found none, or found the row held by ANOTHER leg (the
|
|
252
253
|
* caller's leg is over — a resume re-opened the row — so nothing was written). */
|
|
253
254
|
export type SessionAccountWrite = "written" | "absent" | "stale";
|
|
254
255
|
/** Record that the session's leg ended ({@link SessionAccountRow.terminatedAt}). Touches nothing
|
|
255
256
|
* else — `closedAt` stays whatever the harvests made it. `leg` (the caller's mount) must hold the
|
|
256
257
|
* row: a leg that is over does not end the one that re-opened it. */
|
|
257
|
-
export declare function terminateSessionAccount(controlDir: string, input: {
|
|
258
|
+
export declare function terminateSessionAccount(docs: MemoryGovernanceDocs, controlDir: string, input: {
|
|
258
259
|
sessionId: string;
|
|
259
260
|
now: () => number;
|
|
260
261
|
leg?: string;
|
|
261
|
-
}): SessionAccountWrite
|
|
262
|
+
}): Promise<SessionAccountWrite>;
|
|
262
263
|
/** The host valve for a dangling row (advisory; §3.6 — dangling rows never auto-expire). The
|
|
263
264
|
* close is `closed-unadjudicated` (r7-3): it stops the row dangling but the residue arm keeps
|
|
264
265
|
* firing until a full-domain harvest closes normally. `requestId` required (audit, #123). */
|
|
265
|
-
export declare function resolveSessionAccountRecord(controlDir: string, input: {
|
|
266
|
+
export declare function resolveSessionAccountRecord(docs: MemoryGovernanceDocs, controlDir: string, input: {
|
|
266
267
|
sessionId: string;
|
|
267
268
|
requestId: string;
|
|
268
269
|
now: () => number;
|
|
269
|
-
}): void
|
|
270
|
-
|
|
271
|
-
export declare const
|
|
270
|
+
}): Promise<void>;
|
|
271
|
+
/** The hold ledger's file: the File store's coordinate of the governance document `holds`. */
|
|
272
|
+
export declare const HOLDS_FILE: string;
|
|
273
|
+
/** The hold custody directory: the File store's directory of the control-object kind `hold`. */
|
|
274
|
+
export declare const HOLD_DIR: string;
|
|
272
275
|
export type HoldStatus = "capturing" | "held" | "released" | "disposed";
|
|
273
276
|
export type HoldTerminal = "dirty" | "expired" | "conflict" | "discarded" | "capture_lost";
|
|
274
277
|
export interface HoldRow {
|
|
@@ -384,17 +387,32 @@ export declare function openInstructionHold(controlDir: string, input: {
|
|
|
384
387
|
* - `capturing` + custody absent + plane file gone ⇒ `capture_lost` (nothing to hold).
|
|
385
388
|
* - `held` + plane file REAPPEARED at the seat ⇒ left alone (a fresh write is a fresh file —
|
|
386
389
|
* the next harvest judges it on its own; the hold's custody bytes stay the hold's).
|
|
390
|
+
* - `disposed` + the row names its quarantine seat + the custody file is still at the custody seat
|
|
391
|
+
* ⇒ the disposal's move finishes (the row is written before the bytes move).
|
|
387
392
|
*/
|
|
388
393
|
export declare function reconcileHolds(controlDir: string, input: {
|
|
389
394
|
homeOf: (scope: string) => string;
|
|
390
395
|
now: () => number;
|
|
396
|
+
onStranded: (scope: string, line: string) => void;
|
|
391
397
|
}): void;
|
|
392
|
-
/**
|
|
393
|
-
*
|
|
398
|
+
/** The quarantine seat of a hold's custody bytes: a function of the ROW, never of a clock. The same
|
|
399
|
+
* row names the same seat on every call, in every process, after any crash — the old
|
|
400
|
+
* `<ms>-hold-<captureName>` shape with the row's own content digest where the wall clock was. */
|
|
401
|
+
export declare function holdQuarantineNameOf(row: Pick<HoldRow, "captureName" | "contentDigest">): string;
|
|
402
|
+
/** Dispose one held row: the row records its terminal and the quarantine seat NAMED BY THE ROW
|
|
403
|
+
* ({@link holdQuarantineNameOf}) first, then the custody bytes move there (host-auditable;
|
|
404
|
+
* from-row-to-bytes addressing survives every terminal). Row first, bytes second: a crash between
|
|
405
|
+
* the two leaves a row whose bytes are at the custody seat or the quarantine seat — both of which
|
|
406
|
+
* {@link readHoldCustody} tries — and {@link reconcileHolds} finishes the move; the reverse order
|
|
407
|
+
* would leave bytes in quarantine under a name no row recorded. Whether the row names a seat is read
|
|
408
|
+
* INSIDE the ledger lock, from what stands at the custody seat and the quarantine seat at that
|
|
409
|
+
* moment: a row with no custody bytes anywhere records the terminal with no name (nothing to move).
|
|
410
|
+
* The verdict always lands: a quarantine seat held by something that is not the hold's bytes records
|
|
411
|
+
* the terminal with no name, leaves the custody bytes where they are and replaces nothing — and then
|
|
412
|
+
* refuses loudly (the caller hears it; a refused intake is terminal all the same). */
|
|
394
413
|
export declare function disposeHold(controlDir: string, input: {
|
|
395
414
|
holdId: string;
|
|
396
415
|
terminal: HoldTerminal;
|
|
397
|
-
now: () => number;
|
|
398
416
|
}): {
|
|
399
417
|
ok: boolean;
|
|
400
418
|
quarantineName?: string;
|
|
@@ -444,4 +462,4 @@ export declare function clearHoldResolution(controlDir: string, input: {
|
|
|
444
462
|
export declare function readHoldCustody(controlDir: string, row: HoldRow): string | undefined;
|
|
445
463
|
/** True ⇔ the session's pollution marker or any non-clean settlement row blocks a clean release
|
|
446
464
|
* (§4.2-1: any non-clean row in the session's account keeps the hold held/disposed). */
|
|
447
|
-
export declare function sessionBlocksCleanRelease(controlDir: string, sessionId: string): boolean
|
|
465
|
+
export declare function sessionBlocksCleanRelease(docs: MemoryGovernanceDocs, controlDir: string, sessionId: string): Promise<boolean>;
|