@sema-agent/server 7.142.0 → 7.144.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 +608 -0
- package/USAGE.md +63 -36
- package/dist/adoption/plan.js +22 -0
- package/dist/approval-ask-audit-store.d.ts +7 -5
- package/dist/approval-ask-audit-store.js +12 -6
- package/dist/approval-ask-machine.d.ts +15 -7
- package/dist/approval-ask-machine.js +10 -4
- package/dist/approval-card.d.ts +155 -39
- package/dist/approval-card.js +111 -31
- package/dist/approval-queue-kind.d.ts +27 -0
- package/dist/approval-queue-kind.js +6 -0
- package/dist/approval-reconciler.d.ts +8 -8
- package/dist/approval-reconciler.js +3 -3
- package/dist/audit.js +4 -2
- package/dist/boot/budget-tracing.d.ts +1 -1
- package/dist/boot/execution-env.js +1 -1
- package/dist/boot/governance-seams.d.ts +26 -41
- package/dist/boot/governance-seams.js +61 -28
- package/dist/boot/late-binds.d.ts +7 -4
- package/dist/boot/late-binds.js +3 -1
- package/dist/boot/leader.js +2 -4
- package/dist/boot/memory-consolidation.d.ts +0 -8
- package/dist/boot/memory-consolidation.js +3 -3
- package/dist/boot/reapers.js +5 -4
- package/dist/boot/resolve-spec.d.ts +1 -1
- package/dist/boot/resolve-spec.js +8 -8
- package/dist/boot/runner-deps.d.ts +14 -6
- package/dist/boot/runner-deps.js +6 -17
- package/dist/boot/shutdown.d.ts +9 -0
- package/dist/boot/shutdown.js +18 -2
- package/dist/boot/stage-01-config.js +2 -0
- package/dist/boot/stage-02-web-admin-pull.js +3 -0
- package/dist/boot/stage-03-store-backend.d.ts +4 -1
- package/dist/boot/stage-03-store-backend.js +1 -2
- package/dist/boot/stage-04-stores.d.ts +5 -2
- package/dist/boot/stage-04-stores.js +3 -5
- package/dist/boot/stage-05-execution-env.d.ts +5 -2
- package/dist/boot/stage-06-runners.d.ts +5 -2
- package/dist/boot/stage-06-runners.js +1 -3
- package/dist/boot/stage-07-capability-layer.d.ts +5 -2
- package/dist/boot/stage-07-capability-layer.js +6 -2
- package/dist/boot/stage-08-reapers.d.ts +5 -2
- package/dist/boot/stage-09-leader.d.ts +5 -2
- package/dist/boot/stage-10-http-server.d.ts +5 -2
- package/dist/boot/stage-10-http-server.js +4 -1
- package/dist/boot/stores.d.ts +5 -2
- package/dist/boot/stores.js +7 -7
- package/dist/boot/web-admin.d.ts +5 -1
- package/dist/boot/web-admin.js +31 -19
- package/dist/capabilities/hands-lane.d.ts +9 -39
- package/dist/capabilities/hands-lane.js +8 -13
- package/dist/capabilities/mcp-probe.d.ts +3 -2
- package/dist/capabilities/scenarios.d.ts +23 -17
- package/dist/capabilities/scenarios.js +2 -2
- package/dist/capabilities/skills.d.ts +1 -17
- package/dist/capabilities/skills.js +0 -8
- package/dist/capability-facts.d.ts +8 -8
- package/dist/capability-facts.js +4 -4
- package/dist/card-void.d.ts +6 -9
- package/dist/config-catalog.js +1 -1
- package/dist/config-d-migration.d.ts +2 -0
- package/dist/config-dir-trust.js +58 -29
- package/dist/config-invariants.d.ts +7 -1
- package/dist/config-invariants.js +7 -0
- package/dist/config-provider.d.ts +10 -0
- package/dist/config-provider.js +15 -4
- package/dist/config-root-migration.d.ts +13 -0
- package/dist/config-root-migration.js +99 -0
- package/dist/config-types.d.ts +5 -5
- package/dist/config.d.ts +4 -3
- package/dist/config.js +1 -1
- package/dist/delegated-session-owner.d.ts +35 -151
- package/dist/delegated-session-owner.js +1 -83
- package/dist/device-ws-protocol.d.ts +1 -0
- package/dist/device-ws-protocol.js +2 -1
- package/dist/entry-mode-clamp-notice.d.ts +1 -1
- package/dist/env-model-table-gate.d.ts +53 -0
- package/dist/env-model-table-gate.js +53 -0
- package/dist/execution-placement.d.ts +7 -4
- package/dist/fleet/fleet-bus.d.ts +28 -52
- package/dist/fleet/fleet-bus.js +35 -100
- package/dist/fleet/fleet-reconciler.d.ts +4 -4
- package/dist/fleet/fleet-reconciler.js +1 -1
- package/dist/fleet/subagent-tail-bus.d.ts +14 -11
- package/dist/fleet/subagent-tail-bus.js +15 -28
- package/dist/hooks/classic-stations.d.ts +3 -1
- package/dist/hooks/classic-stations.js +2 -0
- package/dist/hooks/hook-runner.js +28 -7
- package/dist/host-decision.d.ts +54 -20
- package/dist/host-decision.js +42 -14
- package/dist/http/admission.d.ts +1 -1
- package/dist/http/admission.js +7 -3
- package/dist/http/approval-sweeps.js +11 -8
- package/dist/http/caller-trust.d.ts +1 -1
- package/dist/http/durable-run-leg.js +2 -2
- package/dist/http/engine-refusal.d.ts +16 -0
- package/dist/http/engine-refusal.js +17 -0
- package/dist/http/memory-compliance-failure-reply.d.ts +1 -3
- package/dist/http/memory-compliance-failure-reply.js +4 -6
- package/dist/http/owner-access.d.ts +11 -0
- package/dist/http/owner-access.js +13 -0
- package/dist/http/principal-gate.d.ts +1 -1
- package/dist/http/refusal-body.d.ts +7 -3
- package/dist/http/refusal-body.js +1 -0
- package/dist/http/resume-legs.d.ts +21 -7
- package/dist/http/resume-legs.js +82 -53
- package/dist/http/resume-restatement.d.ts +39 -0
- package/dist/http/resume-restatement.js +25 -0
- package/dist/http/route-ctx.d.ts +35 -10
- package/dist/http/route-ctx.js +1 -1
- package/dist/http/routes/approvals-assistant.d.ts +9 -1
- package/dist/http/routes/approvals-assistant.js +143 -31
- package/dist/http/routes/capabilities.js +11 -2
- package/dist/http/routes/memory-policy.d.ts +2 -2
- package/dist/http/routes/memory-policy.js +1 -1
- package/dist/http/routes/notify-wake.js +23 -25
- package/dist/http/routes/rules.js +48 -13
- package/dist/http/routes/runs.js +9 -8
- package/dist/http/routes/session-memory-sync.d.ts +34 -6
- package/dist/http/routes/session-memory-sync.js +27 -10
- package/dist/http/routes/session-sync.js +13 -20
- package/dist/http/routes/sessions.d.ts +2 -2
- package/dist/http/routes/sessions.js +22 -23
- package/dist/http/routes/tasks.js +27 -49
- package/dist/http/server.d.ts +13 -7
- package/dist/http/server.js +2 -2
- package/dist/http/stored-body-replay.js +15 -4
- package/dist/http/wire-types.d.ts +17 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lane-home-probe.d.ts +15 -0
- package/dist/lane-home-probe.js +4 -0
- package/dist/leader/leader.js +5 -2
- package/dist/leader/wire.d.ts +7 -1
- package/dist/leader/wire.js +6 -5
- package/dist/leg-facts.d.ts +37 -0
- package/dist/leg-facts.js +15 -0
- package/dist/memory-bundle-engine.d.ts +1 -4
- package/dist/memory-bundle-engine.js +2 -2
- package/dist/memory-operator-faces.d.ts +30 -66
- package/dist/memory-operator-faces.js +17 -88
- package/dist/memory-scope-stores.d.ts +38 -40
- package/dist/memory-scope-stores.js +51 -36
- package/dist/memory-scope.d.ts +0 -9
- package/dist/memory-scope.js +0 -9
- package/dist/memory-sync-client.js +14 -3
- package/dist/memory-sync.d.ts +20 -4
- package/dist/memory-sync.js +23 -4
- package/dist/model-plane-face.d.ts +13 -7
- package/dist/model-plane-face.js +2 -1
- package/dist/observability/corrupt-read-seat.d.ts +5 -9
- package/dist/observability/corrupt-read-seat.js +1 -2
- package/dist/observability/fail-open.d.ts +30 -10
- package/dist/observability/fail-open.js +27 -10
- package/dist/observability/run-terminal.d.ts +1 -1
- package/dist/observability/run-terminal.js +6 -2
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -19
- package/dist/orchestration/workflow-completion-inbox.js +0 -12
- package/dist/orchestration/workflow-notify-journal.d.ts +3 -2
- package/dist/orchestration/workflow-park-decision.d.ts +8 -3
- package/dist/orchestration/workflow-park-decision.js +5 -3
- package/dist/org-delivery-gate.d.ts +11 -0
- package/dist/org-delivery-gate.js +19 -1
- package/dist/parked-decide.d.ts +13 -9
- package/dist/parked-decide.js +7 -7
- package/dist/parked-revive-surface.d.ts +6 -7
- package/dist/parked-revive-surface.js +1 -1
- package/dist/peer-inbound-face.d.ts +122 -0
- package/dist/peer-inbound-face.js +123 -0
- package/dist/permission-rule-list.d.ts +13 -9
- package/dist/permission-rule-list.js +7 -3
- package/dist/plugins/approval-ask-store-file.js +18 -6
- package/dist/plugins/approval-ask-store-memory.js +8 -6
- package/dist/plugins/approval-ask-store-sql.d.ts +28 -13
- package/dist/plugins/approval-ask-store-sql.js +30 -11
- package/dist/plugins/caching-session-store.d.ts +0 -3
- package/dist/plugins/caching-session-store.js +0 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +45 -38
- package/dist/plugins/checkpoint-store-sql.js +108 -45
- package/dist/plugins/file-history-store-sql.d.ts +24 -18
- package/dist/plugins/file-history-store-sql.js +24 -19
- package/dist/plugins/file-run-store.d.ts +29 -0
- package/dist/plugins/file-run-store.js +97 -8
- package/dist/plugins/fork-routing-session-store.d.ts +8 -1
- package/dist/plugins/fork-routing-session-store.js +6 -0
- package/dist/plugins/imported-layer-root-retirement.d.ts +82 -0
- package/dist/plugins/imported-layer-root-retirement.js +96 -0
- package/dist/plugins/local-checkpoint-store.d.ts +6 -8
- package/dist/plugins/local-checkpoint-store.js +5 -4
- package/dist/plugins/local-session-store.d.ts +69 -30
- package/dist/plugins/local-session-store.js +133 -57
- package/dist/plugins/local-session-window.d.ts +4 -2
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +9 -31
- package/dist/plugins/mailbox-recipient-lifecycle.js +4 -0
- package/dist/plugins/mailbox-store-sql.d.ts +12 -8
- package/dist/plugins/mailbox-store-sql.js +76 -7
- package/dist/plugins/memory-sync-store-pg.d.ts +15 -0
- package/dist/plugins/memory-sync-store-pg.js +21 -0
- package/dist/plugins/memory-sync-store-tidb.d.ts +2 -0
- package/dist/plugins/memory-sync-store-tidb.js +13 -1
- package/dist/plugins/one-time-migrations.d.ts +44 -14
- package/dist/plugins/one-time-migrations.js +118 -15
- package/dist/plugins/org-delivery-quota-store.d.ts +1 -1
- package/dist/plugins/org-delivery-quota-store.js +2 -12
- package/dist/plugins/park-commit-watch.d.ts +1 -1
- package/dist/plugins/permission-rule-store-file.d.ts +10 -1
- package/dist/plugins/permission-rule-store-file.js +15 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +31 -1
- package/dist/plugins/permission-rule-store-sql.js +35 -2
- package/dist/plugins/pg-session-storage.d.ts +1 -9
- package/dist/plugins/pg-session-storage.js +2 -19
- package/dist/plugins/remote-env-device.d.ts +8 -11
- package/dist/plugins/remote-env-device.js +6 -3
- package/dist/plugins/remote-env-host.d.ts +8 -4
- package/dist/plugins/remote-env-host.js +7 -9
- package/dist/plugins/remote-env-k8s.d.ts +37 -24
- package/dist/plugins/remote-env-k8s.js +50 -17
- package/dist/plugins/remote-shell.js +12 -2
- package/dist/plugins/retention-store-sql.d.ts +2 -2
- package/dist/plugins/sandbox-read-floor.d.ts +5 -7
- package/dist/plugins/sandbox-read-floor.js +2 -7
- package/dist/plugins/schema-consistency.d.ts +5 -1
- package/dist/plugins/session-fork.d.ts +1 -1
- package/dist/plugins/session-ownership.d.ts +9 -0
- package/dist/plugins/session-ownership.js +6 -0
- package/dist/plugins/session-store.d.ts +13 -16
- package/dist/plugins/session-store.js +9 -10
- package/dist/plugins/sql-errors.d.ts +10 -1
- package/dist/plugins/sql-errors.js +13 -0
- package/dist/plugins/sql-json-column.d.ts +24 -2
- package/dist/plugins/sql-json-column.js +38 -3
- package/dist/plugins/store-backend.d.ts +23 -28
- package/dist/plugins/store-backend.js +12 -3
- package/dist/plugins/store-contracts.d.ts +29 -5
- package/dist/plugins/store-contracts.js +4 -1
- package/dist/plugins/task-attachment-store.d.ts +2 -2
- package/dist/plugins/task-attachment-store.js +37 -52
- package/dist/plugins/tidb-session-store.d.ts +2 -14
- package/dist/plugins/tidb-session-store.js +2 -20
- package/dist/plugins/tool-result-store-sql.d.ts +9 -8
- package/dist/plugins/tool-result-store-sql.js +23 -2
- package/dist/plugins/wiring-section-codec.d.ts +32 -0
- package/dist/plugins/wiring-section-codec.js +55 -0
- package/dist/plugins/workspace-fill.d.ts +1 -1
- package/dist/rule-entry-list.d.ts +3 -2
- package/dist/rule-entry-list.js +5 -1
- package/dist/rules-consent.d.ts +28 -5
- package/dist/rules-consent.js +40 -28
- package/dist/run-local.js +11 -6
- package/dist/runs.d.ts +12 -8
- package/dist/runs.js +10 -7
- package/dist/runtime-governance.d.ts +1 -1
- package/dist/security.d.ts +0 -4
- package/dist/server-secret-env.d.ts +4 -0
- package/dist/session-error-wire.d.ts +34 -23
- package/dist/session-error-wire.js +8 -3
- package/dist/session-incarnation.d.ts +3 -3
- package/dist/session-notify-door.d.ts +106 -0
- package/dist/session-notify-door.js +97 -0
- package/dist/session-sync.d.ts +9 -14
- package/dist/session-sync.js +5 -5
- package/dist/session-workspace.d.ts +3 -13
- package/dist/session-workspace.js +0 -9
- package/dist/standing-answer-grant.d.ts +5 -0
- package/dist/standing-answer-grant.js +10 -0
- package/dist/stores-sql/session-policy-store-sql.d.ts +4 -2
- package/dist/stores-sql/session-policy-store-sql.js +3 -13
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-settings.d.ts +11 -8
- package/dist/task-settings.js +31 -11
- package/dist/tool-approval.d.ts +55 -35
- package/dist/tool-approval.js +112 -74
- package/dist/trace/core-keyset-guard.d.ts +12 -9
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +4 -2
- package/dist/trace/exit-seat.d.ts +7 -1
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/ledger-sink.d.ts +2 -2
- package/dist/trace/ledger-sink.js +12 -4
- package/dist/trace/model-segment.d.ts +74 -25
- package/dist/trace/model-segment.js +141 -32
- package/dist/trace/project.d.ts +15 -6
- package/dist/trace/project.js +12 -4
- package/dist/trace/redact.d.ts +72 -9
- package/dist/trace/redact.js +1509 -471
- package/dist/trace/self-minted-wire.d.ts +598 -47
- package/dist/trace/self-minted-wire.js +190 -20
- 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 +33 -5
- package/dist/verifier-pause-card.js +15 -10
- package/dist/web-admin-client/apply-effective.d.ts +12 -16
- package/dist/web-admin-client/apply-effective.js +90 -10
- package/dist/workspace-space.d.ts +19 -3
- package/dist/workspace-space.js +8 -4
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +3 -1
- package/package.json +3 -2
- package/wire-changes/server@7.143.0.json +1167 -0
- package/wire-changes/server@7.144.0.json +291 -0
- package/dist/session-records-skipped-notice.d.ts +0 -21
- package/dist/session-records-skipped-notice.js +0 -27
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mysqlDriver, pgDriver, dialectJsonEncoder } from "./sql-driver.js";
|
|
2
2
|
import { ASK_TERMINAL, canAskTransition } from "../approval-ask-machine.js";
|
|
3
|
+
import { DECIDED_VIA } from "@sema-agent/core";
|
|
3
4
|
import { APPROVAL_ENDING_CAUSES, askRowEndingCause, askRowParkTrigger } from "../approval-deny-reasons.js";
|
|
4
5
|
import { isDupKeyError, isMissingColumnError } from "./sql-errors.js";
|
|
5
6
|
import { describeProbedTableDrift } from "./schema-drift-sentence.js";
|
|
@@ -25,7 +26,8 @@ export const MAX_SETTLED_BY_CHARS = 16;
|
|
|
25
26
|
export function settledByFitsColumn(v) {
|
|
26
27
|
return v.length > 0 && v.length <= MAX_SETTLED_BY_CHARS;
|
|
27
28
|
}
|
|
28
|
-
export function
|
|
29
|
+
export function assertDecideSource(decision) {
|
|
30
|
+
assertDecidedViaBesidePolicy(decision);
|
|
29
31
|
const v = decision.settledBy;
|
|
30
32
|
if (v === undefined)
|
|
31
33
|
return;
|
|
@@ -33,6 +35,15 @@ export function assertDecideSettledBy(decision) {
|
|
|
33
35
|
throw new Error(`invalid settledBy: the settlement source is one word from the engine's closed set and lands in a VARCHAR(${MAX_SETTLED_BY_CHARS}) column — must be 1-${MAX_SETTLED_BY_CHARS} chars (got ${JSON.stringify(v.slice(0, 32))}${v.length > 32 ? "…" : ""}, length ${v.length})`);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
38
|
+
export const MAX_DECIDED_VIA_CHARS = 32;
|
|
39
|
+
function assertDecidedViaBesidePolicy(decision) {
|
|
40
|
+
const via = decision.decidedVia;
|
|
41
|
+
if (via === undefined)
|
|
42
|
+
return;
|
|
43
|
+
if (!DECIDED_VIA.some((w) => w === via) || via.length > MAX_DECIDED_VIA_CHARS || decision.settledBy !== "policy") {
|
|
44
|
+
throw new Error(`invalid decidedVia: the machine seat is one of ${DECIDED_VIA.map((w) => `"${w}"`).join(" / ")} and is stated only beside settledBy "policy" (got ${JSON.stringify(String(via).slice(0, 32))} beside ${JSON.stringify(decision.settledBy ?? null)})`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
36
47
|
export class ApprovalAskReadAbortedError extends Error {
|
|
37
48
|
constructor(where) {
|
|
38
49
|
super(`approval-ask read ${where} aborted by caller`);
|
|
@@ -98,12 +109,13 @@ export function projectAskTerminalClaimTruth(row) {
|
|
|
98
109
|
decision: row.decision,
|
|
99
110
|
...(row.updatedInput !== undefined ? { updatedInput: row.updatedInput } : {}),
|
|
100
111
|
settledBy: row.settledBy,
|
|
112
|
+
decidedVia: row.decidedVia,
|
|
101
113
|
...(endingCause !== undefined ? { endingCause } : {}),
|
|
102
114
|
...(parkTrigger !== undefined ? { parkTrigger } : {}),
|
|
103
115
|
};
|
|
104
116
|
}
|
|
105
117
|
export function askRowOnCall(row, call) {
|
|
106
|
-
return row.taskId === call.taskId && row.legKey === call.legKey && row.toolCallId === call.toolCallId && row.
|
|
118
|
+
return row.taskId === call.taskId && row.legKey === call.legKey && row.toolCallId === call.toolCallId && row.sourceSessionId === call.sourceSessionId;
|
|
107
119
|
}
|
|
108
120
|
export function askOwnerAdmits(owner, principal) {
|
|
109
121
|
return owner === null || owner === principal;
|
|
@@ -179,9 +191,12 @@ export const TIDB_APPROVAL_ASK_STATEMENTS = [
|
|
|
179
191
|
-- settled_by(S-558 / #1016 持久半场):这条决议的结算来源词(NULL = 人答的)。语义、两态读法与
|
|
180
192
|
-- 「为什么是自己一列而不是塞进 decision_actor」的全文见 AskRow.settledBy 顶注。
|
|
181
193
|
-- VARCHAR(16):词表属主是 core(AskOutcome.settledBy,今天最长 7 字符 "timeout"),宽度与同表
|
|
182
|
-
-- decision 同尺同理由 —— 闭集词列,不是自由文本。截断面由入店形门堵死(
|
|
194
|
+
-- decision 同尺同理由 —— 闭集词列,不是自由文本。截断面由入店形门堵死(assertDecideSource),
|
|
183
195
|
-- 不靠「列够宽就不会截」这种运气(MySQL 非严格模式静默截、PG 直接报错 = 两方言不同答)。
|
|
184
196
|
settled_by VARCHAR(16) NULL,
|
|
197
|
+
-- decided_via(core 7.61.0 #3169):settled_by = 'policy' 旁的机器座位词(NULL = 没陈述 = 部署自己的策略;旧行同读)。
|
|
198
|
+
-- 与 settled_by 同一条 UPDATE 落列、同一条理由住在行上(语义全文见 AskRow.decidedVia)。闭集词列,宽度 = MAX_DECIDED_VIA_CHARS。
|
|
199
|
+
decided_via VARCHAR(${MAX_DECIDED_VIA_CHARS}) NULL,
|
|
185
200
|
-- updated_input(S-26 / #304,A-054.15 收口):人批准时带的 ctrl+g 编辑实参,JSON 文本,与决议同一条
|
|
186
201
|
-- UPDATE 原子落列;NULL = 没带编辑(与 JSON "null" = 编辑成 null 分家)。LONGTEXT 照 card_json 先例:
|
|
187
202
|
-- 编辑实参是整只工具入参,VARCHAR/TEXT 会造静默截断面。语义三态与读法见 AskRow.updatedInput 顶注。
|
|
@@ -268,6 +283,8 @@ export async function ensurePgApprovalAskSchema(q) {
|
|
|
268
283
|
decision_note TEXT COLLATE "C",
|
|
269
284
|
-- settled_by(S-558)—— MySQL 孪生逐字同形(宽度/语义/形门的理由写在那侧的行内注)。
|
|
270
285
|
settled_by VARCHAR(16) COLLATE "C",
|
|
286
|
+
-- decided_via(#3169)—— MySQL 孪生逐字同形。
|
|
287
|
+
decided_via VARCHAR(${MAX_DECIDED_VIA_CHARS}) COLLATE "C",
|
|
271
288
|
-- updated_input(S-26 / #304)—— MySQL 孪生逐字同形(语义/类型理由见那侧行内注;PG TEXT 无长度上限)。
|
|
272
289
|
updated_input TEXT COLLATE "C",
|
|
273
290
|
decided_at_ms BIGINT,
|
|
@@ -317,7 +334,7 @@ function askCols(dialect) {
|
|
|
317
334
|
"ask_id, task_id, source_task_id, session_id, owner, execution_lane, batch_id, tool_call_id, leg_key, parent_tool_call_id, bound_input_hash, state",
|
|
318
335
|
"provisional, rev, decision",
|
|
319
336
|
jsonColumnText(dialect, "decision_actor"),
|
|
320
|
-
"decision_note, settled_by",
|
|
337
|
+
"decision_note, settled_by, decided_via",
|
|
321
338
|
jsonColumnText(dialect, "updated_input"),
|
|
322
339
|
"decided_at_ms, ending_cause, park_trigger, gate_token",
|
|
323
340
|
"gate_bound_call_id, gate_bound_input_hash, idempotency_key",
|
|
@@ -349,7 +366,7 @@ function mapAskRowBody(r, askId) {
|
|
|
349
366
|
return {
|
|
350
367
|
askId: String(r.ask_id),
|
|
351
368
|
taskId: String(r.task_id),
|
|
352
|
-
|
|
369
|
+
sourceSessionId: String(r.source_task_id),
|
|
353
370
|
sessionId: String(r.session_id),
|
|
354
371
|
owner: strOrNull(r.owner),
|
|
355
372
|
executionLane: executionLaneColumnOf(r.execution_lane, askId),
|
|
@@ -365,6 +382,7 @@ function mapAskRowBody(r, askId) {
|
|
|
365
382
|
decisionActor: r.decision_actor == null ? null : decodeJsonColumn(r.decision_actor, readJsonObjectColumn, `${APPROVAL_ASK_TABLE}.decision_actor for ask ${askId}`),
|
|
366
383
|
decisionNote: strOrNull(r.decision_note),
|
|
367
384
|
settledBy: strOrNull(r.settled_by),
|
|
385
|
+
decidedVia: strOrNull(r.decided_via),
|
|
368
386
|
...(r.updated_input == null ? {} : { updatedInput: decodeJsonColumn(r.updated_input, readTriStateJsonValueColumn, `${APPROVAL_ASK_TABLE}.updated_input for ask ${askId}`) }),
|
|
369
387
|
decidedAtMs: numOrNull(r.decided_at_ms),
|
|
370
388
|
endingCause: strOrNull(r.ending_cause),
|
|
@@ -462,7 +480,7 @@ export class SqlApprovalAskStore {
|
|
|
462
480
|
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, 'STREAM_PENDING', 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $12, $13, $14, $15, $16, $17, $18) ON CONFLICT (ask_id) DO NOTHING"), [
|
|
463
481
|
row.askId,
|
|
464
482
|
row.taskId,
|
|
465
|
-
row.
|
|
483
|
+
row.sourceSessionId,
|
|
466
484
|
row.sessionId,
|
|
467
485
|
row.owner ?? null,
|
|
468
486
|
row.executionLane,
|
|
@@ -516,10 +534,10 @@ export class SqlApprovalAskStore {
|
|
|
516
534
|
async decideAsk(askId, batchId, owner, decision) {
|
|
517
535
|
if (decision.idempotencyKey != null)
|
|
518
536
|
assertIdempotencyKeyShape(decision.idempotencyKey);
|
|
519
|
-
|
|
537
|
+
assertDecideSource(decision);
|
|
520
538
|
const now = Date.now();
|
|
521
539
|
const dialect = this.db.dialect;
|
|
522
|
-
const ownerWhere = decideOwnerWhere(dialect, owner,
|
|
540
|
+
const ownerWhere = decideOwnerWhere(dialect, owner, 12);
|
|
523
541
|
const conn = await this.db.connect();
|
|
524
542
|
try {
|
|
525
543
|
await conn.begin();
|
|
@@ -530,11 +548,12 @@ export class SqlApprovalAskStore {
|
|
|
530
548
|
}
|
|
531
549
|
let askRes;
|
|
532
550
|
try {
|
|
533
|
-
askRes = await conn.query(`UPDATE ${APPROVAL_ASK_TABLE} SET state='DECIDED', decision=${ph(dialect, 1)}, decision_actor=${ph(dialect, 2)}, decision_note=${ph(dialect, 3)}, settled_by=${ph(dialect, 4)},
|
|
551
|
+
askRes = await conn.query(`UPDATE ${APPROVAL_ASK_TABLE} SET state='DECIDED', decision=${ph(dialect, 1)}, decision_actor=${ph(dialect, 2)}, decision_note=${ph(dialect, 3)}, settled_by=${ph(dialect, 4)}, decided_via=${ph(dialect, 5)}, updated_input=${ph(dialect, 6)}, decided_at_ms=${ph(dialect, 7)}, idempotency_key=${ph(dialect, 8)}, rev=rev+1, updated_at_ms=${ph(dialect, 9)} WHERE ${pendingClaimWhere(dialect, 10)} AND ${ownerWhere.sql}`, [
|
|
534
552
|
decision.decision,
|
|
535
553
|
decision.decisionActor == null ? null : this.json(decision.decisionActor),
|
|
536
554
|
decision.decisionNote ?? null,
|
|
537
555
|
decision.settledBy ?? null,
|
|
556
|
+
decision.decidedVia ?? null,
|
|
538
557
|
decision.updatedInput === undefined ? null : this.json(decision.updatedInput),
|
|
539
558
|
now,
|
|
540
559
|
decision.idempotencyKey ?? null,
|
|
@@ -579,7 +598,7 @@ export class SqlApprovalAskStore {
|
|
|
579
598
|
throw new Error(`approval-ask-store.claimTerminal: illegal terminal claim STREAM_PENDING -> ${to} (askId=${askId})`);
|
|
580
599
|
}
|
|
581
600
|
if (intent === "refuse")
|
|
582
|
-
|
|
601
|
+
assertDecideSource(POLICY_REFUSAL_DECISION);
|
|
583
602
|
const now = Date.now();
|
|
584
603
|
const dialect = this.db.dialect;
|
|
585
604
|
const conn = await this.db.connect();
|
|
@@ -752,7 +771,7 @@ export class SqlApprovalAskStore {
|
|
|
752
771
|
return rows.map(mapAskRow);
|
|
753
772
|
}
|
|
754
773
|
async listByCall(call) {
|
|
755
|
-
const { rows } = await this.db.query(this.q(`SELECT ${askCols("mysql")} FROM ${APPROVAL_ASK_TABLE} WHERE task_id = ? AND leg_key = ? AND tool_call_id = ? AND source_task_id = ? ORDER BY created_at_ms ASC, ask_id ASC`, `SELECT ${askCols("pg")} FROM ${APPROVAL_ASK_TABLE} WHERE task_id = $1 AND leg_key = $2 AND tool_call_id = $3 AND source_task_id = $4 ORDER BY created_at_ms ASC, ask_id ASC`), [call.taskId, call.legKey, call.toolCallId, call.
|
|
774
|
+
const { rows } = await this.db.query(this.q(`SELECT ${askCols("mysql")} FROM ${APPROVAL_ASK_TABLE} WHERE task_id = ? AND leg_key = ? AND tool_call_id = ? AND source_task_id = ? ORDER BY created_at_ms ASC, ask_id ASC`, `SELECT ${askCols("pg")} FROM ${APPROVAL_ASK_TABLE} WHERE task_id = $1 AND leg_key = $2 AND tool_call_id = $3 AND source_task_id = $4 ORDER BY created_at_ms ASC, ask_id ASC`), [call.taskId, call.legKey, call.toolCallId, call.sourceSessionId]);
|
|
756
775
|
return rows.map(mapAskRow).filter((r) => askRowOnCall(r, call));
|
|
757
776
|
}
|
|
758
777
|
async listParkingBySession(sessionId) {
|
|
@@ -4,7 +4,6 @@ import type { StagingHandle } from "../session-sync-kernel.js";
|
|
|
4
4
|
import { type PlacementAcquireOpts } from "./session-placement.js";
|
|
5
5
|
import type { InstructionSourceStore } from "../instruction-source-notice.js";
|
|
6
6
|
import type { SessionWorkspaceStore } from "../session-workspace.js";
|
|
7
|
-
import type { OwnerlessClaim } from "../delegated-session-owner.js";
|
|
8
7
|
export interface CachingOptions {
|
|
9
8
|
/** Idle seconds a woken session is kept warm. 0 disables caching (pure passthrough). */
|
|
10
9
|
ttlSec: number;
|
|
@@ -57,8 +56,6 @@ export declare class CachingSessionStore implements SessionStore {
|
|
|
57
56
|
* k8s 工作区空间 / SSE 探针 / resume-at 读的都是本类。 */
|
|
58
57
|
readonly headOf: SessionHeadReader["headOf"];
|
|
59
58
|
readonly register?: (sessionId: string, owner: string | null) => Promise<void>;
|
|
60
|
-
/** [ref] 委派继承律的认领口,纯转发(写的是行上的属主那一格 —— 只 CAS 子行自己,不碰暖缓存里的会话;停驻挂点在默认部署上读的就是本类 —— 与 `placementOf` 同转发同缺:内店记录委派树 ⇒ 两只都在)。 */
|
|
61
|
-
readonly claimOwnerless?: OwnerlessClaim;
|
|
62
59
|
/** Delegated SessionRepo seam (§0.5) — list/fork/delete operate on the DURABLE tables directly (they bypass the
|
|
63
60
|
* warm cache by design; a fork/delete must read/write durable state, not a possibly-stale cached view). */
|
|
64
61
|
readonly listSessions?: (opts: {
|
|
@@ -9,7 +9,6 @@ export class CachingSessionStore {
|
|
|
9
9
|
onStaleHit;
|
|
10
10
|
headOf;
|
|
11
11
|
register;
|
|
12
|
-
claimOwnerless;
|
|
13
12
|
listSessions;
|
|
14
13
|
fork;
|
|
15
14
|
forkTo;
|
|
@@ -56,8 +55,6 @@ export class CachingSessionStore {
|
|
|
56
55
|
const ownerAware = inner;
|
|
57
56
|
if (ownerAware.register)
|
|
58
57
|
this.register = ownerAware.register.bind(inner);
|
|
59
|
-
if (ownerAware.claimOwnerless)
|
|
60
|
-
this.claimOwnerless = ownerAware.claimOwnerless.bind(inner);
|
|
61
58
|
if (ownerAware.listSessions)
|
|
62
59
|
this.listSessions = ownerAware.listSessions.bind(inner);
|
|
63
60
|
if (ownerAware.sessionSummaryOf)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Pool as MySqlPool } from "mysql2/promise";
|
|
2
2
|
import type { Pool as PgPool } from "pg";
|
|
3
|
-
import { type ExecutionOutcomeRecordWord, type GateOutcome, type Checkpoint, type CheckpointGate, type CheckpointState, type CheckpointStore, type CheckpointSummary, type CheckpointToken, type PendingSteerInput, type ResumeOutcome, type ResolvedOutcome, type ResolveExpectation, type ReopenReason, type RiskDescriptor, type StoreDurability, type StoreFidelity, type ToolApprovalCard } from "@sema-agent/core";
|
|
3
|
+
import { type ExecutionOutcomeRecordWord, type GateOutcome, type Checkpoint, type CheckpointGate, type CheckpointRowVerdict, type CheckpointState, type CheckpointStore, type CheckpointSummary, type CheckpointToken, type PendingSteerInput, type ResumeOutcome, type ResolvedOutcome, type ResolveExpectation, type ReopenReason, type RiskDescriptor, type StoreDurability, type StoreFidelity, type ToolApprovalCard } from "@sema-agent/core";
|
|
4
4
|
import { type ParkRowFacts, type RuleOfferProjection, type SkillCardFacts } from "../approval-card.js";
|
|
5
5
|
import type { KindlessBatchRowSource, KindlessBatchScan } from "../approval-batch-census.js";
|
|
6
6
|
import { type SqlDialect, type SqlDriver } from "./sql-driver.js";
|
|
@@ -174,6 +174,14 @@ export interface PendingCheckpoint extends ParkRowFacts, SkillCardFacts {
|
|
|
174
174
|
* `LivePendingRow.approvalCard`。展示/分诊用,永不参与 resume / gate / CAS。(此前此处是按 `tool_name` 列派生的 `contentKind`,随 [ref] 删。)
|
|
175
175
|
*/
|
|
176
176
|
approvalCard?: ToolApprovalCard;
|
|
177
|
+
/**
|
|
178
|
+
* 这一行**本引擎续不续得了** —— core 判官 `judgeCheckpointRow` 对这一行盘上字节的判决(core 7.62.0 [ref];与助手收件箱行的 `rowVerdict`、
|
|
179
|
+
* 续跑在第一级读到的拒同一个读者、同一答),逐字投、本服务不重算不筛。判官要整行:SQL 孪生按 (库内算的 `checkpoint` 文本 sha256, 引擎构建)
|
|
180
|
+
* 记忆({@link StoredRowProjectionMemo}),未命中才按令牌批读整行;LOCAL 孪生取 core 店摘要上的同一位。
|
|
181
|
+
* **在场 ⇔ 这一次列表判过这一行**:缺席只在 SQL 孪生上出现 —— 整行解不出(行照列,计 `server.approvals.park-row-blob-unreadable`,续跑面
|
|
182
|
+
* 对同一行响亮拒)、两次读之间行已离开待决,或两次读之间行的字节变了(判过的是另一份,不拼到这一行上;下一次列表即带)。缺席**不是** `ok`。非 `ok` 的行照列(人要看到它停在哪)。
|
|
183
|
+
*/
|
|
184
|
+
rowVerdict?: CheckpointRowVerdict;
|
|
177
185
|
}
|
|
178
186
|
/**
|
|
179
187
|
* [ref]([ref] / DEBTS [ref]):session 键读口(`findPendingTokenBySession` / `peekPendingScope`)的**行绑定**。
|
|
@@ -343,7 +351,7 @@ export interface CheckpointAskCandidate {
|
|
|
343
351
|
status: string;
|
|
344
352
|
createdAtMs: number;
|
|
345
353
|
/**
|
|
346
|
-
* 🔴 和解三元组的第一维([ref] 件1,黑板 [ref]③①)—— checkpoint 自己带的 `
|
|
354
|
+
* 🔴 和解三元组的第一维([ref] 件1,黑板 [ref]③①)—— checkpoint 自己带的 `sourceSessionId`(core 在
|
|
347
355
|
* suspendAsk 铸行时恒填该腿的 `sessionId`)。**没有对应的列**,只能从 blob 窄读;读不出/缺席 = null。
|
|
348
356
|
*
|
|
349
357
|
* 为什么必须进候选集:读口按 `(scope, session_id, tool_call_id)` 查,而委派子代那条腿的 ask 落行时
|
|
@@ -351,7 +359,7 @@ export interface CheckpointAskCandidate {
|
|
|
351
359
|
* (toolCallId, hash) 两维,一条根腿的 park 会被一只子代的 ask 认领(摘要相同的两次同 args 调用完全
|
|
352
360
|
* 正常)。三元组全同才算同一件事。
|
|
353
361
|
*/
|
|
354
|
-
|
|
362
|
+
sourceSessionId: string | null;
|
|
355
363
|
/** 该 park 绑定的 tool call(= `pendingAction.toolCallId`)。`unparseable` 行为 null。 */
|
|
356
364
|
boundCallId: string | null;
|
|
357
365
|
/** 服务端铸的入参摘要——判据 1 的第二道硬等式(与 `approval_ask.bound_input_hash` 相等才算命中)。 */
|
|
@@ -422,32 +430,24 @@ export declare const DECIDED_REPLAY_SCAN_CAP = 8;
|
|
|
422
430
|
* (plan_review / dry_run_review)的判词,那些门的决议入口不是本腿,回放它们等于跨门作答。
|
|
423
431
|
*/
|
|
424
432
|
export declare function approvalDecisionOfWinner(winner: ResolvedOutcome | undefined, boundCallId: string): "approve" | "deny" | null;
|
|
425
|
-
/**
|
|
426
|
-
|
|
427
|
-
*
|
|
428
|
-
* 🔴 三态、**不是**两态(真双库实跑抓到的缺陷,2026-08-06):「读不出」与「读出来了、但这条 park 本来就
|
|
429
|
-
* 没有 toolCallId」是两件事,压成同一个 `undefined` 会把每一条 `plan_review`/`task_done`/`resource_limit`
|
|
430
|
-
* 腿(core 的 `PendingAction` 联合里三个成员结构上就没有 toolCallId)都误报成坏行。前者应标 `unparseable`
|
|
431
|
-
* 交给收敛器当「不确定」,后者是**确定的不匹配**——干净地不是候选。
|
|
432
|
-
* - `{ readable: false }` —— JSON 坏 / 形状根本不是对象:真的读不出。
|
|
433
|
-
* - `{ readable: true, toolCallId: null }` —— 读出来了,这条 park 无工具动作:确定不匹配。
|
|
434
|
-
* - `{ readable: true, toolCallId: "…" }` —— 读出来了,拿去比。
|
|
435
|
-
*
|
|
436
|
-
* 逐层 `typeof` 收窄,不做裸 `as` 断言:blob 是持久层读回来的 `unknown`,是信任边界(宪法 [ref])。
|
|
437
|
-
*
|
|
438
|
-
* 🔴 [ref]:入参是**已经解过码的体**,不是一格列文本 —— 本函数不再自己 `JSON.parse`(SQL 车道的解码
|
|
439
|
-
* 唯一属主是 `sql-json-column.ts`,见 {@link pendingActionOfColumn};local 孪生本来就递一只对象进来)。
|
|
440
|
-
* 于是「串就再解一次」这条读法在这里按构造消失,两条车道递进来的东西同形。
|
|
441
|
-
*/
|
|
442
|
-
export declare function pendingActionToolCallId(body: unknown): {
|
|
433
|
+
/** 收敛器读口对一行的身份判词(三态 + 读不出;读法见 {@link pendingActionToolCallId} / {@link candidateIdentityOf})。 */
|
|
434
|
+
export type CandidateIdentity = {
|
|
443
435
|
readable: true;
|
|
444
436
|
toolCallId: string | null;
|
|
445
437
|
boundInputHash: string | null;
|
|
446
438
|
kind: string | null;
|
|
447
|
-
|
|
439
|
+
sourceSessionId: string | null;
|
|
448
440
|
} | {
|
|
449
441
|
readable: false;
|
|
450
442
|
};
|
|
443
|
+
/**
|
|
444
|
+
* 收敛器读口的**身份判词**(两只孪生同一只;`findCheckpointCandidatesForAsk` 的 SQL / LOCAL 两形都只经这里):先问 core 判官 `judgeCheckpointRow`
|
|
445
|
+
* (core 7.62.0 [ref],[ref])—— 判 `lacking`(更新的引擎能续它、本引擎缺读法:格式版本超上限,或要求表点名了本引擎不认的读法词)⇒ `{ readable: false }`:
|
|
446
|
+
* 本副本读不准这一行,交给收敛器当「不确定」,留给能续它的副本去绑(修前 SQL 孪生按 `version` 列比 `MAX_SUPPORTED_CHECKPOINT_VERSION`,
|
|
447
|
+
* 射程只有版本一轴,LOCAL 孪生没有这一臂)。`damaged` **不是**这一臂:没有哪个副本续得了它,身份读得出就照常判 —— 绑上之后续跑由判官给那句固定的拒,
|
|
448
|
+
* 比让 ask 停在 PARKING 诚实。其余三态见 {@link pendingActionToolCallId}。
|
|
449
|
+
*/
|
|
450
|
+
export declare function candidateIdentityOf(cp: Checkpoint): CandidateIdentity;
|
|
451
451
|
/** `pending_steer_queue` 列承载的 CheckpointState 字段(= core `appendPendingSteer` / `readPendingSteerQueue`
|
|
452
452
|
* 的入参形)。列是**唯一**权威(suspend 时写的 blob 从不带它)。 */
|
|
453
453
|
type SteerColumnState = Pick<CheckpointState, "pendingSteerQueue">;
|
|
@@ -536,6 +536,8 @@ export declare class SqlCheckpointStore implements CheckpointStore, KindlessBatc
|
|
|
536
536
|
/** ctx 改写的认领栅栏({@link SqlCheckpointStore.rewriteCtxWhileClaimed}):后端装配绑**同一只池**上的 run 店(`plugins/store-backend.ts` 的 `checkpoint()`)。
|
|
537
537
|
* 缺席 ⇒ 那一口响亮抛(装配缺陷),其余口不读它。 */
|
|
538
538
|
private readonly claims;
|
|
539
|
+
/** 停驻行投影记忆([ref] ④;运维队列与调度视图共用,见 {@link StoredRowProjectionMemo})。进程内、按店实例。 */
|
|
540
|
+
private readonly storedRowMemo;
|
|
539
541
|
constructor(db: SqlDriver, logger?: {
|
|
540
542
|
info?(msg: string, meta?: unknown): void;
|
|
541
543
|
} | undefined, opts?: SqlCheckpointStoreOptions);
|
|
@@ -711,21 +713,26 @@ export declare class SqlCheckpointStore implements CheckpointStore, KindlessBatc
|
|
|
711
713
|
*/
|
|
712
714
|
listPending(scope?: string): Promise<PendingCheckpoint[]>;
|
|
713
715
|
/**
|
|
714
|
-
*
|
|
715
|
-
* (授予绑定那一臂 —— 摘要 / 缺席词 —— 不在这里:[ref] 起由 {@link parkRowFacts} 读子树投出,本读口失败时它照在。)
|
|
716
|
+
* 运维队列 / 调度视图要的**整行事实**({@link StoredRowProjection}:判官的判决 + 技能卡两位),按令牌交回。
|
|
716
717
|
*
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
718
|
+
* 为什么要整行:判官 `judgeCheckpointRow` 读要求表要整只用(词集 + 摘要重算读整个 `state` 的表键路径,core [ref] ③);技能卡**清单**
|
|
719
|
+
* `boundGrants` 在寄存行上是未经哈希校验的原值,core 只在摘要里「哈希等于摘要」才发布它,校验读口不在 core 的公开导出面上 —— 两者都只能对整只
|
|
720
|
+
* {@link Checkpoint} 跑 core 的函数(摘要 `summarizeCheckpoint` 一次给两样)。
|
|
720
721
|
*
|
|
721
|
-
* 读放大(如实)
|
|
722
|
-
*
|
|
723
|
-
*
|
|
722
|
+
* 读放大(如实):记忆命中零整行读;未命中的行按令牌**批**读(`IN (…)`,每批 ≤ {@link STORED_ROW_READ_BATCH}),每份字节每个进程一次 ——
|
|
723
|
+
* 起服后第一次列表把全部待决行读一遍,此后只有字节变了 / 被挤出记忆的行再读(修前:普通卡零整行读,技能卡每次列表都读;`/stream` 每连接每 3 s 一拍)。
|
|
724
|
+
* 判过的按**读回的那份字节**的摘要入记忆;两次读之间字节变了(批读的摘要 ≠ 主读交来的那一份)⇒ 判过的那一份照入记忆,但**不交回**给这一行 ——
|
|
725
|
+
* 交回的事实只许出自主读读到的同一份字节(一行一个字节版本;修前按令牌拼,B 的判决与清单配 A 的行),这一行本次不带判决与清单(与「离开待决」同一种缺席),
|
|
726
|
+
* 下一次列表主读读到新字节即命中记忆。
|
|
724
727
|
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
728
|
+
* 失败方向(展示 / 分诊材料、行级容忍 + 响亮,与 {@link readParkRowActionCell} 同一条判据同一个 tag):整行解不出 ⇒ 这一行不在返回里(调用方行照列、
|
|
729
|
+
* 不带判决与清单),计 `server.approvals.park-row-blob-unreadable`;体是对象但 core 的摘要读不动(缺 `pendingAction` / `gate` 的手改行)⇒ 判决照给
|
|
730
|
+
* (判官是全函数),清单与成因词丢、同一个 tag 计数;两种都不进记忆(下一次列表重读、再计)。行已离开待决(两次读之间被决 / 过期)⇒ 不在返回里。
|
|
731
|
+
* `not-text`(读腿漏了投影)与摘要格形不对原样抛(码坏)。授予绑定那一臂(摘要 / 缺席词)不在这里:由 {@link parkRowFacts} 读子树投出,本读口失败时它照在。
|
|
727
732
|
*/
|
|
728
|
-
private
|
|
733
|
+
private storedRowProjections;
|
|
734
|
+
/** 一行整行读回 → 它的 {@link StoredRowProjection}(完整的入记忆;失败方向见 {@link SqlCheckpointStore.storedRowProjections})。 */
|
|
735
|
+
private projectStoredRow;
|
|
729
736
|
/**
|
|
730
737
|
* [ref] #2 (scheduler seam, core 1.105): a scope's PENDING checkpoints as lightweight
|
|
731
738
|
* {@link CheckpointSummary} rows in ONE query — the cross-task triage view a supervisor scheduler needs
|
|
@@ -772,16 +779,16 @@ export declare class SqlCheckpointStore implements CheckpointStore, KindlessBatc
|
|
|
772
779
|
* 若只看 pending 就会把「park 成功过」这个既成事实读成「没 park 过」⇒ 又是一条假阴性 DENIED
|
|
773
780
|
* (对账三约束③)。park 成功是事实,gate 的活性由 `status` 表达,交给收敛器自己判。
|
|
774
781
|
* - **单行读不出 ⇒ 标记返回,不抛**:`unparseable` 的行由收敛器视同「不匹配」,一条坏行不许打断整段
|
|
775
|
-
* 扫描(§8 C-6)。什么算读不出:
|
|
776
|
-
*
|
|
782
|
+
* 扫描(§8 C-6)。什么算读不出:core 判官对这一行答 `lacking`(更新的引擎能续它 —— 本副本不绑,见 {@link candidateIdentityOf};
|
|
783
|
+
* 这里不能 throw,否则一条超前行会让整个 session 的对账永久卡死)、或 blob JSON 坏。
|
|
777
784
|
*
|
|
778
785
|
* 匹配是两段的:`tool_call_id` **列**是 `put()` 从 `pendingAction.toolCallId` 盖下来的权威投影,SQL 谓词
|
|
779
786
|
* 先按它(或 NULL)收窄;列为 NULL 的行(无工具动作的 park,或列存在之前的旧行)靠解 blob 补判——解得出
|
|
780
787
|
* 且相等才算候选,解不出就标 `unparseable`。
|
|
781
788
|
* 🔴 **没有「列命中即零解析」的快路径**(原注写过,已作废,别照它优化):函数体对**每一行**无条件解
|
|
782
|
-
* blob,原因有二 ——(a)
|
|
789
|
+
* blob,原因有二 ——(a) 判官的 `lacking` 臂与 blob 可读性门必须门在**所有**命中路径之前(codex F3 + 确认轮:
|
|
783
790
|
* 列长得对不代表 blob 读得出,放行一条读不出的行去 `bindBatch` 会把 ask 钉成 PARKED + 一张本进程读不出
|
|
784
|
-
* 的 resume 坐标,而 PARKED 不可回滚);(b) `[ref]` 之后 blob 顶层的 `
|
|
791
|
+
* 的 resume 坐标,而 PARKED 不可回滚);(b) `[ref]` 之后 blob 顶层的 `sourceSessionId` 是和解三元组的第一
|
|
785
792
|
* 维,列命中行结构上也必须解 blob 才拿得到它。
|
|
786
793
|
*/
|
|
787
794
|
findCheckpointCandidatesForAsk(scope: string, sessionId: string, toolCallId: string, sinceMs: number): Promise<CheckpointAskCandidate[]>;
|
|
@@ -835,7 +842,7 @@ export declare class SqlCheckpointStore implements CheckpointStore, KindlessBatc
|
|
|
835
842
|
*
|
|
836
843
|
* 刻意**不带** `status='pending'` 谓词:判据是「这一行是不是你的」,与它此刻处在哪一态无关(`get()`
|
|
837
844
|
* 自己也是裸 `WHERE token = ?`);加了反而在「刚被并发消费」的窗里把属主自己的诊断吞掉。
|
|
838
|
-
* 只 SELECT `scope` 一列 ⇒
|
|
845
|
+
* 只 SELECT `scope` 一列 ⇒ 坏 blob 影响不到它(那是 `get()` 读 `checkpoint` 的事;7.144.0 起 `get()` 不再按版本列拒,本引擎续不续由 core 判官在续跑时答)。
|
|
839
846
|
*/
|
|
840
847
|
peekScopeByToken(token: CheckpointToken): Promise<string | null | undefined>;
|
|
841
848
|
peekPendingScope(sessionId: string, binding?: PendingRowBinding): Promise<string | null | undefined>;
|