@lqc123qwe/car-runtime 1.8.0 → 1.10.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/README.md +29 -1
- package/dist/SHA256SUMS +1 -0
- package/dist/authz/authz.d.ts +44 -0
- package/dist/authz/authz.js +65 -0
- package/dist/car-runtime-1.10.0.tgz +0 -0
- package/dist/car-runtime-1.10.0.tgz.sig.bundle +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +825 -0
- package/dist/dx/doctor.d.ts +62 -0
- package/dist/dx/doctor.js +127 -0
- package/dist/governance/dump.d.ts +47 -0
- package/dist/governance/dump.js +17 -0
- package/dist/host/facade.d.ts +13 -0
- package/dist/host/facade.js +154 -0
- package/dist/host/hostGateway.d.ts +117 -0
- package/dist/host/hostGateway.js +65 -0
- package/dist/host/mappings.d.ts +27 -0
- package/dist/host/mappings.js +52 -0
- package/dist/host/stdio.d.ts +14 -0
- package/dist/host/stdio.js +83 -0
- package/dist/kernel/context.d.ts +76 -0
- package/dist/kernel/context.js +203 -0
- package/dist/kernel/events.d.ts +37 -0
- package/dist/kernel/events.js +82 -0
- package/dist/load/config.d.ts +79 -0
- package/dist/load/config.js +285 -0
- package/dist/load/loader.d.ts +72 -0
- package/dist/load/loader.js +162 -0
- package/dist/load/registry.d.ts +44 -0
- package/dist/load/registry.js +58 -0
- package/dist/load/report.d.ts +98 -0
- package/dist/load/report.js +301 -0
- package/dist/load/sigGate.d.ts +22 -0
- package/dist/load/sigGate.js +68 -0
- package/dist/load/sign.d.ts +25 -0
- package/dist/load/sign.js +47 -0
- package/dist/load/verifier.d.ts +35 -0
- package/dist/load/verifier.js +56 -0
- package/dist/loop/goal.d.ts +31 -0
- package/dist/loop/goal.js +34 -0
- package/dist/loop/recover.d.ts +17 -0
- package/dist/loop/recover.js +39 -0
- package/dist/loop/stop.d.ts +79 -0
- package/dist/loop/stop.js +151 -0
- package/dist/mcp/gateway.d.ts +96 -0
- package/dist/mcp/gateway.js +69 -0
- package/dist/mcp/httpClient.d.ts +27 -0
- package/dist/mcp/httpClient.js +196 -0
- package/dist/mcp/stdioClient.d.ts +8 -0
- package/dist/mcp/stdioClient.js +73 -0
- package/dist/ptc/budget.d.ts +21 -0
- package/dist/ptc/budget.js +36 -0
- package/dist/ptc/erasable.d.ts +14 -0
- package/dist/ptc/erasable.js +27 -0
- package/dist/ptc/runCode.d.ts +65 -0
- package/dist/ptc/runCode.js +140 -0
- package/dist/ptc/schemaRender.d.ts +15 -0
- package/dist/ptc/schemaRender.js +90 -0
- package/dist/ptc/sdk.d.ts +27 -0
- package/dist/ptc/sdk.js +23 -0
- package/dist/ptc/worker-entry.d.ts +1 -0
- package/dist/ptc/worker-entry.js +71 -0
- package/dist/release-audit.jsonl +4 -0
- package/dist/runtime-core/chatStep.d.ts +40 -0
- package/dist/runtime-core/chatStep.js +104 -0
- package/dist/runtime-core/credentials.d.ts +49 -0
- package/dist/runtime-core/credentials.js +118 -0
- package/dist/runtime-core/errors.d.ts +30 -0
- package/dist/runtime-core/errors.js +36 -0
- package/dist/runtime-core/llm.d.ts +76 -0
- package/dist/runtime-core/llm.js +553 -0
- package/dist/runtime-core/redaction.d.ts +39 -0
- package/dist/runtime-core/redaction.js +79 -0
- package/dist/runtime-core/telemetry.d.ts +88 -0
- package/dist/runtime-core/telemetry.js +332 -0
- package/dist/runtime-core/tools.d.ts +15 -0
- package/dist/runtime-core/tools.js +12 -0
- package/dist/runtime-core/trace.d.ts +55 -0
- package/dist/runtime-core/trace.js +137 -0
- package/dist/runtime-core/types.d.ts +84 -0
- package/dist/runtime-core/types.js +13 -0
- package/dist/sandbox/sandbox.d.ts +68 -0
- package/dist/sandbox/sandbox.js +153 -0
- package/dist/sbom.json +263 -0
- package/dist/seam.d.ts +21 -0
- package/dist/seam.js +20 -0
- package/dist/security/secrets-baseline.d.ts +43 -0
- package/dist/security/secrets-baseline.js +176 -0
- package/dist/security/secrets.d.ts +45 -0
- package/dist/security/secrets.js +138 -0
- package/dist/session/export.d.ts +55 -0
- package/dist/session/export.js +81 -0
- package/dist/session/fork.d.ts +51 -0
- package/dist/session/fork.js +63 -0
- package/dist/session/format.d.ts +21 -0
- package/dist/session/format.js +49 -0
- package/dist/session/indexStore.d.ts +44 -0
- package/dist/session/indexStore.js +265 -0
- package/dist/session/log.d.ts +79 -0
- package/dist/session/log.js +157 -0
- package/dist/session/store.d.ts +9 -0
- package/dist/session/store.js +37 -0
- package/dist/telemetry/metrics.d.ts +25 -0
- package/dist/telemetry/metrics.js +26 -0
- package/package.json +17 -1
- package/src/mcp/gateway.ts +10 -2
- package/src/mcp/httpClient.ts +23 -5
- package/src/runtime-core/trace.ts +5 -0
- package/src/seam.ts +21 -0
- package/.gitattributes +0 -11
- package/.github/workflows/ci.yml +0 -293
- package/.github/workflows/release.yml +0 -54
- package/adr/ADR-001.md +0 -4
- package/adr/ADR-002.md +0 -5
- package/adr/ADR-003.md +0 -35
- package/adr/host-onboarding.md +0 -68
- package/adr/mlps-audit-checklist.md +0 -41
- package/adr/win32-spike.md +0 -45
- package/docs/plugin-authoring.md +0 -82
- package/native/landlock-run/Makefile +0 -19
- package/native/landlock-run/landlock-run.c +0 -162
- package/scripts/contract-check.ts +0 -56
- package/scripts/invariant-n1.ts +0 -96
- package/scripts/package-check.ts +0 -29
- package/scripts/ptc-baseline/run-baseline.ts +0 -118
- package/scripts/release-artifacts.ts +0 -111
- package/scripts/release-pipeline.ts +0 -245
- package/scripts/secrets-baseline.ts +0 -33
- package/scripts/secrets-scan.ts +0 -56
- package/scripts/win32-ffi-debug.ts +0 -143
- package/scripts/win32-koffi-spike.ts +0 -537
- package/test/contract/eventmap.golden.json +0 -7
- package/test/fixtures/hello-plugin.ts +0 -5
- package/test/kernel.spec.ts +0 -136
- package/test/registry-e2e/run-e2e.ts +0 -213
- package/test/s11.spec.ts +0 -129
- package/test/s12.spec.ts +0 -135
- package/test/s13.spec.ts +0 -117
- package/test/s14.spec.ts +0 -117
- package/test/s15.spec.ts +0 -80
- package/test/s16.spec.ts +0 -133
- package/test/s17.spec.ts +0 -102
- package/test/s18.spec.ts +0 -81
- package/test/s19.spec.ts +0 -138
- package/test/s2.spec.ts +0 -245
- package/test/s20.spec.ts +0 -241
- package/test/s21.spec.ts +0 -231
- package/test/s22-m7-store-format.spec.ts +0 -135
- package/test/s23-m7-export-index.spec.ts +0 -189
- package/test/s24-signature-gate.spec.ts +0 -185
- package/test/s25-m8-runtime-core.spec.ts +0 -600
- package/test/s26-signature-closeout.spec.ts +0 -349
- package/test/s27-host-load-wiring.spec.ts +0 -134
- package/test/s28-session-index-followup.spec.ts +0 -236
- package/test/s29-otel-producer.spec.ts +0 -252
- package/test/s3.spec.ts +0 -179
- package/test/s30-release-artifacts.spec.ts +0 -127
- package/test/s31-real-model-wiring.spec.ts +0 -329
- package/test/s32-telemetry-mcp-ptc.spec.ts +0 -218
- package/test/s33-anthropic-adapter.spec.ts +0 -354
- package/test/s34-mcp-remote-transport.spec.ts +0 -250
- package/test/s35-config-ts-zod.spec.ts +0 -145
- package/test/s36-host-tool-surface.spec.ts +0 -250
- package/test/s37-projection-dedupe.spec.ts +0 -161
- package/test/s38-config-jiti.spec.ts +0 -116
- package/test/s39-otlp-span-semantics.spec.ts +0 -100
- package/test/s4.spec.ts +0 -169
- package/test/s40-metrics-cumulative.spec.ts +0 -67
- package/test/s41-mcp-serve-turn-span.spec.ts +0 -148
- package/test/s42-traceparent-propagation.spec.ts +0 -415
- package/test/s5.spec.ts +0 -95
- package/test/s6.spec.ts +0 -169
- package/test/s7.spec.ts +0 -136
- package/test/s7b-baseline.spec.ts +0 -20
- package/test/s9.spec.ts +0 -89
- package/test/sandbox-escape/j17-orchestrate.sh +0 -30
- package/test/sandbox-escape/run-matrix.sh +0 -98
- package/tsconfig.json +0 -18
package/src/mcp/gateway.ts
CHANGED
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
* (MCP `_meta` 保留扩展点——未知键对端忽略,加法无害);仅 otel 显式开且 client span 存活时
|
|
14
14
|
* 非空(trace.ts mcpToolSpan)——**缺省不注入,JSON-RPC 字节面不变**;tools/list 不注入
|
|
15
15
|
* (注册期无 span 上下文,登记)。解析/校验归 trace.ts(parseTraceparent fail-open),本层原样透传。
|
|
16
|
+
*
|
|
17
|
+
* 1.9(D-32 远程 MCP 头通道):callTool 把 opts.traceparent 加法透传给 transport.send 第二参——
|
|
18
|
+
* 载体由传输层自选(HTTP 通道注入 `traceparent` 请求头〔W3C Trace Context 惯例〕;stdio 通道
|
|
19
|
+
* 忽略 opts,`params._meta` 载体不变)。`_meta` 注入口径一字节不动——otel 开时 HTTP 请求
|
|
20
|
+
* 双载体同值(头为主消费面,登记);otel 关时双载体零注入(头面与字节面不变)。
|
|
16
21
|
*/
|
|
17
22
|
export interface JsonRpcRequest { jsonrpc: '2.0'; id: number; method: string; params?: unknown }
|
|
18
23
|
export interface JsonRpcResponse { jsonrpc: '2.0'; id: number; result?: unknown; error?: { code: number; message: string } }
|
|
@@ -20,9 +25,10 @@ export interface JsonRpcResponse { jsonrpc: '2.0'; id: number; result?: unknown;
|
|
|
20
25
|
/**
|
|
21
26
|
* 客户端传输(CAR → MCP Server 方向)。M3-S11 双向分层:本接口为 client 侧对偶;
|
|
22
27
|
* server 侧(宿主 → CAR)见 src/host/hostGateway.ts 的 ServerTransport。
|
|
28
|
+
* 1.9-D32:send 加法可选第二参 opts(既有 `send(req)` 实现结构兼容零改动)。
|
|
23
29
|
*/
|
|
24
30
|
export interface ClientTransport {
|
|
25
|
-
send(req: JsonRpcRequest): Promise<JsonRpcResponse>
|
|
31
|
+
send(req: JsonRpcRequest, opts?: { traceparent?: string }): Promise<JsonRpcResponse>
|
|
26
32
|
/** 进程/通道存活状态 */
|
|
27
33
|
alive(): boolean
|
|
28
34
|
/** 主动终止 */
|
|
@@ -113,10 +119,12 @@ export class McpGateway {
|
|
|
113
119
|
if (!this.#tools.has(key)) return { ok: false, error: `unknown tool "${tool}" on "${serverId}"` }
|
|
114
120
|
try {
|
|
115
121
|
const res = await Promise.race([
|
|
122
|
+
// 1.9-D32:traceparent 加法透传第二参(载体归传输层——HTTP 头 / stdio 忽略);
|
|
123
|
+
// `_meta` 注入 1.8-D29 口径不动(otel 开 = 双载体同值)
|
|
116
124
|
cfg.transport.send({
|
|
117
125
|
jsonrpc: '2.0', id: this.#nextId++, method: 'tools/call',
|
|
118
126
|
params: { name: tool, arguments: args, ...(opts.traceparent ? { _meta: { traceparent: opts.traceparent } } : {}) },
|
|
119
|
-
}),
|
|
127
|
+
}, opts.traceparent ? { traceparent: opts.traceparent } : undefined),
|
|
120
128
|
new Promise<never>((_, rej) => setTimeout(() => rej(new Error('mcp timeout')), opts.timeoutMs ?? 30_000)),
|
|
121
129
|
])
|
|
122
130
|
return { ok: true, result: (res as JsonRpcResponse).result }
|
package/src/mcp/httpClient.ts
CHANGED
|
@@ -14,13 +14,20 @@
|
|
|
14
14
|
* - headers 凭据规则(CR-05 经配置通道执行):值支持 `${ENV_VAR}` 引用(env 缺席显式报错);
|
|
15
15
|
* 字面值疑似明文凭据(containsPlaintextCredential 同款模式)直接拒绝——env 引用注入
|
|
16
16
|
* 才是登记合规通道(展开后值不复查:引注入即目的,展开值是凭据本身);
|
|
17
|
-
* - legacy HTTP+SSE(2024-11-05)不做(1.5 规划 D-21
|
|
17
|
+
* - legacy HTTP+SSE(2024-11-05)不做(1.5 规划 D-21 登记不追溯);
|
|
18
|
+
* - 1.9(D-32 远程 MCP 头通道):send 加法可选第二参 opts.traceparent → tools/call 请求头
|
|
19
|
+
* 加法 `traceparent`(W3C Trace Context HTTP 载体惯例——第三方 OTel 接入面主消费通道);
|
|
20
|
+
* 注入前 parseTraceparent 校验,畸形**不注入不抛**(协议面 fail-open——严格格式天然排除
|
|
21
|
+
* CR/LF,兼防头注入越权面);otel 关 = 双载体零注入(头与 JSON-RPC 字节面不变);
|
|
22
|
+
* initialize/notifications/tools/list 不注入(无 span 上下文——1.8 tools/list 口径延伸);
|
|
23
|
+
* 配置 headers 含字面 `traceparent` 时注入优先(动态 span 上下文为请求级事实,登记)。
|
|
18
24
|
*/
|
|
19
25
|
import { request as httpRequest } from 'node:http'
|
|
20
26
|
import { request as httpsRequest } from 'node:https'
|
|
21
27
|
import type { ClientTransport, JsonRpcRequest, JsonRpcResponse } from './gateway.ts'
|
|
22
28
|
import { containsPlaintextCredential } from './gateway.ts'
|
|
23
29
|
import { assertTlsOrLoopback } from '../runtime-core/llm.ts'
|
|
30
|
+
import { parseTraceparent } from '../runtime-core/trace.ts'
|
|
24
31
|
|
|
25
32
|
export const MCP_PROTOCOL_VERSION = '2025-06-18'
|
|
26
33
|
|
|
@@ -127,8 +134,9 @@ export function createHttpMcpTransport(spec: HttpMcpServerSpec): ClientTransport
|
|
|
127
134
|
throw new Error('CAR-E-MCP: SSE 流结束未见本请求响应(阶段:read-response)')
|
|
128
135
|
}
|
|
129
136
|
|
|
130
|
-
async function postAndRead(body: unknown, matchId: number | null, phase: string): Promise<JsonRpcResponse> {
|
|
131
|
-
|
|
137
|
+
async function postAndRead(body: unknown, matchId: number | null, phase: string, extraHeaders: Record<string, string> = {}): Promise<JsonRpcResponse> {
|
|
138
|
+
// 1.9-D32:extraHeaders 展开在 baseHeaders 之后——配置头同名时注入优先(登记口径)
|
|
139
|
+
const res = await rawPost(spec.url, { ...baseHeaders(), ...extraHeaders }, JSON.stringify(body), timeoutMs)
|
|
132
140
|
const sid = res.headers['mcp-session-id']
|
|
133
141
|
if (typeof sid === 'string') sessionId = sid
|
|
134
142
|
if (res.status < 200 || res.status >= 300) {
|
|
@@ -158,15 +166,25 @@ export function createHttpMcpTransport(spec: HttpMcpServerSpec): ClientTransport
|
|
|
158
166
|
}
|
|
159
167
|
}
|
|
160
168
|
|
|
169
|
+
/**
|
|
170
|
+
* 1.9-D32:tools/call 请求的 `traceparent` 头(W3C Trace Context HTTP 载体惯例)——
|
|
171
|
+
* parseTraceparent 校验 fail-open(畸形/空 = {} 不注入不抛;严格 hex 格式排除 CR/LF 头注入面);
|
|
172
|
+
* 与 body params._meta.traceparent 双载体同值并存(1.8-D29 `_meta` 面维持,头为主消费面)。
|
|
173
|
+
*/
|
|
174
|
+
function callHeaders(tp: string | undefined): Record<string, string> {
|
|
175
|
+
if (!tp || !parseTraceparent(tp)) return {}
|
|
176
|
+
return { traceparent: tp }
|
|
177
|
+
}
|
|
178
|
+
|
|
161
179
|
const transport: ClientTransport = {
|
|
162
|
-
send(req: JsonRpcRequest): Promise<JsonRpcResponse> {
|
|
180
|
+
send(req: JsonRpcRequest, opts?: { traceparent?: string }): Promise<JsonRpcResponse> {
|
|
163
181
|
return (async (): Promise<JsonRpcResponse> => {
|
|
164
182
|
if (closed) throw new Error('CAR-E-MCP: http transport closed(server 已收口)')
|
|
165
183
|
if (!initialized) {
|
|
166
184
|
initPromise ??= doInitialize().then(() => { initialized = true })
|
|
167
185
|
try { await initPromise } catch (e) { initPromise = null; throw e }
|
|
168
186
|
}
|
|
169
|
-
return postAndRead(req, req.id, 'request')
|
|
187
|
+
return postAndRead(req, req.id, 'request', callHeaders(opts?.traceparent))
|
|
170
188
|
})()
|
|
171
189
|
},
|
|
172
190
|
alive: () => !closed,
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
* - ptcRelay(D-31):PTC worker 桥挂链——workerTrace 载荷(traceId/parentSpanId)经 workerData
|
|
30
30
|
* 进隔离体,worker 计时经 done 消息回传后 complete() 主线程单点收口 car.ptc span(facade
|
|
31
31
|
* time.startMs/end(atMs) 时刻覆盖;单 exporter 纪律——worker 零独立出站通道)。
|
|
32
|
+
*
|
|
33
|
+
* 1.9(D-32 · 远程 MCP Streamable HTTP 头通道):mcpToolSpan 产出的 traceparent 除 1.8 `params._meta`
|
|
34
|
+
* 载体外,经 gateway.callTool → transport.send 第二参透传,httpClient 注入 `traceparent` 请求头
|
|
35
|
+
* (W3C Trace Context HTTP 载体惯例——远程 server 主消费面)。本模块仅复用 parseTraceparent 作
|
|
36
|
+
* 传输层 fail-open 校验(畸形不注入不抛)——编解码与传播语义 1.8 口径零触碰。
|
|
32
37
|
*/
|
|
33
38
|
import { randomBytes } from 'node:crypto'
|
|
34
39
|
import type { TelemetryFacade } from './telemetry.ts'
|
package/src/seam.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KernelSeam 公开导出面(1.10.0 加法——D16 T-6 冻结面口径:本文件即内核库形态的 semver 承诺面)
|
|
3
|
+
*
|
|
4
|
+
* 消费方:CAR 平台层(KernelSeam 适配器);约定:
|
|
5
|
+
* - 仅暴露进程内挂接所需的最窄面(装配/会话/turn/遥测),禁止透出内核内部模块路径语义;
|
|
6
|
+
* - 破坏性变更须内核 major;加法演进走 minor 并在本文件头登记;
|
|
7
|
+
* - 语义不变:runTurn/chatStep/SessionLog 即 CLI 与测试承载的同一实现(非转发壳)。
|
|
8
|
+
*/
|
|
9
|
+
export { SessionLog, type SessionEvent, type EventKind, type Actor } from './session/log.ts'
|
|
10
|
+
export { SessionFileStore } from './session/store.ts'
|
|
11
|
+
export { runTurn, type TurnEndReason, type TurnPreset, type TurnResult } from './loop/stop.ts'
|
|
12
|
+
export { chatStep } from './runtime-core/chatStep.ts'
|
|
13
|
+
export { RuntimeCore, createOpenAICompatAdapter, createAnthropicAdapter } from './runtime-core/llm.ts'
|
|
14
|
+
export { CredentialService } from './runtime-core/credentials.ts'
|
|
15
|
+
export type { LlmAdapter, LlmRequest, LlmChunk } from './runtime-core/types.ts'
|
|
16
|
+
export { mountPlugin } from './load/loader.ts'
|
|
17
|
+
export { Context } from './kernel/context.ts'
|
|
18
|
+
export { loadCarConfig, mergeLlmConfig, mergeSignatureGate, warmCarConfig, type CarConfig, type LlmConfig } from './load/config.ts'
|
|
19
|
+
export { probeCapabilities, SandboxExecutor } from './sandbox/sandbox.ts'
|
|
20
|
+
export { createTelemetryFacade, telemetryConfigFromEnv } from './runtime-core/telemetry.ts'
|
|
21
|
+
export { TurnTracer, type TurnSpanHandle } from './runtime-core/trace.ts'
|
package/.gitattributes
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# 行尾纪律:Windows runner checkout 默认 autocrlf=true 会把文本文件打成 CRLF,
|
|
2
|
-
# WSL 内 bash 脚本遇 \r 即炸(run 35314482866:set: pipefail\r invalid option)。
|
|
3
|
-
* text=auto
|
|
4
|
-
*.sh text eol=lf
|
|
5
|
-
*.c text eol=lf
|
|
6
|
-
*.h text eol=lf
|
|
7
|
-
Makefile text eol=lf
|
|
8
|
-
*.md text eol=lf
|
|
9
|
-
*.yml text eol=lf
|
|
10
|
-
*.json text eol=lf
|
|
11
|
-
*.ts text eol=lf
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
# CI 门禁矩阵(M2部署设计增补 §2.3 16 Job + M3部署设计增补 §2.2 增列 J-17/J-18 = 18 Job ≤ 20)
|
|
2
|
-
#
|
|
3
|
-
# 落地口径(2026-09-18,实施记录见 car-docs/10-内核v1/M3部署设计增补.md 追记):
|
|
4
|
-
# - 矩阵 Job 名对齐文档编号(j01-.../j02-...),required check = j05/j07/j17/j18(G-07 载体 + E-2 收编 + WSL2 对等层 + registry E2E);
|
|
5
|
-
# - 测试/逃逸 Job 禁止重试(M2 §2.4 纪律);仅打包 Job 允许维护者判定后 rerun;
|
|
6
|
-
# - 构建单源:landlock-run 仅在 j01 编译(linux-x64-gnu),j05/j17 消费 artifact 并校验 sha256,禁止平台内重编译(M3 §2.1.2);
|
|
7
|
-
# - J-06 escape-macos = 冻结态登记(M3 §2.4 纪律):macOS Seatbelt 仅 M2-S7 生成器实装,
|
|
8
|
-
# 实跑用例不存在——不设 Job,非 CI 项登记于本注释与文档追记,复核时点 = macOS 实装启动;
|
|
9
|
-
# darwin 逃逸回归的现状覆盖 = j03 全量单测(含 buildSeatbeltProfile 生成器断言);
|
|
10
|
-
# - J-16 release-merge = release.yml(tag 触发:SBOM/SHA256SUMS + npm publish --provenance);
|
|
11
|
-
# - typecheck 门禁范围 = src/ + scripts/(tsconfig include);test/ 为宽松 fixture 风格,
|
|
12
|
-
# 由 node --experimental-transform-types 运行时承载(erasable-TS,类型剥离语义)——显式登记,非遗漏。
|
|
13
|
-
name: ci
|
|
14
|
-
on: [push, pull_request]
|
|
15
|
-
|
|
16
|
-
# CodeQL SARIF 上传需要 security-events: write(run 35312565781 首跑 j01 analyze 403 教训)
|
|
17
|
-
permissions:
|
|
18
|
-
contents: read
|
|
19
|
-
security-events: write
|
|
20
|
-
|
|
21
|
-
jobs:
|
|
22
|
-
# ── J-01 lint-scan-build:typecheck + CodeQL + 依赖审计 + 密钥扫描 + landlock-run 单点编译 ──
|
|
23
|
-
j01-lint-scan-build:
|
|
24
|
-
runs-on: ubuntu-24.04
|
|
25
|
-
timeout-minutes: 15
|
|
26
|
-
steps:
|
|
27
|
-
- uses: actions/checkout@v4
|
|
28
|
-
- uses: actions/setup-node@v4
|
|
29
|
-
with: { node-version: '22.19' }
|
|
30
|
-
- name: cache(键 = 源码哈希 + 工具链 + 三元组,M3 §2.1.2)
|
|
31
|
-
uses: actions/cache@v4
|
|
32
|
-
with:
|
|
33
|
-
path: native/landlock-run/landlock-run
|
|
34
|
-
key: landlock-run-${{ hashFiles('native/landlock-run/**') }}-gcc-${{ runner.os }}-linux-x64-gnu
|
|
35
|
-
- run: npm install
|
|
36
|
-
- name: typecheck(strict,src+scripts 生产面)
|
|
37
|
-
run: npx -y -p typescript tsc --noEmit -p tsconfig.json
|
|
38
|
-
- name: CodeQL(M2 §2.3 J-01 静态分析面)
|
|
39
|
-
uses: github/codeql-action/init@v3
|
|
40
|
-
with: { languages: javascript-typescript }
|
|
41
|
-
- uses: github/codeql-action/analyze@v3
|
|
42
|
-
- name: 依赖审计(npm audit,lockfile 口径;非阻塞登记——升级为阻塞需评审)
|
|
43
|
-
run: npm audit --omit=dev --audit-level=high || echo "::warning::npm audit findings — 见日志"
|
|
44
|
-
- name: 密钥扫描(仓库级 fail-closed)
|
|
45
|
-
run: node --experimental-transform-types scripts/secrets-scan.ts
|
|
46
|
-
- name: landlock-run 单点编译(M3 §2.1.2 构建单源)
|
|
47
|
-
run: |
|
|
48
|
-
make -C native/landlock-run
|
|
49
|
-
sha256sum native/landlock-run/landlock-run > native/landlock-run/landlock-run.sha256
|
|
50
|
-
- uses: actions/upload-artifact@v4
|
|
51
|
-
with:
|
|
52
|
-
name: landlock-run-linux-x64-gnu
|
|
53
|
-
path: |
|
|
54
|
-
native/landlock-run/landlock-run
|
|
55
|
-
native/landlock-run/landlock-run.sha256
|
|
56
|
-
retention-days: 7
|
|
57
|
-
|
|
58
|
-
# ── J-02/J-03/J-04 三平台全量单测(179/179 基线不回退)+ G-06 Node 一致性 ──
|
|
59
|
-
# M7 能力真跑:sqlite(22.5+ 带 flag)flag 直挂测试命令行——不能走 NODE_OPTIONS(白名单拒绝,run 35451413014 实证;
|
|
60
|
-
# 且 job 级 env 会炸 actions 自身 node24)。zstd 为 22.15+ 原生内置(无 flag,Stability 1 实验标记),能力探测自动在场
|
|
61
|
-
j02-test-linux:
|
|
62
|
-
needs: [j01-lint-scan-build]
|
|
63
|
-
runs-on: ubuntu-24.04
|
|
64
|
-
timeout-minutes: 15
|
|
65
|
-
steps:
|
|
66
|
-
- uses: actions/checkout@v4
|
|
67
|
-
- uses: actions/setup-node@v4
|
|
68
|
-
with: { node-version: '22.19' }
|
|
69
|
-
# 1.5 起 zod 为常规运行时依赖(D-22)——CLI/doctor 传递加载,测试 job 需 node_modules
|
|
70
|
-
- run: npm install
|
|
71
|
-
- run: node -p "'G-06 node ' + process.version"
|
|
72
|
-
- run: node --experimental-sqlite --experimental-transform-types --test "test/*.spec.ts"
|
|
73
|
-
|
|
74
|
-
j03-test-macos:
|
|
75
|
-
needs: [j01-lint-scan-build]
|
|
76
|
-
runs-on: macos-14
|
|
77
|
-
timeout-minutes: 25
|
|
78
|
-
steps:
|
|
79
|
-
- uses: actions/checkout@v4
|
|
80
|
-
- uses: actions/setup-node@v4
|
|
81
|
-
with: { node-version: '22.19' }
|
|
82
|
-
# 1.5 起 zod 为常规运行时依赖(D-22)——CLI/doctor 传递加载,测试 job 需 node_modules
|
|
83
|
-
- run: npm install
|
|
84
|
-
- run: node -p "'G-06 node ' + process.version"
|
|
85
|
-
- run: node --experimental-sqlite --experimental-transform-types --test "test/*.spec.ts"
|
|
86
|
-
|
|
87
|
-
j04-test-windows:
|
|
88
|
-
needs: [j01-lint-scan-build]
|
|
89
|
-
runs-on: windows-2022
|
|
90
|
-
timeout-minutes: 25
|
|
91
|
-
steps:
|
|
92
|
-
- uses: actions/checkout@v4
|
|
93
|
-
- uses: actions/setup-node@v4
|
|
94
|
-
with: { node-version: '22.19' }
|
|
95
|
-
# 1.5 起 zod 为常规运行时依赖(D-22)——CLI/doctor 传递加载,测试 job 需 node_modules
|
|
96
|
-
- run: npm install
|
|
97
|
-
- run: node -p "'G-06 node ' + process.version"
|
|
98
|
-
- run: node --experimental-sqlite --experimental-transform-types --test "test/*.spec.ts"
|
|
99
|
-
|
|
100
|
-
# ── J-05 escape-linux(required check,G-07 转 PASS 载体):20 条 POC-4 移植用例常驻 + 审计 JSONL 常驻上传 ──
|
|
101
|
-
j05-escape-linux:
|
|
102
|
-
needs: [j02-test-linux] # 传递依赖 j01(消费其 landlock-run 产物,禁止重编译)
|
|
103
|
-
runs-on: ubuntu-24.04
|
|
104
|
-
timeout-minutes: 30
|
|
105
|
-
steps:
|
|
106
|
-
- uses: actions/checkout@v4
|
|
107
|
-
- uses: actions/download-artifact@v4
|
|
108
|
-
with: { name: landlock-run-linux-x64-gnu, path: dist/ci-artifacts }
|
|
109
|
-
- name: 恢复可执行位(artifact zip 不保留 +x;run 35313717410 教训)
|
|
110
|
-
run: chmod +x dist/ci-artifacts/landlock-run
|
|
111
|
-
- name: 产物指纹校验(防制品传递错位,对齐 M2 §3.5)
|
|
112
|
-
run: |
|
|
113
|
-
EXPECTED="$(cut -d' ' -f1 dist/ci-artifacts/landlock-run.sha256)"
|
|
114
|
-
ACTUAL="$(sha256sum dist/ci-artifacts/landlock-run | cut -d' ' -f1)"
|
|
115
|
-
echo "expected=$EXPECTED actual=$ACTUAL"
|
|
116
|
-
[ "$EXPECTED" = "$ACTUAL" ] || { echo "::error::landlock-run artifact sha256 mismatch"; exit 1; }
|
|
117
|
-
- name: 环境自检 + 逃逸矩阵实跑(20 条 × 5 类;exit 2 = 环境失败,§2.1.3)
|
|
118
|
-
run: bash test/sandbox-escape/run-matrix.sh "$(pwd)/dist/ci-artifacts/landlock-run" "$(pwd)/dist/ci-audit"
|
|
119
|
-
- name: 审计 JSONL 常驻上传(无论成败,§2.1.1 步骤 6)
|
|
120
|
-
if: always()
|
|
121
|
-
uses: actions/upload-artifact@v4
|
|
122
|
-
with: { name: j05-escape-audit, path: dist/ci-audit/escape-audit.jsonl, retention-days: 90 }
|
|
123
|
-
|
|
124
|
-
# ── J-07 escape-windows(required check,E-2 实装态收编):受限 token + Job Object 四判据 ──
|
|
125
|
-
j07-escape-windows:
|
|
126
|
-
needs: [j04-test-windows]
|
|
127
|
-
runs-on: windows-2022
|
|
128
|
-
timeout-minutes: 30
|
|
129
|
-
steps:
|
|
130
|
-
- uses: actions/checkout@v4
|
|
131
|
-
- uses: actions/setup-node@v4
|
|
132
|
-
with: { node-version: '22.19' }
|
|
133
|
-
- run: npm install
|
|
134
|
-
- name: FFI debug matrix(diagnostic,S26 0xC0000142 排查)
|
|
135
|
-
run: node --experimental-transform-types scripts/win32-ffi-debug.ts
|
|
136
|
-
- name: 四判据沙箱 spike(FAIL 即非零退出,脚本退出码直连)
|
|
137
|
-
run: node --experimental-transform-types scripts/win32-koffi-spike.ts
|
|
138
|
-
|
|
139
|
-
# ── J-08 invariant-n1:N1 不变量 100 回放 fixtures(含篡改检出防假绿自检) ──
|
|
140
|
-
j08-invariant-n1:
|
|
141
|
-
needs: [j02-test-linux]
|
|
142
|
-
runs-on: ubuntu-24.04
|
|
143
|
-
timeout-minutes: 15
|
|
144
|
-
steps:
|
|
145
|
-
- uses: actions/checkout@v4
|
|
146
|
-
- uses: actions/setup-node@v4
|
|
147
|
-
with: { node-version: '22.19' }
|
|
148
|
-
- run: node --experimental-transform-types scripts/invariant-n1.ts
|
|
149
|
-
- uses: actions/upload-artifact@v4
|
|
150
|
-
with: { name: j08-invariant-n1, path: dist/ci/invariant-n1.jsonl, retention-days: 90 }
|
|
151
|
-
|
|
152
|
-
# ── J-09 contract:SessionEventMap 快照只增不删 + 公共 API 兼容 ──
|
|
153
|
-
j09-contract:
|
|
154
|
-
needs: [j02-test-linux]
|
|
155
|
-
runs-on: ubuntu-24.04
|
|
156
|
-
timeout-minutes: 10
|
|
157
|
-
steps:
|
|
158
|
-
- uses: actions/checkout@v4
|
|
159
|
-
- uses: actions/setup-node@v4
|
|
160
|
-
with: { node-version: '22.19' }
|
|
161
|
-
- run: node --experimental-transform-types scripts/contract-check.ts
|
|
162
|
-
|
|
163
|
-
# ── J-10/J-11/J-12 dx-smoke:QS-05 首跑通冒烟(doctor + reload 五阶段报告) ──
|
|
164
|
-
j10-dx-smoke-linux:
|
|
165
|
-
needs: [j02-test-linux]
|
|
166
|
-
runs-on: ubuntu-24.04
|
|
167
|
-
timeout-minutes: 15
|
|
168
|
-
steps:
|
|
169
|
-
- uses: actions/checkout@v4
|
|
170
|
-
- uses: actions/setup-node@v4
|
|
171
|
-
with: { node-version: '22.19' }
|
|
172
|
-
# 1.5 起 zod 为常规运行时依赖(D-22)——cli.ts 传递加载,dx-smoke 需 node_modules
|
|
173
|
-
- run: npm install
|
|
174
|
-
- run: node --experimental-transform-types src/cli.ts doctor
|
|
175
|
-
- run: node --experimental-transform-types src/cli.ts reload test/fixtures/hello-plugin.ts
|
|
176
|
-
|
|
177
|
-
j11-dx-smoke-macos:
|
|
178
|
-
needs: [j03-test-macos]
|
|
179
|
-
runs-on: macos-14
|
|
180
|
-
timeout-minutes: 20
|
|
181
|
-
steps:
|
|
182
|
-
- uses: actions/checkout@v4
|
|
183
|
-
- uses: actions/setup-node@v4
|
|
184
|
-
with: { node-version: '22.19' }
|
|
185
|
-
# 1.5 起 zod 为常规运行时依赖(D-22)——cli.ts 传递加载,dx-smoke 需 node_modules
|
|
186
|
-
- run: npm install
|
|
187
|
-
- run: node --experimental-transform-types src/cli.ts doctor
|
|
188
|
-
- run: node --experimental-transform-types src/cli.ts reload test/fixtures/hello-plugin.ts
|
|
189
|
-
|
|
190
|
-
j12-dx-smoke-windows:
|
|
191
|
-
needs: [j04-test-windows]
|
|
192
|
-
runs-on: windows-2022
|
|
193
|
-
timeout-minutes: 20
|
|
194
|
-
steps:
|
|
195
|
-
- uses: actions/checkout@v4
|
|
196
|
-
- uses: actions/setup-node@v4
|
|
197
|
-
with: { node-version: '22.19' }
|
|
198
|
-
# 1.5 起 zod 为常规运行时依赖(D-22)——cli.ts 传递加载,dx-smoke 需 node_modules
|
|
199
|
-
- run: npm install
|
|
200
|
-
- run: node --experimental-transform-types src/cli.ts doctor
|
|
201
|
-
- run: node --experimental-transform-types src/cli.ts reload test/fixtures/hello-plugin.ts
|
|
202
|
-
|
|
203
|
-
# ── J-13/J-14/J-15 package-*:npm pack 干跑 + files 白名单/包名断言(唯一允许 rerun 的 Job 组) ──
|
|
204
|
-
j13-package-linux:
|
|
205
|
-
needs: [j05-escape-linux, j10-dx-smoke-linux]
|
|
206
|
-
runs-on: ubuntu-24.04
|
|
207
|
-
timeout-minutes: 20
|
|
208
|
-
steps:
|
|
209
|
-
- uses: actions/checkout@v4
|
|
210
|
-
- uses: actions/setup-node@v4
|
|
211
|
-
with: { node-version: '22.19' }
|
|
212
|
-
- run: node --experimental-transform-types scripts/package-check.ts
|
|
213
|
-
|
|
214
|
-
# 依赖调整登记:J-14 原依赖 J-06(冻结态未设 Job)→ 回退 J-03(darwin 测试面),见文件头 J-06 冻结登记
|
|
215
|
-
j14-package-macos:
|
|
216
|
-
needs: [j03-test-macos, j11-dx-smoke-macos]
|
|
217
|
-
runs-on: macos-14
|
|
218
|
-
timeout-minutes: 25
|
|
219
|
-
steps:
|
|
220
|
-
- uses: actions/checkout@v4
|
|
221
|
-
- uses: actions/setup-node@v4
|
|
222
|
-
with: { node-version: '22.19' }
|
|
223
|
-
- run: node --experimental-transform-types scripts/package-check.ts
|
|
224
|
-
|
|
225
|
-
j15-package-windows:
|
|
226
|
-
needs: [j07-escape-windows, j12-dx-smoke-windows]
|
|
227
|
-
runs-on: windows-2022
|
|
228
|
-
timeout-minutes: 25
|
|
229
|
-
steps:
|
|
230
|
-
- uses: actions/checkout@v4
|
|
231
|
-
- uses: actions/setup-node@v4
|
|
232
|
-
with: { node-version: '22.19' }
|
|
233
|
-
- run: node --experimental-transform-types scripts/package-check.ts
|
|
234
|
-
|
|
235
|
-
# ── J-17 escape-wsl2(required check,M3 新增):§2.1.1 六步编排,企业代表拓扑对等回归 ──
|
|
236
|
-
j17-escape-wsl2:
|
|
237
|
-
needs: [j02-test-linux]
|
|
238
|
-
runs-on: windows-2022
|
|
239
|
-
timeout-minutes: 40
|
|
240
|
-
steps:
|
|
241
|
-
- uses: actions/checkout@v4
|
|
242
|
-
- uses: actions/download-artifact@v4
|
|
243
|
-
with: { name: landlock-run-linux-x64-gnu, path: dist/ci-artifacts }
|
|
244
|
-
- name: 步骤 1 · WSL 启用自检(内核缺失时 wsl --update 自愈;run 35312957963 教训)
|
|
245
|
-
shell: pwsh
|
|
246
|
-
run: |
|
|
247
|
-
wsl --status; if ($LASTEXITCODE -ne 0) { wsl --update --web-download }
|
|
248
|
-
# run 35315242805 教训:默认版本可能是 1(无内核翻译层,Landlock 不可用)——强制 WSL2
|
|
249
|
-
wsl --set-default-version 2; if ($LASTEXITCODE -ne 0) { wsl --update; wsl --set-default-version 2 }
|
|
250
|
-
wsl --status
|
|
251
|
-
- name: 步骤 2 · Ubuntu 24.04 发行版导入(web-download 绕 Store;失败 = 环境失败 §2.1.3)
|
|
252
|
-
shell: pwsh
|
|
253
|
-
run: |
|
|
254
|
-
wsl --install -d Ubuntu-24.04 --no-launch --web-download
|
|
255
|
-
wsl --set-version Ubuntu-24.04 2
|
|
256
|
-
wsl -d Ubuntu-24.04 -e uname -r
|
|
257
|
-
- name: 步骤 3-5 · 环境自检 + 工作区迁移 ext4 + 20 条实跑
|
|
258
|
-
shell: bash
|
|
259
|
-
run: |
|
|
260
|
-
set -e
|
|
261
|
-
# run 35313717410 教训:runner 的 D 盘不一定被 automount(/mnt/d 不存在)——
|
|
262
|
-
# 全部经 tar 流直灌 ext4(~/car-import),绕开 /mnt 依赖;编排器从该路径自取 native/test
|
|
263
|
-
wsl -d Ubuntu-24.04 -e bash -c "rm -rf ~/car-import && mkdir -p ~/car-import"
|
|
264
|
-
tar -cf - native test dist/ci-artifacts | wsl -d Ubuntu-24.04 -e bash -c "tar -xf - -C ~/car-import && chmod +x ~/car-import/dist/ci-artifacts/landlock-run"
|
|
265
|
-
# 防御性去 CR:runner checkout 可能仍产 CRLF(\r 会让 set -euo pipefail 直接 invalid option)
|
|
266
|
-
wsl -d Ubuntu-24.04 -e bash -c "sed -i 's/\r\$//' ~/car-import/test/sandbox-escape/*.sh"
|
|
267
|
-
wsl -d Ubuntu-24.04 -e bash -c "bash ~/car-import/test/sandbox-escape/j17-orchestrate.sh ~/car-import ~/car-import/dist/ci-artifacts/landlock-run"
|
|
268
|
-
- name: 步骤 6 · 审计 JSONL 回传(无论成败)
|
|
269
|
-
if: always()
|
|
270
|
-
shell: bash
|
|
271
|
-
run: |
|
|
272
|
-
REPO_WSL="/mnt/$(pwd | sed 's#^/##')"
|
|
273
|
-
mkdir -p dist/ci-audit
|
|
274
|
-
wsl -d Ubuntu-24.04 -e bash -c "cp ~/car-matrix/audit/escape-audit.jsonl '$REPO_WSL/dist/ci-audit/escape-audit.jsonl' 2>/dev/null || true" || true
|
|
275
|
-
# /mnt 不可用时兜底:cat 直出(run 35313717410 教训)
|
|
276
|
-
[ -s dist/ci-audit/escape-audit.jsonl ] || wsl -d Ubuntu-24.04 -e bash -c "cat ~/car-matrix/audit/escape-audit.jsonl" > dist/ci-audit/escape-audit.jsonl 2>/dev/null || true
|
|
277
|
-
- uses: actions/upload-artifact@v4
|
|
278
|
-
if: always()
|
|
279
|
-
with: { name: j17-escape-audit, path: dist/ci-audit/escape-audit.jsonl, retention-days: 90 }
|
|
280
|
-
|
|
281
|
-
# ── J-18 registry-e2e(required check,M3 新增):Verdaccio 实跑 + §3.6 六用例组 ──
|
|
282
|
-
j18-registry-e2e:
|
|
283
|
-
needs: [j02-test-linux]
|
|
284
|
-
runs-on: ubuntu-24.04
|
|
285
|
-
timeout-minutes: 20
|
|
286
|
-
steps:
|
|
287
|
-
- uses: actions/checkout@v4
|
|
288
|
-
- uses: actions/setup-node@v4
|
|
289
|
-
with: { node-version: '22.19' }
|
|
290
|
-
- run: node --experimental-transform-types test/registry-e2e/run-e2e.ts
|
|
291
|
-
- uses: actions/upload-artifact@v4
|
|
292
|
-
if: always()
|
|
293
|
-
with: { name: j18-registry-e2e, path: dist/ci/registry-e2e.jsonl, retention-days: 90 }
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
name: release
|
|
2
|
-
on:
|
|
3
|
-
workflow_dispatch:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
permissions:
|
|
7
|
-
# 1.3-S3(W4-2):contents 提升为 write——gh release upload 资产上传需要;
|
|
8
|
-
# id-token: write 为 keyless cosign(OIDC + Rekor)凭据源(D-15 正式轨)
|
|
9
|
-
contents: write
|
|
10
|
-
id-token: write
|
|
11
|
-
# J-16 release-merge(M2 §2.3)+ 1.3 W4 全自动化:
|
|
12
|
-
# 构建制品(release-artifacts.ts——与本地 release-pipeline.ts 单一事实源,R-3)
|
|
13
|
-
# → cosign keyless 签名 tgz(OIDC + Rekor 透明日志;私钥不出本地,D-15 正式轨)
|
|
14
|
-
# → 上传五件套到 Release(gh release upload --clobber;消除 1.0 错挂/1.2 树漂移的人工拖拽面)
|
|
15
|
-
# → npm publish --provenance(原步不动)。
|
|
16
|
-
# 步骤序红线:upload 先于 publish——上传失败 job 即红,publish 不带病出街。
|
|
17
|
-
# 回退预案(R-1,演练预案非静默):keyless 签名/上传失败时可临时人工拖拽资产,事后修复重发。
|
|
18
|
-
jobs:
|
|
19
|
-
j16-release-merge:
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v4
|
|
23
|
-
- uses: actions/setup-node@v4
|
|
24
|
-
with:
|
|
25
|
-
node-version: 22
|
|
26
|
-
registry-url: https://registry.npmjs.org/
|
|
27
|
-
- name: Build release artifacts (single-source with local pipeline, W4-1)
|
|
28
|
-
run: node --experimental-transform-types scripts/release-artifacts.ts
|
|
29
|
-
- name: Install cosign (pinned, R-4)
|
|
30
|
-
uses: sigstore/cosign-installer@v3.7.0
|
|
31
|
-
- name: Keyless sign tarball (OIDC + Rekor, D-15 formal track)
|
|
32
|
-
run: |
|
|
33
|
-
VERSION=$(node -p "require('./package.json').version")
|
|
34
|
-
cosign sign-blob --yes --bundle "dist/car-runtime-${VERSION}.tgz.sig.bundle" "dist/car-runtime-${VERSION}.tgz"
|
|
35
|
-
echo "{\"stage\":\"cosign-keyless\",\"detail\":\"signed car-runtime-${VERSION}.tgz (keyless OIDC + Rekor)\",\"ts\":$(date +%s%3N)}" >> dist/release-audit.jsonl
|
|
36
|
-
- name: "Upload release assets (W4 - zero manual drag-and-drop)"
|
|
37
|
-
env:
|
|
38
|
-
GH_TOKEN: ${{ github.token }}
|
|
39
|
-
run: |
|
|
40
|
-
VERSION=$(node -p "require('./package.json').version")
|
|
41
|
-
for f in dist/car-runtime-${VERSION}.tgz dist/car-runtime-${VERSION}.tgz.sig.bundle dist/SHA256SUMS dist/sbom.json dist/release-audit.jsonl; do
|
|
42
|
-
# 上传目标 = 包版本号(D-14 裸 tag 形态:release tag == version);dispatch 触发亦可用
|
|
43
|
-
gh release upload "$VERSION" "$f" --clobber
|
|
44
|
-
done
|
|
45
|
-
- name: Publish to npm with provenance
|
|
46
|
-
# dist-tag 按版本形态动态选择:prerelease(如 1.0.0-rc.1)→ rc;稳定版(1.0.0)→ latest。
|
|
47
|
-
# M5 §1.1 口径:1.0 发布时 latest→1.0.0,rc tag 保留指向 rc.1 不回指——稳定版禁止 --tag rc。
|
|
48
|
-
run: |
|
|
49
|
-
VERSION=$(node -p "require('./package.json').version")
|
|
50
|
-
if echo "$VERSION" | grep -q -- '-'; then TAG=rc; else TAG=latest; fi
|
|
51
|
-
echo "version=$VERSION -> dist-tag=$TAG"
|
|
52
|
-
npm publish --provenance --tag "$TAG"
|
|
53
|
-
env:
|
|
54
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/adr/ADR-001.md
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
# ADR-001 · max-tokens 处置策略
|
|
2
|
-
状态: 已定稿(S2 实装)| 2026-09-02
|
|
3
|
-
决策: 默认 DSH 式解析前收口(finishReason=length 不解析工具调用,禁补全半截 JSON);TurnEndReason 保留至 turn/end(endReasonTrail);只读白名单工具可选 Pi 式补错重试(preset 显式开启);finishReason 为不可变透传字段,改写/吞没触发 AL-05。
|
|
4
|
-
证据: D5 §4 + SR-17(vLLM #53269 教训)+ POC-3 I4 断言(截断保留语义已验证)。
|
package/adr/ADR-002.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# ADR-002 · 卸载顺序双模式接口
|
|
2
|
-
状态: 已定稿 + S1 实装(strict-topo 默认)| 2026-09-04
|
|
3
|
-
决策: ctx.effect 双模式——strict-topo(Kahn 分层反转逐层排空,消费者先于提供者)/ concurrent(跨 fiber 并发,对照降级模式);fiber 内一律注册逆序。
|
|
4
|
-
证据: POC-1 spike(poc1-dispose-order.ts)实证屏障可行;dsh Fiber._unload 为 Promise.all 并发(fiber.ts:676),barrier 缺失——CAR 自研超越点。
|
|
5
|
-
S1 踩坑记录: Kahn 分层方向为 provider→consumer,teardown 必须 reverse 层序(首版实现即踩,测试捕获)。
|
package/adr/ADR-003.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# ADR-003 · 插件签名信任根与 enforce 策略(D-1/D-2 裁决实装)
|
|
2
|
-
|
|
3
|
-
状态: 已定稿(S5 定稿文档;S6 验签器实装)| 2026-09-04
|
|
4
|
-
|
|
5
|
-
## 决策(D-1)
|
|
6
|
-
|
|
7
|
-
**双轨签名**:Sigstore keyless 主轨(与发布工程 G-08 cosign / G-09 npm provenance 同源,不另起炉灶)+ minisign 式静态密钥离线轨(解决 R-6 内网/离线验证失败)。
|
|
8
|
-
|
|
9
|
-
信任锚三层:
|
|
10
|
-
1. 内置根:CAR 项目公钥编译期 pinning;
|
|
11
|
-
2. Sigstore 链:离线 bundle 验证,禁止运行时拉网(对齐部署侧禁运行时网络下载纪律);
|
|
12
|
-
3. 企业自管替换点:`trustRoot` 配置可替换信任锚,替换动作写审计日志。
|
|
13
|
-
|
|
14
|
-
## 决策(D-2)
|
|
15
|
-
|
|
16
|
-
**enforce 时点**:S6 warn 上线(签名缺失 = 告警放行 + manifestHash 指纹兜底)→ S8 末统计 unsigned 占比与误伤率 → S10 发布预演前切 enforce(缺失 = 硬拒绝)。
|
|
17
|
-
|
|
18
|
-
fail-closed 三情形分级:
|
|
19
|
-
| 情形 | M2 行为 |
|
|
20
|
-
| --- | --- |
|
|
21
|
-
| 签名校验失败(有签名但不对) | 硬拒绝,**不可配置放行** |
|
|
22
|
-
| 签名缺失 | S6-S9 warn + 指纹兜底 → S10 enforce 拒绝 |
|
|
23
|
-
| Rekor 透明日志不可达 | 回退静态轨;双轨皆败按缺失处理 |
|
|
24
|
-
|
|
25
|
-
存量已装插件不回溯强制(manifestHash 指纹持续兜底,M3 企业策略项)。Git 直载维持决议⑦告警语义,不纳入 enforce。
|
|
26
|
-
|
|
27
|
-
## 依据
|
|
28
|
-
|
|
29
|
-
- 决议⑦:分发 = 目录+签名起步(Shai-Hulud/ClawHub 供应链教训,SR-08/09/14);
|
|
30
|
-
- 部署侧 G-08/G-09 同源复用(M2部署设计增补 T-4);
|
|
31
|
-
- M1 已有 manifestHash 指纹兜底(loader.ts)。
|
|
32
|
-
|
|
33
|
-
## 回退方案
|
|
34
|
-
|
|
35
|
-
Sigstore 生态不可用(如 Rekor 长期故障)→ 静态轨独立承载;企业场景 → trustRoot 替换为自管根。验签失败处置遵循安全设计 §4.4 装载前三段。
|
package/adr/host-onboarding.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# E-6 宿主实连接入指南(M4-S18)
|
|
2
|
-
|
|
3
|
-
> CAR-as-MCP-Server:宿主(Claude Code / Codex)把 CAR 当作一个 MCP server 接入——
|
|
4
|
-
> 9 tool 会话级能力面(session_start/turn/stop/status/replay/verify/export + tool_list/tool_call)。
|
|
5
|
-
> 传输 = stdio JSON-RPC(换行分隔),与 M3 契约测试同一接入面(双宿主等价由契约锁定)。
|
|
6
|
-
|
|
7
|
-
## Claude Code 接入
|
|
8
|
-
|
|
9
|
-
项目根目录 `.mcp.json`(或 `~/.claude.json` 全局):
|
|
10
|
-
|
|
11
|
-
```json
|
|
12
|
-
{
|
|
13
|
-
"mcpServers": {
|
|
14
|
-
"car": {
|
|
15
|
-
"command": "node",
|
|
16
|
-
"args": [
|
|
17
|
-
"--experimental-transform-types",
|
|
18
|
-
"{CAR_ROOT}/src/cli.ts",
|
|
19
|
-
"mcp-serve",
|
|
20
|
-
"--host", "claude-code"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Codex 接入
|
|
28
|
-
|
|
29
|
-
`~/.codex/config.toml`:
|
|
30
|
-
|
|
31
|
-
```toml
|
|
32
|
-
[mcp_servers.car]
|
|
33
|
-
command = "node"
|
|
34
|
-
args = [
|
|
35
|
-
"--experimental-transform-types",
|
|
36
|
-
"{CAR_ROOT}/src/cli.ts",
|
|
37
|
-
"mcp-serve",
|
|
38
|
-
"--host", "codex",
|
|
39
|
-
]
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## 验证步骤(E-6 五类契约手工清单)
|
|
43
|
-
|
|
44
|
-
1. `car doctor` → 确认 Node ≥22.19 与沙箱能力状态;
|
|
45
|
-
2. 宿主内触发 MCP 工具列表刷新 → 应看到 9 个 `session_*` / `tool_*` 工具;
|
|
46
|
-
3. 调 `session_start` → 返回 `SH-` 前缀会话 id(跨宿主隔离:两个宿主各自 start 得到不同 id);
|
|
47
|
-
4. `session_turn` 提交一批宿主事件 → 返回 `{reason, steps}`;未知宿主事件应无报错(hostRaw 降级留痕,非失败);
|
|
48
|
-
5. `session_verify` → `ok:true`(哈希链完整);`session_replay` → 消息流与宿主侧对话语义一致;
|
|
49
|
-
6. 结束会话后检查 stderr 快照行:`zeroContent=true`(采集窗口零内容红线)。
|
|
50
|
-
|
|
51
|
-
## 采集窗口(D-2 数据窗口 S18–S20)
|
|
52
|
-
|
|
53
|
-
- 每次会话结束(stdin 关闭)向 **stderr** 输出一行快照(stdout 为协议通道不可污染);
|
|
54
|
-
- 快照仅含 3 个零内容 Counter(load_total / unsigned_confirmed / registry_decision)——
|
|
55
|
-
`assertZeroContent` 自检内建;
|
|
56
|
-
- 登记表兜底:企业未开启遥测时,人工抄录快照行即可满足 S20 enforce 决策的数据输入(双通道设计)。
|
|
57
|
-
|
|
58
|
-
## E-6 实连执行记录(2026-09-05 · 本机冒烟 ✅)
|
|
59
|
-
|
|
60
|
-
- 协议握手已实装(initialize / notifications/initialized——MCP 协议兼容,冒烟前置补齐);
|
|
61
|
-
- 本机端到端冒烟(真实 spawn 进程,配置同款命令行):initialize serverInfo=car-runtime 0.3.0 → tools/list 9 → session_start=SH-fa5c8838469ba4599032d35b → session_turn completed → session_verify ok → stderr 快照 zeroContent=true;
|
|
62
|
-
- 宿主侧配置已写入:Claude Code 项目级 `D:/WorkBuddy/agent/.mcp.json` + Codex `~/.codex/config.toml` 追加段(command 用 Node 22.22.2 绝对路径——系统 node20 不支持 --experimental-transform-types);
|
|
63
|
-
- 待真实宿主 GUI 会话验证(启动 Claude Code 于本工作区 / codex 会话内确认 9 tool 出现)。
|
|
64
|
-
|
|
65
|
-
## 已知边界
|
|
66
|
-
|
|
67
|
-
- 会话状态为进程内存态(进程退出即失);跨进程持久化走 `session_export` 取证包 → S19 评估文件落盘增强;
|
|
68
|
-
- `tool_list`/`tool_call`(宿主工具面透传)在试点期返回占位(S19 接线宿主侧工具注册)。
|