cleargate 0.12.0 → 0.13.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/dist/MANIFEST.json +13 -13
- package/dist/{chunk-HZPJ5QX4.js → chunk-EG6YGT2O.js} +315 -33
- package/dist/chunk-EG6YGT2O.js.map +1 -0
- package/dist/cli.cjs +612 -289
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +73 -37
- package/dist/cli.js.map +1 -1
- package/dist/lib/lifecycle-reconcile.cjs +318 -34
- package/dist/lib/lifecycle-reconcile.cjs.map +1 -1
- package/dist/lib/lifecycle-reconcile.d.cts +55 -4
- package/dist/lib/lifecycle-reconcile.d.ts +55 -4
- package/dist/lib/lifecycle-reconcile.js +7 -3
- package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +1 -1
- package/dist/templates/cleargate-planning/.claude/agents/developer.md +8 -4
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +2 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +73 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +1 -1
- package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +1 -1
- package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +1 -1
- package/dist/templates/cleargate-planning/.cleargate/templates/hotfix.md +1 -1
- package/dist/templates/cleargate-planning/.cleargate/templates/initiative.md +1 -1
- package/dist/templates/cleargate-planning/.cleargate/templates/sprint_report.md +1 -1
- package/dist/templates/cleargate-planning/.cleargate/templates/story.md +1 -1
- package/dist/templates/cleargate-planning/CLAUDE.md +2 -0
- package/dist/templates/cleargate-planning/MANIFEST.json +13 -13
- package/package.json +8 -9
- package/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +1 -1
- package/templates/cleargate-planning/.claude/agents/developer.md +8 -4
- package/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +2 -0
- package/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +73 -0
- package/templates/cleargate-planning/.cleargate/templates/Bug.md +1 -1
- package/templates/cleargate-planning/.cleargate/templates/CR.md +1 -1
- package/templates/cleargate-planning/.cleargate/templates/epic.md +1 -1
- package/templates/cleargate-planning/.cleargate/templates/hotfix.md +1 -1
- package/templates/cleargate-planning/.cleargate/templates/initiative.md +1 -1
- package/templates/cleargate-planning/.cleargate/templates/sprint_report.md +1 -1
- package/templates/cleargate-planning/.cleargate/templates/story.md +1 -1
- package/templates/cleargate-planning/CLAUDE.md +2 -0
- package/templates/cleargate-planning/MANIFEST.json +13 -13
- package/dist/chunk-HZPJ5QX4.js.map +0 -1
|
@@ -55,6 +55,8 @@ This repository uses **ClearGate** — a standalone planning framework for AI co
|
|
|
55
55
|
|
|
56
56
|
**Codebase / PM-Tool Boundary (EPIC-027).** `cleargate-cli/src/**` and `.claude/**` MUST NOT import any PM-tool SDK (`@linear/sdk`, `jira-client`, `azure-devops`, `@atlassian/`, `linear-sdk`, `node-jira-client`, `jira.js`). PM-tool adapters live exclusively in `mcp/src/adapters/`; credentials live in admin DB rows. The type-and-payload contract (open-type validator, KNOWN_TYPES, RESERVED_PAYLOAD_KEYS, `payload.origin`, `cleargate_id` formats, L1 errorCode + L2 warningCode taxonomies) is fully documented in `.cleargate/knowledge/cleargate-protocol.md` §Type & Payload Contract and §Codebase/PM-Tool Boundary. CI enforcement: `npm run check:no-pm-sdk` (exits non-zero on any forbidden import). Target repos that ran `cleargate init` before SPRINT-27 should re-run `cleargate init` to pick up this boundary rule in their local bounded block.
|
|
57
57
|
|
|
58
|
+
**Single test runner (EPIC-028).** All three packages (mcp/, cleargate-cli/, admin/) use node:test exclusively — vitest is fully eliminated as of 2026-05-18. File naming: `*.node.test.ts`. Run via `tsx --test` (mcp/, cleargate-cli/) or `node --conditions browser --import tsx tests/run-tests.mjs` (admin/). The `--conditions browser` flag is required for admin/ — it enables jsdom-bootstrap via `setup-node-test.mjs`. Adding vitest back is forbidden; `check:no-vitest` pre-commit guard enforces this.
|
|
59
|
+
|
|
58
60
|
**Project overrides.** Content OUTSIDE this `<!-- CLEARGATE:START -->...<!-- CLEARGATE:END -->` block takes precedence where it conflicts with ClearGate defaults.
|
|
59
61
|
|
|
60
62
|
**Scope reminder.** ClearGate is a *planning* framework. It scaffolds how work gets planned and how the four-agent loop runs. It does not replace your project's build system, CI, test runner, or deployment tooling.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cleargate_version": "0.
|
|
3
|
-
"generated_at": "2026-05-
|
|
2
|
+
"cleargate_version": "0.13.0",
|
|
3
|
+
"generated_at": "2026-05-18T17:11:10.027Z",
|
|
4
4
|
"files": [
|
|
5
5
|
{
|
|
6
6
|
"path": ".claude/agents/architect.md",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": ".claude/agents/cleargate-wiki-lint.md",
|
|
28
|
-
"sha256": "
|
|
28
|
+
"sha256": "2a9212d81df9a68e167ec7a18093a73c6da0208f13685c6887d5bd832b56fb3d",
|
|
29
29
|
"tier": "agent",
|
|
30
30
|
"overwrite_policy": "always",
|
|
31
31
|
"preserve_on_uninstall": false
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"path": ".claude/agents/developer.md",
|
|
42
|
-
"sha256": "
|
|
42
|
+
"sha256": "db7963778d68654f2dc96658d60433fa79305a10eec937807f2f0ed0cd05ce89",
|
|
43
43
|
"tier": "agent",
|
|
44
44
|
"overwrite_policy": "always",
|
|
45
45
|
"preserve_on_uninstall": false
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"path": ".claude/hooks/pre-commit-surface-gate.sh",
|
|
77
|
-
"sha256": "
|
|
77
|
+
"sha256": "8dd817fbe75ee53753e2fe1fc2ccd2b6efdb2b3c0b6ad3191bebd9640afdd6f8",
|
|
78
78
|
"tier": "hook",
|
|
79
79
|
"overwrite_policy": "always",
|
|
80
80
|
"preserve_on_uninstall": false
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"path": ".cleargate/scripts/close_sprint.mjs",
|
|
203
|
-
"sha256": "
|
|
203
|
+
"sha256": "b14b65f15c5ad57a845df89c069b5417195651b7d3aa7f7f5736416d0db0b868",
|
|
204
204
|
"tier": "script",
|
|
205
205
|
"overwrite_policy": "always",
|
|
206
206
|
"preserve_on_uninstall": false
|
|
@@ -396,35 +396,35 @@
|
|
|
396
396
|
},
|
|
397
397
|
{
|
|
398
398
|
"path": ".cleargate/templates/Bug.md",
|
|
399
|
-
"sha256": "
|
|
399
|
+
"sha256": "cebca344b6b820525c603444cf52626e120ebaa1ac28da099dc19c9cff39302c",
|
|
400
400
|
"tier": "template",
|
|
401
401
|
"overwrite_policy": "merge-3way",
|
|
402
402
|
"preserve_on_uninstall": false
|
|
403
403
|
},
|
|
404
404
|
{
|
|
405
405
|
"path": ".cleargate/templates/CR.md",
|
|
406
|
-
"sha256": "
|
|
406
|
+
"sha256": "ea5acf2087808e0d52806a87a6a7f1ced7473b591857f322fab5285adc80d25a",
|
|
407
407
|
"tier": "template",
|
|
408
408
|
"overwrite_policy": "merge-3way",
|
|
409
409
|
"preserve_on_uninstall": false
|
|
410
410
|
},
|
|
411
411
|
{
|
|
412
412
|
"path": ".cleargate/templates/epic.md",
|
|
413
|
-
"sha256": "
|
|
413
|
+
"sha256": "f9cf44db19288f0756b76bc8b13a075d4089990324db6febd072f5cf93d59cd0",
|
|
414
414
|
"tier": "template",
|
|
415
415
|
"overwrite_policy": "merge-3way",
|
|
416
416
|
"preserve_on_uninstall": false
|
|
417
417
|
},
|
|
418
418
|
{
|
|
419
419
|
"path": ".cleargate/templates/hotfix.md",
|
|
420
|
-
"sha256": "
|
|
420
|
+
"sha256": "de788497b4d224500036773f854801c056d73b08c3c0d66fdb641f17a1610bca",
|
|
421
421
|
"tier": "template",
|
|
422
422
|
"overwrite_policy": "merge-3way",
|
|
423
423
|
"preserve_on_uninstall": false
|
|
424
424
|
},
|
|
425
425
|
{
|
|
426
426
|
"path": ".cleargate/templates/initiative.md",
|
|
427
|
-
"sha256": "
|
|
427
|
+
"sha256": "1170e595f5813c62f86212d6ca1955d84465f396c81aaf34498b8e2d4595d681",
|
|
428
428
|
"tier": "template",
|
|
429
429
|
"overwrite_policy": "merge-3way",
|
|
430
430
|
"preserve_on_uninstall": false
|
|
@@ -445,14 +445,14 @@
|
|
|
445
445
|
},
|
|
446
446
|
{
|
|
447
447
|
"path": ".cleargate/templates/sprint_report.md",
|
|
448
|
-
"sha256": "
|
|
448
|
+
"sha256": "5914d54080f6110be5a5e905e3312811f3d0f80978121b1e15707d5be05cc5b1",
|
|
449
449
|
"tier": "template",
|
|
450
450
|
"overwrite_policy": "merge-3way",
|
|
451
451
|
"preserve_on_uninstall": false
|
|
452
452
|
},
|
|
453
453
|
{
|
|
454
454
|
"path": ".cleargate/templates/story.md",
|
|
455
|
-
"sha256": "
|
|
455
|
+
"sha256": "0badf01a080bca552a06fb64becd9b8c88fbf104e30f32667263522c3ff81051",
|
|
456
456
|
"tier": "template",
|
|
457
457
|
"overwrite_policy": "merge-3way",
|
|
458
458
|
"preserve_on_uninstall": false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cleargate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Planning framework for Claude Code agents — sprint/epic/story protocol, five-role agent team (architect/developer/qa/devops/reporter), Karpathy-style awareness wiki.",
|
|
@@ -47,12 +47,11 @@
|
|
|
47
47
|
"build": "tsup",
|
|
48
48
|
"dev": "tsup --watch",
|
|
49
49
|
"typecheck": "tsc --noEmit",
|
|
50
|
-
"test": "tsx --test --test-reporter=spec 'test/**/*.node.test.ts'",
|
|
51
|
-
"test:file": "tsx --test --test-reporter=spec",
|
|
52
|
-
"test:
|
|
53
|
-
"test:
|
|
54
|
-
"
|
|
55
|
-
"test:node:file": "tsx --test --test-reporter=spec"
|
|
50
|
+
"test": "tsx --test --test-concurrency=1 --experimental-test-module-mocks --test-reporter=spec 'test/**/*.node.test.ts' '!test/fixtures/**'",
|
|
51
|
+
"test:file": "tsx --test --test-concurrency=1 --experimental-test-module-mocks --test-reporter=spec",
|
|
52
|
+
"test:node": "tsx --test --test-concurrency=1 --experimental-test-module-mocks --test-reporter=spec 'test/**/*.node.test.ts' '!test/fixtures/**'",
|
|
53
|
+
"test:node:file": "tsx --test --test-concurrency=1 --experimental-test-module-mocks --test-reporter=spec",
|
|
54
|
+
"check:no-vitest": "node -e \"const r=require('child_process').execSync('grep -rE \\\"\\\\b(vitest|vi\\\\.fn|vi\\\\.mock|vi\\\\.spyOn|vi\\\\.stubGlobal|vi\\\\.useFakeTimers|vi\\\\.useRealTimers|vi\\\\.advanceTimersByTime|vi\\\\.hoisted)\\\\b\\\" --include=\\\"*.ts\\\" --include=\\\"*.js\\\" --include=\\\"*.mjs\\\" --exclude-dir=test/fixtures . 2>/dev/null || true', {encoding:'utf8'}); if(r.trim()){console.error('vitest residue detected:\\\\n'+r); process.exit(1)} console.log('no vitest residue')\""
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
57
|
"@napi-rs/keyring": "^1.2.0",
|
|
@@ -67,9 +66,9 @@
|
|
|
67
66
|
"@types/js-yaml": "^4.0.9",
|
|
68
67
|
"@types/node": "^24.0.0",
|
|
69
68
|
"@types/pg": "^8.11.10",
|
|
69
|
+
"ts-morph": "28.0.0",
|
|
70
70
|
"tsup": "^8",
|
|
71
71
|
"tsx": "^4.21.0",
|
|
72
|
-
"typescript": "^5.8.0"
|
|
73
|
-
"vitest": "^2.1.0"
|
|
72
|
+
"typescript": "^5.8.0"
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cleargate-wiki-lint
|
|
3
|
-
description: Use BEFORE Gate 1 (Proposal approval) and Gate 3 (Push) to enforce wiki-vs-raw consistency. Default mode (enforcement) exits non-zero on any drift, naming the offending page; halts gate transitions. `--suggest` mode (advisory) exits 0 and prints candidate cross-refs the ingest pass missed (Karpathy discovery). Performance: O(n), one pass per page plus one index cross-check; no all-pairs comparison.
|
|
3
|
+
description: "Use BEFORE Gate 1 (Proposal approval) and Gate 3 (Push) to enforce wiki-vs-raw consistency. Default mode (enforcement) exits non-zero on any drift, naming the offending page; halts gate transitions. `--suggest` mode (advisory) exits 0 and prints candidate cross-refs the ingest pass missed (Karpathy discovery). Performance: O(n), one pass per page plus one index cross-check; no all-pairs comparison."
|
|
4
4
|
tools: Read, Grep, Glob, Bash
|
|
5
5
|
model: sonnet
|
|
6
6
|
---
|
|
@@ -72,13 +72,17 @@ flashcards_flagged:
|
|
|
72
72
|
|
|
73
73
|
## Inner-loop test runner
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
All tests use **`node:test` + `node:assert/strict`** — this is the single, mandatory runner across all ClearGate packages (EPIC-028, 2026-05-18). vitest is fully eliminated; adding it back is forbidden and blocked by the `check:no-vitest` pre-commit guard.
|
|
76
76
|
|
|
77
|
-
**
|
|
77
|
+
**File naming:** `*.node.test.ts` for all new test files.
|
|
78
78
|
|
|
79
|
-
**
|
|
79
|
+
**Run commands per package:**
|
|
80
|
+
- `mcp/` and `cleargate-cli/`: `tsx --test --test-concurrency=1 --experimental-test-module-mocks 'test/**/*.node.test.ts'`
|
|
81
|
+
- `admin/`: `node --conditions browser --import tsx tests/run-tests.mjs` — the `--conditions browser` flag is required; it triggers jsdom-bootstrap via `setup-node-test.mjs` for Svelte component tests.
|
|
80
82
|
|
|
81
|
-
**
|
|
83
|
+
**Mocking pattern:** prefer constructor-injected DI seams over module-level mocks. Inject the dependency via the constructor or function parameter and pass a fake in tests. For function-level mocks, use `mock.fn()` / `mock.method()` from `node:test`. For static-import un-interceptability in admin/ (e.g. toast, clipboard), use the `__overrides__` pattern: a `__mocks__/` stub with a mutable `__overrides__` object that the test sets before each call — see `admin/TESTING.md` for full pattern description.
|
|
84
|
+
|
|
85
|
+
**Full-suite verification at commit-time.** Use the project's standard test command (`npm test`, etc.) before committing.
|
|
82
86
|
|
|
83
87
|
## Script Invocation
|
|
84
88
|
|
|
@@ -23,6 +23,8 @@ else
|
|
|
23
23
|
echo "[red-gate] BYPASS: SKIP_RED_GATE=1 set — skipping Red-test immutability check. Log bypass in sprint §4." >&2
|
|
24
24
|
fi
|
|
25
25
|
|
|
26
|
+
if ! npm run check:no-vitest -s --prefix mcp 2>/dev/null || ! npm run check:no-vitest -s --prefix cleargate-cli 2>/dev/null || ! npm run check:no-vitest -s --prefix admin 2>/dev/null; then exit 1; fi
|
|
27
|
+
|
|
26
28
|
SCRIPT="${REPO_ROOT}/.cleargate/scripts/file_surface_diff.sh"
|
|
27
29
|
if [[ ! -f "${SCRIPT}" ]]; then
|
|
28
30
|
echo "[surface-gate] WARNING: file_surface_diff.sh not found — skipping" >&2
|
|
@@ -407,6 +407,79 @@ async function main() {
|
|
|
407
407
|
process.stdout.write('Step 2.6b skipped: CLEARGATE_SKIP_LIFECYCLE_CHECK=1 set (test seam).\n');
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
+
// ── Step 2.6c: Parent (Epic/Sprint) Rollup (CR-066) ──────────────────────
|
|
411
|
+
// Runs unconditionally (not gated by CLEARGATE_SKIP_LIFECYCLE_CHECK).
|
|
412
|
+
// For each active parent in delivery/pending-sync/, checks children coverage:
|
|
413
|
+
// auto-flip → rewrite status: Completed atomically, log one line.
|
|
414
|
+
// halt-partial → collect into haltList; exit 1 after processing all.
|
|
415
|
+
// halt-zero-children → collect into haltList; exit 1 after processing all.
|
|
416
|
+
// no-op / skip-deferred → silent.
|
|
417
|
+
// Defensive guard: if walkActiveParents is not a function (stale dist/), skip with warning.
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Atomic in-place status rewrite (raw-bytes regex-replace).
|
|
421
|
+
* Follows FLASHCARD 2026-04-24 #frontmatter #write-back pattern.
|
|
422
|
+
* @param {string} filePath
|
|
423
|
+
* @param {string} newStatus
|
|
424
|
+
*/
|
|
425
|
+
function setFrontmatterStatusAtomic(filePath, newStatus) {
|
|
426
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
427
|
+
const fm = raw.match(/^---\n([\s\S]*?)\n---/);
|
|
428
|
+
if (!fm) throw new Error(`No frontmatter in ${filePath}`);
|
|
429
|
+
const newFm = fm[1].replace(/^status:.*$/m, `status: ${newStatus}`);
|
|
430
|
+
const newRaw = raw.replace(fm[1], newFm);
|
|
431
|
+
const tmp = filePath + '.tmp.' + process.pid;
|
|
432
|
+
fs.writeFileSync(tmp, newRaw, 'utf8');
|
|
433
|
+
fs.renameSync(tmp, filePath);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
process.stdout.write('Step 2.6c: rolling up parent statuses...\n');
|
|
437
|
+
try {
|
|
438
|
+
// Use __dirname-relative path so the import finds the ACTUAL built dist,
|
|
439
|
+
// not a fixture tmpdir override (CLEARGATE_REPO_ROOT may point elsewhere in tests).
|
|
440
|
+
const scriptRepoRoot26c = path.resolve(SCRIPTS_DIR, '..', '..');
|
|
441
|
+
const reconcilerMod26c = await import(
|
|
442
|
+
path.join(scriptRepoRoot26c, 'cleargate-cli', 'dist', 'lib', 'lifecycle-reconcile.js')
|
|
443
|
+
).catch(() => null);
|
|
444
|
+
|
|
445
|
+
if (!reconcilerMod26c || typeof reconcilerMod26c.walkActiveParents !== 'function') {
|
|
446
|
+
process.stdout.write('Step 2.6c skipped: walkActiveParents not in built CLI — rebuild cleargate-cli/.\n');
|
|
447
|
+
} else {
|
|
448
|
+
// Delivery paths come from REPO_ROOT (may be fixture tmpdir in tests)
|
|
449
|
+
const deliveryRoot26c = path.join(REPO_ROOT, '.cleargate', 'delivery');
|
|
450
|
+
const archiveRoot26c = path.join(deliveryRoot26c, 'archive');
|
|
451
|
+
const results26c = await reconcilerMod26c.walkActiveParents({
|
|
452
|
+
deliveryRoot: deliveryRoot26c,
|
|
453
|
+
archiveRoot: archiveRoot26c,
|
|
454
|
+
});
|
|
455
|
+
const flips26c = results26c.filter((r) => r.verdict === 'auto-flip');
|
|
456
|
+
const halts26c = results26c.filter(
|
|
457
|
+
(r) => r.verdict === 'halt-partial' || r.verdict === 'halt-zero-children',
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
for (const f of flips26c) {
|
|
461
|
+
setFrontmatterStatusAtomic(f.parent_path, 'Completed');
|
|
462
|
+
process.stdout.write(
|
|
463
|
+
`Step 2.6c: ${f.parent_id} status ${f.current_status} → Completed` +
|
|
464
|
+
` (${f.terminal_children.length}/${f.terminal_children.length} children Completed:` +
|
|
465
|
+
` ${f.terminal_children.join(', ')})\n`,
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (halts26c.length > 0) {
|
|
470
|
+
process.stderr.write(`Step 2.6c HALT: ${halts26c.length} parent(s) require manual ack:\n`);
|
|
471
|
+
for (const h of halts26c) {
|
|
472
|
+
process.stderr.write(` - [${h.verdict}] ${h.halt_reason}\n`);
|
|
473
|
+
}
|
|
474
|
+
process.exit(1);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
process.stdout.write(`Step 2.6c passed: ${flips26c.length} parent(s) auto-flipped; no halts.\n`);
|
|
478
|
+
}
|
|
479
|
+
} catch (e26c) {
|
|
480
|
+
process.stderr.write(`Step 2.6c warning: parent rollup unavailable: ${e26c.message}\n`);
|
|
481
|
+
}
|
|
482
|
+
|
|
410
483
|
// ── Step 2.7: Worktree-Closed Check (CR-022 M1) ──────────────────────────
|
|
411
484
|
// Block close if any .worktrees/STORY-* path is present.
|
|
412
485
|
// v2 enforcing (exit 1); v1 advisory (warn + continue).
|
|
@@ -31,7 +31,7 @@ parent_ref: "EPIC-{ID} | STORY-{ID}"
|
|
|
31
31
|
parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
|
|
32
32
|
sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
|
|
33
33
|
carry_over: false # set true to skip lifecycle reconciliation at sprint close
|
|
34
|
-
status: "Draft | Triaged | In Fix |
|
|
34
|
+
status: "Draft | Triaged | In Fix | Completed"
|
|
35
35
|
severity: "P0-Critical | P1-High | P2-Medium | P3-Low"
|
|
36
36
|
reporter: "{name}"
|
|
37
37
|
approved: false
|
|
@@ -31,7 +31,7 @@ parent_ref: "EPIC-{ID} | STORY-{ID}"
|
|
|
31
31
|
parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
|
|
32
32
|
sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
|
|
33
33
|
carry_over: false # set true to skip lifecycle reconciliation at sprint close
|
|
34
|
-
status: "Draft | In Review | Approved"
|
|
34
|
+
status: "Draft | In Review | Approved | Completed"
|
|
35
35
|
approved: false
|
|
36
36
|
created_at: "2026-04-17T00:00:00Z"
|
|
37
37
|
updated_at: "2026-04-17T00:00:00Z"
|
|
@@ -36,7 +36,7 @@ epic_id: "EPIC-{ID}"
|
|
|
36
36
|
parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
|
|
37
37
|
sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
|
|
38
38
|
carry_over: false # set true to skip lifecycle reconciliation at sprint close
|
|
39
|
-
status: "Draft"
|
|
39
|
+
status: "Draft" # lifecycle: Draft → Active → Completed
|
|
40
40
|
ambiguity: "🔴 High"
|
|
41
41
|
context_source: "PROPOSAL-{ID}.md"
|
|
42
42
|
owner: "{PM/PO name}"
|
|
@@ -32,7 +32,7 @@ hotfix_id: "{ID}"
|
|
|
32
32
|
parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
|
|
33
33
|
sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
|
|
34
34
|
carry_over: false # set true to skip lifecycle reconciliation at sprint close
|
|
35
|
-
status: "Draft"
|
|
35
|
+
status: "Draft" # lifecycle: Draft → In Fix → Completed
|
|
36
36
|
severity: "P2"
|
|
37
37
|
originating_signal: "user-report"
|
|
38
38
|
created_at: "{ISO}"
|
|
@@ -29,7 +29,7 @@ DO NOT output these instructions in the rendered file.
|
|
|
29
29
|
initiative_id: "INITIATIVE-{NNN}"
|
|
30
30
|
remote_id: null
|
|
31
31
|
source_tool: "linear | jira | github | manual-paste"
|
|
32
|
-
status: "{PM native status — e.g. Discovery, In Triage, Triaged}"
|
|
32
|
+
status: "{PM native status — e.g. Discovery, In Triage, Triaged, Completed}"
|
|
33
33
|
synced_at: null
|
|
34
34
|
triaged_at: null
|
|
35
35
|
spawned_items: []
|
|
@@ -46,7 +46,7 @@ template_version: 2
|
|
|
46
46
|
Each CR:bug and UR:bug counts toward Bug-Fix Tax (§3). CR:scope-change increments arch_bounces. -->
|
|
47
47
|
|
|
48
48
|
### STORY-NNN-NN: <Title>
|
|
49
|
-
- **Status:**
|
|
49
|
+
- **Status:** Completed | Escalated | Parking Lot | Carried Over
|
|
50
50
|
- **Complexity:** L<n>
|
|
51
51
|
- **Commit:** `<sha>`
|
|
52
52
|
- **Bounce count:** qa=N arch=N total=N
|
|
@@ -59,7 +59,7 @@ parent_epic_ref: "EPIC-{ID}"
|
|
|
59
59
|
parent_cleargate_id: null # canonical cleargate-id of parent work item; null for top-level
|
|
60
60
|
sprint_cleargate_id: null # canonical cleargate-id of owning sprint; null for off-sprint items
|
|
61
61
|
carry_over: false # set true to skip lifecycle reconciliation at sprint close
|
|
62
|
-
status: "Draft"
|
|
62
|
+
status: "Draft" # lifecycle: Draft → In Review → Completed
|
|
63
63
|
ambiguity: "🔴 High"
|
|
64
64
|
context_source: "PROPOSAL-{ID}.md"
|
|
65
65
|
actor: "{Persona Name}"
|
|
@@ -55,6 +55,8 @@ This repository uses **ClearGate** — a standalone planning framework for AI co
|
|
|
55
55
|
|
|
56
56
|
**Codebase / PM-Tool Boundary (EPIC-027).** `cleargate-cli/src/**` and `.claude/**` MUST NOT import any PM-tool SDK (`@linear/sdk`, `jira-client`, `azure-devops`, `@atlassian/`, `linear-sdk`, `node-jira-client`, `jira.js`). PM-tool adapters live exclusively in `mcp/src/adapters/`; credentials live in admin DB rows. The type-and-payload contract (open-type validator, KNOWN_TYPES, RESERVED_PAYLOAD_KEYS, `payload.origin`, `cleargate_id` formats, L1 errorCode + L2 warningCode taxonomies) is fully documented in `.cleargate/knowledge/cleargate-protocol.md` §Type & Payload Contract and §Codebase/PM-Tool Boundary. CI enforcement: `npm run check:no-pm-sdk` (exits non-zero on any forbidden import). Target repos that ran `cleargate init` before SPRINT-27 should re-run `cleargate init` to pick up this boundary rule in their local bounded block.
|
|
57
57
|
|
|
58
|
+
**Single test runner (EPIC-028).** All three packages (mcp/, cleargate-cli/, admin/) use node:test exclusively — vitest is fully eliminated as of 2026-05-18. File naming: `*.node.test.ts`. Run via `tsx --test` (mcp/, cleargate-cli/) or `node --conditions browser --import tsx tests/run-tests.mjs` (admin/). The `--conditions browser` flag is required for admin/ — it enables jsdom-bootstrap via `setup-node-test.mjs`. Adding vitest back is forbidden; `check:no-vitest` pre-commit guard enforces this.
|
|
59
|
+
|
|
58
60
|
**Project overrides.** Content OUTSIDE this `<!-- CLEARGATE:START -->...<!-- CLEARGATE:END -->` block takes precedence where it conflicts with ClearGate defaults.
|
|
59
61
|
|
|
60
62
|
**Scope reminder.** ClearGate is a *planning* framework. It scaffolds how work gets planned and how the four-agent loop runs. It does not replace your project's build system, CI, test runner, or deployment tooling.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cleargate_version": "0.
|
|
3
|
-
"generated_at": "2026-05-
|
|
2
|
+
"cleargate_version": "0.13.0",
|
|
3
|
+
"generated_at": "2026-05-18T17:11:10.027Z",
|
|
4
4
|
"files": [
|
|
5
5
|
{
|
|
6
6
|
"path": ".claude/agents/architect.md",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": ".claude/agents/cleargate-wiki-lint.md",
|
|
28
|
-
"sha256": "
|
|
28
|
+
"sha256": "2a9212d81df9a68e167ec7a18093a73c6da0208f13685c6887d5bd832b56fb3d",
|
|
29
29
|
"tier": "agent",
|
|
30
30
|
"overwrite_policy": "always",
|
|
31
31
|
"preserve_on_uninstall": false
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"path": ".claude/agents/developer.md",
|
|
42
|
-
"sha256": "
|
|
42
|
+
"sha256": "db7963778d68654f2dc96658d60433fa79305a10eec937807f2f0ed0cd05ce89",
|
|
43
43
|
"tier": "agent",
|
|
44
44
|
"overwrite_policy": "always",
|
|
45
45
|
"preserve_on_uninstall": false
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"path": ".claude/hooks/pre-commit-surface-gate.sh",
|
|
77
|
-
"sha256": "
|
|
77
|
+
"sha256": "8dd817fbe75ee53753e2fe1fc2ccd2b6efdb2b3c0b6ad3191bebd9640afdd6f8",
|
|
78
78
|
"tier": "hook",
|
|
79
79
|
"overwrite_policy": "always",
|
|
80
80
|
"preserve_on_uninstall": false
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"path": ".cleargate/scripts/close_sprint.mjs",
|
|
203
|
-
"sha256": "
|
|
203
|
+
"sha256": "b14b65f15c5ad57a845df89c069b5417195651b7d3aa7f7f5736416d0db0b868",
|
|
204
204
|
"tier": "script",
|
|
205
205
|
"overwrite_policy": "always",
|
|
206
206
|
"preserve_on_uninstall": false
|
|
@@ -396,35 +396,35 @@
|
|
|
396
396
|
},
|
|
397
397
|
{
|
|
398
398
|
"path": ".cleargate/templates/Bug.md",
|
|
399
|
-
"sha256": "
|
|
399
|
+
"sha256": "cebca344b6b820525c603444cf52626e120ebaa1ac28da099dc19c9cff39302c",
|
|
400
400
|
"tier": "template",
|
|
401
401
|
"overwrite_policy": "merge-3way",
|
|
402
402
|
"preserve_on_uninstall": false
|
|
403
403
|
},
|
|
404
404
|
{
|
|
405
405
|
"path": ".cleargate/templates/CR.md",
|
|
406
|
-
"sha256": "
|
|
406
|
+
"sha256": "ea5acf2087808e0d52806a87a6a7f1ced7473b591857f322fab5285adc80d25a",
|
|
407
407
|
"tier": "template",
|
|
408
408
|
"overwrite_policy": "merge-3way",
|
|
409
409
|
"preserve_on_uninstall": false
|
|
410
410
|
},
|
|
411
411
|
{
|
|
412
412
|
"path": ".cleargate/templates/epic.md",
|
|
413
|
-
"sha256": "
|
|
413
|
+
"sha256": "f9cf44db19288f0756b76bc8b13a075d4089990324db6febd072f5cf93d59cd0",
|
|
414
414
|
"tier": "template",
|
|
415
415
|
"overwrite_policy": "merge-3way",
|
|
416
416
|
"preserve_on_uninstall": false
|
|
417
417
|
},
|
|
418
418
|
{
|
|
419
419
|
"path": ".cleargate/templates/hotfix.md",
|
|
420
|
-
"sha256": "
|
|
420
|
+
"sha256": "de788497b4d224500036773f854801c056d73b08c3c0d66fdb641f17a1610bca",
|
|
421
421
|
"tier": "template",
|
|
422
422
|
"overwrite_policy": "merge-3way",
|
|
423
423
|
"preserve_on_uninstall": false
|
|
424
424
|
},
|
|
425
425
|
{
|
|
426
426
|
"path": ".cleargate/templates/initiative.md",
|
|
427
|
-
"sha256": "
|
|
427
|
+
"sha256": "1170e595f5813c62f86212d6ca1955d84465f396c81aaf34498b8e2d4595d681",
|
|
428
428
|
"tier": "template",
|
|
429
429
|
"overwrite_policy": "merge-3way",
|
|
430
430
|
"preserve_on_uninstall": false
|
|
@@ -445,14 +445,14 @@
|
|
|
445
445
|
},
|
|
446
446
|
{
|
|
447
447
|
"path": ".cleargate/templates/sprint_report.md",
|
|
448
|
-
"sha256": "
|
|
448
|
+
"sha256": "5914d54080f6110be5a5e905e3312811f3d0f80978121b1e15707d5be05cc5b1",
|
|
449
449
|
"tier": "template",
|
|
450
450
|
"overwrite_policy": "merge-3way",
|
|
451
451
|
"preserve_on_uninstall": false
|
|
452
452
|
},
|
|
453
453
|
{
|
|
454
454
|
"path": ".cleargate/templates/story.md",
|
|
455
|
-
"sha256": "
|
|
455
|
+
"sha256": "0badf01a080bca552a06fb64becd9b8c88fbf104e30f32667263522c3ff81051",
|
|
456
456
|
"tier": "template",
|
|
457
457
|
"overwrite_policy": "merge-3way",
|
|
458
458
|
"preserve_on_uninstall": false
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/lifecycle-reconcile.ts","../src/wiki/parse-frontmatter.ts"],"sourcesContent":["/**\n * lifecycle-reconcile.ts — CR-017 Lifecycle Status Reconciliation + Decomposition Gate\n *\n * Public API:\n * reconcileLifecycle(opts) → { drift: DriftItem[], clean: number }\n * reconcileDecomposition(opts) → { missing: MissingDecomp[], clean: number }\n * parseCommitMessage(msg) → Array<{ verb, id, type }>\n * VERB_STATUS_MAP — verb-to-expected-status table\n *\n * TERMINAL_STATES referenced from .cleargate/scripts/constants.mjs:45.\n * Do NOT redefine; duplicate literal with source citation.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\nimport { parseFrontmatter } from '../wiki/parse-frontmatter.js';\n\n// ─── Constants ─────────────────────────────────────────────────────────────────\n\n/**\n * Terminal statuses for artifact lifecycle.\n * Source: .cleargate/scripts/constants.mjs:45 TERMINAL_STATES.\n * NOTE: These are the *artifact* terminal statuses (Done, Completed, Verified, etc.),\n * not state.json story states (Done, Escalated, Parking Lot).\n */\nexport const ARTIFACT_TERMINAL_STATUSES = new Set([\n 'Done',\n 'Completed',\n 'Verified',\n 'Abandoned',\n 'Closed',\n 'Resolved',\n 'Escalated',\n 'Parking Lot',\n]);\n\n/**\n * Verb-to-expected-status map (v1).\n * Key: verb pattern (lower-case), Value: { types, expected }.\n * types: which artifact types this verb applies to.\n * expected: accepted terminal statuses for this verb.\n */\nexport const VERB_STATUS_MAP: Readonly<Record<string, { types: string[]; expected: string[] }>> = {\n feat: {\n types: ['STORY', 'EPIC', 'CR'],\n expected: ['Done', 'Completed'],\n },\n fix: {\n types: ['BUG', 'HOTFIX'],\n expected: ['Verified', 'Done', 'Completed'],\n },\n};\n\n// ─── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface DriftItem {\n id: string;\n type: 'STORY' | 'CR' | 'BUG' | 'EPIC' | 'PROPOSAL' | 'HOTFIX';\n expected_status: string;\n actual_status: string | null;\n file_path: string | null;\n in_archive: boolean;\n commit_shas: string[];\n carry_over: boolean;\n}\n\nexport interface ReconcileLifecycleResult {\n drift: DriftItem[];\n clean: number;\n}\n\nexport interface ReconcileLifecycleOpts {\n since: Date;\n until?: Date;\n deliveryRoot: string;\n repoRoot: string;\n /** Test seam: replace spawnSync git calls */\n gitRunner?: (cmd: string, args: string[]) => string;\n}\n\nexport interface MissingDecomp {\n id: string;\n type: 'epic' | 'proposal';\n reason: 'no-child-stories' | 'no-decomposed-epic' | 'file-missing';\n expected_files: string[];\n}\n\nexport interface ReconcileDecompositionResult {\n missing: MissingDecomp[];\n clean: number;\n}\n\nexport interface ReconcileDecompositionOpts {\n sprintPlanPath: string;\n deliveryRoot: string;\n}\n\n// ─── ID shape regex (longest-alternative-first per BUG-010 + assert_story_files.mjs) ──\n\nconst ID_PATTERN = /\\b(STORY-\\d{3}-\\d{2}|(CR|BUG|EPIC|HOTFIX)-\\d{3}|(PROPOSAL|PROP)-\\d{3})\\b/g;\n\n/** Artifact type names recognized by the reconciler */\ntype ArtifactType = 'STORY' | 'CR' | 'BUG' | 'EPIC' | 'PROPOSAL' | 'HOTFIX';\n\nfunction normalizeId(raw: string): string {\n // PROP-NNN → PROPOSAL-NNN (BUG-009 lesson)\n return raw.replace(/^PROP-(\\d+)$/, 'PROPOSAL-$1');\n}\n\nfunction idType(id: string): ArtifactType | null {\n if (/^STORY-\\d{3}-\\d{2}$/.test(id)) return 'STORY';\n if (/^CR-\\d{3}$/.test(id)) return 'CR';\n if (/^BUG-\\d{3}$/.test(id)) return 'BUG';\n if (/^EPIC-\\d{3}$/.test(id)) return 'EPIC';\n if (/^PROPOSAL-\\d{3}$/.test(id)) return 'PROPOSAL';\n if (/^HOTFIX-\\d{3}$/.test(id)) return 'HOTFIX';\n return null;\n}\n\n// ─── parseCommitMessage ────────────────────────────────────────────────────────\n\n/**\n * Parse a commit message (subject + optional first body line) for work-item IDs.\n * Returns one entry per ID found with the verb inferred from conventional prefix.\n *\n * commit format: `<verb>(<scope>): <description>\\n\\n<body>`\n * multi-ID: `fix(cli)!: BUG-001 fix + CR-001 align`\n * merge: `merge: STORY-001-01 → main`\n */\nexport function parseCommitMessage(\n msg: string,\n): Array<{ verb: string; id: string; type: string }> {\n const lines = msg.split('\\n');\n const subject = lines[0] ?? '';\n\n // First non-empty body line (if any) after the blank separator\n let firstBodyLine = '';\n for (let i = 1; i < lines.length; i++) {\n if (lines[i]?.trim()) {\n firstBodyLine = lines[i]!;\n break;\n }\n }\n\n // Extract verb from subject: `feat(...)`, `fix(...)`, `merge:`, `chore(...)`, etc.\n const verbMatch = /^(\\w+)[(!]/.exec(subject) ?? /^(\\w+):/.exec(subject);\n const verb = verbMatch ? verbMatch[1]!.toLowerCase() : '';\n\n // Scan subject + first body line for IDs\n const searchText = subject + (firstBodyLine ? '\\n' + firstBodyLine : '');\n const results: Array<{ verb: string; id: string; type: string }> = [];\n const seen = new Set<string>();\n\n let m: RegExpExecArray | null;\n ID_PATTERN.lastIndex = 0;\n while ((m = ID_PATTERN.exec(searchText)) !== null) {\n const rawId = m[0]!;\n const id = normalizeId(rawId);\n if (seen.has(id)) continue;\n seen.add(id);\n const type = idType(id);\n if (!type) continue;\n results.push({ verb, id, type });\n }\n\n return results;\n}\n\n// ─── File finders ─────────────────────────────────────────────────────────────\n\ninterface FoundFile {\n absPath: string;\n inArchive: boolean;\n relPath: string; // relative to deliveryRoot\n}\n\nfunction findArtifactFile(deliveryRoot: string, id: string): FoundFile | null {\n const prefix = `${id}_`;\n const dirs: Array<{ rel: string; inArchive: boolean }> = [\n { rel: 'pending-sync', inArchive: false },\n { rel: 'archive', inArchive: true },\n ];\n for (const { rel, inArchive } of dirs) {\n const dir = path.join(deliveryRoot, rel);\n let entries: string[];\n try {\n entries = fs.readdirSync(dir);\n } catch {\n continue;\n }\n // match `ID_*.md` OR `ID.md`\n const match = entries.find(\n (e) => (e.startsWith(prefix) || e === `${id}.md`) && e.endsWith('.md'),\n );\n if (match) {\n const absPath = path.join(dir, match);\n return { absPath, inArchive, relPath: `${rel}/${match}` };\n }\n }\n return null;\n}\n\nfunction readArtifactStatus(absPath: string): { status: string | null; carryOver: boolean } {\n let raw: string;\n try {\n raw = fs.readFileSync(absPath, 'utf8');\n } catch {\n return { status: null, carryOver: false };\n }\n try {\n const { fm } = parseFrontmatter(raw);\n const status = typeof fm['status'] === 'string' ? fm['status'] : null;\n const carryOver = fm['carry_over'] === true;\n return { status, carryOver };\n } catch {\n return { status: null, carryOver: false };\n }\n}\n\n// ─── reconcileLifecycle ────────────────────────────────────────────────────────\n\n/**\n * Scan git log in [since, until] range and reconcile artifact statuses.\n *\n * For each commit touching feat/fix verbs with IDs:\n * - Find the artifact file in pending-sync or archive\n * - Check if status is at expected terminal status\n * - Report drift items for non-terminal artifacts\n * - Skip artifacts with carry_over: true\n */\nexport function reconcileLifecycle(opts: ReconcileLifecycleOpts): ReconcileLifecycleResult {\n const { since, until = new Date(), deliveryRoot, repoRoot } = opts;\n\n const gitRunner =\n opts.gitRunner ??\n ((cmd: string, args: string[]) => {\n const result = spawnSync(cmd, args, { encoding: 'utf8', cwd: repoRoot });\n return (result.stdout ?? '') as string;\n });\n\n // git log --format=\"%H %s%n%b%n---COMMIT---\" --after=<since> --before=<until>\n const sinceIso = since.toISOString();\n const untilIso = until.toISOString();\n const logOutput = gitRunner('git', [\n 'log',\n `--after=${sinceIso}`,\n `--before=${untilIso}`,\n '--format=%H%x00%s%x00%b%x00---COMMIT---',\n '--',\n ]);\n\n // Map: id → DriftItem (accumulates SHAs for bundled-commit grouping)\n // We track each id independently; bundled-commit = multiple SHAs per id\n const idToItem = new Map<string, DriftItem>();\n // Track ids that were found CLEAN (fully reconciled)\n const cleanIds = new Set<string>();\n\n if (logOutput.trim()) {\n // Split by commit separator\n const rawCommits = logOutput.split('---COMMIT---\\n').filter((c) => c.trim());\n\n for (const raw of rawCommits) {\n // Each commit entry: sha\\0subject\\0body\\0\n const [sha = '', subject = '', body = ''] = raw.split('\\x00');\n const trimSha = sha.trim();\n const trimSubject = subject.trim();\n const trimBody = body.trim();\n\n if (!trimSha || !trimSubject) continue;\n\n const commitMsg = trimSubject + (trimBody ? '\\n\\n' + trimBody : '');\n const parsed = parseCommitMessage(commitMsg);\n\n for (const { verb, id, type } of parsed) {\n // Skip merge, chore, docs, refactor, test, file, plan verbs (no expectation)\n if (verb === 'merge' || verb === 'chore' || verb === 'docs' || verb === 'refactor'\n || verb === 'test' || verb === 'file' || verb === 'plan') {\n continue;\n }\n\n // Skip PROPOSAL types — proposals aren't shipped via feat/fix commits\n if (type === 'PROPOSAL') continue;\n\n const verbConfig = VERB_STATUS_MAP[verb];\n if (!verbConfig) continue;\n\n // Verb mismatch: feat(BUG-NNN) → soft warning only, handled at call site\n // We still need to find the file and check status for the call site to report\n\n // Find the artifact file\n const found = findArtifactFile(deliveryRoot, id);\n if (!found) {\n // Unknown ID — log once at info level (no drift)\n // We skip unknown IDs (no file found); call site logs info\n continue;\n }\n\n // Read status + carry_over from CURRENT frontmatter\n const { status, carryOver } = readArtifactStatus(found.absPath);\n\n // carry_over: true → skip silently\n if (carryOver) continue;\n\n // Determine expected statuses for this (verb, type) pair\n let expectedStatuses: string[];\n if (verb === 'feat' && type === 'BUG') {\n // verb mismatch — soft warning, does not block; still check status\n // Use 'Verified' as expected for BUG even with feat verb\n expectedStatuses = ['Verified', 'Done', 'Completed'];\n } else if (!verbConfig.types.includes(type)) {\n // Type not covered by this verb's map — skip\n continue;\n } else {\n expectedStatuses = verbConfig.expected;\n }\n\n const isTerminal = status !== null && expectedStatuses.includes(status);\n const isArchived = found.inArchive;\n\n if (isTerminal && isArchived) {\n // Clean\n cleanIds.add(id);\n // If we previously recorded drift for this id (from another commit), remove it\n // (Most recent status check wins — carry_over already handled above)\n idToItem.delete(id);\n } else if (!idToItem.has(id)) {\n // New drift item\n const expectedStr = expectedStatuses[0] ?? 'Done';\n idToItem.set(id, {\n id,\n type: type as DriftItem['type'],\n expected_status: expectedStr,\n actual_status: status,\n file_path: found.relPath,\n in_archive: isArchived,\n commit_shas: [trimSha],\n carry_over: carryOver,\n });\n } else {\n // Existing drift item — add SHA if not already present\n const existing = idToItem.get(id)!;\n if (!existing.commit_shas.includes(trimSha)) {\n existing.commit_shas.push(trimSha);\n }\n }\n }\n }\n }\n\n // Remove from drift any IDs that ended up in cleanIds\n for (const id of cleanIds) {\n idToItem.delete(id);\n }\n\n const drift = Array.from(idToItem.values());\n return { drift, clean: cleanIds.size };\n}\n\n// ─── reconcileCrossSprintOrphans ──────────────────────────────────────────────\n\n/**\n * Orphan drift item: a file in pending-sync/ with a non-terminal status\n * that has been marked Done (or another terminal state) in a closed sprint's\n * state.json — indicating it was completed but never archived.\n */\nexport interface OrphanDriftItem {\n id: string;\n type: 'CR' | 'STORY' | 'BUG' | 'EPIC' | 'HOTFIX';\n pending_sync_status: string;\n state_json_state: string;\n state_json_sprint: string;\n file_path: string;\n}\n\nexport interface ReconcileOrphansOpts {\n /** Path to .cleargate/delivery */\n deliveryRoot: string;\n /** Path to .cleargate/sprint-runs */\n sprintRunsRoot: string;\n}\n\nexport interface ReconcileOrphansResult {\n drift: OrphanDriftItem[];\n clean: number;\n}\n\n/**\n * Detect cross-sprint orphan drift: items in pending-sync/ with status: Ready\n * (or any non-terminal status) that are recorded as Done in a closed sprint's\n * state.json. These were completed but never archived at sprint close.\n *\n * Active-sprint exclusion: reads .active sentinel to identify the current\n * sprint and skips that sprint's state.json (in-flight items are not orphans).\n *\n * Scope: only scans pending-sync/*.md files matching the work-item-ID pattern.\n * Does NOT scan .script-incidents/ or any subdirectory.\n */\nexport function reconcileCrossSprintOrphans(opts: ReconcileOrphansOpts): ReconcileOrphansResult {\n const { deliveryRoot, sprintRunsRoot } = opts;\n\n // Terminal states from state.json (story-level states, not artifact statuses)\n const TERMINAL_STATE_JSON = new Set(['Done', 'Escalated', 'Parking Lot']);\n\n // Read the active sprint sentinel (to exclude it from orphan detection)\n let activeSprintId: string | null = null;\n try {\n activeSprintId = fs.readFileSync(path.join(sprintRunsRoot, '.active'), 'utf8').trim();\n } catch {\n // No .active file — no active sprint; scan all sprints\n }\n\n // Collect all pending-sync *.md files (no subdirectory traversal)\n const pendingDir = path.join(deliveryRoot, 'pending-sync');\n let pendingFiles: string[];\n try {\n pendingFiles = fs.readdirSync(pendingDir).filter(\n (f) => f.endsWith('.md') && !f.startsWith('.'),\n );\n } catch {\n pendingFiles = [];\n }\n\n // Build a map: id → { status, filePath } for each pending-sync item\n interface PendingItem {\n status: string;\n filePath: string;\n type: OrphanDriftItem['type'];\n }\n const pendingMap = new Map<string, PendingItem>();\n\n for (const fileName of pendingFiles) {\n const absPath = path.join(pendingDir, fileName);\n const { status } = readArtifactStatus(absPath);\n if (status === null) continue;\n // Skip already-terminal items in pending-sync (shouldn't be there but be safe)\n if (ARTIFACT_TERMINAL_STATUSES.has(status)) continue;\n\n // Extract ID from filename: filenames use <ID>_<slug>.md or <ID>.md format.\n // ID_PATTERN uses \\b word-boundaries which don't fire between a digit and '_'\n // (since '_' is a word char), so we extract the prefix before the first '_' or '.'.\n const fileNameNoExt = fileName.endsWith('.md') ? fileName.slice(0, -3) : fileName;\n const prefixPart = fileNameNoExt.split('_')[0] ?? fileNameNoExt;\n const rawId = prefixPart;\n const id = normalizeId(rawId);\n const type = idType(id);\n if (!type || type === 'PROPOSAL') continue;\n\n pendingMap.set(id, {\n status,\n filePath: path.join('pending-sync', fileName),\n type: type as OrphanDriftItem['type'],\n });\n }\n\n if (pendingMap.size === 0) {\n return { drift: [], clean: 0 };\n }\n\n // Walk sprint-runs directories for state.json files\n let sprintDirs: string[];\n try {\n sprintDirs = fs.readdirSync(sprintRunsRoot).filter((entry) => {\n // Skip the .active sentinel file and any hidden files\n if (entry.startsWith('.')) return false;\n // Skip non-directories (e.g. files in root)\n try {\n return fs.statSync(path.join(sprintRunsRoot, entry)).isDirectory();\n } catch {\n return false;\n }\n });\n } catch {\n sprintDirs = [];\n }\n\n const drift: OrphanDriftItem[] = [];\n // Track which IDs we've flagged to avoid duplicates (first sprint that shows Done wins)\n const flagged = new Set<string>();\n let clean = 0;\n\n for (const sprintDir of sprintDirs) {\n // Skip the active sprint\n if (activeSprintId && sprintDir === activeSprintId) continue;\n\n const stateFile = path.join(sprintRunsRoot, sprintDir, 'state.json');\n let stateJson: Record<string, unknown>;\n try {\n const raw = fs.readFileSync(stateFile, 'utf8');\n stateJson = JSON.parse(raw) as Record<string, unknown>;\n } catch {\n continue;\n }\n\n const stories = stateJson['stories'] as Record<string, { state: string }> | undefined;\n if (!stories || typeof stories !== 'object') continue;\n\n for (const [id, storyEntry] of Object.entries(stories)) {\n // Skip if already flagged from an earlier sprint\n if (flagged.has(id)) continue;\n\n const pending = pendingMap.get(id);\n if (!pending) continue; // not in pending-sync\n\n const stateInJson = storyEntry?.state ?? '';\n if (TERMINAL_STATE_JSON.has(stateInJson)) {\n // This item is Done in a closed sprint but still in pending-sync — orphan drift\n flagged.add(id);\n drift.push({\n id,\n type: pending.type,\n pending_sync_status: pending.status,\n state_json_state: stateInJson,\n state_json_sprint: sprintDir,\n file_path: pending.filePath,\n });\n } else {\n // Item is in pending-sync AND in state.json but NOT terminal — correctly in-flight\n clean++;\n }\n }\n }\n\n return { drift, clean };\n}\n\n// ─── reconcileDecomposition ───────────────────────────────────────────────────\n\n/**\n * Read the sprint plan's epics: and proposals: frontmatter arrays and verify\n * that each referenced epic has ≥1 child story file, and each proposal has\n * a decomposed epic.\n */\nexport function reconcileDecomposition(opts: ReconcileDecompositionOpts): ReconcileDecompositionResult {\n const { sprintPlanPath, deliveryRoot } = opts;\n\n // Parse sprint plan frontmatter\n let raw: string;\n try {\n raw = fs.readFileSync(sprintPlanPath, 'utf8');\n } catch {\n return { missing: [], clean: 0 };\n }\n\n let fm: Record<string, unknown>;\n try {\n ({ fm } = parseFrontmatter(raw));\n } catch {\n return { missing: [], clean: 0 };\n }\n\n const epics: string[] = Array.isArray(fm['epics']) ? fm['epics'].map(String) : [];\n const proposals: string[] = Array.isArray(fm['proposals']) ? fm['proposals'].map(String) : [];\n\n const pendingDir = path.join(deliveryRoot, 'pending-sync');\n const archiveDir = path.join(deliveryRoot, 'archive');\n\n // Read both dirs for all .md files\n function listMdFiles(dir: string): string[] {\n try {\n return fs.readdirSync(dir).filter((f) => f.endsWith('.md'));\n } catch {\n return [];\n }\n }\n const pendingFiles = listMdFiles(pendingDir);\n const archiveFiles = listMdFiles(archiveDir);\n const allFiles = [...pendingFiles, ...archiveFiles];\n\n const missing: MissingDecomp[] = [];\n let clean = 0;\n\n // Check epics\n for (const epicId of epics) {\n // Find the epic file\n const epicFile = allFiles.find(\n (f) => f.startsWith(`${epicId}_`) || f === `${epicId}.md`,\n );\n if (!epicFile) {\n missing.push({\n id: epicId,\n type: 'epic',\n reason: 'file-missing',\n expected_files: [`pending-sync/${epicId}_<name>.md`],\n });\n continue;\n }\n\n // Find child stories: any STORY-*.md with parent_epic_ref: epicId\n const childStories = findChildStories(\n epicId,\n pendingDir,\n pendingFiles,\n archiveDir,\n archiveFiles,\n );\n\n if (childStories.length === 0) {\n missing.push({\n id: epicId,\n type: 'epic',\n reason: 'no-child-stories',\n expected_files: [\n `pending-sync/${epicId.replace('EPIC-', 'STORY-')}-01_<name>.md`,\n ],\n });\n } else {\n clean++;\n }\n }\n\n // Check proposals\n for (const proposalId of proposals) {\n // Find a decomposed epic that cites this proposal in context_source\n const decomposedEpic = findDecomposedEpic(\n proposalId,\n pendingDir,\n pendingFiles,\n );\n if (!decomposedEpic) {\n missing.push({\n id: proposalId,\n type: 'proposal',\n reason: 'no-decomposed-epic',\n expected_files: [`pending-sync/EPIC-<NNN>_<name>.md with context_source citing ${proposalId}`],\n });\n } else {\n clean++;\n }\n }\n\n return { missing, clean };\n}\n\n/**\n * Find story files in pending-sync or archive that have parent_epic_ref: epicId.\n */\nfunction findChildStories(\n epicId: string,\n pendingDir: string,\n pendingFiles: string[],\n archiveDir: string,\n archiveFiles: string[],\n): string[] {\n const results: string[] = [];\n const epicNumMatch = /^EPIC-(\\d+)$/.exec(epicId);\n if (!epicNumMatch) return results;\n const epicNum = epicNumMatch[1]!;\n\n const storyPrefix = `STORY-${epicNum}-`;\n\n for (const [files, dir] of [[pendingFiles, pendingDir], [archiveFiles, archiveDir]] as const) {\n for (const f of files) {\n if (!f.startsWith(storyPrefix) && !f.startsWith('STORY-')) continue;\n // Quick filename match first\n if (!f.includes(storyPrefix)) continue;\n const absPath = path.join(dir, f);\n try {\n const raw = fs.readFileSync(absPath, 'utf8');\n const { fm } = parseFrontmatter(raw);\n const parentRef = fm['parent_epic_ref'];\n if (parentRef === epicId) {\n results.push(f);\n }\n } catch {\n // skip malformed files\n }\n }\n }\n return results;\n}\n\n/**\n * Find an epic file in pending-sync whose context_source cites proposalId.\n */\nfunction findDecomposedEpic(\n proposalId: string,\n pendingDir: string,\n pendingFiles: string[],\n): string | null {\n for (const f of pendingFiles) {\n if (!f.startsWith('EPIC-')) continue;\n const absPath = path.join(pendingDir, f);\n try {\n const raw = fs.readFileSync(absPath, 'utf8');\n const { fm } = parseFrontmatter(raw);\n const contextSource = fm['context_source'];\n if (\n typeof contextSource === 'string' &&\n contextSource.includes(proposalId)\n ) {\n return f;\n }\n } catch {\n // skip\n }\n }\n return null;\n}\n\n// ─── Verb mismatch checker (exported for test use) ────────────────────────────\n\n/**\n * Check if a (verb, type) combination is a mismatch (soft warning only in v1).\n * Returns a warning message or null if no mismatch.\n */\nexport function checkVerbMismatch(verb: string, type: string): string | null {\n if (verb === 'feat' && type === 'BUG') {\n return `verb 'feat' unusual for BUG; expected 'fix'`;\n }\n if (verb === 'fix' && (type === 'STORY' || type === 'EPIC' || type === 'CR')) {\n return `verb 'fix' unusual for ${type}; expected 'feat'`;\n }\n return null;\n}\n","/**\n * YAML frontmatter parser backed by js-yaml with CORE_SCHEMA (YAML 1.2 core).\n *\n * Parses `---\\n<yaml>\\n---\\n<body>` into a typed frontmatter map + body string.\n * Preserves native types (null, boolean, number, string), nested maps, and\n * arrays. Uses CORE_SCHEMA so ISO-8601 timestamp strings are NOT coerced to\n * Date objects (YAML 1.1's quirk).\n *\n * Historical note: an earlier hand-rolled parser flattened indented nested\n * maps into top-level keys and stringified null/boolean scalars. See\n * BUG-001 and FLASHCARD entry `#yaml #frontmatter`.\n */\n\nimport yaml from 'js-yaml';\n\nexport function parseFrontmatter(raw: string): { fm: Record<string, unknown>; body: string } {\n const lines = raw.split('\\n');\n if (lines[0] !== '---') {\n throw new Error('parseFrontmatter: input does not start with ---');\n }\n let closeIdx = -1;\n for (let i = 1; i < lines.length; i++) {\n if (lines[i] === '---') { closeIdx = i; break; }\n }\n if (closeIdx === -1) {\n throw new Error('parseFrontmatter: missing closing ---');\n }\n\n const yamlText = lines.slice(1, closeIdx).join('\\n');\n const bodyLines = lines.slice(closeIdx + 1);\n // strip one leading blank line if present\n if (bodyLines[0] === '') bodyLines.shift();\n const body = bodyLines.join('\\n');\n\n if (yamlText.trim() === '') {\n return { fm: {}, body };\n }\n\n let parsed: unknown;\n try {\n parsed = yaml.load(yamlText, { schema: yaml.CORE_SCHEMA });\n } catch (err) {\n throw new Error(`parseFrontmatter: invalid YAML: ${(err as Error).message}`);\n }\n\n if (parsed === null || parsed === undefined) {\n return { fm: {}, body };\n }\n if (typeof parsed !== 'object' || Array.isArray(parsed)) {\n throw new Error('parseFrontmatter: frontmatter is not a YAML mapping');\n }\n\n return { fm: parsed as Record<string, unknown>, body };\n}\n"],"mappings":";;;AAaA,YAAY,QAAQ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