@sema-agent/server 7.117.0 → 7.119.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 +182 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +58 -28
- package/deploy/sema-up/README.md +2 -0
- package/deploy/sema-up/chart/templates/minio.yaml +2 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +1 -0
- package/deploy/sema-up/chart/templates/server.yaml +1 -0
- package/deploy/sema-up/chart/values.yaml +7 -1
- package/deploy/sema-up/cluster-up.sh +20 -8
- package/deploy/sema-up/kube-up.sh +29 -16
- package/deploy/sema-up/lib/buckets.sh +21 -0
- package/deploy/sema-up/lib/health.sh +33 -0
- package/deploy/sema-up/sema-up.sh +14 -9
- package/deploy/sema-up/smoke.sh +16 -6
- package/deploy/sema-up/stack/compose.yaml +1 -1
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -1
- package/dist/approval-ask-audit-store.js +2 -7
- package/dist/approval-card.d.ts +40 -10
- package/dist/approval-card.js +11 -1
- package/dist/approval.d.ts +55 -17
- package/dist/approval.js +74 -33
- package/dist/audit.d.ts +12 -1
- package/dist/audit.js +62 -2
- package/dist/auto-mode-face.d.ts +2 -3
- package/dist/bake-runner/main.js +1 -6
- package/dist/bake-runner/protocol.d.ts +18 -0
- package/dist/bake-runner/protocol.js +22 -2
- package/dist/bake-runner/runner.d.ts +12 -8
- package/dist/bake-runner/runner.js +5 -9
- package/dist/boot/config-center.js +1 -1
- package/dist/boot/coordinators.js +4 -1
- package/dist/boot/device-lane.d.ts +3 -3
- package/dist/boot/device-lane.js +1 -2
- package/dist/boot/leader.d.ts +4 -4
- package/dist/boot/leader.js +1 -2
- package/dist/boot/parked-revive-gate.d.ts +4 -6
- package/dist/boot/parked-revive-gate.js +2 -6
- package/dist/boot/resolve-spec.js +9 -11
- package/dist/boot/runner-deps.js +2 -2
- package/dist/boot/stage-07-capability-layer.js +7 -3
- package/dist/boot/stage-10-http-server.js +3 -2
- package/dist/boot/stores.js +12 -7
- package/dist/capabilities/center-plugins.d.ts +2 -0
- package/dist/capabilities/center-plugins.js +24 -6
- package/dist/capabilities/code-review-council.js +8 -11
- package/dist/capabilities/hands-lane.d.ts +25 -0
- package/dist/capabilities/hands-lane.js +1 -1
- package/dist/capabilities/mcp-probe.d.ts +2 -2
- package/dist/capabilities/scenarios.d.ts +34 -7
- package/dist/capabilities/scenarios.js +33 -6
- package/dist/config-catalog.js +3 -3
- package/dist/config.d.ts +14 -18
- package/dist/config.js +15 -26
- package/dist/deployment-governance.d.ts +5 -7
- package/dist/deployment-governance.js +4 -5
- package/dist/host-decision.d.ts +114 -31
- package/dist/host-decision.js +39 -2
- package/dist/http/admission.js +12 -6
- package/dist/http/approval-sweeps.js +1 -1
- package/dist/http/mcp-dial-deadline.d.ts +35 -0
- package/dist/http/mcp-dial-deadline.js +21 -0
- package/dist/http/memory-compliance-failure-reply.d.ts +11 -5
- package/dist/http/memory-compliance-failure-reply.js +17 -8
- package/dist/http/memory-store-refusal-reply.d.ts +14 -11
- package/dist/http/memory-store-refusal-reply.js +16 -5
- package/dist/http/resume-legs.js +8 -3
- package/dist/http/routes/approvals-assistant.d.ts +25 -3
- package/dist/http/routes/approvals-assistant.js +27 -26
- package/dist/http/routes/capabilities.js +6 -3
- package/dist/http/routes/mcp-reconnect.d.ts +17 -0
- package/dist/http/routes/mcp-reconnect.js +6 -1
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/memory-origin.js +1 -1
- package/dist/http/routes/runs.js +47 -33
- package/dist/http/routes/sessions.d.ts +1 -1
- package/dist/http/routes/sessions.js +23 -22
- package/dist/http/routes/workflows.js +2 -0
- package/dist/http/wire-types.d.ts +17 -13
- package/dist/images/manifest.d.ts +7 -1
- package/dist/images/manifest.js +18 -16
- package/dist/memory-store-refusal.d.ts +38 -18
- package/dist/memory-store-refusal.js +25 -7
- package/dist/model-unreachable-notice.d.ts +1 -1
- package/dist/namespaced-rule-name.d.ts +46 -41
- package/dist/namespaced-rule-name.js +36 -22
- package/dist/observability/corrupt-read-seat.d.ts +4 -0
- package/dist/observability/corrupt-read-seat.js +1 -0
- package/dist/observability/fail-open.d.ts +19 -3
- package/dist/observability/fail-open.js +19 -3
- package/dist/operator-ask.d.ts +6 -2
- package/dist/orchestration/workflow-agent-session-index.d.ts +82 -59
- package/dist/orchestration/workflow-agent-session-index.js +80 -14
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -0
- package/dist/orchestration/workflow-completion-inbox.js +39 -17
- package/dist/orchestration/workflow-notify-journal.d.ts +1 -1
- package/dist/orchestration/workflow-notify-journal.js +7 -2
- package/dist/outbound-dispatcher.d.ts +29 -20
- package/dist/outbound-dispatcher.js +105 -16
- package/dist/parked-decide.d.ts +43 -48
- package/dist/parked-decide.js +54 -16
- package/dist/permission-rule-vocab.d.ts +4 -3
- package/dist/permission-rule-vocab.js +1 -1
- package/dist/plugins/approval-ask-store-sql.d.ts +17 -20
- package/dist/plugins/approval-ask-store-sql.js +0 -3
- package/dist/plugins/approval-exemption-store.d.ts +4 -0
- package/dist/plugins/approval-exemption-store.js +1 -0
- package/dist/plugins/blob-backend.d.ts +13 -0
- package/dist/plugins/blob-backend.js +26 -0
- package/dist/plugins/local-session-store.d.ts +78 -47
- package/dist/plugins/local-session-store.js +152 -122
- package/dist/plugins/one-time-migrations.d.ts +11 -0
- package/dist/plugins/one-time-migrations.js +128 -4
- package/dist/plugins/pg-pool.js +1 -1
- package/dist/plugins/snapshot-bucket-presence.d.ts +36 -0
- package/dist/plugins/snapshot-bucket-presence.js +40 -0
- package/dist/plugins/store-backend.d.ts +17 -6
- package/dist/plugins/store-backend.js +46 -16
- package/dist/plugins/store-open-wait.d.ts +33 -0
- package/dist/plugins/store-open-wait.js +73 -0
- package/dist/plugins/tidb-pool.js +1 -1
- package/dist/plugins/web-search.d.ts +20 -1
- package/dist/plugins/web-search.js +39 -10
- package/dist/plugins/workflow-run-store-sql.d.ts +7 -6
- package/dist/plugins/workflow-run-store-sql.js +5 -7
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +1 -1
- package/dist/rule-entry-list.d.ts +35 -46
- package/dist/rule-entry-list.js +18 -26
- package/dist/rules-consent.js +3 -0
- package/dist/run-local.js +5 -3
- package/dist/runs.d.ts +1 -1
- package/dist/security.d.ts +5 -3
- package/dist/security.js +4 -0
- package/dist/session-policy-wire.d.ts +13 -12
- package/dist/session-policy-wire.js +11 -11
- package/dist/spec-fields.d.ts +13 -11
- package/dist/spec-fields.js +4 -7
- package/dist/standing-answer-grant.d.ts +14 -2
- package/dist/standing-answer-grant.js +8 -1
- package/dist/store-posture.d.ts +14 -6
- package/dist/store-posture.js +7 -4
- package/dist/task-settings.d.ts +27 -55
- package/dist/task-settings.js +13 -21
- package/dist/tool-approval.d.ts +133 -138
- package/dist/tool-approval.js +175 -66
- package/dist/trace/core-keyset-guard.d.ts +5 -5
- package/dist/trace/redact.d.ts +6 -0
- package/dist/trace/redact.js +9 -9
- package/dist/trace/self-minted-wire.d.ts +16 -2
- package/dist/trace/self-minted-wire.js +7 -0
- package/dist/user-input-ledger.d.ts +30 -14
- package/dist/user-input-ledger.js +25 -14
- package/package.json +2 -2
- package/scripts/drain-check-local.mjs +74 -3
- package/scripts/drain-check.mysql.sql +43 -17
- package/scripts/drain-check.pg.sql +46 -20
package/dist/bake-runner/main.js
CHANGED
|
@@ -73,12 +73,7 @@ function makeApiClient(env, log) {
|
|
|
73
73
|
body: JSON.stringify(frame),
|
|
74
74
|
signal: AbortSignal.timeout(BAKE_CLAIM_INGEST_FETCH_TIMEOUT_MS),
|
|
75
75
|
});
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
accepted: res.ok && body.accepted !== false,
|
|
79
|
-
cancelRequested: body.cancelRequested === true,
|
|
80
|
-
leaseValid: res.status !== 409,
|
|
81
|
-
};
|
|
76
|
+
await res.arrayBuffer().catch(() => undefined);
|
|
82
77
|
},
|
|
83
78
|
async heartbeat(bakeId, ingestSecret) {
|
|
84
79
|
const res = await fetch(`${env.imageApiBase}/v1/images/bakes/${encodeURIComponent(bakeId)}/ingest`, {
|
|
@@ -78,6 +78,11 @@ export declare function dockerBuildTickFrame(lineOrd: number, elapsedSec: number
|
|
|
78
78
|
export declare function synthDoneFrame(lineOrd: number, kind: "cancelled" | "timeout", detail?: {
|
|
79
79
|
error?: string;
|
|
80
80
|
}): IngestFrame;
|
|
81
|
+
/**
|
|
82
|
+
* 失败尾巴的行数 —— **唯一**常量:缓冲({@link createStderrTail})保留这么多行,终局句({@link exitDoneFrame})取这么多行。
|
|
83
|
+
* 两处读同一个数,所以缓冲里「保留的」恒等于消费方「要的」:既没有消费方想要而已被丢掉的行,也没有永远用不上的行占内存。
|
|
84
|
+
*/
|
|
85
|
+
export declare const STDERR_TAIL_LINES = 12;
|
|
81
86
|
/**
|
|
82
87
|
* The runner-side terminal `done` for a build.sh CHILD that exited non-zero WITHOUT printing its own `done` (build.sh
|
|
83
88
|
* normally dies via `die()` which DOES print a `done:FAILED`, but a SIGKILL or a crash before the trap can leave the
|
|
@@ -87,6 +92,19 @@ export declare function synthDoneFrame(lineOrd: number, kind: "cancelled" | "tim
|
|
|
87
92
|
export declare function exitDoneFrame(lineOrd: number, exitCode: number, stderrTail: string): IngestFrame;
|
|
88
93
|
/** Keep only the last `n` lines of a (possibly long) stderr tail — bounds the error string we forward. */
|
|
89
94
|
export declare function lastLines(text: string, n: number): string;
|
|
95
|
+
/** 有界的 stderr 尾部缓冲:只保留**末** {@link STDERR_TAIL_LINES} 行(环形:新行进来、最老的出去)。 */
|
|
96
|
+
export interface StderrTail {
|
|
97
|
+
/** 收一行(spawner 已按换行切好;这里仍按 {@link contentLines} 判据过一遍,空行不入)。 */
|
|
98
|
+
push(raw: string): void;
|
|
99
|
+
/** 当前保留的行,`\n` 连接;空缓冲 = 空串。可直接交 {@link exitDoneFrame}。 */
|
|
100
|
+
text(): string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 修前缓冲是 `if (stderrTail.length < 80) push` —— 留的是**首** 80 行,而消费方({@link exitDoneFrame})要的是**末** 12 行:
|
|
104
|
+
* 超过 80 行的失败里,「尾巴」是前 80 行的末 12 行,真正的最后一行(失败原因所在)一个字也进不来。
|
|
105
|
+
* 现在留末 N 行;N = {@link STDERR_TAIL_LINES}。
|
|
106
|
+
*/
|
|
107
|
+
export declare function createStderrTail(): StderrTail;
|
|
90
108
|
/**
|
|
91
109
|
* The profile-aware HARD DEADLINE (§P2.7/§P2.11) the runner enforces by killing the process group. flutter/full are
|
|
92
110
|
* the heavy profiles (~60min); everything else ~45min. A bands build ("custom") is treated as heavy if it includes
|
|
@@ -33,6 +33,7 @@ export function synthDoneFrame(lineOrd, kind, detail) {
|
|
|
33
33
|
}
|
|
34
34
|
return { event: "done", lineOrd, status: "FAILED", exitCode: 124, error: detail?.error ?? "bake hard-deadline exceeded (killed)" };
|
|
35
35
|
}
|
|
36
|
+
export const STDERR_TAIL_LINES = 12;
|
|
36
37
|
export function exitDoneFrame(lineOrd, exitCode, stderrTail) {
|
|
37
38
|
const tail = stderrTail.trim();
|
|
38
39
|
return {
|
|
@@ -40,13 +41,32 @@ export function exitDoneFrame(lineOrd, exitCode, stderrTail) {
|
|
|
40
41
|
lineOrd,
|
|
41
42
|
status: "FAILED",
|
|
42
43
|
exitCode,
|
|
43
|
-
error: tail.length > 0 ? `build.sh exited ${exitCode}: ${lastLines(tail,
|
|
44
|
+
error: tail.length > 0 ? `build.sh exited ${exitCode}: ${lastLines(tail, STDERR_TAIL_LINES)}` : `build.sh exited ${exitCode}`,
|
|
44
45
|
};
|
|
45
46
|
}
|
|
47
|
+
function contentLines(text) {
|
|
48
|
+
return text
|
|
49
|
+
.split(/\r?\n/)
|
|
50
|
+
.map((l) => l.replace(/\r$/, ""))
|
|
51
|
+
.filter((l) => l.length > 0);
|
|
52
|
+
}
|
|
46
53
|
export function lastLines(text, n) {
|
|
47
|
-
const lines = text
|
|
54
|
+
const lines = contentLines(text);
|
|
48
55
|
return lines.slice(Math.max(0, lines.length - n)).join("\n");
|
|
49
56
|
}
|
|
57
|
+
export function createStderrTail() {
|
|
58
|
+
const lines = [];
|
|
59
|
+
return {
|
|
60
|
+
push(raw) {
|
|
61
|
+
for (const l of contentLines(raw)) {
|
|
62
|
+
lines.push(l);
|
|
63
|
+
if (lines.length > STDERR_TAIL_LINES)
|
|
64
|
+
lines.shift();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
text: () => lines.join("\n"),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
50
70
|
export function deadlineMsForProfile(profile, bands) {
|
|
51
71
|
const HEAVY_MS = 60 * 60 * 1000;
|
|
52
72
|
const NORMAL_MS = 45 * 60 * 1000;
|
|
@@ -11,10 +11,12 @@ export interface ClaimedBake {
|
|
|
11
11
|
profile?: string | null;
|
|
12
12
|
bands?: string[] | null;
|
|
13
13
|
}
|
|
14
|
-
/** The
|
|
15
|
-
|
|
14
|
+
/** The heartbeat response (a no-frame `…/ingest` POST) — image-api echoes whether a cancel was requested so the runner
|
|
15
|
+
* kills the group, and whether the lease is still ours. The heartbeat is the ONE place these two bits are read
|
|
16
|
+
* ({@link BakeRunner.runOne}'s supervisor); a frame ingest's ack has no reader, so `ingest` returns nothing. */
|
|
17
|
+
export interface HeartbeatAck {
|
|
16
18
|
accepted: boolean;
|
|
17
|
-
/** The durable cancel flag (§P2.11) —
|
|
19
|
+
/** The durable cancel flag (§P2.11) — read off each HEARTBEAT response (≤ heartbeat-interval lag). */
|
|
18
20
|
cancelRequested?: boolean;
|
|
19
21
|
/** False when the lease was lost/stolen (the runner aborts + kills the child — it no longer owns the build). */
|
|
20
22
|
leaseValid?: boolean;
|
|
@@ -51,10 +53,11 @@ export interface ChildSpawner {
|
|
|
51
53
|
export interface ImageApiClient {
|
|
52
54
|
/** Long-poll for + claim the next queued bake; null when none is claimable right now. */
|
|
53
55
|
claimNext(): Promise<ClaimedBake | null>;
|
|
54
|
-
/** POST one frame to `…/ingest` (carries the per-bake ingest secret header)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/** POST one frame to `…/ingest` (carries the per-bake ingest secret header). Resolves with nothing: the runner reads no
|
|
57
|
+
* ack off a frame ingest (the cancel / lease bits are read off {@link ImageApiClient.heartbeat} only). */
|
|
58
|
+
ingest(bakeId: string, ingestSecret: string, frame: Record<string, unknown>): Promise<void>;
|
|
59
|
+
/** Heartbeat the lease forward and surface the cancel / lease state — the only call whose response the runner reads. */
|
|
60
|
+
heartbeat(bakeId: string, ingestSecret: string): Promise<HeartbeatAck>;
|
|
58
61
|
}
|
|
59
62
|
/** Host-side ops the runner needs that are NOT image-api calls (fs + a thin docker-push wrapper for the big-blob
|
|
60
63
|
* retry — NOT a build.sh --replay). All injected so the orchestration is testable off build-host. */
|
|
@@ -208,7 +211,8 @@ export declare class BakeRunner {
|
|
|
208
211
|
* reaper + a mid-build fill guard still protect the host). */
|
|
209
212
|
private freeGbOrNull;
|
|
210
213
|
/** Ingest one frame, swallowing transient errors (the buffered-retry of unsent lines is the real-runner's job;
|
|
211
|
-
* image-api's uq_line makes a re-send a no-op, so a dropped frame is recoverable, never a crash).
|
|
214
|
+
* image-api's uq_line makes a re-send a no-op, so a dropped frame is recoverable, never a crash). Returns nothing:
|
|
215
|
+
* the cancel / lease bits are read off the heartbeat response only, never off a frame ingest's ack. */
|
|
212
216
|
private safeIngest;
|
|
213
217
|
}
|
|
214
218
|
/** Allocate the next per-bake lineOrd (monotonic from 1) — the at-least-once ingest dedupe key (§P2.10). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve as resolvePath } from "node:path";
|
|
2
|
-
import { lineToFrame, dockerBuildTickFrame, synthDoneFrame, exitDoneFrame, deadlineMsForProfile, parseDfFreeGb, parseBuildShLine, manifestPathFromLine, } from "./protocol.js";
|
|
2
|
+
import { lineToFrame, dockerBuildTickFrame, synthDoneFrame, exitDoneFrame, deadlineMsForProfile, parseDfFreeGb, parseBuildShLine, manifestPathFromLine, createStderrTail, } from "./protocol.js";
|
|
3
3
|
const DEFAULT_HEARTBEAT_MS = 30_000;
|
|
4
4
|
const DEFAULT_IDLE_POLL_MS = 5_000;
|
|
5
5
|
const DEFAULT_MIN_FREE_GB = 20;
|
|
@@ -137,7 +137,7 @@ export class BakeRunner {
|
|
|
137
137
|
await this.safeIngest(bake, exitDoneFrame(nextOrd(ord), 1, `recipe checkout failed: ${String(err)}`));
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
const stderrTail =
|
|
140
|
+
const stderrTail = createStderrTail();
|
|
141
141
|
let lastManifestPath = null;
|
|
142
142
|
let lastImageTag = null;
|
|
143
143
|
let sawDone = false;
|
|
@@ -166,10 +166,7 @@ export class BakeRunner {
|
|
|
166
166
|
}
|
|
167
167
|
enqueueIngest(lineToFrame(raw, nextOrd(ord)));
|
|
168
168
|
},
|
|
169
|
-
onStderrLine: (raw) =>
|
|
170
|
-
if (stderrTail.length < 80)
|
|
171
|
-
stderrTail.push(raw);
|
|
172
|
-
},
|
|
169
|
+
onStderrLine: (raw) => stderrTail.push(raw),
|
|
173
170
|
});
|
|
174
171
|
inFlight.child = child;
|
|
175
172
|
const deadlineMs = deadlineMsForProfile(bake.profile ?? "custom", bake.bands ?? null);
|
|
@@ -230,7 +227,7 @@ export class BakeRunner {
|
|
|
230
227
|
return;
|
|
231
228
|
}
|
|
232
229
|
const code = exit.code ?? (exit.signal ? 137 : 1);
|
|
233
|
-
await this.safeIngest(bake, exitDoneFrame(nextOrd(ord), code, stderrTail.
|
|
230
|
+
await this.safeIngest(bake, exitDoneFrame(nextOrd(ord), code, stderrTail.text()));
|
|
234
231
|
}
|
|
235
232
|
async forwardDone(bake, ord, doneLine, lastManifestPath, lastImageTag) {
|
|
236
233
|
let line = doneLine;
|
|
@@ -309,11 +306,10 @@ export class BakeRunner {
|
|
|
309
306
|
}
|
|
310
307
|
async safeIngest(bake, frame) {
|
|
311
308
|
try {
|
|
312
|
-
|
|
309
|
+
await this.o.api.ingest(bake.bakeId, bake.ingestSecret, frame);
|
|
313
310
|
}
|
|
314
311
|
catch (err) {
|
|
315
312
|
this.o.log.warn("bake_ingest_error", { bakeId: bake.bakeId, lineOrd: frame.lineOrd, err: String(err) });
|
|
316
|
-
return null;
|
|
317
313
|
}
|
|
318
314
|
}
|
|
319
315
|
}
|
|
@@ -624,7 +624,7 @@ export async function createConfigCenterRuntime(ctx) {
|
|
|
624
624
|
if (effective?.skills && config.configCenter) {
|
|
625
625
|
skills = await applyCenterSkills(skills, effective.skills, config.configCenter, logger, undefined, configLkgEnabled() ? defaultSkillCacheDir() : undefined);
|
|
626
626
|
}
|
|
627
|
-
if (effective?.plugins) {
|
|
627
|
+
if (effective?.plugins !== undefined) {
|
|
628
628
|
const pluginOut = await applyCenterPlugins(skills, effective, {
|
|
629
629
|
cacheRoot: join(config.localDataRoot ?? join(homedir(), ".ai-agent"), "plugin-cache"),
|
|
630
630
|
allowHosts: config.pluginsAllowHosts,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ElicitationCoordinator } from "../elicitation.js";
|
|
2
2
|
import { QuestionCoordinator } from "../question.js";
|
|
3
3
|
import { ToolApprovalCoordinator, resolveStreamApprovalGate } from "../tool-approval.js";
|
|
4
|
+
import { deploymentListAsks } from "../approval.js";
|
|
4
5
|
import { FileApprovalAskAuditStore } from "../approval-ask-audit-store.js";
|
|
5
6
|
import { SendUserFileEmitter, SEND_USER_FILE_MAX_BYTES, sendUserFileTool } from "../capabilities/send-user-file-tool.js";
|
|
6
7
|
import { createSandboxFileSend, TaskEnvRegistry } from "../capabilities/sandbox-file-send.js";
|
|
@@ -58,7 +59,9 @@ export function createLiveCoordinators(ctx) {
|
|
|
58
59
|
unattendedPolicy: config.unattendedApprovalPolicy,
|
|
59
60
|
...(getParkedRedeem !== undefined ? { parkedRedeem: getParkedRedeem } : {}),
|
|
60
61
|
...(approvalAskAudit !== undefined ? { askAudit: approvalAskAudit } : {}),
|
|
61
|
-
...(approvalExemptionStore !== undefined
|
|
62
|
+
...(approvalExemptionStore !== undefined
|
|
63
|
+
? { sessionGrants: approvalExemptionStore, deploymentListAsks: (call) => deploymentListAsks(config, call) }
|
|
64
|
+
: {}),
|
|
62
65
|
...(parkCommits !== undefined ? { parkCommits } : {}),
|
|
63
66
|
})
|
|
64
67
|
: undefined;
|
|
@@ -59,9 +59,9 @@ export declare function createDeviceLane(ctx: DeviceLaneCtx): DeviceLane | undef
|
|
|
59
59
|
* `boot/leader.ts` 的 `assertLeaderDurableStore`)。
|
|
60
60
|
*
|
|
61
61
|
* config 层的门①判的是「运维配没配 SQL 坐标」——那句话回答的是**意图**。它回答不了「这次启动**真的
|
|
62
|
-
* 拿到**了店吗」:`openStoreBackendWithFallback`
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* 拿到**了店吗」:`openStoreBackendWithFallback` 曾在 `SESSION_BACKEND=auto` 下,SQL 连不上 /
|
|
63
|
+
* 建表失败 ⇒ `backend=undefined` + 一条 warn 就继续启动(那条降级臂已退役:配了 DSN 的库窗内重试、到窗拒启,见 `plugins/store-open-wait.ts`;
|
|
64
|
+
* 仍走得到本门的形:`DB_BACKEND=mysql|pg` 声明了 SQL 而 `SESSION_BACKEND=memory`,刻意不持久 ⇒ 不开店)。那次启动里 device lane 的四表整个不在,
|
|
65
65
|
* 而 `boot/execution-env.ts` 的第七臂拿不到三件 ⇒ `executionEnvFactory` 落 `undefined` ⇒ core 拿
|
|
66
66
|
* `StubExecutionEnv`:**一台自称在员工设备上执行的 worker 实际在自己进程里跑,而且回执同形**。
|
|
67
67
|
* 那正是 [ref]「执行车道禁静默降级」点名的样板病,也正是 A-1 那条临时门当初要拦的东西 —— 换执法点,
|
package/dist/boot/device-lane.js
CHANGED
|
@@ -40,8 +40,7 @@ export function assertDeviceLaneWired(isDeviceLane, lane, hasFactory) {
|
|
|
40
40
|
return;
|
|
41
41
|
if (!lane) {
|
|
42
42
|
throw new Error("REMOTE_EXEC=device but the device lane could not be wired at boot [device-lane-unwired]: the SQL backend is " +
|
|
43
|
-
"configured yet this replica did not get one
|
|
44
|
-
"when SESSION_BACKEND=auto), so the device registry / session↔device binding / audit tables are absent. " +
|
|
43
|
+
"configured yet this replica did not get one, so the device registry / session↔device binding / audit tables are absent. " +
|
|
45
44
|
"Refusing to serve a lane that would silently fall back to the in-process stub env — a worker claiming to " +
|
|
46
45
|
"execute on the employee's device while actually running inside its own process (#157). Fix the database " +
|
|
47
46
|
"(or unset REMOTE_EXEC) and restart (device-executor-lane-v2 §4.7)");
|
package/dist/boot/leader.d.ts
CHANGED
|
@@ -64,10 +64,10 @@ export declare function leaderK8sMinioGap(leaderEnabled: boolean, leaderProvider
|
|
|
64
64
|
* [ref] 车4 件2 的**能力面**门(codex 交叉复审 R1-high①,验真后修)。
|
|
65
65
|
*
|
|
66
66
|
* config 层的门②判的是 `DB_BACKEND` 的字面值 —— 那句话回答的是「运维要没要 durable」。它回答不了
|
|
67
|
-
* 「这次启动**真的拿到**了 durable 吗」:`openStoreBackendWithFallback`
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* `leaderRun()` 缺席,leader 端点会静默落进单副本内存臂:多副本各自受理同一个 Idempotency-Key、
|
|
67
|
+
* 「这次启动**真的拿到**了 durable 吗」:`openStoreBackendWithFallback` 曾在 `SESSION_BACKEND=auto`
|
|
68
|
+
* 下,SQL 连不上 / 建表失败 ⇒ 返回 `backend=undefined` + 一条 warn 就继续启动(那条降级臂已退役:配了 DSN 的库窗内重试、到窗拒启,
|
|
69
|
+
* 见 `plugins/store-open-wait.ts`)。仍走得到本门的形:`DB_BACKEND=mysql|pg` 声明了 SQL 而 `SESSION_BACKEND=memory`(声明 pg、刻意不持久 ⇒ 不开店)。
|
|
70
|
+
* 那次启动里 `leaderRun()` 缺席,leader 端点会静默落进单副本内存臂:多副本各自受理同一个 Idempotency-Key、
|
|
71
71
|
* 跨副本 GET 404、重启失忆 —— 而这条腿的产物是**真 git push**。
|
|
72
72
|
*
|
|
73
73
|
* ⇒ 判据锚**真拿到了没有**。纯谓词、只吃两个原语(与 {@link leaderK8sMinioGap} 同姿势),便于单测。
|
package/dist/boot/leader.js
CHANGED
|
@@ -15,8 +15,7 @@ export function assertLeaderDurableStore(leaderEnabled, hasLeaderRunStore) {
|
|
|
15
15
|
if (!leaderEnabled || hasLeaderRunStore)
|
|
16
16
|
return;
|
|
17
17
|
throw new Error("LEADER_ENABLED=true but no durable leader-run store is available at boot — the SQL backend is configured " +
|
|
18
|
-
"yet this replica did not get one
|
|
19
|
-
"SESSION_BACKEND=auto). Refusing to serve the leader endpoint from a single-replica in-memory registry: " +
|
|
18
|
+
"yet this replica did not get one. Refusing to serve the leader endpoint from a single-replica in-memory registry: " +
|
|
20
19
|
"the `leader_run` table is what makes a retried submit idempotent and a cross-replica GET answerable, and " +
|
|
21
20
|
"without it a retry starts a SECOND real git push. Fix the database (or unset LEADER_ENABLED) and restart " +
|
|
22
21
|
"(#193 车4 件2 capability gate; the DB_BACKEND literal check in config.ts is the intent half of the same rule)");
|
|
@@ -3,6 +3,7 @@ import type { ServiceConfig } from "../config.js";
|
|
|
3
3
|
import type { RunnerDepsOnAsk } from "./runner-deps.js";
|
|
4
4
|
import { type ApprovalBaselineConfigView, type DeploymentGovernanceConfigView, type LiveQuestionFace } from "../deployment-governance.js";
|
|
5
5
|
import { type SandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
|
|
6
|
+
import type { ApprovalExemptionStore } from "../plugins/approval-exemption-store.js";
|
|
6
7
|
/** 本腿读的配置切面(`ServiceConfig` 结构满足)。两个构造口各自的切面 + lane 判别式读的 `remoteExec`。 */
|
|
7
8
|
export interface ParkedReviveGateConfigView extends DeploymentGovernanceConfigView, ApprovalBaselineConfigView {
|
|
8
9
|
readonly remoteExec?: ServiceConfig["remoteExec"];
|
|
@@ -11,10 +12,6 @@ export interface ParkedReviveGateConfigView extends DeploymentGovernanceConfigVi
|
|
|
11
12
|
/** host 腿裁决 env 的 cwd 占位根(见下方 `hostGateCwd`)。 */
|
|
12
13
|
readonly localDataRoot?: ServiceConfig["localDataRoot"];
|
|
13
14
|
}
|
|
14
|
-
/** 会话豁免探针店的所需切面(canonical toolName 键空间;`StoreBackend.approvalExemption()` 结构满足)。 */
|
|
15
|
-
export interface ApprovalExemptionProbe {
|
|
16
|
-
has(sessionId: string, toolName: string): Promise<boolean>;
|
|
17
|
-
}
|
|
18
15
|
export interface ParkedReviveGateDeps {
|
|
19
16
|
/** ⚠️ **活引用**:热改字段(autonomy/commandPolicy/守卫集/审批四旋钮)每次赎回现读,见下方「禁 memoize」。 */
|
|
20
17
|
readonly config: ParkedReviveGateConfigView;
|
|
@@ -47,7 +44,8 @@ export interface ParkedReviveGateDeps {
|
|
|
47
44
|
* headless auto-deny,比「再问人一次」严且哑。交了之后最坏也是 park,方向 fail-safe。
|
|
48
45
|
*/
|
|
49
46
|
readonly approverSeat: RunnerDepsOnAsk | undefined;
|
|
50
|
-
|
|
47
|
+
/** 会话豁免店(部署名单那一问的「本会话放行」读面;`StoreBackend.approvalExemption()` 结构满足)。缺席 = 部署没有 store backend ⇒ 名单照问。 */
|
|
48
|
+
readonly approvalExemptionStore: Pick<ApprovalExemptionStore, "has"> | undefined;
|
|
51
49
|
/**
|
|
52
50
|
* [ref] —— core `RunnerDeps.runtimeCapsResolver` 的**同一只**(main.ts 的 `runtimeCapsResolver`,
|
|
53
51
|
* 单一属主同 `boot/runtime-caps.ts`)。重建条目的第三位决议链元数据 `autoModeArmed` 的唯一判据是
|
|
@@ -96,7 +94,7 @@ export type RebuiltParentConstraint = NonNullable<RebuiltInheritedGate["parentCo
|
|
|
96
94
|
* 赎回腿的父约束链重建([ref] 件二)。
|
|
97
95
|
*
|
|
98
96
|
* 语义:**同/跨副本一致地重建「部署 ⊇ 操作员」两层完整链**——审批基线(durable question 门 + F4 高危写
|
|
99
|
-
* 审批门 +
|
|
97
|
+
* 审批门 + 部署名单那一问的豁免读面)作 base 的 `toolPolicy` 座,经**折叠属主** `applyRuntimeGovernance`
|
|
100
98
|
* (→ core `tightenTaskSpec`)叠上部署治理段(autonomy / commandPolicy / MANUAL_MODE_SHELL_GATE /
|
|
101
99
|
* 守卫集),取其 `toolPolicy` 装进单层 `parentConstraints`。
|
|
102
100
|
*
|
|
@@ -6,6 +6,7 @@ import { createApprovalBaselinePolicy, createDeploymentGovernanceInputs, } from
|
|
|
6
6
|
import { applyRuntimeGovernance } from "../runtime-governance.js";
|
|
7
7
|
import { DeferredSandboxPathEnv, isSandboxPathAdjudicationLane, sandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
|
|
8
8
|
import { executionLaneHomeDir } from "../execution-lane-caps.js";
|
|
9
|
+
import { createDeploymentListExemption } from "../approval.js";
|
|
9
10
|
function hostGateCwd(config, localRoot) {
|
|
10
11
|
return join(config.localDataRoot ?? localRoot, "parked-revive-unrooted");
|
|
11
12
|
}
|
|
@@ -30,12 +31,7 @@ export function createParkedReviveInheritedGate(deps) {
|
|
|
30
31
|
const baseline = createApprovalBaselinePolicy(config, {
|
|
31
32
|
kind: "durable",
|
|
32
33
|
question,
|
|
33
|
-
...(approvalExemptionStore && rootSessionId
|
|
34
|
-
? {
|
|
35
|
-
exempt: (toolName) => approvalExemptionStore.has(rootSessionId, toolName),
|
|
36
|
-
onExempted: (toolName, rawToolName) => logger.info("approval_exempted", { sessionId: rootSessionId, toolName, rawToolName, leg: "parked_revive" }),
|
|
37
|
-
}
|
|
38
|
-
: {}),
|
|
34
|
+
...(approvalExemptionStore !== undefined && rootSessionId ? { exemption: createDeploymentListExemption(approvalExemptionStore, rootSessionId, logger, "parked_revive") } : {}),
|
|
39
35
|
});
|
|
40
36
|
const governed = applyRuntimeGovernance({ objective: "", toolPolicy: baseline }, createDeploymentGovernanceInputs(config, pathAdjudication, { engineDataRoot: memoryEngineRoot }));
|
|
41
37
|
return {
|
|
@@ -10,7 +10,7 @@ import { stampHandsLane, toolPolicyForHands } from "../capabilities/hands-lane.j
|
|
|
10
10
|
import { buildNoticeLaneFacts, shouldDiscloseNoPersistentMemory, withNoPersistentMemoryNotice } from "../capabilities/memory-notice.js";
|
|
11
11
|
import { applyLongtailDefer } from "../capabilities/tool-defer.js";
|
|
12
12
|
import { assertGuardPatternsUsable, buildApprovalGrantNotice, buildOnlySensitiveBaselineWarning, createApprovalBaselinePolicy, createDeploymentGovernanceInputs } from "../deployment-governance.js";
|
|
13
|
-
import { singleUserAutoAcceptBaselineApplies } from "../approval.js";
|
|
13
|
+
import { createDeploymentListExemption, gateIntentUnserviceableReason, singleUserAutoAcceptBaselineApplies } from "../approval.js";
|
|
14
14
|
import { acceptShellScratchpadDir, buildEnvFacts, egressForRemoteExec, ensureScratchpadDir, resumeFactsForLane, scratchpadCoveringTaskRoot } from "../env-facts.js";
|
|
15
15
|
import { FleetEventBus } from "../fleet/fleet-bus.js";
|
|
16
16
|
import { composeHooks, createTaskHooks } from "../hooks/hook-runner.js";
|
|
@@ -27,7 +27,7 @@ import { isIsolatedExecEnv, routeServiceTask, supPostureOverrides } from "../rou
|
|
|
27
27
|
import { tightenGoverned } from "../governance-overrides.js";
|
|
28
28
|
import { gateExecutionLane } from "../runtime-caps-resolver.js";
|
|
29
29
|
import { applyRuntimeGovernance, stripDelegationTools } from "../runtime-governance.js";
|
|
30
|
-
import { HttpError, encodeCheckpointScope } from "../security.js";
|
|
30
|
+
import { HttpError, createCodedHttpError, encodeCheckpointScope } from "../security.js";
|
|
31
31
|
import { memoryProjectKeyFor, memorySpecForRequest } from "../memory-scope.js";
|
|
32
32
|
import { inheritEnvFieldIssue, singleMemberOffFieldIssue } from "../request-value-closure.js";
|
|
33
33
|
import { a2aForScenario, mcpForScenario } from "../config-center/facade.js";
|
|
@@ -65,6 +65,9 @@ export function createResolveSpec(ctx) {
|
|
|
65
65
|
if (approvalGrantNotice)
|
|
66
66
|
logger.info(approvalGrantNotice.event, approvalGrantNotice.fields);
|
|
67
67
|
const resolveSpec = async (body, req, auth, opts) => {
|
|
68
|
+
const seatRefusal = gateIntentUnserviceableReason(config, checkpointStore !== undefined);
|
|
69
|
+
if (seatRefusal !== undefined)
|
|
70
|
+
throw createCodedHttpError(501, "capability.checkpoint_store_required", seatRefusal);
|
|
68
71
|
assertRequestMcpUnlocked(body.mcpServers, lockedKeys);
|
|
69
72
|
if (opts?.leg === "fresh")
|
|
70
73
|
assertRequestMcpContentOrigin(body.mcpServers);
|
|
@@ -134,9 +137,8 @@ export function createResolveSpec(ctx) {
|
|
|
134
137
|
return stamped;
|
|
135
138
|
};
|
|
136
139
|
const gateScenarioAndAppend = async (body, auth, opts) => {
|
|
137
|
-
const
|
|
140
|
+
const scenarioName = gateScenarioRequest(await principalCaps?.scenarioRuling(auth?.principal), body.scenario, config.defaultScenario, Object.keys(scenarios), logger, auth?.principal);
|
|
138
141
|
gateExecutionLane(await principalCaps?.executionRuling(auth?.principal), executionLaneOf(config.remoteExec?.provider), logger);
|
|
139
|
-
const scenarioName = scenarios[requested] ? requested : "default";
|
|
140
142
|
const cap = selectScenario(scenarios, scenarioName)(body, auth?.principal, auth?.sessionId !== undefined ? { sessionId: auth.sessionId } : {});
|
|
141
143
|
const centerDecls = getCenterPrompts()?.declarations;
|
|
142
144
|
const appendLessPack = centerDecls
|
|
@@ -320,7 +322,7 @@ export function createResolveSpec(ctx) {
|
|
|
320
322
|
return false;
|
|
321
323
|
if (headerStr(req?.headers["x-detach-on-disconnect"]) === "true")
|
|
322
324
|
return false;
|
|
323
|
-
const askForm = resolveAskSeamForm({}, approverSeat !== undefined ? { onAsk: approverSeat } : {});
|
|
325
|
+
const askForm = resolveAskSeamForm(body.approvalReach !== undefined ? { approvalReach: body.approvalReach } : {}, approverSeat !== undefined ? { onAsk: approverSeat } : {});
|
|
324
326
|
return deriveAskEffective(askForm.form, "unresolved") === "human_reachable";
|
|
325
327
|
};
|
|
326
328
|
const assembleSpecLiteral = (body, auth, req, opts, parts, effMode) => {
|
|
@@ -369,6 +371,7 @@ export function createResolveSpec(ctx) {
|
|
|
369
371
|
...(() => { const v = toolMaterializeStrategyFromBody(body.toolMaterializeStrategy); return v ? { toolMaterializeStrategy: v } : {}; })(),
|
|
370
372
|
...(typeof body.interactiveTools === "boolean" ? { interactiveTools: body.interactiveTools } : {}),
|
|
371
373
|
...(declaresInteractivePosture(body, req, opts) ? { interactionPosture: "interactive" } : {}),
|
|
374
|
+
...(body.approvalReach !== undefined ? { approvalReach: body.approvalReach } : {}),
|
|
372
375
|
...(typeof body.oneShot === "boolean" ? { oneShot: body.oneShot } : {}),
|
|
373
376
|
resilience: normalizeResilience(body.resilience, explicitOperatorOk(auth?.principal, config.operatorPrincipals)),
|
|
374
377
|
finalVerification: cap.finalVerification === true || body.finalVerification === true ? true : undefined,
|
|
@@ -459,12 +462,7 @@ export function createResolveSpec(ctx) {
|
|
|
459
462
|
? createApprovalBaselinePolicy(config, {
|
|
460
463
|
kind: "durable",
|
|
461
464
|
question: liveQuestionFace,
|
|
462
|
-
...(approvalExemptionStore && auth?.sessionId
|
|
463
|
-
? {
|
|
464
|
-
exempt: (toolName) => approvalExemptionStore.has(auth.sessionId, toolName),
|
|
465
|
-
onExempted: (toolName, rawToolName) => logger.info("approval_exempted", { sessionId: auth.sessionId, toolName, rawToolName }),
|
|
466
|
-
}
|
|
467
|
-
: {}),
|
|
465
|
+
...(approvalExemptionStore !== undefined && auth?.sessionId ? { exemption: createDeploymentListExemption(approvalExemptionStore, auth.sessionId, logger) } : {}),
|
|
468
466
|
})
|
|
469
467
|
: singleUserAutoAcceptBaselineApplies(config)
|
|
470
468
|
? createApprovalBaselinePolicy(config, { kind: "absent" })
|
package/dist/boot/runner-deps.js
CHANGED
|
@@ -16,7 +16,7 @@ import { createInstructionSourceSeat } from "../instruction-source-notice.js";
|
|
|
16
16
|
import { workflowModelAllowlistFor } from "../task-workflow.js";
|
|
17
17
|
import { buildCrossSessionInboundLayers, crossSessionDialogExpiryOf } from "../cross-session-settings.js";
|
|
18
18
|
import { createPeerDirectory } from "../peer-directory.js";
|
|
19
|
-
import {
|
|
19
|
+
import { storeFormRefusalInIncident } from "../memory-store-refusal.js";
|
|
20
20
|
import { coreFileHistoryCaptureSeat } from "../file-history-capture.js";
|
|
21
21
|
import { rewindFailureCode } from "../file-history-disclosure.js";
|
|
22
22
|
export function createRunnerDepsOnAsk(toolApproval) {
|
|
@@ -197,7 +197,7 @@ export function createRunnerDeps(ctx) {
|
|
|
197
197
|
if (report.patches)
|
|
198
198
|
metrics.inc("memory_harvest_patches_total", { phase: info.phase }, (report.patches.add ?? 0) + (report.patches.update ?? 0));
|
|
199
199
|
if (report.incident) {
|
|
200
|
-
const code =
|
|
200
|
+
const code = storeFormRefusalInIncident(report.incident);
|
|
201
201
|
logger.warn("memory_harvest_incident", { kind: report.incident.kind, phase: info.phase, ...(code !== undefined ? { code } : {}) });
|
|
202
202
|
}
|
|
203
203
|
const byCode = new Map();
|
|
@@ -10,7 +10,7 @@ import { buildForceDurableGateInertNotice, buildNoResponderBootWarns, gateIntent
|
|
|
10
10
|
import { executionLaneOf } from "../execution-lane-caps.js";
|
|
11
11
|
import { loadDeploymentSkills } from "../capabilities/skills.js";
|
|
12
12
|
import { createRepoClient } from "../capabilities/repo-tools.js";
|
|
13
|
-
import { buildScenarios, builtinScenarioDetails } from "../capabilities/scenarios.js";
|
|
13
|
+
import { buildScenarios, builtinScenarioDetails, danglingScenarioRefusal } from "../capabilities/scenarios.js";
|
|
14
14
|
import { RateLimiter } from "../observability/rate-limit.js";
|
|
15
15
|
import { explicitOperatorOk } from "../http/server.js";
|
|
16
16
|
import { selfOrchestrationDenial } from "../task-workflow.js";
|
|
@@ -64,7 +64,7 @@ export async function runStage07(ctx) {
|
|
|
64
64
|
newId: uuidv7,
|
|
65
65
|
});
|
|
66
66
|
if (converged > 0)
|
|
67
|
-
logger.warn("user_input_ledger_crash_converged", { converged, note: "steers accepted with 200 \"applied\" by a previous process that ended before its run settled were converged as cause:crashed; each session's next run announces them (task.user_steer_undrained) and GET /v1/sessions/:id lists them under userInputUndrained" });
|
|
67
|
+
logger.warn("user_input_ledger_crash_converged", { converged, note: "steers accepted with 200 \"applied\" by a previous process that ended before its run settled were converged as cause:crashed; each session's next run announces them (task.user_steer_undrained, or task.user_followup_undrained for steers queued with priority later) and GET /v1/sessions/:id lists them under userInputUndrained" });
|
|
68
68
|
return ledger;
|
|
69
69
|
})()
|
|
70
70
|
: undefined;
|
|
@@ -166,9 +166,10 @@ export async function runStage07(ctx) {
|
|
|
166
166
|
const parkedReviveSurface = checkpointStore && backgroundAgentStore && builtinDefaultScenario ? createParkedReviveSurface(builtinDefaultScenario) : undefined;
|
|
167
167
|
const parkedReviveInheritedGate = parkedReviveSurface && config.durableApproval
|
|
168
168
|
? createParkedReviveInheritedGate({
|
|
169
|
-
config, question,
|
|
169
|
+
config, question, logger, localRoot,
|
|
170
170
|
memoryEngineRoot: memoryEngine?.root,
|
|
171
171
|
approverSeat: createRunnerDepsOnAsk(toolApproval),
|
|
172
|
+
approvalExemptionStore,
|
|
172
173
|
...(runnerDeps.runtimeCapsResolver ? { resolveRuntimeCaps: runnerDeps.runtimeCapsResolver } : {}),
|
|
173
174
|
autoModeSeatMounted: runnerDeps.autoMode !== undefined,
|
|
174
175
|
})
|
|
@@ -176,6 +177,9 @@ export async function runStage07(ctx) {
|
|
|
176
177
|
const scenarioDetails = builtinScenarioDetails(scenarios, scenarioDeps);
|
|
177
178
|
const builtinScenarioNames = Object.keys(scenarioDetails);
|
|
178
179
|
configCenter.applyCenterScenarios({ scenarioDeps, scenarios, scenarioDetails, builtinScenarioNames });
|
|
180
|
+
const defaultScenarioRefusal = danglingScenarioRefusal(config.defaultScenario, "deployment", Object.keys(scenarios));
|
|
181
|
+
if (defaultScenarioRefusal !== undefined)
|
|
182
|
+
throw new Error(defaultScenarioRefusal);
|
|
179
183
|
logger.info("capabilities", { skills: skills.length, scenarios: Object.keys(scenarios), repoTools: Boolean(repoClient) });
|
|
180
184
|
return { ...ctx, approvalExemptionStore, approvalNonceStore, authorize, imageBakes, imageIndex, parkedReviveInheritedGate, parkedReviveSurface, rateLimiter, resumeAnchorStore, runStore, scenarioDetails, scenarios, selectEnvTool, taskLimitCaps, taskTimeoutSec, userInputLedger, userInputLedgerStore, webSearchProvider: webSearchCfg?.provider };
|
|
181
185
|
}
|
|
@@ -12,6 +12,7 @@ import { backgroundAgentOutput, taskHandleOutput, taskHandleStop } from "../runs
|
|
|
12
12
|
import { SQL_BLOB_DEFAULT_MAX_BYTES } from "../plugins/blob-backend.js";
|
|
13
13
|
import { createStoreLiveProbe } from "../store-live-probe.js";
|
|
14
14
|
import { counterStoreLabel } from "../plugins/store-backend.js";
|
|
15
|
+
import { sessionStoreLabelOf } from "../store-posture.js";
|
|
15
16
|
import { startFleetClientFromEnv } from "../fleet-client.js";
|
|
16
17
|
import { createCenterWiringReader } from "../capabilities/center-wiring.js";
|
|
17
18
|
import { readinessOf } from "../http/readiness.js";
|
|
@@ -133,7 +134,7 @@ export async function runStage10(ctx) {
|
|
|
133
134
|
? createStoreLiveProbe({ probe: () => backend.dbNowMs(), intervalMs: config.storeProbeIntervalMs, logger })
|
|
134
135
|
: undefined;
|
|
135
136
|
const deployment = {
|
|
136
|
-
sessionStoreLabel: config.sessionBackend
|
|
137
|
+
sessionStoreLabel: sessionStoreLabelOf(config.sessionBackend, backend?.kind),
|
|
137
138
|
modelReady: () => configCenter.modelReady(),
|
|
138
139
|
scenarioDetails,
|
|
139
140
|
workflowsCapable,
|
|
@@ -269,7 +270,7 @@ export async function runStage10(ctx) {
|
|
|
269
270
|
model: config.model.id,
|
|
270
271
|
brain: brainSummary(config),
|
|
271
272
|
breakerState: config.resilience.circuitBreaker ? (breakerState ? `shared(${backend.kind})` : "in-process") : "off",
|
|
272
|
-
session: config.sessionBackend
|
|
273
|
+
session: sessionStoreLabelOf(config.sessionBackend, backend?.kind),
|
|
273
274
|
memory: memoryEngine ? `engine(${memoryEngine.root})` : "off",
|
|
274
275
|
instanceId,
|
|
275
276
|
rateLimitPerMin: config.rateLimitPerMin,
|
package/dist/boot/stores.js
CHANGED
|
@@ -9,6 +9,7 @@ import { TiDBMemoryEngineBackend, ensureTiDBMemoryEngineSchema } from "../plugin
|
|
|
9
9
|
import { PgMemoryHistoryStore, PgMemorySyncStore, ensurePgMemoryHistorySchema, ensurePgMemorySyncSchema } from "../plugins/memory-sync-store-pg.js";
|
|
10
10
|
import { TiDBMemoryHistoryStore, TiDBMemorySyncStore, ensureTiDBMemoryHistorySchema, ensureTiDBMemorySyncSchema } from "../plugins/memory-sync-store-tidb.js";
|
|
11
11
|
import { MinioBlobBackend } from "../plugins/blob-backend.js";
|
|
12
|
+
import { ensureSnapshotBucket } from "../plugins/snapshot-bucket-presence.js";
|
|
12
13
|
import { PgBackgroundAgentStore, TiDBBackgroundAgentStore, ensurePgBackgroundAgentSchema, ensureTiDBBackgroundAgentSchema } from "../plugins/background-agent-store-sql.js";
|
|
13
14
|
import { PgMailboxStore, TiDBMailboxStore, ensurePgMailboxSchema, ensureTiDBMailboxSchema } from "../plugins/mailbox-store-sql.js";
|
|
14
15
|
import { createDropOnlyRecipientLifecycle } from "../plugins/mailbox-recipient-lifecycle.js";
|
|
@@ -48,9 +49,12 @@ export async function openStores(ctx) {
|
|
|
48
49
|
const { config, logger, metrics, localRoot } = ctx;
|
|
49
50
|
let backend;
|
|
50
51
|
let storeDegradedReason;
|
|
52
|
+
const dsnConfigured = !!(config.tidb || config.pg);
|
|
53
|
+
if (config.snapshotBlobStore)
|
|
54
|
+
await ensureSnapshotBucket(config.snapshotBlobStore, config.storeLockWaitMs, logger);
|
|
51
55
|
const wantDb = config.sessionBackend === "tidb" ||
|
|
52
56
|
config.dbBackend === "local" ||
|
|
53
|
-
(config.sessionBackend === "auto" &&
|
|
57
|
+
(config.sessionBackend === "auto" && dsnConfigured);
|
|
54
58
|
if (wantDb) {
|
|
55
59
|
const opened = await openStoreBackendWithFallback(config, logger);
|
|
56
60
|
backend = opened.backend;
|
|
@@ -111,7 +115,7 @@ export async function openStores(ctx) {
|
|
|
111
115
|
metrics.setGauge("snapshot_blob_backend", 1, { backend: config.snapshotBlobStore ? "minio" : "sql" });
|
|
112
116
|
}
|
|
113
117
|
if (config.sessionBackend === "auto")
|
|
114
|
-
config.sessionBackend =
|
|
118
|
+
config.sessionBackend = dsnConfigured ? "tidb" : "memory";
|
|
115
119
|
if (config.dbBackend === "local" && backend)
|
|
116
120
|
config.sessionBackend = "tidb";
|
|
117
121
|
let memoryEngine;
|
|
@@ -414,11 +418,12 @@ export async function openStores(ctx) {
|
|
|
414
418
|
}
|
|
415
419
|
const sessionStore = createSessionStore(config, backend, metrics);
|
|
416
420
|
if (config.requirePrincipal && backend?.kind === "local") {
|
|
417
|
-
throw new Error("REQUIRE_PRINCIPAL=true is not supported on the local file backend (DB_BACKEND=local):
|
|
418
|
-
"
|
|
419
|
-
"
|
|
420
|
-
"(DB_BACKEND=mysql|pg) for multi-tenant, or run local
|
|
421
|
-
"still inject x-agent-principal per request for memory
|
|
421
|
+
throw new Error("REQUIRE_PRINCIPAL=true is not supported on the local file backend (DB_BACKEND=local): the lane is single-user " +
|
|
422
|
+
"by construction — a session created before owners were recorded is claimed by the FIRST principal that submits " +
|
|
423
|
+
"to it during the upgrade window, and the lane's mutual-recognition arms assume one user — so it cannot enforce " +
|
|
424
|
+
"a multi-tenant session boundary. Use a SQL backend (DB_BACKEND=mysql|pg) for multi-tenant, or run local " +
|
|
425
|
+
"single-user with REQUIRE_PRINCIPAL=false (a BFF may still inject x-agent-principal per request for memory " +
|
|
426
|
+
"scoping and audit attribution).");
|
|
422
427
|
}
|
|
423
428
|
if (backend)
|
|
424
429
|
assertCloudSnapshotBlobPosture(backend.kind, config);
|
|
@@ -97,6 +97,8 @@ export declare function materializablePlugins(eff: {
|
|
|
97
97
|
url: string;
|
|
98
98
|
sha?: string;
|
|
99
99
|
}>;
|
|
100
|
+
/** 总入口(条款 3/7/8):逐条物化 + 装载 + 让位合并。materialize 盘位 = `<cacheRoot>/<name>/live`
|
|
101
|
+
* (成功后原子 rename 替换,失败保留旧盘位 = LKG)。 */
|
|
100
102
|
export declare function applyCenterPlugins(baseline: LoadedSkill[], eff: {
|
|
101
103
|
plugins?: unknown;
|
|
102
104
|
}, opts: {
|
|
@@ -108,21 +108,39 @@ export function resolvePluginSkillsRoot(cloneRoot) {
|
|
|
108
108
|
}
|
|
109
109
|
return { ok: true, dir: candidate };
|
|
110
110
|
}
|
|
111
|
+
const PLUGINS_DOMAIN_FAILURE_NAME = "(plugins domain)";
|
|
111
112
|
function declaredPlugins(eff) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
const domain = eff.plugins;
|
|
114
|
+
if (domain === undefined)
|
|
115
|
+
return { ok: true, decls: [] };
|
|
116
|
+
if (Array.isArray(domain))
|
|
117
|
+
return { ok: true, decls: domain };
|
|
118
|
+
if (typeof domain === "object" && domain !== null) {
|
|
119
|
+
const inner = domain.plugins;
|
|
120
|
+
if (Array.isArray(inner))
|
|
121
|
+
return { ok: true, decls: inner };
|
|
122
|
+
return { ok: false, reason: `plugins domain shape rejected: expected an array or { plugins: [...] }, got an object whose plugins member is ${wireTypeWord(inner)}` };
|
|
123
|
+
}
|
|
124
|
+
return { ok: false, reason: `plugins domain shape rejected: expected an array or { plugins: [...] }, got ${wireTypeWord(domain)}` };
|
|
116
125
|
}
|
|
117
126
|
export function materializablePlugins(eff, allowHosts) {
|
|
118
|
-
|
|
127
|
+
const shape = declaredPlugins(eff);
|
|
128
|
+
if (!shape.ok)
|
|
129
|
+
return [];
|
|
130
|
+
return shape.decls.flatMap((decl) => {
|
|
119
131
|
const v = validatePluginDecl(decl, allowHosts);
|
|
120
132
|
return v.ok ? [{ name: v.name, url: v.url, ...(v.sha !== undefined ? { sha: v.sha } : {}) }] : [];
|
|
121
133
|
});
|
|
122
134
|
}
|
|
123
135
|
export async function applyCenterPlugins(baseline, eff, opts) {
|
|
124
|
-
const
|
|
136
|
+
const shape = declaredPlugins(eff);
|
|
125
137
|
const out = { skills: [...baseline], failures: [], letGo: [], lkgUsed: [] };
|
|
138
|
+
if (!shape.ok) {
|
|
139
|
+
opts.logger?.warn("center_plugins_domain_rejected", { reason: shape.reason });
|
|
140
|
+
out.failures.push({ plugin: PLUGINS_DOMAIN_FAILURE_NAME, reason: shape.reason });
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
const declared = shape.decls;
|
|
126
144
|
if (declared.length === 0)
|
|
127
145
|
return out;
|
|
128
146
|
const runGit = opts.runGit ?? (async (args) => {
|