@sema-agent/server 7.144.0 → 7.146.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +621 -0
- package/README.md +3 -0
- package/README.zh-CN.md +1 -0
- package/USAGE.md +233 -54
- package/deploy/facts/CHANGES.json +25 -0
- package/deploy/facts/README.md +57 -0
- package/deploy/facts/lanes.json +54 -0
- package/deploy/facts/lanes.schema.json +57 -0
- package/deploy/facts/sandbox-rbac.json +113 -0
- package/deploy/facts/sandbox-rbac.schema.json +74 -0
- package/deploy/facts/sealed-key.json +9 -0
- package/deploy/facts/sealed-key.schema.json +52 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +19 -0
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +4 -0
- package/deploy/sema-up/chart/templates/server.yaml +4 -0
- package/deploy/sema-up/chart/values.yaml +7 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +30 -14
- package/dist/adoption/import-limits.d.ts +6 -0
- package/dist/adoption/import-limits.js +7 -0
- package/dist/adoption/import.d.ts +62 -0
- package/dist/adoption/import.js +107 -0
- package/dist/adoption/wire.d.ts +52 -0
- package/dist/adoption/wire.js +9 -0
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +3 -12
- package/dist/approval-card.js +0 -4
- package/dist/approval-gate-currency.d.ts +1 -1
- package/dist/approval-gate-currency.js +1 -1
- package/dist/approval-reconciler.d.ts +1 -1
- package/dist/audit.d.ts +2 -21
- package/dist/audit.js +0 -9
- package/dist/boot/deployment-mods.d.ts +11 -1
- package/dist/boot/deployment-mods.js +15 -2
- package/dist/boot/device-lane.js +2 -0
- package/dist/boot/engine-lease.d.ts +193 -21
- package/dist/boot/engine-lease.js +146 -20
- package/dist/boot/execution-env.d.ts +4 -0
- package/dist/boot/execution-env.js +12 -0
- package/dist/boot/exit-boundary.d.ts +50 -0
- package/dist/boot/exit-boundary.js +32 -0
- package/dist/boot/exit-last.d.ts +20 -4
- package/dist/boot/exit-last.js +21 -4
- package/dist/boot/governance-seams.js +1 -0
- package/dist/boot/memory-consolidation.d.ts +29 -17
- package/dist/boot/memory-consolidation.js +26 -15
- package/dist/boot/reapers.d.ts +12 -4
- package/dist/boot/reapers.js +39 -15
- package/dist/boot/resolve-spec.d.ts +2 -0
- package/dist/boot/resolve-spec.js +38 -15
- package/dist/boot/runner-deps.js +1 -1
- package/dist/boot/session-faces.d.ts +1 -1
- package/dist/boot/session-faces.js +6 -4
- package/dist/boot/shutdown.js +27 -9
- package/dist/boot/stage-01-config.js +1 -1
- package/dist/boot/stage-03-store-backend.d.ts +1 -0
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -0
- package/dist/boot/stage-05-execution-env.d.ts +3 -0
- package/dist/boot/stage-05-execution-env.js +3 -3
- package/dist/boot/stage-06-runners.d.ts +3 -0
- package/dist/boot/stage-06-runners.js +11 -10
- package/dist/boot/stage-07-capability-layer.d.ts +3 -0
- package/dist/boot/stage-07-capability-layer.js +7 -2
- package/dist/boot/stage-08-reapers.d.ts +3 -0
- package/dist/boot/stage-08-reapers.js +3 -3
- package/dist/boot/stage-09-leader.d.ts +4 -1
- package/dist/boot/stage-10-http-server.d.ts +4 -1
- package/dist/boot/stage-10-http-server.js +4 -3
- package/dist/boot/stores.d.ts +1 -0
- package/dist/boot/stores.js +35 -19
- package/dist/boot/workflow-orchestration.d.ts +1 -1
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/capabilities/composite-members.d.ts +3 -1
- package/dist/capabilities/composite-members.js +3 -1
- package/dist/capabilities/scenarios.d.ts +2 -2
- package/dist/capability-facts.d.ts +18 -1
- package/dist/capability-facts.js +25 -7
- package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
- package/dist/config-catalog.js +13 -4
- package/dist/config-d-migration.d.ts +3 -2
- package/dist/config-provider.d.ts +2 -2
- package/dist/config-types.d.ts +43 -4
- package/dist/config.d.ts +6 -1
- package/dist/config.js +67 -11
- package/dist/deleted-session-ids.d.ts +19 -0
- package/dist/deleted-session-ids.js +26 -0
- package/dist/deploy-facts.d.ts +155 -0
- package/dist/deploy-facts.js +94 -0
- package/dist/device-ws-hub.d.ts +48 -3
- package/dist/device-ws-hub.js +48 -2
- package/dist/error-code-family.d.ts +35 -0
- package/dist/error-code-family.js +26 -0
- package/dist/fleet/drain-entry.d.ts +39 -3
- package/dist/fleet/drain-entry.js +6 -0
- package/dist/fleet/fleet-bus.d.ts +15 -4
- package/dist/fleet/fleet-bus.js +17 -3
- package/dist/hooks/branch-transcript.d.ts +1 -1
- package/dist/hooks/branch-transcript.js +1 -0
- package/dist/hooks/classic-stations.d.ts +25 -8
- package/dist/hooks/classic-stations.js +29 -3
- package/dist/hooks/hook-runner.d.ts +33 -16
- package/dist/hooks/hook-runner.js +166 -73
- package/dist/hooks/hook-source.d.ts +14 -2
- package/dist/hooks/hook-source.js +8 -0
- package/dist/http/active-run-conflict.d.ts +1 -1
- package/dist/http/active-run-conflict.js +1 -1
- package/dist/http/admission.js +13 -2
- package/dist/http/checkpoint-ctx.d.ts +60 -71
- package/dist/http/checkpoint-ctx.js +35 -40
- package/dist/http/dispatch.js +18 -2
- package/dist/http/durable-run-leg.d.ts +5 -0
- package/dist/http/durable-run-leg.js +8 -6
- package/dist/http/execution-context.d.ts +4 -0
- package/dist/http/execution-context.js +9 -0
- package/dist/http/health-self-report.d.ts +6 -2
- package/dist/http/health-self-report.js +3 -2
- package/dist/http/memory-compliance-failure-reply.d.ts +1 -1
- package/dist/http/memory-compliance-failure-reply.js +2 -15
- package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
- package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
- package/dist/http/principal-gate.d.ts +35 -12
- package/dist/http/principal-gate.js +16 -12
- package/dist/http/request-guards.d.ts +1 -1
- package/dist/http/request-guards.js +5 -5
- package/dist/http/resume-legs.d.ts +22 -0
- package/dist/http/resume-legs.js +31 -20
- package/dist/http/route-ctx.d.ts +26 -10
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/adoption.d.ts +11 -0
- package/dist/http/routes/adoption.js +80 -6
- package/dist/http/routes/agents-roster.js +1 -0
- package/dist/http/routes/approvals-assistant.d.ts +20 -1
- package/dist/http/routes/approvals-assistant.js +29 -7
- package/dist/http/routes/background.js +1 -0
- package/dist/http/routes/capabilities.js +4 -1
- package/dist/http/routes/diagnostics.d.ts +9 -14
- package/dist/http/routes/diagnostics.js +10 -20
- package/dist/http/routes/engine.d.ts +31 -0
- package/dist/http/routes/engine.js +81 -0
- package/dist/http/routes/memory-bundle.js +3 -0
- package/dist/http/routes/memory-consolidation.js +3 -5
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/memory-origin.js +2 -4
- package/dist/http/routes/memory-policy.js +5 -1
- package/dist/http/routes/observability.js +3 -6
- package/dist/http/routes/rules.d.ts +1 -1
- package/dist/http/routes/rules.js +5 -2
- package/dist/http/routes/runs.js +7 -3
- package/dist/http/routes/session-sync.js +24 -25
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions.js +4 -0
- package/dist/http/routes/tasks.js +35 -14
- package/dist/http/routes/trace-usage.js +1 -1
- package/dist/http/run-concurrency-cap.d.ts +86 -0
- package/dist/http/run-concurrency-cap.js +54 -0
- package/dist/http/run-meta.d.ts +14 -7
- package/dist/http/run-meta.js +5 -2
- package/dist/http/server.d.ts +27 -16
- package/dist/http/server.js +21 -3
- package/dist/http/stored-body-replay.d.ts +9 -6
- package/dist/http/stored-body-replay.js +19 -5
- package/dist/http/submit-ctx.d.ts +12 -0
- package/dist/http/submit-ctx.js +23 -0
- package/dist/http/wire-types.d.ts +8 -3
- package/dist/json-body-limit.d.ts +8 -0
- package/dist/json-body-limit.js +2 -0
- package/dist/leader/diffout.d.ts +1 -1
- package/dist/local-data-root.d.ts +2 -2
- package/dist/memory-operator-faces.d.ts +9 -4
- package/dist/memory-scope-stores.d.ts +9 -7
- package/dist/memory-scope-stores.js +3 -14
- package/dist/memory-scope.d.ts +36 -0
- package/dist/memory-scope.js +32 -1
- package/dist/net-address.d.ts +53 -0
- package/dist/net-address.js +111 -0
- package/dist/observability/fail-open.d.ts +28 -12
- package/dist/observability/fail-open.js +28 -12
- package/dist/orchestration/workflow-notify-journal.js +2 -3
- package/dist/org-delivery-gate.js +1 -1
- package/dist/peer-directory.d.ts +6 -12
- package/dist/peer-directory.js +5 -1
- package/dist/plugins/approval-ask-store-file.d.ts +16 -2
- package/dist/plugins/approval-ask-store-file.js +21 -1
- package/dist/plugins/approval-ask-store-memory.d.ts +8 -2
- package/dist/plugins/approval-ask-store-memory.js +11 -8
- package/dist/plugins/caching-session-store.d.ts +6 -1
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/checkpoint-store-face.d.ts +426 -0
- package/dist/plugins/checkpoint-store-face.js +152 -0
- package/dist/plugins/file-run-store.d.ts +13 -7
- package/dist/plugins/file-run-store.js +12 -13
- package/dist/plugins/fork-routing-session-store.d.ts +6 -2
- package/dist/plugins/fork-routing-session-store.js +2 -2
- package/dist/plugins/imported-layer-root-retirement.d.ts +10 -8
- package/dist/plugins/local-checkpoint-store.d.ts +16 -5
- package/dist/plugins/local-checkpoint-store.js +25 -6
- package/dist/plugins/local-session-store.d.ts +80 -21
- package/dist/plugins/local-session-store.js +79 -22
- package/dist/plugins/memory-engine-pg.d.ts +29 -6
- package/dist/plugins/memory-engine-pg.js +96 -214
- package/dist/plugins/memory-engine-sql-apply.d.ts +121 -0
- package/dist/plugins/memory-engine-sql-apply.js +358 -0
- package/dist/plugins/memory-engine-tidb.d.ts +35 -9
- package/dist/plugins/memory-engine-tidb.js +97 -227
- package/dist/plugins/memory-key-guards.d.ts +1 -1
- package/dist/plugins/memory-origin-law.d.ts +3 -3
- package/dist/plugins/memory-run-store.d.ts +2 -0
- package/dist/plugins/memory-run-store.js +6 -0
- package/dist/plugins/one-time-migrations.d.ts +32 -56
- package/dist/plugins/one-time-migrations.js +27 -119
- package/dist/plugins/permission-rule-store-file.d.ts +17 -3
- package/dist/plugins/permission-rule-store-file.js +8 -1
- package/dist/plugins/pg-pool.js +1 -1
- package/dist/plugins/pg-session-storage.d.ts +17 -4
- package/dist/plugins/pg-session-storage.js +8 -4
- package/dist/plugins/run-store-sql.d.ts +4 -0
- package/dist/plugins/run-store-sql.js +5 -2
- package/dist/plugins/schema-ensure-legs.js +2 -2
- package/dist/plugins/session-fork.d.ts +31 -9
- package/dist/plugins/session-fork.js +3 -2
- package/dist/plugins/session-placement.d.ts +4 -2
- package/dist/plugins/session-store.d.ts +1 -1
- package/dist/plugins/sql-json-column.d.ts +5 -1
- package/dist/plugins/store-backend.d.ts +11 -8
- package/dist/plugins/store-backend.js +8 -7
- package/dist/plugins/store-contracts.d.ts +1 -11
- package/dist/plugins/store-contracts.js +0 -9
- package/dist/plugins/store-sweep.d.ts +63 -0
- package/dist/plugins/store-sweep.js +48 -0
- package/dist/plugins/tidb-pool.js +1 -1
- package/dist/plugins/tidb-session-store.d.ts +16 -3
- package/dist/plugins/tidb-session-store.js +8 -4
- package/dist/prompt-screen.d.ts +18 -0
- package/dist/prompt-screen.js +5 -0
- package/dist/rules-consent.d.ts +56 -51
- package/dist/rules-consent.js +86 -14
- package/dist/run-acceptance.d.ts +40 -10
- package/dist/run-acceptance.js +38 -5
- package/dist/run-cancel-context.d.ts +4 -1
- package/dist/run-cancel-context.js +2 -1
- package/dist/runs.js +2 -2
- package/dist/sandbox-egress-policy.js +6 -11
- package/dist/sandbox-rbac-rules.d.ts +88 -0
- package/dist/sandbox-rbac-rules.js +80 -0
- package/dist/sealed-key-layout.d.ts +17 -0
- package/dist/sealed-key-layout.js +4 -0
- package/dist/sealed-key.js +5 -5
- package/dist/security.d.ts +48 -9
- package/dist/security.js +9 -2
- package/dist/session-agent.d.ts +39 -0
- package/dist/session-agent.js +16 -0
- package/dist/session-error-wire.d.ts +4 -4
- package/dist/session-notify-door.d.ts +5 -3
- package/dist/session-resident-background.d.ts +57 -0
- package/dist/session-resident-background.js +20 -0
- package/dist/session-sync-kernel.d.ts +53 -14
- package/dist/session-sync-kernel.js +70 -1
- package/dist/session-sync.d.ts +5 -3
- package/dist/session-workspace.d.ts +1 -0
- package/dist/session-workspace.js +1 -0
- package/dist/sighup-idle.d.ts +9 -7
- package/dist/sighup-idle.js +4 -5
- package/dist/spec-fields.d.ts +16 -0
- package/dist/spec-fields.js +7 -0
- package/dist/stored-request-env-credentials-m38.d.ts +3 -0
- package/dist/stored-request-env-credentials-m38.js +8 -0
- package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +33 -429
- package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +70 -209
- package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
- package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
- package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +2 -2
- package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
- package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
- package/dist/task-settings.d.ts +59 -4
- package/dist/task-settings.js +50 -4
- package/dist/tool-approval.d.ts +2 -2
- package/dist/trace/core-keyset-guard.d.ts +8 -7
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.d.ts +6 -0
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/model-segment.d.ts +3 -2
- package/dist/trace/model-segment.js +16 -8
- package/dist/trace/project.js +9 -0
- package/dist/trace/redact.d.ts +79 -4
- package/dist/trace/redact.js +523 -123
- package/dist/trace/self-minted-wire.d.ts +391 -1
- package/dist/trace/self-minted-wire.js +145 -0
- package/dist/trace/wire-projection-faces.d.ts +1 -1
- package/dist/trace/wire-projection-faces.js +1 -1
- package/dist/usage-analytics.d.ts +4 -0
- package/package.json +12 -4
- package/scripts/drain-check-local.mjs +8 -29
- package/scripts/drain-check.mysql.sql +3 -24
- package/scripts/drain-check.pg.sql +3 -24
- package/skills/update-config.md +1 -1
- package/wire-changes/server@7.145.0.json +146 -0
- package/wire-changes/server@7.146.0.json +3221 -0
- package/dist/approval-batch-census.d.ts +0 -27
- package/dist/approval-batch-census.js +0 -27
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"changes": [
|
|
3
|
+
{
|
|
4
|
+
"version": "7.146.0",
|
|
5
|
+
"file": "lanes",
|
|
6
|
+
"kind": "introduced",
|
|
7
|
+
"pointer": "",
|
|
8
|
+
"why": "首发:每条执行车道的租户档、隔离位与必需键,行集 = 所依 settings-schema 的全部车道词"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "7.146.0",
|
|
12
|
+
"file": "sandbox-rbac",
|
|
13
|
+
"kind": "introduced",
|
|
14
|
+
"pointer": "",
|
|
15
|
+
"why": "首发:k8s 沙箱服务账号的 RBAC 规则表(每条规则何时授、引擎真调还是兼容保留)"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"version": "7.146.0",
|
|
19
|
+
"file": "sealed-key",
|
|
20
|
+
"kind": "introduced",
|
|
21
|
+
"pointer": "",
|
|
22
|
+
"why": "首发:钥匙保管目录的安装契约(显式绝对 SEALED_KEY_DIR、整个目录跨重启持久且各副本共享、目录与文件的权限位)"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 引擎部署事实(随包数据)
|
|
2
|
+
|
|
3
|
+
这个目录是 `@sema-agent/server` 引擎**自己的部署要求**的机器可读形:引擎发出的 API 调用、引擎按名读的键与目录、引擎要求先存在的条件。
|
|
4
|
+
安装器(chart / 清单 / 安装脚本)按这里的数据渲自己的产物,不必逐字节拷 server 的 chart。部署方自己拥有的策略实例(例如沙箱出网的 NetworkPolicy:引擎只读来诊断)不在这里。
|
|
5
|
+
|
|
6
|
+
## 取用
|
|
7
|
+
|
|
8
|
+
npm 包内固定路径,子路径 = 文件路径:
|
|
9
|
+
|
|
10
|
+
- Node:`require.resolve("@sema-agent/server/deploy/facts/lanes.json")`(ESM 用 `import.meta.resolve`);
|
|
11
|
+
- tarball:`package/deploy/facts/lanes.json`。
|
|
12
|
+
|
|
13
|
+
公开子路径恰是下表的七个 JSON 文件;这个目录里的其他文件(如本 README)不导出。部署 server 的哪一版,就读那一版包里的这份数据 —— 混版不受支持(规则行是数据,新版可能多一行恒授规则)。
|
|
14
|
+
|
|
15
|
+
| 文件 | 内容 |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `lanes.json` / `lanes.schema.json` | 每条执行车道:分不分租户(`tenantSeparation`)、手跑在不在 OS 级隔离边界里(`isolation`)、选它时引擎起服必须读到的键(`requiredEnv` / `requiredSecretEnv`)。行集 = 本包所依 settings-schema 的全部车道词。 |
|
|
18
|
+
| `sandbox-rbac.json` / `sandbox-rbac.schema.json` | k8s 沙箱车道的服务账号要的 RBAC 规则:范围、资源、动词、何时授(`when`)、引擎适配器真调还是兼容保留(`need`)。 |
|
|
19
|
+
| `sealed-key.json` / `sealed-key.schema.json` | 钥匙保管目录的安装契约:给引擎设绝对路径的 `SEALED_KEY_DIR`;整个目录跨重启持久、各副本共享、引擎可写;目录与钥匙文件的权限位。 |
|
|
20
|
+
| `CHANGES.json` | 形变登记:每份数据的形在哪个版本、怎样变过(与下方「变更」节同源)。 |
|
|
21
|
+
|
|
22
|
+
## 读方义务
|
|
23
|
+
|
|
24
|
+
1. 用**同一个包里**那份 `*.schema.json` 校验数据(JSON Schema 2020-12 的子集)。`x-uniqueKey` 是自定义注解:列出的属性组合在数组里唯一(成员都是标量或标量数组,按值比较即可)—— 标准校验器忽略它,要判就自己判。
|
|
25
|
+
2. 不认识的 `schemaVersion` 整份拒读。
|
|
26
|
+
3. 同一 `schemaVersion` 内的未知键忽略。
|
|
27
|
+
4. 行是数据,不是形:新版可能多一行(新车道、新的恒授规则)而 `schemaVersion` 不变。按行读的消费方对不认识的行(例如不认识的车道词)按自己的策略跳过或拒绝,不要假设行集封闭;
|
|
28
|
+
闭集的是每一列的取值(`enum`),闭集加词才抬版。
|
|
29
|
+
|
|
30
|
+
## 版本与形变
|
|
31
|
+
|
|
32
|
+
- 加性形变只有一种:新增一个**可选**属性 —— `schemaVersion` 不变,`CHANGES.json` 记一条 `additive`。
|
|
33
|
+
- 其余任何形变(删属性、改类型、可选 ⇄ 必有、新增必有属性、闭集增 / 删词、`const` 变、`minItems` / `uniqueItems` / `x-uniqueKey` 变)都是破坏性:该文件的 `schemaVersion` 加 1,记一条 `breaking`。
|
|
34
|
+
- 值的含义变了而形没变,同样记一条 `breaking` 并抬版。
|
|
35
|
+
- 发版前的门禁对上一个已发版本求差:没登记的形变、没抬版的破坏性形变发不出去。
|
|
36
|
+
|
|
37
|
+
## `sealed-key.json` 之外的引擎行为
|
|
38
|
+
|
|
39
|
+
没设 `SEALED_KEY_DIR` 时,引擎回落到数据根下的 `sealed-key/`(数据根自身还有一条回落链)。那是引擎内部行为,安装器不依赖它:安装契约是显式设绝对路径。
|
|
40
|
+
声明的目录建不了保管店 ⇒ 起服拒;回落目录建不了只告警、sealed 模型逐个失败 —— 显式声明响得更早。
|
|
41
|
+
|
|
42
|
+
## 这份数据还没覆盖的
|
|
43
|
+
|
|
44
|
+
本版只覆盖车道、沙箱 RBAC、钥匙保管目录三类。全局必填配置(例如多租户部署的 `REQUIRE_PRINCIPAL=true`)、快照桶、SQL 表列形、缓存卷要求的持久店后端、其余配置交叉约束,
|
|
45
|
+
仍以引擎起服时的拒启判据与 server 的部署前置文档为准 —— 失败照样响亮,只是要到起服时才知道,装之前查不出来。
|
|
46
|
+
|
|
47
|
+
## 变更
|
|
48
|
+
|
|
49
|
+
<!-- @generated-begin facts-changes -->
|
|
50
|
+
本节由形变登记表生成(与 `CHANGES.json` 同源,仓内门禁保证逐字一致),不要手改。
|
|
51
|
+
|
|
52
|
+
| 版本 | 文件 | 种类 | 指针 | 为什么 |
|
|
53
|
+
| --- | --- | --- | --- | --- |
|
|
54
|
+
| 7.146.0 | `lanes` | introduced | `""`(整份) | 首发:每条执行车道的租户档、隔离位与必需键,行集 = 所依 settings-schema 的全部车道词 |
|
|
55
|
+
| 7.146.0 | `sandbox-rbac` | introduced | `""`(整份) | 首发:k8s 沙箱服务账号的 RBAC 规则表(每条规则何时授、引擎真调还是兼容保留) |
|
|
56
|
+
| 7.146.0 | `sealed-key` | introduced | `""`(整份) | 首发:钥匙保管目录的安装契约(显式绝对 SEALED_KEY_DIR、整个目录跨重启持久且各副本共享、目录与文件的权限位) |
|
|
57
|
+
<!-- @generated-end facts-changes -->
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"lanes": [
|
|
4
|
+
{
|
|
5
|
+
"lane": "host",
|
|
6
|
+
"tenantSeparation": "single-user-only",
|
|
7
|
+
"isolation": "unsupported",
|
|
8
|
+
"requiredEnv": [],
|
|
9
|
+
"requiredSecretEnv": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"lane": "e2b",
|
|
13
|
+
"tenantSeparation": "supported",
|
|
14
|
+
"isolation": "supported",
|
|
15
|
+
"requiredEnv": [],
|
|
16
|
+
"requiredSecretEnv": ["E2B_API_KEY"]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"lane": "k8s",
|
|
20
|
+
"tenantSeparation": "supported",
|
|
21
|
+
"isolation": "supported",
|
|
22
|
+
"requiredEnv": ["K8S_SANDBOX_IMAGE", "K8S_NAMESPACE"],
|
|
23
|
+
"requiredSecretEnv": []
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"lane": "ssh",
|
|
27
|
+
"tenantSeparation": "single-user-only",
|
|
28
|
+
"isolation": "unsupported",
|
|
29
|
+
"requiredEnv": ["SSH_HOST", "SSH_USER"],
|
|
30
|
+
"requiredSecretEnv": ["SSH_PRIVATE_KEY"]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"lane": "adb",
|
|
34
|
+
"tenantSeparation": "single-user-only",
|
|
35
|
+
"isolation": "unsupported",
|
|
36
|
+
"requiredEnv": ["ADB_SERIAL"],
|
|
37
|
+
"requiredSecretEnv": []
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"lane": "local-docker",
|
|
41
|
+
"tenantSeparation": "supported",
|
|
42
|
+
"isolation": "supported",
|
|
43
|
+
"requiredEnv": ["DOCKER_IMAGE"],
|
|
44
|
+
"requiredSecretEnv": []
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"lane": "device",
|
|
48
|
+
"tenantSeparation": "supported",
|
|
49
|
+
"isolation": "unsupported",
|
|
50
|
+
"requiredEnv": ["DEVICE_RELAY_URL"],
|
|
51
|
+
"requiredSecretEnv": []
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "引擎的执行车道事实:每条车道分不分租户、手跑在不在 OS 级隔离边界里、选它时引擎起服必须读到的键。行集 = 本包所依 settings-schema 车道表的全部车道词(含没有安装器接线的车道)。",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["schemaVersion", "lanes"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": {
|
|
9
|
+
"type": "integer",
|
|
10
|
+
"const": 1,
|
|
11
|
+
"description": "本份数据的形版本;读方不认识的版本整份拒读。"
|
|
12
|
+
},
|
|
13
|
+
"lanes": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"minItems": 1,
|
|
16
|
+
"x-uniqueKey": ["lane"],
|
|
17
|
+
"description": "每条车道一行,行序 = 车道表次序。",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"required": ["lane", "tenantSeparation", "isolation", "requiredEnv", "requiredSecretEnv"],
|
|
22
|
+
"properties": {
|
|
23
|
+
"lane": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "车道词,即 REMOTE_EXEC 的取值。"
|
|
26
|
+
},
|
|
27
|
+
"tenantSeparation": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"enum": ["supported", "single-user-only"],
|
|
30
|
+
"description": "supported = 可在多租户部署(REQUIRE_PRINCIPAL=true)上用;single-user-only = 只给单用户部署,多租户部署选它起服即拒。"
|
|
31
|
+
},
|
|
32
|
+
"isolation": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["supported", "unsupported"],
|
|
35
|
+
"description": "supported = 手跑在 OS 级隔离边界里(独立沙箱);unsupported = 手跑在没有 OS 级隔离的地方(服务容器本身、远端主机、设备)。"
|
|
36
|
+
},
|
|
37
|
+
"requiredEnv": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"uniqueItems": true,
|
|
40
|
+
"items": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"description": "选这条车道时引擎起服必须读到的非密键(缺任一 ⇒ 起服拒)。"
|
|
44
|
+
},
|
|
45
|
+
"requiredSecretEnv": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"uniqueItems": true,
|
|
48
|
+
"items": {
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
"description": "选这条车道时引擎起服必须读到的密钥键(缺任一 ⇒ 起服拒;值由运维自备)。"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"rules": [
|
|
4
|
+
{
|
|
5
|
+
"scope": "Role",
|
|
6
|
+
"apiGroups": [""],
|
|
7
|
+
"resources": ["pods"],
|
|
8
|
+
"verbs": ["get", "list", "create", "delete"],
|
|
9
|
+
"when": "always",
|
|
10
|
+
"need": "called",
|
|
11
|
+
"why": "沙箱 pod 的生命周期:remote-env-k8s.ts#createPod 建(POST pods)并读就绪(GET pods/<名>)· remote-env-k8s.ts#listSandboxPods 按标签列(GET pods?labelSelector)· remote-env-k8s.ts#reconnect 读存活(GET pods/<名>)· remote-env-k8s.ts#deletePod 删(DELETE pods/<名>)"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"scope": "Role",
|
|
15
|
+
"apiGroups": [""],
|
|
16
|
+
"resources": ["pods"],
|
|
17
|
+
"verbs": ["watch"],
|
|
18
|
+
"when": "always",
|
|
19
|
+
"need": "retained",
|
|
20
|
+
"why": "兼容保留:chart 一直授着,适配器没有 watch 调用"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"scope": "Role",
|
|
24
|
+
"apiGroups": [""],
|
|
25
|
+
"resources": ["pods/exec"],
|
|
26
|
+
"verbs": ["create", "get"],
|
|
27
|
+
"when": "always",
|
|
28
|
+
"need": "called",
|
|
29
|
+
"why": "在沙箱 pod 里执行命令:remote-env-k8s.ts#execUrl 拼 pods/<名>/exec 的连接地址"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"scope": "Role",
|
|
33
|
+
"apiGroups": [""],
|
|
34
|
+
"resources": ["pods/attach"],
|
|
35
|
+
"verbs": ["create", "get"],
|
|
36
|
+
"when": "always",
|
|
37
|
+
"need": "retained",
|
|
38
|
+
"why": "兼容保留:chart 一直授着,适配器没有 attach 调用"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"scope": "Role",
|
|
42
|
+
"apiGroups": [""],
|
|
43
|
+
"resources": ["pods/log"],
|
|
44
|
+
"verbs": ["get"],
|
|
45
|
+
"when": "always",
|
|
46
|
+
"need": "retained",
|
|
47
|
+
"why": "兼容保留:chart 一直授着,适配器没有读日志的调用"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"scope": "Role",
|
|
51
|
+
"apiGroups": [""],
|
|
52
|
+
"resources": ["persistentvolumeclaims"],
|
|
53
|
+
"verbs": ["get", "create", "deletecollection"],
|
|
54
|
+
"when": "WORKSPACE_CACHE=volume",
|
|
55
|
+
"need": "called",
|
|
56
|
+
"why": "按工作区空间的构建缓存卷:remote-env-k8s.ts#ensureCacheClaim 按名读、没有就建(GET / POST persistentvolumeclaims)· remote-env-k8s.ts#cacheClaimBound 按名读 · remote-env-k8s.ts#reclaimSpaceCache 空间结束按标签回收(DELETE persistentvolumeclaims?labelSelector = deletecollection);缺它 ⇒ 缓存卷拿不到,适配器按 fail-open 照起、不挂卷(计数 server.workspace-cache.unavailable)"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"scope": "Role",
|
|
60
|
+
"apiGroups": [""],
|
|
61
|
+
"resources": ["persistentvolumeclaims"],
|
|
62
|
+
"verbs": ["delete"],
|
|
63
|
+
"when": "WORKSPACE_CACHE=volume",
|
|
64
|
+
"need": "retained",
|
|
65
|
+
"why": "兼容保留:chart 一直授着,适配器回收只发按标签的 deletecollection,没有按名 delete 的调用"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"scope": "Role",
|
|
69
|
+
"apiGroups": [""],
|
|
70
|
+
"resources": ["secrets"],
|
|
71
|
+
"verbs": ["create"],
|
|
72
|
+
"when": "K8S_SANDBOX_ENV",
|
|
73
|
+
"need": "called",
|
|
74
|
+
"why": "沙箱秘密座:动词取自 SANDBOX_SECRET_SEAT_VERBS.env —— 起服门(boot/execution-env.ts ensureSandboxSecretSeat)问的与 remote-env-k8s.ts#createOwnedSecret 为 env Secret 真发的(POST secrets)是同一行;起服门只在有效转发集合非空(名单点到的键在服务进程环境里有值)时问:答 denied ⇒ server 起服拒,问不到 ⇒ 告警 sandbox_secret_seat_unverified 照起;名单非空而有效集合为空时本行是保守多授(安装器看不到服务进程的运行时环境,引擎此时既不问也不调)"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"scope": "Role",
|
|
78
|
+
"apiGroups": ["networking.k8s.io"],
|
|
79
|
+
"resources": ["networkpolicies"],
|
|
80
|
+
"verbs": ["list"],
|
|
81
|
+
"when": "always",
|
|
82
|
+
"need": "called",
|
|
83
|
+
"why": "起服的出网自检读本 ns 的 NetworkPolicy 集合:remote-env-k8s.ts#egressPolicyGaps(GET .../networkpolicies)"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"scope": "Role",
|
|
87
|
+
"apiGroups": ["networking.k8s.io"],
|
|
88
|
+
"resources": ["networkpolicies"],
|
|
89
|
+
"verbs": ["get"],
|
|
90
|
+
"when": "always",
|
|
91
|
+
"need": "retained",
|
|
92
|
+
"why": "兼容保留:chart 一直授着,适配器只读集合(list),没有按名 get"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"scope": "ClusterRole",
|
|
96
|
+
"apiGroups": [""],
|
|
97
|
+
"resources": ["nodes"],
|
|
98
|
+
"verbs": ["list"],
|
|
99
|
+
"when": "always",
|
|
100
|
+
"need": "called",
|
|
101
|
+
"why": "出网自检读节点表(节点是集群级对象 ⇒ ClusterRole + Binding 给同一只服务账号):remote-env-k8s.ts#egressPolicyGaps(GET /api/v1/nodes)"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"scope": "ClusterRole",
|
|
105
|
+
"apiGroups": [""],
|
|
106
|
+
"resources": ["nodes"],
|
|
107
|
+
"verbs": ["get"],
|
|
108
|
+
"when": "always",
|
|
109
|
+
"need": "retained",
|
|
110
|
+
"why": "兼容保留:chart 一直授着,适配器只读集合(list),没有按名 get"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "k8s 沙箱车道(REMOTE_EXEC=k8s)的服务账号在沙箱命名空间 / 集群里需要的 RBAC 规则;每条规则何时授、引擎适配器真调还是兼容保留。",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["schemaVersion", "rules"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": {
|
|
9
|
+
"type": "integer",
|
|
10
|
+
"const": 1,
|
|
11
|
+
"description": "本份数据的形版本;读方不认识的版本整份拒读。"
|
|
12
|
+
},
|
|
13
|
+
"rules": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"minItems": 1,
|
|
16
|
+
"x-uniqueKey": ["scope", "apiGroups", "resources", "need"],
|
|
17
|
+
"description": "规则行;同一资源的动词按 need 拆成两行,授权时并回一条规则(Kubernetes 对同一资源的多条规则取并集)。",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"required": ["scope", "apiGroups", "resources", "verbs", "when", "need", "why"],
|
|
22
|
+
"properties": {
|
|
23
|
+
"scope": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"enum": ["Role", "ClusterRole"],
|
|
26
|
+
"description": "Role = 沙箱命名空间里的 Role;ClusterRole = 集群级对象(节点)要的 ClusterRole,绑给同一只服务账号。"
|
|
27
|
+
},
|
|
28
|
+
"apiGroups": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"minItems": 1,
|
|
31
|
+
"uniqueItems": true,
|
|
32
|
+
"items": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"description": "API 组;核心组写空串。"
|
|
36
|
+
},
|
|
37
|
+
"resources": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"minItems": 1,
|
|
40
|
+
"uniqueItems": true,
|
|
41
|
+
"items": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
44
|
+
"description": "资源名(子资源写 pods/exec 这种形)。"
|
|
45
|
+
},
|
|
46
|
+
"verbs": {
|
|
47
|
+
"type": "array",
|
|
48
|
+
"minItems": 1,
|
|
49
|
+
"uniqueItems": true,
|
|
50
|
+
"items": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"enum": ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"]
|
|
53
|
+
},
|
|
54
|
+
"description": "动词。"
|
|
55
|
+
},
|
|
56
|
+
"when": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"enum": ["always", "WORKSPACE_CACHE=volume", "K8S_SANDBOX_ENV"],
|
|
59
|
+
"description": "always = 恒授;WORKSPACE_CACHE=volume = 引擎开着按工作区空间的缓存卷时授(引擎用到它的条件同一个);K8S_SANDBOX_ENV = 引擎的沙箱 env 名单非空时授 —— 这是保守的授权条件,引擎真正问 / 调用的条件是名单点到的键在服务进程环境里有值,两者之差写在该行 why 里。"
|
|
60
|
+
},
|
|
61
|
+
"need": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"enum": ["called", "retained"],
|
|
64
|
+
"description": "called = 引擎适配器源码真发这些调用;retained = 随包 chart 一直授着、适配器源码里零调用(兼容保留)。"
|
|
65
|
+
},
|
|
66
|
+
"why": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"description": "这一行为什么在(called 行写着调用它的适配器方法)。"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"dirEnv": "SEALED_KEY_DIR",
|
|
4
|
+
"dirPath": "absolute",
|
|
5
|
+
"subdirs": ["checkpoint-ctx-keys"],
|
|
6
|
+
"dirMode": "0700",
|
|
7
|
+
"fileMode": "0600",
|
|
8
|
+
"requirements": ["persist-across-restart", "shared-by-all-replicas", "writable", "whole-directory"]
|
|
9
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "引擎钥匙保管目录的安装契约:sealed 形模型钥匙的 X25519 钥匙对与停驻行凭据封签的钥匙都在这个目录里,私钥只存在这里。",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["schemaVersion", "dirEnv", "dirPath", "subdirs", "dirMode", "fileMode", "requirements"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": {
|
|
9
|
+
"type": "integer",
|
|
10
|
+
"const": 1,
|
|
11
|
+
"description": "本份数据的形版本;读方不认识的版本整份拒读。"
|
|
12
|
+
},
|
|
13
|
+
"dirEnv": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"const": "SEALED_KEY_DIR",
|
|
16
|
+
"description": "安装器必须给引擎设的环境变量:值 = 保管目录的挂载位。"
|
|
17
|
+
},
|
|
18
|
+
"dirPath": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["absolute"],
|
|
21
|
+
"description": "absolute = 值必须是绝对路径(相对路径起服即拒;设了而目录建不了保管店也起服拒)。"
|
|
22
|
+
},
|
|
23
|
+
"subdirs": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"uniqueItems": true,
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"description": "引擎在保管目录之下自建的子目录(随目录一起持久、一起共享)。"
|
|
30
|
+
},
|
|
31
|
+
"dirMode": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"const": "0700",
|
|
34
|
+
"description": "引擎每次起服把保管目录设成的权限位(四位八进制);目录必须允许引擎进程改它的权限。"
|
|
35
|
+
},
|
|
36
|
+
"fileMode": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"const": "0600",
|
|
39
|
+
"description": "引擎写钥匙文件时设的权限位(四位八进制)。"
|
|
40
|
+
},
|
|
41
|
+
"requirements": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"minItems": 1,
|
|
44
|
+
"uniqueItems": true,
|
|
45
|
+
"items": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"enum": ["persist-across-restart", "shared-by-all-replicas", "writable", "whole-directory"]
|
|
48
|
+
},
|
|
49
|
+
"description": "persist-across-restart = 目录跨进程重启保留(不然重启后封给旧钥匙的密文与停驻行凭据开不开);shared-by-all-replicas = 同一部署的每个副本挂同一份目录(多副本要支持多处读写的存储;不然 A 副本封的东西 B 副本开不开);writable = 引擎对目录可写(空目录起服时生成一把钥匙;只读挂载 ⇒ 建不了保管店);whole-directory = 持久与共享的单位是整个目录,含 subdirs 列出的子目录。"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -127,3 +127,22 @@ volumes:
|
|
|
127
127
|
persistentVolumeClaim: { claimName: {{ include "sema.sealedKey.claimName" . }} }
|
|
128
128
|
{{- end -}}
|
|
129
129
|
{{- end -}}
|
|
130
|
+
|
|
131
|
+
{{- /*
|
|
132
|
+
沙箱特性开关(`sandbox.workspaceCacheVolume` ↔ 引擎 WORKSPACE_CACHE=volume;`sandbox.sandboxEnv` ↔ 引擎 K8S_SANDBOX_ENV):
|
|
133
|
+
同一个 chart 值既决定沙箱 Role 带不带对应规则(`sandbox-rbac.yaml`),又写引擎旋钮(下面的 `sema.sandbox.switchEnv`)—— 两处不再各写一份。
|
|
134
|
+
判开关的 `sema.sandbox.switchOn` 定义在 `sandbox-rbac.yaml` 里(那份模板整份被取用方拷走,所以它自带自己用到的助手,不依赖本文件);本文件的 `switchEnv` 与它共用同一个定义。
|
|
135
|
+
「哪条规则由哪个开关决定」与开关的值路径 / 引擎旋钮的书写处只有 server 源码里的规则表 `src/sandbox-rbac-rules.ts`;`switchEnv` 的体与 `sandbox-rbac.yaml` 里的条件由 scripts/gen-deploy-lanes.ts 从它生成。
|
|
136
|
+
*/ -}}
|
|
137
|
+
|
|
138
|
+
{{- /* worker 容器 env 里的沙箱特性开关旋钮(`indent 12` 之后接在 env 列表里;体由生成器从规则表渲出);两个开关都关 ⇒ 什么都不出。 */ -}}
|
|
139
|
+
{{- define "sema.sandbox.switchEnv" -}}
|
|
140
|
+
{{/* @generated-begin sandbox-switch-env */}}
|
|
141
|
+
{{- if eq (include "sema.sandbox.switchOn" (list . "workspaceCacheVolume" "bool")) "true" }}
|
|
142
|
+
- { name: WORKSPACE_CACHE, value: "volume" }
|
|
143
|
+
{{- end }}
|
|
144
|
+
{{- if eq (include "sema.sandbox.switchOn" (list . "sandboxEnv" "names")) "true" }}
|
|
145
|
+
- { name: K8S_SANDBOX_ENV, value: {{ .Values.sandbox.sandboxEnv | quote }} }
|
|
146
|
+
{{- end }}
|
|
147
|
+
{{/* @generated-end sandbox-switch-env */}}
|
|
148
|
+
{{- end -}}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
{{- /*
|
|
2
|
+
沙箱特性开关的判官(本文件的规则条件与 _helpers.tpl 里的 `sema.sandbox.switchEnv` 共用):实参是 `list <根上下文> <sandbox 下的键> <形>`,输出 "true" / "false":
|
|
3
|
+
· 形 `bool`:**只收布尔**(`--set-string …=false` / 带引号的 "false" 是字符串,模板里字符串恒为真 ⇒ 会静默授出规则,所以非布尔渲染即拒;键缺席也拒 —— 把本模板整份拷进别的 chart 的人要在自己的 values 里补这个键);
|
|
4
|
+
· 形 `names`:**只收字符串**,去掉首尾空白后非空 = 开(引擎旋钮是 NAME,NAME 名单;形错由引擎起服拒,不在这里重判)。
|
|
5
|
+
定义放在本文件里而不放 `_helpers.tpl`:本模板整份被取用方原样拷走,它用到的助手必须随它走。
|
|
6
|
+
*/ -}}
|
|
7
|
+
{{- define "sema.sandbox.switchOn" -}}
|
|
8
|
+
{{- $root := index . 0 -}}
|
|
9
|
+
{{- $key := index . 1 -}}
|
|
10
|
+
{{- $kind := index . 2 -}}
|
|
11
|
+
{{- $v := index $root.Values.sandbox $key -}}
|
|
12
|
+
{{- if eq $kind "bool" -}}
|
|
13
|
+
{{- if not (kindIs "bool" $v) -}}
|
|
14
|
+
{{- fail (printf "sandbox.%s must be a boolean (true or false), got %s %q — a string such as \"false\" is truthy in a template and would silently grant the rule" $key (kindOf $v) (toString $v)) -}}
|
|
15
|
+
{{- end -}}
|
|
16
|
+
{{- $v -}}
|
|
17
|
+
{{- else -}}
|
|
18
|
+
{{- if not (kindIs "string" $v) -}}
|
|
19
|
+
{{- fail (printf "sandbox.%s must be a string (a NAME,NAME list; empty = off), got %s %q" $key (kindOf $v) (toString $v)) -}}
|
|
20
|
+
{{- end -}}
|
|
21
|
+
{{- if ne (trim $v) "" -}}true{{- else -}}false{{- end -}}
|
|
22
|
+
{{- end -}}
|
|
23
|
+
{{- end -}}
|
|
24
|
+
# ── 沙箱 lane RBAC(k8s+kata):pod 生命周期 / exec / log、出网自检的两只只读(本 ns 的 NetworkPolicy、集群的节点表)恒授;
|
|
25
|
+
# 缓存卷的 persistentvolumeclaims 与沙箱秘密座的 secrets create 只在对应特性开关开着时授(sandbox.workspaceCacheVolume / sandbox.sandboxEnv)。
|
|
26
|
+
# 「哪条规则由哪个开关决定」只写在 server 源码的规则表 src/sandbox-rbac-rules.ts;下面两个规则区由 scripts/gen-deploy-lanes.ts 从它生成,不要手改。────────────────────────────────
|
|
2
27
|
apiVersion: v1
|
|
3
28
|
kind: ServiceAccount
|
|
4
29
|
metadata:
|
|
@@ -20,29 +45,40 @@ metadata:
|
|
|
20
45
|
name: sema-runner
|
|
21
46
|
namespace: {{ .Values.sandbox.namespace }}
|
|
22
47
|
rules:
|
|
48
|
+
{{/* @generated-begin sandbox-role-rules */}}
|
|
49
|
+
# 沙箱 pod 的生命周期:remote-env-k8s.ts#createPod 建(POST pods)并读就绪(GET pods/<名>)· remote-env-k8s.ts#listSandboxPods 按标签列(GET pods?labelSelector)· remote-env-k8s.ts#reconnect 读存活(GET pods/<名>)· remote-env-k8s.ts#deletePod 删(DELETE pods/<名>)
|
|
50
|
+
# 兼容保留:chart 一直授着,适配器没有 watch 调用
|
|
23
51
|
- apiGroups: [""]
|
|
24
52
|
resources: [pods]
|
|
25
53
|
verbs: [get, list, watch, create, delete]
|
|
54
|
+
# 在沙箱 pod 里执行命令:remote-env-k8s.ts#execUrl 拼 pods/<名>/exec 的连接地址
|
|
55
|
+
# 兼容保留:chart 一直授着,适配器没有 attach 调用
|
|
26
56
|
- apiGroups: [""]
|
|
27
57
|
resources: [pods/exec, pods/attach]
|
|
28
|
-
verbs: [
|
|
58
|
+
verbs: [get, create]
|
|
59
|
+
# 兼容保留:chart 一直授着,适配器没有读日志的调用
|
|
29
60
|
- apiGroups: [""]
|
|
30
61
|
resources: [pods/log]
|
|
31
62
|
verbs: [get]
|
|
32
|
-
|
|
63
|
+
{{- if eq (include "sema.sandbox.switchOn" (list . "workspaceCacheVolume" "bool")) "true" }}
|
|
64
|
+
# 按工作区空间的构建缓存卷:remote-env-k8s.ts#ensureCacheClaim 按名读、没有就建(GET / POST persistentvolumeclaims)· remote-env-k8s.ts#cacheClaimBound 按名读 · remote-env-k8s.ts#reclaimSpaceCache 空间结束按标签回收(DELETE persistentvolumeclaims?labelSelector = deletecollection);缺它 ⇒ 缓存卷拿不到,适配器按 fail-open 照起、不挂卷(计数 server.workspace-cache.unavailable)
|
|
65
|
+
# 兼容保留:chart 一直授着,适配器回收只发按标签的 deletecollection,没有按名 delete 的调用
|
|
33
66
|
- apiGroups: [""]
|
|
34
67
|
resources: [persistentvolumeclaims]
|
|
35
68
|
verbs: [get, create, delete, deletecollection]
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
#
|
|
69
|
+
{{- end }}
|
|
70
|
+
{{- if eq (include "sema.sandbox.switchOn" (list . "sandboxEnv" "names")) "true" }}
|
|
71
|
+
# 沙箱秘密座:动词取自 SANDBOX_SECRET_SEAT_VERBS.env —— 起服门(boot/execution-env.ts ensureSandboxSecretSeat)问的与 remote-env-k8s.ts#createOwnedSecret 为 env Secret 真发的(POST secrets)是同一行;起服门只在有效转发集合非空(名单点到的键在服务进程环境里有值)时问:答 denied ⇒ server 起服拒,问不到 ⇒ 告警 sandbox_secret_seat_unverified 照起;名单非空而有效集合为空时本行是保守多授(安装器看不到服务进程的运行时环境,引擎此时既不问也不调)
|
|
39
72
|
- apiGroups: [""]
|
|
40
73
|
resources: [secrets]
|
|
41
74
|
verbs: [create]
|
|
42
|
-
|
|
75
|
+
{{- end }}
|
|
76
|
+
# 起服的出网自检读本 ns 的 NetworkPolicy 集合:remote-env-k8s.ts#egressPolicyGaps(GET .../networkpolicies)
|
|
77
|
+
# 兼容保留:chart 一直授着,适配器只读集合(list),没有按名 get
|
|
43
78
|
- apiGroups: [networking.k8s.io]
|
|
44
79
|
resources: [networkpolicies]
|
|
45
80
|
verbs: [get, list]
|
|
81
|
+
{{/* @generated-end sandbox-role-rules */}}
|
|
46
82
|
---
|
|
47
83
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
48
84
|
kind: RoleBinding
|
|
@@ -64,9 +100,13 @@ kind: ClusterRole
|
|
|
64
100
|
metadata:
|
|
65
101
|
name: sema-runner-nodes-{{ .Values.sandbox.namespace }}
|
|
66
102
|
rules:
|
|
103
|
+
{{/* @generated-begin sandbox-clusterrole-rules */}}
|
|
104
|
+
# 出网自检读节点表(节点是集群级对象 ⇒ ClusterRole + Binding 给同一只服务账号):remote-env-k8s.ts#egressPolicyGaps(GET /api/v1/nodes)
|
|
105
|
+
# 兼容保留:chart 一直授着,适配器只读集合(list),没有按名 get
|
|
67
106
|
- apiGroups: [""]
|
|
68
107
|
resources: [nodes]
|
|
69
108
|
verbs: [get, list]
|
|
109
|
+
{{/* @generated-end sandbox-clusterrole-rules */}}
|
|
70
110
|
---
|
|
71
111
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
72
112
|
kind: ClusterRoleBinding
|
|
@@ -77,6 +77,10 @@ spec:
|
|
|
77
77
|
- { name: K8S_RUNTIME_CLASS, value: {{ .Values.sandbox.runtimeClass }} }
|
|
78
78
|
- { name: K8S_SANDBOX_IMAGE, value: {{ .Values.sandbox.image | quote }} }
|
|
79
79
|
- { name: K8S_SANDBOX_IPV6, value: {{ .Values.sandbox.ipv6 | quote }} }
|
|
80
|
+
{{- /* 沙箱特性开关(sandbox.workspaceCacheVolume / sandbox.sandboxEnv)同一个值写引擎旋钮与沙箱 Role 规则,见 _helpers.tpl。 */}}
|
|
81
|
+
{{- with (include "sema.sandbox.switchEnv" . | trim) }}
|
|
82
|
+
{{ . | indent 12 }}
|
|
83
|
+
{{- end }}
|
|
80
84
|
- { name: K8S_TOKEN, valueFrom: { secretKeyRef: { name: sema-runner-token-copy, key: token } } }
|
|
81
85
|
{{- /* 耐久审批的显式表态与停驻封签钥匙卷同源(助手 sema.durableApproval / sema.sealedKey.*,见 _helpers.tpl):关持久 ⇒ 显式 false;留空 ⇒ 不渲。 */}}
|
|
82
86
|
{{- with (include "sema.sealedKey.env" .) }}
|
|
@@ -90,6 +90,10 @@ spec:
|
|
|
90
90
|
{{- end }}
|
|
91
91
|
- { name: K8S_SANDBOX_IMAGE, value: {{ .Values.sandbox.image | quote }} }
|
|
92
92
|
- { name: K8S_SANDBOX_IPV6, value: {{ .Values.sandbox.ipv6 | quote }} }
|
|
93
|
+
{{- /* 沙箱特性开关(sandbox.workspaceCacheVolume / sandbox.sandboxEnv)同一个值写引擎旋钮与沙箱 Role 规则,见 _helpers.tpl。 */}}
|
|
94
|
+
{{- with (include "sema.sandbox.switchEnv" . | trim) }}
|
|
95
|
+
{{ . | indent 12 }}
|
|
96
|
+
{{- end }}
|
|
93
97
|
- { name: K8S_TOKEN, valueFrom: { secretKeyRef: { name: sema-runner-token-copy, key: token } } }
|
|
94
98
|
{{- /* 耐久审批的显式表态与停驻封签钥匙卷同源(助手 sema.durableApproval / sema.sealedKey.*,见 _helpers.tpl):关持久 ⇒ 显式 false;留空 ⇒ 不渲。 */}}
|
|
95
99
|
{{- with (include "sema.sealedKey.env" .) }}
|
|
@@ -149,6 +149,13 @@ sandbox:
|
|
|
149
149
|
# 每个节点的 kubelet 要 --allowed-unsafe-sysctls 点名它们,否则沙箱 pod 起不来;沙箱 ns 不能 enforce PodSecurity baseline。
|
|
150
150
|
# enabled = 不动 pod(缺省):只执行 IPv4 的出网策略(k3s 单栈缺省即是)管不到 pod 的 IPv6,server 起服每次一行提醒。
|
|
151
151
|
ipv6: enabled
|
|
152
|
+
# 沙箱特性开关 —— 同一个值既写引擎旋钮、又决定沙箱 Role 带不带对应规则(「哪条规则由哪个开关决定」只写在 server 源码的规则表 src/sandbox-rbac-rules.ts):
|
|
153
|
+
# workspaceCacheVolume(布尔,只收 true / false)= 按工作区空间的构建缓存卷:true ⇒ 引擎 env WORKSPACE_CACHE=volume,Role 加 persistentvolumeclaims 的
|
|
154
|
+
# get / create / delete / deletecollection;false(缺省)⇒ 引擎不建卷、Role 不授这四个动词。前提:集群有缺省 StorageClass、引擎有存储后端(本 chart 恒有 PG)。
|
|
155
|
+
# sandboxEnv(名单字符串 NAME,NAME)= 沙箱带外 env 名单:非空 ⇒ 引擎 env K8S_SANDBOX_ENV=<名单>,Role 加 secrets 的 create;空(缺省)⇒ 都不加。
|
|
156
|
+
# 名单点到的键的**值**要在引擎进程的环境里(本 chart 不替部署提供值的来源);点到而环境里没有的键不转发。
|
|
157
|
+
workspaceCacheVolume: false
|
|
158
|
+
sandboxEnv: ""
|
|
152
159
|
# 沙箱出网策略(NetworkPolicy,egress 白名单;要集群 CNI 带 NetworkPolicy 控制器 —— k3s 缺省自带):
|
|
153
160
|
# 放行 = DNS(kube-dns)+ 对象存储(chart 自带的 MinIO 9000,加 objectStore 点名的脸)+ IPv4 公网面;
|
|
154
161
|
# 拒 = 私网 / 共享 / 链路本地 / 环回六段(10/8、172.16/12、192.168/16、100.64/10、169.254/16、127/8)整段,
|