reasonweave 0.0.0-stage → 1.3.2
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.md +101 -0
- package/INSTALL.md +258 -0
- package/README.md +280 -2
- package/bin/lab.mjs +888 -0
- package/constitution.md +55 -0
- package/docs/CONSUMER-PROMPTS.md +474 -0
- package/docs/backlogs/01-forward-wait-self-detach.md +18 -0
- package/docs/backlogs/02-decouple-wait-and-daemon-for-agent-hosts.md +35 -0
- package/docs/backlogs/03-baton-wait-multi-id-lightweight-pubsub.md +34 -0
- package/docs/backlogs/04-adr-cross-repo-automated-dispatch-boundary.md +19 -0
- package/docs/backlogs/05-feat-units-worktree-isolation-engine.md +23 -0
- package/docs/backlogs/06-feat-blind-audit-automated-clean-runner.md +22 -0
- package/docs/backlogs/07-feat-attention-throttle-silent-pipe.md +23 -0
- package/docs/backlogs/08-future-units-shadow-ledger.md +22 -0
- package/docs/backlogs/09-feat-agent-baton-core-convergence-and-resilience.md +42 -0
- package/docs/backlogs/10-feat-anti-orphan-deterministic-wiring-governance.md +35 -0
- package/docs/backlogs/11-perf-orphan-index-fs-read.md +16 -0
- package/docs/backlogs/12-feat-vibe-security-anti-suppression-and-orphan-deps.md +43 -0
- package/docs/backlogs/13-feat-sdd-reppit-tiered-guardrails.md +40 -0
- package/docs/backlogs/14-feat-universal-cli-contract-and-hermetic-test-fixtures.md +48 -0
- package/docs/backlogs/15-feat-reasonweave-rebranding-and-doc-code-synchronization-invariant.md +44 -0
- package/docs/backlogs/16-feat-micro-engineering-skills-and-sdd-baton-fusion.md +52 -0
- package/docs/codegraph-readiness-check.md +49 -0
- package/group/architecture/adr/0001-handoff-async-wait-and-reactive-wakeup.md +87 -0
- package/group/architecture/adr/0002-de-ritualize-handoff-prompt-for-intra-repo.md +53 -0
- package/group/architecture/adr/0003-attention-throttle-and-workspace-driver.md +65 -0
- package/group/architecture/adr/0004-spec-guard-and-drift-prevention.md +90 -0
- package/group/architecture/adr/0005-global-orphan-scavenger-and-read-only-invariants.md +94 -0
- package/group/architecture/adr/0006-triad-engineering-defense-and-mutation-sensitivity.md +68 -0
- package/group/architecture/adr/0007-agent-baton-state-machine-defense-and-workspace-jail-spec.md +86 -0
- package/group/architecture/adr/0008-agent-baton-core-convergence-and-heterogeneous-session-resilience.md +133 -0
- package/group/architecture/adr/0009-anti-orphan-deterministic-wiring-governance-and-federated-guardrails.md +108 -0
- package/group/architecture/adr/0010-agent-baton-identity-security-cryptographic-credentials-and-prompt-anti-confusion.md +119 -0
- package/group/architecture/adr/0011-vibe-security-anti-suppression-and-dependency-reachability.md +161 -0
- package/group/architecture/adr/0012-spec-driven-development-reppit-and-tiered-guardrails.md +130 -0
- package/group/architecture/adr/0013-universal-cli-contract-hermetic-testing-and-defensive-probes.md +110 -0
- package/group/architecture/adr/0014-reasonweave-rebranding-and-doc-code-synchronization-invariant.md +108 -0
- package/group/architecture/adr/0015-micro-engineering-skills-and-dual-core-gate-invariant.md +127 -0
- package/group/architecture/adr/INDEX.md +29 -0
- package/group/architecture/adr/templates/adr-template.md +33 -0
- package/group/architecture/dependency-graph.md +60 -0
- package/group/contracts/npm-packaging.md +69 -0
- package/group/product/intent.md +24 -0
- package/package.json +93 -4
- package/scripts/sync-all-consumers.mjs +174 -0
- package/specs/RFC-20261110-SPEC-GUARD-UNIT.md +353 -0
- package/specs/templates/01-research.md.template +23 -0
- package/specs/templates/02-proposals.md.template +22 -0
- package/specs/templates/03-spec.md.template +33 -0
- package/specs/templates/04-tasks.md.template +29 -0
- package/specs/templates/05-evidence.md.template +29 -0
- package/specs/templates/README.md +26 -0
- package/units/adr/AGENTS.md +85 -0
- package/units/adr/CHANGELOG.md +20 -0
- package/units/adr/README.md +88 -0
- package/units/adr/VERSION.md +10 -0
- package/units/adr/docs/existing-project-prompt.md +24 -0
- package/units/adr/docs/new-project-prompt.md +36 -0
- package/units/adr/scripts/adr-init.sh +101 -0
- package/units/adr/templates/INDEX.md +19 -0
- package/units/adr/templates/adr-frozen.md +33 -0
- package/units/adr/templates/adr-light.md +56 -0
- package/units/adr/templates/adr-standard.md +61 -0
- package/units/backlog/AGENTS.md +53 -0
- package/units/backlog/AUTONOMOUS-GOVERNANCE.md +98 -0
- package/units/backlog/CHANGELOG.md +37 -0
- package/units/backlog/README.md +124 -0
- package/units/backlog/VERSION.md +11 -0
- package/units/backlog/docs/existing-project-ironrules-prompt.md +31 -0
- package/units/backlog/docs/existing-project-prompt.md +24 -0
- package/units/backlog/docs/new-project-prompt.md +19 -0
- package/units/backlog/templates/entry.md +39 -0
- package/units/backlog/templates/project-ironrules.md +36 -0
- package/units/handoffs/AGENT-GUIDE.md +118 -0
- package/units/handoffs/AGENTS.md +28 -0
- package/units/handoffs/CHANGELOG.md +498 -0
- package/units/handoffs/CLAUDE.md +28 -0
- package/units/handoffs/COMMANDS.md +187 -0
- package/units/handoffs/DESIGN.md +74 -0
- package/units/handoffs/README.md +456 -0
- package/units/handoffs/RESPONSE-TEMPLATE.md +138 -0
- package/units/handoffs/VERSION.md +1 -0
- package/units/handoffs/handoff-status.mjs +1017 -0
- package/units/handoffs/handoff.mjs +5675 -0
- package/units/orphan/CHANGELOG.md +118 -0
- package/units/orphan/DESIGN.md +484 -0
- package/units/orphan/README.md +143 -0
- package/units/orphan/VERSION.md +1 -0
- package/units/orphan/adapters/android/index.mjs +140 -0
- package/units/orphan/adapters/python/index.mjs +232 -0
- package/units/orphan/adapters/web/index.mjs +280 -0
- package/units/orphan/bin/lab-orphan.mjs +298 -0
- package/units/orphan/core/blob-reader.mjs +142 -0
- package/units/orphan/core/classifier.mjs +261 -0
- package/units/orphan/core/cleaner.mjs +166 -0
- package/units/orphan/core/diff-checker.mjs +341 -0
- package/units/orphan/core/inverted-index.mjs +124 -0
- package/units/orphan/core/orphan-deps.mjs +192 -0
- package/units/orphan/core/protocol-s1-s3.mjs +194 -0
- package/units/orphan/core/solver.mjs +217 -0
- package/units/orphan/index.mjs +105 -0
- package/units/orphan/templates/ci/orphan-guard.yml +36 -0
- package/units/orphan/templates/pre-commit.d/30-orphan-guard +34 -0
- package/units/orphan/templates/wiring/README.md +51 -0
- package/units/orphan/templates/wiring/miniprogram-route-guard.js.template +80 -0
- package/units/orphan/templates/wiring/pre-commit-node.sh.template +73 -0
- package/units/orphan/templates/wiring/project-agents-gemini-templates.md +60 -0
- package/units/orphan/templates/wiring/python-parity-test.py.template +100 -0
- package/units/orphan/templates/wiring/rust-exhaustive-match.md +65 -0
- package/units/orphan/templates/wiring/swift-periphery.md +56 -0
- package/units/orphan/tests/adapters.test.mjs +243 -0
- package/units/orphan/tests/orphan-deps.test.mjs +131 -0
- package/units/orphan/tests/phase3-gates.test.mjs +135 -0
- package/units/playbook/README.md +106 -0
- package/units/playbook/ZSPEC-AGENT-GUIDE.md +99 -0
- package/units/playbook/docs/01-architecture.md +99 -0
- package/units/playbook/docs/02-bootstrap.md +126 -0
- package/units/playbook/docs/03-units.md +91 -0
- package/units/playbook/docs/04-constitution.md +113 -0
- package/units/playbook/docs/05-adr.md +33 -0
- package/units/playbook/docs/06-spec-kit.md +76 -0
- package/units/playbook/docs/07-backlog.md +30 -0
- package/units/playbook/docs/08-codegraph.md +79 -0
- package/units/playbook/docs/09-skills.md +101 -0
- package/units/playbook/docs/10-handoff.md +72 -0
- package/units/playbook/docs/11-evidence.md +163 -0
- package/units/playbook/docs/12-gates.md +124 -0
- package/units/playbook/docs/13-parallel.md +115 -0
- package/units/playbook/docs/14-dependency-graph.md +86 -0
- package/units/playbook/docs/15-memory.md +153 -0
- package/units/playbook/docs/16-change-control.md +121 -0
- package/units/playbook/docs/17-prompts.md +121 -0
- package/units/playbook/docs/18-shift-left.md +97 -0
- package/units/playbook/docs/19-anti-orphan-vertical-slicing.md +102 -0
- package/units/playbook/docs/20-vibe-security-and-anti-suppression.md +88 -0
- package/units/playbook/docs/21-spec-driven-reppit-closed-loop.md +88 -0
- package/units/playbook/examples/owisel.md +80 -0
- package/units/playbook/references/Agent-Engineering-Framework-AEF-v1.0.md +2033 -0
- package/units/playbook/references/links.md +103 -0
- package/units/playbook/templates/AGENTS.root.md +44 -0
- package/units/playbook/templates/AGENTS.unit.md +52 -0
- package/units/playbook/templates/adr/INDEX.md +17 -0
- package/units/playbook/templates/adr/NNNN-template.md +56 -0
- package/units/playbook/templates/backlogs/entry.md +30 -0
- package/units/playbook/templates/constitution.md +93 -0
- package/units/playbook/templates/evidence/README.md +36 -0
- package/units/playbook/templates/group/architecture/dependency-graph.md +48 -0
- package/units/playbook/templates/group/architecture/system.md +59 -0
- package/units/playbook/templates/group/contracts/api.md +67 -0
- package/units/playbook/templates/group/product/intent.md +30 -0
- package/units/playbook/templates/group/product/requirements.md +48 -0
- package/units/playbook/templates/unit-skeleton/README.md +35 -0
- package/units/preflight/AGENTS.md +45 -0
- package/units/preflight/CHANGELOG.md +55 -0
- package/units/preflight/INSTALL.md +65 -0
- package/units/preflight/README.md +104 -0
- package/units/preflight/VERSION.md +3 -0
- package/units/preflight/docs/audit-requirements.md +114 -0
- package/units/preflight/docs/existing-project-prompt.md +25 -0
- package/units/preflight/docs/new-project-prompt.md +25 -0
- package/units/preflight/docs/transfers/CONSUMER-INSTALL.md +40 -0
- package/units/preflight/docs/transfers/CONSUMER-SELFCHECK.md +51 -0
- package/units/preflight/docs/transfers/README.md +39 -0
- package/units/preflight/docs/transfers/prospero.md +26 -0
- package/units/preflight/templates/check.sh +43 -0
- package/units/preflight/templates/pre-commit +55 -0
- package/units/preflight/templates/pre-commit.d/20-preflight +15 -0
- package/units/preflight/templates/preflight.conf.example +21 -0
- package/units/preflight/templates/preflight.sh +189 -0
- package/units/preflight/templates/wrap-up.md +9 -0
- package/units/review-gate/AGENTS.md +42 -0
- package/units/review-gate/CHANGELOG.md +58 -0
- package/units/review-gate/README.md +118 -0
- package/units/review-gate/VERSION.md +3 -0
- package/units/review-gate/clean-runner.mjs +350 -0
- package/units/review-gate/docs/existing-project-prompt.md +28 -0
- package/units/review-gate/docs/new-project-prompt.md +38 -0
- package/units/review-gate/docs/transfers/iggle.md +34 -0
- package/units/review-gate/docs/transfers/prospero.md +35 -0
- package/units/review-gate/docs/transfers/swoop.md +36 -0
- package/units/review-gate/docs/transfers/yiqiyihuihua.md +35 -0
- package/units/review-gate/templates/.semgrepignore +37 -0
- package/units/review-gate/templates/pre-commit +130 -0
- package/units/review-gate/templates/scan.sh +158 -0
- package/units/skills/AGENTS.md +17 -0
- package/units/skills/CHANGELOG.md +18 -0
- package/units/skills/README.md +63 -0
- package/units/skills/VERSION.md +1 -0
- package/units/skills/bin/review-package.mjs +99 -0
- package/units/skills/bin/task-brief.mjs +102 -0
- package/units/skills/catalog/brainstorming/SKILL.md +75 -0
- package/units/skills/catalog/brainstorming/references/design-doc-template.md +28 -0
- package/units/skills/catalog/systematic-debugging/SKILL.md +101 -0
- package/units/skills/catalog/systematic-debugging/references/root-cause-tracing.md +23 -0
- package/units/skills/catalog/test-driven-development/SKILL.md +88 -0
- package/units/skills/catalog/test-driven-development/references/writing-good-tests.md +13 -0
- package/units/skills/catalog/verification-before-completion/SKILL.md +73 -0
- package/units/skills/skills.mjs +181 -0
- package/units/skills/tests/pipeline.test.mjs +131 -0
- package/units/skills/tests/skill-contract.test.mjs +67 -0
- package/units/skills/tests/skills-cli.test.mjs +107 -0
- package/units/spec-guard/AGENTS.md +43 -0
- package/units/spec-guard/CHANGELOG.md +88 -0
- package/units/spec-guard/README.md +148 -0
- package/units/spec-guard/VERSION.md +1 -0
- package/units/spec-guard/bin/spec-guard.mjs +431 -0
- package/units/spec-guard/core/adr-parser.mjs +540 -0
- package/units/spec-guard/core/matrix-checker.mjs +587 -0
- package/units/spec-guard/core/mutation-runner.mjs +267 -0
- package/units/spec-guard/core/scanner.mjs +333 -0
- package/units/spec-guard/core/telemetry_authenticator.mjs +484 -0
- package/units/spec-guard/core/wiring_tracer.mjs +306 -0
- package/units/spec-guard/templates/annotations/ContractOnly.kt +19 -0
- package/units/spec-guard/templates/annotations/Invariant.kt +16 -0
- package/units/spec-guard/templates/annotations/invariant.go +19 -0
- package/units/spec-guard/templates/annotations/invariant.py +38 -0
- package/units/spec-guard/templates/annotations/invariant.ts +39 -0
- package/units/spec-guard/templates/ci/spec-guard-audit.yml +23 -0
- package/units/spec-guard/templates/pre-commit.d/15-spec-guard +72 -0
- package/units/spec-guard/templates/spec-matrix.overlay.yml +70 -0
- package/units/spec-guard/tests/spec-guard.test.mjs +716 -0
- package/units/spec-guard/tests/telemetry_authenticator.test.mjs +633 -0
- package/units/worktree/AGENTS.md +22 -0
- package/units/worktree/CHANGELOG.md +14 -0
- package/units/worktree/README.md +65 -0
- package/units/worktree/VERSION.md +1 -0
- package/units/worktree/worktree.mjs +352 -0
- package//344/275/277/347/224/250/350/257/264/346/230/216.md +322 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wiring_tracer.mjs
|
|
3
|
+
*
|
|
4
|
+
* 负责 ADR 物理代码接线探测与孤儿决策防卫 (spec-guard v2.0):
|
|
5
|
+
* 1. 从 ADR 决策节 (## 2. Decision) 提取核心架构符号、类名、函数与引擎编号 (支持反引号与自然语言实体)
|
|
6
|
+
* 2. 严格排除测试目录 (src/test/, tests/, __tests__ 等),贯彻 No-Cheat 防作弊铁律
|
|
7
|
+
* 3. 在生产源码目录中反查符号存活性与物理接线
|
|
8
|
+
* 4. 若 ADR 已标记 🔒Frozen 但生产代码零符号命中,判定为孤儿决策 (ORPHAN_DECISION) 并熔断阻断
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { findAdrFiles, parseAdrFile, escapeRegex, loadOverlayConfig } from './adr-parser.mjs';
|
|
14
|
+
import { scanRepository, isTestPath } from './scanner.mjs';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 通用停用词/无业务属性词汇(避免将通用关键字误当作架构实体)
|
|
18
|
+
*/
|
|
19
|
+
const STOP_WORDS = new Set([
|
|
20
|
+
'true', 'false', 'null', 'undefined', 'void', 'unit', 'string', 'int', 'boolean', 'float',
|
|
21
|
+
'any', 'id', 'try', 'catch', 'finally', 'try-finally', 'return', 'import', 'export', 'package',
|
|
22
|
+
'class', 'interface', 'type', 'val', 'var', 'let', 'const', 'def', 'fun', 'fn', 'function',
|
|
23
|
+
'sha256', 'digest', 'hash', 'signature', 'apache-2.0', 'mit', 'agpl-3.0', 'gpl',
|
|
24
|
+
'cpu', 'gpu', 'npu', 'ram', 'rom', 'dom', 'a11y', 'ocr', 'mcp', 'api', 'uri', 'url',
|
|
25
|
+
'p95', 'p99', 'int8', 'fp32', 'fp16', 'ms', 'mb', 'fps',
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 从 ADR 内容中定位 Decision 节并提取候选代码实体符号
|
|
30
|
+
*/
|
|
31
|
+
export function extractDecisionSymbols(content, options = {}) {
|
|
32
|
+
const decAliases = [
|
|
33
|
+
'Decision',
|
|
34
|
+
'决策内容',
|
|
35
|
+
'决策',
|
|
36
|
+
'决定',
|
|
37
|
+
...((options.section_aliases && options.section_aliases.decision) ||
|
|
38
|
+
(options.sectionAliases && options.sectionAliases.decision) ||
|
|
39
|
+
options.decision_section_aliases ||
|
|
40
|
+
[]),
|
|
41
|
+
];
|
|
42
|
+
const decPattern = decAliases.map((s) => escapeRegex(s).replace(/\\s\+/g, '\\s+')).join('|');
|
|
43
|
+
const decHeaderRegex = new RegExp(`^#{2,3}\\s+(?:\\d+\\.?\\s*)?(?:${decPattern})`, 'i');
|
|
44
|
+
const decWordRegex = new RegExp(decPattern, 'i');
|
|
45
|
+
|
|
46
|
+
const lines = content.split('\n');
|
|
47
|
+
let inDecision = false;
|
|
48
|
+
const decisionLines = [];
|
|
49
|
+
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
const trimmed = line.trim();
|
|
52
|
+
if (decHeaderRegex.test(trimmed)) {
|
|
53
|
+
inDecision = true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// 遇到下一个同级二级标题时退出
|
|
57
|
+
if (inDecision && /^##\s+[^#]/.test(trimmed) && !decWordRegex.test(trimmed)) {
|
|
58
|
+
inDecision = false;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
if (inDecision) {
|
|
62
|
+
decisionLines.push(trimmed);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const decisionText = decisionLines.join('\n');
|
|
67
|
+
const symbols = new Set();
|
|
68
|
+
|
|
69
|
+
// 1. 匹配反引号内的代码实体 `...`
|
|
70
|
+
const backtickRegex = /`([^`]+)`/g;
|
|
71
|
+
let match;
|
|
72
|
+
|
|
73
|
+
while ((match = backtickRegex.exec(decisionText)) !== null) {
|
|
74
|
+
const raw = match[1].trim();
|
|
75
|
+
|
|
76
|
+
// 排除 URL 与路径
|
|
77
|
+
if (/^https?:\/\//i.test(raw) || /^git\s+/i.test(raw) || /^cd\s+/i.test(raw)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 若包含文件扩展名 (如 ScreenshotBufferSpike.kt / host_probe.py / contracts.ts)
|
|
82
|
+
const fileExtMatch = raw.match(/([A-Za-z0-9_-]+)\.(?:kt|java|py|go|ts|tsx|js|mjs|rs)$/);
|
|
83
|
+
if (fileExtMatch) {
|
|
84
|
+
const baseName = fileExtMatch[1];
|
|
85
|
+
if (!STOP_WORDS.has(baseName.toLowerCase()) && baseName.length >= 3) {
|
|
86
|
+
symbols.add(baseName);
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 若是方法调用 (如 hardwareBuffer.close() 或 click_candidate())
|
|
92
|
+
const methodMatch = raw.match(/^([A-Za-z0-9_]+)(?:\.([A-Za-z0-9_]+))?\s*\(/);
|
|
93
|
+
if (methodMatch) {
|
|
94
|
+
const first = methodMatch[1];
|
|
95
|
+
const second = methodMatch[2];
|
|
96
|
+
if (first && !STOP_WORDS.has(first.toLowerCase()) && first.length >= 3) {
|
|
97
|
+
symbols.add(first);
|
|
98
|
+
}
|
|
99
|
+
if (second && !STOP_WORDS.has(second.toLowerCase()) && second.length >= 3) {
|
|
100
|
+
symbols.add(second);
|
|
101
|
+
}
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 若是属性/字段或类型 (如 Bitmap.Config.HARDWARE 或 Candidate.id)
|
|
106
|
+
if (raw.includes('.')) {
|
|
107
|
+
const parts = raw.split('.');
|
|
108
|
+
for (const p of parts) {
|
|
109
|
+
if (/^[A-Za-z0-9_]+$/.test(p) && !STOP_WORDS.has(p.toLowerCase()) && p.length >= 3) {
|
|
110
|
+
symbols.add(p);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 匹配常规合法标识符 (CamelCase, snake_case, PascalCase, 或 E8/G0 编号)
|
|
117
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(raw)) {
|
|
118
|
+
if (!STOP_WORDS.has(raw.toLowerCase()) && raw.length >= 2) {
|
|
119
|
+
symbols.add(raw);
|
|
120
|
+
}
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// 2. 补充:从自然语言文本中抽取未包裹反引号的大写驼峰实体标识符 (如 QuantumGhostEngine, PhotonDispatcher)
|
|
126
|
+
const pascalRegex = /\b([A-Z][a-zA-Z0-9_]{3,})\b/g;
|
|
127
|
+
let pMatch;
|
|
128
|
+
while ((pMatch = pascalRegex.exec(decisionText)) !== null) {
|
|
129
|
+
const raw = pMatch[1];
|
|
130
|
+
if (
|
|
131
|
+
!STOP_WORDS.has(raw.toLowerCase()) &&
|
|
132
|
+
!/^(Context|Decision|Consequences|Invariants|Status|Redmi|Android|Linux|Kotlin|Python|Java|Apple|Docker)$/i.test(raw)
|
|
133
|
+
) {
|
|
134
|
+
symbols.add(raw);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return Array.from(symbols);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 预热加载生产代码文件缓存,避免成千上万次磁盘 I/O
|
|
143
|
+
*/
|
|
144
|
+
export function loadProductionFilesCache(repoRoot, scannedRepo = null) {
|
|
145
|
+
const repoScan = scannedRepo || scanRepository(repoRoot);
|
|
146
|
+
const prodFiles = repoScan.scannedFiles.filter((f) => !isTestPath(f));
|
|
147
|
+
const fileCache = [];
|
|
148
|
+
|
|
149
|
+
for (const relFile of prodFiles) {
|
|
150
|
+
try {
|
|
151
|
+
const fullPath = path.join(repoRoot, relFile);
|
|
152
|
+
const content = fs.readFileSync(fullPath, 'utf8');
|
|
153
|
+
fileCache.push({
|
|
154
|
+
file: relFile,
|
|
155
|
+
lines: content.split('\n'),
|
|
156
|
+
});
|
|
157
|
+
} catch {
|
|
158
|
+
// ignore read error
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return { repoScan, fileCache };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 针对单个 ADR 执行生产代码物理接线与符号存活性探测
|
|
167
|
+
*/
|
|
168
|
+
export function traceAdrWiring(adrData, repoRoot, scannedRepo = null, fileCache = null, options = {}) {
|
|
169
|
+
const adrId = adrData.adrId || 'ADR-UNKNOWN';
|
|
170
|
+
const filePath = adrData.filePath || '';
|
|
171
|
+
const isFrozen = !!adrData.isFrozen;
|
|
172
|
+
const content = typeof adrData.content === 'string' ? adrData.content : fs.readFileSync(filePath, 'utf8');
|
|
173
|
+
|
|
174
|
+
// 1. 抽取决策核心符号
|
|
175
|
+
const candidateSymbols = extractDecisionSymbols(content, options);
|
|
176
|
+
|
|
177
|
+
// 2. 加载或复用生产文件内存缓存 (No-Cheat: 严格排除测试代码)
|
|
178
|
+
let cache = fileCache;
|
|
179
|
+
if (!cache) {
|
|
180
|
+
const loaded = loadProductionFilesCache(repoRoot, scannedRepo);
|
|
181
|
+
cache = loaded.fileCache;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const wiredSymbols = [];
|
|
185
|
+
const unwiredSymbols = [];
|
|
186
|
+
const symbolDetails = {};
|
|
187
|
+
|
|
188
|
+
for (const sym of candidateSymbols) {
|
|
189
|
+
const escaped = escapeRegex(sym);
|
|
190
|
+
const regex = new RegExp(`(?<=^|[^a-zA-Z0-9_])${escaped}(?=$|[^a-zA-Z0-9_])`);
|
|
191
|
+
|
|
192
|
+
let hitCount = 0;
|
|
193
|
+
const hitLocations = [];
|
|
194
|
+
|
|
195
|
+
for (const cached of cache) {
|
|
196
|
+
for (let lineIdx = 0; lineIdx < cached.lines.length; lineIdx++) {
|
|
197
|
+
const line = cached.lines[lineIdx];
|
|
198
|
+
if (regex.test(line)) {
|
|
199
|
+
hitCount++;
|
|
200
|
+
if (hitLocations.length < 5) {
|
|
201
|
+
hitLocations.push({ file: cached.file, line: lineIdx + 1 });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (hitCount > 0) {
|
|
208
|
+
wiredSymbols.push(sym);
|
|
209
|
+
symbolDetails[sym] = { hitCount, status: 'WIRED', locations: hitLocations };
|
|
210
|
+
} else {
|
|
211
|
+
unwiredSymbols.push(sym);
|
|
212
|
+
symbolDetails[sym] = { hitCount: 0, status: 'UNWIRED', locations: [] };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 3. 判定 ADR 整体物理接线状态 (🔒Frozen ADR 严禁因格式不合规而静默豁免)
|
|
217
|
+
let status = 'PASS';
|
|
218
|
+
let reason = '';
|
|
219
|
+
let isOrphan = false;
|
|
220
|
+
|
|
221
|
+
if (candidateSymbols.length === 0) {
|
|
222
|
+
if (isFrozen) {
|
|
223
|
+
status = 'FAIL';
|
|
224
|
+
isOrphan = true;
|
|
225
|
+
reason = `🚨 孤儿决策 (ORPHAN_DECISION): 规约已 🔒Frozen 但 Decision 节未声明任何可机检的架构代码实体符号!`;
|
|
226
|
+
} else {
|
|
227
|
+
status = 'SKIPPED';
|
|
228
|
+
reason = 'Decision 节未提取到独立架构符号或无需生产接线';
|
|
229
|
+
}
|
|
230
|
+
} else if (isFrozen && wiredSymbols.length === 0) {
|
|
231
|
+
status = 'FAIL';
|
|
232
|
+
isOrphan = true;
|
|
233
|
+
reason = `🚨 孤儿决策 (ORPHAN_DECISION): 规约已 🔒Frozen 但核心决策符号 (${candidateSymbols.slice(0, 5).join(', ')}) 在生产代码中零命中!`;
|
|
234
|
+
} else if (wiredSymbols.length === 0) {
|
|
235
|
+
status = 'UNWIRED';
|
|
236
|
+
reason = `未接线草案: 生产代码暂无决策符号命中 (0/${candidateSymbols.length})`;
|
|
237
|
+
} else {
|
|
238
|
+
status = 'PASS';
|
|
239
|
+
reason = `✅ 物理接线存活 (${wiredSymbols.length}/${candidateSymbols.length} 符号在生产代码中命中)`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
adrId,
|
|
244
|
+
filePath,
|
|
245
|
+
isFrozen,
|
|
246
|
+
candidateSymbols,
|
|
247
|
+
candidateSymbolsCount: candidateSymbols.length,
|
|
248
|
+
wiredSymbols,
|
|
249
|
+
unwiredSymbols,
|
|
250
|
+
wiredCount: wiredSymbols.length,
|
|
251
|
+
unwiredCount: unwiredSymbols.length,
|
|
252
|
+
status,
|
|
253
|
+
isOrphan,
|
|
254
|
+
reason,
|
|
255
|
+
symbolDetails,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 批量检查全仓 ADR 的物理接线状态
|
|
261
|
+
*/
|
|
262
|
+
export function traceAllAdrsWiring(repoRoot, options = {}) {
|
|
263
|
+
const config = options.config || loadOverlayConfig(repoRoot, options.overlay || options.overlayPath || '');
|
|
264
|
+
const mergedOptions = { ...config, ...options };
|
|
265
|
+
const adrPaths = findAdrFiles(repoRoot, mergedOptions);
|
|
266
|
+
const targetId = options.targetAdrId ? options.targetAdrId.toUpperCase() : null;
|
|
267
|
+
|
|
268
|
+
// 预热加载一次生产文件缓存
|
|
269
|
+
const { repoScan, fileCache } = loadProductionFilesCache(repoRoot, options.scannedRepo);
|
|
270
|
+
|
|
271
|
+
const reports = [];
|
|
272
|
+
let frozenAdrsCount = 0;
|
|
273
|
+
let orphanAdrsCount = 0;
|
|
274
|
+
let passedCount = 0;
|
|
275
|
+
|
|
276
|
+
for (const adrPath of adrPaths) {
|
|
277
|
+
const parsed = parseAdrFile(adrPath, mergedOptions);
|
|
278
|
+
if (targetId && parsed.adrId.toUpperCase() !== targetId) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (parsed.isFrozen) {
|
|
283
|
+
frozenAdrsCount++;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const report = traceAdrWiring(parsed, repoRoot, repoScan, fileCache, mergedOptions);
|
|
287
|
+
reports.push(report);
|
|
288
|
+
|
|
289
|
+
if (report.isOrphan) {
|
|
290
|
+
orphanAdrsCount++;
|
|
291
|
+
}
|
|
292
|
+
if (report.status === 'PASS') {
|
|
293
|
+
passedCount++;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return {
|
|
298
|
+
repoRoot,
|
|
299
|
+
totalAdrs: adrPaths.length,
|
|
300
|
+
frozenAdrsCount,
|
|
301
|
+
orphanAdrsCount,
|
|
302
|
+
passedCount,
|
|
303
|
+
reports,
|
|
304
|
+
isHealthy: orphanAdrsCount === 0,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package lab.specguard.annotations
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 契约沙箱原型隔离注解
|
|
5
|
+
*
|
|
6
|
+
* 用于标记在垂直切片初期尚未接线至生产环境的算法原型。
|
|
7
|
+
* 被此注解标记的符号受到 spec-guard 与 lab-orphan 保护,在有效截止日期前不会被判定为死代码误杀。
|
|
8
|
+
*
|
|
9
|
+
* @param adr 关联的 ADR 编号,如 "ADR-060"
|
|
10
|
+
* @param expire 预计闭环过期的截止日期,格式为 "YYYY-MM-DD"
|
|
11
|
+
* @param reason 原型暂未接线的原因与前置依赖说明
|
|
12
|
+
*/
|
|
13
|
+
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
|
|
14
|
+
@Retention(AnnotationRetention.SOURCE)
|
|
15
|
+
annotation class ContractOnly(
|
|
16
|
+
val adr: String,
|
|
17
|
+
val expire: String = "",
|
|
18
|
+
val reason: String = ""
|
|
19
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package lab.specguard.annotations
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 架构不变量机器断言打标注解
|
|
5
|
+
*
|
|
6
|
+
* 用于在测试函数或类上绑定对应的 ADR 架构不变量,供 spec-guard 对账引擎动态扫描。
|
|
7
|
+
*
|
|
8
|
+
* @param id 严格格式的不变量标识,如 "ADR-060:H-1" 或 "H-1"
|
|
9
|
+
* @param description 可选的不变量描述
|
|
10
|
+
*/
|
|
11
|
+
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
|
|
12
|
+
@Retention(AnnotationRetention.SOURCE)
|
|
13
|
+
annotation class Invariant(
|
|
14
|
+
val id: String,
|
|
15
|
+
val description: String = ""
|
|
16
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package specguard
|
|
2
|
+
|
|
3
|
+
// spec-guard Golang 注释规范
|
|
4
|
+
//
|
|
5
|
+
// 1. 在测试用例上方标记绑定不变量:
|
|
6
|
+
//
|
|
7
|
+
// // Invariant: ADR-060:H-1
|
|
8
|
+
// // Description: 验证冷却期间抓包数为0
|
|
9
|
+
// func TestNoNetworkTrafficDuringCooldown(t *testing.T) {
|
|
10
|
+
// ...
|
|
11
|
+
// }
|
|
12
|
+
//
|
|
13
|
+
// 2. 在未接线的纯算法原型上方标记契约沙箱:
|
|
14
|
+
//
|
|
15
|
+
// // [CONTRACT-ONLY: ADR-060, expire: 2026-12-01]
|
|
16
|
+
// // Reason: 等待 IPC 管道实现
|
|
17
|
+
// func CheckThermalSafety(...) bool {
|
|
18
|
+
// ...
|
|
19
|
+
// }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
spec-guard Python 断言打标装饰器与沙箱标记
|
|
3
|
+
"""
|
|
4
|
+
import functools
|
|
5
|
+
from typing import Callable, Optional
|
|
6
|
+
|
|
7
|
+
def invariant(invariant_id: str, description: str = "") -> Callable:
|
|
8
|
+
"""
|
|
9
|
+
绑定 ADR 不变量机器断言。
|
|
10
|
+
|
|
11
|
+
使用示例:
|
|
12
|
+
@invariant("ADR-060:H-1", "零唤醒/零流量断言")
|
|
13
|
+
def test_no_wake_lock_when_idle():
|
|
14
|
+
...
|
|
15
|
+
"""
|
|
16
|
+
def decorator(fn: Callable) -> Callable:
|
|
17
|
+
setattr(fn, "__invariant_id__", invariant_id)
|
|
18
|
+
setattr(fn, "__invariant_desc__", description)
|
|
19
|
+
return fn
|
|
20
|
+
return decorator
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def contract_only(adr: str, expire: str = "", reason: str = "") -> Callable:
|
|
24
|
+
"""
|
|
25
|
+
标记契约沙箱中的未接线原型代码。
|
|
26
|
+
|
|
27
|
+
使用示例:
|
|
28
|
+
@contract_only(adr="ADR-060", expire="2026-12-01", reason="等待端侧空闲状态服务")
|
|
29
|
+
def calculate_nightly_window(...):
|
|
30
|
+
...
|
|
31
|
+
"""
|
|
32
|
+
def decorator(fn: Callable) -> Callable:
|
|
33
|
+
setattr(fn, "__contract_only__", True)
|
|
34
|
+
setattr(fn, "__adr__", adr)
|
|
35
|
+
setattr(fn, "__expire__", expire)
|
|
36
|
+
setattr(fn, "__reason__", reason)
|
|
37
|
+
return fn
|
|
38
|
+
return decorator
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* spec-guard TypeScript / Node 规范与打标助手
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 装饰器形式 (TS Decorator)
|
|
7
|
+
*/
|
|
8
|
+
export function Invariant(invariantId: string, description: string = "") {
|
|
9
|
+
return function (target: any, propertyKey: string, descriptor?: PropertyDescriptor) {
|
|
10
|
+
if (descriptor) {
|
|
11
|
+
descriptor.value.__invariantId__ = invariantId;
|
|
12
|
+
descriptor.value.__invariantDesc__ = description;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 契约沙箱标记 (TS Decorator)
|
|
19
|
+
*/
|
|
20
|
+
export function ContractOnly(adr: string, expire: string = "", reason: string = "") {
|
|
21
|
+
return function (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) {
|
|
22
|
+
const meta = { contractOnly: true, adr, expire, reason };
|
|
23
|
+
if (descriptor) {
|
|
24
|
+
descriptor.value.__contractOnly__ = meta;
|
|
25
|
+
} else {
|
|
26
|
+
target.__contractOnly__ = meta;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* JSDoc / 测试注释约定形式:
|
|
33
|
+
*
|
|
34
|
+
* // @invariant ADR-060:H-1
|
|
35
|
+
* it('should satisfy zero network traffic', () => { ... });
|
|
36
|
+
*
|
|
37
|
+
* // @contractOnly ADR-060 expire: 2026-12-01
|
|
38
|
+
* export function evaluateSafetyWindow() { ... }
|
|
39
|
+
*/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Architecture Spec & Drift Audit
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ main, master ]
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '0 2 * * *' # 每日凌晨异步对账
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
spec-guard-audit:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout Code
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Setup Node.js
|
|
17
|
+
uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: '>=18'
|
|
20
|
+
|
|
21
|
+
- name: Run spec-guard full audit
|
|
22
|
+
run: |
|
|
23
|
+
npx lab-agent-toolkit spec-guard check --strict
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ==============================================================================
|
|
3
|
+
# pre-commit.d/15-spec-guard
|
|
4
|
+
# 轻量规约与架构漂移防护门禁(增量无改动时 < 0.05s)
|
|
5
|
+
# ==============================================================================
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# 1. 尝试定位 spec-guard CLI
|
|
9
|
+
SPEC_GUARD_BIN=""
|
|
10
|
+
if command -v spec-guard >/dev/null 2>&1; then
|
|
11
|
+
SPEC_GUARD_BIN="spec-guard"
|
|
12
|
+
elif command -v lab >/dev/null 2>&1; then
|
|
13
|
+
SPEC_GUARD_BIN="lab spec-guard"
|
|
14
|
+
elif [ -f "./node_modules/.bin/spec-guard" ]; then
|
|
15
|
+
SPEC_GUARD_BIN="./node_modules/.bin/spec-guard"
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
if [ -z "$SPEC_GUARD_BIN" ]; then
|
|
19
|
+
# Fail-open: 若未安装工具则静默放行,不阻断提交
|
|
20
|
+
exit 0
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# 2. 增量感知:获取当前 commit 暂存区改动文件
|
|
24
|
+
# 若暂存区未涉及任何架构规约、不变量或凭据资产,门禁快速放行(< 0.05s)
|
|
25
|
+
# 杜绝日常普通业务代码、样式或文档提交被全仓历史架构负债误杀
|
|
26
|
+
FORCE_CHECK="${SPEC_GUARD_FORCE_CHECK:-0}"
|
|
27
|
+
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR 2>/dev/null || true)
|
|
28
|
+
|
|
29
|
+
if [ "$FORCE_CHECK" != "1" ]; then
|
|
30
|
+
if [ -z "$STAGED_FILES" ]; then
|
|
31
|
+
# 暂存区无任何改动文件,直接快速放行
|
|
32
|
+
exit 0
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
TOUCHES_SPEC=0
|
|
36
|
+
|
|
37
|
+
# 检查是否命中常规 ADR 目录、Overlay 配置或 Evidence 凭据
|
|
38
|
+
if echo "$STAGED_FILES" | grep -Eq '(^|/)(adr|ADR|decisions|proposals|architecture)/.*\.md$|spec-matrix\.overlay\.ya?ml$|(^|/)evidence/.*\.json$'; then
|
|
39
|
+
TOUCHES_SPEC=1
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
# 检查是否命中 overlay 中自定义配置的 adr_dirs
|
|
43
|
+
if [ "$TOUCHES_SPEC" -eq 0 ] && ([ -f "spec-matrix.overlay.yml" ] || [ -f "spec-matrix.overlay.yaml" ]); then
|
|
44
|
+
CUSTOM_DIRS=$(grep -A 15 '^adr_dirs:' spec-matrix.overlay.y*ml 2>/dev/null | grep '^ *-' | sed 's/^ *- *//' | tr '\n' '|' | sed 's/|$//' || true)
|
|
45
|
+
if [ -n "$CUSTOM_DIRS" ] && echo "$STAGED_FILES" | grep -Eq "(^|/)($CUSTOM_DIRS)/.*\.md$"; then
|
|
46
|
+
TOUCHES_SPEC=1
|
|
47
|
+
fi
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# 检查暂存代码中是否有 @Invariant / @invariant 注解变动
|
|
51
|
+
if [ "$TOUCHES_SPEC" -eq 0 ]; then
|
|
52
|
+
if git diff --cached -G'@(i|I)nvariant' --name-only 2>/dev/null | grep -q .; then
|
|
53
|
+
TOUCHES_SPEC=1
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# 若暂存区未触及任何规约、不变量或机器凭据,快速放行
|
|
58
|
+
if [ "$TOUCHES_SPEC" -eq 0 ]; then
|
|
59
|
+
exit 0
|
|
60
|
+
fi
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# 3. 当且仅当本次提交涉及架构规约/不变量改动时,执行全景三元对账严格门禁拦截
|
|
64
|
+
$SPEC_GUARD_BIN check --full --strict || {
|
|
65
|
+
echo ""
|
|
66
|
+
echo "❌ [spec-guard] 架构规约门禁检查未通过!"
|
|
67
|
+
echo "提示:请检查是否有未按规范修改的 Frozen ADR 或未沙箱隔离的裸原型代码。"
|
|
68
|
+
echo "详细查看:$SPEC_GUARD_BIN check"
|
|
69
|
+
exit 1
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exit 0
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# spec-guard 覆写与跨端契约层 (Overlay)
|
|
2
|
+
#
|
|
3
|
+
# 注意:spec-guard 默认推行 Code-as-Spec-Matrix,即直接通过源码扫描 @Invariant 注解与 ADR 状态表。
|
|
4
|
+
# 本文件仅作为【跨端/跨语言无直接代码引用】(如 Android ↔ Python)或特殊契约的按需覆写层。
|
|
5
|
+
|
|
6
|
+
version: "1.0"
|
|
7
|
+
|
|
8
|
+
# ==============================================================================
|
|
9
|
+
# ADR 发现与状态映射配置 (可选)
|
|
10
|
+
# 适用于定制化 ADR 目录结构或异构决策体系(如 docs/decisions/DECISION-NNNN)
|
|
11
|
+
# ==============================================================================
|
|
12
|
+
|
|
13
|
+
# 可选:自定义 ADR 存放目录列表(缺省搜索 group/architecture/adr, docs/adr, adr, docs/proposals)
|
|
14
|
+
# adr_dirs:
|
|
15
|
+
# - docs/decisions
|
|
16
|
+
|
|
17
|
+
# 可选:自定义 ADR 编号与文件名提取正则(缺省匹配 ADR-\d+ 与 ^\d{4}-)
|
|
18
|
+
# adr_id_pattern: "DECISION-\\d+"
|
|
19
|
+
|
|
20
|
+
# 可选:自定义判定为 Frozen 状态的值列表(缺省自动识别包含 🔒 或 frozen/Frozen 的状态,active/superseded 默认不冻结)
|
|
21
|
+
# frozen_states:
|
|
22
|
+
# - "frozen"
|
|
23
|
+
# - "🔒 Frozen"
|
|
24
|
+
|
|
25
|
+
# 可选:自定义核心章节标题别名
|
|
26
|
+
# section_aliases:
|
|
27
|
+
# decision:
|
|
28
|
+
# - "决定"
|
|
29
|
+
# - "决策"
|
|
30
|
+
# - "Decision"
|
|
31
|
+
# implementation:
|
|
32
|
+
# - "验证"
|
|
33
|
+
# - "落地情况"
|
|
34
|
+
# - "Implementation Status"
|
|
35
|
+
# invariants:
|
|
36
|
+
# - "不可变量"
|
|
37
|
+
# - "不变量"
|
|
38
|
+
# - "Invariants"
|
|
39
|
+
|
|
40
|
+
# 可选:性能实测与机器信任根对账规则 (ADR-064)
|
|
41
|
+
# 用于区分「架构约定阈值/配置上限(如轮询周期 ≤1s)」与「性能实测基准(如推理均值 39.42ms)」
|
|
42
|
+
# telemetry_ignore_patterns:
|
|
43
|
+
# - "≤1s"
|
|
44
|
+
# - "轮询"
|
|
45
|
+
# - "/\\b\\d+\\s*s\\s*轮询/"
|
|
46
|
+
|
|
47
|
+
# 可选:整单豁免机器信任根强校验的 ADR 列表(亦可在 ADR frontmatter 中声明 `telemetry: exempt`)
|
|
48
|
+
# telemetry_exempt_adrs:
|
|
49
|
+
# - "ADR-0006"
|
|
50
|
+
|
|
51
|
+
# ==============================================================================
|
|
52
|
+
# 跨端跨语言契约覆盖定义 (Overlay)
|
|
53
|
+
# ==============================================================================
|
|
54
|
+
invariants:
|
|
55
|
+
- id: "ADR-060:Gate1"
|
|
56
|
+
name: "跨端设备排他锁互斥"
|
|
57
|
+
status: "in_progress" # verified | in_progress | unwired | blocked
|
|
58
|
+
adr_file: "ADR-060-twenty-four-hour-ota-timing-and-business-interlock-spec.md"
|
|
59
|
+
cross_repo_contracts:
|
|
60
|
+
- repo: "Tappy"
|
|
61
|
+
edge: "mcp-server/device_lock.py ↔ android/app/src/main/.../ServiceWatchdog.kt"
|
|
62
|
+
protocol: "WS Frame: system_update_available"
|
|
63
|
+
assertions:
|
|
64
|
+
- type: "cross_boundary_contract"
|
|
65
|
+
target: "tests/contract/test_device_lock_interlock.py"
|
|
66
|
+
marker: "@invariant(\"ADR-060:Gate1\")"
|
|
67
|
+
production:
|
|
68
|
+
symbols:
|
|
69
|
+
- "mcp_server.device_lock#acquire_device_probe_guard"
|
|
70
|
+
wiring_status: "unwired"
|