@sema-agent/settings-schema 11.2.0 → 11.3.1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +2 -1
  3. package/conformance/VERSION +1 -1
  4. package/conformance/cases/c73-projects-extended-registration-reads/expected.json +150 -0
  5. package/conformance/cases/c73-projects-extended-registration-reads/input.json +42 -0
  6. package/conformance/cases/c73-projects-extended-registration-reads/meta.json +6 -0
  7. package/conformance/cases/c74-projects-over-bound-refused/expected.json +89 -0
  8. package/conformance/cases/c74-projects-over-bound-refused/input.json +29 -0
  9. package/conformance/cases/c74-projects-over-bound-refused/meta.json +5 -0
  10. package/conformance/cases/c75-projects-patch-remote-uniqueness/expected.json +89 -0
  11. package/conformance/cases/c75-projects-patch-remote-uniqueness/input.json +35 -0
  12. package/conformance/cases/c75-projects-patch-remote-uniqueness/meta.json +5 -0
  13. package/dist/api/feedback.js +2 -3
  14. package/dist/api/scopes.js +2 -1
  15. package/dist/atomic-write.d.ts +6 -0
  16. package/dist/atomic-write.js +12 -4
  17. package/dist/cli.d.ts +7 -4
  18. package/dist/cli.js +52 -10
  19. package/dist/config-d-file.d.ts +11 -0
  20. package/dist/config-d-file.js +35 -1
  21. package/dist/config-dir-io.js +4 -3
  22. package/dist/config-dir-migration.d.ts +5 -2
  23. package/dist/config-dir-migration.js +23 -9
  24. package/dist/cross-domain.d.ts +8 -3
  25. package/dist/cross-domain.js +23 -13
  26. package/dist/file-edit.js +7 -5
  27. package/dist/file-store.js +2 -1
  28. package/dist/fleet.js +3 -4
  29. package/dist/hooks.d.ts +14 -1
  30. package/dist/hooks.js +61 -16
  31. package/dist/host-path.d.ts +10 -0
  32. package/dist/host-path.js +27 -0
  33. package/dist/integer.js +2 -1
  34. package/dist/local-load.d.ts +1 -1
  35. package/dist/local-load.js +9 -31
  36. package/dist/migration-receipt.d.ts +3 -2
  37. package/dist/node.d.ts +1 -1
  38. package/dist/one-time-migrations.d.ts +5 -3
  39. package/dist/one-time-migrations.js +19 -6
  40. package/dist/quoted-issue.d.ts +41 -0
  41. package/dist/quoted-issue.js +35 -0
  42. package/dist/remote-exec.d.ts +3 -0
  43. package/dist/remote-exec.js +12 -7
  44. package/dist/rfc3339.d.ts +10 -0
  45. package/dist/rfc3339.js +12 -0
  46. package/dist/types.d.ts +140 -20
  47. package/dist/types.js +194 -105
  48. package/dist/web-admin-credential.d.ts +2 -2
  49. package/dist/web-admin-credential.js +5 -10
  50. package/package.json +1 -1
package/dist/types.js CHANGED
@@ -30,6 +30,9 @@ import { Sha256Digest } from "./sha256.js"; // the one `sha256:<hex>` digest for
30
30
  import { EXECUTION_LANES, EXECUTION_LANE_WORDS, MEMORY_ENGINE_BACKENDS, SESSION_BACKENDS, STORE_BACKENDS, retiredLaneWordRefusal } from "./execution-lanes.js"; // 7.0.0 M-R2: the lane / store vocabulary (one exported table)
31
31
  import { LANE_ENV_OWNER, isMigratableEnvKey, laneEnvSeat, laneRowOf } from "./execution-lane-index.js"; // package-private indexes derived from that table (not in the barrel)
32
32
  import { migrationSignpost, retiredFormSentence, retiredKey } from "./retired-form.js"; // 11.0.0: the ONE retired-form sentence + key tombstone (package-private)
33
+ import { buildQuotedIssue, fixed } from "./quoted-issue.js"; // THE minting point of custom issues (package-private)
34
+ import { AbsoluteHostPath } from "./host-path.js"; // the one host-path shape judge (a task's cwd and a project's folder / file entries)
35
+ import { RFC3339_DATE_TIME } from "./rfc3339.js"; // the package's one RFC 3339 date-time judge (package-private)
33
36
  // COARSE, best-effort literal-secret SHAPE detector (NOT exhaustive — the real boundary is the env-NAME schema
34
37
  // on structured fields). Rejected in free-form value fields (worker `env`, model `extraBody`), URL components,
35
38
  // AND as an env-NAME value (an AWS key id is a valid env-NAME charset yet is a secret VALUE, not a NAME). Case-
@@ -56,7 +59,7 @@ export const ENV_NAME = z
56
59
  // lowercase — the charset above rejects them). The ONE secret shape that IS a valid all-caps env-NAME charset
57
60
  // is an AWS access-key id (AKIA…) — block exactly that, WITHOUT false-rejecting legit names like
58
61
  // GITHUB_PAT_TOKEN / GHU_TOKEN (which the full SECRET_LITERAL_RE would). Round-5.
59
- .refine((s) => !/^AKIA[0-9A-Z]{12,}$/.test(s), "looks like an AWS access-key id, not an env-NAME — put the NAME of the env var here (the value lives in .env)");
62
+ .refine((s) => !/^AKIA[0-9A-Z]{12,}$/.test(s), buildQuotedIssue `looks like an AWS access-key id, not an env-NAME — put the NAME of the env var here (the value lives in .env)`);
60
63
  function scanForSecret(s) {
61
64
  // A private-key PEM header ANYWHERE in the string (the one regex the display redactor reads too). The header carries spaces, so
62
65
  // neither the start-anchored SECRET_LITERAL_RE below nor the tokenizer at the bottom can see it behind a prefix / newline. 10.0.0.
@@ -94,30 +97,11 @@ function scanForSecret(s) {
94
97
  * fs path — so the worker dies at exec/boot, not at config edit. A NUL is never legitimate in a command / path
95
98
  * / host / image, so reject it on every exec-bound string field (mcp stdio + the whole remoteExec contract). R20. */
96
99
  export const hasNul = (s) => s.includes("\0");
97
- /** The one rendering of a quoted sentence: `template[0] + show(operands[0]) + template[1] + … + template[n]`. `show` defaults to
98
- * the value as written (that is how `message` is minted); a sanitizer / log boundary passes its own. */
99
- export function renderQuotedSentence(p, show = String) {
100
- return p.template.reduce((out, part, i) => (i === 0 ? part : `${out}${show(p.operands[i - 1])}${part}`), "");
101
- }
102
- const fixed = (text) => ({ fixedText: text });
103
- /** Mint a custom issue's `message` + `params` from a tagged template (`buildQuotedIssue\`duplicate model "${name}"\``): every
104
- * interpolation is an operand unless wrapped in {@link fixed} (then it is template text). The ONE minting point of quoted
105
- * sentences in this file — a template literal written straight into `message` would put a value into a sentence with no record
106
- * of where it is (a source gate pins that none is left). */
107
- function buildQuotedIssue(strings, ...parts) {
108
- const template = [strings[0]];
109
- const operands = [];
110
- parts.forEach((part, i) => {
111
- if (typeof part === "object")
112
- template[template.length - 1] += part.fixedText + strings[i + 1];
113
- else {
114
- operands.push(part);
115
- template.push(strings[i + 1]);
116
- }
117
- });
118
- const params = { template, operands };
119
- return { message: renderQuotedSentence(params), params };
120
- }
100
+ /** The params of a custom issue's sentence and their one rendering live in the package-private minting module `./quoted-issue`
101
+ * (one minting point for the whole package); re-exported here unchanged. */
102
+ export { renderQuotedSentence } from "./quoted-issue.js";
103
+ /** The one host-path shape judge (a task's `cwd`, a project's `folder` / `file` entries) lives in its leaf module `./host-path`. */
104
+ export { ABSOLUTE_HOST_PATH_MAX, AbsoluteHostPath, isAbsoluteHostPath } from "./host-path.js";
121
105
  /** Does `s` contain a secret-shaped token? —— **the one scanner** (11.0.0, S-1274): the write side (this detector, behind every
122
106
  * free-text write port — NON_SECRET_URL, mcp stdio, execution coords, ssh login, worker env, extraBody, …) and the display side
123
107
  * (`redactSecrets`) read the SAME normalized forms ({@link secretScanForms} in the package-private `./secret-scan`: the raw string,
@@ -169,49 +153,52 @@ export function urlQueryFragmentHasSecret(u) {
169
153
  * after it is dropped with it — the engine and server refuse a model route root that carries one, so a stored one only fails
170
154
  * later, on the worker). A query is a legitimate request parameter (`?api-version=…`) and stays. */
171
155
  const NON_SECRET_URL_FORBIDS = ["userinfo", "fragment"];
172
- /** The refusal sentence of one flaw at a {@link NON_SECRET_URL} seat: the judge's rule sentence, and — for the one flaw that stored data
173
- * can carry from before 11.0.0 (a fragment) at a seat the one-time migration reaches — the signpost to the migration that strips
174
- * it, joined the way the other signposted refusals join it (`<rule>; <signpost>`). Closed over the judge's flaw words: a new word is
175
- * a compile error here. */
176
- function nonSecretUrlSentence(flaw, reachedByMigration) {
156
+ /** The refusal of one flaw at a {@link NON_SECRET_URL} seat (a {@link QuotedIssue} with no operands — the sentence quotes no value): the
157
+ * judge's rule sentence, and — for the one flaw that stored data can carry from before 11.0.0 (a fragment) at a seat the one-time migration
158
+ * reaches — the signpost to the migration that strips it, joined the way the other signposted refusals join it (`<rule>; <signpost>`).
159
+ * Closed over the judge's flaw words: a new word is a compile error here. */
160
+ function nonSecretUrlIssue(flaw, reachedByMigration) {
177
161
  switch (flaw) {
178
162
  case "fragment":
179
- return reachedByMigration ? `${httpUrlRule(flaw)}; ${migrationSignpost("SS-M7", "11.0.0")}` : httpUrlRule(flaw);
163
+ return reachedByMigration ? buildQuotedIssue `${fixed(httpUrlRule(flaw))}; ${fixed(migrationSignpost("SS-M7", "11.0.0"))}` : buildQuotedIssue `${fixed(httpUrlRule(flaw))}`;
180
164
  case "not-http-url":
181
165
  case "userinfo":
182
166
  case "query":
183
- return httpUrlRule(flaw);
167
+ return buildQuotedIssue `${fixed(httpUrlRule(flaw))}`;
184
168
  default: {
185
169
  const unhandled = flaw;
186
- throw new Error("nonSecretUrlSentence: unhandled flaw word", { cause: unhandled });
170
+ throw new Error("nonSecretUrlIssue: unhandled flaw word", { cause: unhandled });
187
171
  }
188
172
  }
189
173
  }
190
174
  /** One judge, two seat kinds — the only difference is the fragment refusal's migration signpost. `reachedByMigration` = the seat sits in a
191
- * stored domain document, which the one-time migration SS-M7 rewrites (it finds its seats by this schema's identity, so "carries the
175
+ * stored document the one-time migration SS-M7 rewrites (it finds its seats by this schema's identity, so "carries the
192
176
  * signpost" and "is rewritten by SS-M7" cannot drift apart). */
193
177
  function createNonSecretUrl(reachedByMigration) {
194
178
  return z.string().superRefine((s, ctx) => {
195
179
  const flaws = httpUrlFlaws(s, NON_SECRET_URL_FORBIDS);
196
- for (const flaw of flaws)
197
- ctx.addIssue({ code: "custom", message: nonSecretUrlSentence(flaw, reachedByMigration), params: { flaw } });
180
+ for (const flaw of flaws) {
181
+ const refusal = nonSecretUrlIssue(flaw, reachedByMigration);
182
+ ctx.addIssue({ code: "custom", ...refusal, params: { ...refusal.params, flaw } }); // `flaw` = the judge's rule word, beside the sentence's params
183
+ }
198
184
  if (flaws.length === 0 && urlQueryFragmentHasSecret(new URL(s))) {
199
- ctx.addIssue({ code: "custom", message: "must not carry a secret-shaped value in its path or query — secrets go in the *Env (env-NAME) fields" });
185
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `must not carry a secret-shaped value in its path or query — secrets go in the *Env (env-NAME) fields` });
200
186
  }
201
187
  });
202
188
  }
203
189
  /** A URL handed to `fetch` that carries no credential: judged by THE URL shape judge ({@link httpUrlFlaws}, `./url-shape`) — a
204
190
  * hierarchical http(s) URL with neither userinfo nor a fragment (an empty `#` included, 11.0.0) — and with no secret-shaped value
205
191
  * in its path or query ({@link urlQueryFragmentHasSecret}). One issue per flaw, its message the judge's rule sentence (no value
206
- * echoed; a fragment's also names its migration, {@link nonSecretUrlSentence}); `params.flaw` carries the rule word.
192
+ * echoed; a fragment's also names its migration, {@link nonSecretUrlIssue}); `params` carries the sentence (`template` / `operands`,
193
+ * no operands) and `flaw`, the rule word.
207
194
  *
208
- * This is the seat of every URL in a stored DOMAIN document (models `baseUrl`, mcp `url`, `sessionMirror.engineUrl`, workers
209
- * `gitApiBaseUrl`). A URL outside the domain documents — `remote-exec.json`'s endpoints, the web-admin credential envelope's
210
- * `issuer` — uses {@link NON_SECRET_URL_NO_MIGRATION}.
195
+ * This is the seat of every URL in a STORED document the one-time migration rewrites: the domain documents (models `baseUrl`, mcp `url`,
196
+ * `sessionMirror.engineUrl`, workers `gitApiBaseUrl`) and `config.d/remote-exec.json` (k8s `apiUrl`, `s3Snapshot.endpoint`). A URL
197
+ * that is not stored data — the web-admin credential envelope's `issuer`, a wire input — uses {@link NON_SECRET_URL_NO_MIGRATION}.
211
198
  *
212
199
  * The value is kept EXACTLY as written: nothing here trims or normalizes it (zod's own `.url()` would hand back a rewritten string). */
213
200
  export const NON_SECRET_URL = createNonSecretUrl(true);
214
- /** {@link NON_SECRET_URL}'s judge for a seat no one-time migration reaches (not a domain document): identical rules and rule
201
+ /** {@link NON_SECRET_URL}'s judge for a seat no one-time migration reaches (not stored data): identical rules and rule
215
202
  * sentences, but a fragment's refusal carries no migration signpost — pointing at a migration that cannot rewrite the value would
216
203
  * send the operator to a command that does nothing for it. */
217
204
  export const NON_SECRET_URL_NO_MIGRATION = createNonSecretUrl(false);
@@ -299,19 +286,19 @@ function vetFreeFormJson(v, field) {
299
286
  rawUnsafe = extraBodyUnsafe(v);
300
287
  }
301
288
  catch {
302
- return { ok: false, ...buildQuotedIssue `${fixed(field)} could not be validated (reflective access threw)` }; // R11
289
+ return { ok: false, issue: buildQuotedIssue `${fixed(field)} could not be validated (reflective access threw)` }; // R11
303
290
  }
304
291
  if (rawUnsafe)
305
- return { ok: false, ...buildQuotedIssue `${fixed(field)}: a key/value is a secret shape, non-JSON (Infinity/function/Map), an accessor, cyclic, or too deep` };
292
+ return { ok: false, issue: buildQuotedIssue `${fixed(field)}: a key/value is a secret shape, non-JSON (Infinity/function/Map), an accessor, cyclic, or too deep` };
306
293
  let clone;
307
294
  try {
308
295
  clone = JSON.parse(JSON.stringify(v)); // the ONLY serialization — its result is what we scan AND persist
309
296
  }
310
297
  catch {
311
- return { ok: false, ...buildQuotedIssue `${fixed(field)} is not JSON-serializable` };
298
+ return { ok: false, issue: buildQuotedIssue `${fixed(field)} is not JSON-serializable` };
312
299
  }
313
300
  if (extraBodyUnsafe(clone))
314
- return { ok: false, ...buildQuotedIssue `${fixed(field)}: its serialized form carries a secret` };
301
+ return { ok: false, issue: buildQuotedIssue `${fixed(field)}: its serialized form carries a secret` };
315
302
  return { ok: true, value: clone };
316
303
  }
317
304
  /** The transform of every **parse-transparent free-form** key (`z.unknown().optional().transform(createFreeFormTransform(field))`:
@@ -324,7 +311,7 @@ function createFreeFormTransform(field) {
324
311
  return undefined;
325
312
  const vetted = vetFreeFormJson(v, field);
326
313
  if (!vetted.ok) {
327
- ctx.addIssue({ code: "custom", message: vetted.message, params: vetted.params });
314
+ ctx.addIssue({ code: "custom", ...vetted.issue });
328
315
  return z.NEVER;
329
316
  }
330
317
  return vetted.value;
@@ -504,12 +491,12 @@ export const ModelEntry = z.object({
504
491
  return undefined;
505
492
  const proto = typeof v === "object" && v !== null ? Object.getPrototypeOf(v) : undefined;
506
493
  if (typeof v !== "object" || v === null || Array.isArray(v) || (proto !== Object.prototype && proto !== null)) {
507
- ctx.addIssue({ code: "custom", message: "extraBody must be a plain JSON object" });
494
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `extraBody must be a plain JSON object` });
508
495
  return z.NEVER;
509
496
  }
510
497
  const vetted = vetFreeFormJson(v, "extraBody");
511
498
  if (!vetted.ok) {
512
- ctx.addIssue({ code: "custom", message: vetted.message, params: vetted.params });
499
+ ctx.addIssue({ code: "custom", ...vetted.issue });
513
500
  return z.NEVER;
514
501
  }
515
502
  return vetted.value;
@@ -808,7 +795,7 @@ export const SystemEntry = z.object({
808
795
  // worker that isn't provisioned yet has no Secret to label-check, so a name-level reservation is
809
796
  // the only thing closing the "squat on a future worker's credential surface" timing hole (S3 设计
810
797
  // §4.4, council DESIGN-6/13). Cost: callers can't use a secret that happens to end in -env.
811
- .refine((n) => !n.endsWith("-env"), { message: 'secret names ending in "-env" are reserved for orchestrator worker-credential projections (红线1)' }),
798
+ .refine((n) => !n.endsWith("-env"), buildQuotedIssue `secret names ending in "-env" are reserved for orchestrator worker-credential projections (红线1)`),
812
799
  key: z.string().regex(/^[-._a-zA-Z0-9]+$/, "k8s secret data key").max(253),
813
800
  })
814
801
  .optional(),
@@ -975,13 +962,23 @@ export const LimitsConfig = z.object({
975
962
  // The governance trio an operator tunes via publish: autonomy ladder + command guardrails + approval-required
976
963
  // tools. NOT下沉 — gets its own admin tab (E5 form; E1 ships a transitional generic editor). Same `.optional()`
977
964
  // no-default discipline as the six gates: ABSENT = web-admin 不管这项(keep env / 消费者默认),present 才生效。
965
+ /** The autonomy ladder —— the closed set as a RUNTIME VALUE (same form as `REF_CHECKED_DOMAINS`): {@link AutonomyMode} (the zod enum)
966
+ * and its type are DERIVED from this table, so a consumer that needs the words at runtime (an env parser, a catalog's enum column) imports
967
+ * it instead of reaching into `GovernanceConfig.shape.autonomy.unwrap().options` or writing the four words again. */
968
+ export const AUTONOMY_MODES = ["read-only", "ask", "plan", "auto"];
969
+ /** `governance.autonomy`'s enum, derived from {@link AUTONOMY_MODES}. */
970
+ export const AutonomyMode = z.enum(AUTONOMY_MODES);
971
+ /** A `commandPolicy[]` rule's decision —— the closed set as a RUNTIME VALUE; {@link CommandDecision} and its type are DERIVED from it. */
972
+ export const COMMAND_DECISIONS = ["allow", "ask", "deny"];
973
+ /** `commandPolicy[].decision`'s enum, derived from {@link COMMAND_DECISIONS}. */
974
+ export const CommandDecision = z.enum(COMMAND_DECISIONS);
978
975
  export const GovernanceConfig = z.object({
979
976
  // autonomy:一个跨 knob 的安全总开关 / 放权梯度(普通用户敢用 + 专业用户放权)。
980
977
  // read-only(只读规划,不落改)| ask(每个放权动作问)| plan(plan-review 门)| auto(放开)。
981
978
  // ⚠️ 消费侧(service)把它**展开**到 core 已有三原语(handsReadOnly / shellGate+onAsk / plan_review),
982
979
  // 经 core 的收紧-only `tightenTaskSpec` 合并。core 裁决:不在 core 加并行 autonomy 枚举(双实现陷阱),
983
980
  // 不静默覆盖调用者已设安全字段(auto 模式尤其不能静默清门控)。详见 web-admin docs/CONFIG-RESEARCH §10。
984
- autonomy: z.enum(["read-only", "ask", "plan", "auto"]).optional(),
981
+ autonomy: AutonomyMode.optional(),
985
982
  // commandPolicy:命令级 allow/ask/deny 护栏(remoteExec 管"在哪跑",这管"能跑什么命令")。每条 = 一个
986
983
  // **精确 argv[0] 命令名** → 决策;**DENY-WINS**(冲突 deny 赢,与 core `combinePolicies` 一致,NOT last-match-wins)。
987
984
  // ⚠️ EXACT,不是 glob(service 裁决①,2026-06-22):core 1.114.0 shipped 的 `createCoarseCommandNamePolicy`
@@ -1003,7 +1000,7 @@ export const GovernanceConfig = z.object({
1003
1000
  .min(1)
1004
1001
  .max(128)
1005
1002
  .regex(/^[A-Za-z0-9._+-]+$/, "exact argv[0] command NAME — letters/digits/._+- only; NO glob (*,?), path (/), spaces or shell fragments — e.g. rm, git, docker-compose"),
1006
- decision: z.enum(["allow", "ask", "deny"]),
1003
+ decision: CommandDecision,
1007
1004
  }))
1008
1005
  .optional(),
1009
1006
  /** Tool names needing operator approval (F4). ABSENT = web-admin 不管;显式 `[]` = 一个都不需要审批。 */
@@ -1183,7 +1180,7 @@ export const EntitlementTier = z.object({
1183
1180
  /** 🔴 B1 违宪修复(EXPERT-REDESIGN §4-1):tokenQuota **不挂 tier** —— 只挂 defaults/subject/groupBinding。
1184
1181
  * fail-loud 而非 zod 默认的静默剥除(admin 挂上去以为生效才是最糟的)。 */
1185
1182
  tokenQuota: z
1186
- .custom(() => false, { message: "tokenQuota does not mount on a tier — mount it on defaults / subjects[] / groupBindings[] (拍板:配额挂用户/组,非访问级别)" })
1183
+ .custom(() => false, buildQuotedIssue `tokenQuota does not mount on a tier — mount it on defaults / subjects[] / groupBindings[] (拍板:配额挂用户/组,非访问级别)`)
1187
1184
  .optional(),
1188
1185
  });
1189
1186
  /** A time-bounded, audited per-principal override (escape hatch above the tier/role defaults). */
@@ -1205,7 +1202,7 @@ export const EntitlementOverride = z
1205
1202
  // by env-NAME, never inline. (Budget overrides are numbers/enums, so this never fires on the v1 use.)
1206
1203
  const s = typeof o.value === "string" ? o.value : o.value == null ? "" : JSON.stringify(o.value);
1207
1204
  if (s && containsSecretToken(s))
1208
- ctx.addIssue({ code: "custom", message: "override.value appears to contain a secret token — overrides are persisted + audited; reference secrets by env-NAME, never inline a value", path: ["value"] });
1205
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `override.value appears to contain a secret token — overrides are persisted + audited; reference secrets by env-NAME, never inline a value`, path: ["value"] });
1209
1206
  });
1210
1207
  export const EntitlementSubject = z.object({
1211
1208
  principal: z.string().min(1),
@@ -1368,7 +1365,7 @@ export const SESSION_MIRROR_ENGINE_URL = z.string().trim().pipe(NON_SECRET_URL).
1368
1365
  catch {
1369
1366
  return true; // already passed NON_SECRET_URL; unreachable in practice
1370
1367
  }
1371
- }, "non-loopback sessionMirror.engineUrl must be https — the mirror carries session content + a Bearer credential; plain http across the network is rejected at WRITE time (shell evaluateEngineRouting 同款传输闸)");
1368
+ }, buildQuotedIssue `non-loopback sessionMirror.engineUrl must be https — the mirror carries session content + a Bearer credential; plain http across the network is rejected at WRITE time (shell evaluateEngineRouting 同款传输闸)`);
1372
1369
  /** Org 默认会话镜像目标(WEB-SETUP-RECON 附B,产品拍板两层,0.10.1)。**收编进 execution 域**(非独立
1373
1370
  * 域)——142-S3 草案同款尺量:①同一治理轴(org 对「会话数据必须落到受控引擎」的 scope 级管控,与
1374
1371
  * 「任务必须跑在受控 lane」同族;`required` 语义与 {@link ExecutionPolicy}.required 完全同构=壳锁定、
@@ -1453,41 +1450,72 @@ export const ExecutionPolicy = z.object({
1453
1450
  * flags:本常量刻意**不带** `i`,因为它是登记簿 Record 的**键**,大小写不同的同一个 UUID 会变成两条登记行
1454
1451
  * (同一 project 双注册);引擎侧是识别语义(读 marker / 找回身份),放宽合理。 */
1455
1452
  export const PROJECT_ID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
1453
+ /** The bounds of a project registration's free-form fields —— the ONE source of these numbers: the schema below reads them, and so do
1454
+ * the server's project routes and the admin / client forms (they import this, never copy a number). The path bound of `folder` / `file`
1455
+ * entries is the host-path judge's own ({@link ABSOLUTE_HOST_PATH_MAX}). */
1456
+ export const PROJECT_LIMITS = {
1457
+ displayNameMax: 200,
1458
+ goalMax: 2000,
1459
+ contextItemsMax: 64,
1460
+ noteMax: 4000,
1461
+ };
1462
+ /** A project context item's kind —— the closed set as a RUNTIME VALUE: `folder` / `file` = a host path (judged by the same
1463
+ * {@link isAbsoluteHostPath} as a task's `cwd`), `note` = free text. */
1464
+ export const PROJECT_CONTEXT_ITEM_KINDS = ["folder", "file", "note"];
1465
+ /** A project's icon: a token (lowercase letter first, then lowercase letters / digits / `-`, at most 64). Absent = the default icon. */
1466
+ export const PROJECT_ICON_REGEX = /^[a-z][a-z0-9-]{0,63}$/;
1467
+ /** A project's colour: `#` + six lowercase hex digits. Absent = the default colour. */
1468
+ export const PROJECT_COLOR_REGEX = /^#[0-9a-f]{6}$/;
1469
+ /** One context item of a project. */
1470
+ export const ProjectContextItem = z.discriminatedUnion("kind", [
1471
+ z.object({ kind: z.literal("folder"), value: AbsoluteHostPath }),
1472
+ z.object({ kind: z.literal("file"), value: AbsoluteHostPath }),
1473
+ z.object({ kind: z.literal("note"), value: z.string().max(PROJECT_LIMITS.noteMax) }),
1474
+ ]);
1475
+ // 每个字段的 schema 只写一次:登记形({@link ProjectRegistration})与 PATCH 形({@link ProjectRegistrationPatch})都由它们组成。
1476
+ const ProjectDisplayName = z.string().min(1).max(PROJECT_LIMITS.displayNameMax);
1477
+ /** 归一化 git remotes(`host/path` 形态,design/142 §1.1 归一化规范)。归一化动作发生在 scaffold/调用方,本契约只验底线形状:非空、无空白、
1478
+ * 不含 "://"(出现即证据未归一化,fail-loud)。无仓 project = 空数组合法。`.max(16)` 防登记簿被单条撑爆。 */
1479
+ const ProjectGitRemotes = z
1480
+ .array(z
1481
+ .string()
1482
+ .min(1)
1483
+ .max(512)
1484
+ .refine((s) => !/\s/.test(s) && !s.includes("://"), buildQuotedIssue `must be a NORMALIZED remote (host/path — no scheme, no whitespace)`))
1485
+ .max(16);
1486
+ /** 该项目会话的默认记忆 scope 词表。OPEN value domain — z.string(),不 enum(纪律:加词不得 BREAKING)。方向(S4 细化):消费方=service
1487
+ * memoryScope 派生(作 TaskSpec.memory.scopes 种子),形态=v2 scope 键字符串(过 core parseScopeKey 校验;known 词根:`proj` / `userproj`)。
1488
+ * 未知串=消费者自定义;空数组=不下发默认。本域只登记不解释,零耦合。 */
1489
+ const ProjectDefaultScopes = z.array(z.string().min(1));
1490
+ const ProjectGoal = z.string().max(PROJECT_LIMITS.goalMax);
1491
+ const ProjectContextItems = z.array(ProjectContextItem).max(PROJECT_LIMITS.contextItemsMax);
1492
+ const ProjectIcon = z.string().regex(PROJECT_ICON_REGEX, "an icon is a token: a lowercase letter, then lowercase letters / digits / -, at most 64");
1493
+ const ProjectColor = z.string().regex(PROJECT_COLOR_REGEX, "a colour is # followed by six lowercase hex digits");
1456
1494
  export const ProjectRegistration = z.object({
1457
- /** 人读名(展示/管理面用;不是身份,改名自由——身份=Record 键 projectId)。 */
1458
- displayName: z.string().min(1).max(120),
1459
- /** 归一化 git remotes(`host/path` 形态,design/142 §1.1 归一化规范)。归一化动作发生在 scaffold/
1460
- * 调用方,本契约只验底线形状:非空、无空白、不含 "://"(出现即证据未归一化,fail-loud)。
1461
- * 无仓 project = 空数组合法。`.max(16)` 防登记簿被单条撑爆。 */
1462
- gitRemotes: z
1463
- .array(z
1464
- .string()
1465
- .min(1)
1466
- .max(512)
1467
- .refine((s) => !/\s/.test(s) && !s.includes("://"), "must be a NORMALIZED remote (host/path — no scheme, no whitespace)"))
1468
- .max(16)
1469
- .prefault([]),
1470
- /** 该项目会话的默认记忆 scope 词表。OPEN value domain — z.string(),不 enum(纪律:加词
1471
- * 不得 BREAKING)。方向(S4 细化):消费方=service memoryScope 派生(作 TaskSpec.
1472
- * memory.scopes 种子),形态=v2 scope 键字符串(过 core parseScopeKey 校验;known 词根:`proj` /
1473
- * `userproj`)。未知串=消费者自定义;空数组=不下发默认。本域只登记不解释,零耦合。 */
1474
- defaultScopes: z.array(z.string().min(1)).prefault([]),
1475
- /** 登记人 principal(审计锚;web-admin 写面自动填 caller,不信客户端提交)。 */
1495
+ /** 人读名(展示/管理面用;不是身份,改名自由——身份=Record 键 projectId)。上界 {@link PROJECT_LIMITS}`.displayNameMax`(200;此前 120)。 */
1496
+ displayName: ProjectDisplayName,
1497
+ gitRemotes: ProjectGitRemotes.prefault([]),
1498
+ defaultScopes: ProjectDefaultScopes.prefault([]),
1499
+ /** 登记人 principal(审计锚;web-admin 写面自动填 caller,不信客户端提交)。PATCH 改不了它。 */
1476
1500
  registeredBy: z.string().min(1),
1477
- /** 登记时刻(ISO)。web-admin 写面 server 端盖章。 */
1501
+ /** 登记时刻(ISO)。web-admin 写面 server 端盖章。PATCH 改不了它。 */
1478
1502
  registeredAt: z.string().min(1),
1503
+ /** 自由备注(与 `goal` 不是一件事)。 */
1479
1504
  notes: z.string().optional(),
1480
- });
1481
- export const ProjectsConfig = z
1482
- .object({
1483
- /** 键=projectId({@link PROJECT_ID_REGEX},generic lowercase UUID——宽读);tenant 半边=web-admin
1484
- * scope 轴(不进域文档,见域头注)。 */
1485
- projects: z.record(z.string().regex(PROJECT_ID_REGEX, "projectId must be a lowercase canonical UUID"), ProjectRegistration).prefault({}),
1486
- })
1487
- .superRefine((cfg, ctx) => {
1488
- // 同 scope 内一条 remote 只许属于一个 project——「remote → projectId」找回阶梯(design/142
1489
- // §1.5 ③)与 scaffold 防重铸查询要求该映射在租户内确定;撞了=写入 fail-loud(合法双登记诉求
1490
- // 出现时再放开,先紧后松 additive)。
1505
+ /** 项目目标(≤ {@link PROJECT_LIMITS}`.goalMax`)。 */
1506
+ goal: ProjectGoal.optional(),
1507
+ /** 项目上下文条目(≤ {@link PROJECT_LIMITS}`.contextItemsMax` 条,见 {@link ProjectContextItem})。 */
1508
+ contextItems: ProjectContextItems.optional(),
1509
+ /** 归档时刻(RFC 3339)。在场 = 已归档;没有硬删(会话行引用项目)。 */
1510
+ archivedAt: RFC3339_DATE_TIME.optional(),
1511
+ /** 图标 token({@link PROJECT_ICON_REGEX})。 */
1512
+ icon: ProjectIcon.optional(),
1513
+ /** 颜色({@link PROJECT_COLOR_REGEX})。 */
1514
+ color: ProjectColor.optional(),
1515
+ });
1516
+ /** 同 scope 内一条 remote 只许属于一个 project——「remote → projectId」找回阶梯(design/142 §1.5 ③)与 scaffold 防重铸查询要求该映射在
1517
+ * 租户内确定;撞了=写入 fail-loud(合法双登记诉求出现时再放开,先紧后松 additive)。按文档键序走:后出现的那一条被拒、句子点名先占的项目。 */
1518
+ function remoteUniquenessIssues(cfg, ctx) {
1491
1519
  const seen = new Map();
1492
1520
  for (const [pid, reg] of Object.entries(cfg.projects)) {
1493
1521
  for (const [i, r] of reg.gitRemotes.entries()) {
@@ -1498,7 +1526,66 @@ export const ProjectsConfig = z
1498
1526
  seen.set(r, pid);
1499
1527
  }
1500
1528
  }
1501
- });
1529
+ }
1530
+ export const ProjectsConfig = z
1531
+ .object({
1532
+ /** 键=projectId({@link PROJECT_ID_REGEX},generic lowercase UUID——宽读);tenant 半边=web-admin
1533
+ * scope 轴(不进域文档,见域头注)。 */
1534
+ projects: z.record(z.string().regex(PROJECT_ID_REGEX, "projectId must be a lowercase canonical UUID"), ProjectRegistration).prefault({}),
1535
+ })
1536
+ .superRefine(remoteUniquenessIssues);
1537
+ /** The PATCH form of one registration: every key a PATCH may change, all optional; `registeredBy` / `registeredAt` (and any key
1538
+ * the registration does not have) are refused (`.strict()`). An optional key given `null` is cleared (merge-patch: `archivedAt: null`
1539
+ * un-archives). Each field is the registration's own schema — one bound, one shape. */
1540
+ export const ProjectRegistrationPatch = z
1541
+ .object({
1542
+ displayName: ProjectDisplayName.optional(),
1543
+ gitRemotes: ProjectGitRemotes.optional(),
1544
+ defaultScopes: ProjectDefaultScopes.optional(),
1545
+ notes: z.string().nullable().optional(),
1546
+ goal: ProjectGoal.nullable().optional(),
1547
+ contextItems: ProjectContextItems.nullable().optional(),
1548
+ archivedAt: RFC3339_DATE_TIME.nullable().optional(),
1549
+ icon: ProjectIcon.nullable().optional(),
1550
+ color: ProjectColor.nullable().optional(),
1551
+ })
1552
+ .strict();
1553
+ /**
1554
+ * Apply a PATCH to one registration and judge the whole document with **the same** {@link ProjectsConfig} (the same remote-uniqueness rule a
1555
+ * full write meets — a PATCH has no rule of its own). The patch is judged here by {@link ProjectRegistrationPatch} first — whatever the caller
1556
+ * did before (a request body handed over as is cannot rewrite `registeredBy` / `registeredAt` or carry an unknown key) — and only its parsed
1557
+ * keys are merged. The patched project is judged LAST, so a remote another project already holds is refused on the patched project and the
1558
+ * sentence names the holder, whatever the document's key order; a successful result keeps the document's key order. Every issue path is a
1559
+ * document coordinate (`["projects", <projectId>, …]`), the patch's own included. `projectId` must be registered (the caller answers "no such
1560
+ * project" first) —— otherwise this throws.
1561
+ */
1562
+ export function applyProjectPatch(doc, projectId, patch) {
1563
+ const current = Object.prototype.hasOwnProperty.call(doc.projects, projectId) ? doc.projects[projectId] : undefined;
1564
+ if (current === undefined)
1565
+ throw new Error(`applyProjectPatch: project "${projectId}" is not registered in this document`);
1566
+ const parsed = ProjectRegistrationPatch.safeParse(patch);
1567
+ if (!parsed.success) {
1568
+ const issues = parsed.error.issues.map((i) => ({ ...i, path: ["projects", projectId, ...i.path] }));
1569
+ return { success: false, error: new z.ZodError(issues) };
1570
+ }
1571
+ const next = { ...current };
1572
+ for (const [k, v] of Object.entries(parsed.data)) {
1573
+ if (v === undefined)
1574
+ continue;
1575
+ if (v === null)
1576
+ delete next[k];
1577
+ else
1578
+ next[k] = v;
1579
+ }
1580
+ const { [projectId]: _patched, ...others } = doc.projects;
1581
+ const judged = ProjectsConfig.safeParse({ ...doc, projects: { ...others, [projectId]: next } });
1582
+ if (!judged.success)
1583
+ return judged;
1584
+ const ordered = {};
1585
+ for (const pid of Object.keys(doc.projects))
1586
+ ordered[pid] = judged.data.projects[pid];
1587
+ return { ...judged, data: { ...judged.data, projects: ordered } };
1588
+ }
1502
1589
  // ── Domain: collab (协作模式 — multi-model collaboration templates, 0.7.0) ─────
1503
1590
  // Replaces the deleted `teams` domain (EXPERT-REDESIGN §8/§9, 五拍裁定 T1-T5).
1504
1591
  // Unified shape = slots × topology × rounds × finalizer. COMPLETELY separate from rosters (拍板): a slot
@@ -1571,7 +1658,7 @@ const CollabTemplate = z.object({
1571
1658
  });
1572
1659
  if (t.finalizer.type === "none") {
1573
1660
  if (t.finalizer.slot !== undefined)
1574
- ctx.addIssue({ code: "custom", message: `finalizer type "none" must not anchor a slot`, path: ["finalizer", "slot"] });
1661
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `finalizer type "none" must not anchor a slot`, path: ["finalizer", "slot"] });
1575
1662
  }
1576
1663
  else if (t.finalizer.slot !== undefined && !slotIds.has(t.finalizer.slot)) {
1577
1664
  ctx.addIssue({ code: "custom", ...buildQuotedIssue `finalizer.slot "${t.finalizer.slot}" is not a slot id of this template`, path: ["finalizer", "slot"] });
@@ -1735,7 +1822,7 @@ const nonSecretLiteral = (minLength) => z
1735
1822
  .string()
1736
1823
  .min(minLength)
1737
1824
  .max(2048)
1738
- .refine((s) => !containsSecretToken(s), "looks like a literal secret — a credential goes in a secretRefs field as an env-NAME, never a value here");
1825
+ .refine((s) => !containsSecretToken(s), buildQuotedIssue `looks like a literal secret — a credential goes in a secretRefs field as an env-NAME, never a value here`);
1739
1826
  /**
1740
1827
  * `runtime.execution` —— 这台 worker 的执行车道(渲染:`REMOTE_EXEC=<lane>` + `REQUIRE_EXECUTION_LANE=true` + coords / secretRefs 逐键)。
1741
1828
  * - `lane`:{@link EXECUTION_LANE_WORDS} 之一。没有「无手」词。
@@ -1856,7 +1943,7 @@ const WorkerSpecObject = z.object({
1856
1943
  /** Target average CPU utilization %, vs resources.requests.cpu. Absent → backend default 80. */
1857
1944
  targetCpuPercent: INTEGER.min(10).max(95).optional(),
1858
1945
  })
1859
- .refine((a) => a.maxReplicas >= a.minReplicas, { message: "maxReplicas must be >= minReplicas" })
1946
+ .refine((a) => a.maxReplicas >= a.minReplicas, buildQuotedIssue `maxReplicas must be >= minReplicas`)
1860
1947
  .optional(),
1861
1948
  /** Per-worker resource requests/limits (k8s backend). Optional → the backend's modest default
1862
1949
  * (requests cpu 50m/mem 128Mi, no limits). Hash-INCLUDED → a change rolls the pods (resources are
@@ -2090,7 +2177,7 @@ export const WorkersConfig = z
2090
2177
  // replicas + autoscaling = two owners of the same knob (the orchestrator's SSA vs the HPA controller
2091
2178
  // would endlessly fight over spec.replicas) → reject at save, not at reconcile.
2092
2179
  if (w.replicas !== undefined && w.autoscaling) {
2093
- ctx.addIssue({ code: "custom", message: "replicas and autoscaling are mutually exclusive — the HPA owns the replica count when autoscaling is set", path: ["workers", i, "autoscaling"] });
2180
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `replicas and autoscaling are mutually exclusive — the HPA owns the replica count when autoscaling is set`, path: ["workers", i, "autoscaling"] });
2094
2181
  }
2095
2182
  });
2096
2183
  });
@@ -2251,7 +2338,7 @@ const McpEnvRefs = z.record(ENV_NAME, ENV_NAME); // target ENV key → ENV_NAME
2251
2338
  const HTTP_HEADER_NAME = z
2252
2339
  .string()
2253
2340
  .regex(/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/, "must be an HTTP header NAME")
2254
- .refine((s) => !containsSecretToken(s), "HTTP header name must not contain a secret literal — credentials go in the env-NAME value, never the header name");
2341
+ .refine((s) => !containsSecretToken(s), buildQuotedIssue `HTTP header name must not contain a secret literal — credentials go in the env-NAME value, never the header name`);
2255
2342
  // Header NAME → ENV_NAME holding its value. Header names are tokens (RFC 7230) — not env-name-shaped.
2256
2343
  const McpHeaderRefs = z.record(HTTP_HEADER_NAME, ENV_NAME);
2257
2344
  export const McpTransport = z.discriminatedUnion("kind", [
@@ -2264,13 +2351,13 @@ export const McpTransport = z.discriminatedUnion("kind", [
2264
2351
  command: z
2265
2352
  .string()
2266
2353
  .min(1)
2267
- .refine((s) => !containsSecretToken(s), "mcp stdio command must not contain a secret literal — put credentials in envRefs (an env-NAME)")
2268
- .refine((s) => !hasNul(s), "mcp stdio command must not contain a NUL byte (Node cannot spawn it)"),
2354
+ .refine((s) => !containsSecretToken(s), buildQuotedIssue `mcp stdio command must not contain a secret literal — put credentials in envRefs (an env-NAME)`)
2355
+ .refine((s) => !hasNul(s), buildQuotedIssue `mcp stdio command must not contain a NUL byte (Node cannot spawn it)`),
2269
2356
  args: z
2270
2357
  .array(z
2271
2358
  .string()
2272
- .refine((s) => !containsSecretToken(s), "mcp stdio arg must not contain a secret literal — put credentials in envRefs (an env-NAME)")
2273
- .refine((s) => !hasNul(s), "mcp stdio arg must not contain a NUL byte (Node cannot spawn it)"))
2359
+ .refine((s) => !containsSecretToken(s), buildQuotedIssue `mcp stdio arg must not contain a secret literal — put credentials in envRefs (an env-NAME)`)
2360
+ .refine((s) => !hasNul(s), buildQuotedIssue `mcp stdio arg must not contain a NUL byte (Node cannot spawn it)`))
2274
2361
  .optional(),
2275
2362
  /** target ENV key → ENV_NAME in the service env (never a secret value). */
2276
2363
  envRefs: McpEnvRefs.optional(),
@@ -2374,18 +2461,18 @@ export const McpConfig = z
2374
2461
  export const PLUGIN_ORIGIN = z
2375
2462
  .string()
2376
2463
  .min(1)
2377
- .refine((s) => !containsSecretToken(s), "plugin source must not contain a secret literal — private remotes authenticate via the consuming machine's git credentials, never an inline token")
2378
- .refine((s) => !hasNul(s), "plugin source must not contain a NUL byte")
2464
+ .refine((s) => !containsSecretToken(s), buildQuotedIssue `plugin source must not contain a secret literal — private remotes authenticate via the consuming machine's git credentials, never an inline token`)
2465
+ .refine((s) => !hasNul(s), buildQuotedIssue `plugin source must not contain a NUL byte`)
2379
2466
  .superRefine((s, ctx) => {
2380
2467
  // The shape is THE URL judge's ({@link httpUrlFlaws}); this seat adds two rules of its own: https only, and spelled in full
2381
2468
  // (`https://…` as written — git reads the raw string, and WHATWG's repair of `https:host/x` into `https://host/x` is not git's).
2382
2469
  const flaws = httpUrlFlaws(s, ["userinfo"]);
2383
2470
  if (flaws.includes("not-http-url") || new URL(s).protocol !== "https:" || s.slice(0, 8).toLowerCase() !== "https://") {
2384
- ctx.addIssue({ code: "custom", message: "plugin source must be an https:// URL (contract: https-only; ssh/scp/git/file/plain-http and owner/repo shorthand are not accepted — domestic mirrors ride an https mirror domain via PLUGINS_ALLOW_HOSTS)" });
2471
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `plugin source must be an https:// URL (contract: https-only; ssh/scp/git/file/plain-http and owner/repo shorthand are not accepted — domestic mirrors ride an https mirror domain via PLUGINS_ALLOW_HOSTS)` });
2385
2472
  return;
2386
2473
  }
2387
2474
  if (flaws.includes("userinfo") || urlQueryFragmentHasSecret(new URL(s))) {
2388
- ctx.addIssue({ code: "custom", message: "an https plugin source must not embed credentials (userinfo) or a secret-bearing query/fragment" });
2475
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `an https plugin source must not embed credentials (userinfo) or a secret-bearing query/fragment` });
2389
2476
  }
2390
2477
  });
2391
2478
  /** A full 40-hex git commit SHA — the ONLY pin form the supply-side treats as 钉死 (a branch/tag `version`
@@ -2434,7 +2521,9 @@ export const PluginsConfig = z
2434
2521
  // 消费投影在 server(声明数组逐字喂 core typed stableBlocks 钩子),schema 恒在本仓(零第二份)。
2435
2522
  /** 提示声明的槽位闭集(core `PromptTextDeclaration.slot` 同形):identity = 角色卡、scenario = 场景说明、behavior = 行为守则。
2436
2523
  * declaration 轴与 catalog 轴({@link PromptArtifactSection})共用这一只。 */
2437
- export const PromptSlot = z.enum(["identity", "scenario", "behavior"]);
2524
+ export const PROMPT_SLOTS = ["identity", "scenario", "behavior"];
2525
+ /** The slot enum, DERIVED from {@link PROMPT_SLOTS} (the runtime member table —— same form as `REF_CHECKED_DOMAINS`). */
2526
+ export const PromptSlot = z.enum(PROMPT_SLOTS);
2438
2527
  /** core `PromptTextDeclaration` 的契约层同形(core prompts/default.d.ts 逐字:id/slot 闭集/text)。
2439
2528
  * slot ↔ 三卡:identity=角色卡、scenario=场景说明、behavior=行为守则([1051]①)。 */
2440
2529
  export const PromptTextDeclaration = z.object({
@@ -2465,11 +2554,11 @@ export const PromptBinding = z.object({
2465
2554
  notes: z.string().optional(),
2466
2555
  }).superRefine((b, ctx) => {
2467
2556
  if (b.level === "worker" && !b.worker)
2468
- ctx.addIssue({ code: "custom", message: "level=worker requires `worker`" });
2557
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `level=worker requires \`worker\`` });
2469
2558
  if (b.level === "scenario" && !b.scenario)
2470
- ctx.addIssue({ code: "custom", message: "level=scenario requires `scenario`" });
2559
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `level=scenario requires \`scenario\`` });
2471
2560
  if (b.level === "global" && (b.worker || b.scenario))
2472
- ctx.addIssue({ code: "custom", message: "level=global must not carry a selector" });
2561
+ ctx.addIssue({ code: "custom", ...buildQuotedIssue `level=global must not carry a selector` });
2473
2562
  });
2474
2563
  // ═══ prompts 域 catalog 轴(0.10.20;[ref]a/[1242]/[1248] 过轮定稿;core design/148 S1 seam)═══
2475
2564
  // 形 = core 1.336+ 的 `PublishedPromptArtifactEnvelope`(sema-core src/prompt-assembly/artifact.ts,
@@ -2565,7 +2654,7 @@ export const EffectivePromptsWire = z
2565
2654
  declarations: EffectivePrompts.optional(),
2566
2655
  catalog: PublishedPromptArtifactEnvelope.optional(),
2567
2656
  })
2568
- .refine((w) => w.declarations !== undefined || w.catalog !== undefined, { message: "at least one axis (declarations|catalog) required" });
2657
+ .refine((w) => w.declarations !== undefined || w.catalog !== undefined, buildQuotedIssue `at least one axis (declarations|catalog) required`);
2569
2658
  export const DOMAIN_SCHEMAS = {
2570
2659
  models: ModelsConfig,
2571
2660
  rosters: RostersConfig,
@@ -32,8 +32,8 @@ export declare const WEB_ADMIN_CREDENTIAL_ENVELOPE_KIND: "user-session";
32
32
  * 文件**取当前值,不用内存旧值(另一个写者可能刚轮换过)。
33
33
  * · `expiresAt` —— 访问令牌到期时刻(RFC 3339)。
34
34
  * · `issuer` —— 签发它的 web-admin 的**基础 URL**(与读方连 web-admin 的根 URL 同形,可带路径前缀):续签只向同源的 web-admin 发,
35
- * 同不同源由读方比。URL 形判据与 `remoteExec` 的端点同一只 {@link NON_SECRET_URL_NO_MIGRATION}(http(s)、有 host、userinfo 与
36
- * query / fragment 里不许夹带凭据)—— 本包不另写一份更窄的 URL 律。
35
+ * 同不同源由读方比。URL 形判据是包内 URL 判官的「非存量座位」那一只 {@link NON_SECRET_URL_NO_MIGRATION}(http(s)、有 host、userinfo 与
36
+ * query / fragment 里不许夹带凭据;issuer 是 wire 输入、不是存量,一次性迁移不碰它,fragment 拒句因此不指路)—— 本包不另写一份更窄的 URL 律。
37
37
  */
38
38
  export declare const WebAdminCredentialEnvelope: z.ZodObject<{
39
39
  kind: z.ZodLiteral<"user-session">;
@@ -22,16 +22,11 @@
22
22
  import { z } from "zod";
23
23
  import { looksLikeJwt } from "./api/auth-bridge.js";
24
24
  import { NON_SECRET_URL_NO_MIGRATION } from "./types.js";
25
+ import { buildQuotedIssue } from "./quoted-issue.js";
26
+ import { RFC3339_DATE_TIME } from "./rfc3339.js"; // the package's one RFC 3339 date-time judge (a project registration's `archivedAt` reads the same one)
25
27
  import { WEB_ADMIN_ENV } from "./web-admin-env.js";
26
28
  /** 信封 `kind` 的闭集今只有一员(`SEALED_BOX_ALG` 同式的字面常量:schema 的字面与读方的比较都引它)。 */
27
29
  export const WEB_ADMIN_CREDENTIAL_ENVELOPE_KIND = "user-session";
28
- /** RFC 3339 `date-time` 的**剖面**:zod 的 `z.iso.datetime({offset:true})` 管日历有效性(月日范围、闰年、时分秒范围),
29
- * 这里的正则自己判另三处 —— 秒必备、数字偏移必须是 `±hh:mm`、偏移的时 00–23 / 分 00–59(`10:00Z`、`+0800` 与 `+99:99`
30
- * 都不是 RFC 3339,后者 `Date.parse` 读成 NaN)。这三处的判据在本正则,不随 zod 哪一版收不收而变。大写 `T` / `Z`、不收闰秒 `:60`:读方普遍用
31
- * `Date.parse` 取时刻,这是那组形里它处处读得准的子集。 */
32
- const RFC3339_DATE_TIME = z.iso
33
- .datetime({ offset: true })
34
- .regex(/T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/, "must be an RFC 3339 date-time: seconds and a Z / ±hh:mm offset (hh 00-23, mm 00-59) are required");
35
30
  /** 一枚**令牌串**的形 —— 裸行 bearer、信封里的 `accessToken` / `refreshToken` 共用这**一条**律:可打印 ASCII
36
31
  * (0x20–0x7E),首尾是可见字符(0x21–0x7E)、中间可有空格(共享令牌可以是一句口令 —— 验修轮 N2:今天走得通的
37
32
  * 这种令牌不许被本律拒掉)。控制字符、制表、非 ASCII、不可见字符一律不是令牌:判别器把它判 `unreadable`,而不是
@@ -50,13 +45,13 @@ const TokenString = z.string().regex(TOKEN_CHARS, "must be a token: printable AS
50
45
  * 文件**取当前值,不用内存旧值(另一个写者可能刚轮换过)。
51
46
  * · `expiresAt` —— 访问令牌到期时刻(RFC 3339)。
52
47
  * · `issuer` —— 签发它的 web-admin 的**基础 URL**(与读方连 web-admin 的根 URL 同形,可带路径前缀):续签只向同源的 web-admin 发,
53
- * 同不同源由读方比。URL 形判据与 `remoteExec` 的端点同一只 {@link NON_SECRET_URL_NO_MIGRATION}(http(s)、有 host、userinfo 与
54
- * query / fragment 里不许夹带凭据)—— 本包不另写一份更窄的 URL 律。
48
+ * 同不同源由读方比。URL 形判据是包内 URL 判官的「非存量座位」那一只 {@link NON_SECRET_URL_NO_MIGRATION}(http(s)、有 host、userinfo 与
49
+ * query / fragment 里不许夹带凭据;issuer 是 wire 输入、不是存量,一次性迁移不碰它,fragment 拒句因此不指路)—— 本包不另写一份更窄的 URL 律。
55
50
  */
56
51
  export const WebAdminCredentialEnvelope = z
57
52
  .object({
58
53
  kind: z.literal(WEB_ADMIN_CREDENTIAL_ENVELOPE_KIND),
59
- accessToken: TokenString.refine(looksLikeJwt, "must be a JWT (three dot-separated segments) — a worker pull token never goes into an envelope"),
54
+ accessToken: TokenString.refine(looksLikeJwt, buildQuotedIssue `must be a JWT (three dot-separated segments) — a worker pull token never goes into an envelope`),
60
55
  refreshToken: TokenString,
61
56
  expiresAt: RFC3339_DATE_TIME,
62
57
  issuer: NON_SECRET_URL_NO_MIGRATION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/settings-schema",
3
- "version": "11.2.0",
3
+ "version": "11.3.1",
4
4
  "description": "Sema settings schema — pure config contract (zod domains + effective-config + roster resolution + ref-integrity + remoteExec) shared by sema-web-admin, sema-server, and the TOC desktop/CLI. One source of truth. (Renamed at 1.0.0 from @sema-agent/registry-core — name and docs only, no behavior change; note the range moves 0.19.0 -> 1.0.0, so a dependency must become ^1.0.0. The old names @sema-agent/registry-core <=0.19.0 and @sema-ai/registry-core remain published, frozen, for migration.)",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",