qfai 2.1.2 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +46 -6
  2. package/assets/defaults/agent-routing/qfai-implement.yml +9 -0
  3. package/assets/defaults/agent-routing/qfai-triage.yml +9 -0
  4. package/assets/defaults/workflows/answer-in-session.yml +8 -0
  5. package/assets/defaults/workflows/bump-dependency.yml +4 -1
  6. package/assets/defaults/workflows/decide-design.yml +5 -1
  7. package/assets/defaults/workflows/quarantine-flaky.yml +3 -0
  8. package/assets/defaults/workflows/rename-concept.yml +30 -0
  9. package/assets/defaults/workflows/repair-consistency.yml +1 -0
  10. package/assets/defaults/workflows/resolve-conflicts.yml +14 -0
  11. package/assets/defaults/workflows/retire-feature.yml +26 -0
  12. package/assets/defaults/workflows/run-operation.yml +11 -0
  13. package/assets/defaults/workflows/run-release.yml +12 -0
  14. package/assets/defaults/workflows/write-procedure.yml +18 -0
  15. package/assets/graph/codegraph-native.mjs +174 -0
  16. package/assets/graph/graphify-native.py +72 -0
  17. package/assets/init/.claude/settings.json +11 -29
  18. package/assets/init/.codex/hooks.json +9 -21
  19. package/assets/init/.qfai/assistant/agent/backend-engineer.md +1 -1
  20. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +1 -1
  21. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +5 -0
  22. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +8 -3
  23. package/assets/init/.qfai/assistant/rule/constitution.md +36 -18
  24. package/assets/init/.qfai/assistant/rule/drift-protocol.md +80 -1
  25. package/assets/init/.qfai/assistant/rule/references/codex-delegation.md +27 -0
  26. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +1 -1
  27. package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +21 -9
  28. package/assets/init/.qfai/assistant/rule/review-convergence.md +34 -15
  29. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +12 -2
  30. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +14 -7
  31. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +2 -1
  32. package/assets/init/.qfai/assistant/rule/workflow.md +2 -1
  33. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +11 -2
  34. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +32 -10
  35. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +17 -0
  36. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/trend_scan_playbook.md +3 -1
  37. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/01_Context.md +4 -1
  38. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/04_Sources.md +5 -1
  39. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +4 -1
  40. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +30 -20
  41. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +4 -3
  42. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +8 -2
  43. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +9 -2
  44. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +10 -0
  45. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +35 -0
  46. package/assets/init/.qfai/assistant/skill/qfai-implement/references/test-runner-recipes.md +445 -0
  47. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +3 -3
  48. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +10 -9
  49. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +33 -2
  50. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +77 -2
  51. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +12 -3
  52. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +3 -1
  53. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +31 -5
  54. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +48 -46
  55. package/assets/init/.qfai/assistant/skill/qfai-run/references/codex-cloud-install.md +80 -0
  56. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +202 -126
  57. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +38 -15
  58. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +48 -22
  59. package/assets/init/.qfai/assistant/skill/qfai-run/references/reached-step-observations.md +134 -0
  60. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +7 -4
  61. package/assets/init/.qfai/assistant/skill/qfai-run/scripts/codex-cloud-install.mjs +117 -0
  62. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +2 -1
  63. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -1
  64. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +20 -7
  65. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +2 -2
  66. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +2 -2
  67. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +5 -1
  68. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +2 -2
  69. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +111 -7
  70. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +1 -1
  71. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +58 -8
  72. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +1 -1
  73. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions/page-NNNN.md +6 -0
  74. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +18 -0
  75. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/open-questions.md +13 -0
  76. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +10 -7
  77. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +22 -16
  78. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +1 -1
  79. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +33 -16
  80. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +37 -8
  81. package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +25 -4
  82. package/assets/init/.qfai/assistant/step/common-policy-check/STEP.md +1 -0
  83. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +68 -15
  84. package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +25 -10
  85. package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +17 -1
  86. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +23 -3
  87. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +9 -1
  88. package/assets/init/.qfai/assistant/step/implement-acceptance/STEP.md +3 -0
  89. package/assets/init/.qfai/assistant/step/implement-credentials/STEP.md +4 -0
  90. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +33 -3
  91. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +12 -3
  92. package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +98 -0
  93. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +21 -4
  94. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +25 -5
  95. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +3 -3
  96. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +26 -0
  97. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +28 -5
  98. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +33 -2
  99. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +20 -5
  100. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +70 -6
  101. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +39 -6
  102. package/assets/init/.qfai/assistant/step/prototyping-handoff/STEP.md +12 -3
  103. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +56 -6
  104. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +13 -0
  105. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +8 -0
  106. package/assets/init/.qfai/assistant/step/sdd-cycle/STEP.md +9 -4
  107. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +22 -1
  108. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +52 -14
  109. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +2 -2
  110. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +7 -2
  111. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +6 -0
  112. package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +123 -0
  113. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +35 -10
  114. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +8 -1
  115. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +40 -0
  116. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +77 -7
  117. package/assets/init/root/.agents/rules/api-budget.md +8 -3
  118. package/assets/init/root/.agents/rules/document-schema.md +17 -0
  119. package/assets/init/root/.agents/rules/documentation-clarity.md +1 -1
  120. package/assets/init/root/.agents/rules/graph-exploration.md +164 -0
  121. package/assets/init/root/.agents/rules/grilling.md +100 -43
  122. package/assets/init/root/.agents/rules/reminders.json +20 -32
  123. package/assets/init/root/.agents/rules/session-feedback.md +6 -11
  124. package/assets/init/root/.agents/rules/untrusted-content.md +2 -2
  125. package/assets/init/root/.agents/rules/user-questions.md +24 -14
  126. package/assets/init/root/.gitattributes +2 -0
  127. package/assets/init/root/.github/workflows/qfai-docs.yml +2 -2
  128. package/assets/init/root/.github/workflows/qfai-tests.yml +88 -35
  129. package/assets/init/root/.github/workflows/qfai-validate.yml +2 -2
  130. package/assets/init/root/AGENTS.md +1 -0
  131. package/assets/mdschema/manifest.yml +3 -0
  132. package/assets/mdschema/story/03_contract/tech.mdschema.yml +1 -1
  133. package/assets/mdschema/story/decisions/page-NNNN.mdschema.yml +32 -0
  134. package/assets/mdschema/story/decisions.mdschema.yml +12 -0
  135. package/assets/schemas/workflow/extraction.schema.json +98 -2
  136. package/assets/schemas/workflow/plan.schema.json +34 -1
  137. package/assets/scripts/check-mdschema.mjs +497 -39
  138. package/dist/cli/index.cjs +7667 -3515
  139. package/dist/cli/index.cjs.map +1 -1
  140. package/dist/cli/index.mjs +8872 -4702
  141. package/dist/cli/index.mjs.map +1 -1
  142. package/dist/graph/cli.cjs +1568 -0
  143. package/dist/graph/cli.cjs.map +1 -0
  144. package/dist/graph/cli.d.cts +9 -0
  145. package/dist/graph/cli.d.ts +9 -0
  146. package/dist/graph/cli.mjs +1541 -0
  147. package/dist/graph/cli.mjs.map +1 -0
  148. package/dist/graph/hook.cjs +817 -0
  149. package/dist/graph/hook.cjs.map +1 -0
  150. package/dist/graph/hook.d.cts +9 -0
  151. package/dist/graph/hook.d.ts +9 -0
  152. package/dist/graph/hook.mjs +792 -0
  153. package/dist/graph/hook.mjs.map +1 -0
  154. package/dist/index.cjs +6436 -3012
  155. package/dist/index.cjs.map +1 -1
  156. package/dist/index.d.cts +185 -1
  157. package/dist/index.d.ts +185 -1
  158. package/dist/index.mjs +6620 -3197
  159. package/dist/index.mjs.map +1 -1
  160. package/dist/process-C21nTvkT.d.cts +12 -0
  161. package/dist/process-C21nTvkT.d.ts +12 -0
  162. package/package.json +1 -1
@@ -30,7 +30,7 @@
30
30
  "command": "node",
31
31
  "args": [
32
32
  "-e",
33
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}const p=i.prompt;if(!(typeof p==='string'&&/^[ \\t]*(<(task-notification|wake)[\\s>]|\\[SYSTEM NOTIFICATION)/m.test(p))){let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}",
33
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}const p=i.prompt;if(!(typeof p==='string'&&/^[ \\t]*(<(task-notification|wake|ci-monitor-event)[\\s>]|\\[SYSTEM NOTIFICATION)/m.test(p))){let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}}catch{}",
34
34
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
35
35
  "structured-question"
36
36
  ]
@@ -46,7 +46,7 @@
46
46
  "command": "node",
47
47
  "args": [
48
48
  "-e",
49
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}const p=i.prompt;if(!(typeof p==='string'&&/^[ \\t]*(<(task-notification|wake)[\\s>]|\\[SYSTEM NOTIFICATION)/m.test(p))){let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}",
49
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}const p=i.prompt;if(!(typeof p==='string'&&/^[ \\t]*(<(task-notification|wake|ci-monitor-event)[\\s>]|\\[SYSTEM NOTIFICATION)/m.test(p))){let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}",
50
50
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
51
51
  "free-text-entry"
52
52
  ]
@@ -80,7 +80,7 @@
80
80
  "command": "node",
81
81
  "args": [
82
82
  "-e",
83
- "try{const m=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(m!==undefined)console.log(JSON.stringify(m))}catch{}",
83
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}catch{}",
84
84
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
85
85
  "documentation-clarity-before-post"
86
86
  ]
@@ -96,7 +96,7 @@
96
96
  "command": "node",
97
97
  "args": [
98
98
  "-e",
99
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}catch{}",
99
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}catch{}",
100
100
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
101
101
  "grilling-design-artifact"
102
102
  ]
@@ -112,7 +112,7 @@
112
112
  "command": "node",
113
113
  "args": [
114
114
  "-e",
115
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}catch{}",
115
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}catch{}",
116
116
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
117
117
  "grilling-delegation"
118
118
  ]
@@ -128,7 +128,7 @@
128
128
  "command": "node",
129
129
  "args": [
130
130
  "-e",
131
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}catch{}",
131
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}catch{}",
132
132
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
133
133
  "grilling-plan"
134
134
  ]
@@ -136,7 +136,7 @@
136
136
  ]
137
137
  },
138
138
  {
139
- "matcher": "Bash",
139
+ "matcher": "Bash|PowerShell",
140
140
  "hooks": [
141
141
  {
142
142
  "type": "command",
@@ -144,7 +144,7 @@
144
144
  "command": "node",
145
145
  "args": [
146
146
  "-e",
147
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}const c=i.tool_input&&i.tool_input.command;if(typeof c==='string'&&/(^|[^\\w.-])gh([^\\w.-]|$)|api\\.github\\.com/.test(c)){let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}",
147
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}const c=i.tool_input&&i.tool_input.command;if(typeof c==='string'&&/(^|[^\\w.-])(gh|curl|wget|iwr|irm|invoke-webrequest|invoke-restmethod)(\\.exe)?([^\\w.-]|$)|api\\.github\\.com/i.test(c)){let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}}catch{}",
148
148
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
149
149
  "api-budget"
150
150
  ]
@@ -163,7 +163,7 @@
163
163
  "command": "node",
164
164
  "args": [
165
165
  "-e",
166
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{}let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}catch{}",
166
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{}let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}catch{}",
167
167
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
168
168
  "documentation-clarity-after-write"
169
169
  ]
@@ -175,7 +175,7 @@
175
175
  "command": "node",
176
176
  "args": [
177
177
  "-e",
178
- "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{}let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}catch{}",
178
+ "try{const f=require('fs');let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{}let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}catch{}",
179
179
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
180
180
  "documentation-clarity-after-edit"
181
181
  ]
@@ -191,31 +191,13 @@
191
191
  "command": "node",
192
192
  "args": [
193
193
  "-e",
194
- "try{const f=require('fs'),p=require('path'),R=p.dirname(p.dirname(p.dirname(process.argv[1])));let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{}const u=i.tool_input&&i.tool_input.file_path;let src=true;if(typeof u==='string'&&(x=>{const s=x.split(p.sep),b=s.pop();return p.isAbsolute(x)||s[0]==='..'||s.some(y=>['tmp','test','tests','__tests__','node_modules','.qfai','.agents'].includes(y))||b[0]==='.'||/\\.(test|spec)\\./.test(b)||['.md','.mdx','.markdown','.txt','.rst','.yml','.yaml','.json','.jsonc','.json5','.toml','.ini','.csv','.tsv','.lock','.svg','.png','.jpg','.jpeg','.gif'].includes(p.extname(b).toLowerCase())})(p.relative(R,p.resolve(R,u))))src=false;if(src){let n=1;if(typeof i.session_id==='string'){try{const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}",
194
+ "try{const f=require('fs'),p=require('path'),R=p.dirname(p.dirname(p.dirname(process.argv[1])));let i={};try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{}const u=i.tool_input&&i.tool_input.file_path;let src=true;if(typeof u==='string'&&(x=>{const s=x.split(p.sep),b=s.pop();return p.isAbsolute(x)||s[0]==='..'||s.some(y=>['tmp','test','tests','__tests__','node_modules','.qfai','.agents'].includes(y))||b[0]==='.'||/\\.(test|spec)\\./.test(b)||['.md','.mdx','.markdown','.txt','.rst','.yml','.yaml','.json','.jsonc','.json5','.toml','.ini','.csv','.tsv','.lock','.svg','.png','.jpg','.jpeg','.gif'].includes(p.extname(b).toLowerCase())})(p.relative(R,p.resolve(R,u))))src=false;if(src){let n=1;if(typeof i.session_id==='string'){const t=require('path').join(require('os').tmpdir(),['qfai-reminder',i.session_id,i.agent_id||'main',process.argv[2]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(e!==undefined){if(n===1)console.log(JSON.stringify(e))}}}catch{}",
195
195
  "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
196
196
  "minimal-implementation"
197
197
  ]
198
198
  }
199
199
  ]
200
200
  }
201
- ],
202
- "Stop": [
203
- {
204
- "matcher": "*",
205
- "hooks": [
206
- {
207
- "type": "command",
208
- "statusMessage": "QFAI session feedback reminder",
209
- "command": "node",
210
- "args": [
211
- "-e",
212
- "try{const f=require('fs');let i;try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{process.exit(0)}const l=typeof i.last_assistant_message==='string'?i.last_assistant_message.trim():'';if(i.stop_hook_active===true||(l.length>0&&('?'+String.fromCharCode(65311)).includes(l.slice(-1))))process.exit(0);const m=JSON.parse(f.readFileSync(process.argv[1],'utf8'))[process.argv[2]];if(m!==undefined)console.log(JSON.stringify(m))}catch{}",
213
- "${CLAUDE_PROJECT_DIR}/.agents/rules/reminders.json",
214
- "session-feedback"
215
- ]
216
- }
217
- ]
218
- }
219
201
  ]
220
202
  }
221
203
  }
@@ -6,7 +6,7 @@
6
6
  {
7
7
  "type": "command",
8
8
  "statusMessage": "QFAI structured-question reminder",
9
- "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}\" structured-question",
9
+ "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}catch{}\" structured-question",
10
10
  "timeout": 10
11
11
  }
12
12
  ]
@@ -16,7 +16,7 @@
16
16
  {
17
17
  "type": "command",
18
18
  "statusMessage": "QFAI free-text entry reminder",
19
- "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}\" free-text-entry",
19
+ "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}\" free-text-entry",
20
20
  "timeout": 10
21
21
  }
22
22
  ]
@@ -39,7 +39,7 @@
39
39
  {
40
40
  "type": "command",
41
41
  "statusMessage": "QFAI documentation-clarity reminder",
42
- "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){const m=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];m===undefined||console.log(JSON.stringify(m))}}catch{}\" documentation-clarity-before-post",
42
+ "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}catch{}\" documentation-clarity-before-post",
43
43
  "timeout": 10
44
44
  }
45
45
  ]
@@ -50,7 +50,7 @@
50
50
  {
51
51
  "type": "command",
52
52
  "statusMessage": "QFAI grilling reminder: design artifact",
53
- "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}\" grilling-design-artifact",
53
+ "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}catch{}\" grilling-design-artifact",
54
54
  "timeout": 10
55
55
  }
56
56
  ]
@@ -61,7 +61,7 @@
61
61
  {
62
62
  "type": "command",
63
63
  "statusMessage": "QFAI grilling reminder: delegation",
64
- "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}catch{}\" grilling-delegation",
64
+ "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))||{}}catch{}let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}catch{}\" grilling-delegation",
65
65
  "timeout": 10
66
66
  }
67
67
  ]
@@ -72,7 +72,7 @@
72
72
  {
73
73
  "type": "command",
74
74
  "statusMessage": "QFAI api-budget reminder",
75
- "command": "node -e \"try{const j=JSON.parse(require('fs').readFileSync(0,'utf8')),i=j.tool_input.command;if(typeof i==='string'&&/[^\\w.-]gh[^\\w.-]|api\\.github\\.com/.test(' '+i+' ')){const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}}catch{}\" api-budget",
75
+ "command": "node -e \"try{const j=JSON.parse(require('fs').readFileSync(0,'utf8')),i=j.tool_input.command;if(typeof i==='string'&&/[^\\w.-](gh|curl|wget|iwr|irm|invoke-webrequest|invoke-restmethod)(\\.exe)?[^\\w.-]|api\\.github\\.com/i.test(' '+i+' ')){const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}}catch{}\" api-budget",
76
76
  "timeout": 10
77
77
  }
78
78
  ]
@@ -85,13 +85,13 @@
85
85
  {
86
86
  "type": "command",
87
87
  "statusMessage": "QFAI documentation-clarity reminder",
88
- "command": "node -e \"try{const j=JSON.parse(require('fs').readFileSync(0,'utf8')),i=j.tool_input.command;if(typeof i==='string'&&/^\\*\\*\\* Add File: .*\\.md\\r?\\n/m.test(i)){const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}}catch{}\" documentation-clarity-after-write",
88
+ "command": "node -e \"try{const j=JSON.parse(require('fs').readFileSync(0,'utf8')),i=j.tool_input.command;if(typeof i==='string'&&/^\\*\\*\\* Add File: .*\\.md\\r?\\n/m.test(i)){const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}}catch{}\" documentation-clarity-after-write",
89
89
  "timeout": 10
90
90
  },
91
91
  {
92
92
  "type": "command",
93
93
  "statusMessage": "QFAI documentation-clarity reminder",
94
- "command": "node -e \"try{const j=JSON.parse(require('fs').readFileSync(0,'utf8')),i=j.tool_input.command;if(typeof i==='string'&&/^\\*\\*\\* Update File: .*\\.md\\r?\\n/m.test(i)){const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}}catch{}\" documentation-clarity-after-edit",
94
+ "command": "node -e \"try{const j=JSON.parse(require('fs').readFileSync(0,'utf8')),i=j.tool_input.command;if(typeof i==='string'&&/^\\*\\*\\* Update File: .*\\.md\\r?\\n/m.test(i)){const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}}catch{}\" documentation-clarity-after-edit",
95
95
  "timeout": 10
96
96
  }
97
97
  ]
@@ -102,19 +102,7 @@
102
102
  {
103
103
  "type": "command",
104
104
  "statusMessage": "QFAI minimal-implementation reminder",
105
- "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let go=true,j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))}catch{}try{const R=p.dirname(p.dirname(p.dirname(r))),n=(x=>{const s=x.split(p.sep),b=s.pop();return p.isAbsolute(x)||s[0]==='..'||s.some(y=>['tmp','test','tests','__tests__','node_modules','.qfai','.agents'].includes(y))||b[0]==='.'||/\\.(test|spec)\\./.test(b)||['.md','.mdx','.markdown','.txt','.rst','.yml','.yaml','.json','.jsonc','.json5','.toml','.ini','.csv','.tsv','.lock','.svg','.png','.jpg','.jpeg','.gif'].includes(p.extname(b).toLowerCase())}),a=[...j.tool_input.command.matchAll(/^\\*\\*\\* (?:(?:Add|Update|Delete) File|Move to): (.+)/gm)].map(m=>p.relative(R,p.resolve(process.cwd(),m[1].trim())));if(a.length>0&&a.every(n))go=false}catch{}if(go){let n=1;if(typeof j.session_id==='string'){try{const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));f.appendFileSync(t,'.');n=f.statSync(t).size}catch{}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{const {briefContext,...m}=e;if(n>1&&typeof briefContext==='string')m.hookSpecificOutput.additionalContext=briefContext;console.log(JSON.stringify(m))}}}}catch{}\" minimal-implementation",
106
- "timeout": 10
107
- }
108
- ]
109
- }
110
- ],
111
- "Stop": [
112
- {
113
- "hooks": [
114
- {
115
- "type": "command",
116
- "statusMessage": "QFAI session feedback reminder",
117
- "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let i;try{i=JSON.parse(f.readFileSync(0,'utf8'))}catch{process.exit(0)}const l=typeof i.last_assistant_message==='string'?i.last_assistant_message.trim():'';if(i.stop_hook_active===true||(l.length>0&&('?'+String.fromCharCode(65311)).includes(l.slice(-1))))process.exit(0);const m=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];m===undefined||console.log(JSON.stringify(m))}}catch{}\" session-feedback",
105
+ "command": "node -e \"try{const f=require('fs'),p=require('path');let d=process.cwd(),r;for(;;){const c=p.join(d,'.agents','rules','reminders.json');if(r===undefined&&f.existsSync(c))r=c;if(f.existsSync(p.join(d,'.git')))break;const u=p.dirname(d);if(u===d){r=undefined;break}d=u}if(r){let go=true,j={};try{j=JSON.parse(f.readFileSync(0,'utf8'))}catch{}try{const R=p.dirname(p.dirname(p.dirname(r))),n=(x=>{const s=x.split(p.sep),b=s.pop();return p.isAbsolute(x)||s[0]==='..'||s.some(y=>['tmp','test','tests','__tests__','node_modules','.qfai','.agents'].includes(y))||b[0]==='.'||/\\.(test|spec)\\./.test(b)||['.md','.mdx','.markdown','.txt','.rst','.yml','.yaml','.json','.jsonc','.json5','.toml','.ini','.csv','.tsv','.lock','.svg','.png','.jpg','.jpeg','.gif'].includes(p.extname(b).toLowerCase())}),a=[...j.tool_input.command.matchAll(/^\\*\\*\\* (?:(?:Add|Update|Delete) File|Move to): (.+)/gm)].map(m=>p.relative(R,p.resolve(process.cwd(),m[1].trim())));if(a.length>0&&a.every(n))go=false}catch{}if(go){let n=1;if(typeof j.session_id==='string'){const t=p.join(require('os').tmpdir(),['qfai-reminder',j.session_id,j.agent_id||'main',process.argv[1]].join('-').replace(/[^\\w.-]/g,'_'));try{f.writeFileSync(t,'',{flag:'wx'})}catch(q){try{if(q.code==='EEXIST'&&f.statSync(t).isFile())n=2}catch{}}}const e=JSON.parse(f.readFileSync(r,'utf8'))[process.argv[1]];if(e===undefined){}else{if(n===1)console.log(JSON.stringify(e))}}}}catch{}\" minimal-implementation",
118
106
  "timeout": 10
119
107
  }
120
108
  ]
@@ -63,7 +63,7 @@ specialization_tags:
63
63
  - Backend implementation summary
64
64
  - Changed files and affected contracts
65
65
  - Local verification notes
66
- - Test path, selector, observed RED/GREEN/Refactor results and changed files, in the stage report
66
+ - Test path, selector, observed RED/GREEN/Refactor results (or `ci-deferred`) and changed files, in the stage report
67
67
  - Notes on invariants, validation, and why added abstractions/configuration are necessary now
68
68
 
69
69
  ## Stop conditions
@@ -67,7 +67,7 @@ specialization_tags:
67
67
  - Frontend implementation summary
68
68
  - Changed files and affected flows
69
69
  - Local verification notes
70
- - Test path, selector, observed RED/GREEN/Refactor results and changed files, in the stage report
70
+ - Test path, selector, observed RED/GREEN/Refactor results (or `ci-deferred`) and changed files, in the stage report
71
71
  - Notes on how simplicity, necessity, and reuse were preserved in the chosen implementation
72
72
 
73
73
  ## Stop conditions
@@ -60,6 +60,9 @@ specialization_tags:
60
60
  This is the one reach beyond the touched files, and it covers only the inputs the change handles.
61
61
  A security finding the review demonstrates traces to `defect:security`.
62
62
  - Check the EX test's oracle, selector and RED/GREEN/Refactor evidence.
63
+ - When the change adds, moves or copies an AC or EX annotation, read the annotated test's body and confirm that it asserts the example's observable outcome,
64
+ or for an AC annotation that it asserts the criterion.
65
+ An annotation on a test that checks something else is a finding and traces to `defect:correctness`.
63
66
  - Check for code written only to pass a test: no value hard-coded to the test's
64
67
  inputs and no branch written only for the test, and a wrong test or infeasible
65
68
  task raised as a Change Request, not worked around
@@ -74,6 +77,8 @@ specialization_tags:
74
77
  - `<paths.specsDir>/03_contract/tech.md`, plus the active API, DB or UI contracts this change affects.
75
78
  - The changed code and tests, their diff, repository review instructions, and actual quality-gate results.
76
79
  - The stage report for the reviewed EX: its test, selector and observed results. A missing required observation prevents PASS.
80
+ A `ci-deferred` Red or Green is not a missing observation: read the test against the code before the fix instead,
81
+ as `.qfai/assistant/skill/qfai-implement/references/red-admissibility.md#ci-only-test-gate` states.
77
82
 
78
83
  ## Deliverables
79
84
 
@@ -39,8 +39,11 @@ specialization_tags:
39
39
  - Audit visual design, token alignment, and service-level UX coherence.
40
40
  - Reconcile sidecar artifacts (screen contracts), design tokens, mermaid flows, and rendered output consistency.
41
41
  HTML mock is optional fallback evidence only. Design tokens are supporting input.
42
- - For UI implementation, compare rendered output against the prototype handoff, canonical prototype screenshots, HTML snapshots, and the final prototype the handoff's `finalArtifact` names (`.qfai/prototype/final/index.html`).
43
- - Check the implementation against the handoff's `procurement` before judging
42
+ - For UI implementation, compare rendered output against the prototype handoff, canonical prototype
43
+ screenshots, HTML snapshots, and the final prototype the handoff's `finalArtifact` names
44
+ (`.qfai/prototype/final/index.html`), or, for a `restyle` handoff, its `liveRoutes` (compare in
45
+ the running app) and `entryPoints`.
46
+ - Check the implementation against the handoff's `procurement` (a restyle handoff has none) before judging
44
47
  resemblance: a region the manifest says was procured and the code rebuilt is a finding
45
48
  with a name, and an authored region the manifest does not list is one too.
46
49
  - Reject prototype parity when implementation loses CTA hierarchy, spacing rhythm, information density,
@@ -81,7 +84,9 @@ specialization_tags:
81
84
  - UI contract files: every `.yaml` / `.yml` under `<paths.contractsDir>/ui/**`, walked recursively.
82
85
  `paths.contractsDir` comes from `qfai.config.yaml` (default `.qfai/spec/03_contract`).
83
86
  Read the same contracts that routed the review here (`skill/qfai-implement/references/ui-affecting.md`).
84
- - Prototype handoff at `.qfai/prototype/final/handoff.json` when a prototyping loop ran: the final prototype, `procurement` and implementation notes.
87
+ - Prototype handoff at `.qfai/prototype/final/handoff.json` when a prototyping loop ran: the final
88
+ prototype, `procurement` and implementation notes, or, for a `restyle` handoff, its `liveRoutes`
89
+ (compare in the running app) and `entryPoints`.
85
90
  Read it in the checkout that ran the loop.
86
91
  - Root `DESIGN.md` for the brand tokens.
87
92
  - Runtime screenshots / HTML evidence / relevant diffs
@@ -3,6 +3,13 @@
3
3
  This document defines **non‑negotiable operating rules** for QFAI agents and subagents.
4
4
  It is inspired by proven “constitution / articles / guardrails” patterns in existing SDD toolchains, but adapted to QFAI’s minimal workflow.
5
5
 
6
+ Actual user instructions take priority over repository guidelines. Recorded
7
+ applicable user authority is defined in
8
+ `.agents/rules/grilling.md#explicit-delegation-for-a-discussion`: an explicit
9
+ in-scope delegation may authorize reversible requested judgment without a
10
+ fictional individual approval answer. It supplies no unknown fact or authority
11
+ for an operation outside its scope.
12
+
6
13
  Inside an `npx qfai workflow` run, what authorizes the run's work and the one target a work order binds its stage to are stated in `.qfai/assistant/rule/shared-skill-operating-baseline.md#what-authorizes-a-runs-work`. They add to these articles and except none.
7
14
 
8
15
  ---
@@ -260,7 +267,7 @@ sanctioned move, and neither is asking a sixth clarification anyway.
260
267
  **A grilling session survives exhaustion too**, and for the same reason: its
261
268
  questions never spent budget, so there is none left to run out of. A session
262
269
  already under way continues to its own end condition, a delegated one still
263
- putting its critical decisions to the user, and a stage reached after
270
+ requiring actual user authority for critical decisions, and a stage reached after
264
271
  exhaustion still opens one where its work calls for it. Treating a spent budget
265
272
  as the end of a session would put the design decisions back where this article
266
273
  found them — settled quietly, on an assumption nobody was asked about.
@@ -287,9 +294,11 @@ should exist is a Change Request.
287
294
 
288
295
  ### Prototyping exception (scope floor)
289
296
 
290
- For `/qfai-prototyping`, the minimum allowed scope includes every declared UI
291
- contract and screen in the configured story tree. Shrinking the loop to one
292
- contract is prohibited unless a documented Change Request approves it.
297
+ For `/qfai-prototyping`, the confirmed prototype in `.qfai/prototype/final/`
298
+ covers every declared UI contract and screen in the configured story tree.
299
+ Shrinking what it covers is prohibited unless a documented Change Request
300
+ approves it. A run scoped per `prototyping-grill` § Run scope rebuilds part of
301
+ a confirmed `final/` and merges it back, so it does not shrink the floor.
293
302
 
294
303
  ---
295
304
 
@@ -322,16 +331,18 @@ If confidence is low, inspect the repository further.
322
331
 
323
332
  **Stop on detection.** Where a contradiction in the spec, an unconsidered case,
324
333
  or a technical obstacle surfaces mid-run, stop rather than deciding alone.
325
- Settle it between the agents, and put a critical decision to the user
326
- (`.agents/rules/grilling.md#critical-decisions`). A contradiction with the spec
327
- is critical. Nothing is recorded beyond the stage's final report.
334
+ Settle it between the agents. A critical decision needs an actual user answer
335
+ or recorded applicable authorization under
336
+ `.agents/rules/grilling.md#explicit-delegation-for-a-discussion`; without it,
337
+ ask when permitted or register it open. A contradiction with the spec is
338
+ critical. Nothing is recorded beyond the stage's final report.
328
339
 
329
340
  **Only one outcome is the Drift Protocol's.**
330
341
 
331
- | The stop concludes | What follows |
332
- | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
333
- | Settled input must change | `.qfai/assistant/rule/drift-protocol.md`: stop the dependent work, raise the Change Request, wait for approval |
334
- | The obstacle is this run's to solve — an unavailable dependency, an approach that failed | The run solves it. Nothing upstream changes, so there is nothing to approve |
342
+ | The stop concludes | What follows |
343
+ | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
344
+ | Settled input must change | `.qfai/assistant/rule/drift-protocol.md`: stop dependent work, raise the Change Request, record actual applicable user authority before changing it |
345
+ | The obstacle is this run's to solve — an unavailable dependency, an approach that failed | The run solves it. Nothing upstream changes, so there is nothing to approve |
335
346
 
336
347
  Stopping does not change settled input and is not a second way to. What it
337
348
  contributes to a Change Request is what that protocol asks of the class: for
@@ -366,7 +377,9 @@ rule master names.
366
377
  Rules:
367
378
 
368
379
  0. **A no-question mode is read first.** Where rule 4 applies, no question is put
369
- at all, so there is nothing whose availability rules 1 to 3 could judge. Read
380
+ to the user, so there is nothing whose availability rules 1 to 3 could judge.
381
+ Actual qualifying explicit delegation may still permit agent-to-agent rounds
382
+ under the master; no-question mode alone does not. Read
370
383
  the other way round, a mode that withholds the tool would make it unavailable,
371
384
  route the question to rule 3's plain-text fallback, and hand the agent a rule
372
385
  that says to ask beside one that says not to.
@@ -406,12 +419,14 @@ Rules:
406
419
  this rule is activated by the `--auto` flag alone.
407
420
  6. **A grilling session does not reach the user under `--auto`.** Its questions
408
421
  are exempt from the Article VI budget, not from rule 4: a no-question mode
409
- asks nothing, whatever the question is for. The session still runs — it
422
+ sends no question to the user, whatever it is for. The session still runs — it
410
423
  settles what the repository settles, dispatches sub-agents for the facts, and
411
- in a delegated session adopts the griller's recommendation for every decision
412
- that is not critical — and every **node** left over (in a delegated session,
413
- each critical decision and each fact only the user holds) is **opened as a
414
- question in the register the stage reads**, so the stage cannot complete over it. Every node, not every
424
+ in a delegated session adopts the griller's recommendation for non-critical
425
+ decisions. A critical decision needs an actual user answer or recorded
426
+ applicable authorization; without it the node stays open. It opens every **node**
427
+ left over, including uncovered critical decisions and unavailable user-held
428
+ facts, **as a question in the register the stage reads**, so the
429
+ stage cannot complete over it. Every node, not every
415
430
  decision: a fact only the user holds cannot be settled from evidence either,
416
431
  and opening the decisions while dropping the facts loses exactly the nodes no
417
432
  lookup could have reached. Where a document requires the field to hold
@@ -419,7 +434,10 @@ Rules:
419
434
  open question; a labelled value under an open question is not a settled
420
435
  decision. What rule 4 does not license is the assumption **alone**, which
421
436
  reads as settled to whoever finds it next. A fact declared undefaultable has
422
- no value to write down at all: the run stops and names it.
437
+ no value to write down at all: the run stops and names it. A qualifying
438
+ explicitly delegated session ends `adopted` only with the master's empty-tree,
439
+ actual-input and authority conditions met. No-question mode alone cannot
440
+ close a node or authorize a reserved decision.
423
441
 
424
442
  This article survives context compaction because `.qfai/assistant/rule/constitution.md` is a P1 reload target.
425
443
 
@@ -2,6 +2,24 @@
2
2
 
3
3
  This rule governs changes discovered after a specification or contract has been approved.
4
4
 
5
+ ## Decision-register pages
6
+
7
+ Listed decision pages and their root index are protected project artifacts.
8
+ Read pages in list order, followed by the root table, before interpreting a
9
+ request. A page preserves the same row identity and Status permissions as the
10
+ root. New rows are appended only to the root table. Missing, unsafe or unreadable
11
+ members stop permission decisions; a partial history grants no authority.
12
+
13
+ A historical DONE row is not permission to relocate the register again.
14
+ Physical relocation requires a separately adopted execution change request and
15
+ a reviewed raw-byte receipt for the exact source and target. Preserve every row
16
+ occurrence, cell, Status, order and line ending, plus the current root tail.
17
+ Relocation does not permit duplicate cleanup, Status repair or normalization of
18
+ inherited cells. Relocation changes physical home only; it neither adds nor removes
19
+ a logical row. A migration projection grants no write authority. Never rotate
20
+ automatically. Each physical file still meets the inclusive 500-line limit;
21
+ formatting exclusions preserve bytes and never waive schema or semantic checks.
22
+
5
23
  ## Core rule
6
24
 
7
25
  A downstream skill does not edit an approved specification, policy, contract, or QFAI-owned rule on its own authority. It records the discrepancy and returns the affected artifact to its owner. A discussion pack is discovery material; the story tree and contracts are the current specification.
@@ -24,6 +42,10 @@ The sole Approach-change exception is the published decision prefix recovery
24
42
  below. It preserves the target's ID, Content, Status and complete original
25
43
  Approach suffix. It excludes inherited rows and open-question rows.
26
44
 
45
+ The sole row-removal exception is the merge-added identical decision copy
46
+ recovery below. It removes only proven raw-identical surplus copies of a
47
+ decision and keeps one original. It excludes open-question rows.
48
+
27
49
  ## Allowed exceptions (minimal whitelist)
28
50
 
29
51
  - A project may add a local overlay beside a shipped rule. The overlay adds project guidance; it does not repeal a shipped rule.
@@ -81,6 +103,60 @@ recovery authority and clear no form error. Inherited malformed records need a
81
103
  separate owning change request; this operation cannot repair them. These are
82
104
  owner instructions, not an automatic recovery command or a concurrency guarantee.
83
105
 
106
+ ## Merge-added identical decision copy recovery
107
+
108
+ The SDD owner may manually remove only raw-identical surplus copies of a
109
+ decision row that an exact two-parent bad merge introduced. Approval of this
110
+ protocol authorizes no target. First append a separate new in-force change
111
+ request that names the exact `decisions.md` path and the decision ID.
112
+
113
+ 1. Name the bad merge. It must be an available ancestor of current HEAD with
114
+ exactly two parents, and it must expose the introduced surplus. Name both
115
+ parents and their unique common ancestor. Each of the three must hold exactly
116
+ one byte-identical original of the row. Fix the explicit base and its unique
117
+ comparison ancestor; both must hold one original and no surplus selected for
118
+ removal. A missing or non-ancestor merge, a third parent, a non-unique
119
+ ancestor or a source that does not hold exactly one original stops recovery.
120
+ 2. Read the complete stored UTF-8 raw row of every selected current occurrence:
121
+ all four cells, delimiters, padding and line ending. Hash each with SHA-256,
122
+ including the line ending. Do not trim, decode escapes or normalize endings.
123
+ Nonidentical cells, padding or endings are a different collision and are
124
+ outside this recovery.
125
+ 3. Record in the request the path, the ID, the bad merge, both parents, the
126
+ ancestor, the base and its comparison ancestor, the location of each
127
+ occurrence, the raw hash, the retain/remove mapping, the actual authority,
128
+ the residual risk and the rollback. Record actual authority; invent no
129
+ answer. The request fixes input lineage only.
130
+ 4. After the request is appended, have the evidence for the write reviewed
131
+ independently and adopted. It fixes the actual write HEAD, base and
132
+ comparison ancestor, the complete preimage and replacement bytes and hashes,
133
+ the mapping and the current authority. The request does not name its own
134
+ commit, so the actual write revision stays distinct from the lineage above.
135
+ This adds no receipt grammar and no validator input.
136
+ 5. Immediately before writing, recheck the refs, their availability, the path,
137
+ the authority, the occurrence count, the mapping and the bytes. Stale,
138
+ missing, ambiguous, conflicting or changed proof stops before writing.
139
+ Changed observations need refreshed reviewed evidence. A changed target or
140
+ operation needs a new request; do not rewrite the cells of an earlier one.
141
+ 6. Remove only the mapped surplus occurrences. Keep one complete original, every
142
+ distinct decision and reference, every unrelated current byte and the Git
143
+ history. Do not change a Status, rewrite a reference or reorder other
144
+ history. Open-question rows, nonidentical collisions, ordinary duplicate
145
+ cleanup and surplus that the base or its comparison ancestor already holds
146
+ are excluded.
147
+ 7. Rollback restores the recorded complete preimage only while the current file
148
+ is byte-identical to its owned replacement. Otherwise keep the current bytes,
149
+ stop and name the unrestored path. Restoring brings back the duplicate
150
+ failure. Do not reset, amend or force push.
151
+
152
+ The existing duplicate check, positional drift, consumed-DONE authorization and
153
+ valid Status-only rules keep applying without an exemption. Other drift that
154
+ the file already has stays diagnosed; it is not a prerequisite for this
155
+ correction. An actual required stage gate still stops dependent work. Correcting
156
+ the copies is not a whole-target PASS, and the request stays at WIP while a named
157
+ action or required check is unfinished. These are owner instructions, not a
158
+ command, an executor or a concurrency, atomicity or power-loss guarantee.
159
+
84
160
  ## Drift classes
85
161
 
86
162
  Intent drift means an approved obligation should change. Record the current obligation, the proposed behavior, realistic
@@ -168,6 +244,9 @@ copy of a locked file before deciding its lock is wrong.
168
244
  ## Non-negotiable constraints
169
245
 
170
246
  - Downstream stages do not patch protected upstream artifacts before an in-force Change request: decision row authorizes the path. The drift profile compares the branch against baseBranch and reports QFAI-DRIFT-001 for an unapproved protected change. The SDD owner may create the request row itself without a prior row.
171
- - Existing decisions.md and open-questions.md rows retain their ID, Content, and Approach, except for the explicit branch-added decision renumbering and published decision prefix recovery above. Inherited rows retain those cells without exception. A former row may change Status; new content is appended as a new row.
247
+ QFAI-DRIFT-003 is a warning that nothing was compared, because baseBranch does not resolve.
248
+ QFAI-DRIFT-004 is a warning that an uncommitted edit to a protected file is not compared:
249
+ record the Change request row before you commit the change.
250
+ - Existing decisions.md and open-questions.md rows retain their ID, Content, and Approach, except for the explicit branch-added decision renumbering, published decision prefix recovery and merge-added identical decision copy recovery above. Inherited rows retain those cells without exception. A former row may change Status; new content is appended as a new row.
172
251
  - Vendored assistant rules are changed in the package and synchronized into projects by `npx qfai init --force`, which overwrites a local edit. A project rule lives in a `*.local.md` overlay beside the vendored one.
173
252
  - When approval is unavailable, keep the affected items stopped and report the decision needed. Continue unrelated work.
@@ -0,0 +1,27 @@
1
+ # Codex Delegation
2
+
3
+ Read before the first `spawn_agent` call when the host is Codex.
4
+
5
+ ## Codex delegation notes
6
+
7
+ A sub-agent should cost the orchestrator one brief and one final answer. A call
8
+ that only checks progress, such as a short wait, a sleep or an agent listing,
9
+ is one more model call, so the orchestrator makes none.
10
+
11
+ - **Self-contained brief.** Call `spawn_agent` with `fork_turns: "none"` and a
12
+ `message` that holds everything the sub-agent needs: the task, the files to
13
+ read, the paths it may write, the checks to run and the shape of its answer.
14
+ `fork_turns` defaults to `"all"`, which copies the whole parent thread into
15
+ the sub-agent. Where the tool takes `fork_context` instead, leave it out or
16
+ pass `false`.
17
+ - **One final answer, no interim messages.** The brief tells the sub-agent to
18
+ send no `send_message` updates and to return its result once, as its final
19
+ answer. Where `wait_agent` takes no `targets`, every queued message ends the
20
+ orchestrator's wait early.
21
+ - **Long wait.** With no work of its own left, the orchestrator calls
22
+ `wait_agent` with a `timeout_ms` of minutes within the maximum the tool states,
23
+ such as `600000`, not 10 to 60 seconds. A wait that times out is
24
+ followed by another long wait.
25
+ - **No polling.** Never wait with `sleep`, a loop of short `wait_agent` calls or
26
+ repeated `list_agents` calls. `followup_task` gives a sub-agent a new task; it
27
+ never asks for progress.
@@ -4,7 +4,7 @@ Read when a gate fails.
4
4
 
5
5
  ## Gate Failure Autorepair Protocol
6
6
 
7
- Follow this protocol when any of the validate, doctor, test, lint, typecheck, build, capture, or report gates fail. A reviewer's `REVISE` is not a gate failure and is not rerun: the author fixes or answers each finding once, as `.qfai/assistant/rule/review-convergence.md` sets out.
7
+ Follow this protocol when any of the validate, doctor, test, lint, typecheck, build, capture, or report gates fail. A reviewer's `REVISE` is not a gate failure and is not rerun as one: the author fixes or answers each finding, with a behaviour fix's one focused re-review, as `.qfai/assistant/rule/review-convergence.md` sets out.
8
8
 
9
9
  - inspect exit code, logs, `validate.json`, and cited files before reporting — in `validate.json`, read `counts` for the verdict and `issues[].code` for each finding; the array is `issues`, not `findings`;
10
10
  - classify each finding as skill-owned artifact, upstream spec/contract, code/test defect, environment/tooling, or user decision;