@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.
- package/CHANGELOG.md +7 -0
- package/README.md +4 -2
- package/dist/cli/commands/constraints-disable.d.ts +48 -0
- package/dist/cli/commands/constraints-disable.d.ts.map +1 -0
- package/dist/cli/commands/constraints-disable.js +156 -0
- package/dist/cli/commands/constraints-disable.js.map +1 -0
- package/dist/cli/commands/constraints-pack-proposal.d.ts +1 -1
- package/dist/cli/commands/constraints-pack-proposal.js +1 -1
- package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
- package/dist/cli/commands/constraints-reactivate.js +4 -2
- package/dist/cli/commands/constraints-reactivate.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +14 -4
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +10 -6
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +1 -1
- package/dist/cli/commands/constraints.js +1 -1
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +16 -1
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/knowledge-view.d.ts +3 -3
- package/dist/cli/commands/knowledge-view.js +4 -4
- package/dist/cli/commands/knowledge-view.js.map +1 -1
- package/dist/cli/commands/release.d.ts +2 -2
- package/dist/cli/commands/release.js +2 -2
- package/dist/cli/commands/sync-docs/agents-syncer.js +2 -4
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/head-gate.d.ts +34 -0
- package/dist/cli/commands/sync-docs/head-gate.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/head-gate.js +86 -0
- package/dist/cli/commands/sync-docs/head-gate.js.map +1 -0
- package/dist/cli/commands/sync-docs/index.d.ts +7 -0
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +51 -1
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/completion-checkers/contract-presence.d.ts +1 -1
- package/dist/completion-checkers/contract-presence.js +1 -1
- package/dist/core/constraints/capabilities-parser.js +1 -1
- package/dist/core/constraints/check-cache.d.ts +1 -1
- package/dist/core/constraints/check-cache.js +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts +1 -1
- package/dist/core/constraints/checkers/governance-presence.js +1 -1
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +2 -2
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts +34 -0
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-completion-without-verification.js +157 -0
- package/dist/core/constraints/checkers/no-completion-without-verification.js.map +1 -0
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +3 -0
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +19 -2
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +1 -1
- package/dist/core/constraints/checkers/types.js +1 -1
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +0 -17
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +2 -2
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts +1 -1
- package/dist/core/constraints/definitions.js +1 -1
- package/dist/core/constraints/index.d.ts +1 -1
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/run-env.d.ts +3 -2
- package/dist/core/constraints/run-env.d.ts.map +1 -1
- package/dist/core/constraints/run-env.js +5 -4
- package/dist/core/constraints/run-env.js.map +1 -1
- package/dist/core/constraints/usage-report.d.ts +0 -5
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +3 -12
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/effective-constraints.d.ts +1 -1
- package/dist/core/effective-constraints.js +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/retired-constraints.d.ts +66 -0
- package/dist/core/retired-constraints.d.ts.map +1 -0
- package/dist/core/retired-constraints.js +52 -0
- package/dist/core/retired-constraints.js.map +1 -0
- package/dist/core/validators/checkpoint.d.ts +4 -2
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +4 -2
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -2
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +4 -3
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +3 -3
- package/dist/gates/checker-gate.js +3 -3
- package/dist/gates/index.d.ts +1 -1
- package/dist/gates/index.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-scoring.js +1 -1
- package/dist/knowledge/audit-scoring.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +2 -2
- package/dist/monitoring/trace-analyzer.js +2 -2
- package/dist/monitoring/traces.d.ts +1 -1
- package/dist/monitoring/traces.js +4 -4
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +1 -1
- package/dist/pretool-use-hook.d.ts.map +1 -1
- package/dist/pretool-use-hook.js +5 -5
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts +4 -4
- package/dist/release/integrity.js +4 -4
- package/dist/test-setup/mkdtemp-cleanup.js +1 -1
- package/dist/tools/definitions/core/notification/notify.yml +0 -1
- package/dist/tools/definitions/ext/browser/browser-close.yml +0 -1
- package/dist/tools/definitions/ext/browser/browser-start.yml +0 -1
- package/dist/tools/definitions/std/evolution/implement.yml +0 -1
- package/dist/tools/definitions/std/evolution/prioritize.yml +0 -1
- package/dist/tools/definitions/std/evolution/report-gap.yml +0 -1
- package/dist/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
- package/dist/tools/definitions/std/governance/audit-task.yml +0 -1
- package/dist/tools/definitions/std/governance/cast-vote.yml +0 -1
- package/dist/tools/definitions/std/governance/create-voting-session.yml +0 -1
- package/dist/tools/definitions/std/governance/define-stance.yml +0 -1
- package/dist/tools/definitions/std/governance/impeach.yml +0 -1
- package/dist/tools/definitions/std/governance/multi-stance-review.yml +0 -1
- package/dist/tools/definitions/std/governance/rollback.yml +0 -1
- package/dist/tools/definitions/std/governance/stance-review.yml +0 -1
- package/dist/tools/definitions/std/governance/track-effect.yml +0 -1
- package/dist/tools/definitions/std/governance/vote-tally.yml +0 -1
- package/dist/tools/definitions/std/planning/split-batch.yml +0 -1
- package/dist/tools/definitions/std/planning/split-tasks.yml +0 -1
- package/dist/types/constraint.d.ts +1 -7
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/passes-gate.d.ts +7 -0
- package/dist/types/passes-gate.d.ts.map +1 -1
- package/dist/types/passes-gate.js +8 -0
- package/dist/types/passes-gate.js.map +1 -1
- package/dist/utils/detect-source-roots.d.ts +1 -1
- package/dist/utils/detect-source-roots.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.js +2 -21
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/package.json +1 -2
- package/src/CONTEXT.md +2 -2
- package/src/__tests__/checker-extra.test.ts +32 -9
- package/src/__tests__/checker-primitives-sdk.test.ts +2 -2
- package/src/__tests__/checker.test.ts +16 -14
- package/src/__tests__/detect-source-roots.test.ts +5 -4
- package/src/__tests__/exec-checker-full-chain.test.ts +3 -3
- package/src/__tests__/iron-laws.test.ts +13 -20
- package/src/__tests__/no-studio-references.test.ts +54 -0
- package/src/__tests__/passes-gate-check.test.ts +1 -1
- package/src/__tests__/pretool-use-hook.test.ts +2 -2
- package/src/__tests__/public-exports.test.ts +1 -0
- package/src/__tests__/public-type-surface.test.ts +2 -2
- package/src/__tests__/retired-constraints.test.ts +99 -0
- package/src/__tests__/skip-semantics.test.ts +16 -33
- package/src/__tests__/usage-report-public-export.test.ts +3 -3
- package/src/cli/commands/CONTEXT.md +7 -6
- package/src/cli/commands/__tests__/check-read-count.test.ts +3 -0
- package/src/cli/commands/__tests__/check.test.ts +33 -6
- package/src/cli/commands/__tests__/constraints-disable.test.ts +229 -0
- package/src/cli/commands/__tests__/constraints-report-json-flag.test.ts +1 -1
- package/src/cli/commands/__tests__/constraints-report.test.ts +4 -4
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge.test.ts +3 -3
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +4 -1
- package/src/cli/commands/__tests__/project-path-convention.test.ts +1 -1
- package/src/cli/commands/__tests__/spec-baseline-index-cap.test.ts +1 -1
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +1 -24
- package/src/cli/commands/__tests__/sync-docs-gate.test.ts +154 -0
- package/src/cli/commands/__tests__/sync-docs-table-layout.test.ts +1 -1
- package/src/cli/commands/__tests__/sync-docs.test.ts +3 -3
- package/src/cli/commands/constraints-disable.ts +145 -0
- package/src/cli/commands/constraints-pack-proposal.ts +1 -1
- package/src/cli/commands/constraints-reactivate.ts +4 -2
- package/src/cli/commands/constraints-retire.ts +11 -8
- package/src/cli/commands/constraints.ts +1 -1
- package/src/cli/commands/definitions.ts +16 -1
- package/src/cli/commands/knowledge-view.ts +4 -4
- package/src/cli/commands/release.ts +2 -2
- package/src/cli/commands/sync-docs/agents-syncer.ts +2 -4
- package/src/cli/commands/sync-docs/head-gate.ts +87 -0
- package/src/cli/commands/sync-docs/index.ts +62 -1
- package/src/completion-checkers/contract-presence.ts +1 -1
- package/src/core/CONTEXT.md +4 -3
- package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +1 -1
- package/src/core/constraints/__tests__/check-cache.test.ts +1 -1
- package/src/core/constraints/__tests__/collect-constraints.test.ts +42 -18
- package/src/core/constraints/__tests__/run-env.test.ts +7 -7
- package/src/core/constraints/__tests__/trace-injection.test.ts +8 -2
- package/src/core/constraints/capabilities-parser.ts +1 -1
- package/src/core/constraints/check-cache.ts +1 -1
- package/src/core/constraints/checkers/__tests__/fixtures/public-repo-sanitization.mjs +1 -1
- package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +1 -1
- package/src/core/constraints/checkers/__tests__/input-contract.test.ts +3 -3
- package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +208 -0
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +17 -0
- package/src/core/constraints/checkers/capability-sync.ts +1 -1
- package/src/core/constraints/checkers/docs-freshness.ts +1 -1
- package/src/core/constraints/checkers/governance-presence.ts +1 -1
- package/src/core/constraints/checkers/index.ts +1 -3
- package/src/core/constraints/checkers/no-completion-without-verification.ts +126 -0
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +20 -2
- package/src/core/constraints/checkers/types.ts +1 -1
- package/src/core/constraints/context-builder.ts +0 -18
- package/src/core/constraints/definitions/guidelines.ts +1 -1
- package/src/core/constraints/definitions/iron-laws.ts +2 -2
- package/src/core/constraints/definitions.ts +1 -1
- package/src/core/constraints/doc-freshness/__tests__/runner.test.ts +3 -3
- package/src/core/constraints/index.ts +0 -1
- package/src/core/constraints/run-env.ts +6 -5
- package/src/core/constraints/usage-report.ts +2 -12
- package/src/core/effective-constraints.ts +1 -1
- package/src/core/index.ts +0 -1
- package/src/core/retired-constraints.ts +77 -0
- package/src/core/validators/checkpoint.ts +4 -2
- package/src/core/validators/passes-gate.ts +4 -3
- package/src/gates/CONTEXT.md +3 -2
- package/src/gates/__tests__/checker-gate.test.ts +3 -3
- package/src/gates/checker-gate.ts +3 -3
- package/src/gates/index.ts +1 -1
- package/src/hooks/CONTEXT.md +2 -2
- package/src/index.ts +9 -3
- package/src/knowledge/CONTEXT.md +2 -2
- package/src/knowledge/__tests__/audit.test.ts +1 -1
- package/src/knowledge/__tests__/flywheel-metrics.test.ts +1 -1
- package/src/knowledge/audit-scoring.ts +1 -1
- package/src/monitoring/CONTEXT.md +2 -2
- package/src/monitoring/__tests__/skipped-lines-report.test.ts +2 -2
- package/src/monitoring/__tests__/traces.test.ts +1 -1
- package/src/monitoring/trace-analyzer.ts +2 -2
- package/src/monitoring/traces.ts +4 -4
- package/src/pretool-use-hook.ts +5 -5
- package/src/release/CONTEXT.md +3 -3
- package/src/release/integrity.ts +4 -4
- package/src/test-setup/__tests__/mkdtemp-cleanup.test.ts +1 -1
- package/src/test-setup/mkdtemp-cleanup.ts +1 -1
- package/src/tools/CONTEXT.md +3 -3
- package/src/tools/__tests__/registry.test.ts +3 -3
- package/src/tools/definitions/core/notification/notify.yml +0 -1
- package/src/tools/definitions/ext/browser/browser-close.yml +0 -1
- package/src/tools/definitions/ext/browser/browser-start.yml +0 -1
- package/src/tools/definitions/std/evolution/implement.yml +0 -1
- package/src/tools/definitions/std/evolution/prioritize.yml +0 -1
- package/src/tools/definitions/std/evolution/report-gap.yml +0 -1
- package/src/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
- package/src/tools/definitions/std/governance/audit-task.yml +0 -1
- package/src/tools/definitions/std/governance/cast-vote.yml +0 -1
- package/src/tools/definitions/std/governance/create-voting-session.yml +0 -1
- package/src/tools/definitions/std/governance/define-stance.yml +0 -1
- package/src/tools/definitions/std/governance/impeach.yml +0 -1
- package/src/tools/definitions/std/governance/multi-stance-review.yml +0 -1
- package/src/tools/definitions/std/governance/rollback.yml +0 -1
- package/src/tools/definitions/std/governance/stance-review.yml +0 -1
- package/src/tools/definitions/std/governance/track-effect.yml +0 -1
- package/src/tools/definitions/std/governance/vote-tally.yml +0 -1
- package/src/tools/definitions/std/planning/split-batch.yml +0 -1
- package/src/tools/definitions/std/planning/split-tasks.yml +0 -1
- package/src/types/constraint.ts +1 -8
- package/src/types/passes-gate.ts +8 -0
- package/src/utils/detect-source-roots.ts +2 -20
- package/bin/harness-knowledge-track.sh +0 -47
- package/bin/harness-sensitive-check.sh +0 -67
- package/dist/core/constraints/checkers/iron-flags.d.ts +0 -12
- package/dist/core/constraints/checkers/iron-flags.d.ts.map +0 -1
- package/dist/core/constraints/checkers/iron-flags.js +0 -16
- package/dist/core/constraints/checkers/iron-flags.js.map +0 -1
- package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +0 -43
- package/src/core/constraints/checkers/iron-flags.ts +0 -17
- package/templates/nextjs-app/.github/workflows/ci.yml +0 -39
- package/templates/node-api/.github/workflows/ci.yml +0 -36
- package/templates/node-api/package.json +0 -23
- package/templates/node-api/src/index.ts +0 -2
- package/templates/node-api/tsconfig.json +0 -19
- package/templates/python-api/.github/workflows/ci.yml +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-source-roots.d.ts","sourceRoot":"","sources":["../../src/utils/detect-source-roots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"detect-source-roots.d.ts","sourceRoot":"","sources":["../../src/utils/detect-source-roots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAuD/D"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* 统一所有源码目录发现逻辑:
|
|
6
6
|
* 1. monorepo: packages/下各包的 src 或 lib 子目录
|
|
7
|
-
* 2. monorepo: apps/下各应用的 src
|
|
7
|
+
* 2. monorepo: apps/下各应用的 src 子目录
|
|
8
8
|
* 3. 单 repo: src/ lib/ 目录
|
|
9
9
|
*
|
|
10
10
|
* 返回相对 projectPath 的路径数组。全都不存在时返回空数组。
|
|
@@ -50,29 +50,10 @@ function detectSourceRoots(projectPath) {
|
|
|
50
50
|
if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name.startsWith('__'))
|
|
51
51
|
continue;
|
|
52
52
|
const appDir = (0, path_1.join)(appsDir, entry.name);
|
|
53
|
-
// apps/api/src/modules/* 的子目录
|
|
54
|
-
const modulesDir = (0, path_1.join)(appDir, 'src', 'modules');
|
|
55
|
-
if ((0, fs_1.existsSync)(modulesDir)) {
|
|
56
|
-
try {
|
|
57
|
-
const modEntries = (0, fs_1.readdirSync)(modulesDir, { withFileTypes: true });
|
|
58
|
-
for (const mod of modEntries) {
|
|
59
|
-
if (!mod.isDirectory() || mod.name.startsWith('.') || mod.name.startsWith('__'))
|
|
60
|
-
continue;
|
|
61
|
-
const modPath = (0, path_1.join)(modulesDir, mod.name);
|
|
62
|
-
if (hasSourceFiles(modPath)) {
|
|
63
|
-
roots.push(`apps/${entry.name}/src/modules/${mod.name}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch { /* skip */ }
|
|
68
|
-
}
|
|
69
53
|
// apps/xxx/src 本身
|
|
70
54
|
const appSrcDir = (0, path_1.join)(appDir, 'src');
|
|
71
55
|
if ((0, fs_1.existsSync)(appSrcDir) && hasSourceFiles(appSrcDir)) {
|
|
72
|
-
|
|
73
|
-
if (!roots.some(r => r.startsWith(`apps/${entry.name}/src/`))) {
|
|
74
|
-
roots.push(`apps/${entry.name}/src`);
|
|
75
|
-
}
|
|
56
|
+
roots.push(`apps/${entry.name}/src`);
|
|
76
57
|
}
|
|
77
58
|
}
|
|
78
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-source-roots.js","sourceRoot":"","sources":["../../src/utils/detect-source-roots.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAKH,
|
|
1
|
+
{"version":3,"file":"detect-source-roots.js","sourceRoot":"","sources":["../../src/utils/detect-source-roots.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAKH,8CAuDC;AA1DD,2BAA6C;AAC7C,+BAA4B;AAE5B,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,0BAA0B;IAC1B,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAClD,IAAI,IAAA,eAAU,EAAC,WAAW,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAA,gBAAW,EAAC,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;YAClE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;oBAAE,SAAS;gBAChG,MAAM,MAAM,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7C,aAAa;gBACb,IAAI,SAAS,GAAG,KAAK,CAAC;gBACtB,KAAK,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;oBACjC,MAAM,MAAM,GAAG,IAAA,WAAI,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;oBACjC,IAAI,IAAA,eAAU,EAAC,MAAM,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;wBACjD,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC;wBAC5C,SAAS,GAAG,IAAI,CAAC;oBACnB,CAAC;gBACH,CAAC;gBACD,+BAA+B;gBAC/B,IAAI,CAAC,SAAS,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;oBACzC,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;IAED,sBAAsB;IACtB,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC1C,IAAI,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAA,gBAAW,EAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;oBAAE,SAAS;gBAChG,MAAM,MAAM,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gBAEzC,kBAAkB;gBAClB,MAAM,SAAS,GAAG,IAAA,WAAI,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBACtC,IAAI,IAAA,eAAU,EAAC,SAAS,CAAC,IAAI,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;oBACvD,KAAK,CAAC,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,MAAM,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;IAED,wBAAwB;IACxB,KAAK,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QACtC,IAAI,IAAA,eAAU,EAAC,MAAM,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YACjD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,gBAAW,EAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;YACxB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,MAAM;gBAAE,SAAS;YACjF,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW;gBAAE,SAAS;YAE3D,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACjC,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;gBACnB,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;oBACpD,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;iBAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC/B,IAAI,cAAc,CAAC,QAAQ,CAAC;oBAAE,OAAO,IAAI,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dommaker/harness",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "通用工程约束框架 - 约束检查(severity 分级)、检查点验证、测试门控",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"harness",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"dist",
|
|
48
48
|
"bin",
|
|
49
49
|
"src",
|
|
50
|
-
"templates",
|
|
51
50
|
"README.md",
|
|
52
51
|
"CHANGELOG.md",
|
|
53
52
|
"LICENSE"
|
package/src/CONTEXT.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
- `core/index.ts`: 核心约束引擎
|
|
9
9
|
- `presets/index.ts`: 预设纯数据(strict/standard/relaxed;筛选逻辑统一在 core mergeConstraints)
|
|
10
10
|
- `context/index.ts`: 上下文管理
|
|
11
|
-
- `pretool-use-hook.ts`: provider PreToolUse 执法脚本(stdin JSON → CommandGate block 级 exit 2,fail-open),编译产物 dist/pretool-use-hook.js 随包出厂,provider hook
|
|
11
|
+
- `pretool-use-hook.ts`: provider PreToolUse 执法脚本(stdin JSON → CommandGate block 级 exit 2,fail-open),编译产物 dist/pretool-use-hook.js 随包出厂,provider hook 配置直接指向包内路径;P1-7(ADR-0031,wayfinder 票08)起命中(block/warn/audit)写审计 trace 到 traces.log(汇总 constraintId `command-gate`,evidence 只记规则 id + 命令首 token,留痕失败 fail-open);P1-5(同票)起非 Bash 工具事件(Edit/Write/apply_patch/MCP)只留痕不拦截(constraintId `tool-event:<tool>`,拦截归 codex 沙箱)
|
|
12
12
|
|
|
13
13
|
## 目录
|
|
14
14
|
| 目录 | 职责 |
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
| GateDecision | 三态决策 `deny \| abstain \| ask`;deny 单调(下游不可改回 allow)、ask 枚举预留 fail-closed = deny |
|
|
40
40
|
| GateResult | 报告结构(gate/passed/message/details/timestamp/duration),保留为报告层,不作决策 |
|
|
41
41
|
| 守卫 guard | 仅 dsh 借鉴语境(工具管线单调守卫),不进入 harness 命名 |
|
|
42
|
-
| 回滚 | 分工:版本化回退(单段——yml 数据文件 git 版本化,删段恢复)+ 提案回滚(多段 inverse
|
|
42
|
+
| 回滚 | 分工:版本化回退(单段——yml 数据文件 git 版本化,删段恢复)+ 提案回滚(多段 inverse) |
|
|
43
43
|
| 文件驱动 CLI | yml 状态真值 + 一次性进程、无常驻生命周期;故不引 dispose 链(止步档 1) |
|
|
44
44
|
| 对照(reconcile) | CAPABILITIES.md 声明与源码实况的双向一致性判定(代码→文档查漏登,文档→代码查幽灵);唯一实现 `core/constraints/capabilities-reconcile.ts`,capability_sync / docs_freshness / sync-docs 共消费(ADR-0009)。一次 check run 内只算一次,经 `RunEnv.capabilities()` 供给两 checker(ADR-0023 决策 4) |
|
|
45
45
|
| 判定证据(evidence) | checker 随判定一并返回的路径级依据(`CheckDetail{pass, evidence}`,harness#119/ADR-0016);文案由 checker 措辞、消费端只打印,出口 = `ConstraintResult` / CLI 输出 / trace / error 级异常文案。不是第四种统计态:**违规** = 与本次变更有因果(进 pass/fail 分母),**提示** = `pass:true` + evidence(仓库级漂移等无因果缺口,只露出不拦) |
|
|
@@ -42,10 +42,29 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
42
42
|
afterAll(() => {
|
|
43
43
|
try {
|
|
44
44
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
45
|
+
for (const dir of evidenceFixtures) fs.rmSync(dir, { recursive: true, force: true });
|
|
45
46
|
} catch {
|
|
46
47
|
// ignore
|
|
47
48
|
}
|
|
48
49
|
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 证据夹具(harness#183:验证证据 = .harness/evidence 落盘,不再是 context flag)
|
|
53
|
+
* projectWithEvidence = 有证据(新鲜度无所依即有证据即过);projectWithoutEvidence = 无证据
|
|
54
|
+
*/
|
|
55
|
+
const evidenceFixtures: string[] = [];
|
|
56
|
+
function projectWithEvidence(): string {
|
|
57
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-evidence-'));
|
|
58
|
+
fs.mkdirSync(path.join(dir, '.harness', 'evidence'), { recursive: true });
|
|
59
|
+
fs.writeFileSync(path.join(dir, '.harness', 'evidence', 'test.log'), 'ok');
|
|
60
|
+
evidenceFixtures.push(dir);
|
|
61
|
+
return dir;
|
|
62
|
+
}
|
|
63
|
+
function projectWithoutEvidence(): string {
|
|
64
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-no-evidence-'));
|
|
65
|
+
evidenceFixtures.push(dir);
|
|
66
|
+
return dir;
|
|
67
|
+
}
|
|
49
68
|
describe('findApplicableConstraints', () => {
|
|
50
69
|
it('应该过滤出匹配 trigger 的约束', () => {
|
|
51
70
|
const context: ConstraintContext = {
|
|
@@ -78,8 +97,9 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
78
97
|
it('通过检查不应该抛出异常', async () => {
|
|
79
98
|
const context: ConstraintContext = {
|
|
80
99
|
operation: 'code_implementation',
|
|
100
|
+
projectPath: projectWithEvidence(),
|
|
101
|
+
changedFiles: [],
|
|
81
102
|
hasTest: true,
|
|
82
|
-
hasVerificationEvidence: true,
|
|
83
103
|
hasRequirement: true,
|
|
84
104
|
taskDescription: 'Test task — single focused change',
|
|
85
105
|
hasSingleTask: true,
|
|
@@ -92,8 +112,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
92
112
|
it('违规应该抛出 ConstraintViolationError', async () => {
|
|
93
113
|
const context: ConstraintContext = {
|
|
94
114
|
operation: 'code_implementation',
|
|
115
|
+
projectPath: projectWithoutEvidence(),
|
|
95
116
|
hasTest: false,
|
|
96
|
-
hasVerificationEvidence: false,
|
|
97
117
|
};
|
|
98
118
|
|
|
99
119
|
await expect(checkBeforeExecution(context)).rejects.toThrow();
|
|
@@ -102,8 +122,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
102
122
|
it('customConfig 应替换内置集(空配置不检查内置 error 级约束)', async () => {
|
|
103
123
|
const context: ConstraintContext = {
|
|
104
124
|
operation: 'code_implementation',
|
|
125
|
+
projectPath: projectWithoutEvidence(),
|
|
105
126
|
hasTest: false,
|
|
106
|
-
hasVerificationEvidence: false,
|
|
107
127
|
};
|
|
108
128
|
|
|
109
129
|
// 内置 error 级约束下违规抛错
|
|
@@ -147,7 +167,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
147
167
|
it('checkConstraint 带 customConfig 应命中配置内约束', async () => {
|
|
148
168
|
const context: ConstraintContext = {
|
|
149
169
|
operation: 'code_implementation',
|
|
150
|
-
|
|
170
|
+
projectPath: projectWithEvidence(),
|
|
171
|
+
changedFiles: [],
|
|
151
172
|
};
|
|
152
173
|
const customConfig = {
|
|
153
174
|
constraints: {
|
|
@@ -180,7 +201,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
180
201
|
it('check 结果带约束定义的 severity', async () => {
|
|
181
202
|
const context: ConstraintContext = {
|
|
182
203
|
operation: 'code_implementation',
|
|
183
|
-
|
|
204
|
+
projectPath: projectWithEvidence(),
|
|
205
|
+
changedFiles: [],
|
|
184
206
|
};
|
|
185
207
|
|
|
186
208
|
const result = await checker.check(
|
|
@@ -218,7 +240,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
218
240
|
|
|
219
241
|
const context: ConstraintContext = {
|
|
220
242
|
operation: 'code_implementation',
|
|
221
|
-
|
|
243
|
+
projectPath: projectWithEvidence(),
|
|
244
|
+
changedFiles: [],
|
|
222
245
|
};
|
|
223
246
|
|
|
224
247
|
const result = await checkConstraint('no_completion_without_verification', context);
|
|
@@ -231,8 +254,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
|
|
|
231
254
|
it('error 级违规应该抛出 ConstraintViolationError', async () => {
|
|
232
255
|
const context: ConstraintContext = {
|
|
233
256
|
operation: 'code_implementation',
|
|
257
|
+
projectPath: projectWithoutEvidence(),
|
|
234
258
|
hasTest: false,
|
|
235
|
-
hasVerificationEvidence: false,
|
|
236
259
|
};
|
|
237
260
|
|
|
238
261
|
await expect(checkConstraints(context)).rejects.toThrow();
|
|
@@ -319,11 +342,11 @@ describe('buildCheckEnv - 证据接线契约', () => {
|
|
|
319
342
|
|
|
320
343
|
it("'none' env 下 evidence flag 未接线的 checker 返回带原因的 skip(harness#182)", async () => {
|
|
321
344
|
// 「没接证据 → skip」由注释固化为可执行契约;原因进结果面
|
|
322
|
-
const check = contextEvidenceFlag('test-flag', '
|
|
345
|
+
const check = contextEvidenceFlag('test-flag', 'hasFailingTest');
|
|
323
346
|
const env = buildCheckEnv(context, 'none');
|
|
324
347
|
expect(await check.evaluate(env)).toEqual({
|
|
325
348
|
skip: true,
|
|
326
|
-
reason: '证据标志
|
|
349
|
+
reason: '证据标志 hasFailingTest 未接线',
|
|
327
350
|
});
|
|
328
351
|
});
|
|
329
352
|
|
|
@@ -62,9 +62,9 @@ describe('检查器原语 SDK(harness#181)', () => {
|
|
|
62
62
|
const flagCheck = contextFlag('app_flag', (ctx) => ctx.operation === 'commit');
|
|
63
63
|
expect(normalizeCheckOutcome(await flagCheck.evaluate(env)).satisfied).toBe(true);
|
|
64
64
|
|
|
65
|
-
const evidenceCheck = contextEvidenceFlag('app_evidence', '
|
|
65
|
+
const evidenceCheck = contextEvidenceFlag('app_evidence', 'hasFailingTest');
|
|
66
66
|
const skipped = normalizeCheckOutcome(await evidenceCheck.evaluate(env));
|
|
67
67
|
expect(skipped.skipped).toBe(true);
|
|
68
|
-
expect(skipped.skipReason).toContain('
|
|
68
|
+
expect(skipped.skipReason).toContain('hasFailingTest');
|
|
69
69
|
});
|
|
70
70
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { ConstraintChecker, checkConstraint } from '../core/constraints/checker';
|
|
9
9
|
import type { ConstraintContext } from '../types/constraint';
|
|
10
|
-
import { rmSync, mkdtempSync } from 'fs';
|
|
10
|
+
import { rmSync, mkdtempSync, mkdirSync, writeFileSync } from 'fs';
|
|
11
11
|
import { join } from 'path';
|
|
12
12
|
import { tmpdir } from 'os';
|
|
13
13
|
|
|
@@ -31,14 +31,22 @@ describe('ConstraintChecker', () => {
|
|
|
31
31
|
|
|
32
32
|
describe('error 级约束', () => {
|
|
33
33
|
it('should check no_completion_without_verification', async () => {
|
|
34
|
+
// harness#183:验证证据 = .harness/evidence 落盘(独立链路),不再是 context flag
|
|
35
|
+
const withEvidence = join(tempDir, 'with-evidence');
|
|
36
|
+
mkdirSync(join(withEvidence, '.harness', 'evidence'), { recursive: true });
|
|
37
|
+
writeFileSync(join(withEvidence, '.harness', 'evidence', 'test.log'), 'ok');
|
|
38
|
+
const withoutEvidence = join(tempDir, 'without-evidence');
|
|
39
|
+
mkdirSync(withoutEvidence, { recursive: true });
|
|
40
|
+
|
|
34
41
|
const contextWithEvidence: ConstraintContext = {
|
|
35
42
|
operation: 'code_implementation',
|
|
36
|
-
|
|
43
|
+
projectPath: withEvidence,
|
|
44
|
+
changedFiles: [],
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
const contextWithoutEvidence: ConstraintContext = {
|
|
40
48
|
operation: 'code_implementation',
|
|
41
|
-
|
|
49
|
+
projectPath: withoutEvidence,
|
|
42
50
|
};
|
|
43
51
|
|
|
44
52
|
const resultWithEvidence = await checker.check(
|
|
@@ -86,22 +94,16 @@ describe('ConstraintChecker', () => {
|
|
|
86
94
|
|
|
87
95
|
describe('Helper functions', () => {
|
|
88
96
|
it('should check single constraint via checkConstraint', async () => {
|
|
97
|
+
const withEvidence = join(tempDir, 'helper-with-evidence');
|
|
98
|
+
mkdirSync(join(withEvidence, '.harness', 'evidence'), { recursive: true });
|
|
99
|
+
writeFileSync(join(withEvidence, '.harness', 'evidence', 'test.log'), 'ok');
|
|
89
100
|
const context: ConstraintContext = {
|
|
90
101
|
operation: 'code_implementation',
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const result = await checkConstraint('no_completion_without_verification', context);
|
|
95
|
-
expect(result.satisfied).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('prompt 约束经 checkConstraint 短路通过', async () => {
|
|
99
|
-
const context: ConstraintContext = {
|
|
100
|
-
operation: 'code_implementation',
|
|
102
|
+
projectPath: withEvidence,
|
|
103
|
+
changedFiles: [],
|
|
101
104
|
};
|
|
102
105
|
|
|
103
106
|
const result = await checkConstraint('no_completion_without_verification', context);
|
|
104
|
-
expect(result.id).toBe('no_completion_without_verification');
|
|
105
107
|
expect(result.satisfied).toBe(true);
|
|
106
108
|
});
|
|
107
109
|
|
|
@@ -55,12 +55,13 @@ describe('detectSourceRoots', () => {
|
|
|
55
55
|
expect(roots).toContain('packages/mylib/lib');
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it('monorepo: apps/*/src
|
|
58
|
+
it('monorepo: apps/*/src(不再下探 modules 层)', () => {
|
|
59
59
|
touchFile(join(tempDir, 'apps', 'api', 'src', 'modules', 'auth'), 'index.ts');
|
|
60
60
|
touchFile(join(tempDir, 'apps', 'api', 'src', 'modules', 'users'), 'handler.ts');
|
|
61
61
|
const roots = detectSourceRoots(tempDir);
|
|
62
|
-
expect(roots).toContain('apps/api/src
|
|
63
|
-
expect(roots).toContain('apps/api/src/modules/
|
|
62
|
+
expect(roots).toContain('apps/api/src');
|
|
63
|
+
expect(roots).not.toContain('apps/api/src/modules/auth');
|
|
64
|
+
expect(roots).not.toContain('apps/api/src/modules/users');
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
it('排除 .d.ts 文件(只有类型声明不视为源码目录)', () => {
|
|
@@ -93,6 +94,6 @@ describe('detectSourceRoots', () => {
|
|
|
93
94
|
const roots = detectSourceRoots(tempDir);
|
|
94
95
|
expect(roots).toContain('src');
|
|
95
96
|
expect(roots).toContain('packages/core/src');
|
|
96
|
-
expect(roots).toContain('apps/api/src
|
|
97
|
+
expect(roots).toContain('apps/api/src');
|
|
97
98
|
});
|
|
98
99
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* exec 执行协议全链验收(harness#181 第一半)
|
|
3
3
|
*
|
|
4
|
-
* 示例业务检查器 fixtures/public-repo-sanitization.mjs(场景原型 =
|
|
4
|
+
* 示例业务检查器 fixtures/public-repo-sanitization.mjs(场景原型 = 下游消费方安全底线
|
|
5
5
|
* public_repo_sanitization,ADR-0032 ①;占位符豁免谓词是模板填参表达不了的业务判定)
|
|
6
6
|
* 走完整链:编写(fixtures 脚本)→ 名册登记(.harness/constraints.yml 写
|
|
7
7
|
* checker: exec + params.command)→ 执行(loadAppConstraints → ConstraintChecker 分发)
|
|
@@ -22,12 +22,12 @@ const SCRIPT = path.join(
|
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
const DIRTY_DOC = [
|
|
25
|
-
'部署参考 /Users/alice/projects/
|
|
25
|
+
'部署参考 /Users/alice/projects/demo 的配置。',
|
|
26
26
|
'占位符写法 /Users/<you>/projects 不算残留。',
|
|
27
27
|
'另一个现场 /home/bob/work/app 也要拦。',
|
|
28
28
|
].join('\n');
|
|
29
29
|
|
|
30
|
-
const CLEAN_DOC = '部署参考 /Users/<you>/projects/
|
|
30
|
+
const CLEAN_DOC = '部署参考 /Users/<you>/projects/demo 的配置。\n';
|
|
31
31
|
|
|
32
32
|
function constraintsYml(severity: 'error' | 'warning'): string {
|
|
33
33
|
return [
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
import { constraintChecker } from '../core/constraints/checker';
|
|
13
13
|
import { getConstraintCheck, registeredCheckCount } from '../core/constraints/checkers';
|
|
14
14
|
import type { ConstraintContext } from '../types/constraint';
|
|
15
|
+
import * as fs from 'fs';
|
|
16
|
+
import * as path from 'path';
|
|
17
|
+
import * as os from 'os';
|
|
15
18
|
|
|
16
19
|
describe('Constraint System', () => {
|
|
17
20
|
describe('清单构成(ADR-0029:16 → 7,全部 kind=check)', () => {
|
|
@@ -188,36 +191,26 @@ describe('Constraint Checker', () => {
|
|
|
188
191
|
});
|
|
189
192
|
|
|
190
193
|
it('should check all constraints', async () => {
|
|
194
|
+
// harness#183:验证证据 = .harness/evidence 落盘(独立链路),不再是 context flag
|
|
195
|
+
const projectPath = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-iron-laws-'));
|
|
196
|
+
fs.mkdirSync(path.join(projectPath, '.harness', 'evidence'), { recursive: true });
|
|
197
|
+
fs.writeFileSync(path.join(projectPath, '.harness', 'evidence', 'test.log'), 'ok');
|
|
191
198
|
const context: ConstraintContext = {
|
|
192
199
|
operation: 'code_implementation',
|
|
200
|
+
projectPath,
|
|
201
|
+
changedFiles: [],
|
|
193
202
|
hasRequirement: true,
|
|
194
|
-
hasVerificationEvidence: true,
|
|
195
203
|
hasSingleTask: true,
|
|
196
204
|
};
|
|
197
205
|
|
|
198
206
|
const result = await constraintChecker.checkConstraints(context);
|
|
199
207
|
expect(result.errors.length + result.warnings.length).toBeGreaterThan(0);
|
|
208
|
+
fs.rmSync(projectPath, { recursive: true, force: true });
|
|
200
209
|
});
|
|
201
210
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const result = await constraintChecker.check(CONSTRAINTS['no_completion_without_verification'], context);
|
|
208
|
-
expect(result.skipped).toBe(true);
|
|
209
|
-
expect(result.satisfied).toBe(true);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('should pass no_completion_without_verification when hasVerificationEvidence is true', async () => {
|
|
213
|
-
const context: ConstraintContext = {
|
|
214
|
-
operation: 'code_implementation',
|
|
215
|
-
hasVerificationEvidence: true,
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const result = await constraintChecker.check(CONSTRAINTS['no_completion_without_verification'], context);
|
|
219
|
-
expect(result.satisfied).toBe(true);
|
|
220
|
-
});
|
|
211
|
+
// harness#183:flag 三态(未接线 skip / false fail / true pass)随证据源重构退役,
|
|
212
|
+
// 判定收进 checker 体内(读 .harness/evidence),语义钉子见
|
|
213
|
+
// checkers/__tests__/no-completion-without-verification.test.ts
|
|
221
214
|
});
|
|
222
215
|
|
|
223
216
|
describe('Constraint Severity', () => {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 防回归:src/ 与 bin/ 不得再出现特定下游仓名引用
|
|
3
|
+
*
|
|
4
|
+
* harness 是通用约束框架,不得残留任何特定下游消费方的名字(历史清理票落地)。
|
|
5
|
+
* 递归扫描 src/ 与 bin/ 全部文本文件,逐行断言无目标词命中,
|
|
6
|
+
* 命中即 fail 并列出 文件:行。二进制文件(含 NUL 字节)跳过。
|
|
7
|
+
*
|
|
8
|
+
* 目标词经拼接构造、本文件名以外的内容不出现其字面量——
|
|
9
|
+
* 保证仓级全文检索(grep -ri)对本测试自身也零命中。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import * as fs from 'fs';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
|
|
15
|
+
const REPO_ROOT = path.join(__dirname, '..', '..');
|
|
16
|
+
const SCAN_DIRS = ['src', 'bin'];
|
|
17
|
+
const WORD = ['stu', 'dio'].join('');
|
|
18
|
+
const TARGET = new RegExp(`\\b${WORD}\\b`, 'i');
|
|
19
|
+
|
|
20
|
+
function listFiles(dir: string): string[] {
|
|
21
|
+
const out: string[] = [];
|
|
22
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
23
|
+
const full = path.join(dir, entry.name);
|
|
24
|
+
if (entry.isDirectory()) {
|
|
25
|
+
out.push(...listFiles(full));
|
|
26
|
+
} else if (entry.isFile()) {
|
|
27
|
+
out.push(full);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isText(buf: Buffer): boolean {
|
|
34
|
+
return !buf.includes(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe(`no ${WORD} references`, () => {
|
|
38
|
+
it('src/ 与 bin/ 全部文本文件零命中', () => {
|
|
39
|
+
const hits: string[] = [];
|
|
40
|
+
for (const dir of SCAN_DIRS) {
|
|
41
|
+
for (const file of listFiles(path.join(REPO_ROOT, dir))) {
|
|
42
|
+
const buf = fs.readFileSync(file);
|
|
43
|
+
if (!isText(buf)) continue;
|
|
44
|
+
const lines = buf.toString('utf-8').split('\n');
|
|
45
|
+
lines.forEach((line, i) => {
|
|
46
|
+
if (TARGET.test(line)) {
|
|
47
|
+
hits.push(`${path.relative(REPO_ROOT, file)}:${i + 1}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
expect(hits).toEqual([]);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -97,7 +97,7 @@ describe('PassesGate.check()', () => {
|
|
|
97
97
|
/**
|
|
98
98
|
* AC-007(ADR-0022 改写):零消费者方法已从公共面删除
|
|
99
99
|
*
|
|
100
|
-
* 原用例断言「保留 setPasses()
|
|
100
|
+
* 原用例断言「保留 setPasses() 向后兼容」——兼容对象经双仓
|
|
101
101
|
* 核实不存在,ADR-0022 明确推翻该 AC。`@ts-expect-error` 在编译期钉住删除,
|
|
102
102
|
* 运行期断言同时钉住形状(方法不存在于原型)。
|
|
103
103
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pretool-use-hook
|
|
2
|
+
* pretool-use-hook 测试
|
|
3
3
|
*
|
|
4
|
-
* 验收口径:block/warn/audit
|
|
4
|
+
* 验收口径:block/warn/audit 行为与下游消费方生成版脚本一致——
|
|
5
5
|
* block 级 exit 2 阻断,warn/audit 放行,坏输入 fail-open。
|
|
6
6
|
*
|
|
7
7
|
* P1-7(ADR-0031,wayfinder 票08):命中留痕走 traces 通道——整个套件 chdir 到
|
|
@@ -205,7 +205,6 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
205
205
|
'IngestOptions',
|
|
206
206
|
'InjectionConfig',
|
|
207
207
|
'InjectionResult',
|
|
208
|
-
'IronLawContext',
|
|
209
208
|
'KnowledgeEntry',
|
|
210
209
|
'KnowledgeOrigin',
|
|
211
210
|
'KnowledgeReference',
|
|
@@ -230,6 +229,8 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
230
229
|
'ReferenceRecord',
|
|
231
230
|
'RetireCandidate',
|
|
232
231
|
'RetireCandidateKind',
|
|
232
|
+
'RetiredConstraintEntry',
|
|
233
|
+
'RetiredConstraintMeta',
|
|
233
234
|
'ReviewGateConfig',
|
|
234
235
|
'SchemaLoader',
|
|
235
236
|
'SecurityGateConfig',
|
|
@@ -294,7 +295,6 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
294
295
|
'ContextFilesResolution',
|
|
295
296
|
'EffectiveConfigLint',
|
|
296
297
|
'EvidenceProviders',
|
|
297
|
-
'IronLawContext',
|
|
298
298
|
'NormalizedOutcome',
|
|
299
299
|
'PassesGateConfig',
|
|
300
300
|
'RunEnv',
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 已退役约束清单(listRetiredConstraints,harness#188)测试
|
|
3
|
+
*
|
|
4
|
+
* 口径:只认 retired 墓碑(enabled:false + retired 段,ADR-0032 决策 6.6),
|
|
5
|
+
* 裸 enabled:false 是"禁用"不是"退休",不入选。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import { listRetiredConstraints } from '../core/retired-constraints';
|
|
11
|
+
import { createProjectFixture } from '../test-setup/project-fixture';
|
|
12
|
+
|
|
13
|
+
describe('listRetiredConstraints', () => {
|
|
14
|
+
let tempDir: string;
|
|
15
|
+
let counter = 0;
|
|
16
|
+
|
|
17
|
+
const setupProject = (configYaml?: string): string =>
|
|
18
|
+
createProjectFixture({
|
|
19
|
+
parentDir: tempDir,
|
|
20
|
+
name: `p${counter++}`,
|
|
21
|
+
config: configYaml,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
tempDir = createProjectFixture({ name: 'temp-test-retired', parentDir: process.cwd() });
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('无配置项目:空清单', () => {
|
|
33
|
+
const dir = setupProject();
|
|
34
|
+
expect(listRetiredConstraints(dir)).toEqual([]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('retired 墓碑条目入选,透出 id/enabled/retired 元数据', () => {
|
|
38
|
+
const dir = setupProject(`
|
|
39
|
+
constraints:
|
|
40
|
+
capability_sync:
|
|
41
|
+
enabled: false
|
|
42
|
+
retired:
|
|
43
|
+
at: '2026-09-01T00:00:00.000Z'
|
|
44
|
+
reason: 零拦截期满转退役
|
|
45
|
+
stats: { total: 10, fail: 0, failRate: 0 }
|
|
46
|
+
`);
|
|
47
|
+
const entries = listRetiredConstraints(dir);
|
|
48
|
+
|
|
49
|
+
expect(entries).toEqual([
|
|
50
|
+
{
|
|
51
|
+
id: 'capability_sync',
|
|
52
|
+
enabled: false,
|
|
53
|
+
retired: {
|
|
54
|
+
at: '2026-09-01T00:00:00.000Z',
|
|
55
|
+
reason: '零拦截期满转退役',
|
|
56
|
+
stats: { total: 10, fail: 0, failRate: 0 },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('裸 enabled:false(禁用非退休)与启用条目都不入选', () => {
|
|
63
|
+
const dir = setupProject(`
|
|
64
|
+
constraints:
|
|
65
|
+
docs_freshness:
|
|
66
|
+
enabled: false
|
|
67
|
+
no_hardcoded_credentials:
|
|
68
|
+
enabled: true
|
|
69
|
+
capability_sync:
|
|
70
|
+
enabled: false
|
|
71
|
+
retired:
|
|
72
|
+
at: '2026-09-01T00:00:00.000Z'
|
|
73
|
+
reason: ''
|
|
74
|
+
`);
|
|
75
|
+
const entries = listRetiredConstraints(dir);
|
|
76
|
+
|
|
77
|
+
expect(entries.map(e => e.id)).toEqual(['capability_sync']);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('多条墓碑按 config.yml 条目顺序返回', () => {
|
|
81
|
+
const dir = setupProject(`
|
|
82
|
+
constraints:
|
|
83
|
+
docs_freshness:
|
|
84
|
+
enabled: false
|
|
85
|
+
retired: { at: '2026-09-02T00:00:00.000Z', reason: r2 }
|
|
86
|
+
capability_sync:
|
|
87
|
+
enabled: false
|
|
88
|
+
retired: { at: '2026-09-01T00:00:00.000Z', reason: r1 }
|
|
89
|
+
`);
|
|
90
|
+
const entries = listRetiredConstraints(dir);
|
|
91
|
+
|
|
92
|
+
expect(entries.map(e => e.id)).toEqual(['docs_freshness', 'capability_sync']);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('从包根导出(ADR-0003 公共面)', async () => {
|
|
96
|
+
const harness = await import('../index');
|
|
97
|
+
expect(typeof (harness as Record<string, unknown>).listRetiredConstraints).toBe('function');
|
|
98
|
+
});
|
|
99
|
+
});
|