@manhquy/flow-skill 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to `@manhquy/flow-skill`. Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: [SemVer](https://semver.org/).
4
4
 
5
+ ## [0.5.0] — 2026-08-11 — ships skill v0.28.0 (attested execution)
6
+
7
+ Installer minor: bundles skill **v0.28.0** (risk + attestation receipts + auto trust plane).
8
+ Installer CLI contract unchanged. Prerelease dist-tag policy: **`next`**.
9
+
5
10
  ## [0.4.1] — 2026-08-11 — README + CLI help install UX
6
11
 
7
12
  Docs-only installer release (same skill **v0.27.0**). Professional install section, full
package/README.md CHANGED
@@ -5,7 +5,7 @@ Install the **flow** skill into coding agents with one command.
5
5
  | | |
6
6
  |---|---|
7
7
  | **Package** | [`@manhquy/flow-skill`](https://www.npmjs.com/package/@manhquy/flow-skill) (installer CLI) |
8
- | **Current GA** | **0.4.1** — ships skill product **v0.27.0** |
8
+ | **Current GA** | **0.5.1** — ships skill product **v0.28.1** |
9
9
  | **Platforms** | macOS · Linux · Windows (same Node path) |
10
10
  | **Requirement** | Node.js **≥ 22.14** |
11
11
  | **Source** | [github.com/manhquydev/flow-skill](https://github.com/manhquydev/flow-skill) |
@@ -34,7 +34,7 @@ npx @manhquy/flow-skill@latest
34
34
 
35
35
  ```bash
36
36
  npx @manhquy/flow-skill@latest --help
37
- # expect: flow-skill v0.4.x (ships skill v0.27.x)
37
+ # expect: flow-skill v0.5.x (ships skill v0.27.x)
38
38
  ```
39
39
 
40
40
  ### Common commands
@@ -89,7 +89,7 @@ npx @manhquy/flow-skill@latest --yes --all --dry-run --json
89
89
  |----|--------|
90
90
  | `npx @manhquy/flow-skill@latest` | Bare `npx @manhquy/flow-skill` (stale npx cache) |
91
91
  | **Run** the CLI to copy the skill | `npm i` alone (package only; no skill files in agent homes) |
92
- | Pin installer `@0.4.1` if needed | Pin npm `@0.27.0` (skill version ≠ package version) |
92
+ | Pin installer `@0.5.1` if needed | Pin npm `@0.28.1` (skill version ≠ package version) |
93
93
  | Prefer `@latest` | `@rc` (retired / behind) |
94
94
 
95
95
  **Two version axes:** `package.json` version = installer; `SKILL.md` metadata = skill product. Both appear in `--help` and in the `plan` JSONL event (`version` + `skillVersion`).
@@ -137,7 +137,7 @@ rm -rf <project>/.claude/skills/flow
137
137
  |---------|-----|
138
138
  | Agent has no `/flow` after `npm i` | Run `npx @manhquy/flow-skill@latest` (install must **execute**) |
139
139
  | Old skill after reinstall | Always use `@latest`; avoid bare package name |
140
- | `No matching version found` for `@0.27.0` | That is the **skill** version. Use `@latest` or `@0.4.x` |
140
+ | `No matching version found` for `@0.28.1` | That is the **skill** version. Use `@latest` or `@0.5.x` |
141
141
  | Node too old | Install Node ≥ 22.14 (`nvm install 22`, etc.) |
142
142
  | Windows `EBUSY` / `EPERM` | Close the agent holding files under the skill dir; re-run |
143
143
  | Stale install lock | Delete `<parent>/.flow-skill.installing.lock` if reclaim fails |
@@ -147,7 +147,7 @@ rm -rf <project>/.claude/skills/flow
147
147
  ## JSONL (`--json`)
148
148
 
149
149
  ```jsonl
150
- {"event":"plan","version":"0.4.1","skillVersion":"0.27.0","dryRun":false,"scope":"global","targets":["claude"]}
150
+ {"event":"plan","version":"0.5.1","skillVersion":"0.28.1","dryRun":false,"scope":"global","targets":["claude"]}
151
151
  {"event":"install:start","target":"claude","dests":["~/.claude/skills/flow"]}
152
152
  {"event":"install:done","target":"claude","dests":["~/.claude/skills/flow"],"result":"success","error":null,"warnings":[]}
153
153
  {"event":"summary","success":true,"total":1,"attempted":1,"installed":1,"failed":0,"skipped":0,"aborted":false}
package/README_VN.md CHANGED
@@ -10,7 +10,7 @@ Cài skill **flow** vào coding agent bằng một lệnh.
10
10
  | **Yêu cầu** | Node.js **≥ 22.14** |
11
11
  | **Source** | [github.com/manhquydev/flow-skill](https://github.com/manhquydev/flow-skill) |
12
12
 
13
- flow là harness build có cổng (`/flow`). Package này chỉ **cài** skill đó vào skill home của agent.
13
+ flow là harness build có cổng (`/flow`): ý tưởng → cổng trung thực → bằng chứng done thật. Package này chỉ **cài** skill đó vào skill home của agent.
14
14
 
15
15
  ---
16
16
 
@@ -23,12 +23,12 @@ npx @manhquy/flow-skill@latest
23
23
 
24
24
  | Bước | Chi tiết |
25
25
  |------|----------|
26
- | 1 | Tải dist-tag **`latest`** từ npm |
27
- | 2 | Multi-select agent (Claude luôn được đề xuất) |
28
- | 3 | Copy `skills/flow` vào từng đích |
29
- | 4 | In hướng dẫn gọi sau reload (`/flow`, `$flow`, …) |
26
+ | 1 | Tải dist-tag **`latest`** từ npm registry |
27
+ | 2 | Multi-select tương tác các agent detect được (Claude luôn được đề xuất) |
28
+ | 3 | Copy cây `skills/flow` vào từng đích đã chọn |
29
+ | 4 | In hướng dẫn sau reload (`/flow`, `$flow`, …) |
30
30
 
31
- **Sau cài:** restart/reload agent (xem [Sau khi cài](#sau-khi-cài)).
31
+ **Sau cài:** restart hoặc reload agent (xem [Sau khi cài](#sau-khi-cài)).
32
32
 
33
33
  ### Xác nhận version
34
34
 
@@ -43,18 +43,18 @@ npx @manhquy/flow-skill@latest --help
43
43
  # Không prompt (Claude + agent đã detect)
44
44
  npx @manhquy/flow-skill@latest --yes
45
45
 
46
- # Target rõ ràng
46
+ # Một hoặc nhiều target
47
47
  npx @manhquy/flow-skill@latest --yes --target claude
48
48
  npx @manhquy/flow-skill@latest --yes -t claude -t codex
49
49
  npx @manhquy/flow-skill@latest --yes -t claude,codex
50
50
 
51
- # Cả 5 target
51
+ # Mọi target được hỗ trợ
52
52
  npx @manhquy/flow-skill@latest --yes --all
53
53
 
54
- # Skill trong repo (chỉ Claude)
54
+ # Skill Claude trong repo (dễ commit)
55
55
  npx @manhquy/flow-skill@latest --yes --project --dir .
56
56
 
57
- # Chỉ xem kế hoạch + JSONL (CI)
57
+ # Chỉ xem kế hoạch, không ghi đĩa + JSONL (CI)
58
58
  npx @manhquy/flow-skill@latest --yes --all --dry-run --json
59
59
  ```
60
60
 
@@ -62,37 +62,37 @@ npx @manhquy/flow-skill@latest --yes --all --dry-run --json
62
62
 
63
63
  | Flag | Ý nghĩa |
64
64
  |------|---------|
65
- | `-y`, `--yes` | Bỏ prompt; cài selection mặc định |
66
- | `-t`, `--target <name>` | Target (lặp hoặc comma) |
65
+ | `-y`, `--yes` | Bỏ prompt; cài selection mặc định (detected + Claude) |
66
+ | `-t`, `--target <name>` | Target (lặp được hoặc comma-separated) |
67
67
  | `--all` | Mọi target, kể cả chưa detect |
68
68
  | `--project` | Scope project — chỉ Claude → `<dir>/.claude/skills/flow` |
69
- | `--dir <path>` | Thư mục project (kéo theo `--project`) |
70
- | `--json` | JSONL events |
71
- | `--dry-run` | Không ghi đĩa |
69
+ | `--dir <path>` | Thư mục project (kéo theo `--project`; mặc định: cwd) |
70
+ | `--json` | JSONL events (`plan`, `install:*`, `summary`) |
71
+ | `--dry-run` | In plan; không ghi đĩa |
72
72
  | `-h`, `--help` | Help |
73
73
 
74
74
  ### Targets
75
75
 
76
76
  | Tên | Đích | Detection |
77
77
  |-----|------|-----------|
78
- | `claude` | `~/.claude/skills/flow` | `~/.claude` |
78
+ | `claude` | `~/.claude/skills/flow` | `~/.claude` (luôn được đề xuất) |
79
79
  | `codex` | `~/.codex/skills/flow` | `~/.codex/skills` |
80
80
  | `agents` | `~/.agents/skills/flow` | `~/.agents/skills` |
81
- | `antigravity` | 2 path dưới `~/.gemini/…` | CLI hoặc IDE skills |
81
+ | `antigravity` | `~/.gemini/antigravity-cli/skills/flow` **và** `~/.gemini/config/skills/flow` | một trong hai path |
82
82
  | `cursor` | `~/.cursor/skills/flow` | `~/.cursor/skills` |
83
83
 
84
- `--project` **chỉ** hỗ trợ `claude` (exit `2` nếu kết hợp target khác).
84
+ `--project` **chỉ** hỗ trợ `claude`. Kết hợp target khác → exit `2`.
85
85
 
86
86
  ### Quy tắc
87
87
 
88
88
  | Nên | Không |
89
89
  |-----|--------|
90
- | `npx @manhquy/flow-skill@latest` | Bare package name (cache npx) |
91
- | **Chạy** CLI | Chỉ `npm i` |
92
- | Pin `@0.4.0` nếu cần | Pin `@0.27.0` trên npm (version skill) |
93
- | `@latest` | `@rc` |
90
+ | `npx @manhquy/flow-skill@latest` | Bare `npx @manhquy/flow-skill` (cache npx có thể cũ) |
91
+ | **Chạy** CLI để copy skill | Chỉ `npm i` (chỉ thêm package; không cài skill vào agent home) |
92
+ | Pin installer `@0.4.1` nếu cần cố định | Pin npm `@0.27.0` (version **skill** ≠ version package) |
93
+ | Ưu tiên `@latest` / `@0.4.x` | `@rc` (đã retire / tụt hậu) |
94
94
 
95
- **Hai trục version:** package = installer; skill = `SKILL.md`. Cả hai hiện trong `--help` và event `plan` (`version` + `skillVersion`).
95
+ **Hai trục version:** `package.json` = installer CLI; `SKILL.md` metadata = skill product. Cả hai hiện trong `--help` và event JSONL `plan` (`version` + `skillVersion`).
96
96
 
97
97
  ---
98
98
 
@@ -101,10 +101,13 @@ npx @manhquy/flow-skill@latest --yes --all --dry-run --json
101
101
  | Agent | Bước tiếp |
102
102
  |-------|-----------|
103
103
  | Claude Code | Gõ `/flow` |
104
- | Codex | Restart Codex → `$flow` |
105
- | Antigravity | Restart IDE/`agy` → `/flow` |
106
- | Agents / Cursor | Reload tool; kiểm panel skill |
107
- | Bất kỳ | `/flow doctor` |
104
+ | Codex CLI | Restart Codex một lần → `$flow` |
105
+ | Antigravity | Restart IDE / `agy` → `/flow` |
106
+ | Agents home | Reload tool nếu không tự nhận skill mới |
107
+ | Cursor | Reload Cursor; kiểm panel agent skills |
108
+ | Bất kỳ | `/flow doctor` (hoặc `runner/flow.sh doctor`) |
109
+
110
+ ### Kiểm tra trên đĩa (Claude global)
108
111
 
109
112
  ```bash
110
113
  grep -E '^\s*version:' ~/.claude/skills/flow/SKILL.md | head -1
@@ -116,9 +119,13 @@ bash ~/.claude/skills/flow/runner/flow.sh doctor
116
119
  ## Gỡ cài
117
120
 
118
121
  ```bash
119
- rm -rf ~/.claude/skills/flow ~/.codex/skills/flow ~/.agents/skills/flow
122
+ rm -rf ~/.claude/skills/flow
123
+ rm -rf ~/.codex/skills/flow
124
+ rm -rf ~/.agents/skills/flow
120
125
  rm -rf ~/.cursor/skills/flow
121
- rm -rf ~/.gemini/antigravity-cli/skills/flow ~/.gemini/config/skills/flow
126
+ rm -rf ~/.gemini/antigravity-cli/skills/flow
127
+ rm -rf ~/.gemini/config/skills/flow
128
+ # project scope:
122
129
  rm -rf <project>/.claude/skills/flow
123
130
  ```
124
131
 
@@ -128,16 +135,34 @@ rm -rf <project>/.claude/skills/flow
128
135
 
129
136
  | Hiện tượng | Cách xử lý |
130
137
  |------------|------------|
131
- | Có package nhưng không có `/flow` | Chạy `npx @manhquy/flow-skill@latest` |
132
- | Skill cũ sau khi “cài lại” | Luôn `@latest` |
133
- | `No matching version` với `@0.27.0` | Dùng `@latest` / `@0.4.x` (version skill ≠ package) |
134
- | Node quá cũ | Nâng Node ≥ 22.14 |
135
- | Windows EBUSY | Đóng agent đang giữ file skill; chạy lại |
138
+ | Agent không có `/flow` sau `npm i` | Chạy `npx @manhquy/flow-skill@latest` (phải **execute** installer) |
139
+ | Skill cũ sau khi “cài lại” | Luôn dùng `@latest`; tránh bare package name |
140
+ | `No matching version found` với `@0.27.0` | Đó là version **skill**. Dùng `@latest` hoặc `@0.4.x` |
141
+ | Node quá cũ | Cài Node ≥ 22.14 (`nvm install 22`, v.v.) |
142
+ | Windows `EBUSY` / `EPERM` | Đóng agent đang giữ file trong skill dir; chạy lại |
143
+ | Stale install lock | Xóa `<parent>/.flow-skill.installing.lock` nếu reclaim thất bại |
136
144
 
137
145
  ---
138
146
 
139
- ## JSONL · provenance · license
147
+ ## JSONL (`--json`)
148
+
149
+ ```jsonl
150
+ {"event":"plan","version":"0.4.1","skillVersion":"0.27.0","dryRun":false,"scope":"global","targets":["claude"]}
151
+ {"event":"install:start","target":"claude","dests":["~/.claude/skills/flow"]}
152
+ {"event":"install:done","target":"claude","dests":["~/.claude/skills/flow"],"result":"success","error":null,"warnings":[]}
153
+ {"event":"summary","success":true,"total":1,"attempted":1,"installed":1,"failed":0,"skipped":0,"aborted":false}
154
+ ```
155
+
156
+ Exit codes: `0` success · `1` target failure · `2` bad usage · `130` SIGINT.
157
+
158
+ Contract additive: field mới có thể xuất hiện; field hiện có không đổi tên/xóa.
159
+
160
+ ---
161
+
162
+ ## Provenance & bảo mật
163
+
164
+ Bản publish từ CI có [npm provenance](https://docs.npmjs.com/generating-provenance-statements). Mô hình đe dọa và báo cáo: [SECURITY.md](./SECURITY.md).
140
165
 
141
- Xem bản [English README](./README.md) cho bảng event JSONL, provenance, và [SECURITY.md](./SECURITY.md).
166
+ ## License
142
167
 
143
168
  MIT © 2026 manhquy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manhquy/flow-skill",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "Install the flow skill (buildflow gated build process) into your coding agent(s) via one npx command",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,12 +3,12 @@ name: flow
3
3
  description: Run the buildflow gated build process from idea to real done-evidence. Walk gated stages (Idea->Research->Scope->PRD->ADR->Contract->Cards->Build->Review->Deploy/Ship->Verify->Retro), each with a honest gate that must pass before advancing. Adapts to project type (web|cli|library|skill). Use when starting or driving a real product build, when the user types /flow, /flow next, /flow card, /flow check, or asks to scope/plan/ship a project through gates. Kill at any gate is a valid outcome.
4
4
  user-invocable: true
5
5
  when_to_use: "User wants to build a real product end-to-end with discipline (idea -> a deployed URL for web, or installs+runs for a CLI/library/skill), or types any /flow command, or asks for a gated build process, scope decision, contract-first plan, or card-based shipping."
6
- argument-hint: "[ resume | next | card | check C-NNN | project-type web|cli|library|skill | mode teach|work | skip <stage> | ready | workspace add|list|enter|remove|check|doctor | auto | doctor | retro | eval --stage 01|02|card|routing --fixture <id> --n 3 --keep-going --report | or just say what you want in plain language ]"
6
+ argument-hint: "[ resume | next | card | check C-NNN | project-type web|cli|library|skill | mode teach|work | skip <stage> | ready | workspace add|list|enter|remove|check|doctor | auto [stop] | attest semantic|live-verify|status|recover | doctor | retro | eval --stage 01|02|05|card|routing --fixture <id> --n 3 --keep-going --report | or just say what you want in plain language ]"
7
7
  keywords: [flow, buildflow, gate, build, ship, scope, prd, contract, card, deploy, vertical-slice, cli, library, skill, worktree, parallel-agents, workspace, multi-agent]
8
8
  license: MIT
9
9
  metadata:
10
10
  author: flow-skill
11
- version: "0.27.0"
11
+ version: "0.28.1"
12
12
  attribution: "Methodology from ai20k-build-phase/buildflow (Tony, arealisticdreamer.com); durable-layer ancestry and improve-ritual spirit from repository-harness (protocol v1 EOL — flow-owned fork); agent patterns from claudekit-engineer, BMAD-METHOD. v0.22 concierge from BMAD bmad-help; forge-idea from bmad-forge-idea (MIT, BMad Code LLC)."
13
13
  ---
14
14
 
@@ -94,7 +94,8 @@ takes over a lock you're sure is dead; `/flow unlock` clears it.
94
94
  | `/flow mode teach\|work` | set who writes the artifacts (default `teach`) |
95
95
  | `/flow ready` | `flow.sh ready` — which todo cards are buildable + parallel-safety hint |
96
96
  | `/flow workspace add\|list\|enter\|remove\|check\|doctor` | `flow.sh workspace …` — **multi-agent worktree isolation** for running several agents (Claude/Codex/Antigravity, many terminals) in parallel WITHOUT the "one agent switches branch → every terminal flips" trap. Each agent gets its own `git worktree` (own HEAD/index/files, shared object store); git is the live registry (`git worktree list`) and a 10-field JSONL side-file (`.flow/workspaces.jsonl`) adds vendor/card/port/task. `add <branch> [--card C-NNN] [--vendor …] [--task …] [--copy-env]` provisions a worktree + distinct port-offset + paste-ready cd/env block; `list` shows who-is-where; `enter <branch>` re-prints a crashed terminal's env; `check <branch> [--card]` flags branch-claim + allowed-files overlap before you launch; `remove <branch> [--force]` tears down safely (never auto-forces); `doctor` reconciles orphan trees/records. Advisory layer; git's refusal to check out one branch twice is the real lock. |
97
- | `/flow auto` | `flow.sh auto` preflight, then drive the autonomous run (see AUTO principles) |
97
+ | `/flow auto` | `flow.sh auto` — attested preflight (risk + Stage 05 receipt) activates shared auto policy; then drive the autonomous run (see AUTO principles). `auto stop` clears it. |
98
+ | `/flow attest …` | `flow.sh attest semantic\|live-verify\|status\|recover` — mint/inspect fingerprint-bound receipts (`references/attestations.md`) |
98
99
  | `/flow recall` | `flow.sh recall` — read back durable memory (open debt, recent retro, previous-card scope, harness friction/backlog, playbooks) **at the start of a stage/card** so you don't re-learn known pain |
99
100
  | `/flow usage` | `flow.sh usage` — roll up the mechanical usage log (JSONL flight-recorder of every invocation) into `usage_event` and print build analytics: cycle-time, gate fail-rate, per-stage dwell, cycle completion, command breakdown. `--global` for the device-wide view; `--prune [--keep N]` caps the log (crash-safe). Local-only; disable with `FLOW_LOG_DISABLE=1`/`DO_NOT_TRACK=1`. `recall` now surfaces a one-line usage digest and `retro`'s `propose` flags chronically-failing stages. |
100
101
  | `/flow contract` | `flow.sh contract` — flag client base-URL vs served-path prefix drift (web; advisory; run after the contract gate) |
@@ -189,11 +190,16 @@ deliver the card set as one summary. Gates bind the same as `teach`.
189
190
 
190
191
  ## AUTO principles
191
192
 
192
- `/flow auto` drives the build phase autonomously (`references/auto-run.md`). Operator
193
- setting: **Tier-A auto-merge green cards; halt at security-class.** Per card: tier-classify
194
- → one scoped subagent in its own worktree → build to contract → adversarial review →
195
- `flow.sh check` PASS → merge in card order → deploy → **verify on the LIVE URL** (merge ≠
196
- shipped) → world-state evidence → `status: done` → durable trace + `AUTO-LOG.md`.
193
+ `/flow auto` drives the build phase autonomously (`references/auto-run.md`) under the
194
+ **attested-execution** trust control plane (`references/attestations.md`). Mechanical
195
+ preflight persists auto policy only when every card has classified risk (security-class
196
+ needs a distinct-author DEBT ack) and Stage 05 has a current `semantic_gate` receipt.
197
+ While auto is active, `check` / `card done` / ready deps / merged worktree remove require
198
+ fingerprint-bound semantic and live receipts; `auto stop` returns to warning-only manual
199
+ mode. Operator setting: **Tier-A auto-merge green cards; halt at security-class.** Per
200
+ card: tier-classify → scoped subagent in its own worktree → build → adversarial review →
201
+ owner-backed semantic receipt → `flow.sh check` PASS → merge → deploy → live_verify
202
+ receipt → world-state evidence → `card done` → durable trace + `AUTO-LOG.md`.
197
203
  - **Tier A**: green + no security-class → auto-merge, no ask.
198
204
  - **Tier B**: fixable issues → one repair by a FRESH subagent (two-strikes), else escalate.
199
205
  If the fix needs >1 experimental attempt against a single numeric target (not a review
@@ -3,6 +3,9 @@
3
3
  status: todo
4
4
  deps: [FILL: card ids this depends on, e.g. "C-001, C-002" — or "none"]
5
5
  implements: [FILL: PRD feature ids this card delivers, e.g. "FR1, FR2" — or "infra"/"none" for non-feature cards]
6
+ risk: unknown
7
+ risk-reason:
8
+ risk-ack: none
6
9
 
7
10
  ## Scope
8
11
 
@@ -0,0 +1,22 @@
1
+ # 05 — Contract
2
+
3
+ ## Interfaces
4
+
5
+ | Method | Path | Request | Response | Errors | Owner |
6
+ |---|---|---|---|---|---|
7
+ | GET | /healthz | none | `{ "ok": true }` | 503 if deps down | platform |
8
+
9
+ ## Auth
10
+
11
+ - Public: `/healthz` only.
12
+ - All other routes: bearer session token; 401 if missing/invalid.
13
+
14
+ ## Error model
15
+
16
+ - `code` (string), `message` (string), `request_id` (string).
17
+ - 4xx client; 5xx server; no silent 200 on failure.
18
+
19
+ ## Gate
20
+ - [x] Every endpoint has method, path, request, response, errors, owner.
21
+ - [x] Auth boundary is explicit for each route class.
22
+ - [x] Error shape is machine-readable and stable.
@@ -0,0 +1,11 @@
1
+ # 05 — Contract
2
+
3
+ ## Interfaces
4
+
5
+ We will expose some APIs as needed. Endpoints are flexible and will evolve.
6
+ Auth might be optional depending on context. Errors should be helpful.
7
+
8
+ ## Gate
9
+ - [x] Interfaces sketched
10
+ - [x] Auth considered
11
+ - [x] Errors mentioned
@@ -6,3 +6,5 @@ f02b 02-scope flow/02-scope.md FLAG
6
6
  fcda card cards/C-001.md PASS
7
7
  fcdb card cards/C-001.md FLAG
8
8
  fcdc card cards/C-001.md FLAG
9
+ f05a 05-contract flow/05-contract.md PASS
10
+ f05b 05-contract flow/05-contract.md FLAG
@@ -0,0 +1,307 @@
1
+ # Attestations — risk, receipts, and auto trust (v0.28)
2
+
3
+ Canonical owner for **card risk**, **attestation receipts**, **subject
4
+ fingerprints**, and **auto-active policy state**. Other docs link here; do not
5
+ duplicate full schemas.
6
+
7
+ Fingerprints detect **staleness** of a reviewed/verified subject. They do **not**
8
+ authenticate a human or model. Actor/engine labels and unsigned receipt files
9
+ are forgeable by a filesystem/repository owner. This layer is workflow integrity,
10
+ not a hostile-host or cryptographic identity boundary.
11
+
12
+ ## Risk fields (card markdown)
13
+
14
+ ```text
15
+ risk: standard|security-class|unknown
16
+ risk-reason: <single line, 1..256 bytes once classified>
17
+ risk-ack: none|git:<full repository object id>
18
+ ```
19
+
20
+ Rules:
21
+
22
+ - Missing legacy fields normalize to `unknown`, empty reason, `none` (compat).
23
+ - Duplicate anchored fields are **invalid** (not last-wins).
24
+ - `standard` requires a non-placeholder reason and `risk-ack: none`.
25
+ - `security-class` requires a non-placeholder reason; auto validates `risk-ack`.
26
+ - `unknown` requires `risk-ack: none`.
27
+ - New cards scaffold `risk: unknown` / empty reason / `risk-ack: none`.
28
+
29
+ ### Security acknowledgement (auto only)
30
+
31
+ `risk-ack: git:<full-oid>` is accepted only when:
32
+
33
+ 1. OID shape matches repository object format (`sha1` or `sha256`).
34
+ 2. Commit exists and is an ancestor of current integration `HEAD`.
35
+ 3. `git show <oid>:<project-prefix>DEBT.md` succeeds.
36
+ 4. The blob contains exactly one open line beginning
37
+ `- [ ] DEBT: security-class <card-id> --`.
38
+ 5. `git blame --line-porcelain` at that commit yields `author-mail` **distinct**
39
+ (normalized lowercase, no angle brackets) from `git var GIT_AUTHOR_IDENT`.
40
+ 6. Missing / ambiguous / same identity → fail closed for auto.
41
+
42
+ Residual: Git identity is forgeable by a repository/config owner.
43
+
44
+ ### Semantic override (auto, semantic_gate only)
45
+
46
+ `verdict: override` requires an ancestor DEBT open line:
47
+
48
+ ```text
49
+ - [ ] DEBT: semantic-override <00-idea|01-research|02-scope|03-prd|04-adr|05-contract|C-NNN> -- <reason> -- close before: <condition>
50
+ ```
51
+
52
+ Same author-distinct rule as security-class. Auto never accepts
53
+ `live_verify: override`.
54
+
55
+ ## Committed producer manifests
56
+
57
+ Pass cannot be minted from caller-supplied verdict/argv alone. Subjects reference
58
+ a committed, repo-relative owner:
59
+
60
+ ```text
61
+ schema: flow-attestation-owner/v1
62
+ kind: semantic_gate|live_verify
63
+ subject_id: <closed stage name or C-NNN>
64
+ target_id: none|<lowercase [a-z0-9._-], 1..64 bytes>
65
+ command: repo:<repo-relative executable>
66
+ revision_oracle: none|repo:<repo-relative executable>
67
+ ```
68
+
69
+ - `semantic_gate`: `target_id: none`, `revision_oracle: none`.
70
+ - `live_verify`: non-`none` target and revision oracle.
71
+ - Executables must be tracked regular files at `subject_revision`, inside the
72
+ project, stable object/mode, invoked directly (no shell re-parse).
73
+
74
+ Runner-constructed argv only:
75
+
76
+ ```text
77
+ <command> --subject-id <id> --subject-revision <oid> --subject-fingerprint <fp>
78
+ <revision_oracle> --subject-id <id> --subject-revision <oid> --target-id <target>
79
+ ```
80
+
81
+ Semantic producer stdout (strict):
82
+
83
+ ```text
84
+ schema: flow-semantic-result/v1
85
+ subject_fingerprint: <exact requested fingerprint>
86
+ verdict: pass|fail
87
+ critical_count: <0..999>
88
+ high_count: <0..999>
89
+ evidence_ref: none|repo:<relative-path>
90
+ ```
91
+
92
+ `pass` requires both counts zero. `override` is never producer output.
93
+
94
+ Live revision oracle stdout: exactly one full repository-format OID equal to the
95
+ requested deployed revision.
96
+
97
+ ## Receipt schema (`flow-attestation/v1`)
98
+
99
+ Path layout under main state root:
100
+
101
+ ```text
102
+ <main-state-root>/.flow/attestations/
103
+ semantic_gate/stage-05-contract.receipt
104
+ semantic_gate/card-C-001.receipt
105
+ live_verify/card-C-001.receipt
106
+ live_verify/card-C-001.attempt
107
+ ```
108
+
109
+ Required keys, **canonical order**, single-line `key: value`:
110
+
111
+ ```text
112
+ schema: flow-attestation/v1
113
+ kind: semantic_gate|live_verify
114
+ subject_type: stage|card
115
+ subject_id: <closed stage name or C-NNN>
116
+ subject_fingerprint: git-<sha1|sha256>:<object-id>
117
+ verdict: pass|fail|override
118
+ actor: <sanitized, <=128 bytes>
119
+ engine: <sanitized, <=128 bytes>
120
+ evidence_ref: none|repo:<relative-path>
121
+ timestamp: <UTC YYYY-MM-DDTHH:MM:SSZ>
122
+ override_ref: none|git:<full-object-id>
123
+ owner_ref: repo:<repo-relative owner manifest>
124
+ owner_fingerprint: git-<sha1|sha256>:<object-id>
125
+ ```
126
+
127
+ Kind-specific (also required when present):
128
+
129
+ - stage `semantic_gate`: `subject_revision`
130
+ - card `semantic_gate`: `subject_base`, `subject_revision`, `subject_tree`
131
+ - `live_verify`: `subject_revision`, `command_fingerprint`, `result_code`,
132
+ `result_fingerprint`, `duration_ms`, `target_id`, `revision_oracle_ref`,
133
+ `revision_oracle_fingerprint`
134
+
135
+ `result_code` closed set:
136
+ `exit:<0..255>|timeout|output-cap|signal:<1..64>|spawn-error`.
137
+
138
+ `result_fingerprint` hashes outcome metadata (status, byte counts, argv digest,
139
+ duration bucket) — **never** stdout/stderr bytes.
140
+
141
+ Parser rules:
142
+
143
+ - Reject blank/unknown keys, duplicates, missing required keys, multiline
144
+ values, NUL/control chars, oversized values, path traversal.
145
+ - Never source/eval receipt content.
146
+ - CRLF normalized on read.
147
+ - Invalid CLI/schema input does **not** overwrite an existing receipt.
148
+
149
+ Atomic write: temp in destination dir → `chmod 600` best-effort → rename.
150
+ Latest assessment wins: valid semantic `fail` and terminal live red replace
151
+ older `pass`. Pre-spawn live attempt marker is fail-closed until dead-owner
152
+ recovery or Must-ask `flow attest recover C-NNN --mark-failed`.
153
+
154
+ ### Scalar grammar
155
+
156
+ - `actor` / `engine` / `activated_by`:
157
+ `[A-Za-z0-9][A-Za-z0-9._@/-]{0,127}`
158
+ - `evidence_ref`: `none` or `repo:<normalized relative path>`, ≤256 UTF-8 bytes,
159
+ no `.` / `..` / empty segment / symlink escape
160
+ - `target_id`: `[a-z0-9][a-z0-9._-]{0,63}`
161
+ - Absent optional refs use literal `none`
162
+ - Integers: no signs, spaces, leading plus, or overflow
163
+ - Subject IDs: six stage names
164
+ (`00-idea`…`05-contract`) or normalized `C-NNN`
165
+
166
+ ## Subject projections and fingerprints
167
+
168
+ | Subject | Canonical projection |
169
+ |---|---|
170
+ | Stage semantic | Exact committed Git blob bytes for the stage path |
171
+ | Card semantic | `deps`, `implements`, risk fields, Scope, Allowed files, Verify, Done-evidence + base/head/tree OIDs |
172
+ | Card live | Verify + Done-evidence + owner manifest + target + deployed revision + argv digest |
173
+
174
+ Mutable `status` and `Evidence` are **excluded** from card semantic projection
175
+ so CLI-owned completion updates do not invalidate a still-current review.
176
+
177
+ Cleanliness for mint/consume (auto):
178
+
179
+ - Fail closed on dirty tracked, index, or untracked files **except** skill-owned
180
+ `.flow/` run-state and CLI-owned card `status`/`Evidence` projection fields.
181
+ - Do **not** mutate `.gitignore` to achieve cleanliness.
182
+
183
+ ### Stage fingerprint
184
+
185
+ 1. Validate stage name against closed set.
186
+ 2. Resolve revision to full commit; require clean tracked artifact.
187
+ 3. Blob OID for stage path at that commit; prefix `git-<format>:`.
188
+
189
+ ### Card semantic fingerprint
190
+
191
+ 1. Git repo + explicit base + head.
192
+ 2. Clean worktree including untracked (with `.flow` / status-Evidence exclusions).
193
+ 3. Canonical card-contract projection + base/head/tree OIDs + sorted
194
+ changed-path manifest (`base..head`, excluding card markdown path).
195
+ 4. Hash via `git hash-object --stdin`.
196
+
197
+ Currentness after ancestry-preserving merge: reviewed revision is ancestor of
198
+ integration HEAD; projection still matches; every reviewed changed path
199
+ (except card md) has same object/mode at HEAD. Squash/rebase or code-path edit
200
+ → stale.
201
+
202
+ ### Live fingerprint
203
+
204
+ Deployed revision + Verify/Done-evidence projection + owner/oracle object/mode
205
+ + target + argv digest. Oracle must return exact deployed OID before probe may
206
+ pass.
207
+
208
+ ## Auto-active state
209
+
210
+ ```text
211
+ <main-state-root>/.flow/auto-state
212
+ ```
213
+
214
+ ```text
215
+ schema: flow-auto/v1
216
+ status: active
217
+ activated_at: <UTC RFC3339>
218
+ activated_by: <sanitized <=128>
219
+ integration_branch: <validated branch name>
220
+ risk_fingerprint: git-<sha1|sha256>:<object-id>
221
+ contract_fingerprint: git-<sha1|sha256>:<object-id>
222
+ ```
223
+
224
+ Activation (`flow auto`) requires, atomically after full preflight:
225
+
226
+ - Git repo; main worktree on attached integration branch (linked/detached refuse)
227
+ - Reliable process-group supervisor capability (else refuse live auto)
228
+ - Planning complete + ≥1 card
229
+ - Full risk set valid (no `unknown`, valid security ack)
230
+ - Current accepted Stage 05 `semantic_gate` receipt
231
+
232
+ Card/live receipts are later transition gates, not activation prerequisites.
233
+ `flow auto stop` clears state. Status/resume show `INACTIVE|ACTIVE|STALE|INVALID`.
234
+
235
+ ### Enforcement matrix
236
+
237
+ | Boundary | Auto inactive | Auto active/current | Auto stale/invalid |
238
+ |---|---|---|---|
239
+ | `next` | Warn on stage receipt | Warn only | Warn only |
240
+ | `check` todo | Warn | Require card semantic pass/override | Block |
241
+ | `check` done | Warn | Semantic + live pass | Block |
242
+ | `card done` | Existing + warn | Same hard checks; validate before status mutation | Block |
243
+ | `ready` | Existing + advisory | Done deps need both receipts | No BUILDABLE; non-zero |
244
+ | merged `workspace remove` | Warn | Both receipts | Block |
245
+ | unmerged remove | Existing abandon | Allow without receipts | Allow |
246
+
247
+ No hidden bypass flag. Manual continuation: `flow auto stop`.
248
+
249
+ ## Main state-root resolution
250
+
251
+ Bash must match Python `_db.default_db_path` intent:
252
+
253
+ 1. Explicit `FLOW_PROJECT_ROOT` is project root.
254
+ 2. Resolve Git worktree top + first/main worktree.
255
+ 3. Linked worktree subpath → equivalent main-worktree subpath.
256
+ 4. Submodule / `--separate-git-dir` ambiguity → current root + local receipts
257
+ warning; never place `.flow` inside Git internals.
258
+ 5. Receipts readable without Python.
259
+
260
+ ## CLI surface
261
+
262
+ ```text
263
+ flow attest semantic --stage <stage> --revision <rev> --owner <manifest>
264
+ flow attest semantic --card <id> --base <rev> --revision <rev> --owner <manifest>
265
+ flow attest live-verify <id> --revision <rev> --owner <manifest>
266
+ flow attest status [<stage|card>]
267
+ flow attest recover <C-NNN> --mark-failed
268
+ flow auto
269
+ flow auto stop
270
+ ```
271
+
272
+ Exit codes:
273
+
274
+ - `0` — valid / pass / current accepted
275
+ - `1` — missing / stale / red policy result
276
+ - `2` — invalid usage / schema
277
+ - Timeout / cap / signal → non-zero; never pass
278
+
279
+ ## Process supervisor (attestation only)
280
+
281
+ Argv-safe: fixed cwd = logical checkout root, process group ownership,
282
+ streaming stdout/stderr independent + combined caps, TERM → grace → KILL → wait.
283
+ Capability probe: if reliable process-group supervisor unavailable, live
284
+ verification and auto activation fail closed (never unbounded fallback).
285
+
286
+ Usage/event logs for attestation record only subcommand, subject ID, result
287
+ class, duration bucket — never argv after `--`, raw output, or secrets.
288
+
289
+ ## Locks
290
+
291
+ Order: shared auto-policy mutex → subject locks sorted by `(subject_id, kind)`
292
+ → existing runner/workspace mutation lock.
293
+
294
+ Hard consumers hold locks from validation through irreversible side effects
295
+ (graph/harness/removal).
296
+
297
+ ## Backward compatibility
298
+
299
+ - Manual/teach/work without auto state: warnings only; pre-v0.28 exit codes.
300
+ - Planning `next` never hard-enforced in v0.28.
301
+ - Bash + Git floor; Python/SQLite optional and never required to parse receipts.
302
+ - Harness `risk_lane` remains separate advisory taxonomy (no silent sync).
303
+
304
+ ## Rollback
305
+
306
+ `flow auto stop`, then revert enforcement. Receipt files under `.flow/` are
307
+ run-state; remove for audit loss only — does not corrupt cards/DB.