@bonesofspring/ai-rules 0.2.45 → 0.2.47

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.json +1 -1
  3. package/presets/_shared/ai-local/scripts/manifest.mjs +85 -20
  4. package/presets/_shared/core/agent-team/agent-artifact-contracts.md +8 -2
  5. package/presets/_shared/core/agent-team/task-framing.md +4 -0
  6. package/presets/_shared/core/quality/anti-hallucination-contract.md +2 -0
  7. package/presets/_shared/core/review/code-review-mr.md +2 -0
  8. package/presets/claude/android-kotlin/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  9. package/presets/claude/android-kotlin/rules/tooling-and-review/code-review.md +2 -0
  10. package/presets/claude/android-kotlin/team/README.md +1 -0
  11. package/presets/claude/go/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  12. package/presets/claude/go/rules/tooling-and-review/code-review.md +2 -0
  13. package/presets/claude/go/team/README.md +1 -0
  14. package/presets/claude/ios-swift/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  15. package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +2 -0
  16. package/presets/claude/ios-swift/team/README.md +1 -0
  17. package/presets/claude/java/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  18. package/presets/claude/java/rules/tooling-and-review/code-review.md +2 -0
  19. package/presets/claude/java/team/README.md +1 -0
  20. package/presets/claude/mcp-ts/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  21. package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +2 -0
  22. package/presets/claude/mcp-ts/team/README.md +1 -0
  23. package/presets/claude/next/agents/accessibility-reviewer.md +1 -0
  24. package/presets/claude/next/agents/solution-architect.md +1 -0
  25. package/presets/claude/next/agents/task-analyst.md +1 -0
  26. package/presets/claude/next/agents/tech-writer.md +2 -1
  27. package/presets/claude/next/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  28. package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +2 -0
  29. package/presets/claude/next/rules/ui-and-accessibility/react-a11y-coding.md +1 -0
  30. package/presets/claude/next/team/README.md +1 -0
  31. package/presets/claude/nuxt/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  32. package/presets/claude/nuxt/rules/tooling-and-review/code-review-mr.md +2 -0
  33. package/presets/claude/nuxt/team/README.md +1 -0
  34. package/presets/claude/php-hexagonal/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  35. package/presets/claude/php-hexagonal/rules/tooling-and-review/code-review.md +2 -0
  36. package/presets/claude/php-hexagonal/team/README.md +1 -0
  37. package/presets/claude/php-laravel/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  38. package/presets/claude/php-laravel/rules/tooling-and-review/code-review.md +2 -0
  39. package/presets/claude/php-laravel/team/README.md +1 -0
  40. package/presets/claude/svelte/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
  41. package/presets/claude/svelte/rules/tooling-and-review/code-review-mr.md +2 -0
  42. package/presets/claude/svelte/team/README.md +1 -0
  43. package/presets/cursor/android-kotlin/rules/anti-hallucination-contract.mdc +2 -0
  44. package/presets/cursor/android-kotlin/rules/code-review-mr.mdc +2 -0
  45. package/presets/cursor/android-kotlin/team/README.md +1 -0
  46. package/presets/cursor/go/rules/anti-hallucination-contract.mdc +2 -0
  47. package/presets/cursor/go/rules/code-review-mr.mdc +2 -0
  48. package/presets/cursor/go/team/README.md +1 -0
  49. package/presets/cursor/ios-swift/rules/anti-hallucination-contract.mdc +2 -0
  50. package/presets/cursor/ios-swift/rules/code-review-mr.mdc +2 -0
  51. package/presets/cursor/ios-swift/team/README.md +1 -0
  52. package/presets/cursor/java/rules/anti-hallucination-contract.mdc +2 -0
  53. package/presets/cursor/java/rules/code-review-mr.mdc +2 -0
  54. package/presets/cursor/java/team/README.md +1 -0
  55. package/presets/cursor/mcp-ts/rules/anti-hallucination-contract.mdc +2 -0
  56. package/presets/cursor/mcp-ts/rules/code-review-mr.mdc +2 -0
  57. package/presets/cursor/mcp-ts/team/README.md +1 -0
  58. package/presets/cursor/next/agents/accessibility-reviewer.md +1 -0
  59. package/presets/cursor/next/agents/solution-architect.md +1 -0
  60. package/presets/cursor/next/agents/task-analyst.md +1 -0
  61. package/presets/cursor/next/agents/tech-writer.md +2 -1
  62. package/presets/cursor/next/rules/anti-hallucination-contract.mdc +2 -0
  63. package/presets/cursor/next/rules/code-review-mr.mdc +2 -0
  64. package/presets/cursor/next/rules/react-a11y-coding.mdc +1 -0
  65. package/presets/cursor/next/team/README.md +1 -0
  66. package/presets/cursor/nuxt/rules/anti-hallucination-contract.mdc +2 -0
  67. package/presets/cursor/nuxt/rules/code-review-mr.mdc +2 -0
  68. package/presets/cursor/nuxt/team/README.md +1 -0
  69. package/presets/cursor/php-hexagonal/rules/anti-hallucination-contract.mdc +2 -0
  70. package/presets/cursor/php-hexagonal/rules/code-review-mr.mdc +2 -0
  71. package/presets/cursor/php-hexagonal/team/README.md +1 -0
  72. package/presets/cursor/php-laravel/rules/anti-hallucination-contract.mdc +2 -0
  73. package/presets/cursor/php-laravel/rules/code-review-mr.mdc +2 -0
  74. package/presets/cursor/php-laravel/team/README.md +1 -0
  75. package/presets/cursor/svelte/rules/anti-hallucination-contract.mdc +2 -0
  76. package/presets/cursor/svelte/rules/code-review-mr.mdc +2 -0
  77. package/presets/cursor/svelte/team/README.md +1 -0
  78. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  79. package/presets/mavis/android-kotlin/rules/anti-hallucination-contract.md +2 -0
  80. package/presets/mavis/android-kotlin/rules/code-review-mr.md +2 -0
  81. package/presets/mavis/android-kotlin/team/README.md +1 -0
  82. package/presets/mavis/go/adapter-map.json +1 -1
  83. package/presets/mavis/go/rules/anti-hallucination-contract.md +2 -0
  84. package/presets/mavis/go/rules/code-review-mr.md +2 -0
  85. package/presets/mavis/go/team/README.md +1 -0
  86. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  87. package/presets/mavis/ios-swift/rules/anti-hallucination-contract.md +2 -0
  88. package/presets/mavis/ios-swift/rules/code-review-mr.md +2 -0
  89. package/presets/mavis/ios-swift/team/README.md +1 -0
  90. package/presets/mavis/java/adapter-map.json +1 -1
  91. package/presets/mavis/java/rules/anti-hallucination-contract.md +2 -0
  92. package/presets/mavis/java/rules/code-review-mr.md +2 -0
  93. package/presets/mavis/java/team/README.md +1 -0
  94. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  95. package/presets/mavis/mcp-ts/rules/anti-hallucination-contract.md +2 -0
  96. package/presets/mavis/mcp-ts/rules/code-review-mr.md +2 -0
  97. package/presets/mavis/mcp-ts/team/README.md +1 -0
  98. package/presets/mavis/next/adapter-map.json +1 -1
  99. package/presets/mavis/next/agents/accessibility-reviewer.md +1 -0
  100. package/presets/mavis/next/agents/solution-architect.md +1 -0
  101. package/presets/mavis/next/agents/task-analyst.md +1 -0
  102. package/presets/mavis/next/agents/tech-writer.md +2 -1
  103. package/presets/mavis/next/rules/anti-hallucination-contract.md +2 -0
  104. package/presets/mavis/next/rules/code-review-mr.md +2 -0
  105. package/presets/mavis/next/rules/react-a11y-coding.md +1 -0
  106. package/presets/mavis/next/team/README.md +1 -0
  107. package/presets/mavis/nuxt/adapter-map.json +1 -1
  108. package/presets/mavis/nuxt/rules/anti-hallucination-contract.md +2 -0
  109. package/presets/mavis/nuxt/rules/code-review-mr.md +2 -0
  110. package/presets/mavis/nuxt/team/README.md +1 -0
  111. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  112. package/presets/mavis/php-hexagonal/rules/anti-hallucination-contract.md +2 -0
  113. package/presets/mavis/php-hexagonal/rules/code-review-mr.md +2 -0
  114. package/presets/mavis/php-hexagonal/team/README.md +1 -0
  115. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  116. package/presets/mavis/php-laravel/rules/anti-hallucination-contract.md +2 -0
  117. package/presets/mavis/php-laravel/rules/code-review-mr.md +2 -0
  118. package/presets/mavis/php-laravel/team/README.md +1 -0
  119. package/presets/mavis/svelte/adapter-map.json +1 -1
  120. package/presets/mavis/svelte/rules/anti-hallucination-contract.md +2 -0
  121. package/presets/mavis/svelte/rules/code-review-mr.md +2 -0
  122. package/presets/mavis/svelte/team/README.md +1 -0
  123. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  124. package/presets/opencode/android-kotlin/agents/tech-writer.md +6 -1
  125. package/presets/opencode/android-kotlin/rules/anti-hallucination-contract.md +2 -0
  126. package/presets/opencode/android-kotlin/rules/code-review-mr.md +2 -0
  127. package/presets/opencode/android-kotlin/team/README.md +1 -0
  128. package/presets/opencode/go/adapter-map.json +1 -1
  129. package/presets/opencode/go/agents/tech-writer.md +6 -1
  130. package/presets/opencode/go/rules/anti-hallucination-contract.md +2 -0
  131. package/presets/opencode/go/rules/code-review-mr.md +2 -0
  132. package/presets/opencode/go/team/README.md +1 -0
  133. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  134. package/presets/opencode/ios-swift/agents/tech-writer.md +6 -1
  135. package/presets/opencode/ios-swift/rules/anti-hallucination-contract.md +2 -0
  136. package/presets/opencode/ios-swift/rules/code-review-mr.md +2 -0
  137. package/presets/opencode/ios-swift/team/README.md +1 -0
  138. package/presets/opencode/java/adapter-map.json +1 -1
  139. package/presets/opencode/java/agents/tech-writer.md +6 -1
  140. package/presets/opencode/java/rules/anti-hallucination-contract.md +2 -0
  141. package/presets/opencode/java/rules/code-review-mr.md +2 -0
  142. package/presets/opencode/java/team/README.md +1 -0
  143. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  144. package/presets/opencode/mcp-ts/rules/anti-hallucination-contract.md +2 -0
  145. package/presets/opencode/mcp-ts/rules/code-review-mr.md +2 -0
  146. package/presets/opencode/mcp-ts/team/README.md +1 -0
  147. package/presets/opencode/next/adapter-map.json +1 -1
  148. package/presets/opencode/next/agents/accessibility-reviewer.md +1 -0
  149. package/presets/opencode/next/agents/solution-architect.md +1 -0
  150. package/presets/opencode/next/agents/task-analyst.md +1 -0
  151. package/presets/opencode/next/agents/tech-writer.md +8 -2
  152. package/presets/opencode/next/rules/anti-hallucination-contract.md +2 -0
  153. package/presets/opencode/next/rules/code-review-mr.md +2 -0
  154. package/presets/opencode/next/rules/react-a11y-coding.md +1 -0
  155. package/presets/opencode/next/team/README.md +1 -0
  156. package/presets/opencode/nuxt/adapter-map.json +1 -1
  157. package/presets/opencode/nuxt/agents/tech-writer.md +6 -1
  158. package/presets/opencode/nuxt/rules/anti-hallucination-contract.md +2 -0
  159. package/presets/opencode/nuxt/rules/code-review-mr.md +2 -0
  160. package/presets/opencode/nuxt/team/README.md +1 -0
  161. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  162. package/presets/opencode/php-hexagonal/agents/tech-writer.md +6 -1
  163. package/presets/opencode/php-hexagonal/rules/anti-hallucination-contract.md +2 -0
  164. package/presets/opencode/php-hexagonal/rules/code-review-mr.md +2 -0
  165. package/presets/opencode/php-hexagonal/team/README.md +1 -0
  166. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  167. package/presets/opencode/php-laravel/agents/tech-writer.md +6 -1
  168. package/presets/opencode/php-laravel/rules/anti-hallucination-contract.md +2 -0
  169. package/presets/opencode/php-laravel/rules/code-review-mr.md +2 -0
  170. package/presets/opencode/php-laravel/team/README.md +1 -0
  171. package/presets/opencode/svelte/adapter-map.json +1 -1
  172. package/presets/opencode/svelte/agents/tech-writer.md +6 -1
  173. package/presets/opencode/svelte/rules/anti-hallucination-contract.md +2 -0
  174. package/presets/opencode/svelte/rules/code-review-mr.md +2 -0
  175. package/presets/opencode/svelte/team/README.md +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.47
4
+
5
+ ### Retro guardrails from a cross-layer GitLab feature
6
+
7
+ - **Contract seams get a test.** `task-framing` gains § Contract seams; the `task-analyst` DoR checklist and `code-review-mr` require a named test for every frozen external mapping (sort key ↔ column, command parameter ↔ ingestion, nullable DTO ↔ formatter). A seam that exists only in prose is a review finding.
8
+ - **Async loading must not drop focus.** `react-a11y-coding` and `accessibility-reviewer` state: never `disabled` the control that triggered an in-flight request; keep it focusable, put `aria-busy` on the results region, keep pagination meta stable, and move focus to the heading when the triggering control unmounts.
9
+ - **Multi-phase flags state their scope.** `solution-architect` and `code-review-mr` require a flag honored by only one phase to be documented and tested.
10
+ - **Measured facts are not `[verify]`.** `anti-hallucination-contract` tells every role to reuse a probe already run by the orchestrator or another role; `[verify]` is reserved for unmeasured facts with an owner and effect.
11
+ - **Closeout checks the manifest.** `agent-artifact-contracts` and the installed `team/README.md` require `manifest.mjs check` before the terminal receipt and restoring a root producer body if the hook moved it to `archive/<date>/`.
12
+ - **Tech-writer write scope.** `tech-writer` may write `docs/**`, `README.md` / `**/README.md`, `CHANGELOG.md` / `**/CHANGELOG.md`, and tick `openspec/changes/**/tasks.md`; production code and OpenSpec prose stay out of scope. `AGENT_WRITE_SCOPES` and all four platform agent prompts are aligned.
13
+
14
+ ### Upgrade
15
+
16
+ - Run `npx @bonesofspring/ai-rules update`.
17
+ - The `tech-writer` OpenCode permission map is generated from `AGENT_WRITE_SCOPES`; re-init replaces the installed `.opencode/agents/tech-writer.md`.
18
+
19
+ ## 0.2.46
20
+
21
+ ### The manifest writer validates before it writes
22
+
23
+ - **Why.** A review of the 0.2.45 writer found four gaps: an unconditional `archive/` ban that contradicted the hook compacting a closed entry into `archive/<date>/`, path guards that only matched a leading `../`, `init` writing a skeleton outside `.manifest.lock`, and `--outcome blocked` landing as `status: "completed"`.
24
+ - **Paths.** `upsert` and `check` normalize each `authoritativePaths` entry before judging it, so `reports/../../x.md`, `./archive/x.md`, and `.` hit the same guards as `../x.md` and `archive/x.md`; `reports/../review.md` is stored as `review.md`. `archive/` is accepted only on a `completed` or `superseded` entry — the state the hook leaves after it relocates a closed body — so `check` is green again for an archived task.
25
+ - **Outcome → status.** An outcome now implies the artifact status (`completed` → `completed`; `blocked` / `changes_requested` / `validation_failed` → `blocked`), a contradictory `--status` is rejected with exit 1, and `check` reports a stored `status`/`receipt.outcome` mismatch instead of blessing it. A manifest written before this release may carry such a pair; `check` names the entry and the expected status.
26
+ - **Concurrency.** `init` takes the same `.manifest.lock` as `upsert` and re-checks existence after acquiring it, so entries a concurrent producer already wrote are never replaced by the empty skeleton.
27
+ - **Read safety.** A non-array `artifacts` (or a missing key) is a hard read error (exit 2) that leaves the file untouched: `check` cannot bless a corrupt file and a later `upsert` cannot drop its entries. An empty array belongs only to a new skeleton.
28
+ - **Gate.** `test-manifest-writer.mjs` gains path normalization, archive scope, outcome→status, stored-contradiction, and init/upsert race cases; `check:preset-structure` and `check-rule-eval.mjs` pass.
29
+
30
+ ### Upgrade
31
+
32
+ - Run `npx @bonesofspring/ai-rules update`. Seeding the writer is skip-if-exists, so delete `.ai.local/scripts/manifest.mjs` first to take the hardened copy, then re-run `node .ai.local/scripts/manifest.mjs check --slug <slug>` on completed tasks.
33
+
3
34
  ## 0.2.45
4
35
 
5
36
  ### The manifest is a whole-file merge, not a fragment edit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonesofspring/ai-rules",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
4
4
  "description": "Presets of Cursor, Claude, Mavis, and OpenCode rules/commands for Revy Ross personal use",
5
5
  "license": "MIT",
6
6
  "author": "Revy Ross",
@@ -11,9 +11,10 @@
11
11
  * init --slug <slug> create the skeleton when absent
12
12
  * upsert --slug <slug> --id <id> --producer <agent> … merge one owned entry + receipt
13
13
  * get --slug <slug> --id <id> print one entry
14
- * check --slug <slug> validate; exit 1 on any problem
14
+ * check --slug <slug> validate; exit 1 on schema problems, 2 on an unreadable file
15
15
  *
16
- * Exit codes: 0 ok, 1 usage/validation, 2 manifest parse error (nothing written).
16
+ * Exit codes: 0 ok, 1 usage/validation, 2 unreadable manifest (invalid JSON or a
17
+ * non-array `artifacts`); nothing is written on 2.
17
18
  */
18
19
 
19
20
  import fs from 'node:fs';
@@ -27,10 +28,18 @@ export const DEFAULT_TEAM_ROOT = path.join(process.cwd(), '.ai.local', 'team');
27
28
 
28
29
  const ARTIFACT_STATUSES = ['planned', 'in_progress', 'completed', 'blocked', 'superseded'];
29
30
  const TERMINAL_STATUSES = new Set(['completed', 'blocked', 'superseded']);
31
+ // The hook compacts a closed entry's body into `archive/<date>/` only for `completed`.
32
+ const ARCHIVABLE_STATUSES = new Set(['completed', 'superseded']);
30
33
  const OUTCOMES = ['completed', 'blocked', 'changes_requested', 'validation_failed'];
31
- // `changes_requested` / `validation_failed` block the pipeline but keep their own
32
- // outcome vocabulary, so the artifact status is `blocked` (agent-artifact-contracts).
33
- const BLOCKING_OUTCOMES = new Set(['changes_requested', 'validation_failed']);
34
+ // An outcome implies the artifact status: `blocked` and the two blocking review
35
+ // outcomes are non-advancing, so they land on `blocked` (agent-artifact-contracts).
36
+ // `superseded` stays a lifecycle override on top of any receipt.
37
+ const OUTCOME_STATUS = {
38
+ completed: 'completed',
39
+ blocked: 'blocked',
40
+ changes_requested: 'blocked',
41
+ validation_failed: 'blocked',
42
+ };
34
43
 
35
44
  const USAGE = `usage:
36
45
  manifest.mjs init --slug <slug> [--root <team-dir>]
@@ -49,6 +58,13 @@ const fail = (message, code = 1) => {
49
58
 
50
59
  const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
51
60
 
61
+ const describeShape = (value) => {
62
+ if (value === undefined) return 'no "artifacts" key';
63
+ if (value === null) return 'null';
64
+ if (Array.isArray(value)) return 'an array';
65
+ return `a ${typeof value}`;
66
+ };
67
+
52
68
  const parseArgs = (argv) => {
53
69
  const [command, ...rest] = argv;
54
70
  const flags = {};
@@ -77,14 +93,24 @@ const csv = (value) =>
77
93
  export const manifestPath = (slug, teamRoot = DEFAULT_TEAM_ROOT) =>
78
94
  path.join(teamRoot, 'tasks', slug, MANIFEST_FILE);
79
95
 
80
- /** Task-directory-relative path guard; mirrors the hook's receipt rejection. */
81
- export function assertAuthoritativePath(value, slug) {
96
+ /**
97
+ * Task-directory-relative path guard; mirrors the hook's receipt rejection.
98
+ * `status` scopes the archive ban: the hook relocates a closed entry's body to
99
+ * `archive/<date>/` and rewrites that entry's `authoritativePaths`, so only an
100
+ * open entry is required to cite current files.
101
+ */
102
+ export function assertAuthoritativePath(value, slug, status) {
82
103
  if (typeof value !== 'string' || value.trim() === '') fail('authoritativePaths entries must be non-empty strings');
83
104
  const candidate = value.trim();
84
105
  if (path.isAbsolute(candidate)) {
85
106
  fail(`authoritativePaths must be relative to the task directory, got absolute "${candidate}"`);
86
107
  }
87
- const normalized = candidate.split(path.sep).join('/');
108
+ // Normalize before judging, or `reports/../../x.md` and `./archive/x.md` slip
109
+ // past the guards written for `../x.md` and `archive/x.md`.
110
+ const normalized = path.posix.normalize(candidate.split(path.sep).join('/'));
111
+ if (normalized === '.' || normalized === '') {
112
+ fail(`authoritativePaths must name a file inside the task directory, got "${candidate}"`);
113
+ }
88
114
  if (normalized === '..' || normalized.startsWith('../')) {
89
115
  fail(`authoritativePaths must stay inside the task directory, got "${candidate}"`);
90
116
  }
@@ -93,7 +119,11 @@ export function assertAuthoritativePath(value, slug) {
93
119
  `authoritativePaths are task-relative ("brief.md"), got the repo-root form "${candidate}" — use evidencePaths for anything outside the task directory`,
94
120
  );
95
121
  }
96
- if (normalized.startsWith('archive/')) fail(`authoritativePaths must point at current files, got archived "${candidate}"`);
122
+ if ((normalized === 'archive' || normalized.startsWith('archive/')) && !ARCHIVABLE_STATUSES.has(status)) {
123
+ fail(
124
+ `authoritativePaths must point at current files, got archived "${candidate}" — only a completed or superseded entry may cite archive/`,
125
+ );
126
+ }
97
127
  void slug;
98
128
  return normalized;
99
129
  }
@@ -105,7 +135,12 @@ const skeleton = (slug) => ({
105
135
  artifacts: [],
106
136
  });
107
137
 
108
- /** Read the manifest; `{ manifest, exists }`. Throws exitCode 2 on invalid JSON. */
138
+ /**
139
+ * Read the manifest; `{ manifest, exists }`. Returns the file as parsed, without
140
+ * repairing it. Throws exitCode 2 on invalid JSON or a non-array `artifacts`, so a
141
+ * corrupt file can never be blessed by `check` and then rewritten by `upsert`.
142
+ * An empty `artifacts` array exists only in the skeleton for a new manifest.
143
+ */
109
144
  export function readManifest(slug, teamRoot = DEFAULT_TEAM_ROOT) {
110
145
  const filePath = manifestPath(slug, teamRoot);
111
146
  if (!fs.existsSync(filePath)) return { manifest: skeleton(slug), exists: false, filePath };
@@ -126,7 +161,13 @@ export function readManifest(slug, teamRoot = DEFAULT_TEAM_ROOT) {
126
161
  'Re-run the merge with this writer to drop the stray key.\n',
127
162
  );
128
163
  }
129
- if (!Array.isArray(parsed.artifacts)) parsed.artifacts = [];
164
+ if (!Array.isArray(parsed.artifacts)) {
165
+ fail(
166
+ `${filePath}: "artifacts" must be an array, got ${describeShape(parsed.artifacts)}. ` +
167
+ 'Repair the file by hand (merge the artifact entries into the array) and retry; nothing was written.',
168
+ 2,
169
+ );
170
+ }
130
171
  return { manifest: parsed, exists: true, filePath };
131
172
  }
132
173
 
@@ -180,11 +221,14 @@ const buildEntry = (flags, slug) => {
180
221
  if (!producer) fail('--producer is required');
181
222
  const outcome = flags.outcome;
182
223
  if (outcome && !OUTCOMES.includes(outcome)) fail(`--outcome must be one of ${OUTCOMES.join(' | ')}`);
183
- let status = flags.status || (outcome ? 'completed' : 'in_progress');
184
- if (outcome && BLOCKING_OUTCOMES.has(outcome)) status = 'blocked';
224
+ const impliedStatus = outcome ? OUTCOME_STATUS[outcome] : null;
225
+ const status = flags.status || impliedStatus || 'in_progress';
185
226
  if (!ARTIFACT_STATUSES.includes(status)) fail(`--status must be one of ${ARTIFACT_STATUSES.join(' | ')}`);
227
+ if (impliedStatus && status !== impliedStatus && status !== 'superseded') {
228
+ fail(`--status ${status} contradicts --outcome ${outcome}; use --status ${impliedStatus} (superseded is also allowed)`);
229
+ }
186
230
  if (TERMINAL_STATUSES.has(status) && !outcome) fail(`--outcome is required when --status is ${status}`);
187
- const authoritativePaths = csv(flags.paths).map((value) => assertAuthoritativePath(value, slug));
231
+ const authoritativePaths = csv(flags.paths).map((value) => assertAuthoritativePath(value, slug, status));
188
232
  if (authoritativePaths.length === 0) fail('--paths is required (comma-separated task-relative paths)');
189
233
  const entry = {
190
234
  id,
@@ -216,6 +260,7 @@ export function validateManifest(manifest, slug) {
216
260
  if (typeof manifest.updatedAt !== 'string' || Number.isNaN(Date.parse(manifest.updatedAt))) {
217
261
  problems.push('updatedAt must be an ISO 8601 timestamp');
218
262
  }
263
+ // readManifest already rejects a non-array file; keep the contract check for direct callers.
219
264
  if (!Array.isArray(manifest.artifacts)) return [...problems, 'artifacts must be an array'];
220
265
  if (manifest.entries !== undefined) problems.push('top-level "entries" is not part of the schema; merge into "artifacts"');
221
266
  const seen = new Set();
@@ -235,7 +280,7 @@ export function validateManifest(manifest, slug) {
235
280
  } else {
236
281
  for (const value of entry.authoritativePaths) {
237
282
  try {
238
- assertAuthoritativePath(value, slug);
283
+ assertAuthoritativePath(value, slug, entry.status);
239
284
  } catch (error) {
240
285
  problems.push(`${at}.authoritativePaths: ${error.message}`);
241
286
  }
@@ -252,6 +297,17 @@ export function validateManifest(manifest, slug) {
252
297
  problems.push(`${at}.receipt.outcome is required when status is ${entry.status}`);
253
298
  }
254
299
  }
300
+ if (
301
+ isRecord(entry.receipt) &&
302
+ OUTCOMES.includes(entry.receipt.outcome) &&
303
+ ARTIFACT_STATUSES.includes(entry.status) &&
304
+ entry.status !== OUTCOME_STATUS[entry.receipt.outcome] &&
305
+ entry.status !== 'superseded'
306
+ ) {
307
+ problems.push(
308
+ `${at}.status "${entry.status}" contradicts receipt.outcome "${entry.receipt.outcome}"; expected "${OUTCOME_STATUS[entry.receipt.outcome]}"`,
309
+ );
310
+ }
255
311
  });
256
312
  return problems;
257
313
  }
@@ -269,12 +325,21 @@ export function runCli(argv) {
269
325
 
270
326
  if (command === 'init') {
271
327
  const filePath = manifestPath(slug, teamRoot);
272
- if (fs.existsSync(filePath)) {
273
- process.stdout.write(`${filePath} already exists; left untouched\n`);
274
- return 0;
328
+ fs.mkdirSync(taskDir, { recursive: true });
329
+ // Same lock as `upsert`, plus a re-check under it: a concurrent producer that
330
+ // wrote entries first must not be replaced by the empty skeleton.
331
+ const lockPath = path.join(taskDir, '.manifest.lock');
332
+ const token = acquireLock(lockPath, { timeoutMs: 5000 });
333
+ let created = false;
334
+ try {
335
+ if (!fs.existsSync(filePath)) {
336
+ writeManifestSync(filePath, skeleton(slug));
337
+ created = true;
338
+ }
339
+ } finally {
340
+ releaseLock(lockPath, token);
275
341
  }
276
- writeManifestSync(filePath, skeleton(slug));
277
- process.stdout.write(`${filePath} created\n`);
342
+ process.stdout.write(created ? `${filePath} created\n` : `${filePath} already exists; left untouched\n`);
278
343
  return 0;
279
344
  }
280
345
 
@@ -75,7 +75,7 @@ A producer finishes its step by upserting only its owned artifact entry and term
75
75
  - `evidencePaths`: authoritative files that support the outcome
76
76
  - `authoritativePaths`: paths relative to the task directory (`brief.md`). A repo-root path (`.ai.local/team/tasks/<slug>/brief.md`) resolves outside that directory and the hook rejects the receipt.
77
77
 
78
- `changes_requested` and `validation_failed` use artifact `status: "blocked"` while retaining their distinct receipt outcome. A later successful attempt updates the same owned entry to `completed`; timestamps and evidence must reflect the latest result. Do not infer success from a Markdown filename alone.
78
+ `changes_requested` and `validation_failed` use artifact `status: "blocked"` while retaining their distinct receipt outcome; `outcome: "blocked"` maps to `status: "blocked"` too. A later successful attempt updates the same owned entry to `completed`; timestamps and evidence must reflect the latest result. Do not infer success from a Markdown filename alone.
79
79
 
80
80
  `blocked` is terminal for the producer attempt but non-advancing for the pipeline: the hook persists `status.state` / `phase` as `blocked` and emits no next-agent handoff. A receipt must either carry the active `attemptId` or belong to the step's assigned output entry. Its terminal timestamp must be at or after the active attempt's `startedAt`; otherwise the hook keeps the attempt active in `awaiting_artifact_receipt` and does not advance or retry.
81
81
 
@@ -108,7 +108,7 @@ The manifest is a **whole-file merge target**, never a substring patch. Producer
108
108
  --acs AC-1 --tasks T1 --attempt <attemptId>
109
109
  node .ai.local/scripts/manifest.mjs check --slug <slug>
110
110
  ```
111
- It rejects absolute paths, `..` escapes, and repo-root `authoritativePaths`, and it drops a stray top-level `entries` key.
111
+ It normalizes each path before judging it, so `reports/../../x.md` and `./archive/x.md` hit the same guards as `../x.md` and `archive/x.md`; it rejects absolute paths, `..` escapes, and repo-root `authoritativePaths`, and it drops a stray top-level `entries` key. `archive/` is accepted only on a `completed` or `superseded` entry, because the hook relocates a closed body there and rewrites that entry's paths. An outcome implies the status (`completed` → `completed`; `blocked` / `changes_requested` / `validation_failed` → `blocked`); a contradictory `--status` is rejected and `check` reports a stored mismatch. `init` takes the same `.manifest.lock` and re-checks existence after acquiring it, so it never replaces entries a concurrent `upsert` already wrote. A non-array `artifacts` (or a missing key) is a hard read error (exit 2) that leaves the file untouched: repair the file by hand — an empty array belongs only to a new skeleton.
112
112
  5. Never patch the JSON with a fragment/replace edit (`edit`, `str_replace`, `apply_patch`). A single-byte mismatch aborts the receipt mid-task, leaves the manifest out of sync with the produced artifact, and stalls the step in `awaiting_artifact_receipt`.
113
113
  6. A failed merge or parse is a retry signal, not a guess signal: re-read, merge again, at most twice, then report `blocked` with the parse/merge error. Never leave the file truncated or half-written.
114
114
  7. Parallel wave: the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize. A hand-written merge must take the same lock. Entry `id` uniqueness stays the only shared invariant — the manifest is not a coordination lock.
@@ -293,6 +293,12 @@ Agent-written chronological markdown (`## YYYY-MM-DD` headings). Suggested line
293
293
 
294
294
  Checkpoint/resume semantics (bounded waves, `event:` checkpoints, `authoritativePaths`) live in core **quality/context-and-iteration.md**.
295
295
 
296
+ ## Closeout and archived artifacts
297
+
298
+ Before the terminal receipt, run `node .ai.local/scripts/manifest.mjs check --slug <slug>`. It must exit `0`.
299
+
300
+ The orchestration hook may close a producer artifact by moving its body to `archive/<date>/` and repointing `authoritativePaths`. `check` accepts an archived path only on a completed or superseded entry, but a later write can leave a root-path reference without the root file. Resolve it at closeout: restore the root copy from `archive/<date>/` and point the entry at the root path, or keep the archived path only when the entry is terminal. Never leave a deleted root file plus an untracked archive copy for the human commit.
301
+
296
302
  ## Minimal terminal handoff
297
303
 
298
304
  Report the owned entry ID, outcome, authoritative paths, covered AC/task IDs, and remaining gaps. The hook advances pipeline state from the terminal receipt; the agent receipt is evidence that drives the state transition, not a substitute for writing `status.json`.
@@ -22,6 +22,10 @@ The orchestrator records the frame in `goal.md` before any specialist runs. `pro
22
22
  - Write each criterion so it is **testable and unambiguous** (`Given/When/Then` or a checklist item).
23
23
  - Every requirement maps to at least one AC-ID and every AC-ID maps to at least one requirement. No orphan requirements, no untraceable criteria.
24
24
 
25
+ ## Contract seams
26
+
27
+ When a requirement freezes how an external payload, command parameter, or nullable value maps into the product, name the test that fails without it: sort key ↔ rendered column, command parameter ↔ ingestion call, DTO `null` ↔ UI formatter. A frozen seam without a named test is a review finding, not a documentation gap. Record the seam/test pairs in the brief before decomposition.
28
+
25
29
  ## Success & result-evaluation criteria
26
30
 
27
31
  - **Definition of done** — the conditions under which the task (or a work package) is complete.
@@ -12,6 +12,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
12
12
 
13
13
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
14
14
 
15
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
16
+
15
17
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
16
18
 
17
19
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -18,6 +18,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
18
18
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
19
19
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
20
20
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
21
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
22
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
21
23
 
22
24
  Concrete rule stems — in **Stack notes**.
23
25
 
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32
 
@@ -71,6 +71,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
71
71
  - Merge or parse error → re-read and merge again, at most twice, then report `blocked` with the error. Never leave the file truncated.
72
72
  - Parallel wave → the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize; a hand-written merge must take the same lock.
73
73
  - Plan closure → tick (`- [ ]` → `- [x]`) every `tasks.md` row this receipt closes, in the same turn. An unticked row makes `openspec list` report stale progress and hides the exit criteria from the next agent.
74
+ - **Closeout:** run `manifest.mjs check --slug <slug>` before the terminal receipt. If the hook moved a producer body to `archive/<date>/` and the entry still points at the root, restore the root copy and repoint the entry; do not leave a deleted root file plus an untracked archive copy for the human commit.
74
75
  - Schema and completion conventions: `agent-team/agent-artifact-contracts.md`.
75
76
 
76
77
  ## Commands
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32
 
@@ -71,6 +71,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
71
71
  - Merge or parse error → re-read and merge again, at most twice, then report `blocked` with the error. Never leave the file truncated.
72
72
  - Parallel wave → the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize; a hand-written merge must take the same lock.
73
73
  - Plan closure → tick (`- [ ]` → `- [x]`) every `tasks.md` row this receipt closes, in the same turn. An unticked row makes `openspec list` report stale progress and hides the exit criteria from the next agent.
74
+ - **Closeout:** run `manifest.mjs check --slug <slug>` before the terminal receipt. If the hook moved a producer body to `archive/<date>/` and the entry still points at the root, restore the root copy and repoint the entry; do not leave a deleted root file plus an untracked archive copy for the human commit.
74
75
  - Schema and completion conventions: `agent-team/agent-artifact-contracts.md`.
75
76
 
76
77
  ## Commands
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32
 
@@ -71,6 +71,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
71
71
  - Merge or parse error → re-read and merge again, at most twice, then report `blocked` with the error. Never leave the file truncated.
72
72
  - Parallel wave → the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize; a hand-written merge must take the same lock.
73
73
  - Plan closure → tick (`- [ ]` → `- [x]`) every `tasks.md` row this receipt closes, in the same turn. An unticked row makes `openspec list` report stale progress and hides the exit criteria from the next agent.
74
+ - **Closeout:** run `manifest.mjs check --slug <slug>` before the terminal receipt. If the hook moved a producer body to `archive/<date>/` and the entry still points at the root, restore the root copy and repoint the entry; do not leave a deleted root file plus an untracked archive copy for the human commit.
74
75
  - Schema and completion conventions: `agent-team/agent-artifact-contracts.md`.
75
76
 
76
77
  ## Commands
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32
 
@@ -71,6 +71,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
71
71
  - Merge or parse error → re-read and merge again, at most twice, then report `blocked` with the error. Never leave the file truncated.
72
72
  - Parallel wave → the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize; a hand-written merge must take the same lock.
73
73
  - Plan closure → tick (`- [ ]` → `- [x]`) every `tasks.md` row this receipt closes, in the same turn. An unticked row makes `openspec list` report stale progress and hides the exit criteria from the next agent.
74
+ - **Closeout:** run `manifest.mjs check --slug <slug>` before the terminal receipt. If the hook moved a producer body to `archive/<date>/` and the entry still points at the root, restore the root copy and repoint the entry; do not leave a deleted root file plus an untracked archive copy for the human commit.
74
75
  - Schema and completion conventions: `agent-team/agent-artifact-contracts.md`.
75
76
 
76
77
  ## Commands
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32
 
@@ -71,6 +71,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
71
71
  - Merge or parse error → re-read and merge again, at most twice, then report `blocked` with the error. Never leave the file truncated.
72
72
  - Parallel wave → the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize; a hand-written merge must take the same lock.
73
73
  - Plan closure → tick (`- [ ]` → `- [x]`) every `tasks.md` row this receipt closes, in the same turn. An unticked row makes `openspec list` report stale progress and hides the exit criteria from the next agent.
74
+ - **Closeout:** run `manifest.mjs check --slug <slug>` before the terminal receipt. If the hook moved a producer body to `archive/<date>/` and the entry still points at the root, restore the root copy and repoint the entry; do not leave a deleted root file plus an untracked archive copy for the human commit.
74
75
  - Schema and completion conventions: `agent-team/agent-artifact-contracts.md`.
75
76
 
76
77
  ## Commands
@@ -35,6 +35,7 @@ You are an accessibility reviewer for a Next.js React frontend.
35
35
 
36
36
  - Keyboard navigation and focus order (Tab, Shift+Tab, Escape, Enter).
37
37
  - Focus trap in modals/drawers; focus return on close.
38
+ - Async focus survival: activating filter/sort/search/pagination/retry must not move focus to `<body>`; the triggering control is not `disabled` while its request is in flight; `aria-busy` is on the results region; retry moves focus to the heading.
38
39
  - ARIA roles, labels, `aria-*` attributes, live regions.
39
40
  - Semantic HTML vs div-only interactive elements.
40
41
  - Form labels, error announcements, required field indication.
@@ -67,6 +67,7 @@ Write `.ai.local/team/tasks/<slug>/architecture.md`:
67
67
 
68
68
  - Align with existing layer boundaries — no DTO in UI, no HTTP from components.
69
69
  - Reference concrete paths in the repo (similar features as templates).
70
+ - For a multi-phase CLI or config flow, state which phase each flag reaches and name the test that pins it; a flag honored by only one phase is documented and tested, never left implicit.
70
71
  - Flag when decomposition should change — list suggested updates for analyst/developer.
71
72
  - Do **not** write production code or tests.
72
73
 
@@ -87,6 +87,7 @@ Before writing artifacts, confirm:
87
87
 
88
88
  - [ ] Goal and **out-of-scope** are stated
89
89
  - [ ] **Acceptance criteria** are verifiable (Given/When/Then or checklist)
90
+ - [ ] Every frozen **contract seam** has a named test (sort key ↔ column, command parameter ↔ ingestion, nullable DTO ↔ UI formatter) — see `task-framing` § Contract seams
90
91
  - [ ] **Risks and dependencies** are listed
91
92
  - [ ] **Decomposition** covers all layers touched (types, api, store, ui, tests)
92
93
  - [ ] Each task has layer, dependencies, and "done when"
@@ -58,7 +58,8 @@ Conventional commit / release note snippet.
58
58
  - Write for developers consuming the feature or maintaining the code.
59
59
  - Link to relevant rules, skills, and file paths — not vague references.
60
60
  - Do not duplicate entire decomposition — summarize outcomes and how to use/extend.
61
- - May create or update files under `docs/**` when the task explicitly requests it; otherwise keep primary output in team artifacts.
61
+ - May create or update files under `docs/**`, `README.md` / `**/README.md`, `CHANGELOG.md` / `**/CHANGELOG.md`, and tick task checkboxes in `openspec/changes/**/tasks.md` when the task explicitly requests it; otherwise keep primary output in team artifacts. Do not edit production code or OpenSpec prose.
62
+ - A README edit is documentation, not application code; still cite the feature, env var or command it documents instead of inventing values.
62
63
 
63
64
  ## OpenSpec (`openspec/changes/**`, `openspec/specs/**`)
64
65
 
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32
 
@@ -26,6 +26,7 @@ The reviewer (`accessibility-reviewer`) checks the diff; these rules apply **whi
26
26
  - All interactive elements are **reachable via Tab** and activatable with Enter/Space where expected.
27
27
  - **Modals/drawers** — focus trap, return focus to trigger on close, Esc closes (if UX allows).
28
28
  - Do not remove visible **focus outline** without an accessible custom focus style.
29
+ - **Async loading must not drop focus.** Never pass `disabled` to the control that triggered an in-flight request; keep it focusable and put `aria-busy` on the results region. Keep pagination metadata stable so the pager does not unmount. When the triggering control unmounts (for example a retry button while loading), move focus to the block heading; do not autofocus on initial mount.
29
30
 
30
31
  ## Content
31
32
 
@@ -72,6 +72,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
72
72
  - Merge or parse error → re-read and merge again, at most twice, then report `blocked` with the error. Never leave the file truncated.
73
73
  - Parallel wave → the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize; a hand-written merge must take the same lock.
74
74
  - Plan closure → tick (`- [ ]` → `- [x]`) every `tasks.md` row this receipt closes, in the same turn. An unticked row makes `openspec list` report stale progress and hides the exit criteria from the next agent.
75
+ - **Closeout:** run `manifest.mjs check --slug <slug>` before the terminal receipt. If the hook moved a producer body to `archive/<date>/` and the entry still points at the root, restore the root copy and repoint the entry; do not leave a deleted root file plus an untracked archive copy for the human commit.
75
76
  - Schema and completion conventions: `agent-team/agent-artifact-contracts.md`.
76
77
 
77
78
  ## Commands
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32
 
@@ -71,6 +71,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
71
71
  - Merge or parse error → re-read and merge again, at most twice, then report `blocked` with the error. Never leave the file truncated.
72
72
  - Parallel wave → the writer holds `.manifest.lock` in the task directory, so concurrent producers serialize; a hand-written merge must take the same lock.
73
73
  - Plan closure → tick (`- [ ]` → `- [x]`) every `tasks.md` row this receipt closes, in the same turn. An unticked row makes `openspec list` report stale progress and hides the exit criteria from the next agent.
74
+ - **Closeout:** run `manifest.mjs check --slug <slug>` before the terminal receipt. If the hook moved a producer body to `archive/<date>/` and the entry still points at the root, restore the root copy and repoint the entry; do not leave a deleted root file plus an untracked archive copy for the human commit.
74
75
  - Schema and completion conventions: `agent-team/agent-artifact-contracts.md`.
75
76
 
76
77
  ## Commands
@@ -19,6 +19,8 @@ Do not invent MCP or tool input schemas. Read the installed schema, or mark unce
19
19
 
20
20
  `// VERIFY` is an uncertainty marker. It is not confirmation and it is not a passing check.
21
21
 
22
+ A fact already measured in this run is not uncertain. When the orchestrator or another role probed a live system, reuse the measured value and cite the probe. Reserve `[verify]` for unmeasured facts, with an owner and the effect if the value is wrong; do not downgrade a measurement back to a marker.
23
+
22
24
  For team specs and `brief.md`, the artifact marker is a literal `[NEEDS CLARIFICATION]` line for each unresolved product decision. This contract points at that marker. `// VERIFY` stays a code comment and is not a spec token.
23
25
 
24
26
  Context7 is optional. When it is down or absent, write `// VERIFY` and state the uncertainty. Do not block the pipeline and do not invent the signature.
@@ -25,6 +25,8 @@ On-demand rule for review flows. **Procedure and output format:** skill `code-re
25
25
  - Design smells **in MR diff scope** — load `design-guidance`; do not expand the full Fowler catalog outside the diff
26
26
  - Pattern name (GoF) — only if the repository already uses that shape or the match is minimal
27
27
  - Principles (KISS / DRY+Ro3 / YAGNI / SOLID / CUPID) — via always-on `code-quality-and-refactoring`, do not duplicate the essay in review
28
+ - **Contract seams** — every frozen external mapping has a named test: sort key ↔ rendered column, command parameter ↔ ingestion call, nullable DTO ↔ UI formatter. A seam that exists only in prose is a finding.
29
+ - **Multi-phase flags** — a CLI or config flag honored by only one phase of a two-phase flow states its scope in the design and has a test; an undocumented partial scope is a finding.
28
30
 
29
31
  Concrete rule stems — in **Stack notes**.
30
32