@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
|
@@ -97,7 +97,7 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
97
97
|
it('四类候选诊断:零触发/不可评估(flag)/不可评估(探测)/高噪/零拦截', () => {
|
|
98
98
|
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
99
99
|
writeProjectTraces(root, [
|
|
100
|
-
//
|
|
100
|
+
// 不可评估(证据不可用):全部 skip(harness#183 起不再是 flag 未接线)
|
|
101
101
|
...tracesOf('no_completion_without_verification', 'skip', 3),
|
|
102
102
|
// 不可评估(存在性探测未命中):全部 skip
|
|
103
103
|
...tracesOf('capability_sync', 'skip', 5),
|
|
@@ -113,12 +113,12 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
113
113
|
// 零触发(未出现在 trace 的 check 约束)
|
|
114
114
|
expect(byId.get('docs_freshness')?.kind).toBe('zero_trigger');
|
|
115
115
|
|
|
116
|
-
// 不可评估 · flag
|
|
116
|
+
// 不可评估 · 全部 skip(证据不可用/约定未采用不再分列,harness#183 起无 flag 型约束)
|
|
117
117
|
const flagC = byId.get('no_completion_without_verification');
|
|
118
118
|
expect(flagC?.kind).toBe('unevaluable');
|
|
119
|
-
expect(flagC?.reason).toContain('
|
|
119
|
+
expect(flagC?.reason).toContain('约定未采用或证据不可用');
|
|
120
120
|
|
|
121
|
-
// 不可评估 ·
|
|
121
|
+
// 不可评估 · 同口径
|
|
122
122
|
const probeC = byId.get('capability_sync');
|
|
123
123
|
expect(probeC?.kind).toBe('unevaluable');
|
|
124
124
|
expect(probeC?.reason).toContain('约定未采用');
|
|
@@ -52,7 +52,7 @@ const FIXTURE: KnowledgeEntry[] = [
|
|
|
52
52
|
makeEntry('K-001', 'verified', ['agent-a:2026-09-01', 'search:2026-09-01']),
|
|
53
53
|
makeEntry('K-002', 'verified', ['prompt-inject:2026-08-30', 'test-agent:2026-08-31', 'monitor:2026-09-01']),
|
|
54
54
|
makeEntry('K-003', 'draft', []),
|
|
55
|
-
makeEntry('K-004', 'proven', ['decision-1:2026-07-01', '
|
|
55
|
+
makeEntry('K-004', 'proven', ['decision-1:2026-07-01', 'web-app:2026-07-02']),
|
|
56
56
|
];
|
|
57
57
|
|
|
58
58
|
function setupKnowledgeBase(): string {
|
|
@@ -86,7 +86,7 @@ beforeEach(() => {
|
|
|
86
86
|
|
|
87
87
|
// 解析函数本体自 #133 起住 knowledge-view.ts(resolveKnowledgeBaseDir),行为面不变:
|
|
88
88
|
// 这里经 knowledgeStats 观测 `-p` / KNOWLEDGE_BASE_DIR / 缺省目录三条路径的解析结果
|
|
89
|
-
// (ADR-0034
|
|
89
|
+
// (ADR-0034:旧消费方数据区兼容沿用已退役,不再属观测面)
|
|
90
90
|
describe('getKnowledgeDir', () => {
|
|
91
91
|
const fs = require('fs');
|
|
92
92
|
const os = require('os');
|
|
@@ -127,8 +127,8 @@ describe('getKnowledgeDir', () => {
|
|
|
127
127
|
}));
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
it('should NOT fall back to legacy
|
|
131
|
-
const legacyDir = path.join(tmpHome, '.
|
|
130
|
+
it('should NOT fall back to legacy consumer data dir even when it has data (ADR-0034 目录收编:兼容沿用已退役)', async () => {
|
|
131
|
+
const legacyDir = path.join(tmpHome, '.legacy', 'knowledge');
|
|
132
132
|
fs.mkdirSync(legacyDir, { recursive: true });
|
|
133
133
|
fs.writeFileSync(path.join(legacyDir, 'guideline-x.md'), 'data');
|
|
134
134
|
await knowledgeStats({ json: true }, io);
|
|
@@ -169,7 +169,7 @@ describe('-p 锚定:执行与 IO 必须落在 projectPath(cwd ≠ projectPat
|
|
|
169
169
|
execFileSync('git', args, { cwd: dir, stdio: 'pipe' });
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
/** check 能真跑完的项目:已提交基线 + staged 改动 +
|
|
172
|
+
/** check 能真跑完的项目:已提交基线 + staged 改动 + 真验证证据(harness#183:.harness/evidence 落盘) */
|
|
173
173
|
function checkProject(name: string): string {
|
|
174
174
|
const dir = createProjectFixture({
|
|
175
175
|
name,
|
|
@@ -183,6 +183,9 @@ describe('-p 锚定:执行与 IO 必须落在 projectPath(cwd ≠ projectPat
|
|
|
183
183
|
git(dir, 'commit', '-q', '-m', 'baseline');
|
|
184
184
|
fs.writeFileSync(path.join(dir, 'src/existing.ts'), 'export const a = 2;\n', 'utf-8');
|
|
185
185
|
git(dir, 'add', '--', 'src/existing.ts');
|
|
186
|
+
// 验证证据须在变更之后落盘(mtime 新鲜度口径)
|
|
187
|
+
fs.mkdirSync(path.join(dir, '.harness', 'evidence'), { recursive: true });
|
|
188
|
+
fs.writeFileSync(path.join(dir, '.harness', 'evidence', 'test-fixture.log'), '1 passed\n', 'utf-8');
|
|
186
189
|
return dir;
|
|
187
190
|
}
|
|
188
191
|
|
|
@@ -211,7 +211,7 @@ const RELATIVE_PATH_DEFAULT_EXEMPTIONS: Record<string, string> = {
|
|
|
211
211
|
'src/monitoring/trace-analyzer.ts':
|
|
212
212
|
'summaryFile: ".harness/logs/traces-summary.json" 同型病灶(#139 实测的第二处命中)。不在本票修:' +
|
|
213
213
|
'harness 侧无生产写点(`status` 自 ADR-0020 起直调纯函数,不构造 analyzer),修它等于给无人消费的面' +
|
|
214
|
-
'新增根参数。与 trace 的 failure/summary
|
|
214
|
+
'新增根参数。与 trace 的 failure/summary 三件套同型病灶一并由下游消费方迁移票带走(#139 Out of scope)。',
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
describe('projectPath 传递约定(harness#95)', () => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* #146 把 `sourceContents()` 改成全仓内容常驻一个 Map:排除面只有
|
|
5
5
|
* node_modules / dist / 隐藏目录与 .ts/.js 后缀,**无单文件字节、总量、条目上限**——
|
|
6
|
-
* 峰值内存由 O(单文件) 变 O(全仓源码)
|
|
6
|
+
* 峰值内存由 O(单文件) 变 O(全仓源码),大型 monorepo 跑本命令会承担这个峰值,
|
|
7
7
|
* 而本仓 146 个源文件的规模测不出来。
|
|
8
8
|
*
|
|
9
9
|
* 裁决(票面修法二):索引加总量上限(条目数 + 字节数双闸),超限即放弃驻留、
|
|
@@ -281,29 +281,6 @@ describe('sync-docs --agents', () => {
|
|
|
281
281
|
fs.rmSync(testDir, { recursive: true, force: true });
|
|
282
282
|
});
|
|
283
283
|
|
|
284
|
-
it('旧正本 .studio/CONTEXT.md 仍在场时兼容沿用(免迁移),两者同在以 .harness/ 为准', async () => {
|
|
285
|
-
const legacyDir = path.join(tempDir, 'legacy-context-model');
|
|
286
|
-
createFixture(legacyDir, { pnpm: true, withCapabilities: true });
|
|
287
|
-
fs.mkdirSync(path.join(legacyDir, '.studio'), { recursive: true });
|
|
288
|
-
fs.writeFileSync(path.join(legacyDir, '.studio', 'CONTEXT.md'), '# 模块上下文\n\n## src\n\n职责:夹具\n');
|
|
289
|
-
await syncDocs({ projectPath: legacyDir, agents: true }, io);
|
|
290
|
-
expect(fs.readFileSync(path.join(legacyDir, 'AGENTS.md'), 'utf-8'))
|
|
291
|
-
.toContain('模块上下文正本:`.studio/CONTEXT.md`(模块锚点组织),改动代码时同步更新');
|
|
292
|
-
fs.rmSync(legacyDir, { recursive: true, force: true });
|
|
293
|
-
|
|
294
|
-
const bothDir = path.join(tempDir, 'both-context-model');
|
|
295
|
-
createFixture(bothDir, { pnpm: true, withCapabilities: true });
|
|
296
|
-
fs.mkdirSync(path.join(bothDir, '.studio'), { recursive: true });
|
|
297
|
-
fs.writeFileSync(path.join(bothDir, '.studio', 'CONTEXT.md'), '# 旧\n');
|
|
298
|
-
fs.mkdirSync(path.join(bothDir, '.harness'), { recursive: true });
|
|
299
|
-
fs.writeFileSync(path.join(bothDir, '.harness', 'CONTEXT.md'), '# 新\n');
|
|
300
|
-
await syncDocs({ projectPath: bothDir, agents: true }, io);
|
|
301
|
-
const content = fs.readFileSync(path.join(bothDir, 'AGENTS.md'), 'utf-8');
|
|
302
|
-
expect(content).toContain('模块上下文正本:`.harness/CONTEXT.md`');
|
|
303
|
-
expect(content).not.toContain('.studio/CONTEXT.md');
|
|
304
|
-
fs.rmSync(bothDir, { recursive: true, force: true });
|
|
305
|
-
});
|
|
306
|
-
|
|
307
284
|
it('正本不存在时保持散置模型行,--check 无漂移', async () => {
|
|
308
285
|
const testDir = path.join(tempDir, 'scattered-context-model');
|
|
309
286
|
createFixture(testDir, { pnpm: true, withCapabilities: true });
|
|
@@ -630,7 +607,7 @@ describe('sync-docs --agents', () => {
|
|
|
630
607
|
fs.rmSync(testDir, { recursive: true, force: true });
|
|
631
608
|
});
|
|
632
609
|
|
|
633
|
-
it('PRESERVE:governance 治理契约段开箱即用:重新生成保留、--check 通过(
|
|
610
|
+
it('PRESERVE:governance 治理契约段开箱即用:重新生成保留、--check 通过(ADR 2026-08-21 落点模型)', async () => {
|
|
634
611
|
const testDir = path.join(tempDir, 'preserve-governance');
|
|
635
612
|
createFixture(testDir, { pnpm: true, withCapabilities: true });
|
|
636
613
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sync-docs --gate 测试(harness#189)
|
|
3
|
+
*
|
|
4
|
+
* 行为契约(票面锁定):
|
|
5
|
+
* 1. 照常先跑 sync-docs 自愈写入(幽灵条目剔除、file 模式自动补行不变);
|
|
6
|
+
* 2. 随后判定被管理文档相对 HEAD 是否产生 diff;
|
|
7
|
+
* 3. 有 diff 即 fail,输出点名缺登记文件(diff 新增行即名单);无 diff → ok。
|
|
8
|
+
* 自愈顺序不变:写入永远在校验之前(2026-08-08 CI 4 连红固化结论)。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as fs from 'fs';
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
import * as os from 'os';
|
|
14
|
+
import { execFileSync } from 'child_process';
|
|
15
|
+
import { captureIO } from '../../command-contract';
|
|
16
|
+
import { syncDocs } from '../sync-docs';
|
|
17
|
+
|
|
18
|
+
function git(dir: string, args: string[]): string {
|
|
19
|
+
return execFileSync('git', ['-C', dir, ...args], { encoding: 'utf-8' });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function commitAll(dir: string, msg: string): void {
|
|
23
|
+
git(dir, ['add', '-A']);
|
|
24
|
+
git(dir, [
|
|
25
|
+
'-c', 'user.name=test', '-c', 'user.email=test@example.com',
|
|
26
|
+
'commit', '-m', msg, '--no-gpg-sign',
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 建最小 file 模式项目骨架(package.json + src/alpha.ts) */
|
|
31
|
+
function scaffoldProject(dir: string): void {
|
|
32
|
+
fs.mkdirSync(path.join(dir, 'src'), { recursive: true });
|
|
33
|
+
fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({ name: 'gate-fixture', version: '0.0.1' }));
|
|
34
|
+
fs.writeFileSync(path.join(dir, 'src', 'alpha.ts'), '/**\n * Alpha module\n */\nexport const alpha = 1;');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('sync-docs --gate(harness#189)', () => {
|
|
38
|
+
let tempDir: string;
|
|
39
|
+
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sync-docs-gate-'));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
try {
|
|
46
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
47
|
+
} catch {
|
|
48
|
+
// ignore
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/** 造一个 HEAD 文档干净的仓库:sync-docs 写入后提交 */
|
|
53
|
+
async function setupCleanRepo(): Promise<void> {
|
|
54
|
+
scaffoldProject(tempDir);
|
|
55
|
+
git(tempDir, ['init']);
|
|
56
|
+
await syncDocs({ projectPath: tempDir }, captureIO());
|
|
57
|
+
commitAll(tempDir, 'baseline');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
it('file 模式漏登 → fail 且点名缺登记文件,自愈写入已落盘(写入在校验之前)', async () => {
|
|
61
|
+
await setupCleanRepo();
|
|
62
|
+
|
|
63
|
+
// 造漏登:新增已提交但未登记的源文件(开发者忘了跑 sync-docs)
|
|
64
|
+
fs.writeFileSync(path.join(tempDir, 'src', 'newmod.ts'), '/**\n * New module\n */\nexport const n = 1;');
|
|
65
|
+
commitAll(tempDir, 'add newmod without registering');
|
|
66
|
+
|
|
67
|
+
const io = captureIO();
|
|
68
|
+
const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
|
|
69
|
+
|
|
70
|
+
expect(result.kind).toBe('fail');
|
|
71
|
+
// 输出点名缺登记文件(diff 新增行即名单)
|
|
72
|
+
expect(io.outText()).toContain('newmod');
|
|
73
|
+
if (result.kind === 'fail') {
|
|
74
|
+
expect(result.reason).toContain('newmod');
|
|
75
|
+
}
|
|
76
|
+
// 自愈顺序不变:判定失败时写入已落盘
|
|
77
|
+
expect(fs.readFileSync(path.join(tempDir, 'CAPABILITIES.md'), 'utf-8')).toContain('newmod');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('HEAD 文档干净(无需自愈)→ ok', async () => {
|
|
81
|
+
await setupCleanRepo();
|
|
82
|
+
|
|
83
|
+
const io = captureIO();
|
|
84
|
+
const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
|
|
85
|
+
|
|
86
|
+
expect(result).toEqual({ kind: 'ok' });
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('幽灵条目剔除也触发门:写入在校验之前', async () => {
|
|
90
|
+
await setupCleanRepo();
|
|
91
|
+
|
|
92
|
+
// 造幽灵条目:CAPABILITIES.md 登记了不存在的 src/ghost.ts 并提交
|
|
93
|
+
const capsPath = path.join(tempDir, 'CAPABILITIES.md');
|
|
94
|
+
const content = fs.readFileSync(capsPath, 'utf-8');
|
|
95
|
+
fs.writeFileSync(capsPath, content + '| ghost | src/ghost.ts | Ghost module |\n');
|
|
96
|
+
commitAll(tempDir, 'register ghost entry');
|
|
97
|
+
|
|
98
|
+
const io = captureIO();
|
|
99
|
+
const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
|
|
100
|
+
|
|
101
|
+
expect(result.kind).toBe('fail');
|
|
102
|
+
expect(io.outText()).toContain('ghost');
|
|
103
|
+
// 自愈照做:幽灵行已被剔除
|
|
104
|
+
expect(fs.readFileSync(capsPath, 'utf-8')).not.toContain('ghost');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('sync-docs 查不出的未提交手改(描述改写)也是 vs HEAD 漂移 → fail', async () => {
|
|
108
|
+
await setupCleanRepo();
|
|
109
|
+
|
|
110
|
+
// 手改 CAPABILITIES.md 散文(不增删登记条目,sync-docs 判定面无漂移)且不提交
|
|
111
|
+
const capsPath = path.join(tempDir, 'CAPABILITIES.md');
|
|
112
|
+
const content = fs.readFileSync(capsPath, 'utf-8');
|
|
113
|
+
fs.writeFileSync(capsPath, content.replace('Alpha module', 'Alpha module v2'));
|
|
114
|
+
|
|
115
|
+
const io = captureIO();
|
|
116
|
+
const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
|
|
117
|
+
|
|
118
|
+
expect(result.kind).toBe('fail');
|
|
119
|
+
expect(io.outText()).toContain('CAPABILITIES.md');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('--agents 时 AGENTS.md 漂移(untracked 新建)也判 fail 并点名', async () => {
|
|
123
|
+
await setupCleanRepo();
|
|
124
|
+
|
|
125
|
+
const io = captureIO();
|
|
126
|
+
const result = await syncDocs({ projectPath: tempDir, gate: true, agents: true }, io);
|
|
127
|
+
|
|
128
|
+
expect(result.kind).toBe('fail');
|
|
129
|
+
expect(io.outText()).toContain('AGENTS.md');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('非 git 仓库 → usage-error,且不做任何写入', async () => {
|
|
133
|
+
scaffoldProject(tempDir);
|
|
134
|
+
|
|
135
|
+
const io = captureIO();
|
|
136
|
+
const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
|
|
137
|
+
|
|
138
|
+
expect(result.kind).toBe('usage-error');
|
|
139
|
+
expect(fs.existsSync(path.join(tempDir, 'CAPABILITIES.md'))).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it.each([
|
|
143
|
+
{ extra: { check: true }, label: '--check' },
|
|
144
|
+
{ extra: { json: true }, label: '--json' },
|
|
145
|
+
{ extra: { compact: true }, label: '--compact' },
|
|
146
|
+
])('--gate 与 $label 互斥 → usage-error', async ({ extra }) => {
|
|
147
|
+
await setupCleanRepo();
|
|
148
|
+
|
|
149
|
+
const io = captureIO();
|
|
150
|
+
const result = await syncDocs({ projectPath: tempDir, gate: true, ...extra }, io);
|
|
151
|
+
|
|
152
|
+
expect(result.kind).toBe('usage-error');
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -72,7 +72,7 @@ describe('sync-docs CAPABILITIES.md 表格排版(#171)', () => {
|
|
|
72
72
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
it('
|
|
75
|
+
it('撤目录条目行(撤登记形状):同样整行删除', async () => {
|
|
76
76
|
const dir = makeProject(
|
|
77
77
|
'dir-entry',
|
|
78
78
|
['cli/cli.ts', 'harness/h.ts'],
|
|
@@ -171,7 +171,7 @@ describe('sync-docs command', () => {
|
|
|
171
171
|
it('描述以 / 结尾的表格行不应被误判为目录条目(check 必须收敛)', async () => {
|
|
172
172
|
// 回归:JSDoc 首行在 "gitRepo /" 处换行时,生成的描述单元格以 / 结尾,
|
|
173
173
|
// 旧目录条目正则将其误判为目录 → --check 永远报「包含已删除的模块」
|
|
174
|
-
// (2026-08-04
|
|
174
|
+
// (2026-08-04 CI Governance 不收敛事故)
|
|
175
175
|
const testDir = path.join(tempDir, 'trailing-slash-desc');
|
|
176
176
|
const srcDir = path.join(testDir, 'src');
|
|
177
177
|
fs.mkdirSync(srcDir, { recursive: true });
|
|
@@ -409,7 +409,7 @@ describe('sync-docs command', () => {
|
|
|
409
409
|
const testDir = path.join(tempDir, 'tsx-row');
|
|
410
410
|
const srcDir = path.join(testDir, 'src', 'components');
|
|
411
411
|
fs.mkdirSync(srcDir, { recursive: true });
|
|
412
|
-
//
|
|
412
|
+
// 复刻下游消费方场景:同目录混合 .ts 与 .tsx
|
|
413
413
|
fs.writeFileSync(path.join(srcDir, 'statusClasses.ts'), 'export const statuses = {};');
|
|
414
414
|
fs.writeFileSync(
|
|
415
415
|
path.join(srcDir, 'DistillProposalCard.tsx'),
|
|
@@ -504,7 +504,7 @@ describe('sync-docs command', () => {
|
|
|
504
504
|
fs.writeFileSync(path.join(srcA, 'routes.ts'), 'export const routes = 1;');
|
|
505
505
|
|
|
506
506
|
// CAPABILITIES.md 另有一条指向不存在路径的 routes.ts(basename 碰撞,
|
|
507
|
-
// 按 basename 对比时永远不可见 —— 2026-08-08
|
|
507
|
+
// 按 basename 对比时永远不可见 —— 2026-08-08 CI 4 连红事故)
|
|
508
508
|
fs.writeFileSync(
|
|
509
509
|
path.join(testDir, 'CAPABILITIES.md'),
|
|
510
510
|
[
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* harness constraints disable —— 约束裸禁用(harness#190,ADR-0032 决策 6.6 的另一侧)
|
|
3
|
+
*
|
|
4
|
+
* 裸禁用 = config.yml `constraints.<id>.enabled:false`,无 retired 墓碑、无知识沉淀
|
|
5
|
+
* (墓碑与沉淀是 retire 专有语义)。与 retire 的分工:
|
|
6
|
+
*
|
|
7
|
+
* - disable:临时停用,幂等 already_disabled,不写沉淀;恢复 = 删 enabled 键
|
|
8
|
+
* - retire:永久退役,写 retired 墓碑 + `constraint-retired-<id>` 沉淀;
|
|
9
|
+
* 对裸 disabled 条目会接管补墓碑+沉淀(constraints-retire.ts 头部注释)
|
|
10
|
+
*
|
|
11
|
+
* 语义与下游消费方 applier 的 applyDisable 对齐(经下游裁定
|
|
12
|
+
* config.yml 归 harness,本命令是下游切换的落点):
|
|
13
|
+
* 只认内置 + 应用层(.harness/constraints.yml)check 约束(findRetireTarget 同路径,
|
|
14
|
+
* ADR-0033);写后验证生效集已缩小,失败回滚备份。
|
|
15
|
+
*
|
|
16
|
+
* retired 墓碑不接管不动:已退役条目返回 already_retired(要恢复请 reactivate)。
|
|
17
|
+
* 人确认闸门与 retire/reactivate 同形(ADR-0001 决策 2):直达必须显式 --yes,
|
|
18
|
+
* 不提供交互模式——禁用是低频点对点操作(同 reactivate 定位)。
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import * as fs from 'fs';
|
|
22
|
+
import * as path from 'path';
|
|
23
|
+
import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
24
|
+
import chalk from 'chalk';
|
|
25
|
+
import { ProjectConfigLoader } from '../../core/project-config-loader';
|
|
26
|
+
import { isRetiredTombstone } from '../../core/retired-constraints';
|
|
27
|
+
import { getEffectiveConstraints } from '../../core/effective-constraints';
|
|
28
|
+
import { findRetireTarget, logCommitHint, setYamlEntry } from './constraints-retire';
|
|
29
|
+
|
|
30
|
+
export type DisableStatus =
|
|
31
|
+
| 'disabled'
|
|
32
|
+
| 'already_disabled'
|
|
33
|
+
| 'already_retired'
|
|
34
|
+
| 'unknown_id'
|
|
35
|
+
| 'verify_failed';
|
|
36
|
+
|
|
37
|
+
export interface DisableResult {
|
|
38
|
+
id: string;
|
|
39
|
+
status: DisableStatus;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ConstraintsDisableOptions {
|
|
43
|
+
projectPath?: string;
|
|
44
|
+
/** 直达模式显式确认(--yes):与 retire/reactivate 同一道人确认闸门,无此 flag 直达拒绝执行 */
|
|
45
|
+
yes?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 执行单条约束裸禁用(纯执行逻辑,无交互)
|
|
50
|
+
*
|
|
51
|
+
* 不存在的 id / 已禁用 / 已退役的 id 通过 status 返回,由调用方提示。
|
|
52
|
+
*/
|
|
53
|
+
export function disableConstraint(projectRoot: string, id: string): DisableResult {
|
|
54
|
+
const target = findRetireTarget(id, projectRoot);
|
|
55
|
+
if (!target) {
|
|
56
|
+
return { id, status: 'unknown_id' };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 幂等口径(ADR-0032 决策 6.6):retired 墓碑优先判定——disable 不动墓碑不吞退休语义;
|
|
60
|
+
// 裸 enabled:false 即已禁用。判定谓词唯一实现 = isRetiredTombstone
|
|
61
|
+
const loader = new ProjectConfigLoader(projectRoot);
|
|
62
|
+
loader.load();
|
|
63
|
+
const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
|
|
64
|
+
if (isRetiredTombstone(existing)) {
|
|
65
|
+
return { id, status: 'already_retired' };
|
|
66
|
+
}
|
|
67
|
+
if (existing?.enabled === false) {
|
|
68
|
+
return { id, status: 'already_disabled' };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 1. 落盘裸禁用(config.yml enabled:false,无 retired 段;同文件其他条目不动)
|
|
72
|
+
const configPath = path.join(projectRoot, '.harness', 'config.yml');
|
|
73
|
+
const backup = fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf-8') : null;
|
|
74
|
+
setYamlEntry(configPath, 'config.yml', 'constraints', id, { enabled: false });
|
|
75
|
+
|
|
76
|
+
// 2. 写后验证:生效集必须已缩小(与下游 applier 同一纪律),失败回滚备份
|
|
77
|
+
try {
|
|
78
|
+
if (getEffectiveConstraints(projectRoot).some(c => c.id === id)) {
|
|
79
|
+
throw new Error('constraint still present in effective set after disable');
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
if (backup !== null) fs.writeFileSync(configPath, backup, 'utf-8');
|
|
83
|
+
else fs.rmSync(configPath, { force: true });
|
|
84
|
+
return { id, status: 'verify_failed' };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return { id, status: 'disabled' };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 打印单条禁用结果
|
|
92
|
+
*/
|
|
93
|
+
export function printDisableResult(result: DisableResult, io: CommandIO = processIO, projectRoot?: string): CommandResult {
|
|
94
|
+
switch (result.status) {
|
|
95
|
+
case 'unknown_id':
|
|
96
|
+
log(io, chalk.red(`❌ ${result.id}: 约束不存在(内置与应用层约束中都未找到),未做任何变更`));
|
|
97
|
+
return { kind: 'skip', reason: `${result.id}: 约束不存在,未做任何变更` };
|
|
98
|
+
case 'already_disabled':
|
|
99
|
+
log(io, chalk.yellow(`⚠️ ${result.id}: 已处于禁用状态(config.yml enabled:false 无墓碑),跳过`));
|
|
100
|
+
return { kind: 'skip', reason: `${result.id}: 已处于禁用状态,跳过` };
|
|
101
|
+
case 'already_retired':
|
|
102
|
+
log(io, chalk.yellow(`⚠️ ${result.id}: 已处于退役状态(有 retired 墓碑)——disable 不动墓碑,未做任何变更;要恢复请 harness constraints reactivate ${result.id} --yes`));
|
|
103
|
+
return { kind: 'skip', reason: `${result.id}: 已处于退役状态,未做任何变更` };
|
|
104
|
+
case 'verify_failed':
|
|
105
|
+
logError(io, chalk.red(`❌ ${result.id}: 禁用后约束仍在生效集,写后验证失败,已回滚 config.yml`));
|
|
106
|
+
return { kind: 'fail', reason: `${result.id}: disable 写后验证失败,已回滚 config.yml` };
|
|
107
|
+
case 'disabled': {
|
|
108
|
+
log(io, chalk.green(`✅ ${result.id}: 已禁用(config.yml enabled:false,无 retired 墓碑、无知识沉淀)`));
|
|
109
|
+
log(io, chalk.gray(` disable 是裸禁用不是退役——恢复:删 config.yml constraints.${result.id} 的 enabled 键;要永久退役走 harness constraints retire ${result.id}(会接管补墓碑+沉淀)`));
|
|
110
|
+
if (projectRoot) logCommitHint(projectRoot, io);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { kind: 'ok' };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* CLI handler: harness constraints disable <id>
|
|
119
|
+
*
|
|
120
|
+
* 人确认闸门与 retire/reactivate 同形:直达必须显式 `--yes`,无 `--yes` 报错 +
|
|
121
|
+
* 非零退出码,不落盘任何文件。无交互模式(点对点操作,同 reactivate)。
|
|
122
|
+
*/
|
|
123
|
+
export async function constraintsDisable(
|
|
124
|
+
id?: string,
|
|
125
|
+
options: ConstraintsDisableOptions = {},
|
|
126
|
+
io: CommandIO = processIO,
|
|
127
|
+
): Promise<CommandResult> {
|
|
128
|
+
const projectRoot = options.projectPath || process.cwd();
|
|
129
|
+
|
|
130
|
+
if (!id) {
|
|
131
|
+
logError(io, chalk.red('❌ 用法:harness constraints disable <id> --yes(禁用是点对点操作,无交互模式)'));
|
|
132
|
+
return { kind: 'usage-error', reason: 'disable 缺少约束 id,未做任何变更' };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!options.yes) {
|
|
136
|
+
logError(io,
|
|
137
|
+
chalk.red(`❌ 直达禁用需要显式人确认(与 retire 同一闸门),未做任何变更\n`) +
|
|
138
|
+
` 带 --yes 显式确认直达:harness constraints disable ${id} --yes`
|
|
139
|
+
);
|
|
140
|
+
return { kind: 'usage-error', reason: `直达禁用 ${id} 缺少显式 --yes 人确认,未做任何变更` };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const result = disableConstraint(projectRoot, id);
|
|
144
|
+
return printDisableResult(result, io, projectRoot);
|
|
145
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* harness constraints pack-proposal <id> —— 升级提案材料打包(ADR-0033 决策 4,块 3 子项 5)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 升级通道链路:下游审卡发起/初审 → approve 后由本命令打包脱敏材料 →
|
|
5
5
|
* 人拿材料去 harness 仓开 issue(github 操作留给人,本命令不触网)。
|
|
6
6
|
*
|
|
7
7
|
* 材料内容:条文 + severity + checker 模板与参数 + traces.log 使用统计(只有计数)
|
|
@@ -16,6 +16,7 @@ import * as path from 'path';
|
|
|
16
16
|
import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
|
|
17
17
|
import chalk from 'chalk';
|
|
18
18
|
import { ProjectConfigLoader } from '../../core/project-config-loader';
|
|
19
|
+
import { isRetiredTombstone } from '../../core/retired-constraints';
|
|
19
20
|
import type { KnowledgeEntry } from '../../knowledge/types';
|
|
20
21
|
import { openKnowledgeStore } from './knowledge-view';
|
|
21
22
|
import { findRetireTarget, logCommitHint, removeYamlEntry, type RetireTargetInfo } from './constraints-retire';
|
|
@@ -121,11 +122,12 @@ export function reactivateConstraint(
|
|
|
121
122
|
return { id, status: 'unknown_id' };
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
// 只认 retired 墓碑:裸 disable 与未配置一律 not_retired(与 retire
|
|
125
|
+
// 只认 retired 墓碑:裸 disable 与未配置一律 not_retired(与 retire 的幂等口径对偶,
|
|
126
|
+
// 判定谓词唯一实现 = isRetiredTombstone)
|
|
125
127
|
const loader = new ProjectConfigLoader(projectRoot);
|
|
126
128
|
loader.load();
|
|
127
129
|
const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
|
|
128
|
-
if (!(existing
|
|
130
|
+
if (!isRetiredTombstone(existing)) {
|
|
129
131
|
return { id, status: 'not_retired' };
|
|
130
132
|
}
|
|
131
133
|
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* retired: { at, reason, stats: { total, fail, failRate } }
|
|
13
13
|
*
|
|
14
14
|
* 每条同时写一条 KnowledgeStore 记录(consumptionMode: 'signal')。
|
|
15
|
-
baseDir 不硬编码 projectRoot 拼接,走 openKnowledgeStore 同一解析点(harness#177):
|
|
16
|
-
缺省与 `harness knowledge` 读口同根,KNOWLEDGE_BASE_DIR 覆盖对写口同步生效。
|
|
15
|
+
* baseDir 不硬编码 projectRoot 拼接,走 openKnowledgeStore 同一解析点(harness#177):
|
|
16
|
+
* 缺省与 `harness knowledge` 读口同根,KNOWLEDGE_BASE_DIR 覆盖对写口同步生效。
|
|
17
17
|
*
|
|
18
18
|
* ADR-0029:custom 纯文本约束与治理注入段同步已随文本注入层关停一并退役。
|
|
19
19
|
* ADR-0032 观察名单(块 3 子项 4):零拦截命中先进观察名单(`.harness/.state.json`
|
|
@@ -40,6 +40,7 @@ import * as yaml from 'js-yaml';
|
|
|
40
40
|
import chalk from 'chalk';
|
|
41
41
|
import { getConstraint } from '../../core/constraints/definitions';
|
|
42
42
|
import { ProjectConfigLoader } from '../../core/project-config-loader';
|
|
43
|
+
import { isRetiredTombstone } from '../../core/retired-constraints';
|
|
43
44
|
import { loadAppConstraints } from '../../core/app-constraints-loader';
|
|
44
45
|
import type { RunTarget } from '../../core/constraints/run-env';
|
|
45
46
|
import type { KnowledgeEntry } from '../../knowledge/types';
|
|
@@ -60,7 +61,7 @@ export interface RetireExecuteOptions {
|
|
|
60
61
|
reason?: string;
|
|
61
62
|
/** 注入当前时间(测试用) */
|
|
62
63
|
now?: Date;
|
|
63
|
-
/** 知识库路径解析的 io
|
|
64
|
+
/** 知识库路径解析的 io(注入给 openKnowledgeStore;当前 resolveKnowledgeBaseDir 已不消费,保留注入点与读口签名对齐。缺省 processIO) */
|
|
64
65
|
io?: CommandIO;
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -135,8 +136,10 @@ export function findRetireTarget(id: string, target?: RunTarget): RetireTargetIn
|
|
|
135
136
|
* js-yaml 不保留注释:原文件含注释行时重写会丢失,console 说明(`label` 是给用户看的
|
|
136
137
|
* 文件名)。落盘字节由 `__tests__/constraints-retire.test.ts`
|
|
137
138
|
* 的逐字节冻结用例钉住——合并属内部重构,对外产物不得漂移。
|
|
139
|
+
*
|
|
140
|
+
* 导出给 constraints-disable 复用(裸禁用写 `{ enabled: false }` 同一读-改-写口径)。
|
|
138
141
|
*/
|
|
139
|
-
function setYamlEntry(
|
|
142
|
+
export function setYamlEntry(
|
|
140
143
|
filePath: string,
|
|
141
144
|
label: string,
|
|
142
145
|
section: string,
|
|
@@ -182,11 +185,11 @@ export function removeYamlEntry(filePath: string, section: string, id: string):
|
|
|
182
185
|
|
|
183
186
|
/**
|
|
184
187
|
* 落盘后 commit 提示(票 02 断点 4):仅 git 仓内提示,不替用户动 git。
|
|
185
|
-
*
|
|
188
|
+
* 下游审卡通道由 applier 自动 commit,本提示面向 CLI 直达/裸项目场景。
|
|
186
189
|
*/
|
|
187
190
|
export function logCommitHint(projectRoot: string, io: CommandIO): void {
|
|
188
191
|
if (!fs.existsSync(path.join(projectRoot, '.git'))) return;
|
|
189
|
-
log(io, chalk.gray(' 提示:config.yml 已改未提交——git add .harness/config.yml && git commit
|
|
192
|
+
log(io, chalk.gray(' 提示:config.yml 已改未提交——git add .harness/config.yml && git commit(下游审卡通道会自动 commit)'));
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
/**
|
|
@@ -284,9 +287,9 @@ export function retireConstraint(
|
|
|
284
287
|
|
|
285
288
|
// 已退役保护:只认 retired 墓碑(ADR-0032 决策 6.6,票 02 断点 6)——
|
|
286
289
|
// 裸 enabled:false 是"禁用"不是"退休",落到下面正常退休流程:覆写墓碑 + 补写沉淀,
|
|
287
|
-
// 不让一次裸 disable 吞掉 retire
|
|
290
|
+
// 不让一次裸 disable 吞掉 retire 的知识沉淀。判定谓词唯一实现 = isRetiredTombstone。
|
|
288
291
|
const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
|
|
289
|
-
if (existing
|
|
292
|
+
if (isRetiredTombstone(existing)) {
|
|
290
293
|
return { id, status: 'already_retired', isError, stats: emptyStats };
|
|
291
294
|
}
|
|
292
295
|
|
|
@@ -223,6 +223,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
223
223
|
{ flags: '--json', description: '输出 JSON 格式(供 LLM 消费)', defaultValue: false },
|
|
224
224
|
{ flags: '--agents', description: '同步 AGENTS.md(agent 导读;PRESERVE 标记段重新生成时保留)', defaultValue: false },
|
|
225
225
|
{ flags: '--compact', description: '一次性迁移:将 CAPABILITIES.md 文件表格折叠为目录条目', defaultValue: false },
|
|
226
|
+
{ flags: '--gate', description: '门禁模式:自愈写入后判定被管理文档相对 HEAD 的 diff,有 diff 退 1(CI 用;与 --check/--json/--compact 互斥)', defaultValue: false },
|
|
226
227
|
],
|
|
227
228
|
// --check 下的漂移由实现返回 fail(候选7:退出码映射只在 bin 一处),故无需 afterRun
|
|
228
229
|
action: { module: 'sync-docs', export: 'syncDocs' },
|
|
@@ -297,7 +298,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
297
298
|
},
|
|
298
299
|
{
|
|
299
300
|
command: 'release',
|
|
300
|
-
description: 'npm 发布流水线:tsc → dist 验证 → npm version → git push → npm publish → gh release
|
|
301
|
+
description: 'npm 发布流水线:tsc → dist 验证 → npm version → git push → npm publish → gh release。纯 CLI 实现,不依赖外部 API。',
|
|
301
302
|
options: [
|
|
302
303
|
{ flags: '--bump <type>', description: '版本递增类型', defaultValue: 'patch' },
|
|
303
304
|
{ flags: '--dry-run <bool>', description: '仅模拟执行', defaultValue: 'false' },
|
|
@@ -369,6 +370,20 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
|
|
|
369
370
|
yes: options.yes,
|
|
370
371
|
}],
|
|
371
372
|
},
|
|
373
|
+
{
|
|
374
|
+
command: 'disable',
|
|
375
|
+
argument: '<id>',
|
|
376
|
+
description: '裸禁用约束:config.yml enabled:false 无 retired 墓碑无沉淀(区别于 retire;写后验证生效集已缩小,失败回滚);直达需显式 --yes,幂等 already disabled',
|
|
377
|
+
options: [
|
|
378
|
+
{ flags: '-p, --project-path <path>', description: '项目路径' },
|
|
379
|
+
{ flags: '-y, --yes', description: '显式确认直达禁用(与 retire 同一道人确认闸门)', defaultValue: false },
|
|
380
|
+
],
|
|
381
|
+
action: { module: 'constraints-disable', export: 'constraintsDisable' },
|
|
382
|
+
mapActionArgs: (positionals, options) => [positionals[0], {
|
|
383
|
+
projectPath: options.projectPath,
|
|
384
|
+
yes: options.yes,
|
|
385
|
+
}],
|
|
386
|
+
},
|
|
372
387
|
{
|
|
373
388
|
command: 'pack-proposal',
|
|
374
389
|
argument: '<id>',
|