@hassangameryt/freeflow 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +2 -2
  4. package/.codex-plugin/plugin.json +3 -3
  5. package/.cursor-plugin/plugin.json +1 -1
  6. package/README.md +96 -149
  7. package/capabilities/cognitive-routing/SKILL.md +21 -129
  8. package/capabilities/cognitive-routing/references/coordinator.md +163 -0
  9. package/capabilities/cognitive-routing/references/worker.md +38 -0
  10. package/capabilities/compaction/SKILL.md +3 -3
  11. package/capabilities/compaction/references/summary-format.md +26 -15
  12. package/capabilities/messaging/SKILL.md +49 -0
  13. package/capabilities/task-memory/SKILL.md +87 -0
  14. package/command-surface.json +6 -54
  15. package/gemini-extension.json +1 -1
  16. package/hooks/claude/hooks.json +13 -3
  17. package/hooks/codex/hooks.json +2 -1
  18. package/hooks/shared/runtime-context.mjs +69 -77
  19. package/package.json +25 -8
  20. package/pi-extension/dist/ask-user/ask.js +108 -0
  21. package/pi-extension/dist/ask-user/form.js +250 -0
  22. package/pi-extension/dist/ask-user/questions.js +66 -0
  23. package/pi-extension/dist/ask-user/tool.js +124 -0
  24. package/pi-extension/dist/cognitive-routing/assembler.js +35 -11
  25. package/pi-extension/dist/cognitive-routing/bootstrap.js +90 -0
  26. package/pi-extension/dist/cognitive-routing/config.js +3 -4
  27. package/pi-extension/dist/cognitive-routing/event-store.js +4 -1
  28. package/pi-extension/dist/cognitive-routing/gate.js +20 -5
  29. package/pi-extension/dist/cognitive-routing/handlers.js +15 -13
  30. package/pi-extension/dist/cognitive-routing/model-control.js +17 -8
  31. package/pi-extension/dist/cognitive-routing/projection.js +23 -6
  32. package/pi-extension/dist/cognitive-routing/provenance.js +3 -1
  33. package/pi-extension/dist/cognitive-routing/render.js +15 -15
  34. package/pi-extension/dist/cognitive-routing/runtime.js +4 -2
  35. package/pi-extension/dist/cognitive-routing/schemas.js +4 -4
  36. package/pi-extension/dist/cognitive-routing/session.js +3 -1
  37. package/pi-extension/dist/cognitive-routing/sources.js +29 -4
  38. package/pi-extension/dist/cognitive-routing/state.js +18 -8
  39. package/pi-extension/dist/cognitive-routing/status.js +4 -3
  40. package/pi-extension/dist/cognitive-routing/tools.js +29 -15
  41. package/pi-extension/dist/cognitive-routing/types.js +10 -1
  42. package/pi-extension/dist/compaction/carry.js +36 -22
  43. package/pi-extension/dist/compaction/config.js +4 -2
  44. package/pi-extension/dist/compaction/controller.js +52 -29
  45. package/pi-extension/dist/compaction/harness.js +19 -3
  46. package/pi-extension/dist/compaction/results.js +14 -13
  47. package/pi-extension/dist/compaction/tool.js +6 -6
  48. package/pi-extension/dist/host/catalog.js +20 -35
  49. package/pi-extension/dist/host/config-validation.js +233 -0
  50. package/pi-extension/dist/host/config.js +78 -91
  51. package/pi-extension/dist/host/inbound.js +142 -0
  52. package/pi-extension/dist/host/projection-tags.js +1 -1
  53. package/pi-extension/dist/host/prompts.js +24 -13
  54. package/pi-extension/dist/host/read-only-session.js +6 -1
  55. package/pi-extension/dist/host/request-history.js +7 -3
  56. package/pi-extension/dist/host/rows.js +25 -0
  57. package/pi-extension/dist/host/runtime-state.js +17 -2
  58. package/pi-extension/dist/host/section-keeper.js +85 -0
  59. package/pi-extension/dist/host/settings/freeflow-command.js +846 -93
  60. package/pi-extension/dist/host/settings/settings-view.js +27 -8
  61. package/pi-extension/dist/host/status.js +19 -5
  62. package/pi-extension/dist/index.js +638 -72
  63. package/pi-extension/dist/messaging/config.js +27 -0
  64. package/pi-extension/dist/messaging/messaging.js +398 -0
  65. package/pi-extension/dist/messaging/registry.js +57 -0
  66. package/pi-extension/dist/messaging/render.js +90 -0
  67. package/pi-extension/dist/messaging/tools.js +109 -0
  68. package/pi-extension/dist/messaging/transport.js +101 -0
  69. package/pi-extension/dist/provider-support/cache/keepalive.js +16 -4
  70. package/pi-extension/dist/task-memory/config.js +49 -0
  71. package/pi-extension/dist/task-memory/registry.js +119 -0
  72. package/pi-extension/dist/task-memory/render.js +107 -0
  73. package/pi-extension/dist/task-memory/runtime.js +994 -0
  74. package/pi-extension/dist/task-memory/tool.js +233 -0
  75. package/pi-extension/dist/tool-execution/apply-patch/tool.js +1 -1
  76. package/pi-extension/dist/tool-execution/background.js +220 -28
  77. package/pi-extension/dist/tool-execution/config.js +14 -3
  78. package/pi-extension/dist/tool-execution/file-tracking.js +24 -4
  79. package/pi-extension/dist/tool-execution/guidance-notices.js +124 -0
  80. package/pi-extension/dist/tool-execution/skill-reads.js +143 -0
  81. package/pi-extension/dist/tool-execution/tools.js +2 -2
  82. package/runtime/prompts/cognitive-routing.md +4 -4
  83. package/runtime/prompts/core.md +24 -14
  84. package/runtime/prompts/interaction-contract.md +7 -4
  85. package/runtime/prompts/tool-execution.md +3 -16
  86. package/runtime/prompts/working-method.md +16 -99
  87. package/skills/deliver-work/SKILL.md +76 -0
  88. package/skills/deliver-work/references/branch-closeout.md +134 -0
  89. package/skills/deliver-work/references/commit.md +83 -0
  90. package/skills/deliver-work/references/launch.md +94 -0
  91. package/skills/deliver-work/references/release.md +85 -0
  92. package/skills/deliver-work/scripts/commit-state.mjs +139 -0
  93. package/skills/deliver-work/scripts/delivery-state.mjs +107 -0
  94. package/skills/deliver-work/scripts/lib/git-state.mjs +178 -0
  95. package/skills/deliver-work/scripts/push-route.mjs +122 -0
  96. package/skills/deliver-work/scripts/release-preflight.mjs +177 -0
  97. package/skills/discuss-work/SKILL.md +148 -0
  98. package/skills/{discuss → discuss-work}/references/discussion-continuity.md +10 -27
  99. package/skills/discuss-work/references/learning-action.md +36 -0
  100. package/skills/discuss-work/scripts/choices.mjs +101 -0
  101. package/skills/discuss-work/scripts/lib/choices.mjs +159 -0
  102. package/skills/evaluate-behavior/SKILL.md +107 -0
  103. package/skills/evaluate-behavior/references/authoring.md +381 -0
  104. package/skills/evaluate-behavior/references/coding-tasks.md +145 -0
  105. package/skills/evaluate-behavior/references/conversations-pipelines-judges.md +177 -0
  106. package/skills/evaluate-behavior/references/design-and-measurement.md +273 -0
  107. package/skills/evaluate-behavior/references/running-and-evidence.md +245 -0
  108. package/skills/evaluate-behavior/scripts/claude-guard.mjs +76 -0
  109. package/skills/evaluate-behavior/scripts/guard-rules.mjs +309 -0
  110. package/skills/evaluate-behavior/scripts/lib/agreement.mjs +90 -0
  111. package/skills/evaluate-behavior/scripts/lib/arms.mjs +55 -0
  112. package/skills/evaluate-behavior/scripts/lib/budget.mjs +87 -0
  113. package/skills/evaluate-behavior/scripts/lib/build-source.mjs +287 -0
  114. package/skills/evaluate-behavior/scripts/lib/clear.mjs +74 -0
  115. package/skills/evaluate-behavior/scripts/lib/container.mjs +395 -0
  116. package/skills/evaluate-behavior/scripts/lib/decision.mjs +418 -0
  117. package/skills/evaluate-behavior/scripts/lib/definitions.mjs +1072 -0
  118. package/skills/evaluate-behavior/scripts/lib/freeflow.mjs +103 -0
  119. package/skills/evaluate-behavior/scripts/lib/grade-command.mjs +591 -0
  120. package/skills/evaluate-behavior/scripts/lib/grade-comparison.mjs +90 -0
  121. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-interaction.mjs +19 -18
  122. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-support.mjs +32 -5
  123. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-workspace.mjs +28 -12
  124. package/skills/evaluate-behavior/scripts/lib/grade.mjs +101 -0
  125. package/skills/evaluate-behavior/scripts/lib/hooks.mjs +98 -0
  126. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/confinement.mjs +196 -0
  127. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/constraints.mjs +111 -0
  128. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/index.mjs +48 -0
  129. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/isolation.mjs +74 -0
  130. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/launch.mjs +123 -0
  131. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/model-call.mjs +73 -0
  132. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/recorder.mjs +178 -0
  133. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/session.mjs +494 -0
  134. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/skills.mjs +81 -0
  135. package/skills/evaluate-behavior/scripts/lib/hosts/index.mjs +31 -0
  136. package/skills/evaluate-behavior/scripts/lib/hosts/names.mjs +3 -0
  137. package/skills/evaluate-behavior/scripts/lib/hosts/pi/confinement.mjs +173 -0
  138. package/skills/evaluate-behavior/scripts/lib/hosts/pi/host.mjs +148 -0
  139. package/skills/evaluate-behavior/scripts/lib/hosts/pi/index.mjs +70 -0
  140. package/skills/evaluate-behavior/scripts/lib/hosts/pi/isolation.mjs +81 -0
  141. package/skills/evaluate-behavior/scripts/lib/hosts/pi/model-call.mjs +79 -0
  142. package/skills/evaluate-behavior/scripts/lib/hosts/pi/process.mjs +241 -0
  143. package/skills/{evaluate-skill/scripts/lib → evaluate-behavior/scripts/lib/hosts/pi}/rpc.mjs +144 -26
  144. package/skills/evaluate-behavior/scripts/lib/identity.mjs +82 -0
  145. package/skills/evaluate-behavior/scripts/lib/judge.mjs +688 -0
  146. package/skills/evaluate-behavior/scripts/lib/metrics.mjs +332 -0
  147. package/skills/evaluate-behavior/scripts/lib/model-call.mjs +17 -0
  148. package/skills/evaluate-behavior/scripts/lib/participants.mjs +616 -0
  149. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/process.mjs +22 -0
  150. package/skills/evaluate-behavior/scripts/lib/queue.mjs +54 -0
  151. package/skills/evaluate-behavior/scripts/lib/reference.mjs +343 -0
  152. package/skills/evaluate-behavior/scripts/lib/reuse.mjs +277 -0
  153. package/skills/evaluate-behavior/scripts/lib/review.mjs +933 -0
  154. package/skills/evaluate-behavior/scripts/lib/runner.mjs +732 -0
  155. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/sandbox.mjs +119 -14
  156. package/skills/evaluate-behavior/scripts/lib/scan-shell.mjs +457 -0
  157. package/skills/evaluate-behavior/scripts/lib/scan.mjs +479 -0
  158. package/skills/evaluate-behavior/scripts/lib/seal.mjs +91 -0
  159. package/skills/evaluate-behavior/scripts/lib/shell.mjs +560 -0
  160. package/skills/evaluate-behavior/scripts/lib/source-override.mjs +64 -0
  161. package/skills/evaluate-behavior/scripts/lib/subject-file.mjs +88 -0
  162. package/skills/{evaluate-skill/scripts/lib/pi.mjs → evaluate-behavior/scripts/lib/subject.mjs} +235 -265
  163. package/skills/evaluate-behavior/scripts/lib/task-copy.mjs +124 -0
  164. package/skills/evaluate-behavior/scripts/lib/trials.mjs +524 -0
  165. package/skills/evaluate-behavior/scripts/lib/validity.mjs +68 -0
  166. package/skills/evaluate-behavior/scripts/lib/view-html.mjs +454 -0
  167. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/view.mjs +159 -18
  168. package/skills/{evaluate-skill → evaluate-behavior}/scripts/pi-command-tool.mjs +21 -6
  169. package/skills/evaluate-behavior/scripts/pi-container-route.mjs +23 -0
  170. package/skills/evaluate-behavior/scripts/pi-guard.mjs +77 -0
  171. package/skills/evaluate-behavior/scripts/pi-login-refresh.mjs +31 -0
  172. package/skills/evaluate-behavior/scripts/skill-eval.mjs +586 -0
  173. package/skills/execute-work/SKILL.md +96 -104
  174. package/skills/execute-work/references/code-practices.md +27 -51
  175. package/skills/execute-work/references/design.md +271 -0
  176. package/skills/execute-work/references/diagnose.md +117 -0
  177. package/skills/execute-work/references/migration.md +108 -0
  178. package/skills/execute-work/references/simplify.md +65 -0
  179. package/skills/execute-work/scripts/self-review.mjs +422 -0
  180. package/skills/execute-work/scripts/touch-map.mjs +290 -0
  181. package/skills/review-work/SKILL.md +89 -65
  182. package/skills/review-work/references/adjudication.md +94 -0
  183. package/skills/review-work/references/artifact.md +198 -0
  184. package/skills/review-work/references/evals-and-judges.md +66 -0
  185. package/skills/review-work/references/work.md +177 -0
  186. package/skills/review-work/scripts/check-brief.mjs +128 -0
  187. package/skills/review-work/scripts/review-packet.mjs +233 -0
  188. package/skills/setup-freeflow/SKILL.md +68 -17
  189. package/skills/track-work/SKILL.md +52 -20
  190. package/skills/track-work/references/handoff.md +190 -0
  191. package/skills/track-work/references/projects.md +51 -0
  192. package/skills/track-work/references/working-record-format.md +36 -18
  193. package/skills/track-work/scripts/lib/document.mjs +17 -13
  194. package/skills/track-work/scripts/lib/format.mjs +2 -0
  195. package/skills/track-work/scripts/lib/recover.mjs +254 -0
  196. package/skills/track-work/scripts/lib/registry.mjs +656 -0
  197. package/skills/track-work/scripts/lib/search.mjs +40 -0
  198. package/skills/track-work/scripts/lib/store.mjs +46 -15
  199. package/skills/track-work/scripts/lib/views.mjs +50 -1
  200. package/skills/track-work/scripts/working-record.mjs +232 -13
  201. package/skills/verify-work/SKILL.md +45 -37
  202. package/skills/verify-work/references/feature-map.md +120 -0
  203. package/skills/verify-work/references/runtime-evidence.md +203 -0
  204. package/skills/verify-work/references/test-design.md +25 -6
  205. package/skills/verify-work/scripts/test-changes.mjs +246 -0
  206. package/skills/write-docs/SKILL.md +113 -25
  207. package/skills/write-docs/references/documentation-shapes.md +68 -3
  208. package/skills/write-docs/references/spec-and-plan-shapes.md +308 -0
  209. package/skills/write-docs/scripts/artifact-check.mjs +148 -0
  210. package/skills/write-docs/scripts/docs-check.mjs +96 -6
  211. package/skills/write-docs/scripts/plan-lint.mjs +123 -0
  212. package/skills/write-skill/SKILL.md +92 -52
  213. package/skills/write-skill/references/activation-and-wording.md +143 -0
  214. package/skills/write-skill/references/placement-and-dependencies.md +154 -0
  215. package/skills/write-skill/scripts/lib/compare.mjs +701 -0
  216. package/skills/write-skill/scripts/lib/skill-author.mjs +197 -3
  217. package/skills/write-skill/scripts/skill-author.mjs +51 -8
  218. package/capabilities/cognitive-routing/references/both-mode.md +0 -36
  219. package/capabilities/cognitive-routing/references/executor-mode.md +0 -48
  220. package/capabilities/cognitive-routing/references/helper-mode.md +0 -47
  221. package/plugin.json +0 -33
  222. package/skills/action-selection/SKILL.md +0 -92
  223. package/skills/action-selection/references/trajectory-stalls.md +0 -73
  224. package/skills/bypass/SKILL.md +0 -153
  225. package/skills/commit-work/SKILL.md +0 -93
  226. package/skills/commit-work/references/git-state-edges.md +0 -94
  227. package/skills/commit-work/references/simple-push.md +0 -94
  228. package/skills/commit-work/references/staging-decisions.md +0 -106
  229. package/skills/decision-gate/SKILL.md +0 -87
  230. package/skills/design-for-depth/SKILL.md +0 -108
  231. package/skills/design-for-depth/references/design-pressure-signals.md +0 -84
  232. package/skills/design-for-depth/references/implementation-decisions.md +0 -76
  233. package/skills/design-for-depth/references/interface-design-loop.md +0 -105
  234. package/skills/design-for-depth/references/module-and-dependency-design.md +0 -117
  235. package/skills/design-for-depth/references/state-and-failure-boundaries.md +0 -125
  236. package/skills/diagnose-failure/SKILL.md +0 -140
  237. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +0 -50
  238. package/skills/diagnose-failure/references/flaky-and-performance-diagnosis.md +0 -51
  239. package/skills/discuss/SKILL.md +0 -140
  240. package/skills/evaluate-skill/SKILL.md +0 -188
  241. package/skills/evaluate-skill/references/evaluation-definition-schema.md +0 -415
  242. package/skills/evaluate-skill/references/evaluation-design.md +0 -112
  243. package/skills/evaluate-skill/references/execution-and-evidence.md +0 -111
  244. package/skills/evaluate-skill/references/review-and-revision.md +0 -94
  245. package/skills/evaluate-skill/scripts/lib/definitions.mjs +0 -448
  246. package/skills/evaluate-skill/scripts/lib/grade-comparison.mjs +0 -60
  247. package/skills/evaluate-skill/scripts/lib/grade.mjs +0 -64
  248. package/skills/evaluate-skill/scripts/lib/review.mjs +0 -196
  249. package/skills/evaluate-skill/scripts/lib/runner.mjs +0 -405
  250. package/skills/evaluate-skill/scripts/lib/trials.mjs +0 -103
  251. package/skills/evaluate-skill/scripts/pi-guard.mjs +0 -181
  252. package/skills/evaluate-skill/scripts/skill-eval.mjs +0 -182
  253. package/skills/execute-work/references/execute-work-edges.md +0 -78
  254. package/skills/finish-branch/SKILL.md +0 -117
  255. package/skills/finish-branch/references/integration-options.md +0 -80
  256. package/skills/handoff/SKILL.md +0 -82
  257. package/skills/handoff/references/handoff-templates.md +0 -150
  258. package/skills/launch-work/SKILL.md +0 -116
  259. package/skills/launch-work/references/launch-readiness.md +0 -85
  260. package/skills/migration-work/SKILL.md +0 -115
  261. package/skills/migration-work/references/migration-lifecycle.md +0 -82
  262. package/skills/release-work/SKILL.md +0 -118
  263. package/skills/release-work/references/release-evidence.md +0 -78
  264. package/skills/review-artifact/SKILL.md +0 -143
  265. package/skills/review-artifact/references/adjudicate-artifact-review.md +0 -101
  266. package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +0 -159
  267. package/skills/review-work/references/adjudicate-work-review.md +0 -97
  268. package/skills/review-work/references/independent-work-reviewer-contract.md +0 -139
  269. package/skills/review-work/references/security-risk-lens.md +0 -67
  270. package/skills/setup-freeflow/references/activation-contract.md +0 -103
  271. package/skills/setup-freeflow/references/host-setup.md +0 -67
  272. package/skills/simplify-code/SKILL.md +0 -85
  273. package/skills/simplify-code/references/simplification-patterns.md +0 -70
  274. package/skills/verify-work/references/browser-runtime-evidence.md +0 -51
  275. package/skills/verify-work/references/integration-evidence.md +0 -49
  276. package/skills/verify-work/references/performance-evidence.md +0 -59
  277. package/skills/workflow/SKILL.md +0 -171
  278. package/skills/workflow/references/domain-skill-composition.md +0 -45
  279. package/skills/write-plan/SKILL.md +0 -92
  280. package/skills/write-plan/references/plan-shapes.md +0 -156
  281. package/skills/write-skill/references/activation-boundaries.md +0 -106
  282. package/skills/write-skill/references/agent-first-instructions.md +0 -133
  283. package/skills/write-skill/references/progressive-disclosure.md +0 -129
  284. package/skills/write-skill/references/skill-dependency-graphs.md +0 -192
  285. package/skills/write-spec/SKILL.md +0 -85
  286. package/skills/write-spec/references/artifact-standards.md +0 -86
  287. package/skills/write-spec/references/decision-records.md +0 -80
  288. package/skills/write-spec/references/spec-shapes.md +0 -143
  289. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/evidence.mjs +0 -0
  290. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/pi-observer.mjs +0 -0
@@ -0,0 +1,290 @@
1
+ #!/usr/bin/env node
2
+ // Answers "what does this change touch?" with capped, labelled query results, so the consequences of a change are in
3
+ // front of the agent before its first edit: entry points, readers of the state, writers (where old data comes from),
4
+ // scheduled or concurrent code, the tests that cover it, and the developer docs that cover each touched file. Each
5
+ // block gives its count, the first results, and what it did not search. It is a query, not a verdict: the agent writes
6
+ // a decision next to each result (Execute Work, "Find What The Change Touches").
7
+ // Usage: touch-map.mjs (--symbol <name> | --file <path>)... [--root <repository>] [--cap <n>] [--json]
8
+ // Searches files Git tracks and untracked files it does not ignore. Developer docs come from Write Docs'
9
+ // docs-check.mjs --covering; when no document has a Covers line, a capped search of the docs folder stands in.
10
+ // Exit code 0 when it reports (even nothing), 2 on a usage or Git error.
11
+ import { execFileSync, spawnSync } from "node:child_process";
12
+ import { existsSync, readFileSync } from "node:fs";
13
+ import { basename, dirname, extname, join, relative, resolve } from "node:path";
14
+ import { fileURLToPath } from "node:url";
15
+ import { parseArgs } from "node:util";
16
+
17
+ const USAGE = "Usage: touch-map.mjs (--symbol <name> | --file <path>)... [--root <repository>] [--cap <n>] [--json]";
18
+ const DOCS_CHECK = resolve(dirname(fileURLToPath(import.meta.url)), "../../write-docs/scripts/docs-check.mjs");
19
+
20
+ function fail(message) {
21
+ console.error(message);
22
+ process.exit(2);
23
+ }
24
+
25
+ let values;
26
+ try {
27
+ ({ values } = parseArgs({
28
+ options: {
29
+ symbol: { type: "string", multiple: true, default: [] },
30
+ file: { type: "string", multiple: true, default: [] },
31
+ root: { type: "string" },
32
+ cap: { type: "string", default: "20" },
33
+ json: { type: "boolean", default: false },
34
+ },
35
+ }));
36
+ } catch (error) {
37
+ fail(`${error.message}\n${USAGE}`);
38
+ }
39
+ if (!values.symbol.length && !values.file.length) fail(USAGE);
40
+ const cap = Number(values.cap);
41
+ if (!Number.isInteger(cap) || cap < 1) fail(`--cap must be a positive whole number\n${USAGE}`);
42
+
43
+ const git = (cwd, args) =>
44
+ execFileSync("git", args, { cwd, encoding: "utf8", maxBuffer: 256 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
45
+ let root;
46
+ try {
47
+ root = resolve(git(resolve(values.root ?? "."), ["rev-parse", "--show-toplevel"]).trim());
48
+ } catch {
49
+ fail("not inside a Git repository");
50
+ }
51
+
52
+ // Test files by the common layouts Verify Work's test-changes.mjs lists; enough to tell a test hit from a code hit.
53
+ const TEST_PATH =
54
+ /(^|\/)(tests?|__tests__|spec|e2e|Tests)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py|dart|exs)$|(^|\/)test_[^/]*\.py$|_spec\.rb$|(Test|Tests)\.(java|kt|cs|swift|php)$/;
55
+ const DOC_PATH = /\.(md|mdx|rst|adoc|txt)$/i;
56
+ const isTest = (path) => TEST_PATH.test(path);
57
+ const isDoc = (path) => DOC_PATH.test(path);
58
+
59
+ // Fixed-string git grep over tracked and untracked (not ignored) files; returns [{ path, line, text }]. Callers refine
60
+ // with JavaScript expressions, which behave the same on every platform's Git.
61
+ function grep(text, { word = false, paths = [] } = {}) {
62
+ const args = ["grep", "-n", "-I", "-F", "--no-color", "--untracked", "-e", text];
63
+ if (word) args.splice(1, 0, "-w");
64
+ if (paths.length) args.push("--", ...paths);
65
+ const result = spawnSync("git", args, { cwd: root, encoding: "utf8", maxBuffer: 256 * 1024 * 1024 });
66
+ if (result.status !== 0 && result.status !== 1) fail(`git grep failed: ${result.stderr.trim()}`);
67
+ return (result.stdout ?? "")
68
+ .split("\n")
69
+ .filter(Boolean)
70
+ .map((raw) => {
71
+ const match = /^(.*?):(\d+):(.*)$/.exec(raw);
72
+ return match ? { path: match[1], line: Number(match[2]), text: match[3].trim().slice(0, 200) } : null;
73
+ })
74
+ .filter(Boolean);
75
+ }
76
+
77
+ const block = (label, hits, notSearched) => ({
78
+ label,
79
+ count: hits.length,
80
+ results: hits.slice(0, cap).map((hit) => `${hit.path}:${hit.line}: ${hit.text}`),
81
+ cut: Math.max(0, hits.length - cap),
82
+ notSearched,
83
+ });
84
+ const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
85
+ // Explicit scheduling and concurrency primitives, not every async function, so the block stays readable.
86
+ const SCHEDULED =
87
+ /\b(setTimeout|setInterval|setImmediate|queueMicrotask|requestAnimationFrame|cron|schedule(r|d)?\s*\(|new Worker|worker_threads|Promise\.(all|allSettled|race|any)|go func|goroutine|threading\.|Thread\(|asyncio\.(gather|create_task|wait)|concurrent\.futures|ThreadPool|ExecutorService|tokio::spawn|spawn\(|[Mm]utex|[Ss]emaphore|\.lock\(|withLock|debounce|throttle|retry\(|\.on\(\s*['"`]|addEventListener|setImmediate)/;
88
+
89
+ // Lines in the given files that schedule work or run it concurrently.
90
+ function scheduledIn(files) {
91
+ const hits = [];
92
+ for (const path of files) {
93
+ let text;
94
+ try {
95
+ text = readFileSync(join(root, path), "utf8");
96
+ } catch {
97
+ continue;
98
+ }
99
+ text.split("\n").forEach((line, index) => {
100
+ if (SCHEDULED.test(line)) hits.push({ path, line: index + 1, text: line.trim().slice(0, 200) });
101
+ });
102
+ }
103
+ return hits;
104
+ }
105
+
106
+ function symbolMap(symbol) {
107
+ const pattern = escape(symbol);
108
+ const hits = grep(symbol, { word: true }).filter((hit) => !isDoc(hit.path));
109
+ const definition = new RegExp(
110
+ `\\b(function\\*?|class|def|const|let|var|interface|type|enum|struct|trait|func|fn|module|export\\s+(default\\s+)?)\\s+${pattern}\\b|^\\s*(async\\s+)?${pattern}\\s*\\([^)]*\\)\\s*\\{`,
111
+ );
112
+ const write = new RegExp(
113
+ `(\\b|\\.)${pattern}\\s*(\\+\\+|--|[-+*/|&]?=(?!=))|\\b(set|write|save|store|put|insert|update|upsert|persist|delete|remove|assign)\\w*\\s*\\(\\s*['"\`]?${pattern}\\b|\\b${pattern}\\b\\s*:(?!:)|\\b(INSERT|UPDATE|DELETE)\\b.*\\b${pattern}\\b`,
114
+ "i",
115
+ );
116
+ const call = new RegExp(`\\b${pattern}\\s*\\(|\\bnew\\s+${pattern}\\b|['"\`/]${pattern}['"\`]`);
117
+ const code = hits.filter((hit) => !isTest(hit.path));
118
+ const definitions = code.filter((hit) => definition.test(hit.text));
119
+ const writers = code.filter((hit) => !definition.test(hit.text) && write.test(hit.text));
120
+ const entry = code.filter((hit) => !definition.test(hit.text) && !writers.includes(hit) && call.test(hit.text));
121
+ const readers = code.filter((hit) => !definitions.includes(hit) && !writers.includes(hit) && !entry.includes(hit));
122
+ const files = [...new Set(code.map((hit) => hit.path))];
123
+ const scheduled = scheduledIn(files.filter((path) => !isTest(path)));
124
+ const tests = hits.filter((hit) => isTest(hit.path));
125
+ const defined = [...new Set(definitions.map((hit) => hit.path))];
126
+ return {
127
+ target: symbol,
128
+ kind: "symbol",
129
+ definedIn: definitions.slice(0, cap).map((hit) => `${hit.path}:${hit.line}`),
130
+ blocks: [
131
+ block("entry points (calls, constructions, string references)", entry, [
132
+ "names built at run time, reflection and dynamic dispatch",
133
+ "other repositories, generated or ignored files",
134
+ ]),
135
+ block("readers of the state", readers, ["aliases and destructured or renamed copies", "serialized forms"]),
136
+ block("writers (where old data comes from)", writers, [
137
+ "data already stored by earlier versions: databases, files, caches, user settings",
138
+ "writes through an alias or a generic setter",
139
+ ]),
140
+ block("scheduled or concurrent code in the files that use it", scheduled, [
141
+ "callers in other files that run it concurrently",
142
+ "external schedulers (cron tables, CI, hosts)",
143
+ ]),
144
+ block("covering tests", tests, ["tests that reach it only indirectly", "test files outside the common layouts"]),
145
+ ],
146
+ touchedFiles: defined,
147
+ };
148
+ }
149
+
150
+ function fileMap(input) {
151
+ const path = relative(root, resolve(input)).split("\\").join("/");
152
+ if (path.startsWith("..")) fail(`outside the repository: ${input}`);
153
+ const stem = basename(path, extname(path));
154
+ const name = basename(path);
155
+ // Importers and other references: lines naming the file by its path or its stem in an import-like statement.
156
+ const named = new RegExp(`(^|[^A-Za-z0-9_.-])${escape(stem)}(\\.[A-Za-z0-9]+)?(['"\`)\\s:,;]|$)`);
157
+ const references = grep(stem).filter((hit) => hit.path !== path && !isDoc(hit.path) && named.test(hit.text));
158
+ const imports = references.filter((hit) =>
159
+ /\b(import|require|from|include|source|load|use|mod)\b|\bnode\b|\bpython\b|"(bin|main|exports|scripts)"/.test(
160
+ hit.text,
161
+ ),
162
+ );
163
+ const other = references.filter((hit) => !imports.includes(hit) && !isTest(hit.path));
164
+ const exists = existsSync(join(root, path));
165
+ const scheduled = exists ? scheduledIn([path]) : [];
166
+ const tests = references.filter((hit) => isTest(hit.path));
167
+ return {
168
+ target: path,
169
+ kind: "file",
170
+ exists,
171
+ blocks: [
172
+ block(
173
+ "entry points (importers, commands, manifests)",
174
+ imports.filter((hit) => !isTest(hit.path)),
175
+ ["dynamic imports with built paths", "registration by convention (routes, plugins found by folder)"],
176
+ ),
177
+ block("other references by name", other, [`mentions spelled other than ${name} or ${stem}`]),
178
+ block("scheduled or concurrent code in the file", scheduled, ["callers that run it concurrently"]),
179
+ block("covering tests", tests, ["tests that reach it only through other modules"]),
180
+ ],
181
+ touchedFiles: [path],
182
+ };
183
+ }
184
+
185
+ const maps = [...values.symbol.map(symbolMap), ...values.file.map(fileMap)];
186
+
187
+ // Developer docs covering every touched file, from docs-check --covering; a capped docs search when no doc has Covers.
188
+ const touched = [...new Set(maps.flatMap((map) => map.touchedFiles))];
189
+ let docs = { source: "none", paths: [], notSearched: [] };
190
+ if (touched.length && existsSync(DOCS_CHECK)) {
191
+ const run = spawnSync(
192
+ process.execPath,
193
+ [DOCS_CHECK, ...touched.flatMap((path) => ["--covering", path]), "--root", root, "--json"],
194
+ { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 },
195
+ );
196
+ if (run.status === 0) {
197
+ const found = JSON.parse(run.stdout);
198
+ const withCovers = found.documents - found.withoutCovers.length;
199
+ // Title and one line: the doc's first heading, and the section and line that name the file.
200
+ const describe = (docPath, target) => {
201
+ let text = "";
202
+ try {
203
+ text = readFileSync(join(root, docPath), "utf8");
204
+ } catch {
205
+ return { heading: null, line: null };
206
+ }
207
+ const lines = text.split("\n");
208
+ const title = lines.find((line) => /^#\s/.test(line))?.replace(/^#\s+/, "") ?? null;
209
+ const index = lines.findIndex((line, at) => at > 6 && (line.includes(target) || line.includes(basename(target))));
210
+ let section = title;
211
+ for (let at = index; at >= 0; at -= 1)
212
+ if (/^#{2,4}\s/.test(lines[at])) {
213
+ section = lines[at].replace(/^#+\s+/, "");
214
+ break;
215
+ }
216
+ const first =
217
+ index >= 0
218
+ ? lines[index]
219
+ : (lines.find((line, at) => at > 0 && line.trim() && !/^[#>]/.test(line.trim())) ?? "");
220
+ return { heading: section, line: first.trim().slice(0, 200) };
221
+ };
222
+ if (withCovers > 0)
223
+ docs = {
224
+ source: "docs-check --covering",
225
+ searched: found.searched,
226
+ paths: found.paths.map((entry) => ({
227
+ path: entry.path,
228
+ documents: entry.documents.map((doc) => ({
229
+ path: doc.path,
230
+ ...describe(doc.path, entry.path),
231
+ verifiedAt: doc.verifiedAt,
232
+ state: doc.state,
233
+ changedSince: doc.changed.length,
234
+ })),
235
+ })),
236
+ notSearched: [
237
+ `${found.withoutCovers.length} of ${found.documents} documents have no Covers line, so no lookup finds them`,
238
+ "user docs and READMEs outside the docs index",
239
+ ],
240
+ };
241
+ else {
242
+ const folder = found.searched[0] ?? "";
243
+ docs = {
244
+ source: `capped search of ${folder || "the docs folder"} (no document has a Covers line)`,
245
+ searched: found.searched,
246
+ paths: touched.map((path) => {
247
+ const hits = grep(basename(path), { paths: folder ? [folder] : [] }).filter((hit) => isDoc(hit.path));
248
+ return {
249
+ path,
250
+ documents: hits
251
+ .slice(0, cap)
252
+ .map((hit) => ({ path: hit.path, heading: null, line: `${hit.line}: ${hit.text}` })),
253
+ cut: Math.max(0, hits.length - cap),
254
+ };
255
+ }),
256
+ notSearched: ["docs that describe the code without naming the file", "staleness: no Verified at to compare"],
257
+ };
258
+ }
259
+ } else
260
+ docs = {
261
+ source: "unavailable",
262
+ paths: [],
263
+ notSearched: [`docs-check: ${(run.stderr || run.stdout).trim().split("\n")[0]}`],
264
+ };
265
+ }
266
+
267
+ const report = { command: "touch-map", root, cap, maps, docs };
268
+ if (values.json) console.log(JSON.stringify(report, null, 2));
269
+ else {
270
+ for (const map of maps) {
271
+ console.log(`=== ${map.kind} ${map.target}${map.kind === "file" && !map.exists ? " (does not exist yet)" : ""}`);
272
+ if (map.definedIn) console.log(`defined at: ${map.definedIn.join(", ") || "no definition found"}`);
273
+ for (const each of map.blocks) {
274
+ console.log(`--- ${each.label}: ${each.count}${each.cut ? ` (first ${cap} shown)` : ""}`);
275
+ for (const result of each.results) console.log(` ${result}`);
276
+ console.log(` not searched: ${each.notSearched.join("; ")}`);
277
+ }
278
+ }
279
+ console.log(`--- developer docs (${docs.source})`);
280
+ for (const entry of docs.paths) {
281
+ console.log(` ${entry.path}`);
282
+ if (!entry.documents.length) console.log(" no covering document");
283
+ for (const doc of entry.documents)
284
+ console.log(
285
+ ` ${doc.path}${doc.heading ? ` § ${doc.heading}` : ""}${doc.state ? ` (verified at ${doc.verifiedAt ?? "none"}: ${doc.state}${doc.changedSince ? `, ${doc.changedSince} covered file(s) changed since` : ""})` : ""}${doc.line ? `\n ${doc.line}` : ""}`,
286
+ );
287
+ }
288
+ if (docs.notSearched.length) console.log(` not searched: ${docs.notSearched.join("; ")}`);
289
+ console.log("Write your decision next to each result: it changes too, or its users keep exactly what they get now.");
290
+ }
@@ -1,91 +1,129 @@
1
1
  ---
2
2
  name: review-work
3
- description: "Use when judging implementation or integrated work through self-review or independent review, or when adjudicating a returned independent review report."
3
+ description: "Use whenever finished work or a document is judged fit to use: reviewing code, a diff, a commit or a pull request; checking your own change before reporting it done; reviewing a spec, plan, design, ADR, handoff, skill, final report, status note or Working Record; reviewing changes to authentication, permissions, secrets, untrusted input or other security boundaries; reviewing an eval case, suite, grader or rubric before paying for its runs; preparing, dispatching or skipping an independent review; choosing a model as judge or relying on its verdict; and weighing a review report that came back."
4
4
  ---
5
5
 
6
6
  # Review Work
7
7
 
8
- Judge whether the actual work satisfies the accepted outcome, remains proportionate, and has enough evidence for a named boundary.
8
+ Judge whether the actual work satisfies the accepted outcome, remains proportionate, and has enough evidence for a named boundary; or whether a complete artifact faithfully represents accepted intent and is sufficient for its named use. An artifact's internal consistency is not enough if it consistently describes the wrong outcome or an obsolete baseline.
9
9
 
10
- [Verify Work](../../skills/verify-work/SKILL.md) establishes what observations prove. Review judges their sufficiency and the resulting work; it does not replace verification, choose user-owned behavior, or authorize corrections.
10
+ [Verify Work](../../skills/verify-work/SKILL.md) establishes what observations prove. Review judges their sufficiency and the resulting work or artifact; it does not replace verification, create evidence, choose user-owned behavior, settle owner decisions, or authorize corrections or revisions.
11
+
12
+ Review has three roles:
13
+
14
+ - **Self-review:** the producer or author checks its own supported result or artifact before accepting, reusing, or using it. This is the normal required route.
15
+ - **Independent review:** a separately selected reviewer judges a state it did not produce, from a separate context.
16
+ - **Adjudication:** the receiving agent checks a returned independent report and decides what its findings establish.
11
17
 
12
18
  The **Rules** below are binding; if one cannot be met, stop and say why. Everything else is **judgment**: follow its stated goal, and adapt when a different choice serves that goal better.
13
19
 
20
+ ## Routes
21
+
22
+ Read the reference for what is under review before reviewing it; each names what to establish first, the sources that govern, and the lenses that can change the judgment for that kind.
23
+
24
+ | Situation | Go to |
25
+ | --- | --- |
26
+ | Work: code, a diff, a commit, an implementation, or integrated state | [Work Review](references/work.md) |
27
+ | Work that changes trust boundaries, authentication, authorization, permissions, untrusted input, secrets, sensitive data, security-relevant dependencies or external integrations, code-execution boundaries, or failure behavior with security consequences | Work Review's [Security Risk Lens](references/work.md#security-risk-lens) as well |
28
+ | An artifact that will guide later work: a Spec, Plan, design, decision record, ADR, handoff, or skill | [Artifact Review](references/artifact.md) |
29
+ | An account of work already done: a final report to the user, a status or results note, or a Working Record | [Artifact Review](references/artifact.md), with its [Reports And Records](references/artifact.md#reports-and-records) |
30
+ | An eval case, suite, fixture, grader, or rubric that will be run to measure behavior, before spending on its runs | [Eval Definition Review](references/evals-and-judges.md#eval-definition-review) |
31
+ | A hand-over: dispatching, proposing, or skipping an independent review of the work | The Review Gate, below |
32
+ | Preparing or performing an independent review | Independent Review in [Work Review](references/work.md#independent-review) for work; in [Artifact Review](references/artifact.md#independent-review) for anything else |
33
+ | Writing or dispatching an independent reviewer's brief | Prefill it with [review-packet](scripts/review-packet.mjs) and check it with [check-brief](scripts/check-brief.mjs), as Perform A Selected Independent Review says |
34
+ | A model's verdict on another agent's output will be used as evidence: an independent reviewer, an eval's advisory reviewer, or a grading judge | The [Judge Contract](references/evals-and-judges.md#judge-contract), before selecting the judge or using its verdict |
35
+ | An independent review's report has returned | [Adjudicate A Returned Review](references/adjudication.md), before acting on it |
36
+
14
37
  ## Rules
15
38
 
16
- - Independent review is never automatic after implementation or self-review. Select it through [Workflow](../../skills/workflow/SKILL.md) only when requested, or justified and authorized, to protect a concrete risk, dependency, integration, or delivery boundary. A review budget permits no dispatch by itself, and switching models or loading this skill does not create independence.
17
- - An independent reviewer reports and stops: no edits, no choosing among materially different remedies, no adjudication, no further dispatch, and no continuing until Pass. It runs a missing active check only when review authority covers that exact check; otherwise it reports Needs evidence.
18
- - Findings are evidence, not commands or correction authority. Derive the judgment from your dispositions; never adopt the reviewer's verdict wholesale. Actual correction belongs to [Execute Work](../../skills/execute-work/SKILL.md) under covered authority.
19
- - Never lower acceptance or change tests, Specs, policies, or source truth to obtain Pass, and never review until Pass.
20
- - Never request Review 4. Renaming scope, changing reviewers, or making a local correction does not reset the review budget.
39
+ - Independent review is never automatic after implementation, after self-review, or after writing or revising a Spec or Plan. Select it only when requested, or justified and authorized, to protect a concrete risk, dependency, integration, delivery, or intended-use boundary. At a hand-over, the user's review mode `always`, or `auto` when the Review Gate below fires, authorizes it; under `off`, propose it and wait for a yes. A review budget permits no dispatch by itself, and switching models or compute profiles, or loading this skill, does not create independence: it needs a separately selected reviewer in a separate context. A reviewer from another model family is not required: it changes what gets flagged but has not been shown to find more real defects. Record the reviewer as the Judge Contract says.
40
+ - An independent reviewer reports and stops: no edits, no owner decisions, no choosing among materially different remedies or revisions, no adjudication, no further dispatch, and no continuing until Pass. It runs only what its brief's `May run` line names: by default the project's declared checks (tests, build, typecheck, the feature map's drive steps), in its own copy, with no edits, network calls, or paid runs; another check only when the brief names it with its expected evidence and stop condition. Otherwise it reports Needs evidence.
41
+ - Findings are evidence, not commands or authority to correct or revise. Derive the judgment from your dispositions rather than adopting the reviewer's verdict or conclusion. Actual correction of work belongs to [Execute Work](../../skills/execute-work/SKILL.md) under covered authority; actual revision of an artifact returns to the artifact's owning skill.
42
+ - Never lower acceptance or change tests, Specs, policies, or source truth to obtain Pass. Never settle a user decision or revise upstream intent, accepted content, or owner decisions merely to make an artifact consistent or to obtain Pass. Never repeat a review merely to obtain Pass.
43
+ - Never request Review 4. Renaming scope or intended use, changing reviewers, or making a local correction or revision does not reset the review budget.
44
+ - Never present a review judgment or an artifact's fitness as acceptance, implementation, or execution authority.
21
45
 
22
- ## Choose The Review Role
46
+ ## Before Any Review
23
47
 
24
- Goal: the review done is the one the boundary needs.
48
+ The project's Review Rules (or `REVIEW.md`), read from the base branch, feed the kind's classes and lenses, never a new class.
25
49
 
26
- - **Self-review:** the producer checks its own supported result before accepting or reusing it. This is the normal required route.
27
- - **Independent review:** a separately selected reviewer judges a state it did not produce, from a separate context.
28
- - **Adjudication:** the receiving agent checks a returned independent report and decides what its findings establish.
50
+ Before a model reviews anything, run the deterministic checks that apply and could fail on their own, such as the project's checks, a validator, a docs check, or a definition loader. Give their results to the reviewer as evidence. A model review does not replace a check that can fail mechanically.
29
51
 
30
- ## Establish What The Review Protects
52
+ ## Classify Before Calling Something A Defect
31
53
 
32
- Goal: judge the actual state against its real sources, not the producer's account of it.
54
+ Goal: every reported item is supported and names the right kind of problem.
33
55
 
34
- Identify the exact code, diff, commit, or integrated state; its accepted outcome, non-goals, relevant requirements and amendments; the future action being protected; and the verification evidence and gaps.
56
+ Ask in order:
35
57
 
36
- Inspect the actual state and governing sources, not just the producer's summary or explanation. A detailed execution contract can itself have been mistaken; check the user outcome before judging compliance with the suggested implementation steps.
58
+ 1. Is the relevant behavior or source truth settled (for an artifact, also the content and any owner choice its intended use depends on)? If not, report a **Question** when it affects the boundary or intended use.
59
+ 2. Are reachability, the load-bearing claim, and the material consequence supported by available evidence? If not, report **Needs evidence**, not a hypothetical defect.
60
+ 3. Does this boundary or intended use require correction or revision? If it cannot safely be crossed, report a **Blocking Issue**. If correction or revision is required but safely deferrable, report a **Non-blocking Issue**.
61
+ 4. Is it merely useful beyond this boundary or use? Omit it by default, or identify an **Improvement** when materially relevant or explicitly requested.
37
62
 
38
- Before reviewing changes to trust boundaries, authentication, authorization, permissions, untrusted input, secrets, sensitive data, security-relevant dependencies, code execution, or security-sensitive failure behavior, read [Security Risk Lens](references/security-risk-lens.md).
63
+ A defect the change did not introduce is **Pre-existing**: report it for the user with the evidence that it predates the change, never as Blocking.
39
64
 
40
- Use [Action Selection](../../skills/action-selection/SKILL.md) for uncertain or broad inspection; an obvious diff or source read needs no selection exercise.
65
+ An Issue needs an exact location, path, or dependency; the violated requirement, invariant, source, or artifact responsibility; supporting evidence; and a concrete consequence. Name the defect's class and every other place in the reviewed state where it occurs, not one instance. A Blocking Issue must explain why the protected boundary cannot be crossed or the intended use cannot proceed, and name the correction constraints or the owning activity to re-enter. Recommend a specific correction or revision only when source intent, evidence, and dependency consequences support it rather than merely make it plausible.
41
66
 
42
- ## Apply The Same Technical Kernel
67
+ Needs evidence identifies the load-bearing claim, required observer, existing evidence and its limit, why the gap matters, and the smallest observation that could disagree. First establish that the stronger claim is required; missing proof of an optional guarantee does not justify more work, and an optional stronger claim may be qualified rather than expanding the task. Check whether supplied observations apply to the reviewed candidate and whether material assertion changes preserved the required property. For an artifact, check which source or check state a reported pass examined and whether later changes reduced acceptance or invalidated it; a newer report cannot repair that mismatch. A missing or stale result is not itself a code defect: recover evidence or establish the observer before prescribing a fix. When you can recover it yourself, by running a check you are authorized to run or by reading the code, do so and judge from what you observed: a check the author skipped and you have since run is not Needs evidence.
43
68
 
44
- Goal: use only the lenses that can change the boundary judgment.
69
+ Do not turn preferences, wording or presentation, imagined or exhaustive edge cases, intentional deferrals, or hypothetical completeness into Issues. Finding no material issue is valid.
45
70
 
46
- - **Alignment:** required behavior and accepted amendments are implemented without omission or invented obligations.
47
- - **Correctness and integration:** reachable paths, affected callers, and components work together without regressions.
48
- - **Failure and risk:** material errors, recovery, permissions, data, and compatibility are handled as required.
49
- - **Evidence:** claims are supported at their required observing boundaries, not merely by green summaries.
50
- - **Design and minimality:** complexity and coordination serve requirements or demonstrated needs rather than optional stronger guarantees.
51
- - **Maintainability:** behavior and failure paths remain understandable and changeable.
71
+ ## Self-Review And Re-enter Narrowly
52
72
 
53
- More implementation is not better: check both missing accepted work and unnecessary additions. A prototype result is not production acceptance, and a test protecting a mechanism does not make that mechanism required. If the implementation follows an artifact whose baseline conflicts with a later accepted change, expose that source mismatch rather than choose whichever source makes the work pass.
73
+ Goal: catch real defects in your own result without turning review into an open-ended editing or rewriting loop.
54
74
 
55
- ## Classify Before Calling Something A Defect
75
+ Apply the kind's lenses silently once evidence initially supports the produced result or the artifact's load-bearing facts; do not create formal review items, a numbered review cycle, or an independent-review judgment for self-review. For work, also run Work Review's decision and test-integrity checks.
56
76
 
57
- Goal: every reported item is supported and names the right kind of problem.
77
+ For one clear covered defect (for an artifact, one whose revision basis is settled), return to the producing or authoring activity, correct or revise it, reconcile an artifact's affected dependencies within authority, re-verify the affected boundary or factual claims, and repeat only the affected lenses once (for an artifact, source alignment as well). Do not restart every check or add a reviewer because a local correction occurred. Route anything else as below.
58
78
 
59
- Ask in order:
79
+ Stop self-review when the supported state is accepted, the artifact is fit for its agreed use, or a material issue has a clear next route. Optional polish is not permission to continue editing, and self-review is not a reason to add independent review.
60
80
 
61
- 1. Is the relevant behavior or source truth settled? If not, report a **Question** when it affects the boundary.
62
- 2. Are reachability and material consequence supported? If not, report **Needs evidence**, not a hypothetical defect.
63
- 3. Does this boundary require correction? If it cannot safely be crossed, report a **Blocking Issue**. If correction is required but safely deferrable, report a **Non-blocking Issue**.
64
- 4. Is it merely useful beyond this boundary? Omit it by default, or identify an **Improvement** when materially relevant or explicitly requested.
81
+ ## Route A Problem To Its Owner
65
82
 
66
- An Issue needs an exact location or path, the violated requirement or invariant, supporting evidence, and a concrete consequence; a Blocking Issue must explain why the protected boundary cannot be crossed.
83
+ When a problem is not one clear covered defect, in self-review or adjudication, send it by what changed:
67
84
 
68
- Needs evidence identifies the claim, required observer, existing evidence and its limit, why the gap matters, and the smallest observation that could disagree. First establish that the stronger claim is required; missing proof of an optional guarantee does not justify more work. Check whether supplied observations apply to the reviewed candidate and whether material assertion changes preserved the required property. A missing or stale result is not itself a code defect: recover evidence or establish the observer before prescribing a fix.
85
+ - the outcome remains settled but the implementation approach is invalidated: back to implementation preparation in Execute Work;
86
+ - an unclear, unsupported, or repeated cause: Execute Work's [diagnose](../../skills/execute-work/references/diagnose.md);
87
+ - changed direction or strategy, unsettled behavior or content, materially different remedies or revisions, a user-owned choice, a scope change, or a source conflict: [Discuss Work](../../skills/discuss-work/SKILL.md);
88
+ - missing factual support: the named claim to Verify Work;
89
+ - a correction, revision, or dependency update the current authority does not cover: propose the bounded change once and wait.
69
90
 
70
- Do not turn preferences, imagined edge cases, intentional deferrals, or hypothetical completeness into Issues. Finding no material issue is valid.
91
+ ## The Review Gate
71
92
 
72
- ## Self-Review And Re-enter Narrowly
93
+ Goal: at a hand-over, the work gets the independent review its risk calls for, as the user's review mode says.
94
+
95
+ A **hand-over** is the end of the agreed work, when it goes back to the user to accept: before [Deliver Work](../../skills/deliver-work/SKILL.md) merges or opens a pull request for it, or before the final report when nothing is delivered. Self-review of an intermediate result, such as one Slice or a small local fix, needs no gate.
96
+
97
+ The user sets a review mode, and optionally a reviewer model, as `"review": { "mode": ..., "model": ... }` in `.freeflow/local.json` (personal) or `.freeflow/config.json` (shared). The Runtime State shows a `Review:` line when one is set; with none, the mode is `auto`.
98
+
99
+ - `auto`: the triggers below decide. When one fires, dispatch an independent review; the trigger and the mode are its authorization. When none fires, self-review is enough.
100
+ - `off`: never dispatch on your own. When a trigger would fire, propose an independent review to the user with the trigger and its estimated cost, and run it only after their yes.
101
+ - `always`: dispatch an independent review at every hand-over.
102
+
103
+ A user's explicit request for an independent review authorizes it in any mode.
73
104
 
74
- Goal: catch real defects in your own result without turning review into an open-ended editing loop.
105
+ The gate fires when the change touches:
75
106
 
76
- Apply the kernel silently after evidence initially supports the produced result; do not create formal review items, a numbered review cycle, or an independent-review judgment for self-review.
107
+ - security, authentication, authorization, or secrets;
108
+ - possible data loss, or a migration of stored data;
109
+ - CI or release files;
110
+ - a public interface: anything users or other code depend on, such as CLI flags, config keys, exported APIs, and skill names and descriptions;
111
+ - a path the project's Review Rules mark sensitive;
112
+ - anything the work agreement names for review.
77
113
 
78
- For one clear covered defect, return to the producer, correct it, re-verify the affected boundary, and repeat only the affected lenses once. Do not restart every check or add a reviewer because a local correction occurred.
114
+ Judge from the diff against the base, not from how the task was described. A trigger that fires is enough; a small diff does not cancel it.
79
115
 
80
- When the outcome remains settled but the approach is invalidated, return for implementation preparation. Use [Diagnose Failure](../../skills/diagnose-failure/SKILL.md) for unclear or repeatedly failing causes, [Decision Gate](../../skills/decision-gate/SKILL.md) for unsettled accepted behavior or a user-owned choice, and Workflow for coordination or scope changes.
116
+ Use the user's reviewer model when set. Otherwise use the cheapest model capable of the review: the `standard` tier. When a security, authentication, authorization, or secrets trigger fires, use a stronger model: the `security` tier. The estimated cost names the reviewer model and roughly what one review of a change this size costs on it.
81
117
 
82
- Stop self-review when the supported state is accepted or a material issue has a clear next route. Optional polish is not permission to continue editing.
118
+ When the task has a Working Record, record the gate as one `Review gate` Material update through [Track Work](../../skills/track-work/SKILL.md), in the shape its [format reference](../../skills/track-work/references/working-record-format.md) defines; its tier is `standard`, `security`, or `none` when the result is `skipped`. Without a record, state the same in the hand-over report.
83
119
 
84
120
  ## Perform A Selected Independent Review
85
121
 
86
122
  Goal: a separate context judges the state from the evidence and reports once.
87
123
 
88
- Before preparing or performing it, read [Independent Work Reviewer Contract](references/independent-work-reviewer-contract.md). Use supplied and available evidence; a covered active check uses Verify Work's check-result and claim-result semantics without changing review ownership. Recommend a specific correction only when supported rather than merely plausible.
124
+ The reviewer did not produce the reviewed state. Give it, or point it to, the work product or the complete artifact, source truth, dependencies, and evidence needed to judge it directly, never only the producer's summary, reasoning, claimed result, or change description. Brief a reviewer of work with pointers to where its inputs live, not pasted copies, and run [check-brief](scripts/check-brief.mjs) on the brief before dispatching, as Work Review's Independent Review says; [review-packet](scripts/review-packet.mjs) prefills that brief from the task folder, names the gate triggers the diff shows and the round budget, and runs check-brief; brief a reviewer of anything else with Artifact Review's prompt. When the task has a task directory, save the brief as `scratch/reviews/R<n>-brief.md` there and the returned report as `R<n>-report.md` beside it, where `<n>` is the review number. Delete nothing there without the user's yes.
125
+
126
+ Use supplied and available evidence; a covered active check uses Verify Work's check-result and claim-result semantics without changing review ownership.
89
127
 
90
128
  The independent judgment is:
91
129
 
@@ -94,34 +132,20 @@ The independent judgment is:
94
132
  - **Non-blocking:** only Non-blocking Issues remain.
95
133
  - **Pass:** no Issues or material unresolved items remain.
96
134
 
97
- Improvements do not change the judgment or authorize implementation. Every judgment ends the review.
98
-
99
- ## Adjudicate The Returned Report
100
-
101
- Goal: decide what the report actually establishes before acting on it.
102
-
103
- Read [Adjudicate Work Review](references/adjudicate-work-review.md) before adjudicating. Check each material finding against the actual reviewed state, sources, and evidence:
104
-
105
- - **Accepted:** supported and applicable.
106
- - **Rejected:** unsupported, stale, already resolved, duplicate, preference-only, out of scope, or based on a source misread.
107
- - **Open:** evidence or a decision is missing.
108
-
109
- Pass permits proceeding at the reviewed boundary. Non-blocking permits proceeding with explicit deferrals. Inconclusive requires the missing evidence or decision. Blocking prevents crossing the boundary and returns the smallest supported correction or reconsideration to its owner.
110
-
111
- When correction is ready, state the supported problem, remedy, rationale, verification boundary, authority, and whether independent follow-up is still warranted.
135
+ Improvements and Pre-existing items do not change the judgment or authorize implementation or revision. Every judgment ends the review.
112
136
 
113
137
  ## Bound Independent Review
114
138
 
115
139
  Goal: independent judgment is spent where it changes the outcome.
116
140
 
117
- For the same state and boundary:
141
+ For the same reviewed state and boundary or intended use:
118
142
 
119
143
  - **Review 1:** first selected independent review, broad by default.
120
- - **Review 2:** separately selected focused follow-up when corrections, affected interactions, new evidence, or remaining risk still require independent judgment.
121
- - **Review 3:** exceptional, separately authorized, and final; only after the cause and correction boundary are understood.
144
+ - **Review 2:** separately selected focused follow-up when corrections or revisions, affected interactions or dependencies, new evidence, or remaining risk still require independent judgment.
145
+ - **Review 3:** exceptional, separately authorized, and final; only after the cause, revision basis, and correction or dependency boundary are understood.
122
146
 
123
- A fix does not automatically require another review. If Review 2 remains Blocking, diagnose a repeated, extending, or unclear cause; return an unrelated clear local defect to its owner when diagnosis would add no information, rather than fix and dispatch Review 3 automatically. Workflow may start a new cycle only for a materially new reviewed state and boundary. Self-review does not consume this budget.
147
+ A fix or revision does not automatically require another review. If Review 2 remains Blocking, adjudicate it before acting again; then diagnose a repeated, extending, invalidating, or unclear cause, and return an unrelated clear local defect to its owner when diagnosis would add no information, rather than fix and dispatch Review 3 automatically. If Review 3 remains Blocking, rethink the approach rather than correct it again: route the blocker to diagnose, or to Discuss Work when the approach itself is in question. Start a new cycle only for a materially new reviewed state and boundary or intended use. Self-review does not consume this budget.
124
148
 
125
149
  ## Stop At The Selected Result
126
150
 
127
- Self-review ends with acceptance or a routed issue. Independent review ends with its report. Adjudication ends with dispositions and an explicit next route. Do not turn optional improvement into unfinished work; preserve the agreed user-facing return boundary and any unresolved limits.
151
+ Self-review ends with acceptance, supported fitness, or a routed issue. Independent review ends with its report. Adjudication ends with dispositions and an explicit next route. Do not turn optional improvement into unfinished work; preserve the agreed user-facing return boundary and any unresolved limits.
@@ -0,0 +1,94 @@
1
+ # Adjudicate A Returned Review
2
+
3
+ This reference is judgment; Review Work's Rules still bind. Adjudication belongs to the receiving active agent. It tests the report against the reviewed state or artifact, source truth, dependencies, and evidence. It is not independent review and does not inherit the reviewer's authority or judgment.
4
+
5
+ ## Dispose Each Material Item
6
+
7
+ For every material item, choose one disposition.
8
+
9
+ ### Accepted
10
+
11
+ State:
12
+
13
+ - the supported problem in the work or the artifact;
14
+ - its consequence for the reviewed boundary or the intended use;
15
+ - whether it is Blocking or Non-blocking;
16
+ - for work, whether its cause is supported, unnecessary to select a clear local correction, or uncertain; for an artifact, whether the revision basis is supported or uncertain;
17
+ - for an artifact, which dependencies or contingent material it affects.
18
+
19
+ ### Rejected
20
+
21
+ State the concrete reason: unsupported, stale, resolved, duplicate, preference-only, out of scope or outside the artifact's job, or based on a source or dependency misread.
22
+
23
+ Never close a security finding (one about what [Security Risk Lens](work.md#security-risk-lens) covers) as Rejected on your own: give the user the finding and your reason, and keep it Open until they agree.
24
+
25
+ ### Open
26
+
27
+ State:
28
+
29
+ - the unresolved concern, content, claim, or dependency;
30
+ - its potential consequence for the boundary or the intended use;
31
+ - the missing evidence or owner decision.
32
+
33
+ When factual evidence is missing, hand the item to Verify Work as a Needs evidence item, with the fields Review Work's classification gives one.
34
+
35
+ A suggested correction or revision may help explain a finding, but it does not establish cause, settle source intent, select the remedy or among material alternatives, or authorize implementation or revision.
36
+
37
+ ## Derive The Judgment
38
+
39
+ After disposing the items, derive the adjudicated judgment with Review Work's independent-judgment ladder, counting only Accepted Issues and material Open items. Do not separately accept the reviewer's overall judgment.
40
+
41
+ Pass permits proceeding at the reviewed boundary or with the intended use. Non-blocking permits it with explicit deferrals. Inconclusive requires the missing evidence or decision. Blocking prevents crossing the boundary or the disputed use and returns the smallest supported correction, revision, or reconsideration to its owner (for an artifact, its owning skill).
42
+
43
+ ## Use Verification Results
44
+
45
+ Route a known material evidence gap to [Verify Work](../../../skills/verify-work/SKILL.md). Verification produces factual evidence; it does not revise the reviewer's report or determine the review judgment. By its claim result:
46
+
47
+ - **Supported:** re-adjudicate the evidence gap. Do not infer Pass.
48
+ - **Contradicted:** re-adjudicate against source truth; the result may establish an Issue, invalidate one, or expose a source conflict.
49
+ - **Inconclusive:** keep the item Open. The adjudicated review remains Inconclusive when the gap is material.
50
+ - **Unavailable:** keep the item Open and state why the required boundary cannot currently be observed.
51
+
52
+ Select focused independent follow-up only when the new evidence still requires judgment from a separate context.
53
+
54
+ ## Decide Whether The Correction Or Revision Is Ready
55
+
56
+ It is ready when:
57
+
58
+ - required behavior is settled, or for an artifact, its job and intended use are settled;
59
+ - the problem and its consequence are supported;
60
+ - enough cause, source, or decision basis exists to bound the correction or revision;
61
+ - affected interactions and upstream and downstream dependencies are known sufficiently;
62
+ - for an artifact, the revision will not silently alter accepted content or an owner decision;
63
+ - no material alternative or user-owned choice remains.
64
+
65
+ When it is ready, state:
66
+
67
+ - the proposed correction or revision and its rationale;
68
+ - affected behavior, locations, and dependencies;
69
+ - required ordering, constraints, or reconciliation;
70
+ - regression evidence, acceptance checks, and the verification boundary;
71
+ - whether focused independent follow-up remains justified;
72
+ - the authority state.
73
+
74
+ Use existing correction or revision authority only when it covers that result (for an artifact revision, also its dependency impact). Otherwise propose the change and any warranted follow-up once, then wait. A finding, adjudication, or selected review does not authorize mutation.
75
+
76
+ Actual correction of work returns to [Execute Work](../../../skills/execute-work/SKILL.md). Actual revision of an artifact returns to the artifact's owning skill: [Track Work](../../../skills/track-work/SKILL.md) for a Working Record or a handoff, and [Write Docs](../../../skills/write-docs/SKILL.md) for a Spec, Plan, decision record or documentation.
77
+
78
+ When it is not ready, route it as Review Work's "Route A Problem To Its Owner" says. When findings interact, assumptions or upstream authority are challenged, dependency effects remain uncertain, or user input could change the remedy or revision, report a problem checkpoint and stop before selecting or executing it.
79
+
80
+ ## After An Authorized Correction Or Revision
81
+
82
+ For work, verify the affected boundary and perform ordinary self-review. For an artifact, re-verify affected load-bearing factual claims at their required observing boundaries, then re-check source alignment, intended-use fitness, and every affected dependency before ordinary self-review with the artifact lenses.
83
+
84
+ Whether a follow-up review is warranted, and what to do when Review 2 or 3 remains Blocking, is Review Work's "Bound Independent Review". Do not dispatch follow-up merely because Review 1 found an Issue or because a correction or revision occurred.
85
+
86
+ ## Record The Review
87
+
88
+ Append the dispositions, each with its reason, and the derived judgment to the saved report (`scratch/reviews/R<n>-report.md` when the task has a task directory; otherwise give them in the hand-over report). Keep Rejected items and their reasons, so a rejection can be checked later against what turned out to be true.
89
+
90
+ When the task has a Working Record, then record one `Review` Material update per independent review through [Track Work](../../../skills/track-work/SKILL.md), in the shape its [format reference](../../../skills/track-work/references/working-record-format.md) defines. Its judgment is the adjudicated one, not the reviewer's; its effect is the next route.
91
+
92
+ ## Stop
93
+
94
+ Stop when every material item is Accepted, Rejected, or Open; the adjudicated judgment is supported; for an artifact, affected dependencies and contingent material are explicit; and the next route and authority state are clear.