@sema-agent/settings-schema 35.0.0 → 35.2.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +348 -0
  2. package/README.md +40 -12
  3. package/conformance/VERSION +1 -1
  4. package/conformance/profile/annotations.md +65 -0
  5. package/conformance/profile/loading-rules.md +193 -0
  6. package/conformance/profile/profiles/solo-auto.json +22 -0
  7. package/conformance/profile/profiles/solo-managed.json +21 -0
  8. package/conformance/profile/profiles/tenant-auto.json +36 -0
  9. package/conformance/profile/profiles/tenant-managed.json +36 -0
  10. package/conformance/profile/sema-profile.schema.json +201 -0
  11. package/conformance/profile/tools/mutations.md +62 -0
  12. package/conformance/profile/tools/validate.mjs +1190 -0
  13. package/conformance/profile/vectors/frozen-promises.json +120 -0
  14. package/conformance/profile/vectors/vectors.json +362 -0
  15. package/dist/api/connector-assertions.d.ts +186 -0
  16. package/dist/api/connector-assertions.js +148 -0
  17. package/dist/api/credentials.d.ts +30 -50
  18. package/dist/api/credentials.js +14 -14
  19. package/dist/api/refusal-table.d.ts +16 -0
  20. package/dist/api/refusal-table.js +24 -0
  21. package/dist/conformance/index.d.ts +1 -0
  22. package/dist/conformance/index.js +1 -0
  23. package/dist/conformance/profile.d.ts +55 -0
  24. package/dist/conformance/profile.js +108 -0
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +3 -0
  27. package/dist/mutable-copy.d.ts +48 -0
  28. package/dist/mutable-copy.js +229 -0
  29. package/dist/settings-units.d.ts +8 -0
  30. package/dist/settings-units.js +6 -4
  31. package/dist/tighten-only-seat-limits.d.ts +16 -0
  32. package/dist/tighten-only-seat-limits.js +16 -0
  33. package/docs/API-SURFACE.md +32 -3
  34. package/docs/CONFORMANCE.md +17 -0
  35. package/docs/CONSUMER-INTEGRATION.md +180 -12
  36. package/llms-full.txt +27 -9
  37. package/llms.txt +6 -2
  38. package/package.json +1 -1
@@ -0,0 +1,186 @@
1
+ /**
2
+ * `api/connector-assertions` —— 连接器断言铸口(`POST /api/v1/connectors/assertions`)的 wire 型:管理台铸,本服务的对端座问。
3
+ * 一份 zod,发这些形的一方与收这些形的一方同 import。纯、零 I/O、浏览器安全。
4
+ *
5
+ * 一步答出:座带着「要发给哪台 MCP 服务器、发到哪个地址、替谁发」来问({@link ConnectorAssertionRequest}),管理台要么交回一枚断言与它的到期时刻
6
+ * ({@link ConnectorAssertionAnswer}),要么整次拒答({@link ConnectorAssertionRefusal})—— 没有句柄、没有第二步。
7
+ * 本模块只有**形、词表与一只比较函数**:调用方鉴权(`wat_`)、委托、活表复核、登记册查条目、判定序、断言的签发与缓存都是各方自己的事,不在这里。
8
+ * `assertion` 是应答里唯一的秘密位。
9
+ *
10
+ * ## 请求是严格对象,应答与拒体剥未知键
11
+ * · 请求({@link ConnectorAssertionRequest}):多一个键 ⇒ 不是这一形 ⇒ 答方回 `request_invalid`。凭据铸口上,调用方多给的键看起来像约束
12
+ * (作用域、连接器 id、有效期上限一类);剥掉 = 调用方以为表达了的约束被静默丢掉、断言照铸。所以请求的键集首发即定:以后要加键是主版本,两侧同窗提货。
13
+ * · 应答与拒体:多一个键剥掉(与包里的句柄应答、两只既有拒体同律)。发应答的是管理台、收应答的是本服务的座:管理台在应答里多带一个键,旧的收方照读、不整次失败;
14
+ * 拒体里别的臂带来的 `authorizeUrl` 被剥,收方拿到的值里只在 `authorization_required` 那一臂有地址。
15
+ *
16
+ * ## 拒答表
17
+ * {@link CONNECTOR_ASSERTION_REFUSALS} = 凭据平面共享拒答表的九词(原样原序,复用同一行对象)+ 铸口自有五词(管理台判定序的出场序),派生机关与沙箱 git 那一张是同一份
18
+ * (包内私有叶 `./refusal-table`)。自有五词只在铸口上有意义,所以不进共享表。一个词的 `permanence` 是固定的,拒体里再带一份只为收方不必查表 —— 两处不一致即畸形应答。
19
+ * 状态码是 HTTP 层的:拒体的校验只核 `permanence`,不核状态;词与状态码对不对得上是收方的事。
20
+ * `permanence` 的词集就是 `SANDBOX_GIT_PERMANENCE`(名字里带「沙箱 git」是既有的命名,词集是凭据平面共用的)。
21
+ *
22
+ * ## `terminal` 在铸口上怎么重问
23
+ * `terminal` = 这一次请求不按退避节奏重试;再问要等一件可能改变答案的事。四种情形:
24
+ * · 首次连接(引擎座问题的 `cause` 是连接):terminal ⇒ 这次座拒、不退避重铸;transient(只有 `vault_unavailable`)⇒ 可在座的等待窗内退避重铸;
25
+ * · 后续发送(`cause` 是请求):每次发送是一次新的问,不算定时重试;收方可以记住上一次的 terminal 词,免得每次发送都打中心;
26
+ * · 用户动作之后(重新登录续上委托、去 `authorizeUrl` 授权):立刻重问一次;首拨已失败的,随显式重拨或下一条腿;
27
+ * · 运维修复之后(`plane_misconfigured`、`vault_disabled` / `vault_frozen`、`connector_not_registered`、`connector_target_mismatch` 的出路是改条目或登记册并重启本服务):
28
+ * 重启后的首拨自然是新的一问;收方也可以为这些词设一个低频复查。
29
+ * 哪只词归哪一种情形、复查多久,是收方座的处置表;本模块不加列、不改值。
30
+ *
31
+ * ## 比较函数 {@link compareDialTargets}:只为「准不准铸」
32
+ * 律:两个地址算同一个发送目标,当且仅当两边都过 `NON_SECRET_URL`,且各自按 WHATWG URL 解析后的序列化串(`href`)逐字节相等。
33
+ * 任一边读不出 ⇒ `unreadable`,永不 `same`。先各自判,最后才比;没有「两边字节相同 / 同一只对象」的快径。步骤:
34
+ * 1. 输入不是原始字符串(`typeof` 不是 `string`)⇒ 读不出(不做 `String(raw)`;`new String(...)` 包装对象也是读不出);
35
+ * 2. 过不了 `NON_SECRET_URL` ⇒ 读不出(不另写 URL 形规则);
36
+ * 3. 规范串 = `new URL(raw).href`;
37
+ * 4. 两边各自走完 1–3;任一读不出 ⇒ `unreadable`;两串相等 ⇒ `same`;否则 `different`。
38
+ * 用途只有一个:管理台判定序里「请求的 `url` 与登记册那一行的端点相等」—— `same` 才铸,`different` ⇒ `connector_target_mismatch`,`unreadable` ⇒ 不铸。
39
+ * 在这个方向上多答 `different` 是多拒,失败关闭。**它不是登记册端点去重的判官**:去重方向上安全反过来(`%7E` 与 `~` 答 `different`,去重就放过了可能指向同一处理器的别名),
40
+ * 去重要哪种等价是另一件事。单只地址的规范串不出本模块。与 `DIAL_ADDRESS_URL_FORBIDDEN_PARTS`(`../url-shape`,「逐字发给拨号方的地址」那一座位禁哪些部件)名近义远:
41
+ * 那只是一个座位的部件表,这只是两个地址的比较。
42
+ * WHATWG 解析会做的改写:scheme 与主机名转小写;去默认端口;国际化域名转 punycode;IPv4 别写形规整、IPv6 压缩;解析 `.` / `..` 段(含百分号写的 `%2e`);
43
+ * 空路径补 `/`;路径里的非 ASCII 字符按 UTF-8 百分号编码;去首尾 C0 控制符与空格、去内嵌的制表与换行;空 userinfo 的 `@` 消失;特殊 scheme 缺 `//` 的写法补成层级式。
44
+ * 不做:不去路径尾斜杠(空路径补 `/` 除外)、不折路径大小写、不解码已有的百分号三元组(也不改它的十六进制大小写)、不排查询参数、不去空查询的 `?`、不去主机名末尾的点。
45
+ *
46
+ * ## 不给的保证
47
+ * 1. 同一序列化串 ≠ 同一实际对端:比较只看字符串;各自网络命名空间里的同一本机地址、分区 DNS、域名改指,都能让同一串落到不同进程。这是登记信任与部署网络的残余风险;
48
+ * 引擎发送链上自己的检查(不跟随重定向一类)不由本函数代替,也不靠本函数。
49
+ * 2. 跨运行时的 URL / 国际化域名归一差异没有证明只会偏向 `different`:比较跑在管理台的运行时,拨号跑在引擎的运行时,一边相等推不出另一边相等。
50
+ * 3. 判官按解析结果认,不按原串字面认:空 userinfo 的 `@`、特殊 scheme 缺 `//`、首尾空白、内嵌制表 / 换行都能过 `NON_SECRET_URL`,并与规范写法比成 `same`。
51
+ * 本模块不收紧 `NON_SECRET_URL`:它是多座位共用的判官,请求的 `url` 就是 MCP 条目的 `url`,请求侧另立更严的判法 = 同一串两答。
52
+ * 4. 挡不住会说谎的服务层,也看不到断言缓存命中的发送。
53
+ * 5. 只说「是不是同一个拨号目标」,不说「这个目标许不许拨」(https 律、本机 http 例外是登记册一方的规则)。
54
+ * 6. 不是去重判官(见上)。
55
+ */
56
+ import { z } from "zod";
57
+ /**
58
+ * 铸断言的请求体(严格对象,恰四键,全必填;多一键 ⇒ 不是这一形,见模块头注):
59
+ * · `server` —— MCP 服务器名,与引擎座问题里的同名成员同义;形就是 `McpServerSpec` 的 `name` 那一只判官(同一对象,不另立名字规则);答方按原串逐字节查条目,不折大小写(正则的 `i` 旗只管字符集);
60
+ * · `url` —— 引擎实际要发往的地址(就是 MCP 条目的 `url` 原串);形 = `NON_SECRET_URL`;
61
+ * · `principal` / `principalInc` —— 替谁铸:主体名(就是凭据平面那一只主体名叶子 `PrincipalString`)与化身号,与凭据取值口的请求同义同形(同一对象)。
62
+ */
63
+ export declare const ConnectorAssertionRequest: z.ZodObject<{
64
+ server: z.ZodString;
65
+ url: z.ZodString;
66
+ principal: z.ZodString;
67
+ principalInc: z.ZodString;
68
+ }, z.core.$strict>;
69
+ export type ConnectorAssertionRequest = z.infer<typeof ConnectorAssertionRequest>;
70
+ /** 铸成的应答:断言(不透明串,应答里唯一的秘密位)与它的到期时刻(epoch 毫秒,中心的钟 —— 收方拿自己的钟比时自担钟差)。多一键剥掉。 */
71
+ export declare const ConnectorAssertionAnswer: z.ZodObject<{
72
+ assertion: z.ZodString;
73
+ expiresAt: z.ZodNumber;
74
+ }, z.core.$strip>;
75
+ export type ConnectorAssertionAnswer = z.infer<typeof ConnectorAssertionAnswer>;
76
+ /**
77
+ * 铸口整次拒答词 → 它的 HTTP 状态集(答方答这个词时用其一)与 `permanence`。共享九词的行就是共享表那一行(同一对象),自有五词见上。
78
+ * 收方怎么处置某个词(哪种情形、复查多久)是收方的处置表,不在这里(见模块头注「`terminal` 在铸口上怎么重问」)。
79
+ */
80
+ export declare const CONNECTOR_ASSERTION_REFUSALS: {
81
+ readonly caller_not_admitted: {
82
+ readonly statuses: readonly [401, 403];
83
+ readonly permanence: "terminal";
84
+ };
85
+ readonly incarnation_mismatch: {
86
+ readonly statuses: readonly [403];
87
+ readonly permanence: "terminal";
88
+ };
89
+ readonly request_invalid: {
90
+ readonly statuses: readonly [400];
91
+ readonly permanence: "terminal";
92
+ };
93
+ readonly principal_not_live: {
94
+ readonly statuses: readonly [403];
95
+ readonly permanence: "terminal";
96
+ };
97
+ readonly delegation_required: {
98
+ readonly statuses: readonly [403];
99
+ readonly permanence: "terminal";
100
+ };
101
+ readonly vault_disabled: {
102
+ readonly statuses: readonly [503];
103
+ readonly permanence: "terminal";
104
+ };
105
+ readonly vault_frozen: {
106
+ readonly statuses: readonly [503];
107
+ readonly permanence: "terminal";
108
+ };
109
+ readonly vault_unavailable: {
110
+ readonly statuses: readonly [503];
111
+ readonly permanence: "transient";
112
+ };
113
+ readonly plane_misconfigured: {
114
+ readonly statuses: readonly [503];
115
+ readonly permanence: "terminal";
116
+ };
117
+ readonly runner_credential_unavailable: {
118
+ readonly statuses: readonly [403];
119
+ readonly permanence: "terminal";
120
+ };
121
+ readonly connector_not_entitled: {
122
+ readonly statuses: readonly [403];
123
+ readonly permanence: "terminal";
124
+ };
125
+ readonly connector_not_registered: {
126
+ readonly statuses: readonly [403];
127
+ readonly permanence: "terminal";
128
+ };
129
+ readonly connector_target_mismatch: {
130
+ readonly statuses: readonly [403];
131
+ readonly permanence: "terminal";
132
+ };
133
+ readonly authorization_required: {
134
+ readonly statuses: readonly [403];
135
+ readonly permanence: "terminal";
136
+ };
137
+ };
138
+ /** 铸口整次拒答词(闭集,十四个)—— 类型由 {@link CONNECTOR_ASSERTION_REFUSALS} 派生。 */
139
+ export type ConnectorAssertionRefusalError = keyof typeof CONNECTOR_ASSERTION_REFUSALS;
140
+ /** 铸口整次拒答词表(运行期;表的键,按表序)。 */
141
+ export declare const CONNECTOR_ASSERTION_REFUSAL_ERRORS: readonly [ConnectorAssertionRefusalError, ...ConnectorAssertionRefusalError[]];
142
+ /**
143
+ * 整次拒答的体,按 `error` 判别:
144
+ * · 十三词:`{ error, permanence, message }`;
145
+ * · `authorization_required`:另可带 `authorizeUrl`(非空串)—— 用户去哪里授权。它能不能交给用户不在这里判,由收方问 `connectorAuthorizeUrlFlaws`(`../connector-authorize-url`)。
146
+ * `permanence` 是错误词的函数,必须等于 {@link CONNECTOR_ASSERTION_REFUSALS} 里这一行的;`message` 是答方的诊断句(收方不据它判,可为空串)。
147
+ * 体里不带状态码。未知键剥掉(别的臂带来的 `authorizeUrl` 也剥)。
148
+ */
149
+ export declare const ConnectorAssertionRefusal: z.ZodDiscriminatedUnion<[z.ZodObject<{
150
+ permanence: z.ZodEnum<{
151
+ terminal: "terminal";
152
+ transient: "transient";
153
+ }>;
154
+ message: z.ZodString;
155
+ error: z.ZodEnum<{
156
+ caller_not_admitted: "caller_not_admitted";
157
+ incarnation_mismatch: "incarnation_mismatch";
158
+ request_invalid: "request_invalid";
159
+ principal_not_live: "principal_not_live";
160
+ delegation_required: "delegation_required";
161
+ vault_disabled: "vault_disabled";
162
+ vault_frozen: "vault_frozen";
163
+ vault_unavailable: "vault_unavailable";
164
+ plane_misconfigured: "plane_misconfigured";
165
+ runner_credential_unavailable: "runner_credential_unavailable";
166
+ connector_not_entitled: "connector_not_entitled";
167
+ connector_not_registered: "connector_not_registered";
168
+ connector_target_mismatch: "connector_target_mismatch";
169
+ }>;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ authorizeUrl: z.ZodOptional<z.ZodString>;
172
+ permanence: z.ZodEnum<{
173
+ terminal: "terminal";
174
+ transient: "transient";
175
+ }>;
176
+ message: z.ZodString;
177
+ error: z.ZodLiteral<"authorization_required">;
178
+ }, z.core.$strip>], "error">;
179
+ export type ConnectorAssertionRefusal = z.infer<typeof ConnectorAssertionRefusal>;
180
+ /** 比较的三态答案(闭集):同一个发送目标 / 不是 / 至少一边读不出。三态不能并成一个布尔:读不出永不等于「不同」。 */
181
+ export declare const DIAL_TARGET_COMPARISONS: readonly ["same", "different", "unreadable"];
182
+ export type DialTargetComparison = (typeof DIAL_TARGET_COMPARISONS)[number];
183
+ /**
184
+ * 两个地址是不是同一个发送目标 —— 只为铸口判定「准不准铸」;不是登记册去重的判官。总、不抛。律、步骤与不给的保证见模块头注。
185
+ */
186
+ export declare function compareDialTargets(a: unknown, b: unknown): DialTargetComparison;
@@ -0,0 +1,148 @@
1
+ /**
2
+ * `api/connector-assertions` —— 连接器断言铸口(`POST /api/v1/connectors/assertions`)的 wire 型:管理台铸,本服务的对端座问。
3
+ * 一份 zod,发这些形的一方与收这些形的一方同 import。纯、零 I/O、浏览器安全。
4
+ *
5
+ * 一步答出:座带着「要发给哪台 MCP 服务器、发到哪个地址、替谁发」来问({@link ConnectorAssertionRequest}),管理台要么交回一枚断言与它的到期时刻
6
+ * ({@link ConnectorAssertionAnswer}),要么整次拒答({@link ConnectorAssertionRefusal})—— 没有句柄、没有第二步。
7
+ * 本模块只有**形、词表与一只比较函数**:调用方鉴权(`wat_`)、委托、活表复核、登记册查条目、判定序、断言的签发与缓存都是各方自己的事,不在这里。
8
+ * `assertion` 是应答里唯一的秘密位。
9
+ *
10
+ * ## 请求是严格对象,应答与拒体剥未知键
11
+ * · 请求({@link ConnectorAssertionRequest}):多一个键 ⇒ 不是这一形 ⇒ 答方回 `request_invalid`。凭据铸口上,调用方多给的键看起来像约束
12
+ * (作用域、连接器 id、有效期上限一类);剥掉 = 调用方以为表达了的约束被静默丢掉、断言照铸。所以请求的键集首发即定:以后要加键是主版本,两侧同窗提货。
13
+ * · 应答与拒体:多一个键剥掉(与包里的句柄应答、两只既有拒体同律)。发应答的是管理台、收应答的是本服务的座:管理台在应答里多带一个键,旧的收方照读、不整次失败;
14
+ * 拒体里别的臂带来的 `authorizeUrl` 被剥,收方拿到的值里只在 `authorization_required` 那一臂有地址。
15
+ *
16
+ * ## 拒答表
17
+ * {@link CONNECTOR_ASSERTION_REFUSALS} = 凭据平面共享拒答表的九词(原样原序,复用同一行对象)+ 铸口自有五词(管理台判定序的出场序),派生机关与沙箱 git 那一张是同一份
18
+ * (包内私有叶 `./refusal-table`)。自有五词只在铸口上有意义,所以不进共享表。一个词的 `permanence` 是固定的,拒体里再带一份只为收方不必查表 —— 两处不一致即畸形应答。
19
+ * 状态码是 HTTP 层的:拒体的校验只核 `permanence`,不核状态;词与状态码对不对得上是收方的事。
20
+ * `permanence` 的词集就是 `SANDBOX_GIT_PERMANENCE`(名字里带「沙箱 git」是既有的命名,词集是凭据平面共用的)。
21
+ *
22
+ * ## `terminal` 在铸口上怎么重问
23
+ * `terminal` = 这一次请求不按退避节奏重试;再问要等一件可能改变答案的事。四种情形:
24
+ * · 首次连接(引擎座问题的 `cause` 是连接):terminal ⇒ 这次座拒、不退避重铸;transient(只有 `vault_unavailable`)⇒ 可在座的等待窗内退避重铸;
25
+ * · 后续发送(`cause` 是请求):每次发送是一次新的问,不算定时重试;收方可以记住上一次的 terminal 词,免得每次发送都打中心;
26
+ * · 用户动作之后(重新登录续上委托、去 `authorizeUrl` 授权):立刻重问一次;首拨已失败的,随显式重拨或下一条腿;
27
+ * · 运维修复之后(`plane_misconfigured`、`vault_disabled` / `vault_frozen`、`connector_not_registered`、`connector_target_mismatch` 的出路是改条目或登记册并重启本服务):
28
+ * 重启后的首拨自然是新的一问;收方也可以为这些词设一个低频复查。
29
+ * 哪只词归哪一种情形、复查多久,是收方座的处置表;本模块不加列、不改值。
30
+ *
31
+ * ## 比较函数 {@link compareDialTargets}:只为「准不准铸」
32
+ * 律:两个地址算同一个发送目标,当且仅当两边都过 `NON_SECRET_URL`,且各自按 WHATWG URL 解析后的序列化串(`href`)逐字节相等。
33
+ * 任一边读不出 ⇒ `unreadable`,永不 `same`。先各自判,最后才比;没有「两边字节相同 / 同一只对象」的快径。步骤:
34
+ * 1. 输入不是原始字符串(`typeof` 不是 `string`)⇒ 读不出(不做 `String(raw)`;`new String(...)` 包装对象也是读不出);
35
+ * 2. 过不了 `NON_SECRET_URL` ⇒ 读不出(不另写 URL 形规则);
36
+ * 3. 规范串 = `new URL(raw).href`;
37
+ * 4. 两边各自走完 1–3;任一读不出 ⇒ `unreadable`;两串相等 ⇒ `same`;否则 `different`。
38
+ * 用途只有一个:管理台判定序里「请求的 `url` 与登记册那一行的端点相等」—— `same` 才铸,`different` ⇒ `connector_target_mismatch`,`unreadable` ⇒ 不铸。
39
+ * 在这个方向上多答 `different` 是多拒,失败关闭。**它不是登记册端点去重的判官**:去重方向上安全反过来(`%7E` 与 `~` 答 `different`,去重就放过了可能指向同一处理器的别名),
40
+ * 去重要哪种等价是另一件事。单只地址的规范串不出本模块。与 `DIAL_ADDRESS_URL_FORBIDDEN_PARTS`(`../url-shape`,「逐字发给拨号方的地址」那一座位禁哪些部件)名近义远:
41
+ * 那只是一个座位的部件表,这只是两个地址的比较。
42
+ * WHATWG 解析会做的改写:scheme 与主机名转小写;去默认端口;国际化域名转 punycode;IPv4 别写形规整、IPv6 压缩;解析 `.` / `..` 段(含百分号写的 `%2e`);
43
+ * 空路径补 `/`;路径里的非 ASCII 字符按 UTF-8 百分号编码;去首尾 C0 控制符与空格、去内嵌的制表与换行;空 userinfo 的 `@` 消失;特殊 scheme 缺 `//` 的写法补成层级式。
44
+ * 不做:不去路径尾斜杠(空路径补 `/` 除外)、不折路径大小写、不解码已有的百分号三元组(也不改它的十六进制大小写)、不排查询参数、不去空查询的 `?`、不去主机名末尾的点。
45
+ *
46
+ * ## 不给的保证
47
+ * 1. 同一序列化串 ≠ 同一实际对端:比较只看字符串;各自网络命名空间里的同一本机地址、分区 DNS、域名改指,都能让同一串落到不同进程。这是登记信任与部署网络的残余风险;
48
+ * 引擎发送链上自己的检查(不跟随重定向一类)不由本函数代替,也不靠本函数。
49
+ * 2. 跨运行时的 URL / 国际化域名归一差异没有证明只会偏向 `different`:比较跑在管理台的运行时,拨号跑在引擎的运行时,一边相等推不出另一边相等。
50
+ * 3. 判官按解析结果认,不按原串字面认:空 userinfo 的 `@`、特殊 scheme 缺 `//`、首尾空白、内嵌制表 / 换行都能过 `NON_SECRET_URL`,并与规范写法比成 `same`。
51
+ * 本模块不收紧 `NON_SECRET_URL`:它是多座位共用的判官,请求的 `url` 就是 MCP 条目的 `url`,请求侧另立更严的判法 = 同一串两答。
52
+ * 4. 挡不住会说谎的服务层,也看不到断言缓存命中的发送。
53
+ * 5. 只说「是不是同一个拨号目标」,不说「这个目标许不许拨」(https 律、本机 http 例外是登记册一方的规则)。
54
+ * 6. 不是去重判官(见上)。
55
+ */
56
+ import { z } from "zod";
57
+ import { buildQuotedIssue } from "../quoted-issue.js";
58
+ import { deepFreeze } from "../deep-freeze.js";
59
+ import { McpServerSpec, NON_SECRET_URL } from "../types.js";
60
+ import { PrincipalIncarnation } from "./auth-bridge.js";
61
+ import { CREDENTIAL_PLANE_REFUSALS, CREDENTIAL_PLANE_REFUSAL_ERRORS, SANDBOX_GIT_PERMANENCE, } from "./credentials.js";
62
+ import { buildRefusalTable } from "./refusal-table.js";
63
+ import { NonEmptyString, PrincipalString, SafeCount } from "./wire-scalars.js";
64
+ // ── 请求与应答 ─────────────────────────────────────────────────────────────────────────────────────────────────────
65
+ /**
66
+ * 铸断言的请求体(严格对象,恰四键,全必填;多一键 ⇒ 不是这一形,见模块头注):
67
+ * · `server` —— MCP 服务器名,与引擎座问题里的同名成员同义;形就是 `McpServerSpec` 的 `name` 那一只判官(同一对象,不另立名字规则);答方按原串逐字节查条目,不折大小写(正则的 `i` 旗只管字符集);
68
+ * · `url` —— 引擎实际要发往的地址(就是 MCP 条目的 `url` 原串);形 = `NON_SECRET_URL`;
69
+ * · `principal` / `principalInc` —— 替谁铸:主体名(就是凭据平面那一只主体名叶子 `PrincipalString`)与化身号,与凭据取值口的请求同义同形(同一对象)。
70
+ */
71
+ export const ConnectorAssertionRequest = z.object({
72
+ server: McpServerSpec.shape.name,
73
+ url: NON_SECRET_URL,
74
+ principal: PrincipalString,
75
+ principalInc: PrincipalIncarnation,
76
+ }).strict();
77
+ /** 铸成的应答:断言(不透明串,应答里唯一的秘密位)与它的到期时刻(epoch 毫秒,中心的钟 —— 收方拿自己的钟比时自担钟差)。多一键剥掉。 */
78
+ export const ConnectorAssertionAnswer = z.object({ assertion: NonEmptyString, expiresAt: SafeCount });
79
+ // ── 整次拒答 ───────────────────────────────────────────────────────────────────────────────────────────────────────
80
+ /** 永久性词表的 `terminal`(词只在 `./credentials` 里拼一次,这里取表的首项)。 */
81
+ const TERMINAL = SANDBOX_GIT_PERMANENCE[0];
82
+ /** 铸口自有五词(都是 403 · terminal),出场序 = 管理台判定序。 */
83
+ const CONNECTOR_ASSERTION_OWN_REFUSALS = deepFreeze({
84
+ runner_credential_unavailable: { statuses: [403], permanence: TERMINAL },
85
+ connector_not_entitled: { statuses: [403], permanence: TERMINAL },
86
+ connector_not_registered: { statuses: [403], permanence: TERMINAL },
87
+ connector_target_mismatch: { statuses: [403], permanence: TERMINAL },
88
+ authorization_required: { statuses: [403], permanence: TERMINAL },
89
+ });
90
+ /**
91
+ * 次序:共享九词按共享表的表序在前,自有五词按上面自有表的序在后 —— 次序一发出就是契约(重排 = 主版本)。
92
+ * 共享九词从共享表的词表读,不在这里再拼一遍(词的单一属主是 `./credentials`)。
93
+ */
94
+ const CONNECTOR_ASSERTION_REFUSAL_ORDER = [
95
+ ...CREDENTIAL_PLANE_REFUSAL_ERRORS,
96
+ ...Object.keys(CONNECTOR_ASSERTION_OWN_REFUSALS),
97
+ ];
98
+ /**
99
+ * 铸口整次拒答词 → 它的 HTTP 状态集(答方答这个词时用其一)与 `permanence`。共享九词的行就是共享表那一行(同一对象),自有五词见上。
100
+ * 收方怎么处置某个词(哪种情形、复查多久)是收方的处置表,不在这里(见模块头注「`terminal` 在铸口上怎么重问」)。
101
+ */
102
+ export const CONNECTOR_ASSERTION_REFUSALS = buildRefusalTable("CONNECTOR_ASSERTION_REFUSAL_ORDER", CREDENTIAL_PLANE_REFUSALS, CONNECTOR_ASSERTION_OWN_REFUSALS, CONNECTOR_ASSERTION_REFUSAL_ORDER);
103
+ /** 铸口整次拒答词表(运行期;表的键,按表序)。 */
104
+ export const CONNECTOR_ASSERTION_REFUSAL_ERRORS = deepFreeze(Object.keys(CONNECTOR_ASSERTION_REFUSALS));
105
+ /** 只有这一臂带授权地址。 */
106
+ const AUTHORIZATION_REQUIRED = "authorization_required";
107
+ /** 除授权那一臂之外的十三词,按表序。 */
108
+ const PLAIN_REFUSAL_ERRORS = CONNECTOR_ASSERTION_REFUSAL_ERRORS.filter((word) => word !== AUTHORIZATION_REQUIRED);
109
+ /** 拒体的共有成员:永久性(必须等于表里这一词的,见下面的 `refine`)与诊断句。 */
110
+ const RefusalCommon = {
111
+ permanence: z.enum(SANDBOX_GIT_PERMANENCE),
112
+ message: z.string(),
113
+ };
114
+ /**
115
+ * 整次拒答的体,按 `error` 判别:
116
+ * · 十三词:`{ error, permanence, message }`;
117
+ * · `authorization_required`:另可带 `authorizeUrl`(非空串)—— 用户去哪里授权。它能不能交给用户不在这里判,由收方问 `connectorAuthorizeUrlFlaws`(`../connector-authorize-url`)。
118
+ * `permanence` 是错误词的函数,必须等于 {@link CONNECTOR_ASSERTION_REFUSALS} 里这一行的;`message` 是答方的诊断句(收方不据它判,可为空串)。
119
+ * 体里不带状态码。未知键剥掉(别的臂带来的 `authorizeUrl` 也剥)。
120
+ */
121
+ export const ConnectorAssertionRefusal = z
122
+ .discriminatedUnion("error", [
123
+ z.object({ error: z.enum(PLAIN_REFUSAL_ERRORS), ...RefusalCommon }),
124
+ z.object({ error: z.literal(AUTHORIZATION_REQUIRED), ...RefusalCommon, authorizeUrl: NonEmptyString.optional() }),
125
+ ])
126
+ .refine((body) => CONNECTOR_ASSERTION_REFUSALS[body.error].permanence === body.permanence, buildQuotedIssue `permanence must be the one the refusal table gives for this error`);
127
+ // ── 发送目标比较 ───────────────────────────────────────────────────────────────────────────────────────────────────
128
+ /** 比较的三态答案(闭集):同一个发送目标 / 不是 / 至少一边读不出。三态不能并成一个布尔:读不出永不等于「不同」。 */
129
+ export const DIAL_TARGET_COMPARISONS = deepFreeze(["same", "different", "unreadable"]);
130
+ const [SAME, DIFFERENT, UNREADABLE] = DIAL_TARGET_COMPARISONS;
131
+ /** 单只地址的规范串(模块内私有,不导出:比较律只要「两边各判、最后比串」,规范串交出去就等于给了去重一只现成的判官)。读不出 ⇒ `undefined`。 */
132
+ function dialTargetOf(raw) {
133
+ if (typeof raw !== "string")
134
+ return undefined;
135
+ if (!NON_SECRET_URL.safeParse(raw).success)
136
+ return undefined;
137
+ return new URL(raw).href;
138
+ }
139
+ /**
140
+ * 两个地址是不是同一个发送目标 —— 只为铸口判定「准不准铸」;不是登记册去重的判官。总、不抛。律、步骤与不给的保证见模块头注。
141
+ */
142
+ export function compareDialTargets(a, b) {
143
+ const left = dialTargetOf(a);
144
+ const right = dialTargetOf(b);
145
+ if (left === undefined || right === undefined)
146
+ return UNREADABLE;
147
+ return left === right ? SAME : DIFFERENT;
148
+ }
@@ -15,7 +15,7 @@
15
15
  * 每一行的**条件**(什么事实使它命中)是 web-admin 的判定逻辑,写在 `docs/CONSUMER-INTEGRATION.md` 里,不进运行期表。
16
16
  * · {@link CREDENTIAL_PLANE_REFUSALS} —— 凭据平面共享拒答表(九个词;同一平面的各只口从它派生,每个词的状态集与 `permanence` 只在这里写一次)。
17
17
  * · {@link SANDBOX_GIT_REFUSALS} —— 整次拒答词(十一个)→ HTTP 状态集与 `permanence`,由凭据平面共享表 {@link CREDENTIAL_PLANE_REFUSALS}(九个)与本口自有的两个词按声明的次序派生(上一版的十个词原序、新词只在尾部);拒体里的 `permanence` 是错误词的函数,必须等于这一行的。
18
- * · {@link SANDBOX_GIT_PERMANENCE} —— `terminal`(不按定时重试)/ `transient`(退避重试)两词,语义在本表定义。
18
+ * · {@link SANDBOX_GIT_PERMANENCE} —— `terminal`(这一次请求不按退避节奏重试,再问要等一件可能改变答案的事)/ `transient`(退避重试)两词,语义在本表定义。
19
19
  *
20
20
  * ## 解析一律剥未知键
21
21
  * 与包内 api 契约的前向兼容同律(新键恒为加性)。同时这也是一条安全律:`secret` 只在 `active` 臂的形里 —— 别的臂即使收到也剥掉,
@@ -205,13 +205,18 @@ export declare const SandboxGitCredentialAnswer: z.ZodObject<{
205
205
  kind: z.ZodLiteral<"sandbox_git">;
206
206
  }, z.core.$strip>;
207
207
  export type SandboxGitCredentialAnswer = z.infer<typeof SandboxGitCredentialAnswer>;
208
- /** `permanence` 两词:`terminal` = 不按定时重试;`transient` = 退避重试。 */
208
+ /**
209
+ * `permanence` 两词(凭据平面各只口共用这一张):
210
+ * · `terminal` = 这一次请求不按退避节奏重试;再问要等一件可能改变答案的事(用户的动作 —— 重新登录续上委托、去授权地址授权;运维的修复 —— 改配置并重启;
211
+ * 或收方自己的下一次连接 / 发送)。收方可以为这类词设一个低频的复查,那是收方的处置表,不在这里;
212
+ * · `transient` = 退避重试。
213
+ */
209
214
  export declare const SANDBOX_GIT_PERMANENCE: readonly ["terminal", "transient"];
210
215
  export type SandboxGitPermanence = (typeof SANDBOX_GIT_PERMANENCE)[number];
211
216
  /**
212
217
  * 凭据平面共享拒答表(九个词):同一凭据平面的各只口都从它派生(`sandbox_git` 凭据取值口如此,同一平面的后续取值口同样如此),
213
218
  * 每个词的 HTTP 状态集与 `permanence` 只在这里写一次。
214
- * `plane_misconfigured` = 凭据平面在答方配置错 —— `terminal`,按定时重试不会成功,必须由运维修正配置。
219
+ * `plane_misconfigured` = 凭据平面在答方配置错 —— `terminal`,运维修正配置之前再问也不会成功(不按退避节奏重试;运维修复是那件可能改变答案的事)。
215
220
  */
216
221
  export declare const CREDENTIAL_PLANE_REFUSALS: {
217
222
  readonly caller_not_admitted: {
@@ -255,83 +260,58 @@ export declare const CREDENTIAL_PLANE_REFUSALS: {
255
260
  export type CredentialPlaneRefusalError = keyof typeof CREDENTIAL_PLANE_REFUSALS;
256
261
  /** 凭据平面共享拒答词表(运行期;表的键,按表序)。 */
257
262
  export declare const CREDENTIAL_PLANE_REFUSAL_ERRORS: readonly [CredentialPlaneRefusalError, ...CredentialPlaneRefusalError[]];
258
- declare const SANDBOX_GIT_OWN_REFUSALS: {
259
- readonly scope_mismatch: {
260
- readonly statuses: readonly [403];
261
- readonly permanence: "terminal";
262
- };
263
- readonly handle_invalid: {
264
- readonly statuses: readonly [401];
265
- readonly permanence: "transient";
266
- };
267
- };
268
- /** 上一版的十个词保持原序,新词只追加在尾部 —— 调整既有词的次序是破坏性变更。 */
269
- declare const SANDBOX_GIT_REFUSAL_ORDER: readonly ["caller_not_admitted", "scope_mismatch", "incarnation_mismatch", "request_invalid", "principal_not_live", "delegation_required", "vault_disabled", "vault_frozen", "handle_invalid", "vault_unavailable", "plane_misconfigured"];
270
- type SandboxGitRefusalWord = (typeof SANDBOX_GIT_REFUSAL_ORDER)[number];
271
- type SandboxGitRefusalSource = CredentialPlaneRefusalError | keyof typeof SANDBOX_GIT_OWN_REFUSALS;
272
- /** 编译期核对,只在类型层(不留运行期语句):`T` 必须是 `true`,否则这一行编译即红。 */
273
- type MustBeTrue<T extends true> = T;
274
263
  /**
275
- * 次序表与两张来源表「恰好」互为全集:来源里每个词都在次序表里(漏一个红)、次序表里每个词都在来源里(写进不存在的词红)、
276
- * 共享表与自有表没有同名的词(重名红)。下面 `SANDBOX_GIT_REFUSALS` 的类型用到它,所以不成立 ⇒ 编译红。
264
+ * 整次拒答词 → 它的 HTTP 状态集(中心答这个词时用其一)与 `permanence`。**一个错误词的 permanence 是固定的**,拒体里再带一份只为让收方不必查表 ——
265
+ * 两处不一致就是畸形应答({@link SandboxGitCredentialRefusal} 拒)。收方怎么处置某个词(例如哪些 terminal 可由用户动作恢复)是收方的状态机,不在这里。
266
+ * 表由 {@link CREDENTIAL_PLANE_REFUSALS} 与本口自有两词按声明的次序派生(复用同一行对象,不抄行;次序表重复词即抛、与两张来源表不恰好互为全集即编译红 ——
267
+ * 派生机关在包内私有叶 `./refusal-table`,凭据平面各只口共用一份)。
277
268
  */
278
- type SandboxGitRefusalOrderIsExact = MustBeTrue<[
279
- Exclude<SandboxGitRefusalSource, SandboxGitRefusalWord>,
280
- Exclude<SandboxGitRefusalWord, SandboxGitRefusalSource>,
281
- Extract<CredentialPlaneRefusalError, keyof typeof SANDBOX_GIT_OWN_REFUSALS>
282
- ] extends [never, never, never] ? true : false>;
283
- declare const SANDBOX_GIT_REFUSAL_ROWS: {
284
- scope_mismatch: {
285
- readonly statuses: readonly [403];
286
- readonly permanence: "terminal";
287
- };
288
- handle_invalid: {
289
- readonly statuses: readonly [401];
290
- readonly permanence: "transient";
291
- };
292
- caller_not_admitted: {
269
+ export declare const SANDBOX_GIT_REFUSALS: {
270
+ readonly caller_not_admitted: {
293
271
  readonly statuses: readonly [401, 403];
294
272
  readonly permanence: "terminal";
295
273
  };
296
- incarnation_mismatch: {
274
+ readonly incarnation_mismatch: {
297
275
  readonly statuses: readonly [403];
298
276
  readonly permanence: "terminal";
299
277
  };
300
- request_invalid: {
278
+ readonly request_invalid: {
301
279
  readonly statuses: readonly [400];
302
280
  readonly permanence: "terminal";
303
281
  };
304
- principal_not_live: {
282
+ readonly principal_not_live: {
305
283
  readonly statuses: readonly [403];
306
284
  readonly permanence: "terminal";
307
285
  };
308
- delegation_required: {
286
+ readonly delegation_required: {
309
287
  readonly statuses: readonly [403];
310
288
  readonly permanence: "terminal";
311
289
  };
312
- vault_disabled: {
290
+ readonly vault_disabled: {
313
291
  readonly statuses: readonly [503];
314
292
  readonly permanence: "terminal";
315
293
  };
316
- vault_frozen: {
294
+ readonly vault_frozen: {
317
295
  readonly statuses: readonly [503];
318
296
  readonly permanence: "terminal";
319
297
  };
320
- vault_unavailable: {
298
+ readonly vault_unavailable: {
321
299
  readonly statuses: readonly [503];
322
300
  readonly permanence: "transient";
323
301
  };
324
- plane_misconfigured: {
302
+ readonly plane_misconfigured: {
325
303
  readonly statuses: readonly [503];
326
304
  readonly permanence: "terminal";
327
305
  };
306
+ readonly scope_mismatch: {
307
+ readonly statuses: readonly [403];
308
+ readonly permanence: "terminal";
309
+ };
310
+ readonly handle_invalid: {
311
+ readonly statuses: readonly [401];
312
+ readonly permanence: "transient";
313
+ };
328
314
  };
329
- /**
330
- * 整次拒答词 → 它的 HTTP 状态集(中心答这个词时用其一)与 `permanence`。**一个错误词的 permanence 是固定的**,拒体里再带一份只为让收方不必查表 ——
331
- * 两处不一致就是畸形应答({@link SandboxGitCredentialRefusal} 拒)。收方怎么处置某个词(例如哪些 terminal 可由用户动作恢复)是收方的状态机,不在这里。
332
- * 表由 {@link CREDENTIAL_PLANE_REFUSALS} 与本口自有两词按声明的次序派生(复用同一行对象,不抄行)。
333
- */
334
- export declare const SANDBOX_GIT_REFUSALS: { readonly [W in SandboxGitRefusalOrderIsExact extends true ? SandboxGitRefusalWord : never]: (typeof SANDBOX_GIT_REFUSAL_ROWS)[W]; };
335
315
  /** 整次拒答词(闭集,十一个)—— 类型由 {@link SANDBOX_GIT_REFUSALS} 派生,次序来自声明的次序。 */
336
316
  export type SandboxGitRefusalError = keyof typeof SANDBOX_GIT_REFUSALS;
337
317
  /** 整次拒答词表(运行期;表的键,按声明的次序)。 */
@@ -15,7 +15,7 @@
15
15
  * 每一行的**条件**(什么事实使它命中)是 web-admin 的判定逻辑,写在 `docs/CONSUMER-INTEGRATION.md` 里,不进运行期表。
16
16
  * · {@link CREDENTIAL_PLANE_REFUSALS} —— 凭据平面共享拒答表(九个词;同一平面的各只口从它派生,每个词的状态集与 `permanence` 只在这里写一次)。
17
17
  * · {@link SANDBOX_GIT_REFUSALS} —— 整次拒答词(十一个)→ HTTP 状态集与 `permanence`,由凭据平面共享表 {@link CREDENTIAL_PLANE_REFUSALS}(九个)与本口自有的两个词按声明的次序派生(上一版的十个词原序、新词只在尾部);拒体里的 `permanence` 是错误词的函数,必须等于这一行的。
18
- * · {@link SANDBOX_GIT_PERMANENCE} —— `terminal`(不按定时重试)/ `transient`(退避重试)两词,语义在本表定义。
18
+ * · {@link SANDBOX_GIT_PERMANENCE} —— `terminal`(这一次请求不按退避节奏重试,再问要等一件可能改变答案的事)/ `transient`(退避重试)两词,语义在本表定义。
19
19
  *
20
20
  * ## 解析一律剥未知键
21
21
  * 与包内 api 契约的前向兼容同律(新键恒为加性)。同时这也是一条安全律:`secret` 只在 `active` 臂的形里 —— 别的臂即使收到也剥掉,
@@ -27,6 +27,7 @@ import { SANDBOX_GIT_MAX_ORIGINS, SandboxGitOrigin, SandboxGitOriginList } from
27
27
  import { PrincipalIncarnation } from "./auth-bridge.js";
28
28
  import { NonEmptyString, PrincipalString, SafeCount } from "./wire-scalars.js";
29
29
  import { deepFreeze } from "../deep-freeze.js";
30
+ import { buildRefusalTable } from "./refusal-table.js";
30
31
  // ── 逐 origin 判定序表 ─────────────────────────────────────────────────────────────────────────────────────────────
31
32
  /**
32
33
  * 逐 origin 判定序表(11 行,序即判定序)。每行 `{ state, reason? }`:命中这一行的 origin 的应答是这个状态与这个原因。
@@ -119,12 +120,17 @@ export const SandboxGitCredentialAnswer = z.object({
119
120
  origins: z.array(SandboxGitOriginAnswer).min(1).max(SANDBOX_GIT_MAX_ORIGINS),
120
121
  });
121
122
  // ── 整次拒答 ───────────────────────────────────────────────────────────────────────────────────────────────────────
122
- /** `permanence` 两词:`terminal` = 不按定时重试;`transient` = 退避重试。 */
123
+ /**
124
+ * `permanence` 两词(凭据平面各只口共用这一张):
125
+ * · `terminal` = 这一次请求不按退避节奏重试;再问要等一件可能改变答案的事(用户的动作 —— 重新登录续上委托、去授权地址授权;运维的修复 —— 改配置并重启;
126
+ * 或收方自己的下一次连接 / 发送)。收方可以为这类词设一个低频的复查,那是收方的处置表,不在这里;
127
+ * · `transient` = 退避重试。
128
+ */
123
129
  export const SANDBOX_GIT_PERMANENCE = deepFreeze(["terminal", "transient"]);
124
130
  /**
125
131
  * 凭据平面共享拒答表(九个词):同一凭据平面的各只口都从它派生(`sandbox_git` 凭据取值口如此,同一平面的后续取值口同样如此),
126
132
  * 每个词的 HTTP 状态集与 `permanence` 只在这里写一次。
127
- * `plane_misconfigured` = 凭据平面在答方配置错 —— `terminal`,按定时重试不会成功,必须由运维修正配置。
133
+ * `plane_misconfigured` = 凭据平面在答方配置错 —— `terminal`,运维修正配置之前再问也不会成功(不按退避节奏重试;运维修复是那件可能改变答案的事)。
128
134
  */
129
135
  export const CREDENTIAL_PLANE_REFUSALS = deepFreeze({
130
136
  caller_not_admitted: { statuses: [401, 403], permanence: "terminal" },
@@ -143,24 +149,18 @@ const SANDBOX_GIT_OWN_REFUSALS = deepFreeze({
143
149
  scope_mismatch: { statuses: [403], permanence: "terminal" },
144
150
  handle_invalid: { statuses: [401], permanence: "transient" },
145
151
  });
146
- /** 同一个词写了两遍 ⇒ 模块加载即抛(次序表是公开事实,重复的词会让派生表静默少一行)。原样交回入参(元组类型不丢)。 */
147
- function wordsListedOnce(words) {
148
- if (new Set(words).size !== words.length)
149
- throw new Error("SANDBOX_GIT_REFUSAL_ORDER lists a word twice");
150
- return words;
151
- }
152
152
  /** 上一版的十个词保持原序,新词只追加在尾部 —— 调整既有词的次序是破坏性变更。 */
153
- const SANDBOX_GIT_REFUSAL_ORDER = wordsListedOnce([
153
+ const SANDBOX_GIT_REFUSAL_ORDER = [
154
154
  "caller_not_admitted", "scope_mismatch", "incarnation_mismatch", "request_invalid", "principal_not_live",
155
155
  "delegation_required", "vault_disabled", "vault_frozen", "handle_invalid", "vault_unavailable", "plane_misconfigured",
156
- ]);
157
- const SANDBOX_GIT_REFUSAL_ROWS = { ...CREDENTIAL_PLANE_REFUSALS, ...SANDBOX_GIT_OWN_REFUSALS };
156
+ ];
158
157
  /**
159
158
  * 整次拒答词 → 它的 HTTP 状态集(中心答这个词时用其一)与 `permanence`。**一个错误词的 permanence 是固定的**,拒体里再带一份只为让收方不必查表 ——
160
159
  * 两处不一致就是畸形应答({@link SandboxGitCredentialRefusal} 拒)。收方怎么处置某个词(例如哪些 terminal 可由用户动作恢复)是收方的状态机,不在这里。
161
- * 表由 {@link CREDENTIAL_PLANE_REFUSALS} 与本口自有两词按声明的次序派生(复用同一行对象,不抄行)。
160
+ * 表由 {@link CREDENTIAL_PLANE_REFUSALS} 与本口自有两词按声明的次序派生(复用同一行对象,不抄行;次序表重复词即抛、与两张来源表不恰好互为全集即编译红 ——
161
+ * 派生机关在包内私有叶 `./refusal-table`,凭据平面各只口共用一份)。
162
162
  */
163
- export const SANDBOX_GIT_REFUSALS = deepFreeze(Object.fromEntries(SANDBOX_GIT_REFUSAL_ORDER.map((w) => [w, SANDBOX_GIT_REFUSAL_ROWS[w]])));
163
+ export const SANDBOX_GIT_REFUSALS = buildRefusalTable("SANDBOX_GIT_REFUSAL_ORDER", CREDENTIAL_PLANE_REFUSALS, SANDBOX_GIT_OWN_REFUSALS, SANDBOX_GIT_REFUSAL_ORDER);
164
164
  /** 整次拒答词表(运行期;表的键,按声明的次序)。 */
165
165
  export const SANDBOX_GIT_REFUSAL_ERRORS = deepFreeze(Object.keys(SANDBOX_GIT_REFUSALS));
166
166
  /** 整次拒答的体:`{ error, permanence, message }`。`message` 是中心的诊断句(收方不据它判,可为空串)。 */
@@ -0,0 +1,16 @@
1
+ type RefusalSource = Readonly<Record<string, object>>;
2
+ /** 次序表与两张来源表「恰好」互为全集、两张来源表不重名 ⇒ `unknown`(不收窄实参);否则 `never`(实参不可赋 ⇒ 编译红)。 */
3
+ type OrderIsExact<Shared, Own, Word> = [
4
+ Exclude<keyof Shared | keyof Own, Word>,
5
+ Exclude<Word, keyof Shared | keyof Own>,
6
+ Extract<keyof Shared, keyof Own>
7
+ ] extends [never, never, never] ? unknown : never;
8
+ /** 派生表的型:次序表里的每个词 → 来源里那一行的型。 */
9
+ type RefusalTableOf<Shared, Own, Word extends PropertyKey> = {
10
+ readonly [W in Word]: W extends keyof Own ? Own[W] : W extends keyof Shared ? Shared[W] : never;
11
+ };
12
+ /**
13
+ * 由共享表与自有表按次序表派生一只口的拒答表(见模块头注 ①–④)。`orderName` 只用于抛句(`<orderName> lists a word twice`)。
14
+ */
15
+ export declare function buildRefusalTable<Shared extends RefusalSource, Own extends RefusalSource, const Order extends readonly ((keyof Shared & string) | (keyof Own & string))[]>(orderName: string, shared: Shared, own: Own, order: Order & OrderIsExact<Shared, Own, Order[number]>): RefusalTableOf<Shared, Own, Order[number]>;
16
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `api/refusal-table` —— 包内私有模块(不在主桶、不在任何子路径):凭据平面各只口的拒答表从共享表派生的那一套机关,一处定义、各口调用。
3
+ *
4
+ * 一只口的拒答表 = 凭据平面共享拒答表(`CREDENTIAL_PLANE_REFUSALS`,`./credentials`)的全部词 + 这只口自有的词,按这只口声明的次序排。
5
+ * {@link buildRefusalTable} 做四件事:
6
+ * ① 次序表里同一个词写了两遍 ⇒ 调用即抛(次序表是公开事实,重复的词会让派生表静默少一行);抛句带次序表的名字;
7
+ * ② 编译期三项核:来源(共享表 + 自有表)里每个词都在次序表里 · 次序表里每个词都在来源里 · 共享表与自有表没有同名的词 ——
8
+ * 不成立 ⇒ 次序表那个实参的型是 `never`,调用处编译红(不留运行期语句);
9
+ * ③ 合行复用来源里的同一只行对象(不抄行),按次序逐项构造;
10
+ * ④ 整只表深冻结。
11
+ * 返回型逐词取来源里那一行的型(状态码元组、permanence 单词都是字面量,不放宽)。
12
+ *
13
+ * 不导出给消费方:消费方要的是派生出来的表(`SANDBOX_GIT_REFUSALS` / `CONNECTOR_ASSERTION_REFUSALS`),不是这只机关。纯、浏览器安全。
14
+ */
15
+ import { deepFreeze } from "../deep-freeze.js";
16
+ /**
17
+ * 由共享表与自有表按次序表派生一只口的拒答表(见模块头注 ①–④)。`orderName` 只用于抛句(`<orderName> lists a word twice`)。
18
+ */
19
+ export function buildRefusalTable(orderName, shared, own, order) {
20
+ if (new Set(order).size !== order.length)
21
+ throw new Error(`${orderName} lists a word twice`);
22
+ const rows = { ...shared, ...own };
23
+ return deepFreeze(Object.fromEntries(order.map((word) => [word, rows[word]])));
24
+ }
@@ -18,6 +18,7 @@ export { runConformance, materializeLocalRoot, resolveLegExpectation } from "./r
18
18
  export { runWebAdminCredentialLockConformance, type WebAdminCredentialLockConformanceReport, type WebAdminCredentialLockImplementation } from "./web-admin-credential-lock.js";
19
19
  export { createContractAdapter, type ContractAdapterOptions, type ContractModule } from "./contract-adapter.js";
20
20
  export { loadCorpus, loadCase, kitIdentity, DEFAULT_CORPUS_DIR, PACKAGE_ROOT, type Corpus, type ConformanceCase, type CaseInput, type CaseMeta, type LegExpectationJson } from "./corpus.js";
21
+ export { PROFILE_CONFORMANCE_DIR, PROFILE_VECTORS_FORMAT, PROFILE_FROZEN_PROMISES_FORMAT, PROFILE_VECTOR_EXPECTS, BUILTIN_PROFILE_NAMES, loadProfileVectors, loadBuiltinProfilesAndSchema, type BuiltinProfileName, type ProfileVectorExpect, type ProfileVector, type ProfileVectorsDocument, type ProfileFrozenPromises, type ProfileVectorsData, type BuiltinProfilesAndSchema, } from "./profile.js";
21
22
  export { DERIVATION_TRANSFORMS, LEG_EXPECTATION, NON_LOCAL_READ_DOMAINS, EPOCH_ISO, deriveWireInput, deriveLocalInput, deriveWireExpectation, deriveLocalExpectation, foreignKeysOf, toManifestDoc, type DerivationTransform, type LegExpectation, } from "./derive.js";
22
23
  export { canonicalize, deepEqual, diffJson, stableKey, type JsonPatchOp } from "./canonical.js";
23
24
  export { WARNING_KINDS, projectWarning, normalizeProjection, projectionKey, projectionValue, diffWarningMultiset, findSecretLeaks, type WarningKind, type WarningProjection, } from "./warnings.js";
@@ -19,6 +19,7 @@ export { runConformance, materializeLocalRoot, resolveLegExpectation } from "./r
19
19
  export { runWebAdminCredentialLockConformance } from "./web-admin-credential-lock.js";
20
20
  export { createContractAdapter } from "./contract-adapter.js";
21
21
  export { loadCorpus, loadCase, kitIdentity, DEFAULT_CORPUS_DIR, PACKAGE_ROOT } from "./corpus.js";
22
+ export { PROFILE_CONFORMANCE_DIR, PROFILE_VECTORS_FORMAT, PROFILE_FROZEN_PROMISES_FORMAT, PROFILE_VECTOR_EXPECTS, BUILTIN_PROFILE_NAMES, loadProfileVectors, loadBuiltinProfilesAndSchema, } from "./profile.js";
22
23
  export { DERIVATION_TRANSFORMS, LEG_EXPECTATION, NON_LOCAL_READ_DOMAINS, EPOCH_ISO, deriveWireInput, deriveLocalInput, deriveWireExpectation, deriveLocalExpectation, foreignKeysOf, toManifestDoc, } from "./derive.js";
23
24
  export { canonicalize, deepEqual, diffJson, stableKey } from "./canonical.js";
24
25
  export { WARNING_KINDS, projectWarning, normalizeProjection, projectionKey, projectionValue, diffWarningMultiset, findSecretLeaks, } from "./warnings.js";