@sema-agent/core 7.61.0 → 7.63.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 +840 -0
- package/dist/agents/cascade.d.ts +11 -3
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-session-drain.js +13 -3
- package/dist/agents/subagent-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.d.ts +6 -1
- package/dist/agents/subagent.js +143 -58
- package/dist/agents/suspend-guard.d.ts +38 -16
- package/dist/agents/suspend-guard.js +9 -4
- package/dist/agents/verify.js +4 -3
- package/dist/brain/route-adjudicator.js +9 -4
- package/dist/core/approval-object.js +1 -1
- package/dist/core/arg-summary.js +1 -1
- package/dist/core/ask-question.d.ts +2 -2
- package/dist/core/canonical-json.d.ts +23 -13
- package/dist/core/canonical-json.js +4 -4
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-queries.d.ts +47 -4
- package/dist/core/checkpoint-queries.js +36 -16
- package/dist/core/checkpoint-requirements.d.ts +12 -5
- package/dist/core/checkpoint-requirements.js +11 -5
- package/dist/core/checkpoint-row-verdict.d.ts +110 -0
- package/dist/core/checkpoint-row-verdict.js +245 -0
- package/dist/core/checkpoint-store.d.ts +76 -753
- package/dist/core/checkpoint-store.js +83 -144
- package/dist/core/compliance.d.ts +6 -2
- package/dist/core/compliance.js +3 -3
- package/dist/core/engine-attestation.d.ts +1 -1
- package/dist/core/engine-notice.d.ts +38 -7
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/gate-fold.js +2 -2
- 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 +16 -3
- package/dist/core/hooks.d.ts +13 -0
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +1 -1
- package/dist/core/locked-config.d.ts +2 -2
- package/dist/core/mcp-host-seat.js +6 -1
- package/dist/core/memory-engine/consolidation-driver.d.ts +33 -18
- package/dist/core/memory-engine/consolidation-driver.js +99 -98
- package/dist/core/memory-engine/consolidation.d.ts +73 -10
- package/dist/core/memory-engine/consolidation.js +167 -11
- 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 +37 -35
- package/dist/core/memory-engine/delegation-settlement.js +53 -59
- package/dist/core/memory-engine/dual-root.d.ts +12 -6
- package/dist/core/memory-engine/dual-root.js +9 -5
- package/dist/core/memory-engine/engine.d.ts +98 -35
- package/dist/core/memory-engine/engine.js +477 -380
- 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 +29 -3
- package/dist/core/memory-engine/file-backend.js +66 -35
- package/dist/core/memory-engine/index.d.ts +7 -7
- package/dist/core/memory-engine/index.js +6 -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 +121 -45
- package/dist/core/memory-engine/layout.js +252 -102
- package/dist/core/memory-engine/memory-backend-contract.d.ts +19 -1
- package/dist/core/memory-engine/memory-backend-contract.js +320 -0
- package/dist/core/memory-engine/memory-deployment.d.ts +31 -8
- package/dist/core/memory-engine/memory-deployment.js +26 -12
- 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 +3 -1
- package/dist/core/memory-engine/session-write-home.js +1 -1
- 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 +118 -19
- package/dist/core/memory-engine/types.js +1 -0
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/memory.js +15 -6
- package/dist/core/mode-policy.js +1 -1
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +32 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/kernel/events.d.ts +11 -3
- package/dist/core/mods/kernel/events.js +13 -10
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +4 -1
- package/dist/core/mods/session-append.js +7 -0
- package/dist/core/mods/session-receive.js +12 -15
- package/dist/core/mods/stations.d.ts +70 -6
- package/dist/core/mods/stations.js +144 -1
- package/dist/core/own-property-receipt.d.ts +7 -0
- package/dist/core/own-property-receipt.js +3 -0
- 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/permission-rule-consent.d.ts +10 -3
- package/dist/core/permission-rule-consent.js +37 -24
- package/dist/core/permission-rule-store.d.ts +35 -1
- package/dist/core/permission-rule-store.js +27 -8
- package/dist/core/read-only-shell.js +3 -2
- package/dist/core/read-root-candidate.js +1 -1
- package/dist/core/redaction-marks.d.ts +8 -0
- package/dist/core/redaction-marks.js +6 -0
- package/dist/core/remote-env.d.ts +12 -1
- package/dist/core/remote-env.js +3 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- package/dist/core/runner/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/compact-session.js +5 -2
- package/dist/core/runner/contracts.d.ts +36 -17
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/gate-exit.js +2 -2
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- package/dist/core/runner/memory-consolidation-driver.d.ts +6 -3
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- 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/permission-rule-lanes.d.ts +2 -1
- package/dist/core/runner/permission-rule-lanes.js +2 -2
- package/dist/core/runner/person-path-rows.d.ts +23 -3
- package/dist/core/runner/person-path-rows.js +31 -4
- package/dist/core/runner/placement-fence.d.ts +12 -0
- package/dist/core/runner/placement-fence.js +20 -6
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +3 -4
- package/dist/core/runner/prepare-execution-env.js +17 -6
- package/dist/core/runner/prepare-hands-readface.d.ts +3 -2
- package/dist/core/runner/prepare-hands-readface.js +32 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +12 -8
- package/dist/core/runner/prepare-inherited-gate.js +14 -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 +3 -2
- package/dist/core/runner/prepare-memory.js +28 -20
- package/dist/core/runner/prepare-park-ask.js +4 -3
- package/dist/core/runner/prepare-task.js +22 -16
- package/dist/core/runner/prepare-workspace-restore.js +3 -6
- package/dist/core/runner/resume-admission.d.ts +3 -3
- package/dist/core/runner/resume-admission.js +6 -3
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +11 -4
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +4 -1
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +3 -2
- package/dist/core/runner/run-leg.js +25 -8
- package/dist/core/runner/run-settle-and-teardown.js +6 -4
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-turn-boundary.js +7 -4
- package/dist/core/runner/runtask.js +6 -6
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-steer-verb.js +8 -0
- package/dist/core/runner/terminal-account.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/turn-attachments.d.ts +5 -0
- package/dist/core/runner/turn-attachments.js +1 -1
- package/dist/core/runner-deps.d.ts +8 -4
- package/dist/core/secret-env.d.ts +9 -6
- package/dist/core/secret-env.js +41 -22
- package/dist/core/session-checkout.d.ts +108 -0
- package/dist/core/session-checkout.js +485 -0
- package/dist/core/session-store.d.ts +13 -5
- package/dist/core/session-store.js +28 -4
- package/dist/core/session.d.ts +29 -5
- package/dist/core/session.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -12
- package/dist/core/store-contracts/checkpoint-store-contract.js +73 -6
- package/dist/core/store-contracts/session-store-contract.js +61 -8
- package/dist/core/task-event.d.ts +28 -1
- package/dist/core/task-notification.d.ts +9 -1
- package/dist/core/task-notification.js +8 -1
- package/dist/core/task-registry-agent.d.ts +40 -8
- package/dist/core/task-registry-agent.js +57 -24
- package/dist/core/task-registry-shared.d.ts +33 -11
- package/dist/core/task-registry-workflow.js +4 -3
- package/dist/core/task-registry.d.ts +27 -10
- package/dist/core/task-registry.js +19 -13
- package/dist/core/task-result.d.ts +5 -5
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +21 -1
- package/dist/core/terminal-cause.d.ts +6 -6
- package/dist/core/tool-face.d.ts +6 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-policy.d.ts +16 -13
- package/dist/core/tool-policy.js +11 -10
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +42 -19
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +15 -4
- package/dist/core/untrusted-egress.js +23 -22
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +12 -5
- package/dist/engine/harness/types.d.ts +77 -1
- package/dist/engine/harness/types.js +108 -0
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.d.ts +24 -1
- package/dist/engine/session/session.js +46 -2
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/index.d.ts +16 -12
- package/dist/index.js +11 -8
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/orchestration/run-workflow-tool.d.ts +7 -1
- package/dist/orchestration/run-workflow-tool.js +28 -11
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +5 -8
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +7 -6
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +2 -9
- package/dist/stores/file/index.js +2 -4
- package/dist/stores/file/session-store.d.ts +13 -7
- package/dist/stores/file/session-store.js +42 -18
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +10 -10
- 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 +13 -1
- package/dist/tools/fs/read-deny.js +10 -2
- package/dist/tools/fs/removal-targets.js +5 -5
- 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 +11 -2
- package/dist/tools/fs/shell-read-argv.js +45 -29
- package/dist/tools/fs/shell-read-bindings.d.ts +20 -2
- package/dist/tools/fs/shell-read-bindings.js +153 -69
- 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.js +29 -11
- package/dist/tools/fs/shell-read-establish.js +43 -22
- package/dist/tools/fs/shell-read-functions.js +2 -2
- 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-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +18 -0
- package/dist/tools/fs/shell-read-plan.js +217 -104
- package/dist/tools/fs/shell-read-start.d.ts +76 -13
- package/dist/tools/fs/shell-read-start.js +97 -17
- 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 +54 -14
- package/dist/tools/fs/shell-read-workdir.js +103 -19
- 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 +93 -43
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- 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
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
export declare const MEMORY_INDEX_FILENAME = "MEMORY.md";
|
|
4
4
|
/** Default nesting depth cap under a scope dir (CC memory is flat; a small allowance for topic dirs). */
|
|
5
5
|
export declare const DEFAULT_MAX_ENTRY_DEPTH = 3;
|
|
6
|
+
/**
|
|
7
|
+
* What an entry file's bytes must carry to be an entry file at all: anything but whitespace. A blank
|
|
8
|
+
* file holds no entry, so every reader of the plane reads it exactly as it reads an absent file — the
|
|
9
|
+
* harvest does not admit a blank new file as an entry, a blank file where a committed entry was
|
|
10
|
+
* materialized is that entry's removal (the same as the file being gone), and the backend's read
|
|
11
|
+
* serves nothing from it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function carriesEntry(text: string): boolean;
|
|
6
14
|
/** One on-disk entry file the scan found. */
|
|
7
15
|
export interface ScannedEntryFile {
|
|
8
16
|
/** Absolute path. */
|
|
@@ -2,6 +2,9 @@ import { lstatSync, readdirSync } from "node:fs";
|
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
export const MEMORY_INDEX_FILENAME = "MEMORY.md";
|
|
4
4
|
export const DEFAULT_MAX_ENTRY_DEPTH = 3;
|
|
5
|
+
export function carriesEntry(text) {
|
|
6
|
+
return text.trim() !== "";
|
|
7
|
+
}
|
|
5
8
|
export function scanEntryFiles(dir, opts = {}) {
|
|
6
9
|
const maxDepth = opts.maxDepth ?? DEFAULT_MAX_ENTRY_DEPTH;
|
|
7
10
|
const out = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { scopeDirName, type TxnLockTimings, type ChallengeEvent, type MemoryPartitionIncidentSink } from "./layout.js";
|
|
2
2
|
import type { MemoryBundleImportPlan, MemoryImportReport } from "./export-bundle.js";
|
|
3
|
-
import type { HarvestRejection, MemoryBackend, MemoryEntry, MemoryEntryHeader, MemoryScopeEnumeration, NotePatch, PatchReport, ScoredMemoryEntry } from "./types.js";
|
|
3
|
+
import type { HarvestRejection, MemoryBackend, MemoryEntry, MemoryEntryHeader, MemoryGovernanceStore, MemoryScopeEnumeration, NotePatch, PatchReport, ScoredMemoryEntry } from "./types.js";
|
|
4
4
|
export { DEFAULT_MAX_ENTRY_DEPTH, MEMORY_INDEX_FILENAME, scanEntryFiles, type ScannedEntryFile } from "./entry-scan.js";
|
|
5
5
|
/** design/178 v2-b §3.3(b) — the explicit erasure selector (each form resolves to an explicit id
|
|
6
6
|
* list before anything is deleted; there is no whole-store selector). */
|
|
@@ -97,8 +97,8 @@ export interface MemoryErasureAttestation {
|
|
|
97
97
|
* can clear, and says when it cannot (`unverified`, or `evidenceBinding.remaining` — rows the
|
|
98
98
|
* append-only chain keeps). */
|
|
99
99
|
status: "complete" | "partial";
|
|
100
|
-
/** `"journal"` = the
|
|
101
|
-
* lane (always present — a silent downgrade is the forbidden shape). */
|
|
100
|
+
/** `"journal"` = the backend holds an append-only evidence chain, whatever its medium; `"none"` = the
|
|
101
|
+
* explicit `allowUnevidenced` degradation lane (always present — a silent downgrade is the forbidden shape). */
|
|
102
102
|
evidenceCapability: "journal" | "none";
|
|
103
103
|
/** The evidence chain's integrity as read at assembly (v2-a custody tri-state law). `"damaged"`
|
|
104
104
|
* ⇒ every notFound row carries `historyUnknown` and `erasedPreviously` is never produced ("no
|
|
@@ -372,6 +372,22 @@ export interface MemoryExportSnapshot {
|
|
|
372
372
|
quarantined: string[];
|
|
373
373
|
quarantineOpaque: number;
|
|
374
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* The form of the committed-rev ledger (`revs.json`) under a store's control plane, asked of the file and of nothing else — for
|
|
377
|
+
* a program that must know whether a store still holds the pre-binding ledger before (or instead of) opening it, which would
|
|
378
|
+
* migrate it. It reads the file once, through the judge the store itself opens its ledger by: it takes no
|
|
379
|
+
* lock, upgrades nothing, creates nothing and writes nothing. The answer is one of four words:
|
|
380
|
+
* - `"absent"` — there is no ledger file (a store that never committed);
|
|
381
|
+
* - `"v2"` — the current enveloped schema;
|
|
382
|
+
* - `"v1"` — a bare id → rev map, the pre-binding form the store upgrades in place at its next uncontended entry
|
|
383
|
+
* (RL-1654-ledger-v1; once that arm retires the answer set is `"v2"`, `"absent"` and `"malformed"`);
|
|
384
|
+
* - `"malformed"` — the file is there and the store would refuse it (unparseable, wrong shape, a schema version this engine
|
|
385
|
+
* does not read, or a row the ledger rules refuse).
|
|
386
|
+
* A file that cannot be read for any reason but its absence (`EISDIR`, `EACCES`, `ELOOP`, an I/O error) is no form: the read rejects
|
|
387
|
+
* with {@link ControlPlaneCorruptError}, as the store's own does (the message names the errno), never `"absent"` or `"malformed"` — the
|
|
388
|
+
* outcomes are the four words or that rejection. `controlDir` is `FileMemoryEngineBackend.controlPlaneRoot`; a non-string or empty one rejects (`TypeError`).
|
|
389
|
+
*/
|
|
390
|
+
export declare function readMemoryLedgerForm(controlDir: string): Promise<"v1" | "v2" | "absent" | "malformed">;
|
|
375
391
|
/** Construction options for {@link FileMemoryEngineBackend}. */
|
|
376
392
|
export interface FileMemoryEngineBackendOptions {
|
|
377
393
|
/** ⚠️ 分家坑(service 报告 2026-07-09):不显式传时,控制平面按无参 `resolveMemoryEngineRoot()`
|
|
@@ -407,6 +423,9 @@ export declare class FileMemoryEngineBackend implements MemoryBackend {
|
|
|
407
423
|
* NEVER under {@link directoryRoot}, always on the config-root side even for an in-repo memory dir.
|
|
408
424
|
* The engine picks this up (like `directoryRoot`) so both sides share ONE control plane. */
|
|
409
425
|
readonly controlPlaneRoot: string;
|
|
426
|
+
/** The consolidation state's store (`MemoryBackend.governance`): the File store over {@link controlPlaneRoot} —
|
|
427
|
+
* the same files, names and locks an engine over this backend always kept there. */
|
|
428
|
+
readonly governance: MemoryGovernanceStore;
|
|
410
429
|
/** Injected clock (opus 1.258 LOW: match the engine's `this.now` determinism discipline). */
|
|
411
430
|
private readonly now;
|
|
412
431
|
/** The construction-time incident sink (partition adoption, layout adoption on the standalone faces). */
|
|
@@ -1055,6 +1074,13 @@ export declare class FileMemoryEngineBackend implements MemoryBackend {
|
|
|
1055
1074
|
* (§1.1) at the coordinates the batch ACTUALLY lands — a slug collision's `-n` suffix binds the
|
|
1056
1075
|
* suffixed slug, the same one `applied[].slug` reports (v1's ledger had no landing awareness). */
|
|
1057
1076
|
private planOne;
|
|
1077
|
+
/** Where an update / delete patch's entry stands: the plane copy carrying its id, else the committed
|
|
1078
|
+
* account's own seat — the ledger binding's path, with the committed shadow as the entry — when that
|
|
1079
|
+
* seat holds no other entry (absent, blank, or id-less bytes). The account seat is the address the
|
|
1080
|
+
* twins and the erasure lane already use, so an entry whose plane file lost its id line, was blanked
|
|
1081
|
+
* or was removed is still the entry the patch names. `onPlane` false ⇔ the committed bytes are not
|
|
1082
|
+
* standing at `path` (a CAS conflict puts them back there). */
|
|
1083
|
+
private locateForPatch;
|
|
1058
1084
|
private locateById;
|
|
1059
1085
|
/**
|
|
1060
1086
|
* design/178 v2-b §7 — request-driven erasure with evidence (capability face; probe with
|
|
@@ -8,10 +8,10 @@ import { inlineUntrusted } from "../untrusted-text.js";
|
|
|
8
8
|
import { ambiguousOriginRepresentation, committedDistilledOf, committedOriginOf, computeEntryRev, distilledEquals, entryFromFile, isValidEntryId, originEquals, parseEntryFile, serializeEntryFile } from "./frontmatter.js";
|
|
9
9
|
import { convertV1SidecarKeys } from "./delegation-settlement.js";
|
|
10
10
|
import { layerObservationLookup, observedDivergenceNotice } from "./layer-observations.js";
|
|
11
|
-
import { DEFAULT_MAX_ENTRY_DEPTH, MEMORY_INDEX_FILENAME, scanEntryFiles } from "./entry-scan.js";
|
|
12
|
-
import { ControlPlaneCorruptError, CURSORS_FILE, QUARANTINE_DIR, CHALLENGES_FILE, IMPORT_RECEIPTS_DIR, LINEAGE_FILE, SESSION_POLLUTION_DIR, appendChallengeEvents, atomicWriteFileSync, quarantineAndTombstone, captureAndClearLineageForEntries, adoptRootScopeLayout, anchorStoreRoot, effectiveControlRootOf, ensureDirExists, LEDGER_FILE, enqueueMemoryAnnouncement, importLatchTxnId, importLineageCommitted, importSessionPollution, isContainedIn, lockedStrictUpdate, readStrictSidecar, permissionRemedyOf, withPermissionRemedy, lineageContributionsOfSession, listSessionPollution, readChallengeEvents, readLineageRecord, registerScope, registeredScopes, releaseImportLatch, layoutNeedsAdoption, scopeDirFor, scopeDirName, scopeRegistryShape, stageImportLatch, landsOutsideStore, storeActRefusal, storeRootMovedRefusal, writeAllSync, STORE_JOURNAL_FILE, ERASURE_SWEEP_RECORD_FILE, ERASURE_SWEEP_RECORD_WHAT, coerceErasureSweepRecord, erasureSweepOwedAt, erasureSweepRecordPathOf, STORE_TXN_LOCK_DIR, TXN_LOCK_STALE_MS, acquireStoreTxnLock, assertStoreTxnLockOwnership, renewStoreTxnLock, tryStoreTxnLock, } from "./layout.js";
|
|
11
|
+
import { DEFAULT_MAX_ENTRY_DEPTH, MEMORY_INDEX_FILENAME, carriesEntry, scanEntryFiles } from "./entry-scan.js";
|
|
12
|
+
import { ControlPlaneCorruptError, CURSORS_FILE, QUARANTINE_DIR, CHALLENGES_FILE, IMPORT_RECEIPTS_DIR, LINEAGE_FILE, SESSION_POLLUTION_DIR, appendChallengeEvents, atomicWriteFileSync, quarantineAndTombstone, captureAndClearLineageForEntries, adoptRootScopeLayout, anchorStoreRoot, effectiveControlRootOf, ensureDirExists, LEDGER_FILE, sayAnnounceFailure, enqueueMemoryAnnouncement, importLatchTxnId, importLineageCommitted, importSessionPollution, isContainedIn, lockedStrictUpdate, readStrictSidecar, permissionRemedyOf, withPermissionRemedy, lineageContributionsOfSession, listSessionPollution, readChallengeEvents, readLineageRecord, registerScope, registeredScopes, releaseImportLatch, layoutNeedsAdoption, scopeDirFor, scopeDirName, scopeRegistryShape, stageImportLatch, landsOutsideStore, storeActRefusal, storeRootMovedRefusal, writeAllSync, STORE_JOURNAL_FILE, ERASURE_SWEEP_RECORD_FILE, ERASURE_SWEEP_RECORD_WHAT, coerceErasureSweepRecord, erasureSweepOwedAt, erasureSweepRecordPathOf, STORE_TXN_LOCK_DIR, TXN_LOCK_STALE_MS, acquireStoreTxnLock, assertStoreTxnLockOwnership, renewStoreTxnLock, tryStoreTxnLock, } from "./layout.js";
|
|
13
13
|
import { screenInboundEntries } from "./data-plane.js";
|
|
14
|
-
import { CONSOLIDATION_DRIVER_PLANS_DIR, CONSOLIDATION_PLANS_DIR } from "./consolidation.js";
|
|
14
|
+
import { CONSOLIDATION_DRIVER_PLANS_DIR, CONSOLIDATION_PLANS_DIR, fileGovernanceStore } from "./consolidation.js";
|
|
15
15
|
import { canonicalExpectedScopes, expectedScopesInvalid, firstOutsideExpectedScopes } from "./export-bundle.js";
|
|
16
16
|
import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
|
|
17
17
|
import { admittingLandings, cutPerLanding, LandingsNeedAdmission, requireLandingsAdmitted } from "./landing-admission.js";
|
|
@@ -349,6 +349,26 @@ function parseLedgerText(raw, path) {
|
|
|
349
349
|
}
|
|
350
350
|
return { form: "v1", rows };
|
|
351
351
|
}
|
|
352
|
+
function ledgerFormOnDisk(controlDir) {
|
|
353
|
+
const path = join(controlDir, LEDGER_FILE);
|
|
354
|
+
const raw = readControlFileOrAbsent(path, "committed-rev ledger");
|
|
355
|
+
if (raw === undefined)
|
|
356
|
+
return "absent";
|
|
357
|
+
try {
|
|
358
|
+
return parseLedgerText(raw, path).form;
|
|
359
|
+
}
|
|
360
|
+
catch (err) {
|
|
361
|
+
if (err instanceof ControlPlaneCorruptError)
|
|
362
|
+
return "malformed";
|
|
363
|
+
throw err;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
export async function readMemoryLedgerForm(controlDir) {
|
|
367
|
+
if (typeof controlDir !== "string" || controlDir === "") {
|
|
368
|
+
throw new TypeError(`readMemoryLedgerForm: controlDir is a non-empty directory path (got ${controlDir === "" ? "an empty string" : typeof controlDir})`);
|
|
369
|
+
}
|
|
370
|
+
return ledgerFormOnDisk(controlDir);
|
|
371
|
+
}
|
|
352
372
|
const KNOWN_TRANSFER_CHANNELS = new Set(["adopted-move", "applyPatches-move", "migration-bind", "migration", "delete", "erasure-anchor", "erasure-request"]);
|
|
353
373
|
function transferEventInvalid(raw) {
|
|
354
374
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -597,6 +617,7 @@ const FILE_MEMORY_ENGINE_BACKEND_OPTION_KEYS = optionKeys()({ controlDir: 0, now
|
|
|
597
617
|
export class FileMemoryEngineBackend {
|
|
598
618
|
directoryRoot;
|
|
599
619
|
controlPlaneRoot;
|
|
620
|
+
governance;
|
|
600
621
|
now;
|
|
601
622
|
onIncident;
|
|
602
623
|
ledger;
|
|
@@ -619,6 +640,7 @@ export class FileMemoryEngineBackend {
|
|
|
619
640
|
this.onIncident = o.onIncident;
|
|
620
641
|
this.directoryRoot = dir;
|
|
621
642
|
this.controlPlaneRoot = effectiveControlRootOf(dir, { controlDir: o.controlDir, onIncident: o.onIncident });
|
|
643
|
+
this.governance = fileGovernanceStore(this.controlPlaneRoot);
|
|
622
644
|
this.assertRootAnchored();
|
|
623
645
|
ensureDirExists(dir);
|
|
624
646
|
ensureDirExists(this.controlPlaneRoot);
|
|
@@ -760,13 +782,8 @@ export class FileMemoryEngineBackend {
|
|
|
760
782
|
else {
|
|
761
783
|
scopes = [to.scope];
|
|
762
784
|
}
|
|
763
|
-
for (const scope of scopes)
|
|
764
|
-
|
|
765
|
-
enqueueMemoryAnnouncement(this.controlPlaneRoot, { kind: "external", scope, at: this.now(), items }, opts);
|
|
766
|
-
}
|
|
767
|
-
catch {
|
|
768
|
-
}
|
|
769
|
-
}
|
|
785
|
+
for (const scope of scopes)
|
|
786
|
+
void enqueueMemoryAnnouncement(this.governance, { kind: "external", scope, at: this.now(), items }, opts).catch((err) => sayAnnounceFailure(this.onIncident, "store-notice enqueue", err));
|
|
770
787
|
}
|
|
771
788
|
withholdNotice(items) {
|
|
772
789
|
if (items.length === 0)
|
|
@@ -1249,9 +1266,7 @@ export class FileMemoryEngineBackend {
|
|
|
1249
1266
|
const { rows: snapshotRows, extras: snapshotExtras, form: snapshotForm } = journalLedgerSnapshot(journal, jp);
|
|
1250
1267
|
if (snapshotForm === "v1") {
|
|
1251
1268
|
try {
|
|
1252
|
-
|
|
1253
|
-
const diskParsed = diskRaw !== undefined ? JSON.parse(diskRaw) : undefined;
|
|
1254
|
-
if (diskParsed !== null && typeof diskParsed === "object" && "v" in diskParsed && diskParsed.v === LEDGER_SCHEMA_VERSION) {
|
|
1269
|
+
if (ledgerFormOnDisk(this.controlPlaneRoot) === "v2") {
|
|
1255
1270
|
this.enqueueExternalItems("every-scope", [
|
|
1256
1271
|
"memory ledger: recovering a v1-format journal over a v2 ledger — a pre-v2 process wrote AFTER this store migrated (mixed-version deployment window). Retire old readers/writers before further writes; see the v2 rollback runbook.",
|
|
1257
1272
|
]);
|
|
@@ -1595,6 +1610,8 @@ export class FileMemoryEngineBackend {
|
|
|
1595
1610
|
skippedUnreadable.push(relative(this.directoryRoot, f.path));
|
|
1596
1611
|
continue;
|
|
1597
1612
|
}
|
|
1613
|
+
if (!carriesEntry(text))
|
|
1614
|
+
continue;
|
|
1598
1615
|
const parsed = parseEntryFile(text);
|
|
1599
1616
|
if (parsed.id === undefined)
|
|
1600
1617
|
continue;
|
|
@@ -2472,10 +2489,10 @@ export class FileMemoryEngineBackend {
|
|
|
2472
2489
|
let slug = entry.slug;
|
|
2473
2490
|
let target = join(dir, `${slug}.md`);
|
|
2474
2491
|
for (let n = 2;; n++) {
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2492
|
+
if (!plannedTargets.has(target)) {
|
|
2493
|
+
const existing = readSafe(target);
|
|
2494
|
+
if (existing === undefined || !carriesEntry(existing))
|
|
2495
|
+
break;
|
|
2479
2496
|
const parsed = parseEntryFile(existing);
|
|
2480
2497
|
if (parsed.id === undefined || parsed.id === entry.id)
|
|
2481
2498
|
break;
|
|
@@ -2499,7 +2516,7 @@ export class FileMemoryEngineBackend {
|
|
|
2499
2516
|
report.applied.push({ op: "add", id: entry.id, slug });
|
|
2500
2517
|
return;
|
|
2501
2518
|
}
|
|
2502
|
-
const found = this.
|
|
2519
|
+
const found = this.locateForPatch(patch.id, rows, patch.op === "update" ? patch.entry?.scope : undefined);
|
|
2503
2520
|
if (!found) {
|
|
2504
2521
|
report.conflicts.push({ op: patch.op, id: patch.id, reason: "unknown id (entry not found in backend)" });
|
|
2505
2522
|
return;
|
|
@@ -2543,7 +2560,7 @@ export class FileMemoryEngineBackend {
|
|
|
2543
2560
|
if (patch.baseRev !== undefined && patch.baseRev !== currentRev) {
|
|
2544
2561
|
report.conflicts.push({ op: patch.op, id: patch.id, reason: "rev mismatch (concurrent change)", baseRev: patch.baseRev, currentRev });
|
|
2545
2562
|
const shadowText = this.readCommittedShadow(patch.id);
|
|
2546
|
-
if (shadowText !== undefined && shadowText !== serializeEntryFile(found.entry)) {
|
|
2563
|
+
if (shadowText !== undefined && (!found.onPlane || shadowText !== serializeEntryFile(found.entry))) {
|
|
2547
2564
|
ops.push({ kind: "write", target: found.path, content: shadowText });
|
|
2548
2565
|
landings.push({ id: patch.id, scope: found.entry.scope, slug: found.entry.slug });
|
|
2549
2566
|
}
|
|
@@ -2593,6 +2610,20 @@ export class FileMemoryEngineBackend {
|
|
|
2593
2610
|
bindRowTracked(rows, entry.id, { rev: computeEntryRev(entry), scope: entry.scope, slug: entry.slug, at: this.now() }, transfers, "applyPatches-move");
|
|
2594
2611
|
report.applied.push({ op: "update", id: entry.id, slug: entry.slug });
|
|
2595
2612
|
}
|
|
2613
|
+
locateForPatch(id, rows, preferScope) {
|
|
2614
|
+
const onPlane = this.locateById(id, preferScope);
|
|
2615
|
+
if (onPlane !== undefined)
|
|
2616
|
+
return { ...onPlane, onPlane: true };
|
|
2617
|
+
const binding = rowsBinding(rows, id);
|
|
2618
|
+
const shadowText = binding !== undefined ? this.readCommittedShadow(id) : undefined;
|
|
2619
|
+
if (binding === undefined || shadowText === undefined)
|
|
2620
|
+
return undefined;
|
|
2621
|
+
const path = this.bindingAbsPath(binding);
|
|
2622
|
+
const standing = readSafe(path);
|
|
2623
|
+
if (standing !== undefined && parseEntryFile(standing).id !== undefined)
|
|
2624
|
+
return undefined;
|
|
2625
|
+
return { entry: entryFromFile(shadowText, id, binding.slug, binding.scope), path, onPlane: false };
|
|
2626
|
+
}
|
|
2596
2627
|
locateById(id, preferScope) {
|
|
2597
2628
|
const scopes = Object.keys(registeredScopes(this.controlPlaneRoot));
|
|
2598
2629
|
const ordered = preferScope !== undefined ? [preferScope, ...scopes.filter((s) => s !== preferScope)] : scopes;
|
|
@@ -2738,7 +2769,7 @@ export class FileMemoryEngineBackend {
|
|
|
2738
2769
|
resolvedIds = [...new Set([...ledgerIds, ...ghostIds])].sort();
|
|
2739
2770
|
}
|
|
2740
2771
|
else {
|
|
2741
|
-
resolvedIds = lineageContributionsOfSession(this.
|
|
2772
|
+
resolvedIds = (await lineageContributionsOfSession(this.governance, select.sessionId))
|
|
2742
2773
|
.map((c) => c.entryId)
|
|
2743
2774
|
.sort();
|
|
2744
2775
|
}
|
|
@@ -2789,7 +2820,7 @@ export class FileMemoryEngineBackend {
|
|
|
2789
2820
|
transfers.push({ ev: randomUUID(), channel: "erasure-request", req: requestId, scope, selectHash, ids: byScope.get(scope) ?? [], at: now });
|
|
2790
2821
|
}
|
|
2791
2822
|
}
|
|
2792
|
-
const lineageCommitted = resolvedIds.length > 0 ? readLineageRecord(this.
|
|
2823
|
+
const lineageCommitted = resolvedIds.length > 0 ? (await readLineageRecord(this.governance)).committed : {};
|
|
2793
2824
|
const preSessionsOf = (id) => Object.prototype.hasOwnProperty.call(lineageCommitted, id) ? Object.keys(lineageCommitted[id] ?? {}).sort() : [];
|
|
2794
2825
|
for (const id of rowIds) {
|
|
2795
2826
|
const row = rows[id];
|
|
@@ -2888,7 +2919,7 @@ export class FileMemoryEngineBackend {
|
|
|
2888
2919
|
this.appendTransfers(transfers);
|
|
2889
2920
|
this.closeJournalIfOurs(txn);
|
|
2890
2921
|
}
|
|
2891
|
-
const late = captureAndClearLineageForEntries(this.
|
|
2922
|
+
const late = await captureAndClearLineageForEntries(this.governance, resolvedIds);
|
|
2892
2923
|
for (const e of erased) {
|
|
2893
2924
|
const lateSessions = late.get(e.id);
|
|
2894
2925
|
if (lateSessions !== undefined && lateSessions.length > 0)
|
|
@@ -3400,11 +3431,11 @@ export class FileMemoryEngineBackend {
|
|
|
3400
3431
|
const fullStore = Object.keys(registered).every((s) => scopeSet.has(s));
|
|
3401
3432
|
for (let round = 0; round < 3; round++) {
|
|
3402
3433
|
const before = this.exportGovernanceFingerprint();
|
|
3403
|
-
const lineageRec = readLineageRecord(this.
|
|
3404
|
-
const challenges = readChallengeEvents(this.
|
|
3434
|
+
const lineageRec = await readLineageRecord(this.governance);
|
|
3435
|
+
const challenges = await readChallengeEvents(this.governance);
|
|
3405
3436
|
const polluted = listSessionPollution(this.controlPlaneRoot);
|
|
3406
3437
|
const chainRows = this.readExportChainRowsPure();
|
|
3407
|
-
this.exportFaceProbe?.(round);
|
|
3438
|
+
await this.exportFaceProbe?.(round);
|
|
3408
3439
|
const after = this.exportGovernanceFingerprint();
|
|
3409
3440
|
if (before !== after)
|
|
3410
3441
|
continue;
|
|
@@ -3546,15 +3577,15 @@ export class FileMemoryEngineBackend {
|
|
|
3546
3577
|
this.appendTransfers(toAppend);
|
|
3547
3578
|
return { appended: toAppend.length, withheld };
|
|
3548
3579
|
}
|
|
3549
|
-
appendImportChallengesVerified(events) {
|
|
3580
|
+
async appendImportChallengesVerified(events) {
|
|
3550
3581
|
if (events.length === 0)
|
|
3551
3582
|
return;
|
|
3552
|
-
const { assignments } = appendChallengeEvents(this.
|
|
3583
|
+
const { assignments } = await appendChallengeEvents(this.governance, events, this.now);
|
|
3553
3584
|
const replayed = assignments.filter((a) => a.replayed);
|
|
3554
3585
|
if (replayed.length === 0)
|
|
3555
3586
|
return;
|
|
3556
3587
|
const byEventId = new Map();
|
|
3557
|
-
for (const e of readChallengeEvents(this.
|
|
3588
|
+
for (const e of await readChallengeEvents(this.governance))
|
|
3558
3589
|
if (!byEventId.has(e.eventId))
|
|
3559
3590
|
byEventId.set(e.eventId, e);
|
|
3560
3591
|
for (const a of replayed) {
|
|
@@ -3620,14 +3651,14 @@ export class FileMemoryEngineBackend {
|
|
|
3620
3651
|
catch {
|
|
3621
3652
|
throw new ControlPlaneCorruptError(`bundle import completion receipt is unreadable/malformed at ${receiptPath} — it cannot prove completion and cannot be re-minted; repair or remove it deliberately (fail-closed)`);
|
|
3622
3653
|
}
|
|
3623
|
-
releaseImportLatch(ctl, txnId);
|
|
3654
|
+
await releaseImportLatch(this.governance, ctl, txnId);
|
|
3624
3655
|
return report;
|
|
3625
3656
|
}
|
|
3626
3657
|
const digest = this.deletedIdsDigestLocked();
|
|
3627
3658
|
if (digest.state === "damaged" || this.chainDegradedMarkerPresent()) {
|
|
3628
3659
|
throw erasureCodedError("memory bundle import refused: the destination evidence chain is damaged or durably marked degraded — deletion history cannot be proven, so the anti-resurrection judgment cannot run; heal/rebuild the chain (locked mutation entry / explicit rebuild), then import again (nothing was landed, no latch was set)", "memory.import_rejected");
|
|
3629
3660
|
}
|
|
3630
|
-
stageImportLatch(
|
|
3661
|
+
await stageImportLatch(this.governance, bundleHash, plan.entries.map((e) => ({ entryId: e.id, rev: e.rev })), this.now);
|
|
3631
3662
|
const rows = this.loadLedger();
|
|
3632
3663
|
const rowPresent = (id) => Object.prototype.hasOwnProperty.call(rows, id);
|
|
3633
3664
|
const report = {
|
|
@@ -3729,16 +3760,16 @@ export class FileMemoryEngineBackend {
|
|
|
3729
3760
|
}
|
|
3730
3761
|
report.governanceWithheld = [...withheldIds].sort();
|
|
3731
3762
|
report.referentialOrphans = [...orphanIds].sort();
|
|
3732
|
-
report.lineageDivergence = importLineageCommitted(
|
|
3733
|
-
this.appendImportChallengesVerified(challengesToApply.map((c) => ({
|
|
3763
|
+
report.lineageDivergence = await importLineageCommitted(this.governance, lineageToApply);
|
|
3764
|
+
await this.appendImportChallengesVerified(challengesToApply.map((c) => ({
|
|
3734
3765
|
eventId: `imp:${bundleHash}:${c.eventId}`,
|
|
3735
3766
|
entryId: c.entryId,
|
|
3736
3767
|
reason: c.reason,
|
|
3737
3768
|
...(c.challengedRev !== undefined ? { challengedRev: c.challengedRev } : {}),
|
|
3738
3769
|
})));
|
|
3739
3770
|
for (const p of [...plan.pollutedSessions].sort((a, b) => (a.sessionId < b.sessionId ? -1 : 1))) {
|
|
3740
|
-
const contributions = lineageContributionsOfSession(
|
|
3741
|
-
this.appendImportChallengesVerified(contributions.map((c) => ({
|
|
3771
|
+
const contributions = (await lineageContributionsOfSession(this.governance, p.sessionId)).filter((c) => c.marked !== true);
|
|
3772
|
+
await this.appendImportChallengesVerified(contributions.map((c) => ({
|
|
3742
3773
|
eventId: `imp-sweep:${bundleHash}:pollution:${p.sessionId}:${p.at}:${c.entryId}`,
|
|
3743
3774
|
entryId: c.entryId,
|
|
3744
3775
|
reason: `challenged: the contributing session was marked polluted`,
|
|
@@ -3776,7 +3807,7 @@ export class FileMemoryEngineBackend {
|
|
|
3776
3807
|
}
|
|
3777
3808
|
throw err;
|
|
3778
3809
|
}
|
|
3779
|
-
releaseImportLatch(ctl, txnId);
|
|
3810
|
+
await releaseImportLatch(this.governance, ctl, txnId);
|
|
3780
3811
|
return report;
|
|
3781
3812
|
}
|
|
3782
3813
|
catch (err) {
|
|
@@ -2,7 +2,7 @@ export { MemoryEngine, buildMemoryInstruction, truncateIndex, MEMORY_INSTRUCTION
|
|
|
2
2
|
export { MEMORY_SEARCH_TOOL_NAME, MEMORY_GET_TOOL_NAME, MEMORY_INDEX_TOOL_NAME, MEMORY_ENGINE_TOOL_NAMES, type MemorySearchDetails, type MemorySearchHit, type CleanMemorySearchHit, type ExposedMemorySearchHit, type MemoryGetDetails, type MemoryIndexDetails, type MemoryIndexRow, type CleanMemoryIndexRow, type ExposedMemoryIndexRow, } from "./tools.js";
|
|
3
3
|
export { MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, MEMORY_PROVENANCE_RECALL_SENTENCE, MEMORY_PROVENANCE_SEARCH_SENTENCE, memoryExposureIndexRow, parseMemoryExposureIndexRow, } from "./provenance-wording.js";
|
|
4
4
|
export { scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE } from "./scan.js";
|
|
5
|
-
export { FileMemoryEngineBackend, scanEntryFiles, MEMORY_INDEX_FILENAME, DEFAULT_MAX_ENTRY_DEPTH, type ScannedEntryFile, type TransferEvidence, type CommittedBinding, type CommittedEntrySnapshot, type CommittedScopeSnapshots, type EntryCustodyReport, erasureSelectHash, type EraseMemoryEntriesInput, type ErasureCarrierAnswer, type ErasureCarrierClass, type ErasureCountAnswer, type ErasureSelect, type ErasedBinding, type MemoryErasureAttestation, type MemoryExportSnapshot, } from "./file-backend.js";
|
|
5
|
+
export { FileMemoryEngineBackend, readMemoryLedgerForm, scanEntryFiles, MEMORY_INDEX_FILENAME, DEFAULT_MAX_ENTRY_DEPTH, type ScannedEntryFile, type TransferEvidence, type CommittedBinding, type CommittedEntrySnapshot, type CommittedScopeSnapshots, type EntryCustodyReport, erasureSelectHash, type EraseMemoryEntriesInput, type ErasureCarrierAnswer, type ErasureCarrierClass, type ErasureCountAnswer, type ErasureSelect, type ErasedBinding, type MemoryErasureAttestation, type MemoryExportSnapshot, } from "./file-backend.js";
|
|
6
6
|
export { computeBundleSectionHashes, computeMemoryBundleHash, memoryBundleInvalid, type MemoryExportBundle, type MemoryImportReport, type MemoryBundleImportPlan, type BundleChallengeRow, type BundleLineageRow, type BundlePollutedSession, } from "./export-bundle.js";
|
|
7
7
|
export { ControlPlaneCorruptError, deriveControlPlaneDir, deriveRepoControlPlaneDir, deriveRepoKey, deriveRepoMemoryDir, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, resolveMemoryEngineRoot, scopeDirFor, scopeDirName, scopeRegistryShape, layoutNeedsAdoption, adoptRootScopeLayout, v1MemoryPathKeyResolver, unresolvedProjectionDebts, scanFuseKey, type AdoptRootScopeLayoutOptions, type ScopeRegistryShape, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, type ControlPlaneRebuildReceipt, type StrictControlPlaneLedger, type ChallengeAppendResult, type ChallengeAssignment, type ChallengeEvent, type ChallengedHistoryRow, type LineagePendingTxn, type LineagePromotion, SESSION_CAPTURE_OPTOUT_DIR, markSessionCaptureOptOut, readSessionCaptureOptOut, listSessionCaptureOptOut, fileSessionCaptureRecordStore, type SessionCaptureOptOutRecord, type SessionCaptureOptOutMarkOutcome, type SessionCaptureRecordStore, } from "./layout.js";
|
|
8
8
|
export { readV2HeaderHints, isInstructionEntry, type V2HeaderHints } from "./header-hints.js";
|
|
@@ -10,14 +10,14 @@ export { parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, com
|
|
|
10
10
|
export { consolidationExposedFrontmatter } from "./frontmatter.js";
|
|
11
11
|
export { committedDistilledOf, distilledEquals } from "./frontmatter.js";
|
|
12
12
|
export { deriveShadowedSet } from "./shadowing.js";
|
|
13
|
-
export { CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote,
|
|
13
|
+
export { CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote, supersessionFuseCeiling, DELETION_FUSE_FLOOR, fileGovernanceStore, memoryGovernanceDurability, type MemoryGovernanceDurability, type ConsolidationGateRead, type ConsolidationGateRow, type ConsolidationIntent, type ConsolidationIntentCredentialRow, type ConsolidationLeaseSeat, type ConsolidationProductProposal, type ConsolidationProposal, type ConsolidationWriteGate, type MemoryConsolidationOptions, CONSOLIDATION_RUN_STOP_REASONS, type ConsolidationRunStopReason, } from "./consolidation.js";
|
|
14
14
|
export { DISTILLER_DEFAULT_MAX_INPUTS_PER_PRODUCT, LLM_DISTILLER_CONTRACT, LLM_DISTILLER_CONTRACT_DL2, LLM_DISTILLER_CONTRACT_DL3, LLM_DISTILLER_CONTRACTS, MEMORY_DISTILLER_CONTRACT_V1, contractGroupingDiff, driveConsolidationToFixpoint, isAliasModelId, llmPlanDistiller, mintExposurePartitionedPlan, mintLlmConsolidationPlan, MEMORY_DISTILLER_PURITY_CONTRACT_V1, detectCleanArmVerbatimLeak, type CleanArmLeakFinding, type CleanArmLeakVerdict, type MemoryDistillerPurityContract, openAiCompatChatSeat, parseJsonAnswer, planParseRepairs, sanitizeLlmGroups, scheduleUnderFuse, type ConsolidationDistillFn, type ConsolidationDriveCycleRow, type ConsolidationDriveEngine, type ConsolidationDriveResult, type ConsolidationFoldState, type DistillerCandidate, type DistillerChatAnswer, type DistillerChatFn, type DistillerChatRequest, type FuseSchedule, type LlmConsolidationPlan, type LlmConsolidationPlanArm, type LlmConsolidationPlanProduct, type LlmDistillerContract, type MintLlmConsolidationPlanResult, type PlanParseRepairs, type SanitizedLlmGroups, } from "./distiller.js";
|
|
15
|
-
export {
|
|
15
|
+
export { CONSOLIDATION_WRITE_REFUSED_CODE, runMemoryConsolidationDriver, type ConsolidationDriverEngine, type ConsolidationDriverRunRow, type ConsolidationRunReceipt, type ConsolidationWriteJudge, type ConsolidationWriteTarget, type RunMemoryConsolidationOptions, } from "./consolidation-driver.js";
|
|
16
16
|
export type { OriginClearanceRow, OriginClearanceEvent, OriginClearanceShadow } from "./origin-clearance.js";
|
|
17
|
-
export { MEMORY_ORIGIN_CAUSES, writableRootOf } from "./types.js";
|
|
18
|
-
export type { MemoryBackend, MemoryEntry, MemoryEntryFrontmatter, MemoryEntryOrigin, MemoryOriginCause, MemoryScopeEnumeration, MemoryEntryDistilled, MemoryEntryDistilledInput, MemoryEntryHeader, ScoredMemoryEntry, NotePatch, PatchReport, MaterializedFile, MemorySessionHandle, HarvestReport, HarvestRejection, HarvestRejectionCode, MemoryAnnouncement, ScanFinding, } from "./types.js";
|
|
19
|
-
export { memoryBackendContract, assertMemoryBackendSearchEquivalence, type MemoryBackendContractHooks, } from "./memory-backend-contract.js";
|
|
20
|
-
export { SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, isOrgScopeKey, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, type ParsedScopeKey, } from "./scope-contract.js";
|
|
17
|
+
export { MEMORY_GOVERNANCE_DOC_NAMES, MEMORY_ORIGIN_CAUSES, writableRootOf } from "./types.js";
|
|
18
|
+
export type { ConsolidationTx, MemoryBackend, MemoryGovernanceStore, MemoryGovernanceDocName, MemoryGovernanceDocs, MemoryEntry, MemoryEntryFrontmatter, MemoryEntryOrigin, MemoryOriginCause, MemoryScopeEnumeration, MemoryEntryDistilled, MemoryEntryDistilledInput, MemoryEntryHeader, ScoredMemoryEntry, NotePatch, PatchReport, MaterializedFile, MemorySessionHandle, HarvestReport, HarvestRejection, HarvestRejectionCode, MemoryAnnouncement, ScanFinding, } from "./types.js";
|
|
19
|
+
export { memoryBackendContract, assertMemoryBackendSearchEquivalence, memoryGovernanceStoreContract, type MemoryBackendContractHooks, type MemoryGovernanceStoreContractHooks, } from "./memory-backend-contract.js";
|
|
20
|
+
export { SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatUserLocalScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, isReplicableScope, isOrgScopeKey, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, type ParsedScopeKey, } from "./scope-contract.js";
|
|
21
21
|
export { migrateScope, type MigrateScopeReport } from "./migrate.js";
|
|
22
22
|
export { materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, type RemoteMemoryFile, type RemoteMemoryBaseline, type RemoteMaterialization, type RemoteHarvestResult, type InboundEntryFinding, } from "./data-plane.js";
|
|
23
23
|
export { reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, type MemorySyncCursor, type MemorySyncConflict, type MemorySyncPlan, type RecallSource, } from "./sync.js";
|
|
@@ -2,7 +2,7 @@ export { MemoryEngine, buildMemoryInstruction, truncateIndex, MEMORY_INSTRUCTION
|
|
|
2
2
|
export { MEMORY_SEARCH_TOOL_NAME, MEMORY_GET_TOOL_NAME, MEMORY_INDEX_TOOL_NAME, MEMORY_ENGINE_TOOL_NAMES, } from "./tools.js";
|
|
3
3
|
export { MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, MEMORY_PROVENANCE_RECALL_SENTENCE, MEMORY_PROVENANCE_SEARCH_SENTENCE, memoryExposureIndexRow, parseMemoryExposureIndexRow, } from "./provenance-wording.js";
|
|
4
4
|
export { scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE } from "./scan.js";
|
|
5
|
-
export { FileMemoryEngineBackend, scanEntryFiles, MEMORY_INDEX_FILENAME, DEFAULT_MAX_ENTRY_DEPTH, erasureSelectHash, } from "./file-backend.js";
|
|
5
|
+
export { FileMemoryEngineBackend, readMemoryLedgerForm, scanEntryFiles, MEMORY_INDEX_FILENAME, DEFAULT_MAX_ENTRY_DEPTH, erasureSelectHash, } from "./file-backend.js";
|
|
6
6
|
export { computeBundleSectionHashes, computeMemoryBundleHash, memoryBundleInvalid, } from "./export-bundle.js";
|
|
7
7
|
export { ControlPlaneCorruptError, deriveControlPlaneDir, deriveRepoControlPlaneDir, deriveRepoKey, deriveRepoMemoryDir, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, resolveMemoryEngineRoot, scopeDirFor, scopeDirName, scopeRegistryShape, layoutNeedsAdoption, adoptRootScopeLayout, v1MemoryPathKeyResolver, unresolvedProjectionDebts, scanFuseKey, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, LINEAGE_FILE, CHALLENGES_FILE, CHALLENGED_HISTORY_FILE, CHALLENGE_LEDGER_MAX_EVENTS, rebuildStrictControlPlaneLedger, SESSION_CAPTURE_OPTOUT_DIR, markSessionCaptureOptOut, readSessionCaptureOptOut, listSessionCaptureOptOut, fileSessionCaptureRecordStore, } from "./layout.js";
|
|
8
8
|
export { readV2HeaderHints, isInstructionEntry } from "./header-hints.js";
|
|
@@ -10,12 +10,12 @@ export { parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, com
|
|
|
10
10
|
export { consolidationExposedFrontmatter } from "./frontmatter.js";
|
|
11
11
|
export { committedDistilledOf, distilledEquals } from "./frontmatter.js";
|
|
12
12
|
export { deriveShadowedSet } from "./shadowing.js";
|
|
13
|
-
export { CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote,
|
|
13
|
+
export { CONSOLIDATION_DEFAULTS, ConsolidationRefusedError, MEMORY_SEARCH_SUPERSEDED_TAG, consolidationTypeEligible, deriveSupersededSet, memorySupersededNote, supersessionFuseCeiling, DELETION_FUSE_FLOOR, fileGovernanceStore, memoryGovernanceDurability, CONSOLIDATION_RUN_STOP_REASONS, } from "./consolidation.js";
|
|
14
14
|
export { DISTILLER_DEFAULT_MAX_INPUTS_PER_PRODUCT, LLM_DISTILLER_CONTRACT, LLM_DISTILLER_CONTRACT_DL2, LLM_DISTILLER_CONTRACT_DL3, LLM_DISTILLER_CONTRACTS, MEMORY_DISTILLER_CONTRACT_V1, contractGroupingDiff, driveConsolidationToFixpoint, isAliasModelId, llmPlanDistiller, mintExposurePartitionedPlan, mintLlmConsolidationPlan, MEMORY_DISTILLER_PURITY_CONTRACT_V1, detectCleanArmVerbatimLeak, openAiCompatChatSeat, parseJsonAnswer, planParseRepairs, sanitizeLlmGroups, scheduleUnderFuse, } from "./distiller.js";
|
|
15
|
-
export {
|
|
16
|
-
export { MEMORY_ORIGIN_CAUSES, writableRootOf } from "./types.js";
|
|
17
|
-
export { memoryBackendContract, assertMemoryBackendSearchEquivalence, } from "./memory-backend-contract.js";
|
|
18
|
-
export { SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, isOrgScopeKey, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, } from "./scope-contract.js";
|
|
15
|
+
export { CONSOLIDATION_WRITE_REFUSED_CODE, runMemoryConsolidationDriver, } from "./consolidation-driver.js";
|
|
16
|
+
export { MEMORY_GOVERNANCE_DOC_NAMES, MEMORY_ORIGIN_CAUSES, writableRootOf } from "./types.js";
|
|
17
|
+
export { memoryBackendContract, assertMemoryBackendSearchEquivalence, memoryGovernanceStoreContract, } from "./memory-backend-contract.js";
|
|
18
|
+
export { SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatUserLocalScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, isReplicableScope, isOrgScopeKey, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, } from "./scope-contract.js";
|
|
19
19
|
export { migrateScope } from "./migrate.js";
|
|
20
20
|
export { materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, } from "./data-plane.js";
|
|
21
21
|
export { reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, } from "./sync.js";
|
|
@@ -55,9 +55,11 @@ export interface LandingCut<O, E, R> {
|
|
|
55
55
|
* `finalAccount`, the batch's (whatever the patches after the last landing changed rides with it).
|
|
56
56
|
*/
|
|
57
57
|
export declare function cutPerLanding<O, E, R>(ops: readonly O[], evidence: readonly E[], shares: readonly PatchShare<R>[], finalAccount: R): Array<LandingCut<O, E, R>>;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
|
|
58
|
+
/** One patch per call, so none of the backend's commits carries a landing behind another whatever its own commit unit is; `before`
|
|
59
|
+
* (the caller's holder check) runs ahead of each call. A backend that cannot admit is handed landings its caller admitted already
|
|
60
|
+
* (`admit` absent); a backend that can is handed `admit` with each call, so every landing — a collision suffix included — is
|
|
61
|
+
* asked under its lock. */
|
|
62
|
+
export declare function applyEachAlone(backend: Pick<MemoryBackend, "applyPatches">, patches: readonly NotePatch[], before: () => void | Promise<void>, admit?: AdmitLandings): Promise<PatchReport>;
|
|
61
63
|
/**
|
|
62
64
|
* The backend's side of the loop. `run(admitted)` plans and applies one locked attempt (it throws
|
|
63
65
|
* {@link LandingsNeedAdmission} when the plan names a spelling not in `admitted`); with no `admit` it runs once, unconditioned.
|
|
@@ -36,11 +36,11 @@ export function cutPerLanding(ops, evidence, shares, finalAccount) {
|
|
|
36
36
|
last.account = finalAccount;
|
|
37
37
|
return cuts;
|
|
38
38
|
}
|
|
39
|
-
export async function applyEachAlone(backend, patches, before) {
|
|
39
|
+
export async function applyEachAlone(backend, patches, before, admit) {
|
|
40
40
|
const report = { applied: [], conflicts: [] };
|
|
41
41
|
for (const p of patches) {
|
|
42
|
-
before();
|
|
43
|
-
const r = await backend.applyPatches([p]);
|
|
42
|
+
await before();
|
|
43
|
+
const r = admit !== undefined ? await backend.applyPatches([p], { admit }) : await backend.applyPatches([p]);
|
|
44
44
|
report.applied.push(...r.applied);
|
|
45
45
|
report.conflicts.push(...r.conflicts);
|
|
46
46
|
}
|