@dommaker/harness 1.14.0 → 1.15.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.
Files changed (281) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +4 -2
  3. package/dist/cli/commands/constraints-disable.d.ts +48 -0
  4. package/dist/cli/commands/constraints-disable.d.ts.map +1 -0
  5. package/dist/cli/commands/constraints-disable.js +156 -0
  6. package/dist/cli/commands/constraints-disable.js.map +1 -0
  7. package/dist/cli/commands/constraints-pack-proposal.d.ts +1 -1
  8. package/dist/cli/commands/constraints-pack-proposal.js +1 -1
  9. package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
  10. package/dist/cli/commands/constraints-reactivate.js +4 -2
  11. package/dist/cli/commands/constraints-reactivate.js.map +1 -1
  12. package/dist/cli/commands/constraints-retire.d.ts +14 -4
  13. package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
  14. package/dist/cli/commands/constraints-retire.js +10 -6
  15. package/dist/cli/commands/constraints-retire.js.map +1 -1
  16. package/dist/cli/commands/constraints.d.ts +1 -1
  17. package/dist/cli/commands/constraints.js +1 -1
  18. package/dist/cli/commands/definitions.d.ts.map +1 -1
  19. package/dist/cli/commands/definitions.js +16 -1
  20. package/dist/cli/commands/definitions.js.map +1 -1
  21. package/dist/cli/commands/knowledge-view.d.ts +3 -3
  22. package/dist/cli/commands/knowledge-view.js +4 -4
  23. package/dist/cli/commands/knowledge-view.js.map +1 -1
  24. package/dist/cli/commands/release.d.ts +2 -2
  25. package/dist/cli/commands/release.js +2 -2
  26. package/dist/cli/commands/sync-docs/agents-syncer.js +2 -4
  27. package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
  28. package/dist/cli/commands/sync-docs/head-gate.d.ts +34 -0
  29. package/dist/cli/commands/sync-docs/head-gate.d.ts.map +1 -0
  30. package/dist/cli/commands/sync-docs/head-gate.js +86 -0
  31. package/dist/cli/commands/sync-docs/head-gate.js.map +1 -0
  32. package/dist/cli/commands/sync-docs/index.d.ts +7 -0
  33. package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
  34. package/dist/cli/commands/sync-docs/index.js +51 -1
  35. package/dist/cli/commands/sync-docs/index.js.map +1 -1
  36. package/dist/completion-checkers/contract-presence.d.ts +1 -1
  37. package/dist/completion-checkers/contract-presence.js +1 -1
  38. package/dist/core/constraints/capabilities-parser.js +1 -1
  39. package/dist/core/constraints/check-cache.d.ts +1 -1
  40. package/dist/core/constraints/check-cache.js +1 -1
  41. package/dist/core/constraints/checkers/capability-sync.d.ts +1 -1
  42. package/dist/core/constraints/checkers/capability-sync.js +1 -1
  43. package/dist/core/constraints/checkers/docs-freshness.js +1 -1
  44. package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
  45. package/dist/core/constraints/checkers/governance-presence.d.ts +1 -1
  46. package/dist/core/constraints/checkers/governance-presence.js +1 -1
  47. package/dist/core/constraints/checkers/index.d.ts.map +1 -1
  48. package/dist/core/constraints/checkers/index.js +2 -2
  49. package/dist/core/constraints/checkers/index.js.map +1 -1
  50. package/dist/core/constraints/checkers/no-completion-without-verification.d.ts +34 -0
  51. package/dist/core/constraints/checkers/no-completion-without-verification.d.ts.map +1 -0
  52. package/dist/core/constraints/checkers/no-completion-without-verification.js +157 -0
  53. package/dist/core/constraints/checkers/no-completion-without-verification.js.map +1 -0
  54. package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +3 -0
  55. package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
  56. package/dist/core/constraints/checkers/no-hardcoded-credentials.js +19 -2
  57. package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
  58. package/dist/core/constraints/checkers/types.d.ts +1 -1
  59. package/dist/core/constraints/checkers/types.js +1 -1
  60. package/dist/core/constraints/context-builder.d.ts.map +1 -1
  61. package/dist/core/constraints/context-builder.js +0 -17
  62. package/dist/core/constraints/context-builder.js.map +1 -1
  63. package/dist/core/constraints/definitions/guidelines.js +1 -1
  64. package/dist/core/constraints/definitions/iron-laws.js +2 -2
  65. package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
  66. package/dist/core/constraints/definitions.d.ts +1 -1
  67. package/dist/core/constraints/definitions.js +1 -1
  68. package/dist/core/constraints/index.d.ts +1 -1
  69. package/dist/core/constraints/index.d.ts.map +1 -1
  70. package/dist/core/constraints/index.js.map +1 -1
  71. package/dist/core/constraints/run-env.d.ts +3 -2
  72. package/dist/core/constraints/run-env.d.ts.map +1 -1
  73. package/dist/core/constraints/run-env.js +5 -4
  74. package/dist/core/constraints/run-env.js.map +1 -1
  75. package/dist/core/constraints/usage-report.d.ts +0 -5
  76. package/dist/core/constraints/usage-report.d.ts.map +1 -1
  77. package/dist/core/constraints/usage-report.js +3 -12
  78. package/dist/core/constraints/usage-report.js.map +1 -1
  79. package/dist/core/effective-constraints.d.ts +1 -1
  80. package/dist/core/effective-constraints.js +1 -1
  81. package/dist/core/index.d.ts +1 -1
  82. package/dist/core/index.d.ts.map +1 -1
  83. package/dist/core/index.js.map +1 -1
  84. package/dist/core/retired-constraints.d.ts +66 -0
  85. package/dist/core/retired-constraints.d.ts.map +1 -0
  86. package/dist/core/retired-constraints.js +52 -0
  87. package/dist/core/retired-constraints.js.map +1 -0
  88. package/dist/core/validators/checkpoint.d.ts +4 -2
  89. package/dist/core/validators/checkpoint.d.ts.map +1 -1
  90. package/dist/core/validators/checkpoint.js +4 -2
  91. package/dist/core/validators/checkpoint.js.map +1 -1
  92. package/dist/core/validators/passes-gate.d.ts +2 -2
  93. package/dist/core/validators/passes-gate.d.ts.map +1 -1
  94. package/dist/core/validators/passes-gate.js +4 -3
  95. package/dist/core/validators/passes-gate.js.map +1 -1
  96. package/dist/gates/checker-gate.d.ts +3 -3
  97. package/dist/gates/checker-gate.js +3 -3
  98. package/dist/gates/index.d.ts +1 -1
  99. package/dist/gates/index.js +1 -1
  100. package/dist/index.d.ts +3 -1
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +7 -5
  103. package/dist/index.js.map +1 -1
  104. package/dist/knowledge/audit-scoring.js +1 -1
  105. package/dist/knowledge/audit-scoring.js.map +1 -1
  106. package/dist/monitoring/trace-analyzer.d.ts +2 -2
  107. package/dist/monitoring/trace-analyzer.js +2 -2
  108. package/dist/monitoring/traces.d.ts +1 -1
  109. package/dist/monitoring/traces.js +4 -4
  110. package/dist/monitoring/traces.js.map +1 -1
  111. package/dist/pretool-use-hook.d.ts +1 -1
  112. package/dist/pretool-use-hook.d.ts.map +1 -1
  113. package/dist/pretool-use-hook.js +5 -5
  114. package/dist/pretool-use-hook.js.map +1 -1
  115. package/dist/release/integrity.d.ts +4 -4
  116. package/dist/release/integrity.js +4 -4
  117. package/dist/test-setup/mkdtemp-cleanup.js +1 -1
  118. package/dist/tools/definitions/core/notification/notify.yml +0 -1
  119. package/dist/tools/definitions/ext/browser/browser-close.yml +0 -1
  120. package/dist/tools/definitions/ext/browser/browser-start.yml +0 -1
  121. package/dist/tools/definitions/std/evolution/implement.yml +0 -1
  122. package/dist/tools/definitions/std/evolution/prioritize.yml +0 -1
  123. package/dist/tools/definitions/std/evolution/report-gap.yml +0 -1
  124. package/dist/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
  125. package/dist/tools/definitions/std/governance/audit-task.yml +0 -1
  126. package/dist/tools/definitions/std/governance/cast-vote.yml +0 -1
  127. package/dist/tools/definitions/std/governance/create-voting-session.yml +0 -1
  128. package/dist/tools/definitions/std/governance/define-stance.yml +0 -1
  129. package/dist/tools/definitions/std/governance/impeach.yml +0 -1
  130. package/dist/tools/definitions/std/governance/multi-stance-review.yml +0 -1
  131. package/dist/tools/definitions/std/governance/rollback.yml +0 -1
  132. package/dist/tools/definitions/std/governance/stance-review.yml +0 -1
  133. package/dist/tools/definitions/std/governance/track-effect.yml +0 -1
  134. package/dist/tools/definitions/std/governance/vote-tally.yml +0 -1
  135. package/dist/tools/definitions/std/planning/split-batch.yml +0 -1
  136. package/dist/tools/definitions/std/planning/split-tasks.yml +0 -1
  137. package/dist/types/constraint.d.ts +1 -7
  138. package/dist/types/constraint.d.ts.map +1 -1
  139. package/dist/types/constraint.js.map +1 -1
  140. package/dist/types/passes-gate.d.ts +7 -0
  141. package/dist/types/passes-gate.d.ts.map +1 -1
  142. package/dist/types/passes-gate.js +8 -0
  143. package/dist/types/passes-gate.js.map +1 -1
  144. package/dist/utils/detect-source-roots.d.ts +1 -1
  145. package/dist/utils/detect-source-roots.d.ts.map +1 -1
  146. package/dist/utils/detect-source-roots.js +2 -21
  147. package/dist/utils/detect-source-roots.js.map +1 -1
  148. package/package.json +1 -2
  149. package/src/CONTEXT.md +2 -2
  150. package/src/__tests__/checker-extra.test.ts +32 -9
  151. package/src/__tests__/checker-primitives-sdk.test.ts +2 -2
  152. package/src/__tests__/checker.test.ts +16 -14
  153. package/src/__tests__/detect-source-roots.test.ts +5 -4
  154. package/src/__tests__/exec-checker-full-chain.test.ts +3 -3
  155. package/src/__tests__/iron-laws.test.ts +13 -20
  156. package/src/__tests__/no-studio-references.test.ts +54 -0
  157. package/src/__tests__/passes-gate-check.test.ts +1 -1
  158. package/src/__tests__/pretool-use-hook.test.ts +2 -2
  159. package/src/__tests__/public-exports.test.ts +1 -0
  160. package/src/__tests__/public-type-surface.test.ts +2 -2
  161. package/src/__tests__/retired-constraints.test.ts +99 -0
  162. package/src/__tests__/skip-semantics.test.ts +16 -33
  163. package/src/__tests__/usage-report-public-export.test.ts +3 -3
  164. package/src/cli/commands/CONTEXT.md +7 -6
  165. package/src/cli/commands/__tests__/check-read-count.test.ts +3 -0
  166. package/src/cli/commands/__tests__/check.test.ts +33 -6
  167. package/src/cli/commands/__tests__/constraints-disable.test.ts +229 -0
  168. package/src/cli/commands/__tests__/constraints-report-json-flag.test.ts +1 -1
  169. package/src/cli/commands/__tests__/constraints-report.test.ts +4 -4
  170. package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +1 -1
  171. package/src/cli/commands/__tests__/knowledge.test.ts +3 -3
  172. package/src/cli/commands/__tests__/project-path-anchoring.test.ts +4 -1
  173. package/src/cli/commands/__tests__/project-path-convention.test.ts +1 -1
  174. package/src/cli/commands/__tests__/spec-baseline-index-cap.test.ts +1 -1
  175. package/src/cli/commands/__tests__/sync-docs-agents.test.ts +1 -24
  176. package/src/cli/commands/__tests__/sync-docs-gate.test.ts +154 -0
  177. package/src/cli/commands/__tests__/sync-docs-table-layout.test.ts +1 -1
  178. package/src/cli/commands/__tests__/sync-docs.test.ts +3 -3
  179. package/src/cli/commands/constraints-disable.ts +145 -0
  180. package/src/cli/commands/constraints-pack-proposal.ts +1 -1
  181. package/src/cli/commands/constraints-reactivate.ts +4 -2
  182. package/src/cli/commands/constraints-retire.ts +11 -8
  183. package/src/cli/commands/constraints.ts +1 -1
  184. package/src/cli/commands/definitions.ts +16 -1
  185. package/src/cli/commands/knowledge-view.ts +4 -4
  186. package/src/cli/commands/release.ts +2 -2
  187. package/src/cli/commands/sync-docs/agents-syncer.ts +2 -4
  188. package/src/cli/commands/sync-docs/head-gate.ts +87 -0
  189. package/src/cli/commands/sync-docs/index.ts +62 -1
  190. package/src/completion-checkers/contract-presence.ts +1 -1
  191. package/src/core/CONTEXT.md +4 -3
  192. package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +1 -1
  193. package/src/core/constraints/__tests__/check-cache.test.ts +1 -1
  194. package/src/core/constraints/__tests__/collect-constraints.test.ts +42 -18
  195. package/src/core/constraints/__tests__/run-env.test.ts +7 -7
  196. package/src/core/constraints/__tests__/trace-injection.test.ts +8 -2
  197. package/src/core/constraints/capabilities-parser.ts +1 -1
  198. package/src/core/constraints/check-cache.ts +1 -1
  199. package/src/core/constraints/checkers/__tests__/fixtures/public-repo-sanitization.mjs +1 -1
  200. package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +1 -1
  201. package/src/core/constraints/checkers/__tests__/input-contract.test.ts +3 -3
  202. package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +208 -0
  203. package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +17 -0
  204. package/src/core/constraints/checkers/capability-sync.ts +1 -1
  205. package/src/core/constraints/checkers/docs-freshness.ts +1 -1
  206. package/src/core/constraints/checkers/governance-presence.ts +1 -1
  207. package/src/core/constraints/checkers/index.ts +1 -3
  208. package/src/core/constraints/checkers/no-completion-without-verification.ts +126 -0
  209. package/src/core/constraints/checkers/no-hardcoded-credentials.ts +20 -2
  210. package/src/core/constraints/checkers/types.ts +1 -1
  211. package/src/core/constraints/context-builder.ts +0 -18
  212. package/src/core/constraints/definitions/guidelines.ts +1 -1
  213. package/src/core/constraints/definitions/iron-laws.ts +2 -2
  214. package/src/core/constraints/definitions.ts +1 -1
  215. package/src/core/constraints/doc-freshness/__tests__/runner.test.ts +3 -3
  216. package/src/core/constraints/index.ts +0 -1
  217. package/src/core/constraints/run-env.ts +6 -5
  218. package/src/core/constraints/usage-report.ts +2 -12
  219. package/src/core/effective-constraints.ts +1 -1
  220. package/src/core/index.ts +0 -1
  221. package/src/core/retired-constraints.ts +77 -0
  222. package/src/core/validators/checkpoint.ts +4 -2
  223. package/src/core/validators/passes-gate.ts +4 -3
  224. package/src/gates/CONTEXT.md +3 -2
  225. package/src/gates/__tests__/checker-gate.test.ts +3 -3
  226. package/src/gates/checker-gate.ts +3 -3
  227. package/src/gates/index.ts +1 -1
  228. package/src/hooks/CONTEXT.md +2 -2
  229. package/src/index.ts +9 -3
  230. package/src/knowledge/CONTEXT.md +2 -2
  231. package/src/knowledge/__tests__/audit.test.ts +1 -1
  232. package/src/knowledge/__tests__/flywheel-metrics.test.ts +1 -1
  233. package/src/knowledge/audit-scoring.ts +1 -1
  234. package/src/monitoring/CONTEXT.md +2 -2
  235. package/src/monitoring/__tests__/skipped-lines-report.test.ts +2 -2
  236. package/src/monitoring/__tests__/traces.test.ts +1 -1
  237. package/src/monitoring/trace-analyzer.ts +2 -2
  238. package/src/monitoring/traces.ts +4 -4
  239. package/src/pretool-use-hook.ts +5 -5
  240. package/src/release/CONTEXT.md +3 -3
  241. package/src/release/integrity.ts +4 -4
  242. package/src/test-setup/__tests__/mkdtemp-cleanup.test.ts +1 -1
  243. package/src/test-setup/mkdtemp-cleanup.ts +1 -1
  244. package/src/tools/CONTEXT.md +3 -3
  245. package/src/tools/__tests__/registry.test.ts +3 -3
  246. package/src/tools/definitions/core/notification/notify.yml +0 -1
  247. package/src/tools/definitions/ext/browser/browser-close.yml +0 -1
  248. package/src/tools/definitions/ext/browser/browser-start.yml +0 -1
  249. package/src/tools/definitions/std/evolution/implement.yml +0 -1
  250. package/src/tools/definitions/std/evolution/prioritize.yml +0 -1
  251. package/src/tools/definitions/std/evolution/report-gap.yml +0 -1
  252. package/src/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
  253. package/src/tools/definitions/std/governance/audit-task.yml +0 -1
  254. package/src/tools/definitions/std/governance/cast-vote.yml +0 -1
  255. package/src/tools/definitions/std/governance/create-voting-session.yml +0 -1
  256. package/src/tools/definitions/std/governance/define-stance.yml +0 -1
  257. package/src/tools/definitions/std/governance/impeach.yml +0 -1
  258. package/src/tools/definitions/std/governance/multi-stance-review.yml +0 -1
  259. package/src/tools/definitions/std/governance/rollback.yml +0 -1
  260. package/src/tools/definitions/std/governance/stance-review.yml +0 -1
  261. package/src/tools/definitions/std/governance/track-effect.yml +0 -1
  262. package/src/tools/definitions/std/governance/vote-tally.yml +0 -1
  263. package/src/tools/definitions/std/planning/split-batch.yml +0 -1
  264. package/src/tools/definitions/std/planning/split-tasks.yml +0 -1
  265. package/src/types/constraint.ts +1 -8
  266. package/src/types/passes-gate.ts +8 -0
  267. package/src/utils/detect-source-roots.ts +2 -20
  268. package/bin/harness-knowledge-track.sh +0 -47
  269. package/bin/harness-sensitive-check.sh +0 -67
  270. package/dist/core/constraints/checkers/iron-flags.d.ts +0 -12
  271. package/dist/core/constraints/checkers/iron-flags.d.ts.map +0 -1
  272. package/dist/core/constraints/checkers/iron-flags.js +0 -16
  273. package/dist/core/constraints/checkers/iron-flags.js.map +0 -1
  274. package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +0 -43
  275. package/src/core/constraints/checkers/iron-flags.ts +0 -17
  276. package/templates/nextjs-app/.github/workflows/ci.yml +0 -39
  277. package/templates/node-api/.github/workflows/ci.yml +0 -36
  278. package/templates/node-api/package.json +0 -23
  279. package/templates/node-api/src/index.ts +0 -2
  280. package/templates/node-api/tsconfig.json +0 -19
  281. package/templates/python-api/.github/workflows/ci.yml +0 -39
@@ -0,0 +1,208 @@
1
+ /**
2
+ * no_completion_without_verification 证据源重构(harness#183)
3
+ *
4
+ * 旧证据源是语义循环:traces.log 尾部 pass 记录的唯一生产写入方是约束检查自身
5
+ * ——「你验证过了吗」的回答是「你之前被检查过吗」。本套件钉死新口径:
6
+ *
7
+ * - 证据源 = `.harness/evidence/`(独立链路写入:PassesGate.runTests 真实跑测试
8
+ * 命令落盘,或消费方外部验证事件),与 traces.log 彻底脱钩
9
+ * - 新鲜度 = 最新证据 mtime ≥ 全部可读变更文件的最大 mtime(验证跑在最新变更之后)
10
+ * - 缺失/空目录 → fail;过期 → fail(点名晚于证据的变更文件);
11
+ * 证据位不可读 / 新鲜度不可判定 → 带原因的显式降级 skip(不静默)
12
+ *
13
+ * 端到端口径:一律经 ConstraintChecker.check 编排层进,不直调 evaluate。
14
+ */
15
+
16
+ import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
17
+ import * as fs from 'fs';
18
+ import * as path from 'path';
19
+ import * as os from 'os';
20
+ import { ConstraintChecker } from '../../checker';
21
+ import { CONSTRAINTS } from '../../definitions';
22
+ import { getConstraintCheck } from '..';
23
+ import { PassesGate } from '../../../validators/passes-gate';
24
+ import { DEFAULT_TRACE_FILE } from '../../../../types/trace';
25
+ import type { ConstraintContext } from '../../../../types/constraint';
26
+
27
+ const LAW = CONSTRAINTS['no_completion_without_verification'];
28
+ /** 缺省 no-op trace 记录器:本套件不验 trace 面 */
29
+ const checker = new ConstraintChecker();
30
+
31
+ let dir: string;
32
+
33
+ beforeEach(() => {
34
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-ncwv-'));
35
+ });
36
+
37
+ afterEach(() => {
38
+ fs.rmSync(dir, { recursive: true, force: true });
39
+ });
40
+
41
+ /** 造一个变更文件,mtime 钉到指定时刻(不等真实时钟) */
42
+ function writeChangedFile(rel: string, mtime: Date): string {
43
+ const abs = path.join(dir, rel);
44
+ fs.mkdirSync(path.dirname(abs), { recursive: true });
45
+ fs.writeFileSync(abs, 'export const x = 1;');
46
+ fs.utimesSync(abs, mtime, mtime);
47
+ return rel;
48
+ }
49
+
50
+ /** 造一条验证证据,mtime 钉到指定时刻 */
51
+ function writeEvidence(name: string, mtime: Date): void {
52
+ const evidenceDir = path.join(dir, '.harness', 'evidence');
53
+ fs.mkdirSync(evidenceDir, { recursive: true });
54
+ const abs = path.join(evidenceDir, name);
55
+ fs.writeFileSync(abs, 'test output');
56
+ fs.utimesSync(abs, mtime, mtime);
57
+ }
58
+
59
+ function contextOf(changedFiles?: string[]): ConstraintContext {
60
+ return { operation: 'code_implementation', projectPath: dir, changedFiles };
61
+ }
62
+
63
+ const T_OLD = new Date('2026-09-01T00:00:00Z');
64
+ const T_NEW = new Date('2026-09-02T00:00:00Z');
65
+
66
+ describe('no_completion_without_verification(harness#183 证据源重构)', () => {
67
+ it('真实跑过验证且证据新鲜(证据晚于最新变更)→ pass', async () => {
68
+ writeChangedFile('src/a.ts', T_OLD);
69
+ writeEvidence('test-2026-09-02.log', T_NEW);
70
+
71
+ const result = await checker.check(LAW, contextOf(['src/a.ts']));
72
+
73
+ expect(result.skipped).toBeUndefined();
74
+ expect(result.satisfied).toBe(true);
75
+ });
76
+
77
+ it('证据与最新变更同一时刻(>= 口径)→ pass', async () => {
78
+ writeChangedFile('src/a.ts', T_OLD);
79
+ writeEvidence('test-same-instant.log', T_OLD);
80
+
81
+ const result = await checker.check(LAW, contextOf(['src/a.ts']));
82
+
83
+ expect(result.satisfied).toBe(true);
84
+ });
85
+
86
+ it('changedFiles 为 undefined(调用方未接线变更清单)→ 显式降级 skip,不放行', async () => {
87
+ writeEvidence('test-2026-09-02.log', T_NEW);
88
+
89
+ const result = await checker.check(LAW, contextOf(undefined));
90
+
91
+ // 新鲜度无所依 ≠ 合规:生产侧直调(跳过 context-builder)正是这形态,必须有声
92
+ expect(result.skipped).toBe(true);
93
+ expect(result.skipReason).toContain('变更清单未接线');
94
+ });
95
+
96
+ it('空 changedFiles(真无变更)+ 有证据 → pass', async () => {
97
+ writeEvidence('test-2026-09-02.log', T_NEW);
98
+
99
+ const result = await checker.check(LAW, contextOf([]));
100
+
101
+ expect(result.skipped).toBeUndefined();
102
+ expect(result.satisfied).toBe(true);
103
+ });
104
+
105
+ it('未跑验证(.harness/evidence 不存在)→ fail,证据行给出修复入口', async () => {
106
+ writeChangedFile('src/a.ts', T_OLD);
107
+
108
+ const result = await checker.check(LAW, contextOf(['src/a.ts']));
109
+
110
+ expect(result.skipped).toBeUndefined();
111
+ expect(result.satisfied).toBe(false);
112
+ expect(result.evidence?.join('\n')).toContain('.harness/evidence');
113
+ });
114
+
115
+ it('证据目录为空 → fail(等价未跑)', async () => {
116
+ writeChangedFile('src/a.ts', T_OLD);
117
+ fs.mkdirSync(path.join(dir, '.harness', 'evidence'), { recursive: true });
118
+
119
+ const result = await checker.check(LAW, contextOf(['src/a.ts']));
120
+
121
+ expect(result.satisfied).toBe(false);
122
+ });
123
+
124
+ it('证据过期(旧于最新变更)→ fail,点名晚于证据的变更文件', async () => {
125
+ writeChangedFile('src/a.ts', T_OLD);
126
+ writeChangedFile('src/b.ts', T_NEW);
127
+ writeEvidence('test-2026-09-01.log', T_OLD);
128
+
129
+ const result = await checker.check(LAW, contextOf(['src/a.ts', 'src/b.ts']));
130
+
131
+ expect(result.satisfied).toBe(false);
132
+ const text = result.evidence?.join('\n') ?? '';
133
+ expect(text).toContain('过期');
134
+ expect(text).toContain('src/b.ts');
135
+ expect(text).not.toContain('src/a.ts');
136
+ });
137
+
138
+ it('循环拆除:traces.log 里有 pass 记录但无证据目录 → 仍 fail', async () => {
139
+ writeChangedFile('src/a.ts', T_OLD);
140
+ // 旧口径下这是一条「验证证据」;新口径必须不认
141
+ const logsDir = path.dirname(path.join(dir, DEFAULT_TRACE_FILE));
142
+ fs.mkdirSync(logsDir, { recursive: true });
143
+ fs.writeFileSync(
144
+ path.join(dir, DEFAULT_TRACE_FILE),
145
+ JSON.stringify({ constraintId: 'x', severity: 'error', timestamp: Date.now(), result: 'pass' }) + '\n'
146
+ );
147
+
148
+ const result = await checker.check(LAW, contextOf(['src/a.ts']));
149
+
150
+ expect(result.satisfied).toBe(false);
151
+ });
152
+
153
+ it('证据位被占用但不是目录 → 显式降级 skip(带原因),不静默', async () => {
154
+ writeChangedFile('src/a.ts', T_OLD);
155
+ fs.mkdirSync(path.join(dir, '.harness'), { recursive: true });
156
+ fs.writeFileSync(path.join(dir, '.harness', 'evidence'), 'not a directory');
157
+
158
+ const result = await checker.check(LAW, contextOf(['src/a.ts']));
159
+
160
+ expect(result.skipped).toBe(true);
161
+ expect(result.satisfied).toBe(true); // skip 不产生违规
162
+ expect(result.skipReason).toContain('.harness/evidence');
163
+ });
164
+
165
+ it('有证据但全部变更文件 mtime 不可读 → 显式降级 skip(无法判定新鲜度)', async () => {
166
+ writeEvidence('test-2026-09-02.log', T_NEW);
167
+
168
+ const result = await checker.check(LAW, contextOf(['src/gone.ts']));
169
+
170
+ expect(result.skipped).toBe(true);
171
+ expect(result.skipReason).toContain('新鲜度');
172
+ });
173
+
174
+ it('部分变更文件不可读不降级:按可读文件判定(删除文件是常态)', async () => {
175
+ writeChangedFile('src/a.ts', T_OLD);
176
+ writeEvidence('test-2026-09-02.log', T_NEW);
177
+
178
+ const result = await checker.check(LAW, contextOf(['src/a.ts', 'src/deleted.ts']));
179
+
180
+ expect(result.skipped).toBeUndefined();
181
+ expect(result.satisfied).toBe(true);
182
+ });
183
+
184
+ it('flag 退役:不再声明 contextFlags 输入契约(证据判定在 checker 体内)', () => {
185
+ const check = getConstraintCheck('no_completion_without_verification');
186
+ expect(check).toBeDefined();
187
+ expect(check!.needs?.contextFlags ?? []).not.toContain('hasVerificationEvidence');
188
+ });
189
+
190
+ it('端到端:PassesGate 真跑验证命令 → 证据落盘 → checker pass', async () => {
191
+ // 生产链路的最小真身:package.json 声明测试命令,PassesGate 真跑(退出码判定),
192
+ // 输出落 .harness/evidence/test-*.log,checker 读同一约定位放行
193
+ fs.writeFileSync(
194
+ path.join(dir, 'package.json'),
195
+ JSON.stringify({ scripts: { test: 'node -e "console.log(\'1 passed\')"' } })
196
+ );
197
+ writeChangedFile('src/a.ts', T_OLD);
198
+
199
+ const run = await new PassesGate().runTests(dir);
200
+ expect(run.passed).toBe(true);
201
+ const evidenceDir = path.join(dir, '.harness', 'evidence');
202
+ expect(fs.readdirSync(evidenceDir).some(f => f.startsWith('test-'))).toBe(true);
203
+
204
+ const result = await checker.check(LAW, contextOf(['src/a.ts']));
205
+ expect(result.skipped).toBeUndefined();
206
+ expect(result.satisfied).toBe(true);
207
+ });
208
+ });
@@ -109,6 +109,23 @@ describe('containsHardcodedCredential', () => {
109
109
  containsHardcodedCredential('export function add(a: number, b: number) { return a + b; }')
110
110
  ).toBe(false);
111
111
  });
112
+
113
+ it('豁免右值为代码表达式的赋值(#184 收窄正则版假灯回归)', () => {
114
+ // 现场复现:交付链 2026-09-24 一次采纳 1.14.0 时,业务仓的 React useCallback
115
+ // 赋值被无引号分支判成「口令类赋值」——右值是代码而非字面量。
116
+ expect(
117
+ containsHardcodedCredential('const insertPmoTok' + 'en = useCallback((candidate: string) => {')
118
+ ).toBe(false);
119
+ expect(
120
+ containsHardcodedCredential('const refreshTok' + 'en = getTokenFromStor' + 'age();')
121
+ ).toBe(false);
122
+ expect(
123
+ containsHardcodedCredential('const refreshTok' + 'en = req.cookies.refre' + 'sh;')
124
+ ).toBe(false);
125
+ expect(
126
+ containsHardcodedCredential('api' + '_key: make' + 'Key("abc123456789"),')
127
+ ).toBe(false);
128
+ });
112
129
  });
113
130
 
114
131
  describe('noHardcodedCredentials checker', () => {
@@ -6,7 +6,7 @@
6
6
  * 2. 全量扫描(T-058)— 源码根下所有源文件是否都在 CAPABILITIES.md 中 → **只出提示**
7
7
  *
8
8
  * Step 2 不判违规的理由:它是仓库级完备性不变量,与正在被评估的那次变更无因果——
9
- * 一处历史漏登会让此后每次 module_* 评估恒红(studio 实测 22/22 fail,且因 fail
9
+ * 一处历史漏登会让此后每次 module_* 评估恒红(下游消费方曾实测全量 fail,且因 fail
10
10
  * 零证据而无人能定位)。本处保留缺口输出是为了让人看得见、能自己修,而不是为了拦。
11
11
  *
12
12
  * 已知缺口(ADR-0016「影响」①):降级后仓库级漏登**没有自动拦截点**。`sync-docs --check`
@@ -99,7 +99,7 @@ export const docsFreshness: ConstraintCheck = {
99
99
  try {
100
100
  const deadEntries = findDeadCapabilityEntries(env);
101
101
  if (deadEntries.length > 0) {
102
- // 证据通道点名条目(harness#119):此前是 console.error 侧信道(2026-08-08 studio
102
+ // 证据通道点名条目(harness#119):此前是 console.error 侧信道(2026-08-08
103
103
  // CI 4 连红时的临时办法),CLI 结构化输出与 trace 两头都拿不到,
104
104
  // error 级拦截时用户只看到一句通用提示,basename 碰撞下无从定位
105
105
  return {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * governance_presence:治理契约在场守护(studio #302,ADR 2026-08-21 落点模型)
2
+ * governance_presence:治理契约在场守护(ADR 2026-08-21 落点模型)
3
3
  *
4
4
  * 治理契约正本 = AGENTS.md 手写 `PRESERVE:governance` 段(旧模型仓 = CLAUDE.md
5
5
  * Governance Rules 块 / 历史 HARNESS_CONSTRAINTS 注入段,ADR-0029 后注入段不再
@@ -17,9 +17,7 @@ import type { Constraint } from '../../../types/constraint';
17
17
  import type { ConstraintCheck } from './types';
18
18
  import { getAllConstraints, isGateConstraint } from '../definitions';
19
19
 
20
- import {
21
- noCompletionWithoutVerification,
22
- } from './iron-flags';
20
+ import { noCompletionWithoutVerification } from './no-completion-without-verification';
23
21
  import { noTestSimplification } from './no-test-simplification';
24
22
  import { capabilitySync } from './capability-sync';
25
23
  import { contextDocSync } from './context-doc-sync';
@@ -0,0 +1,126 @@
1
+ /**
2
+ * no_completion_without_verification(harness#183 证据源重构)
3
+ *
4
+ * 旧证据源是语义循环:「验证证据」取自 traces.log 尾部 pass 记录,而 traces.log
5
+ * 的唯一生产写入方是约束检查自身——「你验证过了吗」的回答是「你之前被检查过吗」。
6
+ * 本 checker 把证据源换到独立链路:`.harness/evidence/` 目录
7
+ * (PassesGate.runTests 真实跑项目声明的验证命令后落盘;消费方外部验证事件
8
+ * 也写这里),判定与约束检查自身的 trace 彻底脱钩。
9
+ *
10
+ * 新鲜度口径:最新证据文件的 mtime ≥ 全部可读变更文件的最大 mtime
11
+ * (验证跑在最新变更之后)。不用固定时间窗——与本次变更的因果关系才是口径。
12
+ * 已知边界(保守方向,不修复):git checkout 等刷新工作区 mtime 会误杀真证据
13
+ * (误判过期 → fail,要求重跑验证);证据只核存在性与时间,不读内容——防伪
14
+ * 非本票口径(旧机制是自我指认,更弱)。
15
+ *
16
+ * 与 exec 口子(harness#181)的关系:本判定不依赖 exec 模板;业务仓若要自定义
17
+ * 验证方式,用 exec checker 另行登记业务约束即可,与本铁律互不阻塞。
18
+ *
19
+ * 判定(显式三态,harness#182 语义):
20
+ * - 证据目录缺失/为空 → fail(从未验证)
21
+ * - 证据旧于最新变更 → fail(证据过期,点名晚于证据的变更文件)
22
+ * - 新鲜 → pass
23
+ * - changedFiles 为 undefined(调用方未接线变更清单,如生产侧直调)→ 带原因的
24
+ * CheckSkip:新鲜度无所依不能放行(空数组 = 真无变更,不在此列,有证据即过)
25
+ * - 证据位不可读(不是目录/全部 stat 失败)或全部变更文件 mtime 不可读
26
+ * → 带原因的 CheckSkip:证据源不可用 ≠ 对象合规,也不静默 skip
27
+ *
28
+ * flag 退役:此前经 ConstraintContext.hasVerificationEvidence 三态 flag 接线,
29
+ * 只有 CLI 路径填充(生产调用点恒 skip)。判定收进 checker 体内后,凡走到
30
+ * 编排层的调用方都按同一口径评估,flag 从 ConstraintContext 整体移除。
31
+ */
32
+
33
+ import * as fs from 'fs';
34
+ import * as path from 'path';
35
+ import { EVIDENCE_DIR_REL } from '../../../types/passes-gate';
36
+ import type { ConstraintCheck } from './types';
37
+ import { formatEvidence } from './types';
38
+
39
+ /** 证据目录探测结果:最新证据 mtime / 无证据 / 不可读(三态) */
40
+ type EvidenceProbe = { mtime: number } | { missing: true } | { unreadable: string };
41
+
42
+ /** 探测证据目录的最新证据 mtime(只计文件;目录缺失/为空 → missing;不可读 → unreadable) */
43
+ function probeEvidence(evidenceDir: string): EvidenceProbe {
44
+ let entries: fs.Dirent[];
45
+ try {
46
+ entries = fs.readdirSync(evidenceDir, { withFileTypes: true });
47
+ } catch (err) {
48
+ if ((err as NodeJS.ErrnoException).code === 'ENOENT') return { missing: true };
49
+ return { unreadable: err instanceof Error ? err.message : String(err) };
50
+ }
51
+ const files = entries.filter(e => e.isFile());
52
+ if (files.length === 0) return { missing: true };
53
+ let newest = -Infinity;
54
+ for (const entry of files) {
55
+ try {
56
+ const mtime = fs.statSync(path.join(evidenceDir, entry.name)).mtimeMs;
57
+ if (mtime > newest) newest = mtime;
58
+ } catch {
59
+ // 单个证据文件 stat 失败不拖死判定:跳过该条,按其余证据判定
60
+ }
61
+ }
62
+ if (newest === -Infinity) return { unreadable: '全部证据文件 stat 失败' };
63
+ return { mtime: newest };
64
+ }
65
+
66
+ export const noCompletionWithoutVerification: ConstraintCheck = {
67
+ id: 'no_completion_without_verification',
68
+ evaluate(env) {
69
+ const evidence = probeEvidence(path.join(env.projectPath, EVIDENCE_DIR_REL));
70
+
71
+ if ('unreadable' in evidence) {
72
+ return {
73
+ skip: true,
74
+ reason: `验证证据位 ${EVIDENCE_DIR_REL} 不可读(${evidence.unreadable}),本次未评估`,
75
+ };
76
+ }
77
+ if ('missing' in evidence) {
78
+ return {
79
+ pass: false,
80
+ evidence: formatEvidence('未运行验证:.harness/evidence 无测试输出记录', [
81
+ '先真实运行项目声明的验证命令(harness passes-gate 或等价测试运行),证据落盘后重新提交',
82
+ ]),
83
+ };
84
+ }
85
+
86
+ // 变更清单未接线(undefined)≠ 真无变更([]):前者无法判定新鲜度,显式降级
87
+ const changed = env.context.changedFiles;
88
+ if (changed === undefined) {
89
+ return {
90
+ skip: true,
91
+ reason: '变更清单未接线(context.changedFiles 缺失),无法判定证据新鲜度,本次未评估',
92
+ };
93
+ }
94
+
95
+ // 新鲜度:变更文件 mtime 逐只取,不可读的跳过(删除文件是常态);
96
+ // 全部不可读才无法判定 → 显式降级
97
+ let readable = 0;
98
+ const laterThanEvidence: string[] = [];
99
+ for (const file of changed) {
100
+ try {
101
+ const mtime = fs.statSync(path.join(env.projectPath, file)).mtimeMs;
102
+ readable++;
103
+ if (mtime > evidence.mtime) laterThanEvidence.push(file);
104
+ } catch {
105
+ // 变更文件不可读(如已删除):不参与新鲜度判定
106
+ }
107
+ }
108
+ if (changed.length > 0 && readable === 0) {
109
+ return {
110
+ skip: true,
111
+ reason: '无法判定证据新鲜度(变更文件 mtime 均不可读),本次未评估',
112
+ };
113
+ }
114
+
115
+ if (laterThanEvidence.length > 0) {
116
+ return {
117
+ pass: false,
118
+ evidence: formatEvidence(
119
+ '验证证据过期:最新证据早于本次变更,需重新运行项目声明的验证命令',
120
+ laterThanEvidence.map(f => `晚于证据的变更: ${f}`)
121
+ ),
122
+ };
123
+ }
124
+ return true;
125
+ },
126
+ };
@@ -12,6 +12,9 @@
12
12
  * 模板文件(.example/.sample/.template/.dist)与占位符值(your_xxx、process.env
13
13
  * 引用、变量插值等)豁免;占位符判定作用于「值」而非整行,行内出现 test/example
14
14
  * 等词不再豁免真实值。
15
+ *
16
+ * 无引号右值若是代码表达式(含括号/花括号/分号或 `=>`)一并豁免——那是调用与取值,
17
+ * 不是口令字面量;带引号的值不受此豁免影响(CODE_EXPRESSION 记明残余漏报与取舍)。
15
18
  */
16
19
 
17
20
  import { readFileSync } from 'fs';
@@ -54,6 +57,19 @@ const URL_CREDENTIAL_PATTERN = /\b[a-z][a-z0-9+.-]{1,20}:\/\/[^/\s:@'"]+:[^/\s@'
54
57
  const PLACEHOLDER_VALUE =
55
58
  /^(?:process\.env\b|your[_-]|<|\$\{|xxx+$|placeholder|changeme|dummy|fake|redacted|string\b|number\b|boolean\b|unknown\b|any\b)/i;
56
59
 
60
+ /**
61
+ * 代码表达式特征(只作用于**无引号**右值):带 `(`/`)`/`{`/`}`/`;` 或 `=>` 的裸值是代码,
62
+ * 不是字面量口令。无引号分支会把 `useCallback` 调用的整段左括号到首个空格吃成「值」,
63
+ * 于是 React/Vue 的 hook 赋值、成员链取值、函数调用一律误判「口令类赋值」
64
+ * (2026-09-24 交付链采纳 1.14.0 时于业务仓现场命中,回归测试钉在旁测文件)。
65
+ * 带引号的值不走此豁免——引号内就是字面量,括号属于口令本身。
66
+ *
67
+ * 残余已知漏报:右值是纯标识符引用(对象字面量里指向另一个变量)时不豁免,
68
+ * 它与 .env/YAML 的无引号真值同形、单行内无法区分。增量面刻意宁可放过代码形状,
69
+ * 也不给无引号真值开洞;这类泄露由全历史 gitleaks 兜底(见文件头分工)。
70
+ */
71
+ const CODE_EXPRESSION = /[(){};]|=>/;
72
+
57
73
  /** URL 匹配串内的占位符(变量插值、尖括号、your_xxx) */
58
74
  const URL_PLACEHOLDER = /\$\{|<|your[_-]|xxx+/i;
59
75
 
@@ -83,8 +99,10 @@ function classifyLine(line: string): HitRule | null {
83
99
  }
84
100
  const assign = line.match(ASSIGNMENT_PATTERN);
85
101
  if (assign) {
86
- const value = assign[1] ?? assign[2];
87
- if (!PLACEHOLDER_VALUE.test(value)) return '口令类赋值';
102
+ const quoted = assign[1];
103
+ const value = quoted ?? assign[2];
104
+ const codeRhs = quoted === undefined && CODE_EXPRESSION.test(value);
105
+ if (!codeRhs && !PLACEHOLDER_VALUE.test(value)) return '口令类赋值';
88
106
  }
89
107
  const url = line.match(URL_CREDENTIAL_PATTERN);
90
108
  if (url && !URL_PLACEHOLDER.test(url[0])) return 'URL 内嵌凭证';
@@ -66,7 +66,7 @@ export type CheckEvidenceInput = 'stagedDiff' | 'stagedDiffNames';
66
66
  * - runEnv = 本 run 的运行级观察面(ADR-0023):传入即与 context-builder 及
67
67
  * 其余 checker 共用同一份上行数据读取;不传则自造一枚,只服务本次调用
68
68
  *
69
- * studio 侧若需 git 证据(#129),传真实 providers 即可。
69
+ * 下游消费方若需 git 证据,传真实 providers 即可。
70
70
  */
71
71
  export function buildCheckEnv(
72
72
  context: ConstraintContext,
@@ -124,23 +124,6 @@ export function detectRootCauseInvestigation(projectPath: string): boolean {
124
124
  return false;
125
125
  }
126
126
 
127
- /** 验证证据的尾部窗口(工单 23 原口径:只看最近 10 条) */
128
- const VERIFICATION_EVIDENCE_TAIL = 10;
129
-
130
- /**
131
- * 检测是否有验证证据(取运行级观察面的最近 10 条)
132
- */
133
- async function detectVerificationEvidence(env: RunEnv): Promise<boolean> {
134
- try {
135
- // tail 在 parse 之前截断 → 坏行会占用尾部槽位(#82 裁决范围外的既有口径,本票不改)
136
- return env
137
- .traceTail(VERIFICATION_EVIDENCE_TAIL)
138
- .records.some(trace => trace.result === 'pass');
139
- } catch {
140
- return false;
141
- }
142
- }
143
-
144
127
  /**
145
128
  * 检测是否有需求来源
146
129
  * 检查 CLAUDE.md、README.md、specs/、docs/specs/ 等
@@ -221,7 +204,6 @@ export async function buildConstraintContext(options: {
221
204
  hasTest: changedFiles.some(f => f.includes('.test.') || f.includes('.spec.')),
222
205
  hasFailingTest: await detectFailingTest(runEnv),
223
206
  hasRootCauseInvestigation: detectRootCauseInvestigation(projectPath),
224
- hasVerificationEvidence: await detectVerificationEvidence(runEnv),
225
207
  hasReuseCheck: detectReuseCheck(projectPath),
226
208
  hasRequirement: detectRequirement(projectPath),
227
209
  };
@@ -70,7 +70,7 @@ export const WARNING_CONSTRAINTS: Record<string, Constraint> = {
70
70
  },
71
71
 
72
72
  /**
73
- * 治理契约在场守护(studio #302,ADR 2026-08-21 落点模型)
73
+ * 治理契约在场守护(ADR 2026-08-21 落点模型)
74
74
  * 原因:PRESERVE 只保「存在」不保「在场」——AGENTS.md 治理段被删除/掏空后
75
75
  * sync-docs 重新生成会静默丢失约束正本
76
76
  */
@@ -20,11 +20,11 @@ export const ERROR_CONSTRAINTS: Record<string, Constraint> = {
20
20
  kind: 'check',
21
21
  channel: 'gate',
22
22
  rule: 'NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE',
23
- message: '禁止无验证声明完成,必须运行验证命令',
23
+ message: '禁止无验证声明完成,必须有晚于最新变更的验证证据(.harness/evidence)',
24
24
  severity: 'error',
25
25
  trigger: 'code_implementation',
26
26
  enforcement: 'verify-completion',
27
- description: '在声明任何任务完成之前,必须运行新鲜的验证命令(项目声明的测试 + type check),以新鲜输出作为完成证据。验证命令集由项目自行声明,全量验证留给 CI 流程。',
27
+ description: '在声明任何任务完成之前,必须真实运行项目声明的测试等验证命令,输出落盘 .harness/evidence/(harness passes-gate 运行或外部验证事件写入)作为完成证据;证据须晚于最新变更,缺失或过期即违规。验证命令集由项目自行声明,全量验证留给 CI 流程。',
28
28
  },
29
29
 
30
30
  /**
@@ -6,7 +6,7 @@
6
6
  * 纯文本提示层(prompts.ts)已随文本注入层关停整体删除。
7
7
  *
8
8
  * 工单 20:字面量定义按 severity 分组放 ./definitions/{iron-laws,guidelines}.ts;
9
- * 本文件保持原路径做薄聚合(studio rule-scanner 按此路径解析,P0 #8)。
9
+ * 本文件保持原路径做薄聚合。
10
10
  */
11
11
 
12
12
  import type { Constraint, ConstraintTrigger } from '../../types/constraint';
@@ -278,11 +278,11 @@ describe('FreshnessRunner', () => {
278
278
  'CLAUDE.md': [
279
279
  '## Key Architecture Paths',
280
280
  '',
281
- '| `packages/studio-shared/src/` | Shared |',
281
+ '| `packages/pkg-a/src/` | Shared |',
282
282
  ].join('\n'),
283
283
  });
284
- mkdirSync(join(TEST_ROOT, 'dirdir-skip-reverse', 'packages', 'studio-shared', 'src'), { recursive: true });
285
- mkdirSync(join(TEST_ROOT, 'dirdir-skip-reverse', 'packages', 'studio-web', 'src'), { recursive: true });
284
+ mkdirSync(join(TEST_ROOT, 'dirdir-skip-reverse', 'packages', 'pkg-a', 'src'), { recursive: true });
285
+ mkdirSync(join(TEST_ROOT, 'dirdir-skip-reverse', 'packages', 'pkg-b', 'src'), { recursive: true });
286
286
 
287
287
  const config: DocFreshnessConfig = {
288
288
  checks: [{
@@ -56,7 +56,6 @@ export type {
56
56
  ConstraintResult,
57
57
  ConstraintContext,
58
58
  ConstraintCheckResult,
59
- IronLawContext,
60
59
  } from '../../types/constraint';
61
60
 
62
61
  export { ConstraintViolationError } from '../../types/constraint';
@@ -30,7 +30,8 @@ export const CAPABILITIES_FILE_REL = 'CAPABILITIES.md';
30
30
  /**
31
31
  * 尾部窗口上限 = 本 run 内最大的尾部消费方(有无失败记录看 20 条,见 context-builder)
32
32
  *
33
- * 更小的窗口(验证证据看 10 条)从同一份行文本上截,不再二次读文件。
33
+ * harness#183 起验证证据不再读 trace(语义循环拆除,改读 .harness/evidence),
34
+ * trace 尾部只剩 hasFailingTest 一个消费方。
34
35
  */
35
36
  const TRACE_TAIL_WINDOW = 20;
36
37
 
@@ -52,7 +53,7 @@ export interface RunEnv {
52
53
  * `CAPABILITIES.md` 的读取 + 解析 + 与代码实况的对照判定(ADR-0023 决策 4)
53
54
  *
54
55
  * 此前 capability_sync 与 docs_freshness 各读一遍文档、各跑一遍 `reconcileCapabilities`
55
- * (studio 量得单次 7.6–15.9ms,两边解析输入逐字节相同)。此处一次供给两消费方。
56
+ * (下游消费方量得单次 7.6–15.9ms,两边解析输入逐字节相同)。此处一次供给两消费方。
56
57
  * 文档缺失 → `undefined`(消费方据此 skip / 无幽灵)。
57
58
  *
58
59
  * **memo 只记第一次传入的 `populationFiles`**:同一 run 内两消费方必须给同一份代码实况清单。
@@ -95,9 +96,9 @@ export function createRunEnv(projectPath: string): RunEnv {
95
96
  projectPath,
96
97
  traceTail(limit: number) {
97
98
  if (!window) {
98
- // 计数去向:豁免(harness#100)——本观察面只供给「最近有无 fail / 有无 pass」两个
99
- // 布尔证据的消费方,它们不读 skippedLines;坏行占尾部槽位只会让证据变少(方向保守),
100
- // 告知需要改判定形状,属行为变更不在本票(口径与改前的两处独立 tail 读逐字一致)
99
+ // 计数去向:豁免(harness#100)——本观察面只供给「最近有无 fail」一个布尔证据
100
+ // 消费方,不读 skippedLines;坏行占尾部槽位只会让证据变少(方向保守),
101
+ // 告知需要改判定形状,属行为变更不在本票
101
102
  window = readJsonlWindow<ExecutionTrace>(traceFile, 'skip', TRACE_TAIL_WINDOW);
102
103
  }
103
104
  return window.take(limit);
@@ -19,14 +19,6 @@ import { readJsonl } from '../../utils/jsonl';
19
19
  import { getEffectiveConstraints, lintEffectiveConfig } from '../effective-constraints';
20
20
  import type { EffectiveConfigLint } from '../effective-constraints';
21
21
 
22
- /**
23
- * flag 型 check 约束(证据来自 ConstraintContext flag,见 checkers/iron-flags.ts)。
24
- * 全部 skip 时标注"证据 flag 未接线"(区别于存在性探测的"约定未采用")。
25
- */
26
- export const FLAG_EVIDENCE_CONSTRAINT_IDS: ReadonlySet<string> = new Set([
27
- 'no_completion_without_verification',
28
- ]);
29
-
30
22
  /**
31
23
  * 单条 check 约束的使用统计
32
24
  */
@@ -271,14 +263,12 @@ function diagnose(
271
263
  }
272
264
 
273
265
  if (s.skip === s.total) {
274
- const wiring = FLAG_EVIDENCE_CONSTRAINT_IDS.has(s.id)
275
- ? '证据 flag 未接线'
276
- : '约定未采用(存在性探测未命中)';
266
+ // harness#183 起无 flag 型约束:全 skip = 约定未采用(存在性探测未命中)或证据不可用
277
267
  candidates.push({
278
268
  id: s.id,
279
269
  kind: 'unevaluable',
280
270
  stats: s,
281
- reason: `不可评估:全部 ${s.total} 次均为 skip(${wiring})`,
271
+ reason: `不可评估:全部 ${s.total} 次均为 skip(约定未采用或证据不可用)`,
282
272
  });
283
273
  continue;
284
274
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * `getEffectiveConstraints(projectRoot)` 是全仓唯一的生效集来源:
5
5
  * 内置 → preset → config.yml 禁用。
6
- * `harness check`、外部消费者(studio 等)全部消费它,
6
+ * `harness check`、外部消费者全部消费它,
7
7
  * 不再直接读 CONSTRAINTS 全集。
8
8
  */
9
9
 
package/src/core/index.ts CHANGED
@@ -37,7 +37,6 @@ export type {
37
37
  ConstraintResult,
38
38
  ConstraintContext,
39
39
  ConstraintCheckResult,
40
- IronLawContext,
41
40
  ConstraintCheck,
42
41
  CheckEnv,
43
42
  CheckOutcome,