skill-family-harness-node 0.9.0 → 0.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/CHANGELOG.md +22 -0
- package/CHANGELOG.zh-CN.md +22 -0
- package/README.md +18 -16
- package/README.zh-CN.md +16 -15
- package/candidate/quickstart-profile.mjs +1 -1
- package/package.json +5 -3
- package/release-notes/0.10.0.yaml +25 -0
- package/src/index.mjs +1 -0
- package/src/peer-adapter.mjs +186 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
<!-- release-skill:changelog:start version=0.10.0 locale=en baseline=sha256:64a325d3e51604a8436b33df5a7f617f9aab1f1e02adb32ccb58316aa5c5eab1 -->
|
|
4
|
+
## [0.10.0] - 2026-08-24
|
|
5
|
+
|
|
6
|
+
Harness 0.10.0 adds canonical entrypoints, reuses existing host mechanisms, and adds read-only peer adapter verification from real directories.
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- Adds skill-family-harness-node/quickstart-profile and skill-family-harness-node/rename-directory-no-replace canonical exports.
|
|
11
|
+
- Reuses filesystem-root binding, strict no-replace publication, atomic replacement, and existing build digests for the Kit's local host install/update path.
|
|
12
|
+
- Adds `verifyPeerAdapterDirectories`, which re-enumerates peer roots and verifies common closure, byte digests, standard manifests, and complete logical mappings without writing them.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Keeps each historical candidate export as a same-source migration alias and leaves the mechanism registry unchanged.
|
|
17
|
+
- Keeps validate-many-by-schema-id and its error semantics unchanged while managed Bundles accept historical and canonical Schema IDs through the same validator.
|
|
18
|
+
|
|
19
|
+
### Upgrade Notes
|
|
20
|
+
|
|
21
|
+
Update all three exact pins to 0.10.0 and migrate historical candidate imports and Schema IDs once to canonical identities. The low-level no-replace primitive remains distinct from the stable fixed-set-publication API; choose the contract that matches the use case.
|
|
22
|
+
<!-- release-skill:changelog:end version=0.10.0 locale=en -->
|
|
23
|
+
|
|
24
|
+
|
|
3
25
|
<!-- release-skill:changelog:start version=0.9.0 locale=en baseline=sha256:e5f4e3bb6ab343e4ccfb7dcdbba8b9ab4576b4cf285c30bb3597d577be5eb391 -->
|
|
4
26
|
## [0.9.0] - 2026-08-24
|
|
5
27
|
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# 变更日志
|
|
2
2
|
|
|
3
|
+
<!-- release-skill:changelog:start version=0.10.0 locale=zh-CN baseline=sha256:d8e27cce0c3e97b7d10b6f88fad4df66c8d527d3d6a2fb165f8c909612ff9f19 -->
|
|
4
|
+
## [0.10.0] - 2026-08-24
|
|
5
|
+
|
|
6
|
+
Harness 0.10.0 增加规范入口,复用既有宿主机制,并从真实目录提供同级适配器只读验证。
|
|
7
|
+
|
|
8
|
+
### 新增
|
|
9
|
+
|
|
10
|
+
- 新增 skill-family-harness-node/quickstart-profile 与 skill-family-harness-node/rename-directory-no-replace 规范导出。
|
|
11
|
+
- 复用 filesystem-root binding、严格不替换发布、原子替换和既有构建摘要,支持 Kit 的本地宿主 install/update。
|
|
12
|
+
- 新增 `verifyPeerAdapterDirectories`,重新枚举 peer 根目录,验证共同闭包、逐字节摘要、标准 manifest 和完整 logicalMappings,不写入目录。
|
|
13
|
+
|
|
14
|
+
### 变更
|
|
15
|
+
|
|
16
|
+
- 历史 candidate 导出继续作为同源迁移别名,机制登记表不变。
|
|
17
|
+
- validate-many-by-schema-id 及错误语义不变;受管 Bundle 让历史与规范 Schema ID 共用同一 validator。
|
|
18
|
+
|
|
19
|
+
### 升级说明
|
|
20
|
+
|
|
21
|
+
消费者应把三个包的精确 pin 更新到 0.10.0,并把历史 candidate 导入和 Schema ID 一次迁移到规范身份。低层不替换原语仍不同于稳定 fixed-set-publication API,消费者按所需合同选择。
|
|
22
|
+
<!-- release-skill:changelog:end version=0.10.0 locale=zh-CN -->
|
|
23
|
+
|
|
24
|
+
|
|
3
25
|
<!-- release-skill:changelog:start version=0.9.0 locale=zh-CN baseline=sha256:7f3ff503831b8fb52f20293a4af4003ff116b7f9d820a0c2da1bd34a0b261248 -->
|
|
4
26
|
## [0.9.0] - 2026-08-24
|
|
5
27
|
|
package/README.md
CHANGED
|
@@ -4,28 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
# skill-family-harness-node
|
|
6
6
|
|
|
7
|
-
<!-- release-skill:release-version: 0.
|
|
7
|
+
<!-- release-skill:release-version: 0.10.0 -->
|
|
8
8
|
|
|
9
9
|
The **single default Node implementation** of the Contracts mechanism protocol. This is a thin runtime: it only implements the mechanism protocol, introduces no business semantics, and does not provide a second-language implementation.
|
|
10
10
|
|
|
11
11
|
<!-- release-skill:managed:start id=latest-release -->
|
|
12
|
-
**0.
|
|
12
|
+
**0.10.0** (2026-08-24)
|
|
13
13
|
|
|
14
|
-
Harness 0.
|
|
14
|
+
Harness 0.10.0 adds canonical entrypoints, reuses existing host mechanisms, and adds read-only peer adapter verification from real directories.
|
|
15
15
|
|
|
16
16
|
**Added**
|
|
17
17
|
|
|
18
|
-
- Adds
|
|
19
|
-
-
|
|
20
|
-
- Adds
|
|
18
|
+
- Adds skill-family-harness-node/quickstart-profile and skill-family-harness-node/rename-directory-no-replace canonical exports.
|
|
19
|
+
- Reuses filesystem-root binding, strict no-replace publication, atomic replacement, and existing build digests for the Kit's local host install/update path.
|
|
20
|
+
- Adds `verifyPeerAdapterDirectories`, which re-enumerates peer roots and verifies common closure, byte digests, standard manifests, and complete logical mappings without writing them.
|
|
21
21
|
|
|
22
22
|
**Changed**
|
|
23
23
|
|
|
24
|
-
- Keeps
|
|
24
|
+
- Keeps each historical candidate export as a same-source migration alias and leaves the mechanism registry unchanged.
|
|
25
|
+
- Keeps validate-many-by-schema-id and its error semantics unchanged while managed Bundles accept historical and canonical Schema IDs through the same validator.
|
|
25
26
|
|
|
26
27
|
**Upgrade Notes**
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
Update all three exact pins to 0.10.0 and migrate historical candidate imports and Schema IDs once to canonical identities. The low-level no-replace primitive remains distinct from the stable fixed-set-publication API; choose the contract that matches the use case.
|
|
29
30
|
<!-- release-skill:managed:end id=latest-release -->
|
|
30
31
|
|
|
31
32
|
## Problem It Solves
|
|
@@ -39,14 +40,14 @@ The Harness consumes `skill-family-contracts` (a workspace dependency), reusing
|
|
|
39
40
|
## Installation and Minimal Example
|
|
40
41
|
|
|
41
42
|
```sh
|
|
42
|
-
npm install skill-family-harness-node@0.
|
|
43
|
+
npm install skill-family-harness-node@0.10.0
|
|
43
44
|
npm info skill-family-harness-node --help
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
The minimal example shows validating a contract document inside Node:
|
|
47
48
|
|
|
48
49
|
```js
|
|
49
|
-
// Run from an empty directory: npm install skill-family-harness-node@0.
|
|
50
|
+
// Run from an empty directory: npm install skill-family-harness-node@0.10.0
|
|
50
51
|
import { validateContractDocument } from "skill-family-harness-node";
|
|
51
52
|
|
|
52
53
|
const document = {
|
|
@@ -75,12 +76,12 @@ import {
|
|
|
75
76
|
createQuickstartTask,
|
|
76
77
|
wrapQuickstartResult,
|
|
77
78
|
verifyQuickstartExchange,
|
|
78
|
-
} from "skill-family-harness-node/
|
|
79
|
+
} from "skill-family-harness-node/quickstart-profile";
|
|
79
80
|
```
|
|
80
81
|
|
|
81
82
|
The v2 mechanism recomputes the bytes of every path-backed output and evidence Resource. It also rejects duplicate Resource ids, correlation drift, a changed Task digest, and incomplete or mismatched evidence bindings. It does not perform a domain audit, choose a method, retry work, or own lifecycle state.
|
|
82
83
|
|
|
83
|
-
The
|
|
84
|
+
The capability remains **candidate**. Pin all three Foundation packages exactly while evaluating it. Version 0.10.0 adds the canonical path above; the historical `/candidate/quickstart-profile` path remains a same-source migration alias. Migrate once to the canonical path. A later stable promotion will not require another import or same-byte Bundle rebuild. Integrations that still produce candidate v1 exchanges must stay pinned to exactly `0.2.1`.
|
|
84
85
|
|
|
85
86
|
## Typical Use Cases
|
|
86
87
|
|
|
@@ -167,7 +168,7 @@ Mechanism failures uniformly throw `SFC2004` (EXECUTION_FAILED), with `details.k
|
|
|
167
168
|
### Do not use when
|
|
168
169
|
|
|
169
170
|
- You need to put file-selection business rules into the Foundation (business rules are owned by the caller).
|
|
170
|
-
- You need host
|
|
171
|
+
- You need host identity policy, host drivers, remote publication, uninstall deletion, a full Qoder driver, or binary adapter source (explicitly unsupported).
|
|
171
172
|
- You need domain audit semantics, retry orchestration, or a compatibility-frozen Quickstart API.
|
|
172
173
|
|
|
173
174
|
### Capability selection
|
|
@@ -179,7 +180,7 @@ Mechanism failures uniformly throw `SFC2004` (EXECUTION_FAILED), with `details.k
|
|
|
179
180
|
- `foundation.harness.resource-closure`: deterministic resource closure and sha256 digest.
|
|
180
181
|
- `foundation.harness.request-processing`: operation-request → terminal operation-result.
|
|
181
182
|
- `foundation.harness.report`: report-model validation/render/binding/check.
|
|
182
|
-
- `foundation.harness.host-adapter`: adapter source closure/build/materialize and
|
|
183
|
+
- `foundation.harness.host-adapter`: adapter source closure/build/materialize, version probe, and read-only peer adapter verification.
|
|
183
184
|
- `foundation.harness.state-store`: append-only events, hash chain, snapshots, and lock recovery.
|
|
184
185
|
- `foundation.harness.errors`: mechanism error types and stable error classes.
|
|
185
186
|
- `foundation.harness.quickstart-profile-candidate`: exact-version observation/task/result construction and binding verification.
|
|
@@ -208,16 +209,17 @@ Mechanism failures uniformly throw `SFC2004` (EXECUTION_FAILED), with `details.k
|
|
|
208
209
|
|
|
209
210
|
- Event meaning and reducer transitions remain consumer-owned; state-store only provides the base.
|
|
210
211
|
- Only text adapter source (utf8) is supported; binary projection is not supported.
|
|
212
|
+
- `verifyPeerAdapterDirectories` enumerates and reads two or more real peer roots, reuses bound-read/path containment/closure/manifest primitives, and fails closed on symlinks, escapes, byte drift, member drift, or incomplete mappings.
|
|
211
213
|
|
|
212
214
|
### Route elsewhere when
|
|
213
215
|
|
|
214
216
|
- Business state machine / terminal states: route to loop-agent.
|
|
215
|
-
- Host
|
|
217
|
+
- Host identity policy, host drivers, and lifecycle authorization belong to Engineering Kit; Harness supplies only the reusable bound-read, strict-publication, atomic-write, closure, and probe mechanisms.
|
|
216
218
|
- Domain audit semantics: route to a standalone audit consumer.
|
|
217
219
|
|
|
218
220
|
### Machine-readable sources
|
|
219
221
|
|
|
220
222
|
- Public capability catalog: [`capability-catalog.json`](https://ifoohoo.github.io/skill-family-engineering-kit/agents/capability-catalog.json) (`foundation.harness.*` entries).
|
|
221
223
|
- Package-local source: `src/*.mjs`.
|
|
222
|
-
- Package-local candidate source: `candidate/quickstart-profile.mjs`; public import: `skill-family-harness-node/candidate/quickstart-profile`.
|
|
224
|
+
- Package-local candidate source: `candidate/quickstart-profile.mjs`; canonical public import: `skill-family-harness-node/quickstart-profile`; historical migration alias: `skill-family-harness-node/candidate/quickstart-profile`.
|
|
223
225
|
<!-- agent-quick-reference:end -->
|
package/README.zh-CN.md
CHANGED
|
@@ -5,28 +5,29 @@
|
|
|
5
5
|
|
|
6
6
|
# skill-family-harness-node
|
|
7
7
|
|
|
8
|
-
<!-- release-skill:release-version: 0.
|
|
8
|
+
<!-- release-skill:release-version: 0.10.0 -->
|
|
9
9
|
|
|
10
10
|
Contracts 机制协议的**唯一默认 Node 实现**。这是一个薄运行时(thin runtime):只实现机制协议,不引入业务语义,不做第二语言实现。
|
|
11
11
|
|
|
12
12
|
<!-- release-skill:managed:start id=latest-release -->
|
|
13
|
-
**0.
|
|
13
|
+
**0.10.0** (2026-08-24)
|
|
14
14
|
|
|
15
|
-
Harness 0.
|
|
15
|
+
Harness 0.10.0 增加规范入口,复用既有宿主机制,并从真实目录提供同级适配器只读验证。
|
|
16
16
|
|
|
17
17
|
**新增**
|
|
18
18
|
|
|
19
|
-
- 新增
|
|
20
|
-
-
|
|
21
|
-
-
|
|
19
|
+
- 新增 skill-family-harness-node/quickstart-profile 与 skill-family-harness-node/rename-directory-no-replace 规范导出。
|
|
20
|
+
- 复用 filesystem-root binding、严格不替换发布、原子替换和既有构建摘要,支持 Kit 的本地宿主 install/update。
|
|
21
|
+
- 新增 `verifyPeerAdapterDirectories`,重新枚举 peer 根目录,验证共同闭包、逐字节摘要、标准 manifest 和完整 logicalMappings,不写入目录。
|
|
22
22
|
|
|
23
23
|
**变更**
|
|
24
24
|
|
|
25
|
-
-
|
|
25
|
+
- 历史 candidate 导出继续作为同源迁移别名,机制登记表不变。
|
|
26
|
+
- validate-many-by-schema-id 及错误语义不变;受管 Bundle 让历史与规范 Schema ID 共用同一 validator。
|
|
26
27
|
|
|
27
28
|
**升级说明**
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
消费者应把三个包的精确 pin 更新到 0.10.0,并把历史 candidate 导入和 Schema ID 一次迁移到规范身份。低层不替换原语仍不同于稳定 fixed-set-publication API,消费者按所需合同选择。
|
|
30
31
|
<!-- release-skill:managed:end id=latest-release -->
|
|
31
32
|
|
|
32
33
|
## 解决的问题
|
|
@@ -40,14 +41,14 @@ Harness 消费 `skill-family-contracts`(工作区依赖),复用其方言
|
|
|
40
41
|
## 安装和最小示例
|
|
41
42
|
|
|
42
43
|
```sh
|
|
43
|
-
npm install skill-family-harness-node@0.
|
|
44
|
+
npm install skill-family-harness-node@0.10.0
|
|
44
45
|
npm info skill-family-harness-node --help
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
最小示例演示在 Node 内校验一份契约文档:
|
|
48
49
|
|
|
49
50
|
```js
|
|
50
|
-
// 从空目录运行:npm install skill-family-harness-node@0.
|
|
51
|
+
// 从空目录运行:npm install skill-family-harness-node@0.10.0
|
|
51
52
|
import { validateContractDocument } from "skill-family-harness-node";
|
|
52
53
|
|
|
53
54
|
const document = {
|
|
@@ -76,12 +77,12 @@ import {
|
|
|
76
77
|
createQuickstartTask,
|
|
77
78
|
wrapQuickstartResult,
|
|
78
79
|
verifyQuickstartExchange,
|
|
79
|
-
} from "skill-family-harness-node/
|
|
80
|
+
} from "skill-family-harness-node/quickstart-profile";
|
|
80
81
|
```
|
|
81
82
|
|
|
82
83
|
v2 机制会重算每个 path-backed output 和 evidence Resource 的真实字节摘要,并拒绝重复 Resource id、correlation 漂移、Task digest 变化,以及缺失或错配的 evidence binding。它不执行领域审计,不选择 method,不编排重试,也不拥有生命周期状态。
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
该能力仍是 **candidate**,评估时必须精确锁定三个 Foundation 包。0.10.0 新增上面的规范入口;历史 `/candidate/quickstart-profile` 入口作为同源迁移别名继续可用。消费者迁移一次后,未来晋升 stable 不再切入口或重建相同 Bundle。仍生产 candidate v1 交换的接入必须继续精确锁定 `0.2.1`。
|
|
85
86
|
|
|
86
87
|
## 典型使用场景
|
|
87
88
|
|
|
@@ -168,7 +169,7 @@ v2 机制会重算每个 path-backed output 和 evidence Resource 的真实字
|
|
|
168
169
|
### Do not use when
|
|
169
170
|
|
|
170
171
|
- 需要把文件选择的业务规则放入 Foundation(业务规则由调用方拥有)。
|
|
171
|
-
-
|
|
172
|
+
- 需要宿主身份策略、宿主 driver、远端发布、删除式 uninstall、Qoder 完整 driver 或二进制 adapter source(明确 unsupported)。
|
|
172
173
|
- 需要领域审计语义、重试编排或兼容性已冻结的 Quickstart API。
|
|
173
174
|
|
|
174
175
|
### Capability selection
|
|
@@ -213,12 +214,12 @@ v2 机制会重算每个 path-backed output 和 evidence Resource 的真实字
|
|
|
213
214
|
### Route elsewhere when
|
|
214
215
|
|
|
215
216
|
- 业务状态机/终态:转 loop-agent。
|
|
216
|
-
-
|
|
217
|
+
- 宿主身份策略、宿主 driver 和生命周期授权归 Engineering Kit;Harness 只提供可复用的绑定读取、严格发布、原子写、闭包和探测机制。
|
|
217
218
|
- 领域审计语义:转独立审计消费者。
|
|
218
219
|
|
|
219
220
|
### Machine-readable sources
|
|
220
221
|
|
|
221
222
|
- 公开能力目录:[`capability-catalog.json`](https://ifoohoo.github.io/skill-family-engineering-kit/agents/capability-catalog.json)(`foundation.harness.*` 条目)。
|
|
222
223
|
- 包内源:`src/*.mjs`。
|
|
223
|
-
- 包内 Candidate 源:`candidate/quickstart-profile.mjs
|
|
224
|
+
- 包内 Candidate 源:`candidate/quickstart-profile.mjs`;规范公共导入:`skill-family-harness-node/quickstart-profile`;历史迁移别名:`skill-family-harness-node/candidate/quickstart-profile`。
|
|
224
225
|
<!-- agent-quick-reference:end -->
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
validateHarnessSurfaceDetectorDocument,
|
|
7
7
|
validateHarnessSurfaceInventoryDocument,
|
|
8
8
|
validateQuickstartProfileDocument,
|
|
9
|
-
} from "skill-family-contracts/
|
|
9
|
+
} from "skill-family-contracts/quickstart-profile";
|
|
10
10
|
import { lstat, readdir, readFile, realpath } from "node:fs/promises";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@pnpm/lockfile.fs": "1001.1.35",
|
|
12
12
|
"ipaddr.js": "2.5.0",
|
|
13
|
-
"skill-family-contracts": "0.
|
|
13
|
+
"skill-family-contracts": "0.10.0",
|
|
14
14
|
"yaml": "2.9.0"
|
|
15
15
|
},
|
|
16
16
|
"description": "Thin Node.js mechanism runtime for Skill Family engineering contracts.",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
".": "./src/index.mjs",
|
|
23
23
|
"./candidate/quickstart-profile": "./candidate/quickstart-profile.mjs",
|
|
24
24
|
"./candidate/rename-directory-no-replace": "./candidate/rename-directory-no-replace/rename-directory-no-replace.mjs",
|
|
25
|
-
"./fixed-set-publication": "./src/fixed-set-publication.mjs"
|
|
25
|
+
"./fixed-set-publication": "./src/fixed-set-publication.mjs",
|
|
26
|
+
"./quickstart-profile": "./candidate/quickstart-profile.mjs",
|
|
27
|
+
"./rename-directory-no-replace": "./candidate/rename-directory-no-replace/rename-directory-no-replace.mjs"
|
|
26
28
|
},
|
|
27
29
|
"files": [
|
|
28
30
|
"src",
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
"url": "https://github.com/ifoohoo/skill-family-harness-node.git"
|
|
47
49
|
},
|
|
48
50
|
"type": "module",
|
|
49
|
-
"version": "0.
|
|
51
|
+
"version": "0.10.0",
|
|
50
52
|
"scripts": {
|
|
51
53
|
"check": "node --test",
|
|
52
54
|
"test": "node --test"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
version: 0.10.0
|
|
2
|
+
date: 2026-08-24
|
|
3
|
+
locales:
|
|
4
|
+
en:
|
|
5
|
+
summary: Harness 0.10.0 adds canonical entrypoints, reuses existing host mechanisms, and adds read-only peer adapter verification from real directories.
|
|
6
|
+
changes:
|
|
7
|
+
added:
|
|
8
|
+
- Adds skill-family-harness-node/quickstart-profile and skill-family-harness-node/rename-directory-no-replace canonical exports.
|
|
9
|
+
- Reuses filesystem-root binding, strict no-replace publication, atomic replacement, and existing build digests for the Kit's local host install/update path.
|
|
10
|
+
- Adds `verifyPeerAdapterDirectories`, which re-enumerates peer roots and verifies common closure, byte digests, standard manifests, and complete logical mappings without writing them.
|
|
11
|
+
changed:
|
|
12
|
+
- Keeps each historical candidate export as a same-source migration alias and leaves the mechanism registry unchanged.
|
|
13
|
+
- Keeps validate-many-by-schema-id and its error semantics unchanged while managed Bundles accept historical and canonical Schema IDs through the same validator.
|
|
14
|
+
upgradeNotes: Update all three exact pins to 0.10.0 and migrate historical candidate imports and Schema IDs once to canonical identities. The low-level no-replace primitive remains distinct from the stable fixed-set-publication API; choose the contract that matches the use case.
|
|
15
|
+
zh-CN:
|
|
16
|
+
summary: Harness 0.10.0 增加规范入口,复用既有宿主机制,并从真实目录提供同级适配器只读验证。
|
|
17
|
+
changes:
|
|
18
|
+
added:
|
|
19
|
+
- 新增 skill-family-harness-node/quickstart-profile 与 skill-family-harness-node/rename-directory-no-replace 规范导出。
|
|
20
|
+
- 复用 filesystem-root binding、严格不替换发布、原子替换和既有构建摘要,支持 Kit 的本地宿主 install/update。
|
|
21
|
+
- 新增 `verifyPeerAdapterDirectories`,重新枚举 peer 根目录,验证共同闭包、逐字节摘要、标准 manifest 和完整 logicalMappings,不写入目录。
|
|
22
|
+
changed:
|
|
23
|
+
- 历史 candidate 导出继续作为同源迁移别名,机制登记表不变。
|
|
24
|
+
- validate-many-by-schema-id 及错误语义不变;受管 Bundle 让历史与规范 Schema ID 共用同一 validator。
|
|
25
|
+
upgradeNotes: 消费者应把三个包的精确 pin 更新到 0.10.0,并把历史 candidate 导入和 Schema ID 一次迁移到规范身份。低层不替换原语仍不同于稳定 fixed-set-publication API,消费者按所需合同选择。
|
package/src/index.mjs
CHANGED
|
@@ -148,6 +148,7 @@ export {
|
|
|
148
148
|
materializeAdapterBuild,
|
|
149
149
|
probeVersionVector,
|
|
150
150
|
} from "./host.mjs";
|
|
151
|
+
export { verifyPeerAdapterDirectories } from "./peer-adapter.mjs";
|
|
151
152
|
|
|
152
153
|
// Deterministic report layer (FND-ADR-005): validate -> render -> bind -> check.
|
|
153
154
|
// Pure functions only: no clock, no environment, no network, no model calls.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
2
|
+
import { TextDecoder } from "node:util";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { canonicalJson, validateDocument } from "skill-family-contracts";
|
|
5
|
+
import { classifyPathInput, resolveContained } from "./paths.mjs";
|
|
6
|
+
import { createFilesystemRootBinding, readFileBound } from "./bound-read.mjs";
|
|
7
|
+
import { buildAdapterClosure } from "./host.mjs";
|
|
8
|
+
import { HARNESS_ERROR_KINDS, HarnessError, mechanismError } from "./errors.mjs";
|
|
9
|
+
|
|
10
|
+
const REQUEST_SCHEMA_ID = "https://contracts.skill-family.example/v1/adapter-peer-verification-request.json";
|
|
11
|
+
const RESULT_SCHEMA_ID = "https://contracts.skill-family.example/v1/adapter-peer-verification-result.json";
|
|
12
|
+
|
|
13
|
+
function invalidParams(message, details) {
|
|
14
|
+
return new HarnessError("SFC2003", message, { ...(details ?? {}), kind: "invalid-params" });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function validate(document, schemaId, message) {
|
|
18
|
+
const result = validateDocument(document, { schemaId, dialect: "2020-12", policy: "strict" });
|
|
19
|
+
if (!result.valid) throw mechanismError(HARNESS_ERROR_KINDS.HOST_CONTRACT_INVALID, message, { errors: result.errors });
|
|
20
|
+
return result.data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function relativeChild(parent, name) {
|
|
24
|
+
const rel = parent ? `${parent}/${name}` : name;
|
|
25
|
+
const classified = classifyPathInput(rel);
|
|
26
|
+
if (!classified.ok || path.posix.normalize(rel) !== rel) {
|
|
27
|
+
throw mechanismError(classified.kind ?? HARNESS_ERROR_KINDS.INVALID_PATH, "peer adapter member path is not portable", { input: rel });
|
|
28
|
+
}
|
|
29
|
+
return rel;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function collectFiles(root, rootBinding) {
|
|
33
|
+
const files = [];
|
|
34
|
+
async function walk(relDir) {
|
|
35
|
+
const directoryPath = relDir ? await resolveContained(root, relDir) : root;
|
|
36
|
+
const directoryStat = await lstat(directoryPath).catch((cause) => {
|
|
37
|
+
throw mechanismError(cause?.code === "ENOENT" ? HARNESS_ERROR_KINDS.MISSING_RESOURCE : HARNESS_ERROR_KINDS.READ_FAILED, "peer adapter directory cannot be inspected", { input: relDir || "." });
|
|
38
|
+
});
|
|
39
|
+
if (directoryStat.isSymbolicLink()) throw mechanismError(HARNESS_ERROR_KINDS.SYMLINK_ESCAPE, "peer adapter directory contains a symbolic link", { input: relDir || "." });
|
|
40
|
+
if (!directoryStat.isDirectory()) throw mechanismError(HARNESS_ERROR_KINDS.READ_FAILED, "peer adapter path is not a directory", { input: relDir || "." });
|
|
41
|
+
let entries;
|
|
42
|
+
try {
|
|
43
|
+
entries = await opendir(directoryPath);
|
|
44
|
+
} catch (cause) {
|
|
45
|
+
throw mechanismError(HARNESS_ERROR_KINDS.READ_FAILED, "peer adapter directory cannot be enumerated", { input: relDir || ".", code: cause?.code ?? "unknown" });
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
for await (const entry of entries) {
|
|
49
|
+
const relPath = relativeChild(relDir, entry.name);
|
|
50
|
+
const absolutePath = await resolveContained(root, relPath);
|
|
51
|
+
const entryStat = await lstat(absolutePath).catch((cause) => {
|
|
52
|
+
throw mechanismError(cause?.code === "ENOENT" ? HARNESS_ERROR_KINDS.MISSING_RESOURCE : HARNESS_ERROR_KINDS.READ_FAILED, "peer adapter member disappeared during enumeration", { input: relPath });
|
|
53
|
+
});
|
|
54
|
+
if (entryStat.isSymbolicLink()) throw mechanismError(HARNESS_ERROR_KINDS.SYMLINK_ESCAPE, "peer adapter member is a symbolic link", { input: relPath });
|
|
55
|
+
if (entryStat.isDirectory()) {
|
|
56
|
+
await walk(relPath);
|
|
57
|
+
} else if (entryStat.isFile()) {
|
|
58
|
+
const receipt = await readFileBound(root, relPath, { rootBinding });
|
|
59
|
+
let content;
|
|
60
|
+
try {
|
|
61
|
+
content = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(receipt.content);
|
|
62
|
+
} catch {
|
|
63
|
+
throw mechanismError(HARNESS_ERROR_KINDS.READ_FAILED, "peer adapter member is not valid UTF-8", { input: relPath, encoding: "utf8" });
|
|
64
|
+
}
|
|
65
|
+
files.push({ path: relPath, content, sha256: receipt.sha256, bytes: receipt.bytes });
|
|
66
|
+
} else {
|
|
67
|
+
throw mechanismError(HARNESS_ERROR_KINDS.READ_FAILED, "peer adapter contains a non-regular member", { input: relPath });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} finally {
|
|
71
|
+
await entries.close().catch(() => {});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
await walk("");
|
|
75
|
+
files.sort((left, right) => left.path.localeCompare(right.path));
|
|
76
|
+
return files;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function sourceFromFiles(skillFamilyId, files) {
|
|
80
|
+
const skills = new Map();
|
|
81
|
+
for (const file of files) {
|
|
82
|
+
const slash = file.path.indexOf("/");
|
|
83
|
+
if (slash <= 0 || slash === file.path.length - 1) throw invalidParams("peer adapter files must be nested below a skill directory", { path: file.path });
|
|
84
|
+
const skillId = file.path.slice(0, slash);
|
|
85
|
+
const skillPath = file.path.slice(slash + 1);
|
|
86
|
+
if (!skills.has(skillId)) skills.set(skillId, []);
|
|
87
|
+
skills.get(skillId).push({ path: skillPath, content: file.content });
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
schemaVersion: 1,
|
|
91
|
+
kind: "skill-family.adapter-source",
|
|
92
|
+
skillFamilyId,
|
|
93
|
+
skills: [...skills.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([id, entries]) => ({
|
|
94
|
+
id,
|
|
95
|
+
files: entries.sort((left, right) => left.path.localeCompare(right.path)),
|
|
96
|
+
})),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function verifyMappings(peer, manifest) {
|
|
101
|
+
const mappings = peer.logicalMappings;
|
|
102
|
+
const logicalIds = new Set();
|
|
103
|
+
const sourcePaths = new Set();
|
|
104
|
+
const expectedSkillEntries = new Set(manifest.sourceClosure.members
|
|
105
|
+
.filter((member) => member.sourcePath.split("/").length === 2 && member.sourcePath.endsWith("/SKILL.md"))
|
|
106
|
+
.map((member) => member.sourcePath));
|
|
107
|
+
if (mappings.length !== expectedSkillEntries.size) throw mechanismError(HARNESS_ERROR_KINDS.HOST_CONTRACT_INVALID, "peer logicalMappings must cover every skill entry exactly once");
|
|
108
|
+
const output = mappings.map((mapping) => {
|
|
109
|
+
if (logicalIds.has(mapping.logicalId)) throw mechanismError(HARNESS_ERROR_KINDS.HOST_CONTRACT_INVALID, "peer logicalMappings contain a duplicate logicalId", { logicalId: mapping.logicalId });
|
|
110
|
+
logicalIds.add(mapping.logicalId);
|
|
111
|
+
if (sourcePaths.has(mapping.sourcePath)) throw mechanismError(HARNESS_ERROR_KINDS.HOST_CONTRACT_INVALID, "peer logicalMappings contain a duplicate sourcePath", { sourcePath: mapping.sourcePath });
|
|
112
|
+
sourcePaths.add(mapping.sourcePath);
|
|
113
|
+
const sourceParts = mapping.sourcePath.split("/");
|
|
114
|
+
if (sourceParts.length !== 2 || sourceParts[1] !== "SKILL.md" || !expectedSkillEntries.has(mapping.sourcePath)) throw mechanismError(HARNESS_ERROR_KINDS.HOST_CONTRACT_INVALID, "peer logicalMapping must point to a root-level existing SKILL.md", { sourcePath: mapping.sourcePath });
|
|
115
|
+
const expectedSkillId = sourceParts[0];
|
|
116
|
+
if (mapping.skillId !== expectedSkillId) throw mechanismError(HARNESS_ERROR_KINDS.HOST_CONTRACT_INVALID, "peer logicalMapping skillId does not match its sourcePath", { sourcePath: mapping.sourcePath });
|
|
117
|
+
return { ...mapping, target: `${peer.pathCategory.relPath}/${mapping.sourcePath}` };
|
|
118
|
+
}).sort((left, right) => left.logicalId.localeCompare(right.logicalId));
|
|
119
|
+
if (canonicalJson([...sourcePaths].sort()) !== canonicalJson([...expectedSkillEntries].sort())) throw mechanismError(HARNESS_ERROR_KINDS.HOST_CONTRACT_INVALID, "peer logicalMappings do not cover the complete SKILL.md set");
|
|
120
|
+
return output;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function mappingSemantics(mappings) {
|
|
124
|
+
return mappings.map(({ logicalId, skillId, sourcePath, entryType, userInvocable }) => ({ logicalId, skillId, sourcePath, entryType, userInvocable }))
|
|
125
|
+
.sort((left, right) => left.logicalId.localeCompare(right.logicalId));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function assertRawBytesMatch(files, manifest) {
|
|
129
|
+
const byPath = new Map(files.map((file) => [file.path, file]));
|
|
130
|
+
for (const member of manifest.sourceClosure.members) {
|
|
131
|
+
const file = byPath.get(member.sourcePath);
|
|
132
|
+
if (!file || file.sha256 !== member.sha256 || file.bytes !== member.bytes) {
|
|
133
|
+
throw mechanismError(HARNESS_ERROR_KINDS.MANIFEST_MISMATCH, "adapter manifest does not match the original bound bytes", { sourcePath: member.sourcePath });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Reads and verifies two or more real peer adapter directories. */
|
|
139
|
+
export async function verifyPeerAdapterDirectories({ request, peerRoots } = {}) {
|
|
140
|
+
const verifiedRequest = validate(request, REQUEST_SCHEMA_ID, "peer adapter verification request fails its registered contract");
|
|
141
|
+
if (!peerRoots || typeof peerRoots !== "object" || Array.isArray(peerRoots)) throw invalidParams("verifyPeerAdapterDirectories requires a peerRoots object");
|
|
142
|
+
const requestIds = verifiedRequest.peers.map((peer) => peer.peerId);
|
|
143
|
+
if (new Set(requestIds).size !== requestIds.length) throw invalidParams("peerIds must be unique");
|
|
144
|
+
const rootIds = Object.keys(peerRoots);
|
|
145
|
+
if (canonicalJson([...rootIds].sort()) !== canonicalJson([...requestIds].sort())) throw invalidParams("peerRoots must contain exactly one absolute root for every requested peer");
|
|
146
|
+
|
|
147
|
+
const built = [];
|
|
148
|
+
for (const peer of verifiedRequest.peers) {
|
|
149
|
+
const root = peerRoots[peer.peerId];
|
|
150
|
+
if (typeof root !== "string" || !path.isAbsolute(root)) throw invalidParams("peer root must be an absolute path", { peerId: peer.peerId });
|
|
151
|
+
const rootBinding = await createFilesystemRootBinding(root);
|
|
152
|
+
const files = await collectFiles(root, rootBinding);
|
|
153
|
+
const build = buildAdapterClosure({ hostId: peer.hostId, pathCategory: peer.pathCategory, input: sourceFromFiles(verifiedRequest.skillFamilyId, files) });
|
|
154
|
+
assertRawBytesMatch(files, build.manifest);
|
|
155
|
+
const logicalMappings = verifyMappings(peer, build.manifest);
|
|
156
|
+
built.push({ peer, build, logicalMappings });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const sorted = [...built].sort((left, right) => left.peer.peerId.localeCompare(right.peer.peerId));
|
|
160
|
+
const common = sorted[0].build.manifest.sourceClosure;
|
|
161
|
+
const commonMappings = mappingSemantics(sorted[0].logicalMappings);
|
|
162
|
+
for (const entry of sorted.slice(1)) {
|
|
163
|
+
if (canonicalJson(entry.build.manifest.sourceClosure) !== canonicalJson(common)) {
|
|
164
|
+
throw mechanismError(HARNESS_ERROR_KINDS.CLOSURE_CONFLICT, "peer adapter source closures differ", { peerId: entry.peer.peerId });
|
|
165
|
+
}
|
|
166
|
+
if (canonicalJson(mappingSemantics(entry.logicalMappings)) !== canonicalJson(commonMappings)) {
|
|
167
|
+
throw mechanismError(HARNESS_ERROR_KINDS.CLOSURE_CONFLICT, "peer logical mapping semantics differ", { peerId: entry.peer.peerId });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const result = {
|
|
171
|
+
schemaVersion: 1,
|
|
172
|
+
kind: "skill-family.adapter-peer-verification-result",
|
|
173
|
+
status: "verified",
|
|
174
|
+
decision: "peer-verification",
|
|
175
|
+
skillFamilyId: verifiedRequest.skillFamilyId,
|
|
176
|
+
commonSourceClosure: common,
|
|
177
|
+
peers: sorted.map(({ peer, build, logicalMappings }) => ({
|
|
178
|
+
peerId: peer.peerId,
|
|
179
|
+
hostId: peer.hostId,
|
|
180
|
+
pathCategory: peer.pathCategory,
|
|
181
|
+
manifest: build.manifest,
|
|
182
|
+
logicalMappings,
|
|
183
|
+
})),
|
|
184
|
+
};
|
|
185
|
+
return validate(result, RESULT_SCHEMA_ID, "peer adapter verification result fails its registered contract");
|
|
186
|
+
}
|