Skip to content

Commit 6c71b5f

Browse files
release: GraphStack v4.3.0 — deterministic process gate
Adds mechanical handoff enforcement so Architect → Builder steps are harder to skip silently, while keeping the full MD-based orchestrator workflow unchanged. New CLI: graphstack gate (check / hook cursor / hook claude) and graphstack state (handoff/STATE.json). Hook adapters for Cursor (.cursor/hooks.json) and Claude Code (.claude/settings.json). Portable gate-hook.ps1 / gate-hook.sh shims resolve py -3 vs python on Windows. Gate rules: deny code commits/edits without a board task in doing/; deny commits when BRIEF.md is still the template; advisory STATE.json staleness on turn end. Fail-open on hook errors; bypass via GRAPHSTACK_GATE=off. Also: framework handoff hygiene (.graphstack-framework + validate warnings), Builder/Orchestrator confirmation fix, token rules condensed to TOKEN_OPTIMIZER.md, README/CHANGELOG updated. 74 tests passing. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2c40aab commit 6c71b5f

28 files changed

Lines changed: 6099 additions & 2002 deletions

.claude/settings.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"hooks": {
3+
"PreToolUse": [
4+
{
5+
"matcher": "Edit|Write|MultiEdit|NotebookEdit|Bash",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-hook.ps1 claude",
10+
"timeout": 30
11+
}
12+
]
13+
}
14+
],
15+
"Stop": [
16+
{
17+
"hooks": [
18+
{
19+
"type": "command",
20+
"command": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-hook.ps1 claude",
21+
"timeout": 30
22+
}
23+
]
24+
}
25+
]
26+
}
27+
}

.cursor/hooks.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": 1,
3+
"hooks": {
4+
"beforeShellExecution": [
5+
{ "command": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-hook.ps1 cursor" }
6+
],
7+
"afterFileEdit": [
8+
{ "command": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-hook.ps1 cursor" }
9+
],
10+
"stop": [
11+
{ "command": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-hook.ps1 cursor" }
12+
]
13+
}
14+
}

.cursor/skills/architect/ARCHITECT.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,4 @@ When `handoff/REVIEW.md` has a rejection:
159159

160160
## Token Rules (Architect)
161161

162-
- Read GRAPH_REPORT.md once per session — never twice
163-
- Query graph.json for structural questions instead of reading multiple files
164-
- If you need to read a raw file: read only the relevant function/class, not the whole file
165-
- Never produce output the user didn't ask for
162+
Follow `orchestrator/TOKEN_OPTIMIZER.md` (loaded at session start). Architect-specific: graph before raw files; one targeted read if the graph is insufficient; no output the user didn't ask for.

.cursor/skills/builder/BUILDER.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ When activated, execute this sequence exactly:
2929
4. Claim the task:
3030
python -m graphstack board claim <task-id> builder
3131
32-
5. Report:
33-
"Graph loaded. Brief loaded. Board task claimed: [task-id]
34-
Objective: [one line from brief]
35-
Files to change: [list]
36-
Acceptance criteria: [N items]
37-
Ready to build. Proceed?"
32+
5. Update machine-readable state (Orchestrator already confirmed the brief —
33+
do NOT ask the user again):
34+
python -m graphstack state set --role builder --task <task-id>
3835
39-
6. Wait for user confirmation before writing any code.
36+
6. Report once, then start building immediately:
37+
"[BUILDER MODE] Task: [task-id] | Criteria: [N] | Files: [list]"
4038
```
4139

4240
---
@@ -166,10 +164,4 @@ Ready for Reviewer.
166164

167165
## Token Rules (Builder)
168166

169-
```
170-
Read GRAPH_REPORT.md once → never again this session
171-
Read each file maximum once → use context after
172-
Parallel file reads when possible → one tool call, multiple files
173-
No speculative reads → only read what the brief requires
174-
No output longer than needed → code + brief explanation only
175-
```
167+
Follow `orchestrator/TOKEN_OPTIMIZER.md` (loaded at session start). Builder-specific: read only brief-listed files; parallel reads in one tool call; no speculative exploration.

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ jobs:
9797
"scripts/graphstack/platform_utils.py",
9898
"scripts/graphstack/constants.py",
9999
"scripts/graphstack/validate.py",
100+
"scripts/graphstack/gate.py",
101+
"scripts/graphstack/state.py",
102+
"scripts/gate-hook.sh",
103+
"scripts/gate-hook.ps1",
104+
".cursor/hooks.json",
105+
".claude/settings.json",
106+
".graphstack-framework",
100107
".graphifyignore",
101108
"docs/case-studies/graphstack-self.md",
102109
]
@@ -134,6 +141,9 @@ jobs:
134141
- name: Validate project layout (graphstack validate)
135142
run: python -m graphstack validate
136143

144+
- name: Process gate check (graphstack gate)
145+
run: python -m graphstack gate check
146+
137147
- name: Refresh knowledge graph (CI)
138148
run: graphify update .
139149

.graphstack-framework

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# GraphStack framework source repository (not a consumer project).
2+
# handoff/ must ship as templates — reset BRIEF/REVIEW/STATE and clear board/done/
3+
# before release commits. See CONTRIBUTING.md.

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ All notable changes to GraphStack are documented here.
44

55
---
66

7+
## [v4.3.0] — 2026-06-11
8+
9+
### Added
10+
- **`graphstack gate`** — deterministic process enforcement: `gate check` (CI/manual), `gate hook cursor`, `gate hook claude`. Rules: deny code commits/edits when no board task is in `doing/`, or when `BRIEF.md` is still the template. Fail-open on hook errors; bypass via `GRAPHSTACK_GATE=off` or `handoff/.gate-off`.
11+
- **`graphstack state`** — machine-readable `handoff/STATE.json` (`set` / `get` / `clear`) for hook verification and resume.
12+
- **Hook adapters**`.cursor/hooks.json` (Cursor 3.x, `version: 1`) and `.claude/settings.json` (Claude Code `PreToolUse` + `Stop`). Installer writes OS-specific commands (`gate-hook.ps1` on Windows, `gate-hook.sh` on Unix).
13+
- **`scripts/gate-hook.sh` / `scripts/gate-hook.ps1`** — portable shims (resolve `py -3` / `python3` / `python` without hardcoding).
14+
- **`.graphstack-framework` marker**`validate` warns when the framework repo ships dirty handoff state (non-template brief, `done/` tasks, active `STATE.md` entries).
15+
- **Pytest**`test_gate.py` (26 tests), `test_state.py` (5 tests).
16+
17+
### Changed
18+
- **ORCHESTRATOR** — token tier detail moved to `TOKEN_OPTIMIZER.md` (reference only); state persistence now includes `state set`.
19+
- **BUILDER** — removed duplicate user confirmation at activation (Orchestrator brief confirmation is the single human gate); activation now runs `state set` and builds immediately.
20+
- **ARCHITECT / BUILDER** — token rules condensed to pointers to `TOKEN_OPTIMIZER.md`.
21+
- **CI**`graphstack gate check` step; required-files manifest includes gate modules and hook shims.
22+
- **README** — Process Gate section; Limitations updated.
23+
24+
### Fixed
25+
- **Windows hook launcher** — hooks no longer hardcode `python` (often missing on Windows); shims prefer `py -3`.
26+
27+
---
28+
729
## [v4.2.0] — 2026-05-17
830

931
### Added

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ When you introduce a copy change, restart Cursor once locally (and mention that
5656

5757
---
5858

59+
## Framework repo: reset `handoff/` before release commits
60+
61+
This repository **is** GraphStack (marker: `.graphstack-framework`). The `handoff/` folder ships as **empty templates** for projects that run `install.sh` — not as a log of our own development cycles.
62+
63+
Before pushing framework changes to GitHub:
64+
65+
1. Restore `handoff/BRIEF.md`, `handoff/REVIEW.md`, and `handoff/STATE.md` to their templates (no real task content).
66+
2. Remove any `handoff/board/done/*.json` and `handoff/STATE.json`.
67+
3. Run `python -m graphstack validate` — warnings `framework_*` should be zero.
68+
69+
Consumer projects keep their handoff history; only this source repo resets.
70+
71+
---
72+
5973
## Pull Request Guidelines
6074

6175
- **One PR per change.** Don't bundle unrelated edits.

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ One prompt starts the entire lifecycle — from blank repo to production.
77

88
[![CI](https://github.com/MertCapkin/graphstack/actions/workflows/ci.yml/badge.svg)](https://github.com/MertCapkin/graphstack/actions)
99
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
10-
[![Version](https://img.shields.io/badge/version-v4.2.0-blue)](CHANGELOG.md)
10+
[![Version](https://img.shields.io/badge/version-v4.3.0-blue)](CHANGELOG.md)
1111
[![Platforms](https://img.shields.io/badge/platforms-Windows%20%7C%20macOS%20%7C%20Linux-success)](#compatibility)
1212
[![Works with Cursor](https://img.shields.io/badge/Works%20with-Cursor-blue)](https://cursor.sh)
1313
[![Works with Claude Code](https://img.shields.io/badge/Works%20with-Claude%20Code-orange)](https://claude.ai/code)
1414

1515
</div>
1616

17-
> **v4.2 highlights:** `graphstack run`token-safe shell output for git/tests (quality-preserving compaction, no external deps). Plus v4.1: `pip install -e .`, `validate` / `doctor`, CI graph checks. See [CHANGELOG.md](CHANGELOG.md).
17+
> **v4.3 highlights:** `graphstack gate`deterministic handoff enforcement via Cursor + Claude Code hooks (brief + board task required before code changes). Plus v4.2 `graphstack run` (token-safe shell output), v4.1 `validate` / `doctor`. See [CHANGELOG.md](CHANGELOG.md).
1818
1919
---
2020

@@ -306,7 +306,7 @@ GraphStack is a **workflow protocol** (markdown + handoff files), not a runtime
306306

307307
| Topic | Reality |
308308
|-------|---------|
309-
| Role automation | The Orchestrator state machine lives in `ORCHESTRATOR.md`. Models can skip Activation or transitions unless you use discipline + `graphstack validate`. |
309+
| Role automation | Prompts alone cannot guarantee discipline. v4.3 adds **`graphstack gate`** (hook-enforced) + `state set` + `validate`. Hooks block code commits/edits without a claimed board task; turn-end hooks are advisory only. |
310310
| Token savings | The table above is **estimated**, not guaranteed. Small repos or undisciplined sessions may use **more** tokens than unstructured chat. |
311311
| Knowledge graph | Value appears on **20+ file** codebases with module boundaries. Meta-repos full of markdown produce noisy graphs — use `.graphifyignore` (included in this repo). |
312312
| Setup | Graphify + GraphStack install + `/graphify` + Cursor — four steps, not zero-config. |
@@ -347,6 +347,29 @@ Independent Python implementation (MIT) — inspired by common agent-tooling pat
347347

348348
---
349349

350+
## Process Gate (`graphstack gate`)
351+
352+
v4.3 adds **mechanical enforcement** so Architect → Builder → Reviewer steps are harder to skip silently.
353+
354+
| Rule | What it blocks | Platform |
355+
|------|----------------|----------|
356+
| R1 | `git commit` touching code while `handoff/board/doing/` is empty | Cursor + Claude Code |
357+
| R2 | Edit/Write on code paths while `doing/` is empty | Claude Code (`PreToolUse`) |
358+
| R3 | Commit while `BRIEF.md` is still the template and a task is in `doing/` | Both |
359+
| R4 | *(advisory)* `STATE.json` not updated this cycle | Turn-end hooks |
360+
361+
```bash
362+
python -m graphstack gate check # CI / manual — exit 1 on violation
363+
python -m graphstack state set --role builder --task my-feature
364+
GRAPHSTACK_GATE=off # emergency bypass (one session)
365+
```
366+
367+
**Install** writes `.cursor/hooks.json` and `.claude/settings.json` with OS-specific shim commands (`scripts/gate-hook.ps1` on Windows, `scripts/gate-hook.sh` on macOS/Linux). Hooks **fail open** if Python is missing — a crashing gate is worse than no gate.
368+
369+
> **Framework repo note:** This GitHub repo ships `handoff/` as **templates** (empty brief, no `done/` tasks). Your installed project fills those files during real work. Before contributing here, reset handoff — see [CONTRIBUTING.md](CONTRIBUTING.md).
370+
371+
---
372+
350373
## What Gets Installed
351374

352375
```

0 commit comments

Comments
 (0)