@sema-agent/core 7.15.0 → 7.17.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 +202 -0
- package/dist/agents/builtin-agents.d.ts +3 -3
- package/dist/agents/cross-session-envelope.d.ts +0 -1
- package/dist/agents/cross-session-envelope.js +0 -1
- package/dist/agents/peer-notices.d.ts +0 -9
- package/dist/agents/peer-notices.js +0 -63
- package/dist/agents/subagent.js +7 -15
- package/dist/brain/request-params.d.ts +2 -2
- package/dist/config/defaults.d.ts +0 -7
- package/dist/config/defaults.js +0 -2
- package/dist/core/artifact-host.d.ts +218 -0
- package/dist/core/artifact-host.js +92 -0
- package/dist/core/ask-origin.d.ts +29 -3
- package/dist/core/ask-origin.js +17 -9
- package/dist/core/ask-question.d.ts +25 -0
- package/dist/core/ask-question.js +4 -0
- package/dist/core/ask-unresolvable-notice.d.ts +30 -21
- package/dist/core/ask-unresolvable-notice.js +16 -8
- package/dist/core/auto-compaction.d.ts +10 -10
- package/dist/core/auto-mode-arming.d.ts +2 -2
- package/dist/core/background-agent-store.d.ts +5 -5
- package/dist/core/background-shell.d.ts +1 -1
- package/dist/core/checkpoint-execution-record.d.ts +0 -3
- package/dist/core/checkpoint-execution-record.js +0 -4
- package/dist/core/checkpoint-store.d.ts +71 -99
- package/dist/core/checkpoint-store.js +9 -16
- package/dist/core/context-edit.d.ts +36 -104
- package/dist/core/context-edit.js +37 -60
- package/dist/core/effective-path-target.d.ts +68 -8
- package/dist/core/effective-path-target.js +42 -30
- package/dist/core/engine-notice.d.ts +46 -32
- package/dist/core/env-budget.d.ts +31 -0
- package/dist/core/env-budget.js +39 -0
- package/dist/core/exec-output-tail.d.ts +5 -5
- package/dist/core/file-history-store.js +3 -6
- package/dist/core/fs-write-gate-policy.d.ts +1 -1
- package/dist/core/fs-write-gate-policy.js +3 -3
- package/dist/core/gate-lanes.js +9 -15
- package/dist/core/governance-codes.d.ts +1 -1
- package/dist/core/governance-codes.js +4 -0
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +18 -17
- package/dist/core/lsp-session.d.ts +1 -1
- package/dist/core/lsp.d.ts +1 -1
- package/dist/core/lsp.js +5 -4
- package/dist/core/mcp.d.ts +5 -5
- package/dist/core/mcp.js +4 -48
- package/dist/core/memory-engine/delegation-settlement.d.ts +37 -12
- package/dist/core/memory-engine/delegation-settlement.js +128 -39
- package/dist/core/memory-engine/engine.d.ts +9 -8
- package/dist/core/memory-engine/engine.js +115 -120
- package/dist/core/memory-engine/file-backend.d.ts +17 -5
- package/dist/core/memory-engine/file-backend.js +78 -34
- package/dist/core/memory-engine/index.d.ts +2 -2
- package/dist/core/memory-engine/index.js +2 -2
- package/dist/core/memory-engine/layout.d.ts +152 -54
- package/dist/core/memory-engine/layout.js +441 -104
- package/dist/core/memory-engine/types.d.ts +8 -3
- package/dist/core/memory-engine/types.js +5 -0
- package/dist/core/memory-recall.d.ts +0 -8
- package/dist/core/memory.d.ts +1 -1
- package/dist/core/oracle-isolation.js +2 -2
- package/dist/core/parent-spec-seat.d.ts +66 -0
- package/dist/core/parent-spec-seat.js +47 -0
- package/dist/core/permission-rule-model.d.ts +11 -6
- package/dist/core/permission-rule-model.js +53 -37
- package/dist/core/permission-rules.js +8 -3
- package/dist/core/protocol-naming.d.ts +2 -2
- package/dist/core/remote-env.d.ts +1 -1
- package/dist/core/retired-keys.d.ts +19 -0
- package/dist/core/retired-keys.js +15 -0
- package/dist/core/runner/abort-race.d.ts +3 -3
- package/dist/core/runner/active-skill-scope.d.ts +2 -2
- package/dist/core/runner/active-skill-scope.js +3 -3
- package/dist/core/runner/assemble-result.d.ts +42 -40
- package/dist/core/runner/assemble-result.js +5 -4
- package/dist/core/runner/checkpoint-scope.d.ts +4 -4
- package/dist/core/runner/clock-and-limits.d.ts +3 -3
- package/dist/core/runner/compaction-call-options.d.ts +35 -99
- package/dist/core/runner/compaction-knobs.d.ts +4 -4
- package/dist/core/runner/compaction-seams.d.ts +5 -5
- package/dist/core/runner/contracts.d.ts +232 -233
- package/dist/core/runner/decide-continuation.d.ts +6 -6
- package/dist/core/runner/denial-limit-arms.d.ts +8 -8
- package/dist/core/runner/derived-route-fallback.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +6 -6
- package/dist/core/runner/gate-exit.js +15 -1
- package/dist/core/runner/git-status-frame.d.ts +7 -7
- package/dist/core/runner/halt-attribution.d.ts +35 -0
- package/dist/core/runner/halt-attribution.js +16 -0
- package/dist/core/runner/inherited-ask-grants.d.ts +6 -6
- package/dist/core/runner/memory-capture-optout.d.ts +1 -1
- package/dist/core/runner/memory-consolidation-driver.d.ts +4 -4
- package/dist/core/runner/memory-consolidation.d.ts +6 -8
- package/dist/core/runner/memory-consolidation.js +0 -1
- package/dist/core/runner/park-commit.d.ts +6 -6
- package/dist/core/runner/permission-rule-lanes.d.ts +19 -19
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -4
- package/dist/core/runner/prepare-artifact.d.ts +53 -0
- package/dist/core/runner/prepare-artifact.js +77 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +3 -3
- package/dist/core/runner/prepare-boundary-parks.d.ts +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +9 -7
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -3
- package/dist/core/runner/prepare-config-doors.d.ts +24 -24
- package/dist/core/runner/prepare-config-doors.js +5 -2
- package/dist/core/runner/prepare-context-lane.d.ts +8 -8
- package/dist/core/runner/prepare-context-lane.js +2 -13
- package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
- package/dist/core/runner/prepare-file-history.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +3 -52
- package/dist/core/runner/prepare-gate-stations.d.ts +5 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +35 -38
- package/dist/core/runner/prepare-hands-readface.js +3 -2
- package/dist/core/runner/prepare-inherited-gate.d.ts +9 -6
- package/dist/core/runner/prepare-inherited-gate.js +7 -8
- package/dist/core/runner/prepare-listings.d.ts +3 -3
- package/dist/core/runner/prepare-lsp.d.ts +3 -3
- package/dist/core/runner/prepare-memory-engine-session.d.ts +5 -5
- package/dist/core/runner/prepare-memory.d.ts +4 -6
- package/dist/core/runner/prepare-memory.js +10 -9
- package/dist/core/runner/prepare-offload-wrappers.d.ts +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +6 -6
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +15 -30
- package/dist/core/runner/prepare-prompt-assembly.js +1 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -5
- package/dist/core/runner/prepare-protocol-tools.d.ts +1 -1
- package/dist/core/runner/prepare-question-face.d.ts +4 -4
- package/dist/core/runner/prepare-run-refs.d.ts +11 -11
- package/dist/core/runner/prepare-safety-scan.d.ts +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -4
- package/dist/core/runner/prepare-suspend-saga.js +0 -2
- package/dist/core/runner/prepare-task.d.ts +12 -12
- package/dist/core/runner/prepare-task.js +10 -9
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +2 -3
- package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -4
- package/dist/core/runner/prepare-wiring-manifest.js +9 -7
- package/dist/core/runner/prepare-workspace-restore.d.ts +1 -1
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/resume-admission.d.ts +1 -1
- package/dist/core/runner/resume-admission.js +2 -1
- package/dist/core/runner/resume-claim.d.ts +1 -1
- package/dist/core/runner/resume-internals-and-config.d.ts +1 -1
- package/dist/core/runner/resume-internals-and-config.js +4 -0
- package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
- package/dist/core/runner/resume-preflight.d.ts +1 -1
- package/dist/core/runner/resume-review-outcome.d.ts +1 -1
- package/dist/core/runner/retired-runner-deps.d.ts +3 -0
- package/dist/core/runner/retired-runner-deps.js +7 -0
- package/dist/core/runner/run-brain-sinks.d.ts +1 -1
- package/dist/core/runner/run-clock-and-content.d.ts +4 -4
- package/dist/core/runner/run-compaction-machinery.d.ts +3 -3
- package/dist/core/runner/run-git-lane.d.ts +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +2 -2
- package/dist/core/runner/run-harness-handlers.js +2 -3
- package/dist/core/runner/run-identity-wiring.d.ts +4 -4
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-notification-lane.d.ts +2 -2
- package/dist/core/runner/run-reasoning-seat.d.ts +2 -2
- package/dist/core/runner/run-settle-and-teardown.d.ts +5 -5
- package/dist/core/runner/run-settle-and-teardown.js +3 -1
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +5 -5
- package/dist/core/runner/runtask.d.ts +14 -14
- package/dist/core/runner/session-file-state-replay.d.ts +3 -3
- package/dist/core/runner/session-file-state-replay.js +3 -3
- package/dist/core/runner/session-rule-policy.d.ts +2 -2
- package/dist/core/runner/session-rule-policy.js +3 -4
- package/dist/core/runner/steer-admission.d.ts +2 -2
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -1
- package/dist/core/runner/stream-halt-verbs.js +1 -1
- package/dist/core/runner/stream-reap.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +1 -4
- package/dist/core/runner/synthetic-tools.d.ts +8 -8
- package/dist/core/runner/teardown-bounded.d.ts +2 -2
- package/dist/core/runner/tool-defer-gate.d.ts +1 -1
- package/dist/core/runner/tool-disclosure.d.ts +33 -33
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -2
- package/dist/core/runner/tool-output-projection.d.ts +2 -2
- package/dist/core/runner/turn-attachments.d.ts +53 -53
- package/dist/core/runner/usage-accounting.d.ts +4 -4
- package/dist/core/runner/workspace-path.d.ts +1 -1
- package/dist/core/runner/workspace-path.js +3 -0
- package/dist/core/runner-deps.d.ts +30 -49
- package/dist/core/safe-notify.d.ts +1 -1
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/sensitive-path-policy.js +4 -4
- package/dist/core/session.d.ts +2 -2
- package/dist/core/skill-tool-specifier.d.ts +1 -1
- package/dist/core/skills-directory.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +1 -1
- package/dist/core/strategy-store.d.ts +8 -11
- package/dist/core/task-event.d.ts +20 -17
- package/dist/core/task-limits.d.ts +1 -1
- package/dist/core/task-notification.d.ts +5 -5
- package/dist/core/task-registry-agent.d.ts +5 -5
- package/dist/core/task-registry-monitor.d.ts +2 -2
- package/dist/core/task-registry-shared.d.ts +27 -27
- package/dist/core/task-registry-shared.js +3 -13
- package/dist/core/task-registry.d.ts +8 -8
- package/dist/core/task-result.d.ts +37 -37
- package/dist/core/task-spec.d.ts +5 -5
- package/dist/core/task-stream.d.ts +16 -11
- package/dist/core/tool-catalog-entries.d.ts +1 -0
- package/dist/core/tool-catalog-entries.js +5 -0
- package/dist/core/tool-conformance.d.ts +0 -2
- package/dist/core/tool-conformance.js +1 -3
- package/dist/core/tool-errors.d.ts +5 -0
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-policy.d.ts +51 -22
- package/dist/core/tool-policy.js +28 -5
- package/dist/core/tool-result-budget.d.ts +1 -1
- package/dist/core/tool-result-store.d.ts +11 -11
- package/dist/core/tool-spec.d.ts +34 -38
- package/dist/core/tools.d.ts +2 -2
- package/dist/core/trace.d.ts +12 -15
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/wiring-manifest.d.ts +4 -3
- package/dist/core/workflow-journal-store.d.ts +11 -11
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -2
- package/dist/engine/execution-env/node-execution-env.js +4 -2
- package/dist/engine/harness/agent-harness.d.ts +47 -4
- package/dist/engine/harness/agent-harness.js +52 -9
- package/dist/engine/llm/types.d.ts +1 -1
- package/dist/engine/loop/agent-loop.js +15 -8
- package/dist/engine/loop/types.d.ts +5 -0
- package/dist/index.d.ts +21 -16
- package/dist/index.js +17 -12
- package/dist/internal/harness.d.ts +1 -0
- package/dist/orchestration/run-spec.d.ts +3 -0
- package/dist/orchestration/run-spec.js +3 -3
- package/dist/orchestration/run-workflow-tool.d.ts +12 -6
- package/dist/orchestration/run-workflow-tool.js +23 -5
- package/dist/orchestration/workflow-primitives.d.ts +4 -2
- package/dist/orchestration/workflow-primitives.js +1 -4
- package/dist/orchestration/workflow-types.d.ts +34 -4
- package/dist/orchestration/workflow-types.js +2 -0
- package/dist/orchestration/workflow.d.ts +39 -7
- package/dist/orchestration/workflow.js +234 -113
- package/dist/prompt-assembly/assemble.d.ts +2 -2
- package/dist/prompt-assembly/assemble.js +9 -9
- package/dist/prompt-assembly/composer.d.ts +6 -7
- package/dist/prompt-assembly/composer.js +10 -10
- package/dist/prompt-assembly/epoch.js +1 -1
- package/dist/prompt-assembly/event-registry.d.ts +0 -21
- package/dist/prompt-assembly/packs/sema-default.js +30 -30
- package/dist/prompt-assembly/types.d.ts +14 -14
- package/dist/prompts/coordinator.d.ts +0 -13
- package/dist/prompts/coordinator.js +0 -3
- package/dist/stores/file/checkpoint-store.js +1 -5
- package/dist/stores/file/file-history-store.js +2 -2
- package/dist/stores/file/permission-rule-store.d.ts +4 -35
- package/dist/stores/file/permission-rule-store.js +4 -148
- package/dist/tools/artifact/artifact-text.d.ts +62 -0
- package/dist/tools/artifact/artifact-text.js +68 -0
- package/dist/tools/artifact/artifact-tool.d.ts +52 -0
- package/dist/tools/artifact/artifact-tool.js +351 -0
- package/dist/tools/artifact/local-stub.d.ts +26 -0
- package/dist/tools/artifact/local-stub.js +296 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +114 -48
- package/dist/tools/fs/bash-readonly-classifier.js +171 -60
- package/dist/tools/fs/encoding.d.ts +31 -40
- package/dist/tools/fs/fs-bash.d.ts +49 -45
- package/dist/tools/fs/fs-bash.js +19 -27
- package/dist/tools/fs/fs-pdf.d.ts +8 -8
- package/dist/tools/fs/fs-search-tools.d.ts +4 -4
- package/dist/tools/fs/fs-search-tools.js +5 -2
- package/dist/tools/fs/fs-shared.d.ts +146 -158
- package/dist/tools/fs/fs-shared.js +3 -11
- package/dist/tools/fs/fs-write.d.ts +8 -8
- package/dist/tools/fs/gh-rate-limit.d.ts +13 -14
- package/dist/tools/fs/index.d.ts +78 -78
- package/dist/tools/fs/index.js +4 -1
- package/dist/tools/fs/notebook.d.ts +24 -25
- package/dist/tools/fs/pdf.d.ts +3 -3
- package/dist/tools/fs/read-deny.d.ts +22 -22
- package/dist/tools/fs/read-face.d.ts +21 -24
- package/dist/tools/fs/repo-map.d.ts +8 -8
- package/dist/tools/fs/safety.d.ts +233 -130
- package/dist/tools/fs/safety.js +131 -31
- package/dist/tools/fs/search.d.ts +63 -71
- package/dist/tools/fs/search.js +8 -6
- package/package.json +6 -2
- package/test/export-surface.snapshot.json +119 -39
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type MemoryAnnouncement } from "./types.js";
|
|
2
|
+
import type { AssertAllKeysHandled } from "../ask-origin.js";
|
|
2
3
|
/** Cursor sidecar for the design/84 Seam B pair on the FileBackend (`{ [scope]: cursor }`). B3: control plane. */
|
|
3
4
|
export declare const CURSORS_FILE = "cursors.json";
|
|
4
5
|
/** The control-plane subdir name under a key dir — ONE spelling for every derivation and for the
|
|
@@ -127,41 +128,126 @@ export declare function scopeDirName(scope: string): string;
|
|
|
127
128
|
* Exported for the layout pins; not part of the package surface.
|
|
128
129
|
*/
|
|
129
130
|
export declare function dirCaseFolds(dir: string): boolean | undefined;
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
131
|
+
/** The closure of every label {@link scopeDirName} can mint: a safe-form scope verbatim, or the
|
|
132
|
+
* folded form (leading `.`/`-` stripped) plus a hash suffix. One non-hidden path segment — never
|
|
133
|
+
* empty, never `.`/`..`, never a separator — so two labels are two distinct directory entries. */
|
|
134
|
+
export declare const SCOPE_DIR_LABEL_RE: RegExp;
|
|
135
|
+
/** Prefix of the case-fold probe files the layout leaves (briefly) at a memory root. One spelling
|
|
136
|
+
* for the probe writer and for the migration's residue removal. */
|
|
137
|
+
export declare const CASEFOLD_PROBE_PREFIX = ".casefold-probe-";
|
|
138
|
+
/** The four shapes a scope registry read can take. */
|
|
139
|
+
export declare const SCOPE_REGISTRY_SHAPES: readonly ["absent", "v1", "v2", "migrating"];
|
|
140
|
+
export type ScopeRegistryShape = (typeof SCOPE_REGISTRY_SHAPES)[number];
|
|
141
|
+
/** Which shapes the path-deriving read faces (`registerScope` / `scopeDirFor` / `registeredScopes`)
|
|
142
|
+
* may serve. `v1` (the pre-v2 file: a root-owning scope, `""` labels) and `migrating` (a v2 file
|
|
143
|
+
* carrying an unfinished move marker) are refused fail-closed: the registry then does not describe
|
|
144
|
+
* where entries physically live until {@link adoptRootScopeLayout} has run to completion. */
|
|
145
|
+
export declare const REGISTRY_SHAPE_DERIVES_PATHS: {
|
|
146
|
+
readonly absent: true;
|
|
147
|
+
readonly v1: false;
|
|
148
|
+
readonly v2: true;
|
|
149
|
+
readonly migrating: false;
|
|
150
|
+
};
|
|
151
|
+
export type DerivesPathsTableCoversEveryRegistryShape = AssertAllKeysHandled<Exclude<ScopeRegistryShape, keyof typeof REGISTRY_SHAPE_DERIVES_PATHS>>;
|
|
152
|
+
/** The unfinished-move marker: the physical root whose loose content is being moved into
|
|
153
|
+
* `<root>/<label>` for `owner`. Durable across crashes; whoever holds the registry lock next
|
|
154
|
+
* finishes it before doing anything else. */
|
|
155
|
+
export interface ScopeLayoutMigratingMarker {
|
|
156
|
+
root: string;
|
|
157
|
+
owner: string;
|
|
158
|
+
label: string;
|
|
159
|
+
}
|
|
160
|
+
/** The v2 registry record. `rootOwner` is the scope that historically owned the memory root; it is
|
|
161
|
+
* consulted only to attribute loose root content during adoption and never derives a path. */
|
|
162
|
+
export interface ScopesRecordV2 {
|
|
163
|
+
v: 2;
|
|
164
|
+
scopes: Record<string, string>;
|
|
165
|
+
rootOwner?: string;
|
|
166
|
+
migrating?: ScopeLayoutMigratingMarker;
|
|
167
|
+
}
|
|
168
|
+
/** A parsed registry, tagged by shape. `v1` keeps the pre-v2 fields for the one-time conversion. */
|
|
169
|
+
export type ScopeRegistryRead = {
|
|
170
|
+
shape: "absent";
|
|
171
|
+
rec: ScopesRecordV2;
|
|
172
|
+
} | {
|
|
173
|
+
shape: "v1";
|
|
174
|
+
rootScope?: string;
|
|
175
|
+
scopes: Record<string, string>;
|
|
176
|
+
} | {
|
|
177
|
+
shape: "v2";
|
|
178
|
+
rec: ScopesRecordV2;
|
|
179
|
+
} | {
|
|
180
|
+
shape: "migrating";
|
|
181
|
+
rec: ScopesRecordV2 & {
|
|
182
|
+
migrating: ScopeLayoutMigratingMarker;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
/** Register `scope` in the durable registry (idempotent) and return its home `<memoryDir>/<label>`.
|
|
186
|
+
* The registered label is the truth for a scope that has one (a home never moves); the
|
|
187
|
+
* {@link scopeDirName} formula mints the label for a never-registered scope. Both collision arms
|
|
188
|
+
* run over the effective labels; the home is created on first registration and its physical form
|
|
189
|
+
* is proven on every call. Lock-serialized; a `v1`/`migrating` registry is refused. */
|
|
157
190
|
export declare function registerScope(memoryDir: string, controlDir: string, scope: string, opts?: {
|
|
158
191
|
caseFoldingFs?: boolean;
|
|
159
192
|
}): string;
|
|
160
|
-
/** All registered scopes →
|
|
193
|
+
/** All registered scopes → label. A `v1`/`migrating` registry is refused. */
|
|
161
194
|
export declare function registeredScopes(controlDir: string): Record<string, string>;
|
|
162
|
-
/** The stable home directory of `scope`'s entry files:
|
|
163
|
-
*
|
|
195
|
+
/** The stable home directory of `scope`'s entry files: `<memoryDir>/<label>`, the REGISTERED label
|
|
196
|
+
* when there is one, the formula otherwise. Registers nothing. A `v1`/`migrating` registry is refused. */
|
|
164
197
|
export declare function scopeDirFor(memoryDir: string, controlDir: string, scope: string): string;
|
|
198
|
+
/** The scope registry's shape as it stands on disk (lock-free, journal-aware). Exported for the
|
|
199
|
+
* backend's cheap pre-check and for the layout pins; not part of the package surface. */
|
|
200
|
+
export declare function scopeRegistryShape(controlDir: string): ScopeRegistryShape;
|
|
201
|
+
/** The v1 path-key resolver (design A6): maps a memory-dir-relative persistent key written under the
|
|
202
|
+
* root-owning layout onto the ledger form `(scope, rel)`. The first segment names a registered
|
|
203
|
+
* non-owner label ⇒ that scope's home; otherwise the key belonged to the root owner. `undefined`
|
|
204
|
+
* when the row cannot be attributed (no root owner on record) — the caller keeps the row in its
|
|
205
|
+
* old form and refuses the operations that depend on it. Reads any registry shape (the conversion
|
|
206
|
+
* is independent of the physical move). */
|
|
207
|
+
export declare function v1MemoryPathKeyResolver(controlDir: string): (relPath: string) => {
|
|
208
|
+
scope: string;
|
|
209
|
+
rel: string;
|
|
210
|
+
} | undefined;
|
|
211
|
+
/** Options of {@link adoptRootScopeLayout}. `ownerCandidate` attributes loose root content when the
|
|
212
|
+
* registry records no root owner (the mount's write scope / a standalone batch's first add scope).
|
|
213
|
+
* `renew` is the caller's outer-lock heartbeat (the backend's transaction lock) — called before
|
|
214
|
+
* every filesystem action and every sidecar write, together with the registry lock's own. */
|
|
215
|
+
export interface AdoptRootScopeLayoutOptions {
|
|
216
|
+
ownerCandidate?: string | null;
|
|
217
|
+
onIncident?: MemoryPartitionIncidentSink;
|
|
218
|
+
renew?: () => void;
|
|
219
|
+
/** The one-time v1 sidecar key conversions, run in the adoption (before any later scope
|
|
220
|
+
* registration can change what a v1 key's first segment names). Each conversion is idempotent
|
|
221
|
+
* and takes its own sidecar lock. */
|
|
222
|
+
convertSidecars?: (controlDir: string) => void;
|
|
223
|
+
}
|
|
224
|
+
/** The lock-free pre-check the backend's public faces ask before a registry-derived path: does the
|
|
225
|
+
* tree at `root` still need the adoption (a v1/migrating registry, or loose content at the root)?
|
|
226
|
+
* One journal-aware registry read plus one readdir; the adoption re-enumerates under the locks. */
|
|
227
|
+
export declare function layoutNeedsAdoption(root: string, controlDir: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Adopt the per-scope layout for the physical tree at `root` (the engine's memory dir, or the
|
|
230
|
+
* backend's directory root; both when they differ — they share one control plane, so the registry
|
|
231
|
+
* conversion happens once). Runs under the registry lock; the caller holds any outer lock. Every
|
|
232
|
+
* step is idempotent and the two-phase marker makes an interrupted move resumable by whoever holds
|
|
233
|
+
* the lock next:
|
|
234
|
+
* 0. registry shape: `absent` ⇒ an empty v2 record; `v1` ⇒ v2 with `rootOwner` = the old
|
|
235
|
+
* `rootScope` (the root owner is also given its label); `migrating` ⇒ that move is finished
|
|
236
|
+
* FIRST, whichever tree it names. The root's loose content is enumerated on every call — a v2
|
|
237
|
+
* registry proves nothing about THIS tree.
|
|
238
|
+
* 1. loose content ⇒ owner = `rootOwner ?? ownerCandidate`; neither ⇒ `memory.layout_unowned_root_content`
|
|
239
|
+
* (names capped), registry converted, nothing moved.
|
|
240
|
+
* 2. pre-checks, zero writes: the control plane inside the root; the owner's home a link/file, or
|
|
241
|
+
* a real non-empty directory without a marker for it; any loose name already present in the
|
|
242
|
+
* home — each refuses with {@link ControlPlaneCorruptError}.
|
|
243
|
+
* 3. commit A: the v2 record with the owner registered, `rootOwner`, and the `migrating` marker.
|
|
244
|
+
* 4. move: per entry, lstat the destination (absent ⇒ rename; present ⇒ refuse; source gone ⇒
|
|
245
|
+
* already moved); probe residue removed. No sidecar key and no index text is rewritten (the
|
|
246
|
+
* ledger form keys are location-free; the index heals through its rebuild law).
|
|
247
|
+
* 5. `index-revs.json` cleared (fail-open snapshot; the next rebuild keeps model wording once).
|
|
248
|
+
* 6. commit B: the marker removed; `memory.layout_migrated` disclosed.
|
|
249
|
+
*/
|
|
250
|
+
export declare function adoptRootScopeLayout(rootPath: string, controlDir: string, opts?: AdoptRootScopeLayoutOptions): void;
|
|
165
251
|
/** Canonicalize a path for containment checks (resolves symlinks on the EXISTING prefix). */
|
|
166
252
|
export declare function canonicalize(p: string): string;
|
|
167
253
|
/** True iff `child` (canonicalized) is `root` or inside it. */
|
|
@@ -297,7 +383,10 @@ export declare function enqueueMemoryAnnouncement(controlDir: string, ann: Memor
|
|
|
297
383
|
export declare function drainMemoryAnnouncements(controlDir: string): AnnouncementsRecord;
|
|
298
384
|
/** Test/observability peek (journal-aware, non-destructive). */
|
|
299
385
|
export declare function peekMemoryAnnouncements(controlDir: string): AnnouncementsRecord;
|
|
300
|
-
/**
|
|
386
|
+
/** The fuse key for a memory file: the ledger form `(scope, rel)` (`rel` relative to the scope's
|
|
387
|
+
* home, `/`-separated) — location-free, so a home move never re-keys a count. */
|
|
388
|
+
export declare function scanFuseKey(scope: string, rel: string): string;
|
|
389
|
+
/** S2-C — record one write-time scan rejection for `key` ({@link scanFuseKey}); returns the count
|
|
301
390
|
* BEFORE this bump (callers mute the feedback when it is already ≥ {@link SCAN_FUSE_THRESHOLD}). */
|
|
302
391
|
export declare function bumpScanFuse(controlDir: string, key: string): number;
|
|
303
392
|
export declare function readIndexRevs(controlDir: string): Record<string, string>;
|
|
@@ -816,48 +905,57 @@ export declare function recordChallengedHistory(controlDir: string, rows: Readon
|
|
|
816
905
|
/** Journal-aware read (observability/tests only — no engine consumer exists, on purpose). */
|
|
817
906
|
export declare function readChallengedHistory(controlDir: string): Record<string, ChallengedHistoryRow>;
|
|
818
907
|
export declare const PROJECTION_DEBTS_FILE = "projection-debts.json";
|
|
819
|
-
/** One standing debt: the plane file at `
|
|
820
|
-
* committed entry `entryId`, whose id write-back has not landed; `rev`
|
|
821
|
-
* was staged against (the CAS baseline a reconciling harvest hands its
|
|
908
|
+
/** One standing debt: the plane file at `(scope, rel)` — `rel` relative to the scope's home,
|
|
909
|
+
* `/`-separated — belongs to committed entry `entryId`, whose id write-back has not landed; `rev`
|
|
910
|
+
* is the rev the projection was staged against (the CAS baseline a reconciling harvest hands its
|
|
911
|
+
* update). The key is the ledger form: location-free, so a home move never re-keys a row. */
|
|
822
912
|
export interface ProjectionDebtRow {
|
|
823
|
-
|
|
913
|
+
scope: string;
|
|
914
|
+
rel: string;
|
|
824
915
|
entryId: string;
|
|
825
916
|
rev: string;
|
|
826
917
|
at: number;
|
|
827
918
|
}
|
|
828
|
-
/** WRITE-AHEAD staging. Upsert discipline
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
* integrity. */
|
|
919
|
+
/** WRITE-AHEAD staging. Upsert discipline: a stage lands only when the seat has NO standing row,
|
|
920
|
+
* the standing row is the stager's OWN entry (a rev refresh), or the standing row is the entry the
|
|
921
|
+
* stager itself just judged stale (`replaces` — the same-harvest stale-then-remint lane). It never
|
|
922
|
+
* blindly replaces ANOTHER writer's protection: a lagging process that validated an old row before
|
|
923
|
+
* pausing must not overwrite the row a faster sibling staged at the same seat (its own commit then
|
|
924
|
+
* CAS-conflicts and its tuple-keyed clear misses the survivor — the account converges instead of
|
|
925
|
+
* emptying). Called before the backend transaction; the caller degrades LOUDLY (report warning)
|
|
926
|
+
* on a refused stage rather than refusing the harvest — the ledger is duplicate-admission
|
|
927
|
+
* protection, not the commit's integrity. */
|
|
838
928
|
export declare function stageProjectionDebts(controlDir: string, rows: ReadonlyArray<{
|
|
839
|
-
|
|
929
|
+
scope: string;
|
|
930
|
+
rel: string;
|
|
840
931
|
entryId: string;
|
|
841
932
|
rev: string;
|
|
842
933
|
replaces?: string;
|
|
843
934
|
}>, now: () => number): {
|
|
844
935
|
refused: Array<{
|
|
845
|
-
|
|
936
|
+
scope: string;
|
|
937
|
+
rel: string;
|
|
846
938
|
entryId: string;
|
|
847
939
|
}>;
|
|
848
940
|
};
|
|
849
|
-
/** Settle (remove) rows by ROW IDENTITY — (
|
|
941
|
+
/** Settle (remove) rows by ROW IDENTITY — (scope, rel, entryId), never the bare seat: the write-back
|
|
850
942
|
* landed, the staged claim turned out stale, or a materialize re-projected the seat. Identity
|
|
851
|
-
* matters
|
|
852
|
-
*
|
|
853
|
-
* Y's write-back failed — a path-keyed drop would erase Y and re-open the duplicate window; same
|
|
854
|
-
* shape across processes for a lagging sibling's clear). Missing rows are a no-op (idempotent). */
|
|
943
|
+
* matters: a stale-clear judged against an OLD row must not delete the NEWER row a later staging
|
|
944
|
+
* upserted at the same seat. Missing rows are a no-op (idempotent). */
|
|
855
945
|
export declare function settleProjectionDebts(controlDir: string, rows: ReadonlyArray<{
|
|
856
|
-
|
|
946
|
+
scope: string;
|
|
947
|
+
rel: string;
|
|
857
948
|
entryId: string;
|
|
858
949
|
}>): void;
|
|
859
|
-
/** Strict read (ENOENT ⇒ empty; corrupt ⇒ throws — the caller's fail-closed arm owns the refusal).
|
|
950
|
+
/** Strict read (ENOENT ⇒ empty; corrupt ⇒ throws — the caller's fail-closed arm owns the refusal).
|
|
951
|
+
* A v1 record is converted in the ledger's lock on this first read. Rows the registry
|
|
952
|
+
* could not attribute stay on the record's `unresolved` seat and are not served. */
|
|
860
953
|
export declare function readProjectionDebts(controlDir: string): ProjectionDebtRow[];
|
|
954
|
+
/** The rows a key-form conversion could not attribute (audit read; empty on a converted ledger). */
|
|
955
|
+
export declare function unresolvedProjectionDebts(controlDir: string): Array<{
|
|
956
|
+
relPath: string;
|
|
957
|
+
entryId: string;
|
|
958
|
+
}>;
|
|
861
959
|
/**
|
|
862
960
|
* REF-C6 — write EVERY byte of `data` to `fd`, looping until the OS has taken all of them.
|
|
863
961
|
*
|