cleargate 0.11.4 → 0.12.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.
@@ -77,19 +77,21 @@ Before a v2 sprint plan is confirmed by the human, you MUST write Sprint Plan §
77
77
 
78
78
  **Trigger:** Orchestrator invokes you with all story files for the sprint milestone AND signals "Design Review requested". You produce §2 content and return it as a markdown block for the orchestrator to insert into the sprint plan file.
79
79
 
80
- **§2 Execution Strategy — four required subsections:**
80
+ **§2 Execution Strategy — five required subsections:**
81
81
 
82
- 1. **§2.1 Phase Plan** — Group stories into parallel waves vs sequential chains. Source: `parallel_eligible` field on each story's frontmatter + dependency graph from `## 3. Implementation Guide`. Explicitly state which stories can run concurrently and which must be serialized.
82
+ 1. **§2.1 Phase Plan** — Group stories into parallel waves vs sequential chains. Before declaring any cross-story dependency, grep the codebase to verify the cited surface exists today vs. is created in-sprint. Story `## Existing Surfaces` bullets are advisory; the codebase is authoritative. Source: `parallel_eligible` field on each story's frontmatter + dependency graph from `## 3. Implementation Guide`. Explicitly state which stories can run concurrently and which must be serialized.
83
83
 
84
84
  2. **§2.2 Merge Ordering** — Grep each story's "Files to modify" list for overlap. For every file touched by more than one story, determine which story lands first (typically the one that creates the section the other amends). Produce a table: `Shared File | Stories | Order | Rationale`.
85
85
 
86
86
  3. **§2.3 Shared-Surface Warnings** — For each pair of stories that touch the same file, flag the specific risk: section collision, rename hazard, append-vs-insert conflict. One bullet per risk pair.
87
87
 
88
- 4. **§2.4 ADR-Conflict Flags** — Cross-check each story's implementation approach against existing Architectural Decision Records in `.cleargate/knowledge/` and prior sprint decisions captured in flashcards. Flag any story that diverges from a locked decision.
88
+ 4. **§2.4 Lane Audit** — Per the seven-check Lane Classification rubric below; emit one row per fast-lane story with a ≤80-char rationale. Empty by default — rows added only for non-`standard` lanes. Full mechanics at "Lane Classification" section in this file.
89
+
90
+ 5. **§2.5 ADR-Conflict Flags** — Cross-check each story's implementation approach against existing Architectural Decision Records in `.cleargate/knowledge/` and prior sprint decisions captured in flashcards. Flag any story that diverges from a locked decision.
89
91
 
90
92
  **V-Bounce reference:** `skills/agent-team/SKILL.md` §"Architect Sprint Design Review (Phase 2 → Phase 3 transition)" at pinned SHA `2b8477ab65e39e594ee8b6d8cf13a210498eaded`.
91
93
 
92
- **Output:** A single markdown block (§§2.1–2.4 as shown above) ready for insertion into the sprint plan. Not a separate file. The orchestrator writes it into the plan.
94
+ **Output:** A single markdown block (§§2.1–2.5 as shown above) ready for insertion into the sprint plan. Not a separate file. The orchestrator writes it into the plan.
93
95
 
94
96
  These rules apply under `execution_mode: v2`. Under v1 the Design Review is informational.
95
97
 
@@ -642,3 +642,141 @@ wiki:
642
642
  ```
643
643
 
644
644
  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.
645
+
646
+ ---
647
+
648
+ ## Type & Payload Contract
649
+
650
+ Every item pushed to the MCP server (`cleargate_push_item`) must conform to the following contract. Adapter authors implementing new PM-tool integrations MUST satisfy all requirements below before the server accepts the payload.
651
+
652
+ ### Open-type validator
653
+
654
+ `type` is validated as an open vocabulary (new types do not require a server upgrade):
655
+
656
+ ```
657
+ z.string().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/)
658
+ ```
659
+
660
+ Applied after lowercase-normalize. Types that fail this regex are rejected at the MCP transport layer with an L1 `TYPE_INVALID` error.
661
+
662
+ ### KNOWN_TYPES — advisory registry (8 entries)
663
+
664
+ These 8 types have first-class gate and reporting support. Any type outside this list passes validation but triggers an L2 `TYPE_UNKNOWN` warning in the server log.
665
+
666
+ | Type | Description |
667
+ |---|---|
668
+ | `initiative` | High-level strategic investment |
669
+ | `epic` | Feature-level work breakdown |
670
+ | `story` | Executable unit of work (one sprint, one commit) |
671
+ | `bug` | Defect report + fix |
672
+ | `cr` | Change request — scope amendment or approach change |
673
+ | `proposal` | Stakeholder-authored item awaiting triage |
674
+ | `sprint` | Sprint plan artifact |
675
+ | `sprint_report` | Sprint closeout report |
676
+
677
+ ### RESERVED_PAYLOAD_KEYS (5 entries)
678
+
679
+ The following keys are set exclusively by the MCP server or the CLI sync engine. Callers MUST NOT include them in `payload`; the server strips or rejects them on receipt.
680
+
681
+ | Key | Owner | Reason |
682
+ |---|---|---|
683
+ | `cleargate_id` | CLI stamp engine | Must match the frontmatter `cleargate_id` — server validates; caller cannot override |
684
+ | `pushed_by` | Server | Set from JWT `sub` → member lookup; client-supplied value is ignored |
685
+ | `pushed_at` | Server | Set to server UTC timestamp; client-supplied value is ignored |
686
+ | `last_synced_body_sha` | Sync engine | Conflict-detection cursor; tampering causes spurious diffs |
687
+ | `_version` | Server | Internal optimistic-lock counter; client tampering causes 409 |
688
+
689
+ ### Minimum payload contract
690
+
691
+ Every push MUST include:
692
+
693
+ | Key | Level | Note |
694
+ |---|---|---|
695
+ | `cleargate_id` | **Required (L1 error if absent)** | `TYPE-NNN` or 5-digit numeric (see formats below) |
696
+ | `type` | **Required (L1 error if absent)** | Open vocabulary, validated by regex above |
697
+ | `title` | Recommended (L2 warning if absent) | Human-readable item title |
698
+ | `status` | Recommended (L2 warning if absent) | From §21 status vocabulary |
699
+
700
+ ### `payload.origin` convention
701
+
702
+ `payload.origin` identifies the surface that produced the push. Gates fire or are bypassed based on this value:
703
+
704
+ | Value pattern | Gate behavior |
705
+ |---|---|
706
+ | `cleargate-cli` | All readiness gates run (standard path) |
707
+ | `adapter:<vendor>` | Gates bypass — adapter is assumed to have already validated externally. Example: `adapter:linear`, `adapter:jira` |
708
+ | `system:<service>` | Gates bypass — system-generated push (e.g. `system:reporter`, `system:wiki-ingest`) |
709
+ | absent / null | Treated as `cleargate-cli`; gates run |
710
+
711
+ ### `cleargate_id` formats (2 valid forms)
712
+
713
+ | Format | Pattern | Example | Used for |
714
+ |---|---|---|---|
715
+ | Type-prefixed | `TYPE-NNN` (TYPE = uppercase letters, NNN = 1–5 digits) | `STORY-027-05`, `EPIC-003` | All standard work items |
716
+ | 5-digit numeric | Exactly 5 decimal digits | `00042` | Legacy PM-tool remote IDs; internal migration use only |
717
+
718
+ ### L1 errorCode taxonomy (7 codes)
719
+
720
+ L1 errors cause the MCP tool call to return a structured error payload with shape `{ code, message, hint }` and HTTP 422 (or equivalent MCP error).
721
+
722
+ | Code | Condition | Hint |
723
+ |---|---|---|
724
+ | `TYPE_INVALID` | `type` fails regex validation | Normalize to lowercase-kebab; max 64 chars |
725
+ | `ID_INVALID` | `cleargate_id` does not match either valid format | Use `TYPE-NNN` or 5-digit numeric |
726
+ | `ID_MISSING` | `cleargate_id` absent from payload | Required field — stamp it before push |
727
+ | `TYPE_MISSING` | `type` absent from payload | Required field |
728
+ | `RESERVED_KEY` | Payload contains a `RESERVED_PAYLOAD_KEYS` member | Remove the key; server owns it |
729
+ | `APPROVED_GATE` | `payload.approved !== true` and `skipApprovedGate` not set | Set `approved: true` after human sign-off |
730
+ | `PROJECT_NOT_FOUND` | JWT `project_id` claim has no matching project row | Re-join with a valid invite URL |
731
+
732
+ ### L2 warningCode taxonomy (3 codes)
733
+
734
+ L2 warnings are non-blocking. The push succeeds, but the server appends `[advisory: <code>]` to the item body and logs the warning.
735
+
736
+ | Code | Condition | Field |
737
+ |---|---|---|
738
+ | `TITLE_MISSING` | `title` absent or empty | `title` |
739
+ | `STATUS_MISSING` | `status` absent or not in §21 vocabulary | `status` |
740
+ | `TYPE_UNKNOWN` | `type` is not in `KNOWN_TYPES` advisory registry | `type` |
741
+
742
+ ---
743
+
744
+ ## Codebase / PM-Tool Boundary
745
+
746
+ **Rule:** `cleargate-cli/src/**` and `.claude/**` MUST NOT import any PM-tool SDK. PM-tool adapters live exclusively in `mcp/src/adapters/`. Credentials and connection config live in admin DB rows, configured via the admin console UI.
747
+
748
+ ### Rationale
749
+
750
+ ClearGate must remain PM-tool-agnostic at the CLI and agent-definition layer so that:
751
+ 1. The CLI can be installed in any repo regardless of which PM tool the team uses.
752
+ 2. Agent prompts (`.claude/**`) do not hard-code vendor assumptions.
753
+ 3. A new PM-tool adapter can be added by dropping a file in `mcp/src/adapters/` without touching `cleargate-cli/` or `.claude/`.
754
+
755
+ ### Forbidden import patterns
756
+
757
+ Any `import` or `require` statement in `cleargate-cli/src/**/*.ts` or `.claude/**/*.{ts,sh,md}` that references the following patterns fails CI:
758
+
759
+ | Pattern | PM tool |
760
+ |---|---|
761
+ | `@linear/sdk` | Linear |
762
+ | `linear-sdk` | Linear (alt package) |
763
+ | `jira-client` | Jira |
764
+ | `node-jira-client` | Jira (alt package) |
765
+ | `jira.js` | Jira (alt package) |
766
+ | `azure-devops` | Azure DevOps |
767
+ | `@atlassian/` | Atlassian family |
768
+
769
+ ### Allowed surface for PM-tool code
770
+
771
+ `mcp/src/adapters/` is the only surface where PM-tool SDK imports are permitted. Each adapter file is responsible for importing its SDK, mapping ClearGate payload shapes to PM-tool API calls, and surfacing errors as structured MCP errors.
772
+
773
+ ### CI enforcement
774
+
775
+ `scripts/ci-no-pm-sdk.mjs` scans the two forbidden surfaces and exits non-zero on any match. Run via:
776
+
777
+ ```
778
+ node scripts/ci-no-pm-sdk.mjs
779
+ npm run check:no-pm-sdk
780
+ ```
781
+
782
+ Comments (lines starting with `//`, `#`, `/*`, or `*`) are excluded from the scan. The script prints `✓ no forbidden PM-SDK imports` on a clean tree.
@@ -746,6 +746,95 @@ async function main() {
746
746
  process.stderr.write('Run `cleargate sync work-items` manually to retry.\n');
747
747
  }
748
748
 
749
+ // ── Step 7.4: MCP push of sprint plan + report ───────────────────────────────
750
+ // CR-064: mcp push sprint plan + report
751
+ // Runs after Step 7 (work-item sync) and BEFORE Step 7.5 (CR-063 wiki ingest).
752
+ // Per SDR-locked ordering: MCP push first, wiki ingest second (CR-064 §0.5 Q4 accepted).
753
+ // Non-fatal on failure: sprint stays Completed. MCP push can be retried manually.
754
+ process.stdout.write('Step 7.4: pushing sprint plan + report to MCP...\n');
755
+ try {
756
+ const cliBin74 = path.join(REPO_ROOT, 'cleargate-cli', 'dist', 'cli.js');
757
+ if (fs.existsSync(cliBin74)) {
758
+ // Resolve sprint plan path: prefer archive/, fall back to pending-sync/
759
+ const deliveryBase = path.join(REPO_ROOT, '.cleargate', 'delivery');
760
+ const archiveDir = path.join(deliveryBase, 'archive');
761
+ const pendingDir = path.join(deliveryBase, 'pending-sync');
762
+ let planPath = null;
763
+ for (const dir of [archiveDir, pendingDir]) {
764
+ if (!fs.existsSync(dir)) continue;
765
+ const match = fs.readdirSync(dir).find(
766
+ (f) => f.startsWith(sprintId + '_') && f.endsWith('.md'),
767
+ );
768
+ if (match) { planPath = path.join(dir, match); break; }
769
+ }
770
+ if (planPath && fs.existsSync(planPath)) {
771
+ try {
772
+ execSync(`node ${JSON.stringify(cliBin74)} push ${JSON.stringify(planPath)}`, {
773
+ stdio: 'inherit',
774
+ env: process.env,
775
+ timeout: 60000,
776
+ });
777
+ process.stdout.write('Step 7.4a passed: sprint plan pushed to MCP.\n');
778
+ } catch (err74a) {
779
+ process.stderr.write(`Step 7.4a warning: sprint plan push failed: ${/** @type {Error} */ (err74a).message}\n`);
780
+ }
781
+ } else {
782
+ process.stdout.write('Step 7.4a skipped: sprint plan file not found.\n');
783
+ }
784
+ // Resolve sprint report path: reuses reportFile resolved via legacy-fallback in Step 4
785
+ if (reportFile && fs.existsSync(reportFile)) {
786
+ try {
787
+ execSync(`node ${JSON.stringify(cliBin74)} push ${JSON.stringify(reportFile)}`, {
788
+ stdio: 'inherit',
789
+ env: process.env,
790
+ timeout: 60000,
791
+ });
792
+ process.stdout.write('Step 7.4b passed: sprint report pushed to MCP.\n');
793
+ } catch (err74b) {
794
+ process.stderr.write(`Step 7.4b warning: sprint report push failed: ${/** @type {Error} */ (err74b).message}\n`);
795
+ }
796
+ } else {
797
+ process.stdout.write('Step 7.4b skipped: sprint report file not found (legacy sprint or report not yet written).\n');
798
+ }
799
+ } else {
800
+ process.stdout.write('Step 7.4 skipped: CLI binary not found (non-fatal).\n');
801
+ }
802
+ } catch (err) {
803
+ // Non-fatal — sprint stays Completed; MCP push can be retried manually
804
+ process.stderr.write(`Step 7.4 warning: MCP push failed: ${/** @type {Error} */ (err).message}\n`);
805
+ process.stderr.write('Run `cleargate push <plan-or-report-path>` manually to retry.\n');
806
+ }
807
+
808
+ // ── Step 7.5: wiki ingest sprint report ──────────────────────────────────
809
+ // CR-063: wiki ingest sprint report
810
+ // Runs after Step 7 (MCP sync). Non-fatal: sprint stays Completed on failure.
811
+ // CR-064 (Wave 3) inserts its MCP-push step at Step 7.4, immediately before this anchor.
812
+ process.stdout.write('Step 7.5: ingesting sprint report into wiki...\n');
813
+ try {
814
+ const cliBin = path.join(REPO_ROOT, 'cleargate-cli', 'dist', 'cli.js');
815
+ if (fs.existsSync(cliBin)) {
816
+ // Resolve report path using the same legacy-fallback rule as Step 4
817
+ // (SPRINT-NN_REPORT.md preferred; fall back to REPORT.md for legacy sprints)
818
+ const reportPath = reportFile; // reportFile is already resolved via legacy-fallback in Step 4
819
+ if (fs.existsSync(reportPath)) {
820
+ execSync(`node ${JSON.stringify(cliBin)} wiki ingest ${JSON.stringify(reportPath)}`, {
821
+ stdio: 'inherit',
822
+ env: process.env,
823
+ timeout: 60000,
824
+ });
825
+ process.stdout.write('Step 7.5 passed: sprint report ingested into wiki.\n');
826
+ } else {
827
+ process.stdout.write('Step 7.5 skipped: report file not found (legacy sprint or report not yet written).\n');
828
+ }
829
+ } else {
830
+ process.stdout.write('Step 7.5 skipped: CLI binary not found (non-fatal).\n');
831
+ }
832
+ } catch (err) {
833
+ // Non-fatal — sprint stays Completed; ingest can be retried manually
834
+ process.stderr.write(`Step 7.5 warning: wiki ingest sprint report failed: ${/** @type {Error} */ (err).message}\n`);
835
+ process.stderr.write('Run `cleargate wiki ingest <report-path>` manually to retry.\n');
836
+ }
837
+
749
838
  // ── Step 8: Verbose post-close handoff list ───────────────────────────────
750
839
  // Prints 6 explicit next-step items to stdout (CR-022 §3 M4).
751
840
  {
@@ -53,6 +53,8 @@ This repository uses **ClearGate** — a standalone planning framework for AI co
53
53
 
54
54
  **Cross-project orchestration.** When running an orchestrator from one project's repo against another project's sprint tree, export `ORCHESTRATOR_PROJECT_DIR=/absolute/path/to/target/repo` in the shell before launching the session. Overrides `CLAUDE_PROJECT_DIR`; sentinel + ledger writes route into the target's `.cleargate/sprint-runs/` tree. If the target has no `.cleargate/sprint-runs/.active` sentinel, writes land in the target's `_off-sprint` bucket — not the orchestrator's own repo.
55
55
 
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
+
56
58
  **Project overrides.** Content OUTSIDE this `<!-- CLEARGATE:START -->...<!-- CLEARGATE:END -->` block takes precedence where it conflicts with ClearGate defaults.
57
59
 
58
60
  **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,10 +1,10 @@
1
1
  {
2
- "cleargate_version": "0.11.4",
3
- "generated_at": "2026-05-05T17:48:13.929Z",
2
+ "cleargate_version": "0.12.0",
3
+ "generated_at": "2026-05-15T05:10:35.575Z",
4
4
  "files": [
5
5
  {
6
6
  "path": ".claude/agents/architect.md",
7
- "sha256": "a2d11d6a7f21bce22730ba9076af9ddde44b258082e33aa99fcd57c14ad75f55",
7
+ "sha256": "823db34b934d080e648955326dcc3cd31899e90f62ecfa4a9344f5b473237084",
8
8
  "tier": "agent",
9
9
  "overwrite_policy": "always",
10
10
  "preserve_on_uninstall": false
@@ -165,7 +165,7 @@
165
165
  },
166
166
  {
167
167
  "path": ".cleargate/knowledge/cleargate-protocol.md",
168
- "sha256": "50e999717b9c9e1c11638f3f2433f413d177ed8ddf3cffdbb20b50c8807b1fc5",
168
+ "sha256": "0380e74efa8aa782b77952fa68cc0171de035653e777d5c241d84c6e0414957b",
169
169
  "tier": "protocol",
170
170
  "overwrite_policy": "merge-3way",
171
171
  "preserve_on_uninstall": false
@@ -200,7 +200,7 @@
200
200
  },
201
201
  {
202
202
  "path": ".cleargate/scripts/close_sprint.mjs",
203
- "sha256": "1807e5b27f1501476c9dec41cbb350c432d2894cb0727d8da0c860ad3f9181c7",
203
+ "sha256": "b42018973ec6f02fc5d0ddf2a7d302aa0ee6d127cb5140474a67cb1fb0af6b28",
204
204
  "tier": "script",
205
205
  "overwrite_policy": "always",
206
206
  "preserve_on_uninstall": false
@@ -6,7 +6,7 @@ import {
6
6
  getMembershipState,
7
7
  loadConfig,
8
8
  requireMcpUrl
9
- } from "./chunk-Q3BTSXCK.js";
9
+ } from "./chunk-WFNLCTY5.js";
10
10
  import "./chunk-4V4QABOJ.js";
11
11
 
12
12
  // src/commands/whoami.ts
@@ -73,4 +73,4 @@ async function whoamiHandler(opts) {
73
73
  export {
74
74
  whoamiHandler
75
75
  };
76
- //# sourceMappingURL=whoami-W4U6DPVG.js.map
76
+ //# sourceMappingURL=whoami-GQTFZHFQ.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cleargate",
3
- "version": "0.11.4",
3
+ "version": "0.12.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.",
@@ -77,19 +77,21 @@ Before a v2 sprint plan is confirmed by the human, you MUST write Sprint Plan §
77
77
 
78
78
  **Trigger:** Orchestrator invokes you with all story files for the sprint milestone AND signals "Design Review requested". You produce §2 content and return it as a markdown block for the orchestrator to insert into the sprint plan file.
79
79
 
80
- **§2 Execution Strategy — four required subsections:**
80
+ **§2 Execution Strategy — five required subsections:**
81
81
 
82
- 1. **§2.1 Phase Plan** — Group stories into parallel waves vs sequential chains. Source: `parallel_eligible` field on each story's frontmatter + dependency graph from `## 3. Implementation Guide`. Explicitly state which stories can run concurrently and which must be serialized.
82
+ 1. **§2.1 Phase Plan** — Group stories into parallel waves vs sequential chains. Before declaring any cross-story dependency, grep the codebase to verify the cited surface exists today vs. is created in-sprint. Story `## Existing Surfaces` bullets are advisory; the codebase is authoritative. Source: `parallel_eligible` field on each story's frontmatter + dependency graph from `## 3. Implementation Guide`. Explicitly state which stories can run concurrently and which must be serialized.
83
83
 
84
84
  2. **§2.2 Merge Ordering** — Grep each story's "Files to modify" list for overlap. For every file touched by more than one story, determine which story lands first (typically the one that creates the section the other amends). Produce a table: `Shared File | Stories | Order | Rationale`.
85
85
 
86
86
  3. **§2.3 Shared-Surface Warnings** — For each pair of stories that touch the same file, flag the specific risk: section collision, rename hazard, append-vs-insert conflict. One bullet per risk pair.
87
87
 
88
- 4. **§2.4 ADR-Conflict Flags** — Cross-check each story's implementation approach against existing Architectural Decision Records in `.cleargate/knowledge/` and prior sprint decisions captured in flashcards. Flag any story that diverges from a locked decision.
88
+ 4. **§2.4 Lane Audit** — Per the seven-check Lane Classification rubric below; emit one row per fast-lane story with a ≤80-char rationale. Empty by default — rows added only for non-`standard` lanes. Full mechanics at "Lane Classification" section in this file.
89
+
90
+ 5. **§2.5 ADR-Conflict Flags** — Cross-check each story's implementation approach against existing Architectural Decision Records in `.cleargate/knowledge/` and prior sprint decisions captured in flashcards. Flag any story that diverges from a locked decision.
89
91
 
90
92
  **V-Bounce reference:** `skills/agent-team/SKILL.md` §"Architect Sprint Design Review (Phase 2 → Phase 3 transition)" at pinned SHA `2b8477ab65e39e594ee8b6d8cf13a210498eaded`.
91
93
 
92
- **Output:** A single markdown block (§§2.1–2.4 as shown above) ready for insertion into the sprint plan. Not a separate file. The orchestrator writes it into the plan.
94
+ **Output:** A single markdown block (§§2.1–2.5 as shown above) ready for insertion into the sprint plan. Not a separate file. The orchestrator writes it into the plan.
93
95
 
94
96
  These rules apply under `execution_mode: v2`. Under v1 the Design Review is informational.
95
97
 
@@ -642,3 +642,141 @@ wiki:
642
642
  ```
643
643
 
644
644
  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.
645
+
646
+ ---
647
+
648
+ ## Type & Payload Contract
649
+
650
+ Every item pushed to the MCP server (`cleargate_push_item`) must conform to the following contract. Adapter authors implementing new PM-tool integrations MUST satisfy all requirements below before the server accepts the payload.
651
+
652
+ ### Open-type validator
653
+
654
+ `type` is validated as an open vocabulary (new types do not require a server upgrade):
655
+
656
+ ```
657
+ z.string().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/)
658
+ ```
659
+
660
+ Applied after lowercase-normalize. Types that fail this regex are rejected at the MCP transport layer with an L1 `TYPE_INVALID` error.
661
+
662
+ ### KNOWN_TYPES — advisory registry (8 entries)
663
+
664
+ These 8 types have first-class gate and reporting support. Any type outside this list passes validation but triggers an L2 `TYPE_UNKNOWN` warning in the server log.
665
+
666
+ | Type | Description |
667
+ |---|---|
668
+ | `initiative` | High-level strategic investment |
669
+ | `epic` | Feature-level work breakdown |
670
+ | `story` | Executable unit of work (one sprint, one commit) |
671
+ | `bug` | Defect report + fix |
672
+ | `cr` | Change request — scope amendment or approach change |
673
+ | `proposal` | Stakeholder-authored item awaiting triage |
674
+ | `sprint` | Sprint plan artifact |
675
+ | `sprint_report` | Sprint closeout report |
676
+
677
+ ### RESERVED_PAYLOAD_KEYS (5 entries)
678
+
679
+ The following keys are set exclusively by the MCP server or the CLI sync engine. Callers MUST NOT include them in `payload`; the server strips or rejects them on receipt.
680
+
681
+ | Key | Owner | Reason |
682
+ |---|---|---|
683
+ | `cleargate_id` | CLI stamp engine | Must match the frontmatter `cleargate_id` — server validates; caller cannot override |
684
+ | `pushed_by` | Server | Set from JWT `sub` → member lookup; client-supplied value is ignored |
685
+ | `pushed_at` | Server | Set to server UTC timestamp; client-supplied value is ignored |
686
+ | `last_synced_body_sha` | Sync engine | Conflict-detection cursor; tampering causes spurious diffs |
687
+ | `_version` | Server | Internal optimistic-lock counter; client tampering causes 409 |
688
+
689
+ ### Minimum payload contract
690
+
691
+ Every push MUST include:
692
+
693
+ | Key | Level | Note |
694
+ |---|---|---|
695
+ | `cleargate_id` | **Required (L1 error if absent)** | `TYPE-NNN` or 5-digit numeric (see formats below) |
696
+ | `type` | **Required (L1 error if absent)** | Open vocabulary, validated by regex above |
697
+ | `title` | Recommended (L2 warning if absent) | Human-readable item title |
698
+ | `status` | Recommended (L2 warning if absent) | From §21 status vocabulary |
699
+
700
+ ### `payload.origin` convention
701
+
702
+ `payload.origin` identifies the surface that produced the push. Gates fire or are bypassed based on this value:
703
+
704
+ | Value pattern | Gate behavior |
705
+ |---|---|
706
+ | `cleargate-cli` | All readiness gates run (standard path) |
707
+ | `adapter:<vendor>` | Gates bypass — adapter is assumed to have already validated externally. Example: `adapter:linear`, `adapter:jira` |
708
+ | `system:<service>` | Gates bypass — system-generated push (e.g. `system:reporter`, `system:wiki-ingest`) |
709
+ | absent / null | Treated as `cleargate-cli`; gates run |
710
+
711
+ ### `cleargate_id` formats (2 valid forms)
712
+
713
+ | Format | Pattern | Example | Used for |
714
+ |---|---|---|---|
715
+ | Type-prefixed | `TYPE-NNN` (TYPE = uppercase letters, NNN = 1–5 digits) | `STORY-027-05`, `EPIC-003` | All standard work items |
716
+ | 5-digit numeric | Exactly 5 decimal digits | `00042` | Legacy PM-tool remote IDs; internal migration use only |
717
+
718
+ ### L1 errorCode taxonomy (7 codes)
719
+
720
+ L1 errors cause the MCP tool call to return a structured error payload with shape `{ code, message, hint }` and HTTP 422 (or equivalent MCP error).
721
+
722
+ | Code | Condition | Hint |
723
+ |---|---|---|
724
+ | `TYPE_INVALID` | `type` fails regex validation | Normalize to lowercase-kebab; max 64 chars |
725
+ | `ID_INVALID` | `cleargate_id` does not match either valid format | Use `TYPE-NNN` or 5-digit numeric |
726
+ | `ID_MISSING` | `cleargate_id` absent from payload | Required field — stamp it before push |
727
+ | `TYPE_MISSING` | `type` absent from payload | Required field |
728
+ | `RESERVED_KEY` | Payload contains a `RESERVED_PAYLOAD_KEYS` member | Remove the key; server owns it |
729
+ | `APPROVED_GATE` | `payload.approved !== true` and `skipApprovedGate` not set | Set `approved: true` after human sign-off |
730
+ | `PROJECT_NOT_FOUND` | JWT `project_id` claim has no matching project row | Re-join with a valid invite URL |
731
+
732
+ ### L2 warningCode taxonomy (3 codes)
733
+
734
+ L2 warnings are non-blocking. The push succeeds, but the server appends `[advisory: <code>]` to the item body and logs the warning.
735
+
736
+ | Code | Condition | Field |
737
+ |---|---|---|
738
+ | `TITLE_MISSING` | `title` absent or empty | `title` |
739
+ | `STATUS_MISSING` | `status` absent or not in §21 vocabulary | `status` |
740
+ | `TYPE_UNKNOWN` | `type` is not in `KNOWN_TYPES` advisory registry | `type` |
741
+
742
+ ---
743
+
744
+ ## Codebase / PM-Tool Boundary
745
+
746
+ **Rule:** `cleargate-cli/src/**` and `.claude/**` MUST NOT import any PM-tool SDK. PM-tool adapters live exclusively in `mcp/src/adapters/`. Credentials and connection config live in admin DB rows, configured via the admin console UI.
747
+
748
+ ### Rationale
749
+
750
+ ClearGate must remain PM-tool-agnostic at the CLI and agent-definition layer so that:
751
+ 1. The CLI can be installed in any repo regardless of which PM tool the team uses.
752
+ 2. Agent prompts (`.claude/**`) do not hard-code vendor assumptions.
753
+ 3. A new PM-tool adapter can be added by dropping a file in `mcp/src/adapters/` without touching `cleargate-cli/` or `.claude/`.
754
+
755
+ ### Forbidden import patterns
756
+
757
+ Any `import` or `require` statement in `cleargate-cli/src/**/*.ts` or `.claude/**/*.{ts,sh,md}` that references the following patterns fails CI:
758
+
759
+ | Pattern | PM tool |
760
+ |---|---|
761
+ | `@linear/sdk` | Linear |
762
+ | `linear-sdk` | Linear (alt package) |
763
+ | `jira-client` | Jira |
764
+ | `node-jira-client` | Jira (alt package) |
765
+ | `jira.js` | Jira (alt package) |
766
+ | `azure-devops` | Azure DevOps |
767
+ | `@atlassian/` | Atlassian family |
768
+
769
+ ### Allowed surface for PM-tool code
770
+
771
+ `mcp/src/adapters/` is the only surface where PM-tool SDK imports are permitted. Each adapter file is responsible for importing its SDK, mapping ClearGate payload shapes to PM-tool API calls, and surfacing errors as structured MCP errors.
772
+
773
+ ### CI enforcement
774
+
775
+ `scripts/ci-no-pm-sdk.mjs` scans the two forbidden surfaces and exits non-zero on any match. Run via:
776
+
777
+ ```
778
+ node scripts/ci-no-pm-sdk.mjs
779
+ npm run check:no-pm-sdk
780
+ ```
781
+
782
+ Comments (lines starting with `//`, `#`, `/*`, or `*`) are excluded from the scan. The script prints `✓ no forbidden PM-SDK imports` on a clean tree.
@@ -746,6 +746,95 @@ async function main() {
746
746
  process.stderr.write('Run `cleargate sync work-items` manually to retry.\n');
747
747
  }
748
748
 
749
+ // ── Step 7.4: MCP push of sprint plan + report ───────────────────────────────
750
+ // CR-064: mcp push sprint plan + report
751
+ // Runs after Step 7 (work-item sync) and BEFORE Step 7.5 (CR-063 wiki ingest).
752
+ // Per SDR-locked ordering: MCP push first, wiki ingest second (CR-064 §0.5 Q4 accepted).
753
+ // Non-fatal on failure: sprint stays Completed. MCP push can be retried manually.
754
+ process.stdout.write('Step 7.4: pushing sprint plan + report to MCP...\n');
755
+ try {
756
+ const cliBin74 = path.join(REPO_ROOT, 'cleargate-cli', 'dist', 'cli.js');
757
+ if (fs.existsSync(cliBin74)) {
758
+ // Resolve sprint plan path: prefer archive/, fall back to pending-sync/
759
+ const deliveryBase = path.join(REPO_ROOT, '.cleargate', 'delivery');
760
+ const archiveDir = path.join(deliveryBase, 'archive');
761
+ const pendingDir = path.join(deliveryBase, 'pending-sync');
762
+ let planPath = null;
763
+ for (const dir of [archiveDir, pendingDir]) {
764
+ if (!fs.existsSync(dir)) continue;
765
+ const match = fs.readdirSync(dir).find(
766
+ (f) => f.startsWith(sprintId + '_') && f.endsWith('.md'),
767
+ );
768
+ if (match) { planPath = path.join(dir, match); break; }
769
+ }
770
+ if (planPath && fs.existsSync(planPath)) {
771
+ try {
772
+ execSync(`node ${JSON.stringify(cliBin74)} push ${JSON.stringify(planPath)}`, {
773
+ stdio: 'inherit',
774
+ env: process.env,
775
+ timeout: 60000,
776
+ });
777
+ process.stdout.write('Step 7.4a passed: sprint plan pushed to MCP.\n');
778
+ } catch (err74a) {
779
+ process.stderr.write(`Step 7.4a warning: sprint plan push failed: ${/** @type {Error} */ (err74a).message}\n`);
780
+ }
781
+ } else {
782
+ process.stdout.write('Step 7.4a skipped: sprint plan file not found.\n');
783
+ }
784
+ // Resolve sprint report path: reuses reportFile resolved via legacy-fallback in Step 4
785
+ if (reportFile && fs.existsSync(reportFile)) {
786
+ try {
787
+ execSync(`node ${JSON.stringify(cliBin74)} push ${JSON.stringify(reportFile)}`, {
788
+ stdio: 'inherit',
789
+ env: process.env,
790
+ timeout: 60000,
791
+ });
792
+ process.stdout.write('Step 7.4b passed: sprint report pushed to MCP.\n');
793
+ } catch (err74b) {
794
+ process.stderr.write(`Step 7.4b warning: sprint report push failed: ${/** @type {Error} */ (err74b).message}\n`);
795
+ }
796
+ } else {
797
+ process.stdout.write('Step 7.4b skipped: sprint report file not found (legacy sprint or report not yet written).\n');
798
+ }
799
+ } else {
800
+ process.stdout.write('Step 7.4 skipped: CLI binary not found (non-fatal).\n');
801
+ }
802
+ } catch (err) {
803
+ // Non-fatal — sprint stays Completed; MCP push can be retried manually
804
+ process.stderr.write(`Step 7.4 warning: MCP push failed: ${/** @type {Error} */ (err).message}\n`);
805
+ process.stderr.write('Run `cleargate push <plan-or-report-path>` manually to retry.\n');
806
+ }
807
+
808
+ // ── Step 7.5: wiki ingest sprint report ──────────────────────────────────
809
+ // CR-063: wiki ingest sprint report
810
+ // Runs after Step 7 (MCP sync). Non-fatal: sprint stays Completed on failure.
811
+ // CR-064 (Wave 3) inserts its MCP-push step at Step 7.4, immediately before this anchor.
812
+ process.stdout.write('Step 7.5: ingesting sprint report into wiki...\n');
813
+ try {
814
+ const cliBin = path.join(REPO_ROOT, 'cleargate-cli', 'dist', 'cli.js');
815
+ if (fs.existsSync(cliBin)) {
816
+ // Resolve report path using the same legacy-fallback rule as Step 4
817
+ // (SPRINT-NN_REPORT.md preferred; fall back to REPORT.md for legacy sprints)
818
+ const reportPath = reportFile; // reportFile is already resolved via legacy-fallback in Step 4
819
+ if (fs.existsSync(reportPath)) {
820
+ execSync(`node ${JSON.stringify(cliBin)} wiki ingest ${JSON.stringify(reportPath)}`, {
821
+ stdio: 'inherit',
822
+ env: process.env,
823
+ timeout: 60000,
824
+ });
825
+ process.stdout.write('Step 7.5 passed: sprint report ingested into wiki.\n');
826
+ } else {
827
+ process.stdout.write('Step 7.5 skipped: report file not found (legacy sprint or report not yet written).\n');
828
+ }
829
+ } else {
830
+ process.stdout.write('Step 7.5 skipped: CLI binary not found (non-fatal).\n');
831
+ }
832
+ } catch (err) {
833
+ // Non-fatal — sprint stays Completed; ingest can be retried manually
834
+ process.stderr.write(`Step 7.5 warning: wiki ingest sprint report failed: ${/** @type {Error} */ (err).message}\n`);
835
+ process.stderr.write('Run `cleargate wiki ingest <report-path>` manually to retry.\n');
836
+ }
837
+
749
838
  // ── Step 8: Verbose post-close handoff list ───────────────────────────────
750
839
  // Prints 6 explicit next-step items to stdout (CR-022 §3 M4).
751
840
  {
@@ -53,6 +53,8 @@ This repository uses **ClearGate** — a standalone planning framework for AI co
53
53
 
54
54
  **Cross-project orchestration.** When running an orchestrator from one project's repo against another project's sprint tree, export `ORCHESTRATOR_PROJECT_DIR=/absolute/path/to/target/repo` in the shell before launching the session. Overrides `CLAUDE_PROJECT_DIR`; sentinel + ledger writes route into the target's `.cleargate/sprint-runs/` tree. If the target has no `.cleargate/sprint-runs/.active` sentinel, writes land in the target's `_off-sprint` bucket — not the orchestrator's own repo.
55
55
 
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
+
56
58
  **Project overrides.** Content OUTSIDE this `<!-- CLEARGATE:START -->...<!-- CLEARGATE:END -->` block takes precedence where it conflicts with ClearGate defaults.
57
59
 
58
60
  **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,10 +1,10 @@
1
1
  {
2
- "cleargate_version": "0.11.4",
3
- "generated_at": "2026-05-05T17:48:13.929Z",
2
+ "cleargate_version": "0.12.0",
3
+ "generated_at": "2026-05-15T05:10:35.575Z",
4
4
  "files": [
5
5
  {
6
6
  "path": ".claude/agents/architect.md",
7
- "sha256": "a2d11d6a7f21bce22730ba9076af9ddde44b258082e33aa99fcd57c14ad75f55",
7
+ "sha256": "823db34b934d080e648955326dcc3cd31899e90f62ecfa4a9344f5b473237084",
8
8
  "tier": "agent",
9
9
  "overwrite_policy": "always",
10
10
  "preserve_on_uninstall": false
@@ -165,7 +165,7 @@
165
165
  },
166
166
  {
167
167
  "path": ".cleargate/knowledge/cleargate-protocol.md",
168
- "sha256": "50e999717b9c9e1c11638f3f2433f413d177ed8ddf3cffdbb20b50c8807b1fc5",
168
+ "sha256": "0380e74efa8aa782b77952fa68cc0171de035653e777d5c241d84c6e0414957b",
169
169
  "tier": "protocol",
170
170
  "overwrite_policy": "merge-3way",
171
171
  "preserve_on_uninstall": false
@@ -200,7 +200,7 @@
200
200
  },
201
201
  {
202
202
  "path": ".cleargate/scripts/close_sprint.mjs",
203
- "sha256": "1807e5b27f1501476c9dec41cbb350c432d2894cb0727d8da0c860ad3f9181c7",
203
+ "sha256": "b42018973ec6f02fc5d0ddf2a7d302aa0ee6d127cb5140474a67cb1fb0af6b28",
204
204
  "tier": "script",
205
205
  "overwrite_policy": "always",
206
206
  "preserve_on_uninstall": false