@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,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"version": 29,
|
|
4
|
+
"updatedAt": "2026-11-15T00:00:00.000Z"
|
|
5
|
+
},
|
|
6
|
+
"domains": {
|
|
7
|
+
"mcp": {
|
|
8
|
+
"servers": [
|
|
9
|
+
{
|
|
10
|
+
"name": "dotted",
|
|
11
|
+
"transport": {
|
|
12
|
+
"kind": "http",
|
|
13
|
+
"url": "https://mcp.example.com/connector",
|
|
14
|
+
"credentials": {
|
|
15
|
+
"kind": "assertion",
|
|
16
|
+
"audience": "a.b"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "plain",
|
|
22
|
+
"transport": {
|
|
23
|
+
"kind": "http",
|
|
24
|
+
"url": "https://mcp.example.com/plain"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contributor": "contract",
|
|
3
|
+
"claim": "断言臂的 `audience` 不是连接器 id(`a.b`:DNS label 不收点)⇒ 拒:读腿整条丢、兄弟存活;严写整份拒。打的是:读者只判 audience 是非空串(拼错的 id 让断言发往一个不存在的受众,调用时才失败)。",
|
|
4
|
+
"firstRedOn": [],
|
|
5
|
+
"note": "firstRedOn 为空:historical 阶梯不覆盖 29.0.0 的新键;对 28.0.0 这一条的读数不同(`transport.credentials` 在那一版不是条目的键 / `assertionHeader` 在那一版受理),那一版不在入库的真跑证据里。"
|
|
6
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"domains": {
|
|
3
|
+
"outcome": "effective",
|
|
4
|
+
"effective": {
|
|
5
|
+
"a2a": {
|
|
6
|
+
"peers": []
|
|
7
|
+
},
|
|
8
|
+
"collab": {
|
|
9
|
+
"templates": []
|
|
10
|
+
},
|
|
11
|
+
"entitlement": {
|
|
12
|
+
"budgetGroups": [],
|
|
13
|
+
"groupBindings": [],
|
|
14
|
+
"subjects": [],
|
|
15
|
+
"tiers": []
|
|
16
|
+
},
|
|
17
|
+
"execution": {
|
|
18
|
+
"allowedLanes": [
|
|
19
|
+
"host"
|
|
20
|
+
],
|
|
21
|
+
"required": false
|
|
22
|
+
},
|
|
23
|
+
"governance": {},
|
|
24
|
+
"hosts": {
|
|
25
|
+
"hosts": []
|
|
26
|
+
},
|
|
27
|
+
"limits": {},
|
|
28
|
+
"mcp": {
|
|
29
|
+
"servers": [
|
|
30
|
+
{
|
|
31
|
+
"elicitation": false,
|
|
32
|
+
"enabled": true,
|
|
33
|
+
"name": "plain",
|
|
34
|
+
"rosters": [],
|
|
35
|
+
"scenarios": [],
|
|
36
|
+
"transport": {
|
|
37
|
+
"kind": "http",
|
|
38
|
+
"url": "https://mcp.example.com/plain"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"models": {
|
|
44
|
+
"atMention": {
|
|
45
|
+
"mode": "all"
|
|
46
|
+
},
|
|
47
|
+
"models": [],
|
|
48
|
+
"roles": {},
|
|
49
|
+
"tierGroups": []
|
|
50
|
+
},
|
|
51
|
+
"plugins": {
|
|
52
|
+
"plugins": []
|
|
53
|
+
},
|
|
54
|
+
"projects": {
|
|
55
|
+
"projects": {}
|
|
56
|
+
},
|
|
57
|
+
"prompts": {},
|
|
58
|
+
"rosters": {
|
|
59
|
+
"rosters": []
|
|
60
|
+
},
|
|
61
|
+
"scenarios": {
|
|
62
|
+
"scenarios": []
|
|
63
|
+
},
|
|
64
|
+
"skills": {
|
|
65
|
+
"skills": []
|
|
66
|
+
},
|
|
67
|
+
"systems": {
|
|
68
|
+
"systems": []
|
|
69
|
+
},
|
|
70
|
+
"workers": {
|
|
71
|
+
"workers": []
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"warnings": [
|
|
75
|
+
{
|
|
76
|
+
"domain": "mcp",
|
|
77
|
+
"identity": {
|
|
78
|
+
"name": "extra"
|
|
79
|
+
},
|
|
80
|
+
"kind": "entry-dropped",
|
|
81
|
+
"path": [
|
|
82
|
+
"servers",
|
|
83
|
+
0
|
|
84
|
+
],
|
|
85
|
+
"reasonCode": "entry-schema-invalid"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"metadata": {
|
|
89
|
+
"version": 29,
|
|
90
|
+
"updatedAt": "2026-11-15T00:00:00.000Z"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"strictWrite": {
|
|
94
|
+
"outcome": "rejected",
|
|
95
|
+
"stage": "validate",
|
|
96
|
+
"why": "拒:引用的读法只经原语包 readCredentialRef,多余成员是它的 extra_field。"
|
|
97
|
+
},
|
|
98
|
+
"wire": {
|
|
99
|
+
"derive": true
|
|
100
|
+
},
|
|
101
|
+
"localRoot": {
|
|
102
|
+
"derive": true,
|
|
103
|
+
"localVersion": 1984804257573732
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"version": 29,
|
|
4
|
+
"updatedAt": "2026-11-15T00:00:00.000Z"
|
|
5
|
+
},
|
|
6
|
+
"domains": {
|
|
7
|
+
"mcp": {
|
|
8
|
+
"servers": [
|
|
9
|
+
{
|
|
10
|
+
"name": "extra",
|
|
11
|
+
"transport": {
|
|
12
|
+
"kind": "http",
|
|
13
|
+
"url": "https://mcp.example.com/connector",
|
|
14
|
+
"credentials": {
|
|
15
|
+
"kind": "assertion",
|
|
16
|
+
"audience": "gitea",
|
|
17
|
+
"header": "x-assertion"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "plain",
|
|
23
|
+
"transport": {
|
|
24
|
+
"kind": "http",
|
|
25
|
+
"url": "https://mcp.example.com/plain"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contributor": "contract",
|
|
3
|
+
"claim": "断言臂带一只它没有的成员(`header`)⇒ 原语包的问题理由(多余成员)拒:读腿整条丢、兄弟存活;严写整份拒。打的是:读者自带一份宽读法(只看 kind 与 audience),多余成员被静默剥掉 —— 写进去的头名不生效且无声。",
|
|
4
|
+
"firstRedOn": [],
|
|
5
|
+
"note": "firstRedOn 为空:historical 阶梯不覆盖 29.0.0 的新键;对 28.0.0 这一条的读数不同(`transport.credentials` 在那一版不是条目的键 / `assertionHeader` 在那一版受理),那一版不在入库的真跑证据里。"
|
|
6
|
+
}
|
package/dist/api/credentials.js
CHANGED
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
* 解析出的值里不会带着谁多塞的秘密。`secret` 是应答里唯一的秘密位;`credentialId` / `version` / `auditId` 是不带值的审计位。
|
|
22
22
|
*/
|
|
23
23
|
import { z } from "zod";
|
|
24
|
-
import { INTEGER } from "../integer.js";
|
|
25
24
|
import { buildQuotedIssue } from "../quoted-issue.js";
|
|
26
25
|
import { SANDBOX_GIT_MAX_ORIGINS, SandboxGitOrigin, SandboxGitOriginList } from "../sandbox-git.js";
|
|
27
|
-
import {
|
|
26
|
+
import { PrincipalIncarnation } from "./auth-bridge.js";
|
|
27
|
+
import { NonEmptyString, PrincipalString, SafeCount } from "./wire-scalars.js";
|
|
28
28
|
import { deepFreeze } from "../deep-freeze.js";
|
|
29
29
|
// ── 逐 origin 判定序表 ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
30
30
|
/**
|
|
@@ -54,15 +54,13 @@ function reasonsOf(state) {
|
|
|
54
54
|
return SANDBOX_GIT_ORIGIN_VERDICTS.flatMap((v) => (v.state === state && "reason" in v ? [v.reason] : []));
|
|
55
55
|
}
|
|
56
56
|
// ── 公共字段 ───────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
57
|
-
|
|
58
|
-
const SafeCount = INTEGER.nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
59
|
-
const NonEmptyString = z.string().min(1);
|
|
57
|
+
// 本模块里的数值位(毫秒时刻、凭据行版本)、非空串与主体名的形来自包内私有叶子 `./wire-scalars`(与 `api/lifecycle-events` 共用一份,不各抄一遍)。
|
|
60
58
|
/**
|
|
61
|
-
* 请求与应答都带的「这是谁的 run」字段:主体(长度界同令牌 `sub`
|
|
59
|
+
* 请求与应答都带的「这是谁的 run」字段:主体(长度界同令牌 `sub` 的界,`PRINCIPAL_MAX_LENGTH`,见 `./api/auth-bridge`)、化身号({@link PrincipalIncarnation},与令牌 `sub_inc` 同一只 schema)、
|
|
62
60
|
* scope(非空串 —— 与 `readTokenScope` 读 token 声明的规则同一条,不另立 slug 规则)。应答里这三键是**回显**,等不等于请求由收方核。
|
|
63
61
|
*/
|
|
64
62
|
const RunIdentity = {
|
|
65
|
-
principal:
|
|
63
|
+
principal: PrincipalString,
|
|
66
64
|
principalInc: PrincipalIncarnation,
|
|
67
65
|
scope: NonEmptyString,
|
|
68
66
|
};
|
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
/**
|
|
38
|
+
* 事件 `kind` 表(包内私有):一词一行 `{ kind, scoped }` —— **每个词只在这里拼一次**;`scoped` = 这一臂**必带** `scope`(`membership.*` 两词),其余臂不带。
|
|
39
|
+
* 词表({@link PRINCIPAL_LIFECYCLE_EVENT_KINDS})、词的类型({@link PrincipalLifecycleEventKind})与事件行联合({@link PrincipalLifecycleEvent})的每一臂都由它派生,没有第二张词表。
|
|
40
|
+
*/
|
|
41
|
+
declare const EVENT_KIND_ROWS: readonly [{
|
|
42
|
+
readonly kind: "principal.deleted";
|
|
43
|
+
readonly scoped: false;
|
|
44
|
+
}, {
|
|
45
|
+
readonly kind: "principal.pending";
|
|
46
|
+
readonly scoped: false;
|
|
47
|
+
}, {
|
|
48
|
+
readonly kind: "principal.role_lowered";
|
|
49
|
+
readonly scoped: false;
|
|
50
|
+
}, {
|
|
51
|
+
readonly kind: "membership.removed";
|
|
52
|
+
readonly scoped: true;
|
|
53
|
+
}, {
|
|
54
|
+
readonly kind: "membership.role_lowered";
|
|
55
|
+
readonly scoped: true;
|
|
56
|
+
}];
|
|
57
|
+
type EventKindRows = typeof EVENT_KIND_ROWS;
|
|
58
|
+
/** 表的 `kind` 列(类型面;按元组逐位映射,保住「五个字面量的只读元组」)。 */
|
|
59
|
+
type KindColumn<Rows extends readonly {
|
|
60
|
+
readonly kind: string;
|
|
61
|
+
}[]> = {
|
|
62
|
+
readonly [I in keyof Rows]: Rows[I]["kind"];
|
|
63
|
+
};
|
|
64
|
+
/** 用户生命周期事件的 `kind`(闭集,五个,按表序)。事件行的联合按它判别;`membership.*` 两词的臂必带 `scope`,`principal.*` 三词的臂不带。 */
|
|
65
|
+
export type PrincipalLifecycleEventKind = EventKindRows[number]["kind"];
|
|
66
|
+
/** 用户生命周期事件的 `kind` 词表(运行期;定义处深冻结;表的 `kind` 列,按表序)。 */
|
|
67
|
+
export declare const PRINCIPAL_LIFECYCLE_EVENT_KINDS: KindColumn<EventKindRows>;
|
|
68
|
+
/**
|
|
69
|
+
* 一条用户生命周期事件,按 `kind` 判别;臂由 `kind` 表派生,每词一臂、同序。未知键剥掉(`principal.*` 臂带的 `scope` 也是它那一臂的未知键,同样剥掉);
|
|
70
|
+
* `membership.*` 臂缺 `scope` 拒;**未知的 `kind` 值拒,句子点名那个词**(经 {@link echoCallerText} 回显:剥控制与双向字符、有界)。
|
|
71
|
+
* `kind` 不是字符串 / 缺席时没有词可点,句子是 zod 自己的、不回显值。
|
|
72
|
+
*/
|
|
73
|
+
export declare const PrincipalLifecycleEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
74
|
+
at: z.ZodNumber;
|
|
75
|
+
principal: z.ZodString;
|
|
76
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
77
|
+
eventId: z.ZodString;
|
|
78
|
+
seq: z.ZodNumber;
|
|
79
|
+
kind: z.ZodLiteral<"principal.deleted">;
|
|
80
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
81
|
+
at: z.ZodNumber;
|
|
82
|
+
principal: z.ZodString;
|
|
83
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
84
|
+
eventId: z.ZodString;
|
|
85
|
+
seq: z.ZodNumber;
|
|
86
|
+
kind: z.ZodLiteral<"principal.pending">;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
at: z.ZodNumber;
|
|
89
|
+
principal: z.ZodString;
|
|
90
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
91
|
+
eventId: z.ZodString;
|
|
92
|
+
seq: z.ZodNumber;
|
|
93
|
+
kind: z.ZodLiteral<"principal.role_lowered">;
|
|
94
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
95
|
+
scope: z.ZodString;
|
|
96
|
+
at: z.ZodNumber;
|
|
97
|
+
principal: z.ZodString;
|
|
98
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
99
|
+
eventId: z.ZodString;
|
|
100
|
+
seq: z.ZodNumber;
|
|
101
|
+
kind: z.ZodLiteral<"membership.removed">;
|
|
102
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
103
|
+
scope: z.ZodString;
|
|
104
|
+
at: z.ZodNumber;
|
|
105
|
+
principal: z.ZodString;
|
|
106
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
107
|
+
eventId: z.ZodString;
|
|
108
|
+
seq: z.ZodNumber;
|
|
109
|
+
kind: z.ZodLiteral<"membership.role_lowered">;
|
|
110
|
+
}, z.core.$strip>], "kind">;
|
|
111
|
+
export type PrincipalLifecycleEvent = z.infer<typeof PrincipalLifecycleEvent>;
|
|
112
|
+
/**
|
|
113
|
+
* 一页事件:`events`(按 `seq` 升序,可以是空页)· `head`(发方此刻的头游标)· `next`(下一次拉取带的游标,只进不退)。三个成员都不可缺席;未知键剥掉;
|
|
114
|
+
* 页里有一条事件的 `kind` 不认识 ⇒ 整页拒(坐标 `events.<下标>.kind`)。
|
|
115
|
+
* 页的长度上界、`seq` 在页内是否升序、`next` 与最后一条事件的关系都是发方的事,本形不核。
|
|
116
|
+
*/
|
|
117
|
+
export declare const PrincipalLifecycleEventPage: z.ZodObject<{
|
|
118
|
+
events: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
119
|
+
at: z.ZodNumber;
|
|
120
|
+
principal: z.ZodString;
|
|
121
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
122
|
+
eventId: z.ZodString;
|
|
123
|
+
seq: z.ZodNumber;
|
|
124
|
+
kind: z.ZodLiteral<"principal.deleted">;
|
|
125
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
126
|
+
at: z.ZodNumber;
|
|
127
|
+
principal: z.ZodString;
|
|
128
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
129
|
+
eventId: z.ZodString;
|
|
130
|
+
seq: z.ZodNumber;
|
|
131
|
+
kind: z.ZodLiteral<"principal.pending">;
|
|
132
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
133
|
+
at: z.ZodNumber;
|
|
134
|
+
principal: z.ZodString;
|
|
135
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
136
|
+
eventId: z.ZodString;
|
|
137
|
+
seq: z.ZodNumber;
|
|
138
|
+
kind: z.ZodLiteral<"principal.role_lowered">;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
scope: z.ZodString;
|
|
141
|
+
at: z.ZodNumber;
|
|
142
|
+
principal: z.ZodString;
|
|
143
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
144
|
+
eventId: z.ZodString;
|
|
145
|
+
seq: z.ZodNumber;
|
|
146
|
+
kind: z.ZodLiteral<"membership.removed">;
|
|
147
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
148
|
+
scope: z.ZodString;
|
|
149
|
+
at: z.ZodNumber;
|
|
150
|
+
principal: z.ZodString;
|
|
151
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
152
|
+
eventId: z.ZodString;
|
|
153
|
+
seq: z.ZodNumber;
|
|
154
|
+
kind: z.ZodLiteral<"membership.role_lowered">;
|
|
155
|
+
}, z.core.$strip>], "kind">>;
|
|
156
|
+
head: z.ZodNumber;
|
|
157
|
+
next: z.ZodNumber;
|
|
158
|
+
}, z.core.$strip>;
|
|
159
|
+
export type PrincipalLifecycleEventPage = z.infer<typeof PrincipalLifecycleEventPage>;
|
|
160
|
+
/**
|
|
161
|
+
* 拉取失败词(游标与分页这一类,四个)→ 它的 HTTP 状态码与永久性。**一个词只有一个状态码、一个永久性**,表是它们的唯一一处:
|
|
162
|
+
* · 400 —— 请求自己不合格:`cursor_invalid`(游标不是合法游标)/ `limit_invalid`(页长不合法);
|
|
163
|
+
* · 410 —— 游标对不上发方的现状,收方要重同步:`cursor_expired`(游标早于发方还保留的最早位置)/ `cursor_unknown`(游标晚于发方已知的位置)。
|
|
164
|
+
* **410 的拒体带 `head`**(收方从它起重新拉);400 的拒体不带。「带不带 `head`」由这一列推出,不另立一张表({@link LifecyclePageRefusal})。
|
|
165
|
+
* 永久性({@link SandboxGitPermanence},词表在凭据 wire 里):四个词都是 `terminal` —— 同一请求原样重发不会成功(400 的要改请求,410 的要先重新同步);拒体里的 `permanence` 必须等于这一行的。
|
|
166
|
+
* 鉴权类的拒答不在这张表里。
|
|
167
|
+
*/
|
|
168
|
+
export declare const LIFECYCLE_PAGE_REFUSALS: {
|
|
169
|
+
readonly cursor_invalid: {
|
|
170
|
+
readonly status: 400;
|
|
171
|
+
readonly permanence: "terminal";
|
|
172
|
+
};
|
|
173
|
+
readonly limit_invalid: {
|
|
174
|
+
readonly status: 400;
|
|
175
|
+
readonly permanence: "terminal";
|
|
176
|
+
};
|
|
177
|
+
readonly cursor_expired: {
|
|
178
|
+
readonly status: 410;
|
|
179
|
+
readonly permanence: "terminal";
|
|
180
|
+
};
|
|
181
|
+
readonly cursor_unknown: {
|
|
182
|
+
readonly status: 410;
|
|
183
|
+
readonly permanence: "terminal";
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
/** 拉取失败词(闭集,四个)—— 类型由 {@link LIFECYCLE_PAGE_REFUSALS} 派生。 */
|
|
187
|
+
export type LifecyclePageRefusalError = keyof typeof LIFECYCLE_PAGE_REFUSALS;
|
|
188
|
+
/** 拉取失败词表(运行期;表的键,按表序)。 */
|
|
189
|
+
export declare const LIFECYCLE_PAGE_REFUSAL_ERRORS: readonly [LifecyclePageRefusalError, ...LifecyclePageRefusalError[]];
|
|
190
|
+
/**
|
|
191
|
+
* 拉取失败的体,按 `error` 判别(与凭据 wire 的拒体同一种形:码 + 永久性 + 诊断句):
|
|
192
|
+
* · 400 的词:`{ error, permanence, message }`;
|
|
193
|
+
* · 410 的词:`{ error, permanence, message, head }` —— `head` = 发方此刻的头游标(安全整数)。
|
|
194
|
+
* `permanence` 是错误词的函数,必须等于 {@link LIFECYCLE_PAGE_REFUSALS} 里这一行的,两处不一致就是畸形应答(拒)。
|
|
195
|
+
* `message` 是发方的诊断句(收方不据它判,可为空串)。体里不带状态码:状态码是 HTTP 层的,词与状态码的对应只看 {@link LIFECYCLE_PAGE_REFUSALS}。未知键剥掉。
|
|
196
|
+
*/
|
|
197
|
+
export declare const LifecyclePageRefusal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
198
|
+
permanence: z.ZodEnum<{
|
|
199
|
+
terminal: "terminal";
|
|
200
|
+
transient: "transient";
|
|
201
|
+
}>;
|
|
202
|
+
message: z.ZodString;
|
|
203
|
+
error: z.ZodEnum<{
|
|
204
|
+
cursor_invalid: "cursor_invalid";
|
|
205
|
+
limit_invalid: "limit_invalid";
|
|
206
|
+
}>;
|
|
207
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
208
|
+
head: z.ZodNumber;
|
|
209
|
+
permanence: z.ZodEnum<{
|
|
210
|
+
terminal: "terminal";
|
|
211
|
+
transient: "transient";
|
|
212
|
+
}>;
|
|
213
|
+
message: z.ZodString;
|
|
214
|
+
error: z.ZodEnum<{
|
|
215
|
+
cursor_expired: "cursor_expired";
|
|
216
|
+
cursor_unknown: "cursor_unknown";
|
|
217
|
+
}>;
|
|
218
|
+
}, z.core.$strip>], "error">;
|
|
219
|
+
export type LifecyclePageRefusal = z.infer<typeof LifecyclePageRefusal>;
|
|
220
|
+
/** 一次对账请求(与应答)里最多几项。 */
|
|
221
|
+
export declare const PRINCIPAL_RECONCILE_MAX_ITEMS = 500;
|
|
222
|
+
/** 对账请求的一项:要问现状的那个身份元组。 */
|
|
223
|
+
export declare const PrincipalReconcileItem: z.ZodObject<{
|
|
224
|
+
principal: z.ZodString;
|
|
225
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
export type PrincipalReconcileItem = z.infer<typeof PrincipalReconcileItem>;
|
|
228
|
+
/** 对账请求:`{ principals }`,1 – {@link PRINCIPAL_RECONCILE_MAX_ITEMS} 项;未知键剥掉。 */
|
|
229
|
+
export declare const PrincipalReconcileRequest: z.ZodObject<{
|
|
230
|
+
principals: z.ZodArray<z.ZodObject<{
|
|
231
|
+
principal: z.ZodString;
|
|
232
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
233
|
+
}, z.core.$strip>>;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
export type PrincipalReconcileRequest = z.infer<typeof PrincipalReconcileRequest>;
|
|
236
|
+
/**
|
|
237
|
+
* 一个主体的现状,按 `standing` 判别;回显请求里的身份元组(`principal`、可缺席的 `principalInc`);未知键剥掉:
|
|
238
|
+
* · `live` —— 仍在;`since`(毫秒时刻,可缺席)**只在这一臂**:这一段「在」的起点;
|
|
239
|
+
* · `gone` —— 不在了;这一臂的形没有 `since`(带了的被剥掉)。
|
|
240
|
+
*/
|
|
241
|
+
export declare const PrincipalStanding: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
242
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
243
|
+
principal: z.ZodString;
|
|
244
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
245
|
+
standing: z.ZodLiteral<"live">;
|
|
246
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
247
|
+
principal: z.ZodString;
|
|
248
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
249
|
+
standing: z.ZodLiteral<"gone">;
|
|
250
|
+
}, z.core.$strip>], "standing">;
|
|
251
|
+
export type PrincipalStanding = z.infer<typeof PrincipalStanding>;
|
|
252
|
+
/** 对账应答:`{ principals }`,每项是一个 {@link PrincipalStanding};1 – {@link PRINCIPAL_RECONCILE_MAX_ITEMS} 项(与请求逐项对应是收方要核的事);未知键剥掉。 */
|
|
253
|
+
export declare const PrincipalReconcileAnswer: z.ZodObject<{
|
|
254
|
+
principals: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
255
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
principal: z.ZodString;
|
|
257
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
258
|
+
standing: z.ZodLiteral<"live">;
|
|
259
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
260
|
+
principal: z.ZodString;
|
|
261
|
+
principalInc: z.ZodOptional<z.ZodString>;
|
|
262
|
+
standing: z.ZodLiteral<"gone">;
|
|
263
|
+
}, z.core.$strip>], "standing">>;
|
|
264
|
+
}, z.core.$strip>;
|
|
265
|
+
export type PrincipalReconcileAnswer = z.infer<typeof PrincipalReconcileAnswer>;
|
|
266
|
+
export {};
|