@sema-agent/settings-schema 28.0.0 → 29.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +330 -0
- package/README.md +81 -12
- package/conformance/VERSION +1 -1
- package/conformance/cases/c01-entry-salvage-then-typo/expected.json +1 -1
- package/conformance/cases/c02-hosts-clamp-stacked/expected.json +1 -1
- package/conformance/cases/c03-literal-dotted-top-key/expected.json +1 -1
- package/conformance/cases/c04-all-bad-collection-not-salvaged/expected.json +1 -1
- package/conformance/cases/c07-hooks-is-not-a-config-domain/expected.json +1 -1
- package/conformance/cases/c08-limits-unknown-carried-64/expected.json +1 -1
- package/conformance/cases/c09-limits-unknown-carried-65/expected.json +1 -1
- package/conformance/cases/c10-record-key-secret-redacted-twice/expected.json +1 -1
- package/conformance/cases/c11-unicode-unknown-keys/expected.json +1 -1
- package/conformance/cases/c12-prototype-name-top-keys/expected.json +1 -1
- package/conformance/cases/c13-models-field-null/expected.json +1 -1
- package/conformance/cases/c14-models-field-empty-array/expected.json +1 -1
- package/conformance/cases/c15-models-field-number/expected.json +1 -1
- package/conformance/cases/c18-wire-envelope-not-an-object/expected.json +1 -1
- package/conformance/cases/c19-wire-envelope-no-version/expected.json +1 -1
- package/conformance/cases/c21-governance-empty-object-wins/expected.json +1 -1
- package/conformance/cases/c23-mixed-validity-models/expected.json +1 -1
- package/conformance/cases/c24-valid-entries-with-unknown-keys/expected.json +1 -1
- package/conformance/cases/c25-published-roundtrip-zero-warnings/expected.json +1 -1
- package/conformance/cases/c26-hosts-array-1024/expected.json +1 -1
- package/conformance/cases/c27-hosts-array-1025/expected.json +1 -1
- package/conformance/cases/c28-large-document-over-1mb/expected.json +1 -1
- package/conformance/cases/c29-salvage-then-domain-refine-fails/expected.json +1 -1
- package/conformance/cases/c30-version-triple-a-first/expected.json +1 -1
- package/conformance/cases/c31-version-triple-b-changed/expected.json +1 -1
- package/conformance/cases/c32-version-triple-a-restored/expected.json +1 -1
- package/conformance/cases/c33-limits-nested-carried-key/expected.json +1 -1
- package/conformance/cases/c34-skills-content-vs-manifest/expected.json +1 -1
- package/conformance/cases/c36-skills-entry-without-content/expected.json +1 -1
- package/conformance/cases/c38-remote-exec-is-a-non-domain-file/expected.json +1 -1
- package/conformance/cases/c39-hidden-file-in-config-d/expected.json +1 -1
- package/conformance/cases/c40-s712-identity-only-what-reads-out/expected.json +1 -1
- package/conformance/cases/c41-s792-encoded-pem-identity/expected.json +1 -1
- package/conformance/cases/c42-s792-unknown-key-secret-redacted/expected.json +1 -1
- package/conformance/cases/c43-s792-form-and-deep-encoded-pem/expected.json +1 -1
- package/conformance/cases/c44-s792-utf8-escape-glued-token/expected.json +1 -1
- package/conformance/cases/c45-s792-identity-bounds-and-decode-depth/expected.json +1 -1
- package/conformance/cases/c46-s811-host-name-url-userinfo-withheld/expected.json +1 -1
- package/conformance/cases/c47-s811-roles-key-url-userinfo-withheld/expected.json +1 -1
- package/conformance/cases/c48-s935-model-headers-transported/expected.json +1 -1
- package/conformance/cases/c49-s935-model-headers-secret-entry-dropped/expected.json +1 -1
- package/conformance/cases/c50-s784-lane-host-legal/expected.json +1 -1
- package/conformance/cases/c51-s784-lane-e2b-legal/expected.json +1 -1
- package/conformance/cases/c52-s784-lane-k8s-legal/expected.json +1 -1
- package/conformance/cases/c53-s784-lane-ssh-legal/expected.json +1 -1
- package/conformance/cases/c54-s784-lane-adb-legal/expected.json +1 -1
- package/conformance/cases/c55-s784-lane-local-docker-legal/expected.json +1 -1
- package/conformance/cases/c56-s784-lane-device-legal/expected.json +1 -1
- package/conformance/cases/c57-s784-g1-enabled-no-lane/expected.json +1 -1
- package/conformance/cases/c58-s784-g2-multitenant-host/expected.json +1 -1
- package/conformance/cases/c59-s784-g3-k8s-missing-image/expected.json +1 -1
- package/conformance/cases/c60-s784-g3-e2b-missing-key/expected.json +1 -1
- package/conformance/cases/c61-s784-g3-other-lane-key/expected.json +1 -1
- package/conformance/cases/c62-s784-g7a-session-tidb/expected.json +1 -1
- package/conformance/cases/c63-s784-host-two-replicas/expected.json +1 -1
- package/conformance/cases/c64-s784-multitenant-local-store/expected.json +1 -1
- package/conformance/cases/c65-s784-pg-without-db/expected.json +1 -1
- package/conformance/cases/c66-s784-memory-backend-mismatch/expected.json +1 -1
- package/conformance/cases/c67-s784-retired-field-loud/expected.json +1 -1
- package/conformance/cases/c68-s784-device-local-store/expected.json +1 -1
- package/conformance/cases/c69-deep-encoded-token-past-every-reading/expected.json +1 -1
- package/conformance/cases/c70-rewritten-token-in-front-of-encoded-pem-header/expected.json +1 -1
- package/conformance/cases/c71-one-scanner-write-reads-display-forms/expected.json +1 -1
- package/conformance/cases/c72-dangling-reference-write-seat-refuses/expected.json +1 -1
- package/conformance/cases/c73-projects-extended-registration-reads/expected.json +1 -1
- package/conformance/cases/c74-projects-over-bound-refused/expected.json +3 -72
- package/conformance/cases/c75-projects-patch-remote-uniqueness/expected.json +3 -72
- package/conformance/cases/c76-projects-entry-salvage-nested/expected.json +1 -1
- package/conformance/cases/c77-prompts-center-artifact-carried/expected.json +1 -1
- package/conformance/cases/c78-prompts-empty-bindings-refused/expected.json +1 -1
- package/conformance/cases/c79-prompts-bad-worker-artifact-not-salvaged/expected.json +1 -1
- package/conformance/cases/c80-prompts-wire-v2-verbatim/expected.json +1 -1
- package/conformance/cases/c81-prompts-declaration-bindings-refused/expected.json +1 -1
- package/conformance/cases/c82-prompts-v1-catalog-refused/expected.json +1 -1
- package/conformance/cases/c83-prompts-bad-overlay-not-salvaged/expected.json +1 -1
- package/conformance/cases/c84-sandbox-git-block-carried-verbatim/expected.json +1 -1
- package/conformance/cases/c85-sandbox-git-refused-block-still-carried/expected.json +1 -1
- package/conformance/cases/c86-a2a-peers-legal/expected.json +1 -1
- package/conformance/cases/c87-a2a-credential-refs-not-partially-salvaged/expected.json +1 -1
- package/conformance/cases/c88-projects-content-attestation-carried/expected.json +1 -1
- package/conformance/cases/c89-projects-content-attestation-malformed/expected.json +1 -1
- package/conformance/cases/c90-mcp-assertion-credential-carried/expected.json +143 -0
- package/conformance/cases/c90-mcp-assertion-credential-carried/input.json +30 -0
- package/conformance/cases/c90-mcp-assertion-credential-carried/meta.json +6 -0
- package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/expected.json +105 -0
- package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/input.json +27 -0
- package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/meta.json +6 -0
- package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/expected.json +105 -0
- package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/input.json +31 -0
- package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/meta.json +6 -0
- package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/expected.json +105 -0
- package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/input.json +33 -0
- package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/meta.json +6 -0
- package/conformance/cases/c94-mcp-credentials-env-kind-dropped/expected.json +105 -0
- package/conformance/cases/c94-mcp-credentials-env-kind-dropped/input.json +32 -0
- package/conformance/cases/c94-mcp-credentials-env-kind-dropped/meta.json +6 -0
- package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/expected.json +105 -0
- package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/input.json +30 -0
- package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/meta.json +6 -0
- package/conformance/cases/c96-mcp-credentials-extra-member-dropped/expected.json +105 -0
- package/conformance/cases/c96-mcp-credentials-extra-member-dropped/input.json +31 -0
- package/conformance/cases/c96-mcp-credentials-extra-member-dropped/meta.json +6 -0
- package/conformance/cases/cc01-mcp-toolfaces-non-object/expected.json +1 -1
- package/conformance/cases/cc02-mcp-source-key-is-transported/expected.json +1 -1
- package/conformance/cases/cc03-model-compat-unknown-subkey/expected.json +1 -1
- package/conformance/cases/cli01-model-name-nfc-vs-nfd/expected.json +1 -1
- package/conformance/cases/cli02-control-and-zero-width-chars/expected.json +1 -1
- package/conformance/cases/cli03-credential-pasted-into-unknown-key/expected.json +1 -1
- package/conformance/cases/cli04-env-value-with-newline/expected.json +1 -1
- package/conformance/cases/cli05-long-and-prefix-colliding-names/expected.json +1 -1
- package/conformance/cases/t01-absent-domain-key-not-null/expected.json +1 -1
- package/conformance/cases/t03-prototype-name-key-not-swallowed/expected.json +1 -1
- package/conformance/cases/t04-secret-literal-never-in-warning-value/expected.json +1 -1
- package/conformance/cases/z01-every-domain-empty-object/expected.json +1 -1
- package/conformance/cases/z02-every-domain-unknown-key/expected.json +1 -1
- package/dist/api/credentials.js +5 -7
- package/dist/api/lifecycle-events.d.ts +266 -0
- package/dist/api/lifecycle-events.js +169 -0
- package/dist/api/wire-scalars.d.ts +13 -0
- package/dist/api/wire-scalars.js +15 -0
- package/dist/atomic-write.d.ts +4 -0
- package/dist/atomic-write.js +26 -3
- package/dist/config-d-file.d.ts +1 -1
- package/dist/config-document-refusal.d.ts +4 -4
- package/dist/config-fns.d.ts +1 -1
- package/dist/config-root-documents.d.ts +1 -1
- package/dist/config-root-node.js +2 -1
- package/dist/conformance/corpus.d.ts +1 -1
- package/dist/conformance/derive.d.ts +13 -5
- package/dist/conformance/derive.js +36 -20
- package/dist/conformance/index.d.ts +1 -1
- package/dist/conformance/index.js +1 -1
- package/dist/conformance/run.js +8 -9
- package/dist/connector-authorize-url.d.ts +23 -0
- package/dist/connector-authorize-url.js +129 -0
- package/dist/connector-id.d.ts +23 -0
- package/dist/connector-id.js +27 -0
- package/dist/file-edit.d.ts +44 -0
- package/dist/file-edit.js +70 -1
- package/dist/file-store.d.ts +12 -7
- package/dist/file-store.js +70 -58
- package/dist/hooks.d.ts +15 -5
- package/dist/hooks.js +13 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -1
- package/dist/mcp-entry-credential.d.ts +47 -0
- package/dist/mcp-entry-credential.js +73 -0
- package/dist/mcp-request-entry.d.ts +32 -13
- package/dist/mcp-request-entry.js +104 -58
- package/dist/migration-receipt.d.ts +2 -2
- package/dist/migration-receipt.js +2 -2
- package/dist/one-time-migrations.d.ts +2 -2
- package/dist/one-time-migrations.js +72 -55
- package/dist/portable-domains.d.ts +18 -12
- package/dist/portable-domains.js +17 -12
- package/dist/retired-role-words.d.ts +1 -1
- package/dist/retired-role-words.js +4 -6
- package/dist/scheduler-store-node.d.ts +5 -2
- package/dist/scheduler-store-node.js +8 -5
- package/dist/sha256.d.ts +5 -0
- package/dist/sha256.js +7 -0
- package/dist/skills-manifest.js +2 -2
- package/dist/types.d.ts +80 -10
- package/dist/types.js +30 -39
- package/docs/API-SURFACE.md +47 -7
- package/docs/CONFORMANCE.md +6 -4
- package/docs/CONSUMER-INTEGRATION.md +109 -4
- package/llms-full.txt +44 -23
- package/llms.txt +26 -13
- package/package.json +3 -2
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `api/lifecycle-events` —— 用户生命周期事件的 wire 型(29.0.0):管理面把「一个主体被删 / 被降级 / 被移出空间」这类事实发成一串带序号的事件,
|
|
3
|
+
* 执行面按页拉取、按序号去重,并在启动与游标失效时用「对账」补齐现状。一份 zod,发这些形的一方(管理面)与收这些形的一方(执行面)同 import。纯、浏览器安全。
|
|
4
|
+
*
|
|
5
|
+
* 本模块只有**形与词表**:事件怎么产生与存放、保留多久、页怎么切、`head` 怎么算、鉴权与委托、消费方拿事件做什么(停谁的活),都是各方自己的事,不在这里。
|
|
6
|
+
* 拉取口的查询参数(`after` / `limit`)不是体,本模块不立它们的型;拒词({@link LIFECYCLE_PAGE_REFUSALS})只管游标与分页这四种,
|
|
7
|
+
* 鉴权类的拒答(401 / 403)不在这张表里。
|
|
8
|
+
*
|
|
9
|
+
* ## 解析一律剥未知键(与同目录的凭据 wire 型同一条规则)
|
|
10
|
+
* 对象型里不认识的**键**被剥掉、不进解析结果、不拒 —— 新键恒为加性,发方与收方各自独立升级。**例外只有一个:不认识的 `kind` 值**(事件行的判别键)
|
|
11
|
+
* 响亮地拒,整页随之拒,拒句点名那个词(坐标带它在 `events` 里的下标):`kind` 是闭集,收方悄悄丢掉一条自己不认识的生命周期事件 = 安全面的静默放过。
|
|
12
|
+
* 同理 `standing` / `error` 这两个判别键里不认识的词也拒。
|
|
13
|
+
*
|
|
14
|
+
* ## 事件
|
|
15
|
+
* 一条事件 = 一个按 `kind` 判别的对象。五个 `kind`(闭集 {@link PRINCIPAL_LIFECYCLE_EVENT_KINDS}):
|
|
16
|
+
* · `principal.deleted` —— 主体的 users 行被删;`principalInc` 取被删那一行的。不带 `scope`。
|
|
17
|
+
* · `principal.pending` —— 主体的实例角色从 `admin` 改走,且此刻没有任何空间成员资格。不带 `scope`。
|
|
18
|
+
* · `principal.role_lowered` —— 主体的实例角色从 `admin` 改走,但仍有空间成员资格。不带 `scope`:消费方立即对该主体对账。
|
|
19
|
+
* · `membership.removed` —— 一条空间成员行被删,且该主体不是实例 `admin`。**必带** `scope`。
|
|
20
|
+
* · `membership.role_lowered` —— 一个空间角色跨过 `editor` 底线往下降。**必带** `scope`。
|
|
21
|
+
* 共有成员:`eventId`(非空串;审计与跨库恢复时辨认事件)· `seq`(≥ 1 的安全整数;发方给的单调序号,收方的**去重键**)· `principal`(主体名,界同令牌 `sub`)·
|
|
22
|
+
* `principalInc`(可缺席;化身号,与令牌 `sub_inc` 同一只 {@link PrincipalIncarnation} —— 同一个名字被删后重建是另一个人,靠它分辨)· `at`(毫秒时刻,发方的钟)。
|
|
23
|
+
*
|
|
24
|
+
* ## 页与游标
|
|
25
|
+
* 一页 = `{ events, head, next }`:`events` 按 `seq` 升序(可以是空页);`head` = 发方此刻的头游标(收方「启动与游标失效」时先取它、再对账、再从它起拉);
|
|
26
|
+
* `next` = 下一次拉取带的游标(只进不退)。三个成员都不可缺席;游标是安全整数。
|
|
27
|
+
* 拉取失败的四个词({@link LIFECYCLE_PAGE_REFUSALS}):`cursor_invalid` / `limit_invalid`(400,请求自己不合格)· `cursor_expired`(游标早于发方还保留的最早位置)/
|
|
28
|
+
* `cursor_unknown`(游标晚于发方已知的位置,例如发方的库恢复到更早的备份)(410,拒体带 `head`:收方的重同步程序从它起)。
|
|
29
|
+
* 拒体 = `{ error, permanence, message }`(410 的词再加 `head`),与凭据 wire 的拒体同一种形(码 + 永久性);四个词的永久性都是 `terminal`(同一请求原样重发不会成功)。
|
|
30
|
+
*
|
|
31
|
+
* ## 对账
|
|
32
|
+
* 请求 {@link PrincipalReconcileRequest} = `{ principals: [{ principal, principalInc? }] }`,1 – {@link PRINCIPAL_RECONCILE_MAX_ITEMS} 项;
|
|
33
|
+
* 应答 {@link PrincipalReconcileAnswer} = `{ principals: [...] }`,每项回显请求里的身份元组并按 `standing` 判别:`live`(仍在;`since` 可缺席,只在这一臂)/ `gone`(不在了)。
|
|
34
|
+
* 应答与请求逐项对应(同序同长)是收方要核的事,本形只钉 1 – {@link PRINCIPAL_RECONCILE_MAX_ITEMS} 项。
|
|
35
|
+
*/
|
|
36
|
+
import { z } from "zod";
|
|
37
|
+
import { echoCallerText } from "../caller-text-echo.js";
|
|
38
|
+
import { deepFreeze } from "../deep-freeze.js";
|
|
39
|
+
import { ownValueOf } from "../own-key-read.js";
|
|
40
|
+
import { isPlainJsonObject } from "../plain-json-object.js";
|
|
41
|
+
import { buildQuotedIssue } from "../quoted-issue.js";
|
|
42
|
+
import { PrincipalIncarnation } from "./auth-bridge.js";
|
|
43
|
+
import { SANDBOX_GIT_PERMANENCE } from "./credentials.js";
|
|
44
|
+
import { ScopeId } from "./scopes.js";
|
|
45
|
+
import { NonEmptyString, PrincipalString, SafeCount } from "./wire-scalars.js";
|
|
46
|
+
// ── 事件 ───────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
/**
|
|
48
|
+
* 事件 `kind` 表(包内私有):一词一行 `{ kind, scoped }` —— **每个词只在这里拼一次**;`scoped` = 这一臂**必带** `scope`(`membership.*` 两词),其余臂不带。
|
|
49
|
+
* 词表({@link PRINCIPAL_LIFECYCLE_EVENT_KINDS})、词的类型({@link PrincipalLifecycleEventKind})与事件行联合({@link PrincipalLifecycleEvent})的每一臂都由它派生,没有第二张词表。
|
|
50
|
+
*/
|
|
51
|
+
const EVENT_KIND_ROWS = deepFreeze([
|
|
52
|
+
{ kind: "principal.deleted", scoped: false },
|
|
53
|
+
{ kind: "principal.pending", scoped: false },
|
|
54
|
+
{ kind: "principal.role_lowered", scoped: false },
|
|
55
|
+
{ kind: "membership.removed", scoped: true },
|
|
56
|
+
{ kind: "membership.role_lowered", scoped: true },
|
|
57
|
+
]);
|
|
58
|
+
/** 用户生命周期事件的 `kind` 词表(运行期;定义处深冻结;表的 `kind` 列,按表序)。 */
|
|
59
|
+
export const PRINCIPAL_LIFECYCLE_EVENT_KINDS = deepFreeze(EVENT_KIND_ROWS.map((row) => row.kind));
|
|
60
|
+
/** 身份元组:主体名 + 可缺席的化身号。事件行、对账请求项、对账应答项都是它 —— 一份定义。 */
|
|
61
|
+
const PrincipalTuple = {
|
|
62
|
+
principal: PrincipalString,
|
|
63
|
+
principalInc: PrincipalIncarnation.optional(),
|
|
64
|
+
};
|
|
65
|
+
/** 事件行的共有成员(`kind` 与 `scope` 由各臂自己带)。 */
|
|
66
|
+
const EventCommon = {
|
|
67
|
+
eventId: NonEmptyString,
|
|
68
|
+
seq: SafeCount.positive(),
|
|
69
|
+
...PrincipalTuple,
|
|
70
|
+
at: SafeCount,
|
|
71
|
+
};
|
|
72
|
+
/** 不带空间的臂:`{ kind, eventId, seq, principal, principalInc?, at }`。 */
|
|
73
|
+
function plainArm(kind) {
|
|
74
|
+
return z.object({ kind: z.literal(kind), ...EventCommon });
|
|
75
|
+
}
|
|
76
|
+
/** 带空间的臂:在共有成员之上**必带** `scope`({@link ScopeId};保留的 `global` 也是合法空间)。 */
|
|
77
|
+
function scopedArm(kind) {
|
|
78
|
+
return z.object({ kind: z.literal(kind), ...EventCommon, scope: ScopeId });
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 一条用户生命周期事件,按 `kind` 判别;臂由 `kind` 表派生,每词一臂、同序。未知键剥掉(`principal.*` 臂带的 `scope` 也是它那一臂的未知键,同样剥掉);
|
|
82
|
+
* `membership.*` 臂缺 `scope` 拒;**未知的 `kind` 值拒,句子点名那个词**(经 {@link echoCallerText} 回显:剥控制与双向字符、有界)。
|
|
83
|
+
* `kind` 不是字符串 / 缺席时没有词可点,句子是 zod 自己的、不回显值。
|
|
84
|
+
*/
|
|
85
|
+
export const PrincipalLifecycleEvent = z.discriminatedUnion("kind", EVENT_KIND_ROWS.map((row) => (row.scoped ? scopedArm(row.kind) : plainArm(row.kind))), {
|
|
86
|
+
error: (iss) => {
|
|
87
|
+
if (iss.code !== "invalid_union" || !isPlainJsonObject(iss.input))
|
|
88
|
+
return undefined;
|
|
89
|
+
// `kind` 从输入自己的键读(输入是调用方的对象:继承来的 / 被污染的 `kind` 不是对方写的词;读不出的 Proxy 没有词可点)
|
|
90
|
+
const kind = ownValueOf(iss.input, "kind");
|
|
91
|
+
if (!kind.ok || typeof kind.value !== "string" || kind.value === "")
|
|
92
|
+
return undefined;
|
|
93
|
+
return `unknown lifecycle event kind ${echoCallerText(kind.value)}; the closed set is ${PRINCIPAL_LIFECYCLE_EVENT_KINDS.join(", ")}`; // no quotes: the sentence survives a JSON-rendered issue list verbatim
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
// ── 事件页 ─────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
97
|
+
/**
|
|
98
|
+
* 一页事件:`events`(按 `seq` 升序,可以是空页)· `head`(发方此刻的头游标)· `next`(下一次拉取带的游标,只进不退)。三个成员都不可缺席;未知键剥掉;
|
|
99
|
+
* 页里有一条事件的 `kind` 不认识 ⇒ 整页拒(坐标 `events.<下标>.kind`)。
|
|
100
|
+
* 页的长度上界、`seq` 在页内是否升序、`next` 与最后一条事件的关系都是发方的事,本形不核。
|
|
101
|
+
*/
|
|
102
|
+
export const PrincipalLifecycleEventPage = z.object({
|
|
103
|
+
events: z.array(PrincipalLifecycleEvent),
|
|
104
|
+
head: SafeCount,
|
|
105
|
+
next: SafeCount,
|
|
106
|
+
});
|
|
107
|
+
// ── 拉取失败的词与状态码 ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
108
|
+
/** 永久性词表(凭据 wire 的那一张)的 `terminal`:同一请求原样重发不会成功。词只在 `./credentials` 里拼一次,这里取表的首项(次序在那边的钉里)。 */
|
|
109
|
+
const TERMINAL = SANDBOX_GIT_PERMANENCE[0];
|
|
110
|
+
/**
|
|
111
|
+
* 拉取失败词(游标与分页这一类,四个)→ 它的 HTTP 状态码与永久性。**一个词只有一个状态码、一个永久性**,表是它们的唯一一处:
|
|
112
|
+
* · 400 —— 请求自己不合格:`cursor_invalid`(游标不是合法游标)/ `limit_invalid`(页长不合法);
|
|
113
|
+
* · 410 —— 游标对不上发方的现状,收方要重同步:`cursor_expired`(游标早于发方还保留的最早位置)/ `cursor_unknown`(游标晚于发方已知的位置)。
|
|
114
|
+
* **410 的拒体带 `head`**(收方从它起重新拉);400 的拒体不带。「带不带 `head`」由这一列推出,不另立一张表({@link LifecyclePageRefusal})。
|
|
115
|
+
* 永久性({@link SandboxGitPermanence},词表在凭据 wire 里):四个词都是 `terminal` —— 同一请求原样重发不会成功(400 的要改请求,410 的要先重新同步);拒体里的 `permanence` 必须等于这一行的。
|
|
116
|
+
* 鉴权类的拒答不在这张表里。
|
|
117
|
+
*/
|
|
118
|
+
export const LIFECYCLE_PAGE_REFUSALS = deepFreeze({
|
|
119
|
+
cursor_invalid: { status: 400, permanence: TERMINAL },
|
|
120
|
+
limit_invalid: { status: 400, permanence: TERMINAL },
|
|
121
|
+
cursor_expired: { status: 410, permanence: TERMINAL },
|
|
122
|
+
cursor_unknown: { status: 410, permanence: TERMINAL },
|
|
123
|
+
});
|
|
124
|
+
/** 拉取失败词表(运行期;表的键,按表序)。 */
|
|
125
|
+
export const LIFECYCLE_PAGE_REFUSAL_ERRORS = deepFreeze(Object.keys(LIFECYCLE_PAGE_REFUSALS));
|
|
126
|
+
/** 表里状态码是 `status` 的词,按表序。 */
|
|
127
|
+
function refusalWordsWith(status) {
|
|
128
|
+
return LIFECYCLE_PAGE_REFUSAL_ERRORS.filter((word) => LIFECYCLE_PAGE_REFUSALS[word].status === status);
|
|
129
|
+
}
|
|
130
|
+
/** 拒体的共有成员:永久性(必须等于表里这一词的,见下面的 `refine`)与诊断句。 */
|
|
131
|
+
const RefusalCommon = {
|
|
132
|
+
permanence: z.enum(SANDBOX_GIT_PERMANENCE),
|
|
133
|
+
message: z.string(),
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* 拉取失败的体,按 `error` 判别(与凭据 wire 的拒体同一种形:码 + 永久性 + 诊断句):
|
|
137
|
+
* · 400 的词:`{ error, permanence, message }`;
|
|
138
|
+
* · 410 的词:`{ error, permanence, message, head }` —— `head` = 发方此刻的头游标(安全整数)。
|
|
139
|
+
* `permanence` 是错误词的函数,必须等于 {@link LIFECYCLE_PAGE_REFUSALS} 里这一行的,两处不一致就是畸形应答(拒)。
|
|
140
|
+
* `message` 是发方的诊断句(收方不据它判,可为空串)。体里不带状态码:状态码是 HTTP 层的,词与状态码的对应只看 {@link LIFECYCLE_PAGE_REFUSALS}。未知键剥掉。
|
|
141
|
+
*/
|
|
142
|
+
export const LifecyclePageRefusal = z
|
|
143
|
+
.discriminatedUnion("error", [
|
|
144
|
+
z.object({ error: z.enum(refusalWordsWith(400)), ...RefusalCommon }),
|
|
145
|
+
z.object({ error: z.enum(refusalWordsWith(410)), ...RefusalCommon, head: SafeCount }),
|
|
146
|
+
])
|
|
147
|
+
.refine((body) => LIFECYCLE_PAGE_REFUSALS[body.error].permanence === body.permanence, buildQuotedIssue `permanence must be the one the refusal table gives for this error`);
|
|
148
|
+
// ── 对账 ───────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
149
|
+
/** 一次对账请求(与应答)里最多几项。 */
|
|
150
|
+
export const PRINCIPAL_RECONCILE_MAX_ITEMS = 500;
|
|
151
|
+
/** 对账请求的一项:要问现状的那个身份元组。 */
|
|
152
|
+
export const PrincipalReconcileItem = z.object({ ...PrincipalTuple });
|
|
153
|
+
/** 对账请求:`{ principals }`,1 – {@link PRINCIPAL_RECONCILE_MAX_ITEMS} 项;未知键剥掉。 */
|
|
154
|
+
export const PrincipalReconcileRequest = z.object({
|
|
155
|
+
principals: z.array(PrincipalReconcileItem).min(1).max(PRINCIPAL_RECONCILE_MAX_ITEMS),
|
|
156
|
+
});
|
|
157
|
+
/**
|
|
158
|
+
* 一个主体的现状,按 `standing` 判别;回显请求里的身份元组(`principal`、可缺席的 `principalInc`);未知键剥掉:
|
|
159
|
+
* · `live` —— 仍在;`since`(毫秒时刻,可缺席)**只在这一臂**:这一段「在」的起点;
|
|
160
|
+
* · `gone` —— 不在了;这一臂的形没有 `since`(带了的被剥掉)。
|
|
161
|
+
*/
|
|
162
|
+
export const PrincipalStanding = z.discriminatedUnion("standing", [
|
|
163
|
+
z.object({ standing: z.literal("live"), ...PrincipalTuple, since: SafeCount.optional() }),
|
|
164
|
+
z.object({ standing: z.literal("gone"), ...PrincipalTuple }),
|
|
165
|
+
]);
|
|
166
|
+
/** 对账应答:`{ principals }`,每项是一个 {@link PrincipalStanding};1 – {@link PRINCIPAL_RECONCILE_MAX_ITEMS} 项(与请求逐项对应是收方要核的事);未知键剥掉。 */
|
|
167
|
+
export const PrincipalReconcileAnswer = z.object({
|
|
168
|
+
principals: z.array(PrincipalStanding).min(1).max(PRINCIPAL_RECONCILE_MAX_ITEMS),
|
|
169
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `api/wire-scalars` —— 包内私有叶子模块(不在主桶、不在任何子路径):api 各 wire 模块共用的标量形,一处定义、各处引用。
|
|
3
|
+
*
|
|
4
|
+
* 这几只形此前是 `api/credentials` 的模块私有常量;第二个 wire 模块(`api/lifecycle-events`)要同样的形时,不抄第二份 —— 挪到这里,两处 import。
|
|
5
|
+
* 不导出给消费方:消费方要的是 wire 型(`SandboxGitCredentialAnswer` / `PrincipalLifecycleEvent` …),不是这几只积木。纯、浏览器安全。
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
/** wire 上每个数值位(毫秒时刻、行版本、游标)的形:非负安全整数 —— 包内的整数判据 + 安全整数上界;浮点、负数、超出安全整数的都不是。 */
|
|
9
|
+
export declare const SafeCount: z.ZodNumber;
|
|
10
|
+
/** 非空串:一个不透明标识(行 id、句柄、审计 id …),不 trim、不折叠、不解析。 */
|
|
11
|
+
export declare const NonEmptyString: z.ZodString;
|
|
12
|
+
/** wire 上的主体名:非空串,长度界同令牌 `sub` 的界({@link PRINCIPAL_MAX_LENGTH} —— 引擎的主体门拒更长的)。校验或铸主体名的一方都查这一个值。 */
|
|
13
|
+
export declare const PrincipalString: z.ZodString;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `api/wire-scalars` —— 包内私有叶子模块(不在主桶、不在任何子路径):api 各 wire 模块共用的标量形,一处定义、各处引用。
|
|
3
|
+
*
|
|
4
|
+
* 这几只形此前是 `api/credentials` 的模块私有常量;第二个 wire 模块(`api/lifecycle-events`)要同样的形时,不抄第二份 —— 挪到这里,两处 import。
|
|
5
|
+
* 不导出给消费方:消费方要的是 wire 型(`SandboxGitCredentialAnswer` / `PrincipalLifecycleEvent` …),不是这几只积木。纯、浏览器安全。
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { INTEGER } from "../integer.js";
|
|
9
|
+
import { PRINCIPAL_MAX_LENGTH } from "./auth-bridge.js";
|
|
10
|
+
/** wire 上每个数值位(毫秒时刻、行版本、游标)的形:非负安全整数 —— 包内的整数判据 + 安全整数上界;浮点、负数、超出安全整数的都不是。 */
|
|
11
|
+
export const SafeCount = INTEGER.nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
12
|
+
/** 非空串:一个不透明标识(行 id、句柄、审计 id …),不 trim、不折叠、不解析。 */
|
|
13
|
+
export const NonEmptyString = z.string().min(1);
|
|
14
|
+
/** wire 上的主体名:非空串,长度界同令牌 `sub` 的界({@link PRINCIPAL_MAX_LENGTH} —— 引擎的主体门拒更长的)。校验或铸主体名的一方都查这一个值。 */
|
|
15
|
+
export const PrincipalString = z.string().min(1).max(PRINCIPAL_MAX_LENGTH);
|
package/dist/atomic-write.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export declare function resolveSymlinkTarget(target: string): string;
|
|
|
19
19
|
/** 读一份**可以缺席**的 UTF-8 文本 —— `config.d` 文档与 `.env` 的缺席律在 {@link absentUnlessDangling}:读得到 ⇒ 文本;读不出 ⇒ 缺席尾(`ENOENT` 且无座位是悬空链接 ⇒ `undefined`;悬空 ⇒ 抛那一句;别的读不出原样抛)。
|
|
20
20
|
* 配置根自己是悬空链接(祖先座)不在问的范围内:`dirSeats` 只列文件所在的那一级布局座。 */
|
|
21
21
|
export declare function readTextIfPresent(file: string, dirSeats?: readonly string[]): Promise<string | undefined>;
|
|
22
|
+
/** 读一份**可以缺席**的文件的**原始字节**:与 {@link readTextIfPresent} 同一个缺席尾(缺席律只此一处),只有读的那一行 I/O 不同 —— 要对**盘上的字节**算摘要的读者(条件写器 `writeDomainFileIf`)用它,不经 UTF-8 解码。 */
|
|
23
|
+
export declare function readBytesIfPresent(file: string, dirSeats?: readonly string[]): Promise<Buffer | undefined>;
|
|
22
24
|
/** {@link readTextIfPresent} 的同步孪生(壳在同步具名锁里读 `config.d` 文档要它):同一个缺席尾,只有读文本那一行 I/O 不同。 */
|
|
23
25
|
export declare function readTextIfPresentSync(file: string, dirSeats?: readonly string[]): string | undefined;
|
|
24
26
|
/** 原子写 `text`(UTF-8)到 `target`(符号链接则写到它指向的真文件,见文件头);模式按 `kind` 在 {@link ATOMIC_FILE_CLASSES} 里的行。父目录须已存在。 */
|
|
@@ -47,5 +49,7 @@ export declare function createFileExclusive(target: string, text: string, kind:
|
|
|
47
49
|
* 目录不在就建(连同缺的上级):**逐级** mkdir、每建一级立刻 chmod 到 {@link OWNER_ONLY_DIRECTORY_MODE} —— 模式恰是它,不经 umask(umask 0777 下一次性的递归 mkdir 会先建出
|
|
48
50
|
* 一级 0000 的目录、再也进不去建下一级)。本进程建了 `dir` ⇒ `"created"`;`dir` 已在(或恰被别的进程同时建成)⇒ `"present"`(它的模式一位不动)。
|
|
49
51
|
* 路径上有一节不是目录 ⇒ 抛。
|
|
52
|
+
* 交来的路径串**原样交内核**、不做任何解法(见文件头「一次操作一条路径串」):调用方交的是它随后要写的那份文件的路径串的 `dirname`,目录与文件于是落在同一处
|
|
53
|
+
* (`链接/..` 由内核按链接目标的物理父目录解,相对路径对进程 cwd 解)。向上找已在的祖先时逐级取 `path.dirname`,每一级的「在不在」都问内核。
|
|
50
54
|
*/
|
|
51
55
|
export declare function ensureOwnerOnlyDirectory(dir: string): "created" | "present";
|
package/dist/atomic-write.js
CHANGED
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
* **不受 umask 放宽,也不受 umask 收窄**(前者:`mkdir` 给的 mode 本身就是 0o700,umask 只能清掉位、加不了位;后者:例如 umask 0o277 下 `mkdir` 先出 0o500,紧跟的 `chmod` 把它定回 0o700)。
|
|
35
35
|
* 这是目录的另一条律,与上面「新建文件经进程 umask」不是同一条律的两个特例;已在的目录一位不动。目录模式与文件模式同在本文件一处定。
|
|
36
36
|
*
|
|
37
|
+
* ## 一次操作一条路径串
|
|
38
|
+
* 本文件的原语(建目录 {@link ensureOwnerOnlyDirectory}、原子写器、不存在才建、读)**对交来的路径串不做词法归一**:原样交内核(原子写器对「目标是符号链接」的处置见下节 —— 那是对目标文件的解法,不是对这条串的归一),派生只用 `path.dirname` 与只拼接({@link entryIn})。
|
|
39
|
+
* 路径串由拼它的那一面在操作入口定一次,一次操作里建目录、临时文件、`rename` / `link` 的落点都从这一串派生 —— **要建的目录 = 随后要写的那份文件的路径串的 `dirname`**:
|
|
40
|
+
* 调度店 = 调用方给的店路径原样;配置根 = `path.join(根, 文件名)`(配置根的每一个读口与写口一向这么拼)。同一次操作里不出现第二种解法。
|
|
41
|
+
*
|
|
37
42
|
* ## 写失败(12.0.0;句子归文件系统失败句的唯一铸点)
|
|
38
43
|
* 三步各一句({@link FsFailure},句子在 `./fs-failure`):临时文件建不出 ⇒ 「cannot write into directory <dir> (<errno>): …」(点名目录 —— 目录不可写时
|
|
39
44
|
* 文件本身没错);沿用原模式的文件给临时文件设模式失败 ⇒ 「cannot set the mode of <file> (<errno>): …」(点名设模式这一步 —— 文件系统不让改模式,目录没有问题);`rename` 失败 ⇒ 「cannot replace <file> (<errno>): …」(点名真文件)。
|
|
@@ -100,6 +105,15 @@ export async function readTextIfPresent(file, dirSeats = []) {
|
|
|
100
105
|
return absentUnlessDangling(e, file, dirSeats);
|
|
101
106
|
}
|
|
102
107
|
}
|
|
108
|
+
/** 读一份**可以缺席**的文件的**原始字节**:与 {@link readTextIfPresent} 同一个缺席尾(缺席律只此一处),只有读的那一行 I/O 不同 —— 要对**盘上的字节**算摘要的读者(条件写器 `writeDomainFileIf`)用它,不经 UTF-8 解码。 */
|
|
109
|
+
export async function readBytesIfPresent(file, dirSeats = []) {
|
|
110
|
+
try {
|
|
111
|
+
return await readFile(file);
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
return absentUnlessDangling(e, file, dirSeats);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
103
117
|
/** {@link readTextIfPresent} 的同步孪生(壳在同步具名锁里读 `config.d` 文档要它):同一个缺席尾,只有读文本那一行 I/O 不同。 */
|
|
104
118
|
export function readTextIfPresentSync(file, dirSeats = []) {
|
|
105
119
|
try {
|
|
@@ -109,6 +123,13 @@ export function readTextIfPresentSync(file, dirSeats = []) {
|
|
|
109
123
|
return absentUnlessDangling(e, file, dirSeats);
|
|
110
124
|
}
|
|
111
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* 目录 `dir`(`path.dirname` 的结果)下名为 `name` 的条目 —— **只拼接,不做词法归一**:路径里的 `链接/..` 留给内核按链接目标的物理父目录解,
|
|
128
|
+
* 与目标路径本身(rename / link 的落点)同一种解法;`path.join` 会先把它消成链接所在的目录,临时文件就落在另一个目录里。
|
|
129
|
+
*/
|
|
130
|
+
function entryIn(dir, name) {
|
|
131
|
+
return dir.endsWith(path.sep) ? `${dir}${name}` : `${dir}${path.sep}${name}`;
|
|
132
|
+
}
|
|
112
133
|
/** 原子写 `text`(UTF-8)到 `target`(符号链接则写到它指向的真文件,见文件头);模式按 `kind` 在 {@link ATOMIC_FILE_CLASSES} 里的行。父目录须已存在。 */
|
|
113
134
|
export function writeFileAtomic(target, text, kind) {
|
|
114
135
|
const real = resolveSymlinkTarget(target);
|
|
@@ -132,7 +153,7 @@ export function writeFileAtomic(target, text, kind) {
|
|
|
132
153
|
}
|
|
133
154
|
}
|
|
134
155
|
const dir = path.dirname(real);
|
|
135
|
-
const tmp =
|
|
156
|
+
const tmp = entryIn(dir, `.${path.basename(real)}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
|
|
136
157
|
let site = { landing: "dir-create-temp", path: tmp };
|
|
137
158
|
try {
|
|
138
159
|
writeFileSync(tmp, text, { encoding: "utf8", mode: kept ?? spec.newMode });
|
|
@@ -209,7 +230,7 @@ function writeTempExclusive(tmp, text, mode) {
|
|
|
209
230
|
export function createFileExclusive(target, text, kind) {
|
|
210
231
|
const spec = ATOMIC_FILE_CLASSES[kind];
|
|
211
232
|
const dir = path.dirname(target);
|
|
212
|
-
const tmp =
|
|
233
|
+
const tmp = entryIn(dir, `.${path.basename(target)}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
|
|
213
234
|
try {
|
|
214
235
|
writeTempExclusive(tmp, text, spec.newMode);
|
|
215
236
|
}
|
|
@@ -244,9 +265,11 @@ export function createFileExclusive(target, text, kind) {
|
|
|
244
265
|
* 目录不在就建(连同缺的上级):**逐级** mkdir、每建一级立刻 chmod 到 {@link OWNER_ONLY_DIRECTORY_MODE} —— 模式恰是它,不经 umask(umask 0777 下一次性的递归 mkdir 会先建出
|
|
245
266
|
* 一级 0000 的目录、再也进不去建下一级)。本进程建了 `dir` ⇒ `"created"`;`dir` 已在(或恰被别的进程同时建成)⇒ `"present"`(它的模式一位不动)。
|
|
246
267
|
* 路径上有一节不是目录 ⇒ 抛。
|
|
268
|
+
* 交来的路径串**原样交内核**、不做任何解法(见文件头「一次操作一条路径串」):调用方交的是它随后要写的那份文件的路径串的 `dirname`,目录与文件于是落在同一处
|
|
269
|
+
* (`链接/..` 由内核按链接目标的物理父目录解,相对路径对进程 cwd 解)。向上找已在的祖先时逐级取 `path.dirname`,每一级的「在不在」都问内核。
|
|
247
270
|
*/
|
|
248
271
|
export function ensureOwnerOnlyDirectory(dir) {
|
|
249
|
-
const target =
|
|
272
|
+
const target = dir;
|
|
250
273
|
const missing = [];
|
|
251
274
|
for (let at = target; !existsSync(at);) {
|
|
252
275
|
missing.unshift(at);
|
package/dist/config-d-file.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare function readConfigDFileReading(root: string, name: ConfigDDocume
|
|
|
48
48
|
export declare function readConfigDFileReadingSync(root: string, name: ConfigDDocumentName): ConfigDReading;
|
|
49
49
|
/** 抛出口:读一个 `config.d/<名>.json`:路径上没有任何条目 ⇒ `undefined`;在场 ⇒ 它的值;被拒 ⇒ 抛读数的 `thrown`(见 {@link readConfigDFileReading})。 */
|
|
50
50
|
export declare function readConfigDFile(root: string, name: ConfigDDocumentName): Promise<Record<string, unknown> | undefined>;
|
|
51
|
-
/** 一棵 `config.d`
|
|
51
|
+
/** 一棵 `config.d` 的原文快照:本地读取域与 retired 域的文档原文(缺席 ⇒ `undefined`),版本哈希的入参。 */
|
|
52
52
|
export type ConfigDRaws = Partial<Record<DomainName | RetiredDomainName, unknown>>;
|
|
53
53
|
/** 一棵 `config.d` 原文快照的内容版本(稳定的 u53 整数):同样的文档 ⇒ 同一个数。`FileConfigStore` 的 `getVersion()` / `getEffective()` / `read()` 读同一只。 */
|
|
54
54
|
export declare function configDVersionOf(raws: ConfigDRaws): number;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* ## 形
|
|
12
12
|
* 一条拒 = `{ document, reason, error }`:
|
|
13
|
-
* · `document`:被拒的文档 ——
|
|
13
|
+
* · `document`:被拒的文档 —— 本地读取域名(便携域名或 `projects`),或 retired 域名(retired 域的文档就以域名相称,墓碑拒的「域」就是这个名字,不另设第二个键);
|
|
14
14
|
* · `reason`:闭集词 {@link CONFIG_DOCUMENT_REFUSAL_REASONS}。文件层五个 —— `empty`(空 / 纯空白:半写、截断)· `invalid_json`(JSON 解析不过)· `not_object`(解析出来不是 JSON 对象:
|
|
15
15
|
* `null` / 数组 / 数 / 串 / 布尔)· `io`(在场却读不出:权限、路径是目录、I/O 错误、悬空的符号链接〔文档本身或 `config.d` 目录:链接在、目标不在,17.0.0 起;句子点名链接与出路〕;缺席 = 路径上没有任何条目,不是拒)· `too_deep`(16.0.0:嵌套深过整棵目录的内容版本能算的深度 ——
|
|
16
16
|
* 此前它在算版本那一步抛,已经收集的拒一并丢掉);第六个 `retired_domain` 是墓碑(retired 域文档带事实);
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
* · 墓碑拒的 `document` 恒是 retired 域名(26.0.0 起不再另带 `migration`:改写存量的一次性迁移到期删了,那一格没有来源)。
|
|
20
20
|
* 词表是闭集:消费方用 `switch (refusal.reason)` 穷举,加词 ⇒ 它们编译红(这是通知)。
|
|
21
21
|
*/
|
|
22
|
-
import type {
|
|
22
|
+
import type { LocalReadDomain } from "./portable-domains.js";
|
|
23
23
|
import type { RetiredDomainName } from "./types.js";
|
|
24
24
|
/** 文件层拒一份文档的闭集词:五个文件层成因 + 墓碑(恒在末位)。墓碑那个词就是 `RetiredDomainError.code`(一个词,不立第二个名)。 */
|
|
25
25
|
export declare const CONFIG_DOCUMENT_REFUSAL_REASONS: readonly ["empty", "invalid_json", "not_object", "io", "too_deep", "retired_domain"];
|
|
26
26
|
export type ConfigDocumentRefusalReason = (typeof CONFIG_DOCUMENT_REFUSAL_REASONS)[number];
|
|
27
|
-
/** 能被拒的 `config.d`
|
|
28
|
-
export type ConfigDocumentName =
|
|
27
|
+
/** 能被拒的 `config.d` 文档:本地读取域({@link LocalReadDomain})的文档,或retired 域的文档(读它只为墓碑)。 */
|
|
28
|
+
export type ConfigDocumentName = LocalReadDomain | RetiredDomainName;
|
|
29
29
|
/** 被拒的一份文档(按 `reason` 判别):`{ document, reason, error }`;墓碑拒的文档名恒是 retired 域名。 */
|
|
30
30
|
export type ConfigDocumentRefusal = {
|
|
31
31
|
readonly document: ConfigDocumentName;
|
package/dist/config-fns.d.ts
CHANGED
|
@@ -447,7 +447,7 @@ export type EffectiveReadWarning = {
|
|
|
447
447
|
identity?: DroppedEntryIdentity;
|
|
448
448
|
reasonCode?: DroppedEntryReasonCode;
|
|
449
449
|
}
|
|
450
|
-
/** `config.d/`
|
|
450
|
+
/** `config.d/` 里存在、但本地读取集(`LOCAL_READ_DOMAINS`)**永远不会读**的文件:名字不是域(`not-a-domain`),或是域但不在本地读取集里(`non-portable-domain`:已发的闭集词,今天说的是 workers / hosts / systems / entitlement;`projects` 29.0.0 起在读取集里,被读)。 */
|
|
451
451
|
| {
|
|
452
452
|
kind: "unread-config-file";
|
|
453
453
|
file: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ```
|
|
5
5
|
* <根>/
|
|
6
|
-
* config.d/…
|
|
6
|
+
* config.d/… 域文档(本地读取域的文件;文件仓库只扫这一个目录)
|
|
7
7
|
* config.env-models.json env 模型表被目录顶替的部署决定 {"envModels":"replaced"|"kept"}
|
|
8
8
|
* config.migration.SS-M11.json 一次性迁移 SS-M11 的运行记录 {"migration":"SS-M11"}(按 id 一份)
|
|
9
9
|
* .env 秘密值(不归本包读)
|
package/dist/config-root-node.js
CHANGED
|
@@ -287,7 +287,8 @@ export async function migrateEnvModelsDecision(input) {
|
|
|
287
287
|
let createdRoot;
|
|
288
288
|
let created;
|
|
289
289
|
try {
|
|
290
|
-
|
|
290
|
+
// 一次操作一条路径串:建的目录是随后要写的那份文件的路径串的 dirname(原子写器的文件头「一次操作一条路径串」)—— 配置根下的文件一向是 `path.join(根, 文件名)`
|
|
291
|
+
createdRoot = (await io.ensureDirectory(path.dirname(file))) === "created";
|
|
291
292
|
created = await io.createDocument(migrationMarkerDocument("SS-M11"), file, configDDocumentText(migrationMarkerValue("SS-M11")));
|
|
292
293
|
}
|
|
293
294
|
catch (e) {
|
|
@@ -61,7 +61,7 @@ export interface ConformanceCase {
|
|
|
61
61
|
}
|
|
62
62
|
export interface Corpus {
|
|
63
63
|
version: string;
|
|
64
|
-
/** 空文档集的 effective(冻结的 golden
|
|
64
|
+
/** 空文档集的 effective(冻结的 golden;非本地读取域的那一格由它供给,见 derive.ts T3)。 */
|
|
65
65
|
baseline: Record<string, unknown>;
|
|
66
66
|
cases: readonly ConformanceCase[];
|
|
67
67
|
}
|
|
@@ -35,8 +35,8 @@ export declare const LEG_EXPECTATION: {
|
|
|
35
35
|
readonly why: "T3 / T4 / T5 / T6";
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
/**
|
|
39
|
-
export declare const
|
|
38
|
+
/** 非本地读取域(T3 的集合)—— 由 {@link LOCAL_READ_DOMAINS} 派生,零手抄:本地读腿(`loadLocalConfig`)不读它们的文件(报 `unread-config-file{non-portable-domain}`),域取 schema 默认。 */
|
|
39
|
+
export declare const NON_LOCAL_READ_DOMAINS: readonly DomainName[];
|
|
40
40
|
/** 一份 `domains` 文档集里,**不是域名**的那些顶层键(T4 的触发面)。 */
|
|
41
41
|
export declare const foreignKeysOf: (docs: Readonly<Record<string, unknown>>) => string[];
|
|
42
42
|
/** T2 的**入参**半场:域形的 skills 文档 → wire 形的 manifest 文档。结构变换,不解析 —— 坏形原样传下去,
|
|
@@ -64,14 +64,22 @@ export type LegExpectation = {
|
|
|
64
64
|
path: ReadonlyArray<string | number>;
|
|
65
65
|
}>;
|
|
66
66
|
};
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* T1 + T2 + T4:`domains` 期望 → `wire` 期望。
|
|
69
|
+
*
|
|
70
|
+
* **T2 只许是恒等**(这只护栏住在这里,语料跑器与直接调用同一只判、同一句):skills 是变换表里唯一一条**算出新值**的变换(content → contentHash),
|
|
71
|
+
* 而派生 wire 入参({@link deriveWireInput})用的是同一只 {@link toManifestDoc} —— 期望也由它算,哈希算错就两侧同错、门照绿;域形条目自带字面 `contentHash` 时,
|
|
72
|
+
* 那个值还被派生算出的覆盖掉,派生期望与线上读数对不上。所以 `source.effective.skills` 上 T2 不是恒等(有一条 T2 会改写的条目 —— 与入参半场同一只判据 `t2Rewrites`)⇒ 抛,
|
|
73
|
+
* 这条腿要写显式期望(金样入库即冻结,哈希一改就红);恒等 ⇒ skills 原样进期望。其余三条变换只搬 / 只删、不铸新值。
|
|
74
|
+
* **先取快照、再对快照判、再用同一份快照派生**:调用方的 `source.effective` 只读一次(克隆那一次),护栏判的与派生用的是同一份 —— 访问器第二次答别的值也进不来。
|
|
75
|
+
*/
|
|
68
76
|
export declare function deriveWireExpectation(source: Extract<LegExpectation, {
|
|
69
77
|
outcome: "effective";
|
|
70
78
|
}>, docs: Readonly<Record<string, unknown>>): LegExpectation;
|
|
71
|
-
/** 纪元时刻 —— 一个 `config.d/`
|
|
79
|
+
/** 纪元时刻 —— 一个 `config.d/` 里没有任何**本地读取**域文件时 `updatedAt` 的取值(`#maxMtimeIso` 只 stat 本地读取域)。 */
|
|
72
80
|
export declare const EPOCH_ISO: string;
|
|
73
81
|
/** T3 + T4 + T5:`domains` 期望 → `local-root` 期望。`baseline` = 空文档集的 effective(语料里冻结的
|
|
74
|
-
* `conformance/baseline.json`)
|
|
82
|
+
* `conformance/baseline.json`),非本地读取域取它的那一格 —— 不现算,免得 schema 默认一改 golden 就跟着动。 */
|
|
75
83
|
export declare function deriveLocalExpectation(source: Extract<LegExpectation, {
|
|
76
84
|
outcome: "effective";
|
|
77
85
|
}>, docs: Readonly<Record<string, unknown>>, baseline: Readonly<Record<string, unknown>>, localVersion: number | undefined): LegExpectation;
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* 挂回(线上读口不编造生产方没发的域)—— 缺席进缺席出;在场时 `prompts` 是**未解析的原文档**,`a2a` 是域腿的读数。表由常量派生,不手抄域名。
|
|
13
13
|
* · **T2 skills 表示**(wire):域形带 `content`,wire 形带 `contentHash`(manifest)。判据 schema 随表示走;读法不随(24.0.0 起清单与域文档同一只读法、
|
|
14
14
|
* 同两张表,剥键扫描与告警同读 —— 此前清单不走剥键扫描,派生要把 skills 的剥键告警从 wire 期望里滤掉)。
|
|
15
|
-
* · **T3
|
|
16
|
-
* `unread-config-file{why:"non-portable-domain"}
|
|
17
|
-
* 不手抄域名** —— 设计稿只点了 `hosts`
|
|
15
|
+
* · **T3 非本地读取域**(local-root):`config.d/` 只读 {@link LOCAL_READ_DOMAINS}(便携域集 + `projects`);其余域(workers / hosts / systems / entitlement)的文件在场则报
|
|
16
|
+
* `unread-config-file{why:"non-portable-domain"}`(词是已发的闭集词,不随这里改名),域本身取 schema 默认。**由 `LOCAL_READ_DOMAINS` 派生,
|
|
17
|
+
* 不手抄域名** —— 设计稿只点了 `hosts` 一个实例,类是「本地读取集之外的域」。29.0.0 以前这一格读的是便携域集(搬运义),`projects` 因此被算作「本地不读」;两个义拆开之后本格只问本地读取义。
|
|
18
18
|
* · **T4 未知顶层键**(wire + local-root):wire 是 open-world,不认识的顶层键**逐字承运**;`domains` 腿
|
|
19
19
|
* 只按域名取文档,多出来的键根本不会被问到(无声);local-root 报
|
|
20
20
|
* `unread-config-file{why:"not-a-domain"}`。三腿三样 —— 这条是本车对着真读数补登记的第四条。
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* 就等于让 domains 金样的一处错同时改写两条腿的期望 —— 两条腿同错、门照绿。它的金样逐条显式入库、各自冻结。
|
|
36
36
|
*/
|
|
37
37
|
import { NON_DOMAIN_CONFIG_FILES } from "../file-store.js";
|
|
38
|
-
import {
|
|
38
|
+
import { LOCAL_READ_DOMAINS } from "../portable-domains.js";
|
|
39
39
|
import { isJsonArray, isPlainJsonObject } from "../plain-json-object.js";
|
|
40
40
|
import { skillContentHash } from "../skills-manifest.js";
|
|
41
41
|
import { DOMAINS, WIRE_CARRIED_DOMAINS, isDomainName } from "../types.js";
|
|
@@ -44,7 +44,7 @@ import { deepFreeze } from "../deep-freeze.js";
|
|
|
44
44
|
export const DERIVATION_TRANSFORMS = deepFreeze([
|
|
45
45
|
{ id: "T1-wire-carried-domains", legs: ["wire"], what: "buildEffective 恒物化每个域;wire 对 WIRE_CARRIED_DOMAINS(prompts / a2a)按在场性挂回(缺席进缺席出;在场时 prompts 是原文档、a2a 是域腿读数)" },
|
|
46
46
|
{ id: "T2-skills-representation", legs: ["wire"], what: "域形 content ↔ wire 形 contentHash(manifest),判据 schema 随表示走;读法与告警同一只" },
|
|
47
|
-
{ id: "T3-non-
|
|
47
|
+
{ id: "T3-non-local-read-domains", legs: ["localRoot"], what: "config.d/ 只读 LOCAL_READ_DOMAINS;其余域取默认 + unread-config-file{non-portable-domain}" },
|
|
48
48
|
{ id: "T4-unknown-top-level-key", legs: ["wire", "localRoot"], what: "wire open-world 逐字承运;domains 腿按域名取文档故无声;local 报 unread-config-file{not-a-domain}" },
|
|
49
49
|
{ id: "T5-file-layer-first", legs: ["localRoot"], what: "config.d/<域>.json 必须是 JSON 对象(空/null/数组/标量 throw),这一层在域解析之前" },
|
|
50
50
|
{ id: "T6-file-name-classification", legs: ["localRoot"], what: "config.d/ 的文件分三类:域文件 / NON_DOMAIN_CONFIG_FILES(remote-exec.json 自带读取与校验路径)/ 隐藏文件与非 .json(忽略);只有剩下的才报 not-a-domain" },
|
|
@@ -66,10 +66,14 @@ export const LEG_EXPECTATION = deepFreeze({
|
|
|
66
66
|
wire: { source: "derivable", why: "T1 / T2 / T4" },
|
|
67
67
|
localRoot: { source: "derivable", why: "T3 / T4 / T5 / T6" },
|
|
68
68
|
});
|
|
69
|
-
/**
|
|
70
|
-
export const
|
|
69
|
+
/** 非本地读取域(T3 的集合)—— 由 {@link LOCAL_READ_DOMAINS} 派生,零手抄:本地读腿(`loadLocalConfig`)不读它们的文件(报 `unread-config-file{non-portable-domain}`),域取 schema 默认。 */
|
|
70
|
+
export const NON_LOCAL_READ_DOMAINS = deepFreeze(DOMAINS.filter((d) => !LOCAL_READ_DOMAINS.includes(d)));
|
|
71
71
|
/** 一份 `domains` 文档集里,**不是域名**的那些顶层键(T4 的触发面)。 */
|
|
72
72
|
export const foreignKeysOf = (docs) => Object.keys(docs).filter((k) => !isDomainName(k));
|
|
73
|
+
/** T2 改写这一条吗 —— **唯一的判据**:入参半场 {@link toManifestDoc} 按它改写,期望半场的护栏({@link deriveWireExpectation})按它拒;条目是朴素对象且 `content` 是串。 */
|
|
74
|
+
const t2Rewrites = (entry) => isPlainJsonObject(entry) && typeof entry.content === "string";
|
|
75
|
+
/** T2 在这份 skills 文档上会不会改动任何东西:是朴素对象、`skills` 是数组、有一条 {@link t2Rewrites}。只问条目 —— 与 T2 无关的值不读、不序列化。 */
|
|
76
|
+
const t2Moves = (doc) => isPlainJsonObject(doc) && isJsonArray(doc.skills) && doc.skills.some(t2Rewrites);
|
|
73
77
|
/** T2 的**入参**半场:域形的 skills 文档 → wire 形的 manifest 文档。结构变换,不解析 —— 坏形原样传下去,
|
|
74
78
|
* 让 wire 腿自己的判据去裁(否则语料就没法喂一份坏 manifest 了)。 */
|
|
75
79
|
export function toManifestDoc(doc) {
|
|
@@ -78,7 +82,7 @@ export function toManifestDoc(doc) {
|
|
|
78
82
|
return {
|
|
79
83
|
...doc,
|
|
80
84
|
skills: doc.skills.map((entry) => {
|
|
81
|
-
if (!
|
|
85
|
+
if (!t2Rewrites(entry))
|
|
82
86
|
return entry;
|
|
83
87
|
const { content, ...rest } = entry;
|
|
84
88
|
return { ...rest, contentHash: skillContentHash(content) };
|
|
@@ -105,18 +109,30 @@ export function deriveLocalInput(docs, mtime) {
|
|
|
105
109
|
return { leg: "localRoot", files, mtime };
|
|
106
110
|
}
|
|
107
111
|
const clone = (v) => structuredClone(v);
|
|
108
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* T1 + T2 + T4:`domains` 期望 → `wire` 期望。
|
|
114
|
+
*
|
|
115
|
+
* **T2 只许是恒等**(这只护栏住在这里,语料跑器与直接调用同一只判、同一句):skills 是变换表里唯一一条**算出新值**的变换(content → contentHash),
|
|
116
|
+
* 而派生 wire 入参({@link deriveWireInput})用的是同一只 {@link toManifestDoc} —— 期望也由它算,哈希算错就两侧同错、门照绿;域形条目自带字面 `contentHash` 时,
|
|
117
|
+
* 那个值还被派生算出的覆盖掉,派生期望与线上读数对不上。所以 `source.effective.skills` 上 T2 不是恒等(有一条 T2 会改写的条目 —— 与入参半场同一只判据 `t2Rewrites`)⇒ 抛,
|
|
118
|
+
* 这条腿要写显式期望(金样入库即冻结,哈希一改就红);恒等 ⇒ skills 原样进期望。其余三条变换只搬 / 只删、不铸新值。
|
|
119
|
+
* **先取快照、再对快照判、再用同一份快照派生**:调用方的 `source.effective` 只读一次(克隆那一次),护栏判的与派生用的是同一份 —— 访问器第二次答别的值也进不来。
|
|
120
|
+
*/
|
|
109
121
|
export function deriveWireExpectation(source, docs) {
|
|
110
122
|
const base = clone(source.effective);
|
|
123
|
+
if (t2Moves(base.skills)) {
|
|
124
|
+
throw new Error("deriveWireExpectation: 这份期望的 skills 表示变换(T2)会**算出新值**(contentHash)—— 派生入参用的是同一只变换,哈希算错会两侧同错(域形条目自带的字面 `contentHash` 还会被覆盖);" +
|
|
125
|
+
"这条 wire 腿要写显式期望并写明 why(跑 `npm run conformance:bless` 填金样)");
|
|
126
|
+
}
|
|
111
127
|
// T1:承运表里的域缺席进缺席出;在场 = 自有键且值不是 undefined(与读口同一条律,这里独立写一遍 —— 派生不调被测读口;嵌入方调导出的派生时
|
|
112
128
|
// 文档集里可以有 undefined,JSON 语料没有);在场时 prompts 是**未解析的原文档**(wire 腿从不 parse prompts),其余是域腿读数。
|
|
113
|
-
// T2
|
|
129
|
+
// T2:上面的护栏放行 ⇒ 恒等,skills 原样。
|
|
114
130
|
// T4:open-world 顶层键逐字承运 —— 用 fromEntries 而不是逐键赋值,否则一个叫 `__proto__` 的顶层键
|
|
115
131
|
// 会变成一次原型改写(期望侧与实际侧被同样吃掉 = 比对器对这一类全盲,S-332 同族)。
|
|
116
132
|
const carried = WIRE_CARRIED_DOMAINS;
|
|
117
133
|
const effective = Object.fromEntries([
|
|
118
134
|
...Object.entries(base).filter(([k]) => !carried.includes(k) && k !== "skills"),
|
|
119
|
-
["skills",
|
|
135
|
+
["skills", base.skills],
|
|
120
136
|
...WIRE_CARRIED_DOMAINS.filter((d) => Object.prototype.hasOwnProperty.call(docs, d) && docs[d] !== undefined).map((d) => [d, d === "prompts" ? clone(docs.prompts) : base[d]]),
|
|
121
137
|
...foreignKeysOf(docs).map((k) => [k, clone(docs[k])]),
|
|
122
138
|
]);
|
|
@@ -127,20 +143,20 @@ export function deriveWireExpectation(source, docs) {
|
|
|
127
143
|
});
|
|
128
144
|
return { outcome: "effective", effective, warnings, metadata: { ...source.metadata } };
|
|
129
145
|
}
|
|
130
|
-
/** 纪元时刻 —— 一个 `config.d/`
|
|
146
|
+
/** 纪元时刻 —— 一个 `config.d/` 里没有任何**本地读取**域文件时 `updatedAt` 的取值(`#maxMtimeIso` 只 stat 本地读取域)。 */
|
|
131
147
|
export const EPOCH_ISO = new Date(0).toISOString();
|
|
132
148
|
/** T3 + T4 + T5:`domains` 期望 → `local-root` 期望。`baseline` = 空文档集的 effective(语料里冻结的
|
|
133
|
-
* `conformance/baseline.json`)
|
|
149
|
+
* `conformance/baseline.json`),非本地读取域取它的那一格 —— 不现算,免得 schema 默认一改 golden 就跟着动。 */
|
|
134
150
|
export function deriveLocalExpectation(source, docs, baseline, localVersion) {
|
|
135
|
-
// T5:文件层先判 ——
|
|
136
|
-
const badFile =
|
|
151
|
+
// T5:文件层先判 —— 任何一个**本地读取**域的文档不是 JSON 对象 ⇒ 整条腿在解析层被拒。
|
|
152
|
+
const badFile = LOCAL_READ_DOMAINS.find((d) => Object.prototype.hasOwnProperty.call(docs, d) && !isPlainJsonObject(docs[d]));
|
|
137
153
|
if (badFile !== undefined)
|
|
138
154
|
return { outcome: "rejected", stage: "parse" };
|
|
139
155
|
const effective = clone(source.effective);
|
|
140
|
-
for (const d of
|
|
156
|
+
for (const d of NON_LOCAL_READ_DOMAINS)
|
|
141
157
|
effective[d] = clone(baseline[d]);
|
|
142
|
-
const warnings = source.warnings.filter((w) => !("domain" in w && w.domain !== undefined &&
|
|
143
|
-
for (const d of
|
|
158
|
+
const warnings = source.warnings.filter((w) => !("domain" in w && w.domain !== undefined && NON_LOCAL_READ_DOMAINS.includes(w.domain)));
|
|
159
|
+
for (const d of NON_LOCAL_READ_DOMAINS) {
|
|
144
160
|
if (Object.prototype.hasOwnProperty.call(docs, d))
|
|
145
161
|
warnings.push({ kind: "unread-config-file", file: `${d}.json`, domain: d, why: "non-portable-domain" });
|
|
146
162
|
}
|
|
@@ -151,11 +167,11 @@ export function deriveLocalExpectation(source, docs, baseline, localVersion) {
|
|
|
151
167
|
continue;
|
|
152
168
|
warnings.push({ kind: "unread-config-file", file, why: "not-a-domain" });
|
|
153
169
|
}
|
|
154
|
-
const
|
|
170
|
+
const anyLocalRead = LOCAL_READ_DOMAINS.some((d) => Object.prototype.hasOwnProperty.call(docs, d));
|
|
155
171
|
return {
|
|
156
172
|
outcome: "effective",
|
|
157
173
|
effective,
|
|
158
174
|
warnings,
|
|
159
|
-
metadata: { updatedAt:
|
|
175
|
+
metadata: { updatedAt: anyLocalRead ? source.metadata.updatedAt : EPOCH_ISO, ...(localVersion === undefined ? {} : { version: localVersion }) },
|
|
160
176
|
};
|
|
161
177
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
export { runConformance, materializeLocalRoot, resolveLegExpectation } from "./run.js";
|
|
18
18
|
export { createContractAdapter, type ContractAdapterOptions, type ContractModule } from "./contract-adapter.js";
|
|
19
19
|
export { loadCorpus, loadCase, kitIdentity, DEFAULT_CORPUS_DIR, PACKAGE_ROOT, type Corpus, type ConformanceCase, type CaseInput, type CaseMeta, type LegExpectationJson } from "./corpus.js";
|
|
20
|
-
export { DERIVATION_TRANSFORMS, LEG_EXPECTATION,
|
|
20
|
+
export { DERIVATION_TRANSFORMS, LEG_EXPECTATION, NON_LOCAL_READ_DOMAINS, EPOCH_ISO, deriveWireInput, deriveLocalInput, deriveWireExpectation, deriveLocalExpectation, foreignKeysOf, toManifestDoc, type DerivationTransform, type LegExpectation, } from "./derive.js";
|
|
21
21
|
export { canonicalize, deepEqual, diffJson, stableKey, type JsonPatchOp } from "./canonical.js";
|
|
22
22
|
export { WARNING_KINDS, projectWarning, normalizeProjection, projectionKey, projectionValue, diffWarningMultiset, findSecretLeaks, type WarningKind, type WarningProjection, } from "./warnings.js";
|
|
23
23
|
export { LEDGER_REF_RULE, LEG_DECLINE_REASONS, REF_INTEGRITY_REJECT_CODE, type RefIssueCoordinate, LEG_NAMES, REJECT_STAGES, type ConformanceAdapter, type ConformanceLeg, type DomainDocsInput, type LegDeclineReason, type LegDeclined, type LegStance, type ConformanceMode, type ConformanceNormalizer, type ConformanceOptions, type ConformanceProvenance, type ConformanceReport, type ConformanceResult, type ConformanceStatus, type KnownDivergence, type OutcomeDivergence, type PathDivergence, type LedgerRow, type LegEntry, type LegInput, type LegName, type LegOutcome, type RejectStage, } from "./types.js";
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
export { runConformance, materializeLocalRoot, resolveLegExpectation } from "./run.js";
|
|
18
18
|
export { createContractAdapter } from "./contract-adapter.js";
|
|
19
19
|
export { loadCorpus, loadCase, kitIdentity, DEFAULT_CORPUS_DIR, PACKAGE_ROOT } from "./corpus.js";
|
|
20
|
-
export { DERIVATION_TRANSFORMS, LEG_EXPECTATION,
|
|
20
|
+
export { DERIVATION_TRANSFORMS, LEG_EXPECTATION, NON_LOCAL_READ_DOMAINS, EPOCH_ISO, deriveWireInput, deriveLocalInput, deriveWireExpectation, deriveLocalExpectation, foreignKeysOf, toManifestDoc, } from "./derive.js";
|
|
21
21
|
export { canonicalize, deepEqual, diffJson, stableKey } from "./canonical.js";
|
|
22
22
|
export { WARNING_KINDS, projectWarning, normalizeProjection, projectionKey, projectionValue, diffWarningMultiset, findSecretLeaks, } from "./warnings.js";
|
|
23
23
|
export { LEDGER_REF_RULE, LEG_DECLINE_REASONS, REF_INTEGRITY_REJECT_CODE, LEG_NAMES, REJECT_STAGES, } from "./types.js";
|
package/dist/conformance/run.js
CHANGED
|
@@ -16,7 +16,7 @@ import { basename, extname, isAbsolute, join, resolve, sep } from "node:path";
|
|
|
16
16
|
import { isJsonArray, isPlainJsonObject, jsonShapeOf } from "../plain-json-object.js";
|
|
17
17
|
import { canonicalize, deepEqual, diffJson, stableKey } from "./canonical.js";
|
|
18
18
|
import { diffWarningMultiset, findSecretLeaks, projectWarning } from "./warnings.js";
|
|
19
|
-
import { deriveLocalExpectation, deriveLocalInput, deriveWireExpectation, deriveWireInput
|
|
19
|
+
import { deriveLocalExpectation, deriveLocalInput, deriveWireExpectation, deriveWireInput } from "./derive.js";
|
|
20
20
|
import { kitIdentity, loadCorpus } from "./corpus.js";
|
|
21
21
|
import { contractOwnedEntry, contractOwnedEntryWhy } from "./entry-origin.js";
|
|
22
22
|
import { mintLocalRoot, removeLocalRoot } from "./temp-roots.js";
|
|
@@ -109,15 +109,14 @@ export function resolveLegExpectation(c, leg, baseline) {
|
|
|
109
109
|
}
|
|
110
110
|
const from = { outcome: "effective", effective: source.effective, warnings: source.warnings, metadata: source.metadata };
|
|
111
111
|
if (leg === "wire") {
|
|
112
|
-
// **派生不许替被测 helper
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
// **派生不许替被测 helper 同时造输入与期望**:那只护栏(T2 不是恒等 ⇒ 拒)住在派生积木件自己身上 —— 跑器与直接调用同一只判、同一句;
|
|
113
|
+
// 这里只给它的拒句加上 case 坐标(语料作者要知道是哪一条)。
|
|
114
|
+
try {
|
|
115
|
+
return deriveWireExpectation(from, c.input.domains);
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
throw new Error(`conformance corpus: ${c.id}/expected.json#wire cannot be derived — ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
119
119
|
}
|
|
120
|
-
return deriveWireExpectation(from, c.input.domains);
|
|
121
120
|
}
|
|
122
121
|
if (leg === "localRoot")
|
|
123
122
|
return deriveLocalExpectation(from, c.input.domains, baseline, spec.localVersion);
|