@sema-agent/server 7.140.0 → 7.142.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/MIGRATION.md +505 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +142 -25
- package/dist/approval-ask-audit-store.d.ts +54 -38
- package/dist/approval-ask-audit-store.js +58 -39
- package/dist/approval-batch-census.d.ts +27 -0
- package/dist/approval-batch-census.js +27 -0
- package/dist/approval-card.d.ts +39 -24
- package/dist/approval-card.js +6 -3
- package/dist/approval-crash-convergence.d.ts +17 -7
- package/dist/approval-crash-convergence.js +94 -22
- package/dist/approval-deny-reasons.d.ts +34 -30
- package/dist/approval-deny-reasons.js +21 -6
- package/dist/approval-policy-settlement.d.ts +1 -1
- package/dist/approval-reconciler.d.ts +33 -1
- package/dist/approval-reconciler.js +43 -40
- package/dist/approval.d.ts +15 -0
- package/dist/approval.js +10 -0
- package/dist/audit.d.ts +4 -2
- package/dist/audit.js +2 -2
- package/dist/auth-bridge.d.ts +9 -6
- package/dist/auth-bridge.js +9 -3
- package/dist/boot/adoption.js +2 -1
- package/dist/boot/budget-tracing.d.ts +16 -0
- package/dist/boot/budget-tracing.js +10 -6
- package/dist/boot/device-lane.d.ts +11 -0
- package/dist/boot/device-lane.js +16 -0
- package/dist/boot/engine-lease.d.ts +24 -3
- package/dist/boot/engine-lease.js +9 -2
- package/dist/boot/execution-env.d.ts +24 -4
- package/dist/boot/execution-env.js +34 -27
- package/dist/boot/execution-lane.js +2 -1
- package/dist/boot/exit-boundary.js +5 -4
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-consolidation.d.ts +1 -1
- package/dist/boot/memory-consolidation.js +3 -2
- package/dist/boot/parked-revive-gate.js +2 -1
- package/dist/boot/permission-rules-audit.d.ts +0 -28
- package/dist/boot/permission-rules-audit.js +2 -1
- package/dist/boot/read-deny-anchor-audit.js +2 -1
- package/dist/boot/reapers.d.ts +2 -2
- package/dist/boot/reapers.js +4 -3
- package/dist/boot/resolve-spec.js +18 -6
- package/dist/boot/retention-lane.js +5 -3
- package/dist/boot/runner-deps.js +16 -13
- package/dist/boot/runtime-caps.js +3 -2
- package/dist/boot/session-faces.d.ts +1 -1
- package/dist/boot/session-faces.js +8 -6
- package/dist/boot/shutdown.js +8 -2
- package/dist/boot/stage-04-stores.js +3 -2
- package/dist/boot/stage-05-execution-env.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.js +11 -7
- package/dist/boot/stage-06-runners.d.ts +1 -3
- package/dist/boot/stage-06-runners.js +3 -2
- package/dist/boot/stage-07-capability-layer.d.ts +1 -2
- package/dist/boot/stage-07-capability-layer.js +10 -11
- package/dist/boot/stage-08-reapers.d.ts +1 -2
- package/dist/boot/stage-08-reapers.js +3 -2
- package/dist/boot/stage-09-leader.d.ts +1 -2
- package/dist/boot/stage-10-http-server.d.ts +1 -2
- package/dist/boot/stage-10-http-server.js +6 -4
- package/dist/boot/stores.js +13 -6
- package/dist/boot/web-admin.js +18 -17
- package/dist/boot/webfetch-summarize-lane.js +2 -1
- package/dist/boot/workflow-orchestration.js +3 -2
- package/dist/capabilities/builtin-tools.d.ts +2 -1
- package/dist/capabilities/builtin-tools.js +2 -4
- package/dist/capabilities/composite-members.d.ts +2 -1
- package/dist/capabilities/composite-members.js +2 -1
- package/dist/capabilities/scenarios.d.ts +1 -1
- package/dist/capability-facts.d.ts +33 -0
- package/dist/capability-facts.js +32 -0
- package/dist/card-void.d.ts +38 -0
- package/dist/card-void.js +23 -0
- package/dist/config-catalog.js +12 -8
- package/dist/config-provider.d.ts +13 -13
- package/dist/config-provider.js +19 -33
- package/dist/config-types.d.ts +39 -10
- package/dist/config.d.ts +6 -0
- package/dist/config.js +72 -49
- package/dist/delegated-session-owner.d.ts +21 -19
- package/dist/delegated-session-owner.js +1 -1
- package/dist/device-store.d.ts +7 -0
- package/dist/device-store.js +3 -0
- package/dist/execution-config-root.d.ts +22 -0
- package/dist/execution-config-root.js +35 -0
- package/dist/execution-lane-caps.d.ts +50 -2
- package/dist/execution-lane-caps.js +90 -13
- package/dist/execution-placement.d.ts +3 -0
- package/dist/execution-placement.js +7 -0
- package/dist/fleet/drain-entry.d.ts +3 -0
- package/dist/fleet/fleet-bus.d.ts +6 -3
- package/dist/hooks/hook-runner.d.ts +6 -0
- package/dist/hooks/hook-runner.js +30 -1
- package/dist/hosted-posture.d.ts +8 -0
- package/dist/hosted-posture.js +4 -0
- package/dist/http/admission.js +3 -3
- package/dist/http/caller-trust.d.ts +3 -2
- package/dist/http/caller-trust.js +2 -1
- package/dist/http/dispatch.js +8 -2
- package/dist/http/execution-context.d.ts +2 -2
- package/dist/http/idempotency.d.ts +1 -1
- package/dist/http/live-frame.d.ts +24 -0
- package/dist/http/live-frame.js +16 -0
- package/dist/http/principal-gate.d.ts +3 -1
- package/dist/http/principal-gate.js +17 -8
- package/dist/http/resume-legs.js +42 -29
- package/dist/http/route-table.js +4 -0
- package/dist/http/routes/approvals-assistant.js +1 -0
- package/dist/http/routes/attachments.js +18 -0
- package/dist/http/routes/capabilities.js +10 -6
- package/dist/http/routes/diagnostics.d.ts +0 -19
- package/dist/http/routes/diagnostics.js +16 -2
- package/dist/http/routes/memory-bundle.d.ts +2 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-policy.js +27 -7
- package/dist/http/routes/run-permission-mode.d.ts +75 -0
- package/dist/http/routes/run-permission-mode.js +170 -0
- package/dist/http/routes/runs.js +3 -3
- package/dist/http/routes/session-memory-sync.d.ts +63 -0
- package/dist/http/routes/session-memory-sync.js +157 -0
- package/dist/http/routes/session-sync.d.ts +3 -6
- package/dist/http/routes/session-sync.js +7 -2
- package/dist/http/routes/sessions-list.d.ts +2 -1
- package/dist/http/routes/sessions.js +5 -4
- package/dist/http/routes/tasks.js +70 -71
- package/dist/http/run-read-face.d.ts +7 -0
- package/dist/http/run-read-face.js +10 -4
- package/dist/http/send.d.ts +6 -1
- package/dist/http/send.js +10 -3
- package/dist/http/server.d.ts +20 -7
- package/dist/http/server.js +2 -4
- package/dist/http/sse-log.d.ts +3 -8
- package/dist/http/stored-body-replay.d.ts +3 -3
- package/dist/http/stored-body-replay.js +3 -1
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +2 -2
- package/dist/http/sync-submit-body.d.ts +21 -4
- package/dist/http/sync-submit-body.js +13 -0
- package/dist/identity-source.d.ts +21 -2
- package/dist/identity-source.js +6 -0
- package/dist/instruction-source-notice.d.ts +7 -0
- package/dist/instruction-source-notice.js +6 -6
- package/dist/mcp-assertion-header.d.ts +4 -0
- package/dist/mcp-assertion-header.js +5 -0
- package/dist/memory-incident-sink.d.ts +19 -6
- package/dist/memory-incident-sink.js +8 -4
- package/dist/memory-posture.d.ts +1 -1
- package/dist/memory-scope.d.ts +4 -4
- package/dist/memory-scope.js +1 -1
- package/dist/memory-sync-client.d.ts +35 -23
- package/dist/memory-sync-client.js +122 -52
- package/dist/memory-sync-identity.d.ts +24 -0
- package/dist/memory-sync-identity.js +57 -0
- package/dist/memory-sync.d.ts +7 -1
- package/dist/memory-sync.js +6 -3
- package/dist/observability/fail-open.d.ts +57 -12
- package/dist/observability/fail-open.js +50 -9
- package/dist/observability/metrics.js +0 -1
- package/dist/observability/run-terminal.d.ts +93 -31
- package/dist/observability/run-terminal.js +175 -171
- package/dist/observability/secret-env-scrub.d.ts +20 -1
- package/dist/observability/secret-env-scrub.js +14 -0
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -2
- package/dist/orchestration/workflow-completion-inbox.js +13 -5
- package/dist/orchestration/workflow-notify-journal.d.ts +5 -3
- package/dist/orchestration/workflow-notify-journal.js +2 -1
- package/dist/permission-mode-admission.d.ts +68 -0
- package/dist/permission-mode-admission.js +23 -0
- package/dist/permission-rule-list.d.ts +55 -6
- package/dist/permission-rule-list.js +52 -5
- package/dist/plugins/approval-ask-store-file.d.ts +14 -4
- package/dist/plugins/approval-ask-store-file.js +48 -7
- package/dist/plugins/approval-ask-store-memory.d.ts +2 -1
- package/dist/plugins/approval-ask-store-memory.js +9 -8
- package/dist/plugins/approval-ask-store-sql.d.ts +42 -10
- package/dist/plugins/approval-ask-store-sql.js +49 -19
- package/dist/plugins/caching-session-store.d.ts +6 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +65 -17
- package/dist/plugins/checkpoint-store-sql.js +74 -3
- package/dist/plugins/device-store-sql.d.ts +5 -2
- package/dist/plugins/device-store-sql.js +4 -1
- package/dist/plugins/execution-placement-sql.d.ts +11 -1
- package/dist/plugins/execution-placement-sql.js +12 -1
- package/dist/plugins/file-run-store.d.ts +7 -2
- package/dist/plugins/file-run-store.js +12 -2
- package/dist/plugins/fork-routing-session-store.d.ts +10 -32
- package/dist/plugins/fork-routing-session-store.js +2 -61
- package/dist/plugins/k8s-exec-protocol.d.ts +4 -1
- package/dist/plugins/k8s-exec-protocol.js +6 -1
- package/dist/plugins/local-checkpoint-store.d.ts +10 -1
- package/dist/plugins/local-checkpoint-store.js +22 -0
- package/dist/plugins/local-session-store.d.ts +260 -39
- package/dist/plugins/local-session-store.js +582 -57
- package/dist/plugins/local-session-window.d.ts +17 -3
- package/dist/plugins/local-session-window.js +7 -13
- package/dist/plugins/local-task-attachment-store.d.ts +12 -2
- package/dist/plugins/local-task-attachment-store.js +67 -43
- package/dist/plugins/memory-key-guards.d.ts +3 -3
- package/dist/plugins/memory-run-store.d.ts +7 -2
- package/dist/plugins/memory-run-store.js +12 -2
- package/dist/plugins/one-time-migrations.d.ts +68 -2
- package/dist/plugins/one-time-migrations.js +120 -4
- package/dist/plugins/pg-pool.js +3 -2
- package/dist/plugins/pg-session-storage.d.ts +2 -0
- package/dist/plugins/pg-session-storage.js +3 -2
- package/dist/plugins/remote-env-e2b.d.ts +47 -7
- package/dist/plugins/remote-env-e2b.js +242 -46
- package/dist/plugins/remote-env-k8s.d.ts +51 -6
- package/dist/plugins/remote-env-k8s.js +234 -44
- package/dist/plugins/remote-env-local-docker.d.ts +40 -14
- package/dist/plugins/remote-env-local-docker.js +127 -33
- package/dist/plugins/run-store-sql.d.ts +11 -3
- package/dist/plugins/run-store-sql.js +13 -4
- package/dist/plugins/sandbox-read-floor.d.ts +273 -0
- package/dist/plugins/sandbox-read-floor.js +608 -0
- package/dist/plugins/session-ownership.d.ts +2 -1
- package/dist/plugins/session-placement.d.ts +17 -4
- package/dist/plugins/session-placement.js +2 -1
- package/dist/plugins/session-store.d.ts +18 -20
- package/dist/plugins/session-store.js +4 -12
- package/dist/plugins/store-backend.d.ts +41 -7
- package/dist/plugins/store-backend.js +22 -4
- package/dist/plugins/store-contracts.d.ts +35 -3
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +112 -14
- package/dist/plugins/task-attachment-store.js +221 -28
- package/dist/plugins/tidb-pool.js +2 -1
- package/dist/plugins/tidb-session-store.d.ts +4 -1
- package/dist/plugins/tidb-session-store.js +3 -2
- package/dist/plugins/workspace-fill.d.ts +60 -0
- package/dist/plugins/workspace-fill.js +106 -0
- package/dist/project-bundle.d.ts +38 -0
- package/dist/project-bundle.js +609 -0
- package/dist/run-cancel-context.d.ts +34 -0
- package/dist/run-cancel-context.js +7 -0
- package/dist/run-local.js +2 -8
- package/dist/runs.d.ts +39 -12
- package/dist/runs.js +69 -55
- package/dist/sandbox-egress-policy.d.ts +4 -1
- package/dist/sandbox-egress-policy.js +3 -1
- package/dist/sandbox-git-plane.d.ts +31 -12
- package/dist/sandbox-git-plane.js +24 -4
- package/dist/security.d.ts +11 -2
- package/dist/security.js +8 -0
- package/dist/server-secret-env.d.ts +2 -1
- package/dist/server-secret-env.js +2 -4
- package/dist/session-error-wire.d.ts +46 -4
- package/dist/session-error-wire.js +23 -0
- package/dist/session-incarnation.d.ts +9 -3
- package/dist/session-sync-kernel.d.ts +42 -1
- package/dist/session-sync-kernel.js +17 -0
- package/dist/session-sync.js +16 -4
- package/dist/sql-engine-coordinates.d.ts +49 -0
- package/dist/sql-engine-coordinates.js +27 -0
- package/dist/standing-answer-grant.d.ts +31 -2
- package/dist/standing-answer-grant.js +14 -2
- package/dist/store-posture.d.ts +1 -1
- package/dist/task-a2a.d.ts +1 -1
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-settings.d.ts +62 -27
- package/dist/task-settings.js +105 -29
- package/dist/terminal.d.ts +97 -20
- package/dist/terminal.js +107 -18
- package/dist/tool-approval.d.ts +4 -3
- package/dist/tool-approval.js +12 -14
- package/dist/trace/core-keyset-guard.d.ts +196 -2
- package/dist/trace/engine-notice-wire.d.ts +8 -2
- package/dist/trace/engine-notice-wire.js +4 -2
- package/dist/trace/exit-seat.d.ts +9 -1
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/ledger-sink.d.ts +8 -4
- package/dist/trace/ledger-sink.js +2 -2
- package/dist/trace/model-segment.d.ts +2 -2
- package/dist/trace/project.d.ts +18 -1
- package/dist/trace/project.js +16 -0
- package/dist/trace/redact.js +323 -90
- package/dist/trace/self-minted-wire.d.ts +419 -4
- package/dist/trace/self-minted-wire.js +145 -0
- package/dist/trace/wire-projection-faces.d.ts +1 -1
- package/dist/trace/wire-projection-faces.js +1 -1
- package/dist/verifier-pause-card.d.ts +8 -0
- package/dist/verifier-pause-card.js +19 -0
- package/dist/web-admin-client/apply-effective.d.ts +5 -7
- package/dist/web-admin-client/apply-effective.js +22 -2
- package/dist/web-admin-client/candidate-gate.d.ts +1 -1
- package/dist/web-admin-client/effective-keys.js +2 -0
- package/dist/web-admin-client/read-warnings.d.ts +2 -2
- package/dist/web-admin-client/types.d.ts +4 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +3 -2
- package/package.json +2 -2
- package/wire-changes/server@7.141.0.json +367 -0
- package/wire-changes/server@7.142.0.json +639 -0
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
* branch below the floor — so the record the engine reads is the one the run's walk reaches.
|
|
17
17
|
* Read-only: the log is read once (`exportEntries`, pure), no append log is opened, and the window refuses writes.
|
|
18
18
|
*
|
|
19
|
+
* ## The metadata is the store's, not the archive's
|
|
20
|
+
* Both halves come from the local session store ({@link LocalSessionRows}) — this module opens no repo of its own. The metadata is the
|
|
21
|
+
* store's one projection of the session's row (`LocalSessionStore.sessionMetadataOf`: owner, creation time and fork lineage read from the
|
|
22
|
+
* session-meta cell, the same projection the store hands the engine), never the archive header's copy — an archive rebuilt by a log swap
|
|
23
|
+
* keeps the row's creation time. The log is the store's export of the archive.
|
|
24
|
+
*
|
|
19
25
|
* ## Cost: one linear walk, the engine's
|
|
20
26
|
* The branch is core's own `getPathToRoot` over the whole log (the walk every engine read of a local session makes, with its stop
|
|
21
27
|
* rules: an entry without a parent ends it, a parent the log does not hold is `invalid_session`, an unknown leaf is `not_found`).
|
|
@@ -29,7 +35,15 @@
|
|
|
29
35
|
* by `getPathToRoot` and the run's resume ancestor scan (the two walks core 7.54.1 guards; this module has no walker of its own left).
|
|
30
36
|
* Pinned in `test/session-log-parent-cycle.test.ts`.
|
|
31
37
|
*/
|
|
32
|
-
import { BaseSessionStorage } from "@sema-agent/core";
|
|
38
|
+
import { BaseSessionStorage, type SessionMetadata, type SessionTreeEntry } from "@sema-agent/core";
|
|
39
|
+
/**
|
|
40
|
+
* What the window reads, and from whom: the local session store's row projection and its export of the log (`LocalSessionStore` is the one
|
|
41
|
+
* implementation; `store-backend.ts#localSessionRowsOf` hands it out). `undefined` / `null` = no such session.
|
|
42
|
+
*/
|
|
43
|
+
export interface LocalSessionRows {
|
|
44
|
+
sessionMetadataOf(sessionId: string): Promise<SessionMetadata | undefined>;
|
|
45
|
+
exportEntries(sessionId: string): Promise<SessionTreeEntry[] | null>;
|
|
46
|
+
}
|
|
33
47
|
export declare class LocalSessionWindow extends BaseSessionStorage {
|
|
34
48
|
/** The branch below the floor, root first (empty when the window is the whole branch). */
|
|
35
49
|
private readonly below;
|
|
@@ -39,7 +53,7 @@ export declare class LocalSessionWindow extends BaseSessionStorage {
|
|
|
39
53
|
/** `SessionStorage.getEpochAnchor?()` — the nearest carrier on the branch below the floor, as stored ({@link scanEpochAnchor}).
|
|
40
54
|
* A row's `seq` is its position on the branch; the whole branch is in memory, so one page holds every row. */
|
|
41
55
|
getEpochAnchor(): Promise<unknown>;
|
|
42
|
-
/** Wake the window of `sessionId`
|
|
43
|
-
static wake(
|
|
56
|
+
/** Wake the window of `sessionId` from the local session store's rows; `null` if there is no such session. */
|
|
57
|
+
static wake(rows: LocalSessionRows, sessionId: string): Promise<LocalSessionWindow | null>;
|
|
44
58
|
}
|
|
45
59
|
//# sourceMappingURL=local-session-window.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseSessionStorage, InMemorySessionStorage, SessionError, boundedTail } from "@sema-agent/core";
|
|
2
|
-
import { createLocalSessionRepo } from "./local-session-store.js";
|
|
3
2
|
import { scanEpochAnchor } from "./session-epoch-anchor.js";
|
|
4
3
|
export class LocalSessionWindow extends BaseSessionStorage {
|
|
5
4
|
below;
|
|
@@ -16,18 +15,13 @@ export class LocalSessionWindow extends BaseSessionStorage {
|
|
|
16
15
|
async getEpochAnchor() {
|
|
17
16
|
return scanEpochAnchor(this.below.length, async (beforeSeq) => this.below.slice(0, beforeSeq).map((entry, seq) => ({ seq, entry })).reverse(), (row) => row.entry);
|
|
18
17
|
}
|
|
19
|
-
static async wake(
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (e.code === "not_found")
|
|
27
|
-
return null;
|
|
28
|
-
throw e;
|
|
29
|
-
}
|
|
30
|
-
const metadata = (await repo.list()).find((m) => m.id === sessionId) ?? { id: sessionId, createdAt: new Date().toISOString() };
|
|
18
|
+
static async wake(rows, sessionId) {
|
|
19
|
+
const log = await rows.exportEntries(sessionId);
|
|
20
|
+
if (log === null)
|
|
21
|
+
return null;
|
|
22
|
+
const metadata = await rows.sessionMetadataOf(sessionId);
|
|
23
|
+
if (metadata === undefined)
|
|
24
|
+
return null;
|
|
31
25
|
const whole = new InMemorySessionStorage({ entries: log });
|
|
32
26
|
const leafId = await whole.getLeafId();
|
|
33
27
|
const branch = await whole.getPathToRoot(leafId);
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import { type TaskAttachmentStore, type TaskAttachmentRecord } from "./task-attachment-store.js";
|
|
1
|
+
import { type AttachmentStoreBindOutcome, type TaskAttachmentStore, type TaskAttachmentRecord } from "./task-attachment-store.js";
|
|
2
2
|
export declare class LocalTaskAttachmentStore implements TaskAttachmentStore {
|
|
3
3
|
private readonly dir;
|
|
4
4
|
private metas;
|
|
5
5
|
private hydration;
|
|
6
|
+
/** 变更串行段的尾(见 `serialized`):每只变更口排在上一只的落盘与合回之后。本店唯一一只。 */
|
|
7
|
+
private mutationTail;
|
|
6
8
|
constructor(rootDir: string);
|
|
7
9
|
private hydrate;
|
|
10
|
+
/**
|
|
11
|
+
* 本店**唯一**的变更串行段:凡改 `this.metas` 或删盘上行的口(put / bind / delete / deleteBySession / reapUnbound)把**整条操作**
|
|
12
|
+
* (判 + 落盘 + 合回内存)交进来,于是任何一只变更口都观察不到别的变更口做到一半的中间态 —— bind 落盘期间「副本已判、内存未合」
|
|
13
|
+
* 的那一段,收割 / 删除既不会判到旧内存、也不会把盘上正在落的行删掉。读口不进来:它们只读内存,不排队。
|
|
14
|
+
* 一只变更失败不堵后面的(尾巴吞掉失败,错原样上抛给它自己的调用方)。操作体里不得再调 `serialized`(会排在自己后面)。
|
|
15
|
+
*/
|
|
16
|
+
private serialized;
|
|
8
17
|
put(rec: TaskAttachmentRecord & {
|
|
9
18
|
content: Uint8Array;
|
|
10
19
|
}): Promise<void>;
|
|
11
20
|
get(owner: string, id: string): Promise<TaskAttachmentRecord | null>;
|
|
12
21
|
getContent(owner: string, id: string): Promise<Uint8Array | null>;
|
|
13
22
|
private persistMeta;
|
|
14
|
-
bind(owner: string, ids: string[], sessionId: string, boundAtMs: number): Promise<
|
|
23
|
+
bind(owner: string, ids: readonly string[], sessionId: string, boundAtMs: number): Promise<AttachmentStoreBindOutcome>;
|
|
15
24
|
listBySession(sessionId: string): Promise<TaskAttachmentRecord[]>;
|
|
25
|
+
/** 删一行(meta + bytes + 内存索引)。只在 `serialized` 的操作体里调用。 */
|
|
16
26
|
private removeRow;
|
|
17
27
|
delete(owner: string, id: string): Promise<boolean>;
|
|
18
28
|
deleteBySession(sessionId: string): Promise<number>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fsp } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { TaskAttachmentRecordSchema } from "./task-attachment-store.js";
|
|
3
|
+
import { bindRowsInProcess, TaskAttachmentRecordSchema } from "./task-attachment-store.js";
|
|
4
4
|
import { createZodColumnReader, decodeJsonColumn } from "./sql-json-column.js";
|
|
5
5
|
const ID_RE = /^[0-9a-f-]{16,64}$/i;
|
|
6
6
|
const readAttachmentMeta = createZodColumnReader(TaskAttachmentRecordSchema);
|
|
@@ -8,6 +8,7 @@ export class LocalTaskAttachmentStore {
|
|
|
8
8
|
dir;
|
|
9
9
|
metas;
|
|
10
10
|
hydration;
|
|
11
|
+
mutationTail = Promise.resolve();
|
|
11
12
|
constructor(rootDir) {
|
|
12
13
|
this.dir = join(rootDir, "attachments");
|
|
13
14
|
}
|
|
@@ -37,17 +38,24 @@ export class LocalTaskAttachmentStore {
|
|
|
37
38
|
})();
|
|
38
39
|
return this.hydration;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
serialized(op) {
|
|
42
|
+
const run = this.mutationTail.then(op);
|
|
43
|
+
this.mutationTail = run.then(() => undefined, () => undefined);
|
|
44
|
+
return run;
|
|
45
|
+
}
|
|
46
|
+
put(rec) {
|
|
47
|
+
return this.serialized(async () => {
|
|
48
|
+
const metas = await this.hydrate();
|
|
49
|
+
await fsp.mkdir(this.dir, { recursive: true });
|
|
50
|
+
const { content, ...meta } = rec;
|
|
51
|
+
const binTmp = join(this.dir, `${rec.id}.bin.tmp`);
|
|
52
|
+
const metaTmp = join(this.dir, `${rec.id}.json.tmp`);
|
|
53
|
+
await fsp.writeFile(binTmp, Buffer.from(content));
|
|
54
|
+
await fsp.rename(binTmp, join(this.dir, `${rec.id}.bin`));
|
|
55
|
+
await fsp.writeFile(metaTmp, JSON.stringify(meta));
|
|
56
|
+
await fsp.rename(metaTmp, join(this.dir, `${rec.id}.json`));
|
|
57
|
+
metas.set(rec.id, { ...meta });
|
|
58
|
+
});
|
|
51
59
|
}
|
|
52
60
|
async get(owner, id) {
|
|
53
61
|
const m = (await this.hydrate()).get(id);
|
|
@@ -69,19 +77,29 @@ export class LocalTaskAttachmentStore {
|
|
|
69
77
|
await fsp.writeFile(tmp, JSON.stringify(m));
|
|
70
78
|
await fsp.rename(tmp, join(this.dir, `${m.id}.json`));
|
|
71
79
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
bind(owner, ids, sessionId, boundAtMs) {
|
|
81
|
+
return this.serialized(async () => {
|
|
82
|
+
const metas = await this.hydrate();
|
|
83
|
+
const draft = new Map(metas);
|
|
84
|
+
for (const id of new Set(ids)) {
|
|
85
|
+
const row = metas.get(id);
|
|
86
|
+
if (row !== undefined)
|
|
87
|
+
draft.set(id, { ...row });
|
|
88
|
+
}
|
|
89
|
+
const { outcome, claimed } = bindRowsInProcess(draft, owner, ids, sessionId, boundAtMs);
|
|
90
|
+
const landed = [];
|
|
91
|
+
try {
|
|
92
|
+
for (const m of claimed) {
|
|
93
|
+
await this.persistMeta(m);
|
|
94
|
+
landed.push(m);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
for (const m of landed)
|
|
99
|
+
metas.set(m.id, m);
|
|
100
|
+
}
|
|
101
|
+
return outcome;
|
|
102
|
+
});
|
|
85
103
|
}
|
|
86
104
|
async listBySession(sessionId) {
|
|
87
105
|
const metas = await this.hydrate();
|
|
@@ -95,26 +113,32 @@ export class LocalTaskAttachmentStore {
|
|
|
95
113
|
await fsp.rm(join(this.dir, `${id}.bin`), { force: true });
|
|
96
114
|
this.metas?.delete(id);
|
|
97
115
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
delete(owner, id) {
|
|
117
|
+
return this.serialized(async () => {
|
|
118
|
+
const m = (await this.hydrate()).get(id);
|
|
119
|
+
if (!m || m.owner !== owner)
|
|
120
|
+
return false;
|
|
121
|
+
await this.removeRow(id);
|
|
122
|
+
return true;
|
|
123
|
+
});
|
|
104
124
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
deleteBySession(sessionId) {
|
|
126
|
+
return this.serialized(async () => {
|
|
127
|
+
const metas = await this.hydrate();
|
|
128
|
+
const hit = [...metas.values()].filter((m) => m.sessionId === sessionId);
|
|
129
|
+
for (const m of hit)
|
|
130
|
+
await this.removeRow(m.id);
|
|
131
|
+
return hit.length;
|
|
132
|
+
});
|
|
111
133
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
134
|
+
reapUnbound(olderThanMs) {
|
|
135
|
+
return this.serialized(async () => {
|
|
136
|
+
const metas = await this.hydrate();
|
|
137
|
+
const hit = [...metas.values()].filter((m) => m.sessionId === undefined && m.createdAtMs < olderThanMs);
|
|
138
|
+
for (const m of hit)
|
|
139
|
+
await this.removeRow(m.id);
|
|
140
|
+
return hit.length;
|
|
141
|
+
});
|
|
118
142
|
}
|
|
119
143
|
}
|
|
120
144
|
//# sourceMappingURL=local-task-attachment-store.js.map
|
|
@@ -15,9 +15,9 @@ export declare const MEMORY_SLUG_COLUMN_CHARS = 512;
|
|
|
15
15
|
* sync_cursor/push_queue/history)。`formatUserScope`/`formatProjScope` 的段编码(百分号转义)会
|
|
16
16
|
* **膨胀**——非 ASCII principal 编码后可超列宽,故产出处与写口两道都要判。 */
|
|
17
17
|
export declare const MEMORY_SCOPE_COLUMN_CHARS = 190;
|
|
18
|
-
/** memory-sync 店 `sync_cursor.peer` 列宽(两方言 VARCHAR(190) 同宽)—— 中心侧请求的 `peer`
|
|
19
|
-
* (`memory-sync.ts` `
|
|
20
|
-
*
|
|
18
|
+
/** memory-sync 店 `sync_cursor.peer` 列宽(两方言 VARCHAR(190) 同宽)—— 中心侧请求的 `peer` 落这一列。唯一读者 = 同步身份的铸点
|
|
19
|
+
* (`memory-sync-identity.ts` `readMemorySyncIdentity`:规范化之后超宽 = `too-long`)—— 它的四个座位(客户端 `MEMORY_SYNC_URL` 拒启、中心声明
|
|
20
|
+
* `MEMORY_SYNC_SERVE_IDENTITY` 拒启、会话触发的 `target` 400、中心入站的 `peer` 400)由此同宽:身份就是请求的 `peer`,装不进这一列的身份每一轮都会被中心拒。 */
|
|
21
21
|
export declare const MEMORY_SYNC_PEER_COLUMN_CHARS = 190;
|
|
22
22
|
export declare function assertSlugWidth(slug: string): void;
|
|
23
23
|
export declare function assertMemoryScopeWidth(scope: string): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UsageRow } from "../usage-analytics.js";
|
|
2
2
|
import type { TaskStatus } from "@sema-agent/core";
|
|
3
|
-
import { type FenceLanded, type InProcessClaimFence, type CreateRunOutcome, type NewRunMeta, type RunIdemBinding, type RunListQuery, type RunRecord, type SessionSummary, type RunEvent, type PersistedTaskResult, type LatestRunRef } from "./store-contracts.js";
|
|
3
|
+
import { type FenceLanded, type FencedRun, type InProcessClaimFence, type CreateRunOutcome, type NewRunMeta, type RunIdemBinding, type RunListQuery, type RunRecord, type SessionSummary, type RunEvent, type PersistedTaskResult, type LatestRunRef, type SettledLegMemoryObservation } from "./store-contracts.js";
|
|
4
4
|
import type { LedgerEventType } from "../trace/ledger-events.js";
|
|
5
5
|
import { type SpaceCommitClaim, type SpaceCommitReading, type SpaceCommitState } from "../workspace-space-commit.js";
|
|
6
6
|
/**
|
|
@@ -83,7 +83,7 @@ export declare class MemoryRunStore implements InProcessClaimFence {
|
|
|
83
83
|
markResuming(taskId: string, instanceId: string): Promise<boolean>;
|
|
84
84
|
getActiveTaskId(sessionId: string): Promise<string | undefined>;
|
|
85
85
|
/** 认领当写栅栏用(契约 = `store-contracts.ts` 的 `InProcessClaimFence`):判、刷新活性与 `write` 是同一个同步段。 */
|
|
86
|
-
whileHoldingClaim(sessionId: string, taskId: string, write: () => FenceLanded): boolean;
|
|
86
|
+
whileHoldingClaim(sessionId: string, taskId: string, write: (run: FencedRun) => FenceLanded): boolean;
|
|
87
87
|
getRun(taskId: string): Promise<RunRecord | undefined>;
|
|
88
88
|
/** Runs newest-first, keyset on (createdAt, taskId) DESC; optional exact-match filters (owner is exact, like the SQL). */
|
|
89
89
|
listRuns(opts: RunListQuery): Promise<RunRecord[]>;
|
|
@@ -92,6 +92,11 @@ export declare class MemoryRunStore implements InProcessClaimFence {
|
|
|
92
92
|
* `createdAt DESC, taskId DESC`,与本店 {@link MemoryRunStore.listSessions} 挑 `rn=1` 那一行的比较器逐字同一份)。
|
|
93
93
|
*/
|
|
94
94
|
latestRunForSession(sessionId: string): Promise<LatestRunRef | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* [ref] —— 这个会话**最近一条已结腿**与它的记忆观测(规则属主 = `store-contracts.ts` 的 {@link SettledLegMemoryObservation};
|
|
97
|
+
* {@link SqlRunStore.latestMemoryObservationForSession} 的孪生:同一只已结谓词(`isTerminalRunStatus`)、同一个排序口径 —— 与本店 {@link MemoryRunStore.latestRunForSession} 的比较器逐字同一份)。
|
|
98
|
+
*/
|
|
99
|
+
latestMemoryObservationForSession(sessionId: string): Promise<SettledLegMemoryObservation | undefined>;
|
|
95
100
|
/** DISTINCT sessions newest-first by last activity (the CC /resume picker): latest run's preview/status + first/last/count. */
|
|
96
101
|
listSessions(opts: {
|
|
97
102
|
owner?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { redactErrorMessage, redactLedgerEventData, sealRunRowResult } from "../observability/run-terminal.js";
|
|
2
2
|
import { outwardPlane } from "../terminal.js";
|
|
3
3
|
import { projectUsageStats, USAGE_SCAN_LIMIT } from "../usage-analytics.js";
|
|
4
|
-
import { RUN_HOLDER_DEATH_CODES, RUN_STALLED_ERROR } from "./store-contracts.js";
|
|
4
|
+
import { RUN_HOLDER_DEATH_CODES, RUN_STALLED_ERROR, isTerminalRunStatus, settledLegObservationOf } from "./store-contracts.js";
|
|
5
5
|
import { notifyRunTerminal } from "../observability/run-terminal.js";
|
|
6
6
|
import { createInProcessSpaceCommitTable, fenceSpaceCommitAtTerminal } from "../workspace-space-commit.js";
|
|
7
7
|
const ownerEq = (a, b) => (a ?? null) === (b ?? null);
|
|
@@ -238,7 +238,7 @@ export class MemoryRunStore {
|
|
|
238
238
|
if (this.active.get(sessionId) !== taskId || r === undefined || r.status !== "running")
|
|
239
239
|
return false;
|
|
240
240
|
r.updatedAt = new Date();
|
|
241
|
-
write();
|
|
241
|
+
write({ instanceId: r.instanceId });
|
|
242
242
|
return true;
|
|
243
243
|
}
|
|
244
244
|
async getRun(taskId) {
|
|
@@ -273,6 +273,16 @@ export class MemoryRunStore {
|
|
|
273
273
|
}
|
|
274
274
|
return latest === undefined ? undefined : { taskId: latest.taskId, owner: latest.owner, createdAt: latest.createdAt.toISOString() };
|
|
275
275
|
}
|
|
276
|
+
async latestMemoryObservationForSession(sessionId) {
|
|
277
|
+
let latest;
|
|
278
|
+
for (const r of this.runs.values()) {
|
|
279
|
+
if (r.sessionId !== sessionId || !isTerminalRunStatus(r.status))
|
|
280
|
+
continue;
|
|
281
|
+
if (latest === undefined || r.createdAt.getTime() > latest.createdAt.getTime() || (r.createdAt.getTime() === latest.createdAt.getTime() && r.taskId > latest.taskId))
|
|
282
|
+
latest = r;
|
|
283
|
+
}
|
|
284
|
+
return latest === undefined ? undefined : settledLegObservationOf(latest.taskId, latest.result);
|
|
285
|
+
}
|
|
276
286
|
async listSessions(opts) {
|
|
277
287
|
const bySession = new Map();
|
|
278
288
|
for (const r of this.runs.values()) {
|
|
@@ -316,6 +316,28 @@
|
|
|
316
316
|
* 或 `storage` 时权限 / 磁盘修好)后的下一次起服照常补放置;存档移走则它不再是本服务的会话(不补放置、不再点名;fork 创建的会话例外 —— 它的格还在,读作 fork 未落定,出路是同键重试那次 fork 或删除该会话)。
|
|
317
317
|
* · **旧版在已切换库上**:≤7.137.x 起服建回空 `device_session`,随后列册对账见执行列为幽灵列拒启、零行写;再起本版 ⇒ ⓪ 删掉那张空表。回滚的唯一支持形 = 恢复切换前的备份。
|
|
318
318
|
* 读数:`executionPlacementColumnsAdded` / `deviceBindingsMoved` / `deviceBindingsOrphaned`(非零 ⇒ 另一行 warn)/ `deviceBindingTablesDropped` / `executionPlacementsBackfilled` / `executionPlacementSessionsUnreadable`(点名数组 `{ sessionId, fault, errno? }`,只 local;一行一条 warn),收据只记起服日志行。
|
|
319
|
+
* · **M33 local 存档的行事实搬进行、带戳存档改写成匿名**(7.141.0;local 独有 —— SQL 孪生的行事实本来就只在 `session_meta` 行上)—— local 店的行事实(属主 / 化身 / 执行放置 /
|
|
320
|
+
* 建档时刻 / fork 谱系)只住在会话元数据边档的那一格,引擎仓是匿名内容仓(`local-session-store.ts` 头注「规则一」):本店交给引擎仓的写一律不交属主,交出的会话元数据是那一格的一只投影。
|
|
321
|
+
* ≤7.140.x 写下的存量 ① 格里没有建档时刻 / 谱系(那两样只在存档头上)② 换装 / 导入写下的存档头带着导入者的属主戳(及其 fork 后代 —— fork 抄戳)⇒ **一次性**:
|
|
322
|
+
* 步 0 恢复先行(上一次被打断留下的快照逐份消化,`LocalSessionStore.settleArchiveSnapshots`;起服 `ensureSchema` 先调,迁移开头再调)· 步 1 枚举(引擎仓列表 ∪ 边档全部键;
|
|
323
|
+
* 只在边档里、头读不出的 ⇒ 点名 unreadable)· 步 2 行回填(列表里每只存档:格缺 ⇒ 建一格、属主「从没被记下」;格缺建档时刻 / 谱系 ⇒ 从存档头补;一次边档提交 + 文件与目录各 fsync,
|
|
324
|
+
* 在这之前不碰任何存档)· 步 3 存档归一(每只带戳存档,在它的会话写锁里):整档一次读 → 读时跳过了记录 ⇒ 留着(`records_skipped`)→ 引擎导入闸先验(带发言者归属)不过 ⇒ 留着
|
|
325
|
+
* (`invalid`)→ 验后与原日志不逐条相等 ⇒ 留着(`normalizes`;迁移从不改内容)→ 快照记录(core `atomicWriteFile`)→ 以这一代为条件删存档 → 匿名导入 → 删快照。
|
|
326
|
+
* 留着的存档字节不动、点名(一行一条 warn);它们之后被 fork 拒、改日志的推送答 `conflict`(读、续跑、拉取照常),出路 = 删掉会话后重推。
|
|
327
|
+
* **快照目录的常设拒启臂**(`assertNoArchiveSnapshots`,无窗;删码后仍在):起服时数据根下的快照目录非空 ⇒ 拒启(`config.local_archive_snapshot_present`,`StoreBootRefusalError` 族)。
|
|
328
|
+
* **回滚**:边档对象形一格是严格形,上一版不认 `createdAt` / `forkedFrom` 两键 ⇒ 读本版写过的边档严格拒启 —— 回滚的唯一支持形 = 恢复升级前的数据根备份(MIGRATION 写了:升级前备份、先停光旧副本)。
|
|
329
|
+
* 读数:`localArchiveRowFactsBackfilled` / `localArchivesAnonymized` / `localArchivesKeptStamped`(点名数组 `{ sessionId, reason }`)/ `localArchivesUnreadable`(点名数组 `{ sessionId }`)/
|
|
330
|
+
* `localArchiveSnapshotsRecovered`;只 local(SQL 恒零 / 空)。
|
|
331
|
+
* · **M34 问账行成因两列**(7.142.0)—— ≤7.141.x 的 `approval_ask` 只有一列 `denied_reason`,按行的 state 承载两种意思(PARKING / PARKED 行上是转 park 的触发成因,VOID / DENIED 行上是
|
|
332
|
+
* 终态成因),对账器把 PARKING 行收成 DENIED / VOID 时终态成因**覆盖**了触发成因。本版一列一义:`ending_cause`(终态成因)+ `park_trigger`(触发成因,只由 expire claim 写一次)。
|
|
333
|
+
* **SQL 两方言**({@link splitApprovalAskCauseColumns},锁内,M18 之后):① `denied_reason` 在 ⇒ 改名成 `ending_cause`(MySQL 协议 `CHANGE COLUMN`、PG `RENAME COLUMN`;后置条件 `execUntil`)——
|
|
334
|
+
* 改名让滚动窗里的旧副本对这张表的每一条读写**响亮失败**(它们的列清单点名 `denied_reason`),而不是把触发词写进终态列;② `park_trigger` 不在 ⇒ 加列;
|
|
335
|
+
* ③ PARKING / PARKED 行上那一格搬进 `park_trigger`(`park_trigger IS NULL` 才搬),再把这两态上的 `ending_cause` 置空(两句各自幂等;第二跑起零命中)。
|
|
336
|
+
* 中断 ⇒ 下一次起服从首个未满足的后置条件续(钉:真库在改名之后续跑收敛)。终态行上被覆盖掉的触发词没有出处可补 —— 如实缺席。
|
|
337
|
+
* **local 车道**(File 问账日志):信封号 1 → 2;窗内读侧半场按意义译 v1 记录(`approval-ask-store-file.ts` 的 `translateJournalV1Record`),
|
|
338
|
+
* 起服迁移的 local 腿(`FileApprovalAskStore.upgradeJournalEnvelope`)一次压实把整本重写成 v2。
|
|
339
|
+
* **回滚**:7.141.x 对改名后的表每一条读写都响亮失败、对 v2 日志拒启 —— 回滚的唯一支持形 = 恢复升级前的备份,或手工把列改回(MIGRATION 写了语句)。
|
|
340
|
+
* 读数:`askCauseColumnsChanged`(0–2 处表形改动)/ `askParkTriggersMoved`(SQL;local 恒 0)/ `askJournalRecordsUpgraded`(local;SQL 恒 0)。
|
|
319
341
|
*
|
|
320
342
|
* ## 收据账(一次起服一只,每一条迁移同一只)
|
|
321
343
|
* 每一步把它**已提交**的改写 / 删除与点名读数当场记进同一只收据账({@link MigrationReceipts}):计数随每次提交累加、行随每次提交追加、形读数在那一步落定时写。走完 ⇒
|
|
@@ -424,6 +446,22 @@ export interface OneTimeMigrationReport {
|
|
|
424
446
|
/** M32 local 腿:该回填放置、却读不出的会话 —— 有 run、存档读不出(会话头读不出 / 结构走不通 / 读存档文件时抛了别的故障:权限 / 磁盘 I/O / 超大)。一个字节没写,起服不挡:
|
|
425
447
|
* 该会话的请求照旧答存档的故障;存档修好(从留存副本恢复,或权限 / 磁盘修好)后的下一次起服照常补放置。点名行数组(会话 id + 故障词,`storage` 再带 errno),一行一条 warn,每次起服都报直到处置。SQL 独有的反面:SQL 没有这一形(行就是会话);SQL 恒空。 */
|
|
426
448
|
readonly executionPlacementSessionsUnreadable: readonly ExecutionPlacementSessionUnreadable[];
|
|
449
|
+
/** M33:本次补了行事实(建档时刻 / fork 谱系)的会话元数据格数(含为「有存档、没有格」的会话新建的格)。local 独有;SQL 恒 0。非零 = 真写了存量行。 */
|
|
450
|
+
readonly localArchiveRowFactsBackfilled: number;
|
|
451
|
+
/** M33:本次由带属主戳改写成匿名的存档数(条目逐条相等,内容不改)。local 独有;SQL 恒 0。非零 = 真写了存量存档。 */
|
|
452
|
+
readonly localArchivesAnonymized: number;
|
|
453
|
+
/** M33:留着带戳的存档(点名 + 原因,一行一条 warn,每次起服都报直到处置)。local 独有;SQL 恒空。 */
|
|
454
|
+
readonly localArchivesKeptStamped: readonly LocalArchiveKeptStamped[];
|
|
455
|
+
/** M33:存档读不出的会话(边档里有格而存档头读不出,或整档读抛;点名,一行一条 warn,每次起服都报直到处置)。local 独有;SQL 恒空。 */
|
|
456
|
+
readonly localArchivesUnreadable: readonly LocalArchiveUnreadable[];
|
|
457
|
+
/** M33:本次起服消化掉的快照记录数(上一次被打断的改写留下的;补回 / 丢弃)。local 独有;SQL 恒 0。 */
|
|
458
|
+
readonly localArchiveSnapshotsRecovered: number;
|
|
459
|
+
/** M34:本次对 `approval_ask` 成因列做的表形改动数(改名 `denied_reason → ending_cause`、加 `park_trigger`;0–2)。非零 = 这次真改了表形。SQL 独有;local 恒 0。 */
|
|
460
|
+
readonly askCauseColumnsChanged: number;
|
|
461
|
+
/** M34:本次把那一格从 `ending_cause` 搬进 `park_trigger` 的 PARKING / PARKED 行数。非零 = 真写了存量行。SQL 独有;local 恒 0。 */
|
|
462
|
+
readonly askParkTriggersMoved: number;
|
|
463
|
+
/** M34 local 腿:问账日志里信封号 1 的记录数(窗内读侧已按意义译读;本次一次压实把整本重写成 v2)。非零 = 真重写了日志。local 独有;SQL 恒 0。 */
|
|
464
|
+
readonly askJournalRecordsUpgraded: number;
|
|
427
465
|
}
|
|
428
466
|
/** 退役的两只命令桶(引擎 7.51.0 起不是桶;只给 M17 点名认)。 */
|
|
429
467
|
export type RetiredSessionRuleBucket = "commandAllow" | "commandDeny";
|
|
@@ -474,6 +512,24 @@ export interface ExecutionPlacementSessionUnreadable {
|
|
|
474
512
|
/** 仅 `fault === "storage"` 且那只故障带字符串 `code` 时在场(`EACCES` / `EIO` / `ERR_STRING_TOO_LONG` ……)。 */
|
|
475
513
|
readonly errno?: string;
|
|
476
514
|
}
|
|
515
|
+
/**
|
|
516
|
+
* M33 留着带戳的一只存档的原因(闭集):`invalid` = 引擎导入闸不收这份日志(重导会被拒);`normalizes` = 引擎导入会改写它的内容(重导不再逐条相等);
|
|
517
|
+
* `records_skipped` = 读这只存档时跳过了读不出的记录(重写会把盘上那几行字节抹掉)。三种都一个字节不动。
|
|
518
|
+
*/
|
|
519
|
+
export type LocalArchiveKeptReason = "invalid" | "normalizes" | "records_skipped";
|
|
520
|
+
/** M33 留着带戳的一只存档:会话 id 是点名坐标 + 原因。日志内容与盘上路径不出店。 */
|
|
521
|
+
export interface LocalArchiveKeptStamped {
|
|
522
|
+
readonly sessionId: string;
|
|
523
|
+
readonly reason: LocalArchiveKeptReason;
|
|
524
|
+
/** `reason: "invalid"` 时在场:引擎导入闸拒的那一句(条目 id + 结构毛病,不含条目内容)—— 运维据它找到挡住改写的那一条。 */
|
|
525
|
+
readonly detail?: string;
|
|
526
|
+
}
|
|
527
|
+
/** M33 读不出的一只:会话元数据边档里有它的格而存档头读不出(会话头坏),或列表读得出头、整档读抛。一个字节没写;会话的请求照旧答存档的故障。 */
|
|
528
|
+
export interface LocalArchiveUnreadable {
|
|
529
|
+
readonly sessionId: string;
|
|
530
|
+
/** 读的时候抛的那只故障带串型 `code` 时在场(`EACCES` / `EIO` / `corrupt_session` …);盘上路径与故障句不出店。 */
|
|
531
|
+
readonly errno?: string;
|
|
532
|
+
}
|
|
477
533
|
/** 三个形读数(M9 主键 / M17 列名 / M24 scope 列)—— 那一步**落定**之前收据账里缺席(读数行要它们齐;被打断的那一行只带已落定的)。 */
|
|
478
534
|
type ShapeReadingKey = "workflowParkIndexKey" | "sessionRuleColumn" | "workflowJournalScopeColumn";
|
|
479
535
|
/**
|
|
@@ -544,8 +600,8 @@ export declare function migrationWindowOpen(window: Pick<OneTimeMigrationWindow,
|
|
|
544
600
|
* 还没有日期可写)⇒ 响亮抛,不铸一句带空日期的句子。
|
|
545
601
|
*/
|
|
546
602
|
export declare function migrationWindowEnd(id: string): string;
|
|
547
|
-
/** local 车道上 SQL 独有的几条(M8 / M9 / M11 / M17 / M18 / M21 / M23 / M24 / M26 / M27 / M29)的读数(M6 与 M32
|
|
548
|
-
export declare const NO_SQL_MIGRATIONS: Omit<OneTimeMigrationReport, "holderDeathCodeRowsBackfilled" | "executionPlacementsBackfilled" | "askExecutionLanesBackfilled" | "executionPlacementSessionsUnreadable">;
|
|
603
|
+
/** local 车道上 SQL 独有的几条(M8 / M9 / M11 / M17 / M18 / M21 / M23 / M24 / M26 / M27 / M29)的读数(M6 与 M32 的回填两车道都有、M33 只在 local,local 腿的读数由 `LocalBackend.runOneTimeMigrations` 现算):那几张表 / 列在文件底座上从来不存在 ⇒ 如实答 absent / 0。 */
|
|
604
|
+
export declare const NO_SQL_MIGRATIONS: Omit<OneTimeMigrationReport, "holderDeathCodeRowsBackfilled" | "executionPlacementsBackfilled" | "askExecutionLanesBackfilled" | "executionPlacementSessionsUnreadable" | "localArchiveRowFactsBackfilled" | "localArchivesAnonymized" | "localArchivesKeptStamped" | "localArchivesUnreadable" | "localArchiveSnapshotsRecovered" | "askJournalRecordsUpgraded">;
|
|
549
605
|
/** 启动期的日志口(logger 的子集)。两级各有其用,见 {@link logOneTimeMigrations}。 */
|
|
550
606
|
export interface MigrationLogSink {
|
|
551
607
|
warn(msg: string, meta?: Record<string, unknown>): void;
|
|
@@ -579,6 +635,16 @@ export interface MigrationDb {
|
|
|
579
635
|
* `createStoreBackend()` → `ensureSchema()` → `runOneTimeMigrations()` 的嵌入方与本服务的起服序列一样,有这一问、零动作。
|
|
580
636
|
*/
|
|
581
637
|
export declare function runSqlOneTimeMigrations(dialect: SqlDialect, pool: MysqlPool | PgPool, input: ExecutionPlacementSwitchInput): Promise<OneTimeMigrationReport>;
|
|
638
|
+
/**
|
|
639
|
+
* M34 —— 问账行成因两列(判据与形见头注 M34 段)。三步,每一步先读形再判,DDL 按后置条件收敛({@link execUntil}),中断 ⇒ 下一次起服从首个未满足的后置条件续:
|
|
640
|
+
* ① `denied_reason` 在 ⇒ 改名成 `ending_cause`(后置条件:旧名不在 ∧ 新名在)—— 改名让滚动窗里的旧副本对这张表的每一条读写响亮失败;
|
|
641
|
+
* ② `park_trigger` 不在 ⇒ 加列(列定义 = 建表 DDL 内联的同一份);
|
|
642
|
+
* ③ PARKING / PARKED 行:`ending_cause` 里的词搬进 `park_trigger`(只搬 `park_trigger IS NULL` 的行),再把这两态上的 `ending_cause` 置空。两句而不是一句
|
|
643
|
+
* `SET park_trigger = ending_cause, ending_cause = NULL`:一句的结果取决于赋值的求值次序(MySQL 协议方言按左到右读已改的值,PG 读原行),两句不依赖它;两句各自幂等,
|
|
644
|
+
* 中间被打断 ⇒ 下一次起服第一句零命中、第二句收尾(这期间读口照旧:终态成因读口在这两态上不作数)。本版写者不会在这两态上写终态成因 ⇒ 第二跑起两句都零命中。
|
|
645
|
+
* 表不在(中央 DDL 之前被调到)⇒ 零动作。读数:①② 各记 `askCauseColumnsChanged` +1;③ 第一句的受影响行数记 `askParkTriggersMoved`。
|
|
646
|
+
*/
|
|
647
|
+
export declare function splitApprovalAskCauseColumns(db: MigrationDb, dialect: SqlDialect, receipts: MigrationReceipts): Promise<void>;
|
|
582
648
|
/** M32 的起服拒码(确定的拒启表态:再等也等不来另一个答案;不是线上 wire 码,与 `config.schema_mismatch` 同一族)。 */
|
|
583
649
|
export declare const EXECUTION_PLACEMENT_SWITCH_REFUSED_CODE = "config.execution_placement_switch_refused";
|
|
584
650
|
/** 拒因闭集:`fence` = 切换开始之后退役绑定表里又出现了行(旧版副本 / 手工写下的);`backfill_ambiguous` = 车道表不止一项而还有要回填的存量。 */
|