cleargate 0.2.0 → 0.3.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/LICENSE +21 -0
- package/dist/MANIFEST.json +59 -17
- package/dist/admin-api/index.cjs +88 -1
- package/dist/admin-api/index.cjs.map +1 -1
- package/dist/admin-api/index.d.cts +105 -1
- package/dist/admin-api/index.d.ts +105 -1
- package/dist/admin-api/index.js +77 -1
- package/dist/admin-api/index.js.map +1 -1
- package/dist/bootstrap-root-FGWDICDT.js +130 -0
- package/dist/bootstrap-root-FGWDICDT.js.map +1 -0
- package/dist/chunk-OM4FAEA7.js +184 -0
- package/dist/chunk-OM4FAEA7.js.map +1 -0
- package/dist/cli.cjs +7995 -3984
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4062 -561
- package/dist/cli.js.map +1 -1
- package/dist/templates/cleargate-planning/.claude/agents/architect.md +72 -0
- package/dist/templates/cleargate-planning/.claude/agents/developer.md +45 -3
- package/dist/templates/cleargate-planning/.claude/agents/qa.md +7 -3
- package/dist/templates/cleargate-planning/.claude/agents/reporter.md +72 -75
- package/dist/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +204 -0
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +10 -0
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-test-ratchet.sh +58 -0
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit.sh +19 -0
- package/dist/templates/cleargate-planning/.claude/hooks/session-start.sh +51 -0
- package/dist/templates/cleargate-planning/.claude/hooks/token-ledger.sh +1 -1
- package/dist/templates/cleargate-planning/.claude/settings.json +11 -0
- package/dist/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +31 -12
- package/dist/templates/cleargate-planning/.cleargate/FLASHCARD.md +2 -1
- package/dist/templates/cleargate-planning/.cleargate/config.example.yml +37 -0
- package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +407 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +146 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +250 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/constants.mjs +57 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/file_surface_diff.sh +320 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +15 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/init_gate_config.sh +38 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +187 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +132 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +307 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/prefill_report.mjs +280 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/run_script.sh +123 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/state.schema.json +110 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +247 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/surface-whitelist.txt +27 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_assert_story_files.sh +261 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_file_surface.sh +210 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +190 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_test_ratchet.sh +327 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test_ratchet.mjs +261 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/update_state.mjs +154 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/validate_bounce_readiness.mjs +111 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +164 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +29 -3
- package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/proposal.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/sprint_context.md +42 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/sprint_report.md +175 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/story.md +29 -0
- package/dist/templates/cleargate-planning/CLAUDE.md +3 -0
- package/dist/templates/cleargate-planning/MANIFEST.json +59 -17
- package/dist/whoami-CX7CXJD5.js +76 -0
- package/dist/whoami-CX7CXJD5.js.map +1 -0
- package/package.json +6 -2
- package/templates/cleargate-planning/.claude/agents/architect.md +72 -0
- package/templates/cleargate-planning/.claude/agents/developer.md +45 -3
- package/templates/cleargate-planning/.claude/agents/qa.md +7 -3
- package/templates/cleargate-planning/.claude/agents/reporter.md +72 -75
- package/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +204 -0
- package/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +10 -0
- package/templates/cleargate-planning/.claude/hooks/pre-commit-test-ratchet.sh +58 -0
- package/templates/cleargate-planning/.claude/hooks/pre-commit.sh +19 -0
- package/templates/cleargate-planning/.claude/hooks/session-start.sh +51 -0
- package/templates/cleargate-planning/.claude/hooks/token-ledger.sh +1 -1
- package/templates/cleargate-planning/.claude/settings.json +11 -0
- package/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +31 -12
- package/templates/cleargate-planning/.cleargate/FLASHCARD.md +2 -1
- package/templates/cleargate-planning/.cleargate/config.example.yml +37 -0
- package/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +407 -0
- package/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +146 -0
- package/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +250 -0
- package/templates/cleargate-planning/.cleargate/scripts/constants.mjs +57 -0
- package/templates/cleargate-planning/.cleargate/scripts/file_surface_diff.sh +320 -0
- package/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +15 -0
- package/templates/cleargate-planning/.cleargate/scripts/init_gate_config.sh +38 -0
- package/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +187 -0
- package/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +132 -0
- package/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +307 -0
- package/templates/cleargate-planning/.cleargate/scripts/prefill_report.mjs +280 -0
- package/templates/cleargate-planning/.cleargate/scripts/run_script.sh +123 -0
- package/templates/cleargate-planning/.cleargate/scripts/state.schema.json +110 -0
- package/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +247 -0
- package/templates/cleargate-planning/.cleargate/scripts/surface-whitelist.txt +27 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_assert_story_files.sh +261 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_file_surface.sh +210 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +190 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_test_ratchet.sh +327 -0
- package/templates/cleargate-planning/.cleargate/scripts/test_ratchet.mjs +261 -0
- package/templates/cleargate-planning/.cleargate/scripts/update_state.mjs +154 -0
- package/templates/cleargate-planning/.cleargate/scripts/validate_bounce_readiness.mjs +111 -0
- package/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +164 -0
- package/templates/cleargate-planning/.cleargate/templates/Bug.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/CR.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +29 -3
- package/templates/cleargate-planning/.cleargate/templates/epic.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/proposal.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/sprint_context.md +42 -0
- package/templates/cleargate-planning/.cleargate/templates/sprint_report.md +175 -0
- package/templates/cleargate-planning/.cleargate/templates/story.md +29 -0
- package/templates/cleargate-planning/CLAUDE.md +3 -0
- package/templates/cleargate-planning/MANIFEST.json +59 -17
|
@@ -10,6 +10,17 @@
|
|
|
10
10
|
]
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
|
+
"PreToolUse": [
|
|
14
|
+
{
|
|
15
|
+
"matcher": "Task",
|
|
16
|
+
"hooks": [
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pending-task-sentinel.sh"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
13
24
|
"PostToolUse": [
|
|
14
25
|
{
|
|
15
26
|
"matcher": "Edit|Write",
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: flashcard
|
|
3
|
-
description: Append-only project lesson log at .cleargate/FLASHCARD.md. Use BEFORE starting non-trivial work to read past gotchas ("check" mode). Use WHEN you hit a surprise,
|
|
3
|
+
description: Append-only project lesson log at .cleargate/FLASHCARD.md. Use BEFORE starting non-trivial work to read past gotchas ("check" mode). Use WHEN you (a) hit a surprise, (b) found the winning path after a non-trivial task succeeded, or (c) were corrected by the user — record a one-liner for future agents ("record: <text>" mode). One-liners only; tag with #schema/#auth/#test-harness/etc. Also triggers on phrases: "turns out", "unexpected", "gotcha", "wasted time on", "starting work on", "before implementing", "user pushed back", "prefer X over Y", "winning path", "after several attempts", "the recipe that worked".
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Flashcard — Project Lesson Log
|
|
7
7
|
|
|
8
8
|
Append-only one-liner log of non-obvious gotchas that future agents in this project should know. Lives at `.cleargate/FLASHCARD.md` in the project root. Not a general wiki — only things that surprised us and would surprise someone else.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Modes
|
|
11
11
|
|
|
12
12
|
### `check` — read before work
|
|
13
|
-
Read `.cleargate/FLASHCARD.md`. Scan for tags relevant to your
|
|
13
|
+
Read `.cleargate/FLASHCARD.md`. Apply the Rule 8 filter: skip cards marked `[S]` (stale) or `[R]` (resolved) unless your current task directly matches a tag in a superseded card. Scan active cards for tags relevant to your task (grep by `#schema`, `#auth`, etc.). If unsure whether a card applies, err on applying it — reading 20 one-liners is cheap.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
Use `check-all` instead when investigating history or debugging a recurring issue — it includes `[S]` and `[R]` cards.
|
|
16
|
+
|
|
17
|
+
### `record: <text>` — three trigger classes, same format
|
|
18
|
+
Append a single line to `.cleargate/FLASHCARD.md`. Same 120-char cap regardless of trigger:
|
|
19
|
+
|
|
20
|
+
1. **Surprise** — something bit us. Lead with the surprise, not the context.
|
|
21
|
+
2. **Recipe** — the winning path after a non-trivial task succeeded (roughly 5+ tool calls, or one clear dead-end recovery). Lead with the *action that worked*, not the failures traversed. Tag `#recipe` alongside the domain tag.
|
|
22
|
+
3. **Correction** — the user pushed back on an approach. Capture the rule, not the exchange. Prefer the shape "prefer X over Y because Z". Tag `#correction` alongside the domain tag.
|
|
23
|
+
|
|
24
|
+
Format (unchanged):
|
|
17
25
|
|
|
18
26
|
```
|
|
19
27
|
YYYY-MM-DD · #tag1 #tag2 · <lesson ≤ 120 chars>
|
|
20
28
|
```
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
Examples:
|
|
23
31
|
```
|
|
24
32
|
2026-04-18 · #redis #auth · Invite tokens in Redis-only vanish on eviction — use Postgres invites table as source of truth.
|
|
33
|
+
2026-04-19 · #recipe #wiki · For wiki drift detection, git SHA beats content hash — drops the metadata-lifecycle dependency.
|
|
34
|
+
2026-04-19 · #correction #planning · Prefer two L1/L2 stories over one L3 at epic-decomposition (user: splits are free pre-push).
|
|
25
35
|
```
|
|
26
36
|
|
|
27
37
|
### Tag vocabulary (append new tags freely, but prefer these)
|
|
@@ -46,14 +56,21 @@ Example:
|
|
|
46
56
|
3. **Lead with the surprise, not the context.** Good: "Drizzle 0.45 silently drops `DEFAULT gen_random_uuid()` — use `sql` template." Bad: "When working on schema migrations yesterday we found that sometimes…"
|
|
47
57
|
4. **Lessons, not events.** "Shipped STORY-004-07 today" is NOT a flashcard. "Postgres 18 needs `pgcrypto` extension for gen_random_uuid — not enabled by default in official docker image" IS.
|
|
48
58
|
5. **Ordered newest-first after the header** — new entries go at the TOP of the log section, not bottom. Readers scan the top; old stuff drifts down.
|
|
49
|
-
6. **Never delete.** Edit to add reconfirmations or
|
|
59
|
+
6. **Never delete.** Edit to add reconfirmations, supersede pointers, or status markers (Rule 7); keep the original text. History is the point.
|
|
60
|
+
7. **Status markers for cleanup.** A card may carry a status marker placed *immediately after the second `·`* and before the lesson body:
|
|
61
|
+
- no marker → active (default; the vast majority of cards).
|
|
62
|
+
- `[S]` → stale. The symbol the card references no longer exists in the repo.
|
|
63
|
+
- `[R] → superseded-by <short-ref>` → resolved or replaced by a later card / shipped fix. `<short-ref>` is a date+tag (e.g. `2026-04-19/#hooks-sentinel`) or a STORY/CR ID.
|
|
64
|
+
Markers are additive — the original lesson text is preserved. The reporter agent flags candidates at sprint end; a human approves the batch before markers are applied (see `.claude/agents/reporter.md` → "Flashcard audit").
|
|
65
|
+
8. **Check-mode filter.** `check` reads active cards only (no marker). Include `[S]` / `[R]` cards only when: (a) their tags directly match the current task area, or (b) the invocation is `check-all` (explicit history read). This keeps `check` signal-dense without losing the historical record.
|
|
50
66
|
|
|
51
67
|
## Invocation contract
|
|
52
68
|
|
|
53
69
|
When an agent invokes this skill:
|
|
54
70
|
|
|
55
|
-
- **`Skill(flashcard, "check")`** — open `.cleargate/FLASHCARD.md`,
|
|
56
|
-
- **`Skill(flashcard, "
|
|
71
|
+
- **`Skill(flashcard, "check")`** — open `.cleargate/FLASHCARD.md`, apply the Rule 8 filter, summarize matching active cards in one line per card. If none apply, respond "no relevant flashcards" and proceed.
|
|
72
|
+
- **`Skill(flashcard, "check-all")`** — same as `check` but includes `[S]` / `[R]` cards. Use when investigating history, debugging a recurring issue, or tracing a supersede chain.
|
|
73
|
+
- **`Skill(flashcard, "record: <text>")`** — parse the text for date + tags + body. If date missing, insert today's UTC date. If tags missing, refuse with "add at least one tag." For recipe-class entries include `#recipe`; for correction-class entries include `#correction`. Grep for duplicates; if dup, reconfirm the existing line instead of appending. Append to the top of the log section in the file.
|
|
57
74
|
|
|
58
75
|
## File shape
|
|
59
76
|
|
|
@@ -63,11 +80,13 @@ When an agent invokes this skill:
|
|
|
63
80
|
# ClearGate Flashcards
|
|
64
81
|
|
|
65
82
|
One-liner gotcha log. Newest first. Grep by tag (e.g. `grep '#schema'`).
|
|
66
|
-
|
|
83
|
+
Active cards have no marker; `[S]` = stale, `[R]` = resolved (see SKILL.md Rule 7).
|
|
84
|
+
Format: `YYYY-MM-DD · #tags · [marker]? lesson`
|
|
67
85
|
|
|
68
86
|
---
|
|
69
87
|
|
|
70
|
-
2026-04-
|
|
71
|
-
2026-04-17 · #schema ·
|
|
88
|
+
2026-04-19 · #redis #auth · <newest active lesson>
|
|
89
|
+
2026-04-17 · #schema · [S] drizzle-kit v0.42 silently drops indexes — fixed in v0.45 upgrade.
|
|
90
|
+
2026-04-15 · #hooks · [R] → superseded-by 2026-04-19/#hooks-sentinel · SubagentStop fires on orchestrator not subagents.
|
|
72
91
|
...
|
|
73
92
|
```
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# ClearGate Flashcards
|
|
2
2
|
|
|
3
3
|
One-liner gotcha log. Newest first. Grep by tag (e.g. `grep '#schema'`).
|
|
4
|
-
|
|
4
|
+
Active cards have no marker; `[S]` = stale, `[R]` = resolved (see `.claude/skills/flashcard/SKILL.md` Rules 7–8).
|
|
5
|
+
Format: `YYYY-MM-DD · #tags · [marker]? lesson`
|
|
5
6
|
|
|
6
7
|
---
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# ClearGate per-repo configuration.
|
|
2
|
+
# Copy to .cleargate/config.yml and edit. All keys optional.
|
|
3
|
+
|
|
4
|
+
# wiki:
|
|
5
|
+
# index_token_ceiling: 8000 # chars budget for wiki/index.md (STORY-015-03)
|
|
6
|
+
|
|
7
|
+
# gates:
|
|
8
|
+
# precommit: "<command run before every commit — typecheck + tests>"
|
|
9
|
+
# test: "<command to run the test suite>"
|
|
10
|
+
# typecheck: "<command to run the type checker>"
|
|
11
|
+
# lint: "<command to run the linter>"
|
|
12
|
+
|
|
13
|
+
# Node example:
|
|
14
|
+
# gates:
|
|
15
|
+
# precommit: "npm run typecheck && npm test"
|
|
16
|
+
# test: "npm test"
|
|
17
|
+
# typecheck: "npm run typecheck"
|
|
18
|
+
# lint: "npm run lint"
|
|
19
|
+
|
|
20
|
+
# Go example:
|
|
21
|
+
# gates:
|
|
22
|
+
# precommit: "go vet ./... && go test ./..."
|
|
23
|
+
# test: "go test ./..."
|
|
24
|
+
# typecheck: "go build ./..."
|
|
25
|
+
|
|
26
|
+
# Python example:
|
|
27
|
+
# gates:
|
|
28
|
+
# precommit: "mypy . && pytest"
|
|
29
|
+
# test: "pytest"
|
|
30
|
+
# typecheck: "mypy ."
|
|
31
|
+
|
|
32
|
+
# Rust example:
|
|
33
|
+
# gates:
|
|
34
|
+
# precommit: "cargo check && cargo test"
|
|
35
|
+
# test: "cargo test"
|
|
36
|
+
# typecheck: "cargo check"
|
|
37
|
+
# lint: "cargo clippy"
|
|
@@ -102,6 +102,12 @@ There are three hard stops. You halt at each one and do not proceed until the hu
|
|
|
102
102
|
4. Once §6 is empty and zero "TBDs" remain in the document, move the status to 🟢.
|
|
103
103
|
5. Only documents at 🟢 may proceed to the Delivery phase.
|
|
104
104
|
|
|
105
|
+
**v2 enforcement rule:** When the sprint frontmatter has `execution_mode: "v2"`, a 🔴 High-ambiguity Epic BLOCKS bounce start — the orchestrator MUST NOT transition the story to `Bouncing` state until the Epic reaches 🟢. To override: the sprint plan frontmatter MUST contain `human_override: true` AND a `human_override_reason` field captured in §0 Readiness Gate of the sprint plan, with explicit human sign-off recorded. Without both fields, the orchestrator halts and presents the block message: *"Gate 2 blocked: Epic {ID} is 🔴 High ambiguity under execution_mode: v2. Set human_override: true + human_override_reason in sprint §0 to proceed."*
|
|
106
|
+
|
|
107
|
+
Under `execution_mode: "v1"` this rule is **advisory only** — the orchestrator surfaces the ambiguity level but does not block bounce start.
|
|
108
|
+
|
|
109
|
+
**v2 story-file assertion:** Additionally for v2 sprints, `cleargate sprint init` asserts every story in §1 Consolidated Deliverables has a `pending-sync/STORY-*.md` file before writing `state.json`; missing files block init with an enumerated stderr list. Under v1 the assertion runs but only warns (does not block). The assertion is also available standalone: `node .cleargate/scripts/assert_story_files.mjs <sprint-file-path>`.
|
|
110
|
+
|
|
105
111
|
### Gate 3 — Push Gate
|
|
106
112
|
|
|
107
113
|
- **Never call `cleargate_push_item` on a file where `approved: false`.**
|
|
@@ -506,3 +512,404 @@ Future `cleargate init` in the same dir detects this marker and offers restore.
|
|
|
506
512
|
|
|
507
513
|
### §13.6 Publishing notes
|
|
508
514
|
`MANIFEST.json` is built at `npm run build` (prebuild step in `cleargate-cli/package.json`) and shipped in the npm tarball (`files[]`). Never computed at install time. `generate-changelog-diff.ts` diffs `MANIFEST.json` between the previous published version and the current one at release time; CHANGELOG.md auto-opens with a "Scaffold files changed" block per release. Content-identical entries (path-moved-only, metadata-changed-only) are collapsed to avoid noise.
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
518
|
+
## 14. Multi-Participant Sync
|
|
519
|
+
|
|
520
|
+
### §14.1 Sync matrix & authority split
|
|
521
|
+
|
|
522
|
+
**Rule:** Remote is authoritative for status, assignees, and comments; local is authoritative for work-item body.
|
|
523
|
+
|
|
524
|
+
When both sides change the same field, the authoritative side wins without prompt (except body+body — see §14.2). This split prevents accidental overwrites of carefully authored local prose while still tracking PM-tool state transitions faithfully. Source: EPIC-010 §4 authority table; `cleargate-cli/src/commands/sync.ts` conflict-detector snapshot shape.
|
|
525
|
+
|
|
526
|
+
### §14.2 Conflict resolution
|
|
527
|
+
|
|
528
|
+
**Rule:** content+content → interactive 3-way merge prompt; status+status → remote-wins silently; delete+edit (either direction) → refuse; unrecognized conflict shape → `halt`.
|
|
529
|
+
|
|
530
|
+
Nine conflict states are recognized (`content-content`, `status-status`, `remote-delete-local-edit`, `local-delete-remote-edit`, `remote-only`, `local-only`, `remote-status-only`, `local-content-only`, `unknown`). Resolution values are `three-way-merge`, `remote-wins`, `local-wins`, `refuse`, `halt`, `remote-only-apply`, `local-only-apply`. The `halt` resolution surfaces an actionable error rather than silently discarding data. Source: `cleargate-cli/src/lib/conflict-detector.ts`; `cleargate-cli/src/commands/sync.ts:307-367`.
|
|
531
|
+
|
|
532
|
+
### §14.3 Sync ordering invariant
|
|
533
|
+
|
|
534
|
+
**Rule:** `cleargate sync` MUST execute pull → classify → resolve → push in that order; reversal amplifies conflicts.
|
|
535
|
+
|
|
536
|
+
Executing a push before all pulls are complete risks overwriting a remote state change that the local resolve step would have otherwise detected. The 6-step driver enforces this order at the code level; a unit test asserts step ordering as a dataflow invariant. Source: `cleargate-cli/src/commands/sync.ts` driver doc comment (steps 1–6); R2 mitigation.
|
|
537
|
+
|
|
538
|
+
### §14.4 Identity resolution precedence
|
|
539
|
+
|
|
540
|
+
**Rule:** `.cleargate/.participant.json` → `CLEARGATE_USER` env → `git config user.email` → `host+user` fallback.
|
|
541
|
+
|
|
542
|
+
Identity is per-repo, not global, so two participants on the same machine with different `.participant.json` files get distinct attribution. The env var override allows CI or scripted sync. Source: `cleargate-cli/src/lib/identity.ts`; R5 mitigation.
|
|
543
|
+
|
|
544
|
+
### §14.5 Stakeholder-authored proposal flow
|
|
545
|
+
|
|
546
|
+
**Rule:** Remote items labeled `cleargate:proposal` (configurable via `CLEARGATE_PROPOSAL_LABEL` env) and absent locally land in `pending-sync/PROPOSAL-NNN-remote-<slug>.md` with `source: "remote-authored"` and `approved: false`.
|
|
547
|
+
|
|
548
|
+
This prevents external stakeholders from bypassing the approval gate: the proposal arrives locally for human review before any push. The label name is configurable so teams can map to their own PM-tool taxonomy. Source: `cleargate-cli/src/lib/intake.ts`; `cleargate-cli/src/commands/sync.ts:167-183`.
|
|
549
|
+
|
|
550
|
+
### §14.6 Comment policy
|
|
551
|
+
|
|
552
|
+
**Rule:** Comments pull as read-only snapshots, active items only (current sprint + last 30 days), rendered under `## Remote comments` with literal-string delimiters. Never pushed upstream.
|
|
553
|
+
|
|
554
|
+
Pulling comments for stale items wastes tokens and clutters archives; the 30-day window keeps recent feedback visible. The `## Remote comments` block uses byte-stable literal delimiters so repeated pulls are idempotent. A 429 rate-limit on any single item causes that item to be skipped silently. Source: `cleargate-cli/src/lib/wiki-comments-render.ts`; `cleargate-cli/src/lib/active-criteria.ts`; R4/R6 mitigations.
|
|
555
|
+
|
|
556
|
+
### §14.7 Push preconditions
|
|
557
|
+
|
|
558
|
+
**Rule:** `cleargate_push_item` requires `payload.approved === true` unless the caller passes `skipApprovedGate: true` (reserved for `sync_status` internal callers). `pushed_by` is stamped from `members.email` via JWT `sub` → member lookup, NOT the raw JWT `sub` value.
|
|
559
|
+
|
|
560
|
+
The `skipApprovedGate` bypass is an internal escape hatch for status-only updates triggered by `cleargate_sync_status`; it is not exposed as a public CLI flag. The email lookup ensures human-readable attribution independent of UUID-based JWT subjects. Source: `mcp/src/tools/push-item.ts`; flashcard `#mcp #jwt #attribution`.
|
|
561
|
+
|
|
562
|
+
### §14.8 Revert policy
|
|
563
|
+
|
|
564
|
+
**Rule:** `cleargate push --revert <id>` soft-reverts by calling `cleargate_sync_status` with `new_status: "archived-without-shipping"`; it never deletes the remote item. `--force` is required when local `status: done`.
|
|
565
|
+
|
|
566
|
+
Soft revert preserves audit history on the PM-tool side. Refusing to revert done items without `--force` prevents accidental archival of shipped work. Source: `cleargate-cli/src/commands/push.ts` revert branch; `cleargate-cli/src/cli.ts:268-273`.
|
|
567
|
+
|
|
568
|
+
### §14.9 Sync cadence
|
|
569
|
+
|
|
570
|
+
**Rule:** All sync actions are manual (`cleargate sync` / `cleargate pull <id>` / `cleargate push <file>`). The SessionStart hook SUGGESTS via `cleargate sync --check` — it never auto-pulls or auto-pushes. MCP probes are throttled to at most one per 24 hours per repo.
|
|
571
|
+
|
|
572
|
+
Auto-push without human review would bypass the approval gate; auto-pull would overwrite in-progress local edits without conflict detection. The 24-hour throttle prevents session-start latency accumulation. Throttle state is stored in `.cleargate/.sync-marker.json` with schema `{ "last_check": "<ISO-8601>" }` (v1; unknown keys are ignored on read for forward compatibility). Source: `.claude/hooks/session-start.sh`; `.cleargate/.sync-marker.json`; R7 mitigation.
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
## 15. Worktree Lifecycle (v2)
|
|
577
|
+
|
|
578
|
+
**v1/v2 gating:** Under `execution_mode: v1` the rules in this section are **informational** — they document the intended workflow but are not enforced by any script. Under `execution_mode: v2` they are **mandatory**: every story transition that would run a Developer agent MUST follow these procedures before any file edits begin.
|
|
579
|
+
|
|
580
|
+
### §15.1 Branch hierarchy
|
|
581
|
+
|
|
582
|
+
The branch hierarchy for a sprint is:
|
|
583
|
+
|
|
584
|
+
```
|
|
585
|
+
main
|
|
586
|
+
└── sprint/S-XX ← cut at sprint start; never commit directly
|
|
587
|
+
└── story/STORY-NNN-NN ← cut when story transitions Ready → Bouncing
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
- **Sprint branch** is cut from `main` once at the start of each sprint:
|
|
591
|
+
```bash
|
|
592
|
+
git checkout -b sprint/S-XX main
|
|
593
|
+
```
|
|
594
|
+
- **Story branch** is cut from the active sprint branch when the story enters `Bouncing` state:
|
|
595
|
+
```bash
|
|
596
|
+
git checkout sprint/S-XX
|
|
597
|
+
git checkout -b story/STORY-NNN-NN sprint/S-XX
|
|
598
|
+
```
|
|
599
|
+
- Story branches are **never** cut from `main` directly; they always track the sprint branch as parent.
|
|
600
|
+
|
|
601
|
+
### §15.2 Worktree commands
|
|
602
|
+
|
|
603
|
+
Per-story working trees live under `.worktrees/` at repo root. Each story gets its own isolated filesystem view.
|
|
604
|
+
|
|
605
|
+
**Create worktree (story starts bouncing):**
|
|
606
|
+
```bash
|
|
607
|
+
git worktree add .worktrees/STORY-NNN-NN -b story/STORY-NNN-NN sprint/S-XX
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
**Verify worktree:**
|
|
611
|
+
```bash
|
|
612
|
+
git worktree list
|
|
613
|
+
# .../repo <sha> [sprint/S-XX]
|
|
614
|
+
# .../repo/.worktrees/STORY-NNN-NN <sha> [story/STORY-NNN-NN]
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**Merge story back into sprint branch (story passes QA + Architect):**
|
|
618
|
+
```bash
|
|
619
|
+
git checkout sprint/S-XX
|
|
620
|
+
git merge story/STORY-NNN-NN --no-ff -m "merge(story/STORY-NNN-NN): STORY-NNN-NN <title>"
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
**Remove worktree and story branch (after successful merge):**
|
|
624
|
+
```bash
|
|
625
|
+
git worktree remove .worktrees/STORY-NNN-NN
|
|
626
|
+
git branch -d story/STORY-NNN-NN
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
**Prune stale worktree refs:**
|
|
630
|
+
```bash
|
|
631
|
+
git worktree prune
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
All commands must be run from the **repo root** (not from inside `.worktrees/`), except Developer Agent file edits which happen inside the assigned worktree path.
|
|
635
|
+
|
|
636
|
+
### §15.3 MCP nested-repo rule
|
|
637
|
+
|
|
638
|
+
**The `mcp/` directory is a nested independent git repository.** Running `git worktree add` inside `mcp/` would create a worktree scoped to the nested repo, not to the outer ClearGate repo. This is a git footgun: the outer repo cannot track, merge, or remove the inner worktree via its own git commands.
|
|
639
|
+
|
|
640
|
+
**Rule:** Never run `git worktree add` inside `mcp/`. If a story requires edits to `mcp/`, the Developer Agent must edit `mcp/` from inside the outer worktree (`.worktrees/STORY-NNN-NN/mcp/...`) — the nested repo's files are visible there as a subdirectory, not as a separate git context. MCP-native worktree support is deferred to Q3.
|
|
641
|
+
|
|
642
|
+
### §15.4 Local state.json is in-flight authority
|
|
643
|
+
|
|
644
|
+
During a story's execution, `state.json` at `.cleargate/sprint-runs/<sprint-id>/state.json` is the single source of truth for story state. The MCP server is a **post-facto audit** channel: it receives state updates after each transition but is never consulted during execution. If MCP is unavailable, execution continues uninterrupted; state.json records the ground truth that MCP will eventually replicate. (Source: EPIC-013 Q7 resolution.)
|
|
645
|
+
|
|
646
|
+
### §15.5 Enforcement gates
|
|
647
|
+
|
|
648
|
+
| `execution_mode` | These rules are |
|
|
649
|
+
|---|---|
|
|
650
|
+
| `v1` | Informational — document intended workflow; not script-enforced |
|
|
651
|
+
| `v2` | Mandatory — `validate_bounce_readiness.mjs` checks worktree isolation before any Developer Agent edit |
|
|
652
|
+
|
|
653
|
+
Under v2, attempting to run a Developer Agent on a story without a matching `.worktrees/STORY-NNN-NN/` path present causes `validate_bounce_readiness.mjs` to exit non-zero and the orchestrator to halt the story transition.
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
## 16. User Walkthrough on Sprint Branch (v2)
|
|
658
|
+
|
|
659
|
+
**v1/v2 gating:** Under `execution_mode: v1` this section is **informational**. Under `execution_mode: v2` it is **mandatory**: the sprint branch MUST NOT merge to `main` until the walkthrough is complete and all `UR:bug` items are resolved.
|
|
660
|
+
|
|
661
|
+
### §16.1 Walkthrough trigger
|
|
662
|
+
|
|
663
|
+
After all stories in the sprint are merged into `sprint/S-XX` (every story state ∈ `TERMINAL_STATES`) and before `sprint/S-XX` merges to `main`, the orchestrator invites the user to test the running application on the sprint branch.
|
|
664
|
+
|
|
665
|
+
### §16.2 Feedback classification
|
|
666
|
+
|
|
667
|
+
User feedback during the walkthrough is classified into exactly two event types:
|
|
668
|
+
|
|
669
|
+
| Event type | Definition | Bug-Fix Tax effect |
|
|
670
|
+
|---|---|---|
|
|
671
|
+
| `UR:review-feedback` | Enhancement, polish, copy change, or UX preference — does NOT fix broken behavior | Does NOT increment Bug-Fix Tax |
|
|
672
|
+
| `UR:bug` | Defect, crash, wrong output, or behavior broken relative to spec | DOES increment Bug-Fix Tax |
|
|
673
|
+
|
|
674
|
+
**Classification rule:** when in doubt, ask the user one targeted question — "Is this broken relative to spec, or a preference?" Do not default to `UR:bug`.
|
|
675
|
+
|
|
676
|
+
### §16.3 Logging
|
|
677
|
+
|
|
678
|
+
Each piece of walkthrough feedback MUST be logged in the sprint markdown file under `## 4. Execution Log` with the event prefix:
|
|
679
|
+
|
|
680
|
+
```
|
|
681
|
+
UR:review-feedback 2026-04-21 — copy should say "Sign in" not "Log in" (resolved: STORY-013-09-dev.md commit abc123)
|
|
682
|
+
UR:bug 2026-04-21 — create-project button 500s on submit (resolved: STORY-013-10-dev.md commit def456)
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
### §16.4 Resolution gate
|
|
686
|
+
|
|
687
|
+
The sprint branch MUST NOT merge to `main` while any `UR:bug` item is unresolved. `UR:review-feedback` items MAY be deferred to the next sprint with orchestrator + user acknowledgment logged.
|
|
688
|
+
|
|
689
|
+
---
|
|
690
|
+
|
|
691
|
+
## 17. Mid-Sprint Change Request Triage (v2)
|
|
692
|
+
|
|
693
|
+
**v1/v2 gating:** Under `execution_mode: v1` this section is **informational**. Under `execution_mode: v2` it is **mandatory**: every user-injected change during a bounce MUST be classified before routing.
|
|
694
|
+
|
|
695
|
+
### §17.1 Classification table
|
|
696
|
+
|
|
697
|
+
When the user injects new input during a QA bounce or active story execution, the orchestrator classifies the input into one of four categories:
|
|
698
|
+
|
|
699
|
+
| Event type | Definition | Bounce-counter effect | Routing |
|
|
700
|
+
|---|---|---|---|
|
|
701
|
+
| `CR:bug` | Defect introduced by the current story's implementation | Counts toward Bug-Fix Tax; increments `qa_bounces` | Re-open story; Developer fixes; QA re-verifies |
|
|
702
|
+
| `CR:spec-clarification` | Clarification of existing spec — no new scope, removes ambiguity | Does NOT increment any bounce counter | Update story acceptance criteria in place; re-run impacted test |
|
|
703
|
+
| `CR:scope-change` | Net-new requirement or expansion of story scope | Deferred: create a new Story in `pending-sync/`; current story continues unchanged | New Story ID assigned; current bounce counter unaffected |
|
|
704
|
+
| `CR:approach-change` | Switch implementation approach without changing functional spec | Does NOT increment bounce counter; resets Developer context | Re-spawn Developer with updated approach note; same story ID |
|
|
705
|
+
|
|
706
|
+
### §17.2 Logging
|
|
707
|
+
|
|
708
|
+
Each mid-sprint CR MUST be logged in the sprint markdown file under `## 4. Execution Log` with the event prefix:
|
|
709
|
+
|
|
710
|
+
```
|
|
711
|
+
CR:spec-clarification 2026-04-21 — endpoint must return project slug (clarified in STORY-013-05 §1.2; no new scope)
|
|
712
|
+
CR:scope-change 2026-04-21 — user requests audit log table (new STORY-013-11 created in pending-sync/)
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### §17.3 Scope-change quarantine
|
|
716
|
+
|
|
717
|
+
A `CR:scope-change` MUST NOT be folded into the current story's commit. Create a new Story file and handle in a future sprint or as a mid-sprint addition (requires orchestrator + user explicit sign-off to add mid-sprint).
|
|
718
|
+
|
|
719
|
+
---
|
|
720
|
+
|
|
721
|
+
## 18. Immediate Flashcard Gate (v2)
|
|
722
|
+
|
|
723
|
+
**v1/v2 gating:** Under `execution_mode: v1` this section is **informational** — the gate is advisory and the orchestrator may proceed without processing flagged cards (though it is strongly encouraged). Under `execution_mode: v2` it is **mandatory**: the orchestrator MUST NOT create the next story's worktree until all `flashcards_flagged` entries from the prior story's dev + QA reports are processed.
|
|
724
|
+
|
|
725
|
+
**V-Bounce reference:** `skills/agent-team/SKILL.md` §"Step 5.5: Immediate Flashcard Recording (Hard Gate)" at pinned SHA `2b8477ab65e39e594ee8b6d8cf13a210498eaded`.
|
|
726
|
+
|
|
727
|
+
### §18.1 Trigger
|
|
728
|
+
|
|
729
|
+
After story N's commit merges into `sprint/S-XX` and QA approves, the orchestrator collects `flashcards_flagged` from both:
|
|
730
|
+
- `STORY-NNN-NN-dev.md` (Developer Agent output report)
|
|
731
|
+
- `STORY-NNN-NN-qa.md` (QA Agent output report)
|
|
732
|
+
|
|
733
|
+
The two lists are merged (union, deduplication by exact string match). If the combined list is empty, the gate passes immediately.
|
|
734
|
+
|
|
735
|
+
### §18.2 Processing rule
|
|
736
|
+
|
|
737
|
+
For each entry in the merged `flashcards_flagged` list, the orchestrator MUST take exactly one of two actions before creating story N+1's worktree:
|
|
738
|
+
|
|
739
|
+
| Action | Effect | Record location |
|
|
740
|
+
|---|---|---|
|
|
741
|
+
| **Approve** | Append the one-liner verbatim to `.cleargate/FLASHCARD.md` (newest-first, per SKILL.md format) | The card itself is the record |
|
|
742
|
+
| **Reject** | Discard the entry — do NOT append to `FLASHCARD.md` | Sprint §4 Execution Log: `FLASHCARD-REJECT YYYY-MM-DD — "<card text>" — reason: <one sentence>` |
|
|
743
|
+
|
|
744
|
+
### §18.3 Worktree creation gate
|
|
745
|
+
|
|
746
|
+
The orchestrator MUST NOT run `git worktree add .worktrees/STORY-NNN-NN ...` for story N+1 until the §18.2 processing loop is complete (every entry either approved or rejected). This is a blocking serial step, not a background task.
|
|
747
|
+
|
|
748
|
+
### §18.4 Cards format
|
|
749
|
+
|
|
750
|
+
Each entry in `flashcards_flagged` MUST conform to the format required by `.claude/skills/flashcard/SKILL.md`:
|
|
751
|
+
|
|
752
|
+
```
|
|
753
|
+
YYYY-MM-DD · #tag1 #tag2 · lesson ≤120 chars
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
The orchestrator may reformat an entry that violates the format before appending, but must log the reformat in sprint §4 Execution Log.
|
|
757
|
+
|
|
758
|
+
### §18.5 v1 dogfood note
|
|
759
|
+
|
|
760
|
+
SPRINT-09 runs under `execution_mode: v1`. From STORY-013-06 merge onwards, the orchestrator applies the §18.2 processing loop manually as a dogfood check even though the rule is informational. This is recorded in the SPRINT-09 sprint plan (line 121).
|
|
761
|
+
|
|
762
|
+
### §18.6 PreToolUse hook enforcement (v2)
|
|
763
|
+
|
|
764
|
+
Under `execution_mode: v2`, the `pending-task-sentinel.sh` PreToolUse hook automatically enforces the flashcard gate before every Task (subagent) dispatch. This is implemented by STORY-014-03.
|
|
765
|
+
|
|
766
|
+
**Hash-marker convention:**
|
|
767
|
+
|
|
768
|
+
Each `flashcards_flagged` card is identified by the first 12 hexadecimal characters of its SHA-1 hash (computed with `shasum -a 1`):
|
|
769
|
+
|
|
770
|
+
```bash
|
|
771
|
+
HASH="$(printf '%s' "<card text>" | shasum -a 1 | cut -c1-12)"
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
Hash stability: the same card string always produces the same hash. The hash is computed over the exact card string as it appears in the report's `flashcards_flagged` list (after stripping surrounding quotes).
|
|
775
|
+
|
|
776
|
+
**Processed marker:**
|
|
777
|
+
|
|
778
|
+
To mark a card as processed (approved or rejected by the orchestrator), touch the marker file:
|
|
779
|
+
|
|
780
|
+
```bash
|
|
781
|
+
touch .cleargate/sprint-runs/<sprint-id>/.processed-<hash>
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
The marker files are gitignored via the existing `.cleargate/sprint-runs/` gitignore rule and serve only as local bookkeeping.
|
|
785
|
+
|
|
786
|
+
**Enforcement logic:**
|
|
787
|
+
|
|
788
|
+
1. The hook globs `SPRINT_DIR/STORY-*-dev.md` and `SPRINT_DIR/STORY-*-qa.md` (flat layout — no `reports/` subdirectory).
|
|
789
|
+
2. For each report file, it parses the `flashcards_flagged:` YAML list (inline `[]` and block `- "text"` forms both supported).
|
|
790
|
+
3. For each card, it computes the 12-char SHA-1 hash and checks for the `.processed-<hash>` marker in `SPRINT_DIR`.
|
|
791
|
+
4. If any card is unprocessed:
|
|
792
|
+
- **v2**: exits non-zero (blocks Task spawn) with stderr listing each unprocessed card and the `touch` command hint.
|
|
793
|
+
- **v1**: prints an advisory warning to stderr and exits 0 (does not block).
|
|
794
|
+
5. If `flashcards_flagged: []` or no report files exist, the gate passes immediately.
|
|
795
|
+
|
|
796
|
+
**Bypass:**
|
|
797
|
+
|
|
798
|
+
Set `SKIP_FLASHCARD_GATE=1` in the environment to bypass the gate entirely (both v1 and v2). This bypass is intended for CI and bootstrap scenarios where the hook runs without sprint context. Bypasses should be disabled once M1 is closed; the orchestrator tracks this in the sprint §4 Execution Log.
|
|
799
|
+
|
|
800
|
+
---
|
|
801
|
+
|
|
802
|
+
## 19. Execution Mode Routing (v2)
|
|
803
|
+
|
|
804
|
+
The `execution_mode` field in a Sprint Plan's frontmatter is the single switch that controls whether §§15–18 of this protocol are **enforcing** or **advisory** for that sprint.
|
|
805
|
+
|
|
806
|
+
### §19.1 Flag semantics
|
|
807
|
+
|
|
808
|
+
| `execution_mode` value | Effect |
|
|
809
|
+
|---|---|
|
|
810
|
+
| `"v1"` | All §§15–18 rules are **advisory** — document intended workflow; no CLI or script enforcement. New CLI commands (`sprint init|close`, `story start|complete`, `gate qa|arch`, `state update|validate`) print an inert-mode message and exit 0. |
|
|
811
|
+
| `"v2"` | All §§15–18 rules are **mandatory** — CLI wrappers route to `run_script.sh` scripts; worktree isolation, pre-gate scanning, bounce counters, flashcard gate, and sprint-close pipeline are all enforced. |
|
|
812
|
+
|
|
813
|
+
### §19.2 Sprint-scoped flag
|
|
814
|
+
|
|
815
|
+
The `execution_mode` flag is **sprint-scoped**, not global. A project may run SPRINT-10 on `v2` while SPRINT-11 planning files default to `v1` until the Architect completes a Sprint Design Review (§15.1). Setting the flag on one sprint has no effect on any other sprint file.
|
|
816
|
+
|
|
817
|
+
### §19.3 Orchestrator routing rule
|
|
818
|
+
|
|
819
|
+
Before spawning any Developer, QA, or Reporter agent, the orchestrator MUST:
|
|
820
|
+
|
|
821
|
+
1. Locate the active sprint file at `.cleargate/delivery/pending-sync/SPRINT-{ID}_*.md` (or the archived equivalent).
|
|
822
|
+
2. Read the `execution_mode` frontmatter field. If absent, treat as `"v1"`.
|
|
823
|
+
3. If `"v1"`: proceed with advisory-only loop. §§15–18 rules are informational.
|
|
824
|
+
4. If `"v2"`: enforce §§15–18 before each agent spawn as mandatory gates.
|
|
825
|
+
|
|
826
|
+
### §19.4 CLI inert-mode message
|
|
827
|
+
|
|
828
|
+
When a v2-only CLI command is invoked and the active sprint's `execution_mode` is `"v1"`, the CLI MUST print exactly:
|
|
829
|
+
|
|
830
|
+
```
|
|
831
|
+
v1 mode active — command inert. Set execution_mode: v2 in sprint frontmatter to enable.
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
and exit 0. No subprocess is spawned. This preserves backward compatibility for users who have not yet migrated to v2.
|
|
835
|
+
|
|
836
|
+
### §19.5 Default value
|
|
837
|
+
|
|
838
|
+
The default value is `"v1"`. All sprint plans generated from the Sprint Plan Template default to `execution_mode: "v1"` until explicitly flipped. The flag should only be set to `"v2"` after all M2 EPIC-013 stories have shipped and the Architect has completed a Sprint Design Review (§15.1).
|
|
839
|
+
|
|
840
|
+
---
|
|
841
|
+
|
|
842
|
+
## 20. File-Surface Contract (v2)
|
|
843
|
+
|
|
844
|
+
Under `execution_mode: v2`, each story's §3.1 "Context & Files" table is the **authoritative file surface** for that story's commit. The pre-commit hook enforces this contract automatically.
|
|
845
|
+
|
|
846
|
+
### §20.1 Rule
|
|
847
|
+
|
|
848
|
+
A Developer agent MUST NOT stage and commit any file not declared in the active story's §3.1 table, unless that file matches a whitelist entry in `.cleargate/scripts/surface-whitelist.txt`.
|
|
849
|
+
|
|
850
|
+
Off-surface edits require one of:
|
|
851
|
+
1. A CR:scope-change item approved before the commit, OR
|
|
852
|
+
2. An updated §3.1 table committed in the same story (self-amending surface — rare, must be explicitly justified in the commit message).
|
|
853
|
+
|
|
854
|
+
### §20.2 Hook mechanics
|
|
855
|
+
|
|
856
|
+
The gate runs as `.cleargate/scripts/file_surface_diff.sh` invoked via `.claude/hooks/pre-commit-surface-gate.sh` and dispatched from `.claude/hooks/pre-commit.sh`. The dispatcher is symlinked to `.git/hooks/pre-commit`.
|
|
857
|
+
|
|
858
|
+
- Under v2: off-surface files cause a non-zero exit — the commit is blocked.
|
|
859
|
+
- Under v1: the hook prints a warning but exits 0 (advisory only).
|
|
860
|
+
- `SKIP_SURFACE_GATE=1` env variable bypasses the gate entirely (use sparingly; log bypass in sprint §4 Execution Log).
|
|
861
|
+
|
|
862
|
+
### §20.3 §3.1 table contract
|
|
863
|
+
|
|
864
|
+
The §3.1 table in `story.md` template uses a two-column `| Item | Value |` pipe table. The parser:
|
|
865
|
+
- Scans between the `### 3.1` heading and the next `### ` heading.
|
|
866
|
+
- Only processes rows where the Value cell contains `.` or `/` (path-shaped values).
|
|
867
|
+
- Strips backticks from values.
|
|
868
|
+
- Splits on `, ` to handle multiple paths in one cell.
|
|
869
|
+
- Ignores header and separator rows.
|
|
870
|
+
|
|
871
|
+
Non-path rows (e.g., "Mirrors", "New Files Needed: Yes/No") are silently skipped.
|
|
872
|
+
|
|
873
|
+
### §20.4 Whitelist
|
|
874
|
+
|
|
875
|
+
`.cleargate/scripts/surface-whitelist.txt` declares auto-generated files that are always admitted regardless of story surface. Seed entries include: `cleargate-planning/MANIFEST.json`, `.cleargate/hook-log/*`, `.cleargate/sprint-runs/**/token-ledger.jsonl`, `.cleargate/sprint-runs/**/.pending-task-*.json`, `.cleargate/sprint-runs/**/state.json`.
|
|
876
|
+
|
|
877
|
+
### §20.5 Install (dogfood)
|
|
878
|
+
|
|
879
|
+
On `cleargate init`, the scaffold automatically installs the `.git/hooks/pre-commit` symlink. For existing dogfood repositories, install once by hand:
|
|
880
|
+
|
|
881
|
+
```bash
|
|
882
|
+
ln -sf ../../.claude/hooks/pre-commit.sh .git/hooks/pre-commit
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
Log this step in the sprint §4 Execution Log.
|
|
886
|
+
|
|
887
|
+
---
|
|
888
|
+
|
|
889
|
+
## 21. Status Vocabulary
|
|
890
|
+
|
|
891
|
+
Raw work-item frontmatter `status:` values must be drawn from this canonical set:
|
|
892
|
+
|
|
893
|
+
| Status | Meaning |
|
|
894
|
+
|---|---|
|
|
895
|
+
| `Draft` | Newly authored; not yet ambiguity-gated |
|
|
896
|
+
| `Ready` | Ambiguity gate passed; eligible for sprint planning |
|
|
897
|
+
| `Approved` | Epic approved for execution |
|
|
898
|
+
| `Planned` | Sprint planned; not yet started |
|
|
899
|
+
| `Active` | Work in progress |
|
|
900
|
+
| `Completed` | Shipped (sprints, epics) |
|
|
901
|
+
| `Done` | Shipped (stories) — treated as alias of `Completed` for terminal-status checks |
|
|
902
|
+
| `Abandoned` | Work deliberately stopped without shipping. The artifact stays in `archive/` for historical record. Not eligible for the Active index. |
|
|
903
|
+
| `Closed` | Closed without shipping (administrative close) |
|
|
904
|
+
| `Resolved` | Bug or CR confirmed resolved |
|
|
905
|
+
|
|
906
|
+
### §21.1 Index Token Ceiling
|
|
907
|
+
|
|
908
|
+
`cleargate wiki lint` enforces a ceiling on `.cleargate/wiki/index.md` size, measured as `bytes ÷ 4` approximate tokens. Default ceiling: `8000`. Override via `.cleargate/config.yml`:
|
|
909
|
+
|
|
910
|
+
```yaml
|
|
911
|
+
wiki:
|
|
912
|
+
index_token_ceiling: 8000
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
Exceeding the ceiling fails `cleargate wiki lint` (enforcement mode). Under `--suggest`, the usage percentage is reported but the check does not fail. Reference: EPIC-015.
|