@yottameta/yotta-dev-mcp-plugin 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +3 -3
- package/.claude-plugin/marketplace.json +3 -3
- package/package.json +1 -1
- package/plugin.json +2 -2
- package/skills/yotta-dev-mcp/SKILL.md +19 -5
- package/skills/yotta-dev-mcp/references/adapters.md +69 -0
- package/skills/yotta-dev-mcp/references/architecture-contract.md +256 -0
- package/skills/yotta-dev-mcp/references/tools.md +147 -1
- package/skills/yotta-dev-mcp/scripts/dev_adapters.py +609 -0
- package/skills/yotta-dev-mcp/scripts/dev_architecture.py +379 -0
- package/skills/yotta-dev-mcp/scripts/dev_common.py +144 -0
- package/skills/yotta-dev-mcp/scripts/dev_contract.py +830 -0
- package/skills/yotta-dev-mcp/scripts/dev_engine.py +258 -134
- package/skills/yotta-dev-mcp/scripts/dev_impact.py +556 -0
- package/skills/yotta-dev-mcp/scripts/dev_model.py +435 -0
- package/skills/yotta-dev-mcp/scripts/dev_selftest.py +534 -0
- package/skills/yotta-dev-mcp/scripts/dev_verify.py +450 -0
- package/skills/yotta-dev-mcp/scripts/yotta_dev_mcp.py +234 -5
- package/skills/yotta-dev-mcp/server.json +3 -3
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"authentication": "ON_INSTALL"
|
|
13
13
|
},
|
|
14
14
|
"category": "Developer Tools",
|
|
15
|
-
"version": "0.
|
|
16
|
-
"description": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, find_code, compress_output, review_code, review_diff, mcp_doctor, scan_secrets, scan_dependencies, check_publish_readiness, run_checks, scaffold_skill and workflow_state. Python 3.8+ standard library, offline by default; writes and command execution require explicit flags.",
|
|
15
|
+
"version": "0.2.0",
|
|
16
|
+
"description": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, system_model, architecture_review, impact_analysis, verify_change, self_test, run_adapter, find_code, compress_output, review_code, review_diff, mcp_doctor, scan_secrets, scan_dependencies, check_publish_readiness, run_checks, scaffold_skill and workflow_state. Reads an optional .yotta/architecture.json contract plus .yotta/verification.json policy for architecture reviews, change impact cones and the L0-L5 evidence ledger. Optional explicit adapters integrate import-linter, dependency-cruiser and Repomix without auto-install or network access. Python 3.8+ standard library, offline by default; writes and command execution require explicit flags.",
|
|
17
17
|
"interface": {
|
|
18
18
|
"displayName": "元开 yotta-dev-mcp",
|
|
19
|
-
"shortDescription": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map,
|
|
19
|
+
"shortDescription": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, system_model, architec",
|
|
20
20
|
"developerName": "YottaMeta",
|
|
21
21
|
"category": "Developer Tools"
|
|
22
22
|
}
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"authentication": "ON_INSTALL"
|
|
13
13
|
},
|
|
14
14
|
"category": "Developer Tools",
|
|
15
|
-
"version": "0.
|
|
16
|
-
"description": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, find_code, compress_output, review_code, review_diff, mcp_doctor, scan_secrets, scan_dependencies, check_publish_readiness, run_checks, scaffold_skill and workflow_state. Python 3.8+ standard library, offline by default; writes and command execution require explicit flags.",
|
|
15
|
+
"version": "0.2.0",
|
|
16
|
+
"description": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, system_model, architecture_review, impact_analysis, verify_change, self_test, run_adapter, find_code, compress_output, review_code, review_diff, mcp_doctor, scan_secrets, scan_dependencies, check_publish_readiness, run_checks, scaffold_skill and workflow_state. Reads an optional .yotta/architecture.json contract plus .yotta/verification.json policy for architecture reviews, change impact cones and the L0-L5 evidence ledger. Optional explicit adapters integrate import-linter, dependency-cruiser and Repomix without auto-install or network access. Python 3.8+ standard library, offline by default; writes and command execution require explicit flags.",
|
|
17
17
|
"interface": {
|
|
18
18
|
"displayName": "元开 yotta-dev-mcp",
|
|
19
|
-
"shortDescription": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map,
|
|
19
|
+
"shortDescription": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, system_model, architec",
|
|
20
20
|
"developerName": "YottaMeta",
|
|
21
21
|
"category": "Developer Tools"
|
|
22
22
|
}
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "yotta-dev-mcp",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, find_code, compress_output, review_code, review_diff, mcp_doctor, scan_secrets, scan_dependencies, check_publish_readiness, run_checks, scaffold_skill and workflow_state. Python 3.8+ standard library, offline by default; writes and command execution require explicit flags.",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "YuanKai (yotta-dev-mcp) - deterministic local development tools exposed over stdio MCP: repo_map, system_model, architecture_review, impact_analysis, verify_change, self_test, run_adapter, find_code, compress_output, review_code, review_diff, mcp_doctor, scan_secrets, scan_dependencies, check_publish_readiness, run_checks, scaffold_skill and workflow_state. Reads an optional .yotta/architecture.json contract plus .yotta/verification.json policy for architecture reviews, change impact cones and the L0-L5 evidence ledger. Optional explicit adapters integrate import-linter, dependency-cruiser and Repomix without auto-install or network access. Python 3.8+ standard library, offline by default; writes and command execution require explicit flags.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "YottaMeta",
|
|
8
8
|
"url": "https://github.com/YottaMeta"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: yotta-dev-mcp
|
|
3
|
-
description: 元开(yotta-dev-mcp)—— 本地、确定性的开发工具 MCP,把只读默认的开发能力暴露为 stdio MCP server:repo_map / find_code / compress_output / review_code / review_diff / mcp_doctor / scan_secrets / scan_dependencies / check_publish_readiness / run_checks / scaffold_skill / workflow_state。触发:让 AI
|
|
4
|
-
version: 0.
|
|
3
|
+
description: 元开(yotta-dev-mcp)—— 本地、确定性的开发工具 MCP,把只读默认的开发能力暴露为 stdio MCP server:repo_map / system_model / architecture_review / impact_analysis / verify_change / self_test / run_adapter / find_code / compress_output / review_code / review_diff / mcp_doctor / scan_secrets / scan_dependencies / check_publish_readiness / run_checks / scaffold_skill / workflow_state。触发:让 AI 在陌生项目里先做结构盘点、构建系统模型或架构契约(.yotta/architecture.json)、按契约评审架构、分析改动影响锥与回归面、按验证阶梯产出证据账本、对元开自身做完整性 / 反证自测、探测或显式运行 import-linter / dependency-cruiser / Repomix 可选适配器、定位代码、评审改动、扫描密钥/依赖、检查发布就绪、运行白名单检查、生成脚手架或读取 .workflow 状态时;或用户说 元开 / 开发能力 MCP / yotta-dev-mcp / 代码库地图 / 系统模型 / 架构契约 / 架构评审 / 影响分析 / 验证账本 / 反证自测 / 代码评审 MCP / 适配器 等。边界:Python 3.8+ 标准库、离线默认;除 run_checks(显式 allow_execute)、verify_change 的 L2-L4 策略检查(显式 allow_execute)与 self_test 的测试子集(显式 allow_execute)、run_adapter 的 action=run(显式 allow_execute)、scaffold_skill / workflow_state 的显式 apply 外均为只读;不上传源码、不自动修改、不提交、不联网查询包是否存在、不自动安装或下载适配器。
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
license: MIT
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -13,6 +13,12 @@ license: MIT
|
|
|
13
13
|
## 何时使用
|
|
14
14
|
|
|
15
15
|
- 接手陌生项目:先 `repo_map` 看模块、依赖和入口,再 `find_code` 定位。
|
|
16
|
+
- 架构与影响分析:先写 `.yotta/architecture.json`,再用 `system_model` 拿分层、依赖、测试映射与 `UNKNOWN` 清单。
|
|
17
|
+
- 契约评审:用 `architecture_review` 查依赖规则、边界可见性与数据归属,每条给证据与严重级。
|
|
18
|
+
- 改动前评估:用 `impact_analysis` 从改动文件 / diff / 目标符号走出影响锥、映射测试与回滚探针。
|
|
19
|
+
- 改动后验证:用 `verify_change` 跑 L0 / L1 默认检查,按需结合 `.yotta/verification.json` 与 `allow_execute=true` 执行 L2-L4 白名单检查,产出可复算账本。
|
|
20
|
+
- 自身完整性:用 `self_test` 检查文件、版本、工具契约、写闸门与 seeded defect / mutation 反证。
|
|
21
|
+
- 可选增强:用 `run_adapter` 先 `action=list` 探测 import-linter / dependency-cruiser / Repomix,再按需 `action=run` + `allow_execute=true`;缺工具或配置返回 UNKNOWN,不自动安装、不自动下载。
|
|
16
22
|
- 评审改动:`review_diff` 只看新增行;`review_code` 对文件或仓库做规则检查。
|
|
17
23
|
- 长日志 / 长命令输出:`compress_output` 保错误、错误栈和首尾上下文。
|
|
18
24
|
- 本机排查:`mcp_doctor` 只读检查技能目录和 MCP JSON 配置。
|
|
@@ -40,6 +46,12 @@ python scripts/yotta_dev_mcp.py
|
|
|
40
46
|
| 工具 | 用途 | 写入 |
|
|
41
47
|
|---|---|---|
|
|
42
48
|
| `repo_map` | 模块、导入、入口点地图 | 否 |
|
|
49
|
+
| `system_model` | 系统模型:模块、依赖、入口、测试映射、配置与数据归属;附带契约分层,输出 PASS / FAIL / UNKNOWN | 否 |
|
|
50
|
+
| `architecture_review` | 按契约评审依赖规则、边界可见性与数据归属;critical / high 判 FAIL,medium / low 只告警 | 否 |
|
|
51
|
+
| `impact_analysis` | 变更影响锥:直接消费者、受影响层 / 边界 / 存储 / 不变量、映射测试、风险分级与回滚探针 | 否 |
|
|
52
|
+
| `verify_change` | L0-L5 验证阶梯与证据账本:L0 / L1 默认,L2-L4 需策略声明 + 显式执行,L5 始终留在未验证项 | 仅显式 allow_execute 的 L2-L4 |
|
|
53
|
+
| `self_test` | 文件 / 版本 / 工具契约 / 写闸门 / seeded defect 与 mutation 反证自测 | 仅显式 allow_execute 的测试子集 |
|
|
54
|
+
| `run_adapter` | 探测或显式运行 import-linter / dependency-cruiser / Repomix;固定 argv、项目内 cwd、有界输出与哈希 | 仅 action=run + 显式 allow_execute |
|
|
43
55
|
| `find_code` | 符号 / 文本定位,结果有上限 | 否 |
|
|
44
56
|
| `compress_output` | 保留错误与首尾的长输出压缩 | 否 |
|
|
45
57
|
| `review_code` | 规则化代码评审,带行号与建议 | 否 |
|
|
@@ -52,16 +64,18 @@ python scripts/yotta_dev_mcp.py
|
|
|
52
64
|
| `scaffold_skill` | 生成最小技能脚手架,默认 dry-run | 仅显式 apply |
|
|
53
65
|
| `workflow_state` | 读取 `.workflow`,可选显式追加日志 | 仅显式 apply |
|
|
54
66
|
|
|
55
|
-
详细契约见 `references/tools.md`。
|
|
67
|
+
详细契约见 `references/tools.md`;架构契约、评审语义与影响锥字段见 `references/architecture-contract.md`。
|
|
56
68
|
|
|
57
69
|
## 边界
|
|
58
70
|
|
|
59
|
-
-
|
|
60
|
-
- `
|
|
71
|
+
- 会执行项目代码的工具默认关闭:`run_checks`、`verify_change` 的 L2-L4 策略检查、`self_test` 的测试子集都必须显式 `allow_execute=true`,且只运行白名单检查或已声明的策略检查。
|
|
72
|
+
- 外部适配器只在用户已安装时接入:`run_adapter` 不安装、不下载、不访问远端、不接收任意命令参数;工具缺失或配置缺失一律返回 `UNKNOWN` 并给出 next_step。
|
|
73
|
+
- `scaffold_skill` / `workflow_state` 默认只预览,显式 `apply=true` 才写入;脚手架拒绝覆盖已有非空目录,状态写入使用原子替换并为被覆盖文件保留 `.bak`。
|
|
61
74
|
- 不联网,不查询包是否存在于公共仓库。
|
|
62
75
|
- 不读取或修改 YottaCode 仓库。
|
|
63
76
|
- 结论是确定性静态判断,不替代人工评审与最终决策。
|
|
64
77
|
|
|
65
78
|
## 当前版本
|
|
66
79
|
|
|
80
|
+
- v0.2.0(2026-09-25):新增 `system_model`、`architecture_review`、`impact_analysis`、`verify_change`、`self_test`、`run_adapter`,以及 `.yotta/architecture.json` 与可选 `.yotta/verification.json` 契约(版本 1);工具总数 18,原 12 个工具行为不变。
|
|
67
81
|
- v0.1.1:品牌显示名统一为「元开」;功能与 12 个工具不变。
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Optional external adapters
|
|
2
|
+
|
|
3
|
+
`run_adapter` probes and explicitly runs mature third-party tools that the user
|
|
4
|
+
already installed. The core engine stays Python-standard-library-only; adapters
|
|
5
|
+
are optional evidence sources, never a required dependency.
|
|
6
|
+
|
|
7
|
+
## Adapter matrix
|
|
8
|
+
|
|
9
|
+
| Adapter | License | What it adds | Required config |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `import-linter` | BSD-2-Clause | Python import boundaries and layered contracts | `.importlinter`, `setup.cfg`, `tox.ini` or `pyproject.toml` |
|
|
12
|
+
| `dependency-cruiser` | MIT | JavaScript / TypeScript dependency rules | `.dependency-cruiser.js` / `.cjs` / `.mjs` / `.json` |
|
|
13
|
+
| `repomix` | MIT | Repository packing and context budget enforcement | optional `repomix.config.json` |
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
`action=list` only inspects the project-local `node_modules/.bin`, project
|
|
18
|
+
virtualenv directories and `PATH`. It does not execute anything. Each adapter
|
|
19
|
+
entry reports `available`, `ready`, `executable`, `executable_source`, `config`
|
|
20
|
+
and a reason when it is not ready.
|
|
21
|
+
|
|
22
|
+
`action=run` requires `allow_execute=true` and exactly one adapter. The command
|
|
23
|
+
arguments are fixed by the adapter implementation:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
lint-imports --config <detected-config>
|
|
27
|
+
depcruise --config <detected-config> --output-type json --progress none --exclude node_modules <target>
|
|
28
|
+
repomix --stdout --style xml --quiet --no-git-sort-by-changes [--token-budget N] <target>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
No adapter accepts arbitrary arguments, shell strings, remote repositories or
|
|
32
|
+
package installation. Repomix never receives `--remote` or
|
|
33
|
+
`--no-security-check`.
|
|
34
|
+
|
|
35
|
+
## Output
|
|
36
|
+
|
|
37
|
+
The run result contains:
|
|
38
|
+
|
|
39
|
+
- `status`: `PASS`, `FAIL` or `UNKNOWN`;
|
|
40
|
+
- `adapter`: detected executable, source, config and version;
|
|
41
|
+
- `command`: fixed argv, relative cwd, exit code, timeout flag and output hash;
|
|
42
|
+
- `findings`: normalized adapter violations with rule, severity, path and target;
|
|
43
|
+
- `content`: Repomix-only packed text metadata and bounded text;
|
|
44
|
+
- `next_step`: what to install, configure or rerun when the result is not PASS.
|
|
45
|
+
|
|
46
|
+
Missing tools, missing required config, invalid JSON output, timeouts and
|
|
47
|
+
non-whitelisted execution all degrade to `UNKNOWN`. Adapter findings are
|
|
48
|
+
reported separately; they do not silently change the status of
|
|
49
|
+
`system_model`, `architecture_review`, `impact_analysis` or `verify_change`.
|
|
50
|
+
|
|
51
|
+
## Safety boundary
|
|
52
|
+
|
|
53
|
+
Adapters are local-only and deterministic under the same repository state:
|
|
54
|
+
|
|
55
|
+
- executable discovery is limited to the project `node_modules/.bin`, project
|
|
56
|
+
virtualenvs and `PATH`;
|
|
57
|
+
- execution uses a fixed argv with `shell=False`;
|
|
58
|
+
- the working directory and target must stay inside the repository;
|
|
59
|
+
- output is bounded, hashed and never contains wall-clock timestamps;
|
|
60
|
+
- no package is installed, downloaded or updated by this tool.
|
|
61
|
+
|
|
62
|
+
## Command line
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
python scripts/dev_engine.py adapter . --action list
|
|
66
|
+
python scripts/dev_engine.py adapter . --action run --adapter import-linter --allow-execute
|
|
67
|
+
python scripts/dev_engine.py adapter . --action run --adapter dependency-cruiser --allow-execute
|
|
68
|
+
python scripts/dev_engine.py adapter . --action run --adapter repomix --allow-execute --token-budget 50000
|
|
69
|
+
```
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Architecture contract and system model
|
|
2
|
+
|
|
3
|
+
`system_model` builds a deterministic model of a local repository and attaches
|
|
4
|
+
layer data from an optional architecture contract. Everything runs offline with
|
|
5
|
+
the Python standard library; no file is written.
|
|
6
|
+
|
|
7
|
+
## Contract file
|
|
8
|
+
|
|
9
|
+
Path: `.yotta/architecture.json`. Plain JSON, version `1`.
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"version": 1,
|
|
14
|
+
"project": "demo",
|
|
15
|
+
"layers": [
|
|
16
|
+
{"id": "core", "title": "Core", "paths": ["src/core/**"], "risk": "high"},
|
|
17
|
+
{"id": "api", "paths": ["src/api/**"]},
|
|
18
|
+
{"id": "ui", "paths": ["src/ui/**"]}
|
|
19
|
+
],
|
|
20
|
+
"rules": [
|
|
21
|
+
{
|
|
22
|
+
"id": "core-no-ui",
|
|
23
|
+
"type": "forbid-dependency",
|
|
24
|
+
"from": "core",
|
|
25
|
+
"to": "ui",
|
|
26
|
+
"severity": "high",
|
|
27
|
+
"claim": "core must not import ui"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"boundaries": [
|
|
31
|
+
{"id": "public-api", "layer": "api", "paths": ["src/api/public/**"], "visibility": "public"}
|
|
32
|
+
],
|
|
33
|
+
"data_ownership": [
|
|
34
|
+
{"store": "memory-db", "owner": "core", "paths": ["var/memory/**"], "kind": "sqlite"}
|
|
35
|
+
],
|
|
36
|
+
"invariants": [
|
|
37
|
+
{"id": "no-plaintext-secrets", "claim": "secrets are never stored in plaintext",
|
|
38
|
+
"severity": "high", "check": "static"}
|
|
39
|
+
],
|
|
40
|
+
"risk_weights": {"core": 3, "api": 2, "ui": 1}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Fields
|
|
45
|
+
|
|
46
|
+
| Field | Required | Notes |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `version` | yes | Must be `1`. |
|
|
49
|
+
| `project` | no | Free-form name. |
|
|
50
|
+
| `layers` | yes | Layer id, optional title/description, `paths` globs, optional `risk`. |
|
|
51
|
+
| `rules` | no | `forbid-dependency` (`to` is one layer) or `allow-dependency` (`to` is a layer list). `from`, `to`, `severity` and `claim` describe the invariant. |
|
|
52
|
+
| `boundaries` | no | Layer id plus globs; `visibility` is `public`, `internal` or `private`. |
|
|
53
|
+
| `data_ownership` | no | Store id, owning layer, globs and optional `kind`. |
|
|
54
|
+
| `invariants` | no | id plus a non-empty `claim`; `check` is `static`, `command` or `manual`. |
|
|
55
|
+
| `risk_weights` | no | Layer id to a number between 0 and 5. |
|
|
56
|
+
|
|
57
|
+
Ids match `[a-z0-9][a-z0-9._-]{0,63}`. Paths are repository-relative POSIX
|
|
58
|
+
globs and must not be absolute or contain `..`.
|
|
59
|
+
|
|
60
|
+
### Glob rules
|
|
61
|
+
|
|
62
|
+
`*` stays inside one path segment, `**` crosses segments, `?` matches one
|
|
63
|
+
character, and a trailing `/` means the whole directory (`pkg/` equals
|
|
64
|
+
`pkg/**`). Matching is case-sensitive. Layers are evaluated in declaration
|
|
65
|
+
order and the first match wins; a module that matches several layers is
|
|
66
|
+
reported as `layer-overlap`.
|
|
67
|
+
|
|
68
|
+
### Validation findings
|
|
69
|
+
|
|
70
|
+
Every finding carries `code`, `severity`, `message`, a JSON `pointer`, the
|
|
71
|
+
contract `path` and short `evidence`. Severity `critical` or `high` makes the
|
|
72
|
+
contract `FAIL`; `medium` and `low` are advisory.
|
|
73
|
+
|
|
74
|
+
| Code | Meaning |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `contract-invalid-json` | The file is not valid JSON. |
|
|
77
|
+
| `contract-not-object` | The root value is not a JSON object. |
|
|
78
|
+
| `contract-unsupported-version` | `version` is missing or not `1`. |
|
|
79
|
+
| `contract-invalid-layer` / `contract-duplicate-layer` | Layer shape or ids are wrong. |
|
|
80
|
+
| `contract-layer-without-paths` | A layer declares no globs. |
|
|
81
|
+
| `contract-invalid-path` | A glob is absolute, escapes the root, or is empty. |
|
|
82
|
+
| `contract-invalid-rule` / `contract-duplicate-rule` | Rule shape, type or ids are wrong. |
|
|
83
|
+
| `contract-invalid-severity` / `contract-invalid-risk` | Enum values are outside the allowed set. |
|
|
84
|
+
| `contract-unknown-layer-ref` | A rule, boundary, store or risk weight points at a missing layer. |
|
|
85
|
+
| `contract-invalid-boundary` / `contract-invalid-store` / `contract-invalid-invariant` | Section entries are malformed. |
|
|
86
|
+
| `contract-unknown-key` | Unknown top-level key; reported as a warning and ignored. |
|
|
87
|
+
|
|
88
|
+
## system_model output
|
|
89
|
+
|
|
90
|
+
| Key | Content |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `status` | `PASS`, `FAIL` (contract has blocking findings) or `UNKNOWN` (something still needs evidence). |
|
|
93
|
+
| `contract` | Path, presence, validity, version, layer and rule ids, findings. |
|
|
94
|
+
| `model.modules` | Repository-relative module id, language, line count and resolved layer. |
|
|
95
|
+
| `model.layers` | Declared layers with the modules that match them. |
|
|
96
|
+
| `model.imports` | `source`, `target`, `kind`, `line` and the raw specifier. |
|
|
97
|
+
| `model.entrypoints` | Files that look like executable entrypoints. |
|
|
98
|
+
| `model.tests` | Test files and the internal modules they import. |
|
|
99
|
+
| `model.configs` | Configuration files with a coarse kind. |
|
|
100
|
+
| `model.data_stores` | Declared stores (with owner and owner modules) and detected local database files. |
|
|
101
|
+
| `unknowns` | `contract-missing`, `contract-invalid`, `unassigned-module`, `layer-overlap`, `unresolved-import`. |
|
|
102
|
+
| `unverified_claims` | Verification levels that were not executed, with the reason. |
|
|
103
|
+
| `evidence` | Bounded, sorted evidence lines for the findings above. |
|
|
104
|
+
| `truncated` | True when the file limit cut the scan short. |
|
|
105
|
+
| `model_digest` | `sha256:` digest of the model, stable across runs on the same tree. |
|
|
106
|
+
|
|
107
|
+
Import kinds: `internal` (another source module), `internal-file` (a
|
|
108
|
+
repository file that is not source, such as `package.json`), `external`
|
|
109
|
+
(outside the repository) and `unresolved` (a relative path that does not
|
|
110
|
+
exist; also listed under `unknowns`).
|
|
111
|
+
|
|
112
|
+
`system_model` never asserts that a change is safe. Levels `L1` and above stay
|
|
113
|
+
listed in `unverified_claims` until a dedicated check runs them.
|
|
114
|
+
|
|
115
|
+
## architecture_review
|
|
116
|
+
|
|
117
|
+
`architecture_review` evaluates the same contract against the same system model and
|
|
118
|
+
returns every finding with file, line and severity. Per-item status is `PASS`,
|
|
119
|
+
`WARN` (advisory findings only), `FAIL` or `UNKNOWN`.
|
|
120
|
+
|
|
121
|
+
| Code | Meaning | Severity |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `rule-forbid-dependency` | a module in the rule's `from` layer imports the forbidden `to` layer | the rule's severity |
|
|
124
|
+
| `rule-allow-dependency` | a module in the rule's `from` layer imports a layer outside `to` | the rule's severity |
|
|
125
|
+
| `boundary-visibility` | a module imports a protected boundary it may not reach | `high` for `private`, `medium` for `internal` |
|
|
126
|
+
| `data-ownership-mismatch` | a module inside the store paths is not in the owner layer | `medium` |
|
|
127
|
+
| `data-store-access-outside-owner` | a module outside the owner layer references the store path | `medium` |
|
|
128
|
+
|
|
129
|
+
Boundary visibility decides who may import the protected modules:
|
|
130
|
+
|
|
131
|
+
- `public` - any layer may import them; the declaration is recorded and never a finding.
|
|
132
|
+
- `internal` - only modules of the same layer may import them.
|
|
133
|
+
- `private` - only modules inside the boundary globs may import them.
|
|
134
|
+
|
|
135
|
+
Data ownership is checked in two ways: modules that live inside a store's paths but
|
|
136
|
+
belong to another layer, and modules outside the owner layer that reference the
|
|
137
|
+
store path literal (the part before the first wildcard).
|
|
138
|
+
|
|
139
|
+
Invariants are never reported as passing. `static`, `command` and `manual` checks
|
|
140
|
+
all land in `unverified_claims` with the reason, so a review can be `PASS` while
|
|
141
|
+
still stating what it did not verify.
|
|
142
|
+
|
|
143
|
+
The overall status is `FAIL` when the contract has blocking findings or any
|
|
144
|
+
violation reaches `critical` / `high`; `UNKNOWN` when the contract is missing or
|
|
145
|
+
anything stays undecided; otherwise `PASS` (advisory findings may still be listed).
|
|
146
|
+
|
|
147
|
+
### Unknown kinds
|
|
148
|
+
|
|
149
|
+
| Kind | Meaning |
|
|
150
|
+
|---|---|
|
|
151
|
+
| `contract-missing` / `contract-invalid` | no usable contract was found. |
|
|
152
|
+
| `model-truncated` | the file limit cut the scan short. |
|
|
153
|
+
| `unassigned-module` / `layer-overlap` | a module has no layer or matches several. |
|
|
154
|
+
| `unresolved-import` | a relative import does not resolve. |
|
|
155
|
+
| `rule-target-unassigned` | the rule's source layer matches, but the target module has no layer. |
|
|
156
|
+
| `boundary-no-modules` | the boundary globs match no module. |
|
|
157
|
+
| `boundary-importer-unassigned` | the importer has no layer, so visibility is undecided. |
|
|
158
|
+
|
|
159
|
+
## impact_analysis
|
|
160
|
+
|
|
161
|
+
`impact_analysis` starts from changed files, a unified diff or target symbols and
|
|
162
|
+
walks reverse dependencies (internal imports and repository-file imports) into a
|
|
163
|
+
bounded cone. Each node carries `depth`, `via`, `line`, `layer` and `is_test`.
|
|
164
|
+
|
|
165
|
+
Alongside the cone it reports direct consumers, affected layers, boundaries, data
|
|
166
|
+
stores, invariants scoped to the changed paths, tests mapped to the cone, the
|
|
167
|
+
architecture violations that fall inside the cone, rollback probes and an
|
|
168
|
+
explainable blast radius.
|
|
169
|
+
|
|
170
|
+
| Blast radius factor | Weight | When |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `layer-risk` | 0-5 | highest declared risk weight or risk level of affected layers |
|
|
173
|
+
| `layer-count` | +1 / +2 | 3-4 layers / 5 or more layers are affected |
|
|
174
|
+
| `cone-depth` | +1 | the consumer chain reaches depth 2 or more |
|
|
175
|
+
| `public-boundary` | +1 | a public boundary is inside the cone |
|
|
176
|
+
| `data-store` | +1 per store, capped at 2 | declared or detected stores are touched |
|
|
177
|
+
| `architecture-violation` | +2 / +3 | a `high` / `critical` violation is inside the cone |
|
|
178
|
+
|
|
179
|
+
`level` maps the capped score (10 max): 9-10 `critical`, 6-8 `high`, 3-5 `medium`,
|
|
180
|
+
otherwise `low`. `score` is the raw sum of the weights and `reasons` lists every
|
|
181
|
+
factor with its detail, so the number can be recomputed by hand.
|
|
182
|
+
|
|
183
|
+
Rollback probes are derived, not invented: `data-store` (affected stores),
|
|
184
|
+
`entrypoint` (non-test entrypoints in the cone, capped at 5), `tests` (mapped test
|
|
185
|
+
files), `invariant` (declared `command` checks) and `model` (fallback when the cone
|
|
186
|
+
has no anchor). Test files that only guard on `__main__` are covered by the test
|
|
187
|
+
probe and are not reported as startup entrypoints.
|
|
188
|
+
|
|
189
|
+
## verification policy
|
|
190
|
+
|
|
191
|
+
`.yotta/verification.json` is optional. It declares the L2-L4 checks that
|
|
192
|
+
`verify_change` may execute, plus manual work that must stay unverified. It never
|
|
193
|
+
holds shell strings: `kind` must be one of the whitelisted runners already supported
|
|
194
|
+
by `run_checks`.
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"version": 1,
|
|
199
|
+
"checks": [
|
|
200
|
+
{
|
|
201
|
+
"id": "unit-tests",
|
|
202
|
+
"level": "L2",
|
|
203
|
+
"kind": "python-unittest",
|
|
204
|
+
"cwd": ".",
|
|
205
|
+
"timeout": 120,
|
|
206
|
+
"required": true,
|
|
207
|
+
"claim": "the unit suite passes"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"manual": [
|
|
211
|
+
{"id": "independent-review", "claim": "a second person reviews the change"}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
| Field | Required | Notes |
|
|
217
|
+
|---|---|---|
|
|
218
|
+
| `version` | yes | Must be `1`. |
|
|
219
|
+
| `checks` | no | Array of L2-L4 checks. |
|
|
220
|
+
| `checks[].id` | yes | Unique slug matching the same id rule as the architecture contract. |
|
|
221
|
+
| `checks[].level` | yes | `L2`, `L3` or `L4`. |
|
|
222
|
+
| `checks[].kind` | yes | `python-unittest`, `pytest`, `python-compile`, `npm-test` or `npm-lint`. |
|
|
223
|
+
| `checks[].cwd` | no | Repository-relative directory, default `.`; absolute paths and `..` are rejected. |
|
|
224
|
+
| `checks[].timeout` | no | 1-600 seconds, default 120. |
|
|
225
|
+
| `checks[].required` | no | Default `true`; a required check that did not run keeps the overall result `UNKNOWN`. |
|
|
226
|
+
| `checks[].claim` | no | Human-readable claim recorded in the ledger. |
|
|
227
|
+
| `manual[].id` / `manual[].claim` | yes | Manual claims that are always reported as unverified. |
|
|
228
|
+
|
|
229
|
+
Verification findings use the same evidence shape as the architecture contract:
|
|
230
|
+
`code`, `severity`, `message`, JSON `pointer`, `path` and short `evidence`.
|
|
231
|
+
Blocking codes include `verification-invalid-json`,
|
|
232
|
+
`verification-unsupported-version`, `verification-invalid-id`,
|
|
233
|
+
`verification-duplicate-check`, `verification-invalid-level`,
|
|
234
|
+
`verification-invalid-kind`, `verification-invalid-cwd`,
|
|
235
|
+
`verification-invalid-timeout` and `verification-invalid-manual`.
|
|
236
|
+
|
|
237
|
+
`verify_change` runs L0/L1 in-process. L2-L4 execute only when the caller passes
|
|
238
|
+
`allow_execute=true`; L5 is always manual. A `PASS` means every required claim has
|
|
239
|
+
evidence. Unrun or manual claims remain in `unverified_claims` and are never written
|
|
240
|
+
as passing.
|
|
241
|
+
|
|
242
|
+
## Command line
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
python scripts/dev_engine.py system-model .
|
|
246
|
+
python scripts/dev_engine.py system-model . --contract config/architecture.json
|
|
247
|
+
python scripts/dev_engine.py architecture-review .
|
|
248
|
+
python scripts/dev_engine.py impact-analysis . --changed src/core/store.py
|
|
249
|
+
python scripts/dev_engine.py impact-analysis . --diff-file change.patch --depth 2
|
|
250
|
+
python scripts/dev_engine.py impact-analysis . --symbol save
|
|
251
|
+
python scripts/dev_engine.py verify-change . --changed src/core/store.py
|
|
252
|
+
python scripts/dev_engine.py verify-change . --changed src/core/store.py --level L2 --allow-execute
|
|
253
|
+
python scripts/dev_engine.py self-test .
|
|
254
|
+
python scripts/dev_engine.py adapter . --action list
|
|
255
|
+
python scripts/dev_engine.py adapter . --action run --adapter import-linter --allow-execute
|
|
256
|
+
```
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Tool contracts
|
|
2
2
|
|
|
3
|
-
All tools are local
|
|
3
|
+
All tools are local and deterministic. Unless a section says otherwise they are
|
|
4
|
+
read-only; `run_checks`, `verify_change` and `run_adapter` require
|
|
5
|
+
`allow_execute=true` for their explicit execution paths, and `scaffold_skill` /
|
|
6
|
+
`workflow_state` require `apply=true` before writing.
|
|
4
7
|
|
|
5
8
|
## repo_map
|
|
6
9
|
|
|
@@ -11,6 +14,149 @@ Input:
|
|
|
11
14
|
|
|
12
15
|
Output: `root`, `modules`, `imports`, `entrypoints`, `truncated`.
|
|
13
16
|
|
|
17
|
+
## system_model
|
|
18
|
+
|
|
19
|
+
Input:
|
|
20
|
+
|
|
21
|
+
- `path` (required): repository or source directory.
|
|
22
|
+
- `max_files` (optional, default 2000): source file limit.
|
|
23
|
+
- `contract_file` (optional): contract path relative to the repository root
|
|
24
|
+
(default `.yotta/architecture.json`).
|
|
25
|
+
|
|
26
|
+
Output: `status` (`PASS` / `FAIL` / `UNKNOWN`), `contract`, `model` (`modules`,
|
|
27
|
+
`layers`, `imports`, `entrypoints`, `tests`, `configs`, `data_stores`),
|
|
28
|
+
`unknowns`, `unknowns_truncated`, `unverified_claims`, `evidence`, `truncated`
|
|
29
|
+
and `model_digest`.
|
|
30
|
+
|
|
31
|
+
Contract schema, glob rules, finding codes and import kinds are documented in
|
|
32
|
+
`references/architecture-contract.md`.
|
|
33
|
+
|
|
34
|
+
## architecture_review
|
|
35
|
+
|
|
36
|
+
Input:
|
|
37
|
+
|
|
38
|
+
- `path` (required): repository or source directory.
|
|
39
|
+
- `max_files` (optional, default 2000): source file limit.
|
|
40
|
+
- `contract_file` (optional): contract path relative to the repository root
|
|
41
|
+
(default `.yotta/architecture.json`).
|
|
42
|
+
|
|
43
|
+
Output: `status` (`PASS` / `FAIL` / `UNKNOWN`), `contract`, `checked`
|
|
44
|
+
(`rules` / `boundaries` / `data_stores` / `invariants`, each with a per-item
|
|
45
|
+
`status` of `PASS` / `WARN` / `FAIL` / `UNKNOWN`), `violations`, `blocking_findings`,
|
|
46
|
+
`advisory_findings`, `unknowns`, `unverified_claims`, `evidence`, `truncated` and
|
|
47
|
+
`model_digest`.
|
|
48
|
+
|
|
49
|
+
`critical` / `high` findings fail the review; `medium` / `low` stay advisory.
|
|
50
|
+
Anything the model cannot decide becomes `UNKNOWN`; declared invariants that this
|
|
51
|
+
tool cannot evaluate are listed in `unverified_claims` instead of being reported
|
|
52
|
+
as passing. Read-only.
|
|
53
|
+
|
|
54
|
+
## impact_analysis
|
|
55
|
+
|
|
56
|
+
Input:
|
|
57
|
+
|
|
58
|
+
- `path` (required): repository or source directory.
|
|
59
|
+
- `changed_files` (optional): repository-relative changed files.
|
|
60
|
+
- `diff` (optional): unified diff text; changed files and line numbers are parsed
|
|
61
|
+
from it, deleted files keep their declared layer.
|
|
62
|
+
- `symbols` (optional): target symbols; their definition sites become the change.
|
|
63
|
+
- `depth` (optional, default 3, 1-10): reverse-dependency depth.
|
|
64
|
+
- `max_files` (optional, default 2000): source file limit.
|
|
65
|
+
- `contract_file` (optional): contract path relative to the repository root.
|
|
66
|
+
|
|
67
|
+
At least one of `changed_files`, `diff` or `symbols` is required.
|
|
68
|
+
|
|
69
|
+
Output: `status`, `inputs`, `changed`, `direct_consumers`, `cone` (`nodes` with
|
|
70
|
+
`depth` / `via` / `layer` / `is_test`, `max_depth`, `limit`, `truncated`),
|
|
71
|
+
`affected_layers`, `affected_boundaries`, `affected_data_stores`,
|
|
72
|
+
`affected_invariants`, `relevant_tests`, `architecture` (`status`,
|
|
73
|
+
`violations_total`, `violations_in_scope`, `unknowns`), `blast_radius`
|
|
74
|
+
(`level`, `score`, `capped`, `reasons`), `rollback_probes`, `unknowns`,
|
|
75
|
+
`unverified_claims`, `evidence`, `truncated` and `model_digest`.
|
|
76
|
+
|
|
77
|
+
`status` is `FAIL` when a blocking architecture violation sits inside the cone,
|
|
78
|
+
`UNKNOWN` while anything is undecided, otherwise `PASS`. Read-only; no command is
|
|
79
|
+
executed.
|
|
80
|
+
|
|
81
|
+
## verify_change
|
|
82
|
+
|
|
83
|
+
Input:
|
|
84
|
+
|
|
85
|
+
- `path` (required): repository or source directory.
|
|
86
|
+
- `changed_files` / `diff` / `symbols` (at least one): the same change inputs as
|
|
87
|
+
`impact_analysis`.
|
|
88
|
+
- `depth` (optional, default 3, 1-10): reverse-dependency depth.
|
|
89
|
+
- `levels` (optional): additional execution levels `L2`, `L3`, `L4` or manual `L5`.
|
|
90
|
+
L0 and L1 always run.
|
|
91
|
+
- `allow_execute` (optional, default false): required before any L2-L4 check runs.
|
|
92
|
+
- `timeout` (optional, default 120, 1-600): upper bound for each policy check.
|
|
93
|
+
- `max_files` / `contract_file` (optional): model limit and contract override.
|
|
94
|
+
- `policy_file` (optional, default `.yotta/verification.json`): policy override.
|
|
95
|
+
|
|
96
|
+
Output: `status`, `inputs`, `required_levels`, `ledger`, `unverified_claims`,
|
|
97
|
+
`policy`, `evidence`, `ledger_digest`, `model_digest` and `impact_status`.
|
|
98
|
+
|
|
99
|
+
Every ledger entry has `id`, `level`, `claim`, `status` (`PASS` / `FAIL` / `UNKNOWN` /
|
|
100
|
+
`UNVERIFIED`), `severity`, `check`, `confidence`, `evidence`, `next_step` and
|
|
101
|
+
`command`. Static checks keep `command` as `null`; executed checks record the
|
|
102
|
+
whitelisted kind, relative cwd, exit code, timeout flag and `output_hash`.
|
|
103
|
+
|
|
104
|
+
The default ladder runs L0 (changed-file syntax, contract schema) and L1 (architecture
|
|
105
|
+
rules and boundaries inside the change cone). L2-L4 are skipped unless both a policy
|
|
106
|
+
check is declared and `allow_execute=true`; they never accept arbitrary commands.
|
|
107
|
+
L5 is always manual and stays in `unverified_claims`. The ledger intentionally has no
|
|
108
|
+
wall-clock timestamp: its digest and the command output hashes are the reproducible
|
|
109
|
+
evidence anchors.
|
|
110
|
+
|
|
111
|
+
## self_test
|
|
112
|
+
|
|
113
|
+
Input:
|
|
114
|
+
|
|
115
|
+
- `path` (required): source checkout or installed skill directory.
|
|
116
|
+
- `mode` (optional, default `auto`): `auto`, `source` or `installed`.
|
|
117
|
+
- `allow_execute` (optional, default false): run the target test suite.
|
|
118
|
+
- `timeout` (optional, default 120, 1-600).
|
|
119
|
+
|
|
120
|
+
Source mode checks required files, version alignment across `package.json` /
|
|
121
|
+
`SKILL.md` / `CHANGELOG.md` / `server.json` / engine `VERSION`, protocol tool names
|
|
122
|
+
and `inputSchema.additionalProperties=false`, fail-closed defaults for every write or
|
|
123
|
+
execute gate, and counterexamples. Installed mode checks `SKILL.md` and the installed
|
|
124
|
+
asset payload, and records source-only checks as out of scope.
|
|
125
|
+
|
|
126
|
+
The counterexample suite is in-process and deterministic: a seeded forbidden
|
|
127
|
+
dependency must be `FAIL`, removing the rule must stop the failure, an invalid
|
|
128
|
+
contract must be `FAIL` or `UNKNOWN`, a missing contract must be `UNKNOWN`, a seeded
|
|
129
|
+
credential must be found, and a seeded version mismatch must fail readiness. These
|
|
130
|
+
probes prove the verifier is not a rubber stamp.
|
|
131
|
+
|
|
132
|
+
## run_adapter
|
|
133
|
+
|
|
134
|
+
Input:
|
|
135
|
+
|
|
136
|
+
- `action` (required): `list` probes optional adapters without executing them;
|
|
137
|
+
`run` executes exactly one adapter.
|
|
138
|
+
- `path` (required): repository root.
|
|
139
|
+
- `adapter` (required when `action=run`): `import-linter`,
|
|
140
|
+
`dependency-cruiser` or `repomix`.
|
|
141
|
+
- `allow_execute` (optional, default false): required for `action=run`.
|
|
142
|
+
- `timeout` (optional, default 120, 1-600).
|
|
143
|
+
- `max_chars` (optional, default 120000, 1000-1000000): Repomix output cap.
|
|
144
|
+
- `token_budget` (optional): Repomix token budget; over-budget output fails.
|
|
145
|
+
- `target` (optional, default `.`): repository-relative adapter target.
|
|
146
|
+
|
|
147
|
+
`action=list` returns `status`, `adapters` with `available` / `ready` /
|
|
148
|
+
`executable` / `executable_source` / `config` / `reason`, plus `unknowns`.
|
|
149
|
+
|
|
150
|
+
`action=run` returns `status` (`PASS` / `FAIL` / `UNKNOWN`), the selected
|
|
151
|
+
`adapter` metadata, a fixed `command` record with `output_hash`, normalized
|
|
152
|
+
`findings`, Repomix `content` metadata when applicable, `next_step` and
|
|
153
|
+
`unknowns`. Missing tools, missing configs, invalid output and timeouts are
|
|
154
|
+
`UNKNOWN`, never silent passes.
|
|
155
|
+
|
|
156
|
+
Adapters are optional enhancements: no package is installed or downloaded, no
|
|
157
|
+
arbitrary argv is accepted, and adapter findings do not silently change the
|
|
158
|
+
status of the core architecture tools. See `references/adapters.md`.
|
|
159
|
+
|
|
14
160
|
## find_code
|
|
15
161
|
|
|
16
162
|
Input:
|