@aria_asi/cli 0.2.40 → 0.2.41

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 (802) hide show
  1. package/bin/aria.js +236 -34
  2. package/dist/aria-connector/src/action-ledger-core.d.ts +387 -0
  3. package/dist/aria-connector/src/action-ledger-core.d.ts.map +1 -0
  4. package/dist/aria-connector/src/action-ledger-core.js +638 -0
  5. package/dist/aria-connector/src/action-ledger-core.js.map +1 -0
  6. package/dist/aria-connector/src/chat.d.ts.map +1 -1
  7. package/dist/aria-connector/src/chat.js +5 -6
  8. package/dist/aria-connector/src/chat.js.map +1 -1
  9. package/dist/aria-connector/src/codebase-scanner.d.ts +1 -1
  10. package/dist/aria-connector/src/codebase-scanner.d.ts.map +1 -1
  11. package/dist/aria-connector/src/connectors/claude-code.d.ts +1 -0
  12. package/dist/aria-connector/src/connectors/claude-code.d.ts.map +1 -1
  13. package/dist/aria-connector/src/connectors/claude-code.js +152 -14
  14. package/dist/aria-connector/src/connectors/claude-code.js.map +1 -1
  15. package/dist/aria-connector/src/connectors/codebase-awareness.d.ts +10 -0
  16. package/dist/aria-connector/src/connectors/codebase-awareness.d.ts.map +1 -1
  17. package/dist/aria-connector/src/connectors/codebase-awareness.js +276 -27
  18. package/dist/aria-connector/src/connectors/codebase-awareness.js.map +1 -1
  19. package/dist/aria-connector/src/connectors/codex.d.ts +3 -1
  20. package/dist/aria-connector/src/connectors/codex.d.ts.map +1 -1
  21. package/dist/aria-connector/src/connectors/codex.js +1223 -41
  22. package/dist/aria-connector/src/connectors/codex.js.map +1 -1
  23. package/dist/aria-connector/src/connectors/cursor.d.ts.map +1 -1
  24. package/dist/aria-connector/src/connectors/cursor.js +7 -0
  25. package/dist/aria-connector/src/connectors/cursor.js.map +1 -1
  26. package/dist/aria-connector/src/connectors/governed-adapter.d.ts +30 -0
  27. package/dist/aria-connector/src/connectors/governed-adapter.d.ts.map +1 -0
  28. package/dist/aria-connector/src/connectors/governed-adapter.js +132 -0
  29. package/dist/aria-connector/src/connectors/governed-adapter.js.map +1 -0
  30. package/dist/aria-connector/src/connectors/opencode.d.ts +3 -1
  31. package/dist/aria-connector/src/connectors/opencode.d.ts.map +1 -1
  32. package/dist/aria-connector/src/connectors/opencode.js +18 -2
  33. package/dist/aria-connector/src/connectors/opencode.js.map +1 -1
  34. package/dist/aria-connector/src/connectors/repo-guard.d.ts.map +1 -1
  35. package/dist/aria-connector/src/connectors/repo-guard.js +25 -14
  36. package/dist/aria-connector/src/connectors/repo-guard.js.map +1 -1
  37. package/dist/aria-connector/src/connectors/runtime.d.ts.map +1 -1
  38. package/dist/aria-connector/src/connectors/runtime.js +92 -2
  39. package/dist/aria-connector/src/connectors/runtime.js.map +1 -1
  40. package/dist/aria-connector/src/connectors/shell.d.ts.map +1 -1
  41. package/dist/aria-connector/src/connectors/shell.js +123 -7
  42. package/dist/aria-connector/src/connectors/shell.js.map +1 -1
  43. package/dist/aria-connector/src/cross-cli-hive-binding.d.ts +63 -0
  44. package/dist/aria-connector/src/cross-cli-hive-binding.d.ts.map +1 -0
  45. package/dist/aria-connector/src/cross-cli-hive-binding.js +205 -0
  46. package/dist/aria-connector/src/cross-cli-hive-binding.js.map +1 -0
  47. package/dist/aria-connector/src/garden-control-plane.d.ts +6 -1
  48. package/dist/aria-connector/src/garden-control-plane.d.ts.map +1 -1
  49. package/dist/aria-connector/src/garden-control-plane.js +8 -2
  50. package/dist/aria-connector/src/garden-control-plane.js.map +1 -1
  51. package/dist/aria-connector/src/governed-surface-runner.d.ts +189 -0
  52. package/dist/aria-connector/src/governed-surface-runner.d.ts.map +1 -0
  53. package/dist/aria-connector/src/governed-surface-runner.js +1022 -0
  54. package/dist/aria-connector/src/governed-surface-runner.js.map +1 -0
  55. package/dist/aria-connector/src/index.d.ts +10 -1
  56. package/dist/aria-connector/src/index.d.ts.map +1 -1
  57. package/dist/aria-connector/src/index.js +5 -0
  58. package/dist/aria-connector/src/index.js.map +1 -1
  59. package/dist/aria-connector/src/task-runner.d.ts +3 -0
  60. package/dist/aria-connector/src/task-runner.d.ts.map +1 -0
  61. package/dist/aria-connector/src/task-runner.js +3526 -0
  62. package/dist/aria-connector/src/task-runner.js.map +1 -0
  63. package/dist/aria-web/src/lib/codebase-scanner.d.ts +21 -2
  64. package/dist/aria-web/src/lib/codebase-scanner.d.ts.map +1 -1
  65. package/dist/aria-web/src/lib/codebase-scanner.js +59 -14
  66. package/dist/aria-web/src/lib/codebase-scanner.js.map +1 -1
  67. package/dist/assets/hooks/README.md +58 -0
  68. package/dist/assets/hooks/aria-agent-handoff.mjs +147 -2
  69. package/dist/assets/hooks/aria-agent-ledger-merge.mjs +31 -7
  70. package/dist/assets/hooks/aria-architect-fallback.mjs +10 -2
  71. package/dist/assets/hooks/aria-claim-evidence-stop-gate.mjs +240 -0
  72. package/dist/assets/hooks/aria-cognition-substrate-binding.mjs +84 -10
  73. package/dist/assets/hooks/aria-first-class-coach.mjs +305 -10
  74. package/dist/assets/hooks/aria-harness-via-sdk.mjs +93 -16
  75. package/dist/assets/hooks/aria-import-resolution-gate.mjs +106 -20
  76. package/dist/assets/hooks/aria-outcome-record.mjs +56 -20
  77. package/dist/assets/hooks/aria-pre-emit-autoload.mjs +1809 -0
  78. package/dist/assets/hooks/aria-pre-emit-autoload.mjs.before-orchestration-redesign +1400 -0
  79. package/dist/assets/hooks/aria-pre-emit-dryrun.mjs +22 -3
  80. package/dist/assets/hooks/aria-pre-text-gate.mjs +11 -2
  81. package/dist/assets/hooks/aria-pre-tool-gate.mjs +477 -81
  82. package/dist/assets/hooks/aria-pre-tool-use.mjs +70 -6
  83. package/dist/assets/hooks/aria-preprompt-consult.mjs +23 -4
  84. package/dist/assets/hooks/aria-repo-doctrine-gate.mjs +29 -3
  85. package/dist/assets/hooks/aria-stop-gate.mjs +585 -76
  86. package/dist/assets/hooks/aria-trigger-autolearn.mjs +17 -3
  87. package/dist/assets/hooks/aria-universal-turn-packet.mjs +1165 -0
  88. package/dist/assets/hooks/aria-userprompt-abandon-detect.mjs +9 -1
  89. package/dist/assets/hooks/canonical-settings-block.json +172 -0
  90. package/dist/assets/hooks/codex-native/aria-harness-ticker-sidecar.mjs +92 -0
  91. package/dist/assets/hooks/codex-native/aria-hive-wal-consumer.mjs +86 -0
  92. package/dist/assets/hooks/codex-native/aria-live-ticker.mjs +38 -0
  93. package/dist/assets/hooks/codex-native/aria-post-tool-use.mjs +236 -0
  94. package/dist/assets/hooks/codex-native/aria-pre-tool-use.mjs +362 -0
  95. package/dist/assets/hooks/codex-native/aria-stop.mjs +691 -0
  96. package/dist/assets/hooks/codex-native/aria-userprompt-submit.mjs +623 -0
  97. package/dist/assets/hooks/codex-native/atlas-session-context.mjs +121 -0
  98. package/dist/assets/hooks/codex-native/lib/evaluate-with-kernel.mjs +257 -0
  99. package/dist/assets/hooks/codex-native/lib/hive-wal-consumer.mjs +452 -0
  100. package/dist/assets/hooks/codex-native/lib/kernel/deterministic-cognitive-kernel.mjs +914 -0
  101. package/dist/assets/hooks/codex-native/lib/project-boundary-cognition.mjs +143 -0
  102. package/dist/assets/hooks/codex-native/lib/runtime-client.mjs +3567 -0
  103. package/dist/assets/hooks/codex-native/lib/task-project-ledger.mjs +294 -0
  104. package/dist/assets/hooks/doctrine_trigger_map.json +236 -25
  105. package/dist/assets/hooks/doctrine_trigger_map.schema.json +46 -0
  106. package/dist/assets/hooks/install.sh +84 -0
  107. package/dist/assets/hooks/lib/action-ledger-core.mjs +269 -0
  108. package/dist/assets/hooks/lib/aria-gate-ledger.mjs +143 -0
  109. package/dist/assets/hooks/lib/ast-stub-shape-detector.mjs +107 -0
  110. package/dist/assets/hooks/lib/atlas-dossier-client.mjs +151 -0
  111. package/dist/assets/hooks/lib/atlas-orchestrator-postwire.mjs +221 -0
  112. package/dist/assets/hooks/lib/canonical-lenses.mjs +83 -6
  113. package/dist/assets/hooks/lib/coach-intent-classifier.mjs +248 -0
  114. package/dist/assets/hooks/lib/cognitive-block-parser.mjs +111 -0
  115. package/dist/assets/hooks/lib/doctrine-trigger-map-loader.mjs +137 -0
  116. package/dist/assets/hooks/lib/domain-output-quality.mjs +132 -3
  117. package/dist/assets/hooks/lib/empty-catch-scanner.mjs +91 -0
  118. package/dist/assets/hooks/lib/end-phase-qa-autofire.mjs +426 -0
  119. package/dist/assets/hooks/lib/evaluate-with-kernel.mjs +133 -0
  120. package/dist/assets/hooks/lib/first-class-coach.mjs +454 -19
  121. package/dist/assets/hooks/lib/gate-audit.mjs +12 -2
  122. package/dist/assets/hooks/lib/gate-loop-state.mjs +11 -2
  123. package/dist/assets/hooks/lib/goal-contract-quality.mjs +302 -0
  124. package/dist/assets/hooks/lib/hook-message-window.mjs +101 -9
  125. package/dist/assets/hooks/lib/invocation-required-verifier.mjs +184 -0
  126. package/dist/assets/hooks/lib/kernel/deterministic-cognitive-kernel.mjs +906 -0
  127. package/dist/assets/hooks/lib/obligation-ledger.mjs +147 -0
  128. package/dist/assets/hooks/lib/orchestration-manifest-extract.mjs +217 -0
  129. package/dist/assets/hooks/lib/owner-authorizations.mjs +269 -0
  130. package/dist/assets/hooks/lib/probe-discipline-scanner.mjs +142 -0
  131. package/dist/assets/hooks/lib/project-boundary-cognition.mjs +143 -0
  132. package/dist/assets/hooks/lib/recovery-context.mjs +151 -0
  133. package/dist/assets/hooks/lib/recovery-template-loader.mjs +154 -0
  134. package/dist/assets/hooks/lib/self-doctrine-check.mjs +321 -0
  135. package/dist/assets/hooks/lib/sensitive-shape-detector.mjs +64 -0
  136. package/dist/assets/hooks/lib/skill-autoload-gate-impl.mjs +226 -1
  137. package/dist/assets/hooks/lib/stop-hook-protocol.mjs +166 -0
  138. package/dist/assets/hooks/lib/surface-caught.mjs +94 -0
  139. package/dist/assets/hooks/recovery-templates/force-reauthor.md +67 -0
  140. package/dist/assets/hooks/recovery-templates/handoff-recovery.md +25 -0
  141. package/dist/assets/hooks/scripts/check-hard-risk-prefix.mjs +99 -0
  142. package/dist/assets/hooks/skills/aria-conversational-doctrine-discipline/SKILL.md +101 -0
  143. package/dist/assets/hooks/test-aria-preturn-memory-gate.mjs +2 -2
  144. package/dist/assets/hooks/test-tier-lens-labeling.mjs +14 -3
  145. package/dist/assets/opencode-plugins/harness-context/index.js +39 -6
  146. package/dist/assets/opencode-plugins/harness-context/task-project-ledger.mjs +5 -1
  147. package/dist/assets/opencode-plugins/harness-gate/index.js +36 -0
  148. package/dist/assets/opencode-plugins/harness-gate/lib/atlas-dossier-client.js +1 -0
  149. package/dist/assets/opencode-plugins/harness-gate/lib/recovery-grants.js +79 -0
  150. package/dist/assets/opencode-plugins/harness-outcome/index.js +12 -0
  151. package/dist/assets/opencode-plugins/harness-stop/index.js +97 -2
  152. package/dist/assets/opencode-plugins/harness-stop/lib/atlas-dossier-client.js +1 -0
  153. package/dist/assets/opencode-plugins/harness-stop/lib/domain-output-quality.js +15 -2
  154. package/dist/assets/opencode-plugins/lib/coach.js +148 -0
  155. package/dist/runtime/coach-kernel.mjs +144 -7
  156. package/dist/runtime/codex-bridge.mjs +254 -8
  157. package/dist/runtime/discipline/doctrine_trigger_map.json +236 -25
  158. package/dist/runtime/discipline/skills/aria-cognition/34-frameworks-unified/SKILL.md +42 -0
  159. package/dist/runtime/discipline/skills/aria-cognition/aria-aristotle-cognitives/SKILL.md +128 -0
  160. package/dist/runtime/discipline/skills/aria-cognition/aria-aristotle-intra-phase/SKILL.md +99 -0
  161. package/dist/runtime/discipline/skills/aria-cognition/aria-aristotle-post-phase/SKILL.md +118 -0
  162. package/dist/runtime/discipline/skills/aria-cognition/aria-aristotle-pre-phase/SKILL.md +117 -0
  163. package/dist/runtime/discipline/skills/aria-cognition/aria-axioms-first-principles/SKILL.md +202 -0
  164. package/dist/runtime/discipline/skills/aria-cognition/aria-axioms-first-principles/agents/openai.yaml +4 -0
  165. package/dist/runtime/discipline/skills/aria-cognition/aria-axioms-first-principles/references/source-map.md +130 -0
  166. package/dist/runtime/discipline/skills/aria-cognition/aria-backend-architect/SKILL.md +124 -0
  167. package/dist/runtime/discipline/skills/aria-cognition/aria-backend-architect/references/backend-cookbook.md +417 -0
  168. package/dist/runtime/discipline/skills/aria-cognition/aria-business-audit/SKILL.md +133 -0
  169. package/dist/runtime/discipline/skills/aria-cognition/aria-business-audit/references/audit-cookbook.md +247 -0
  170. package/dist/runtime/discipline/skills/aria-cognition/aria-business-frame/SKILL.md +138 -0
  171. package/dist/runtime/discipline/skills/aria-cognition/aria-business-frame/references/business-cookbook.md +154 -0
  172. package/dist/runtime/discipline/skills/aria-cognition/aria-chat/SKILL.md +84 -0
  173. package/dist/runtime/discipline/skills/aria-cognition/aria-chat/scripts/aria-chat.sh +57 -0
  174. package/dist/runtime/discipline/skills/aria-cognition/aria-cognition-autofire/SKILL.md +137 -0
  175. package/dist/runtime/discipline/skills/aria-cognition/aria-cognition-batch/SKILL.md +264 -0
  176. package/dist/runtime/discipline/skills/aria-cognition/aria-decision-mizan/SKILL.md +136 -0
  177. package/dist/runtime/discipline/skills/aria-cognition/aria-decision-mizan/references/decision-frameworks.md +287 -0
  178. package/dist/runtime/discipline/skills/aria-cognition/aria-first-class-operating-contract/SKILL.md +104 -0
  179. package/dist/runtime/discipline/skills/aria-cognition/aria-frontend-architect/SKILL.md +123 -0
  180. package/dist/runtime/discipline/skills/aria-cognition/aria-frontend-architect/references/frontend-cookbook.md +358 -0
  181. package/dist/runtime/discipline/skills/aria-cognition/aria-fullstack-orchestrator/SKILL.md +127 -0
  182. package/dist/runtime/discipline/skills/aria-cognition/aria-fullstack-orchestrator/references/fullstack-cookbook.md +383 -0
  183. package/dist/runtime/discipline/skills/aria-cognition/aria-gtm-architect/SKILL.md +126 -0
  184. package/dist/runtime/discipline/skills/aria-cognition/aria-gtm-architect/references/gtm-cookbook.md +235 -0
  185. package/dist/runtime/discipline/skills/aria-cognition/aria-harness-deploy/SKILL.md +145 -0
  186. package/dist/runtime/discipline/skills/aria-cognition/aria-harness-no-stripping/SKILL.md +135 -0
  187. package/dist/runtime/discipline/skills/aria-cognition/aria-harness-onboarding/SKILL.md +130 -0
  188. package/dist/runtime/discipline/skills/aria-cognition/aria-harness-output-discipline/SKILL.md +120 -0
  189. package/dist/runtime/discipline/skills/aria-cognition/aria-harness-substrate-binding/SKILL.md +139 -0
  190. package/dist/runtime/discipline/skills/aria-cognition/aria-http-harness-client/SKILL.md +85 -0
  191. package/dist/runtime/discipline/skills/aria-cognition/aria-http-harness-client/scripts/smoke.mjs +47 -0
  192. package/dist/runtime/discipline/skills/aria-cognition/aria-k8s-deploy/SKILL.md +174 -0
  193. package/dist/runtime/discipline/skills/aria-cognition/aria-k8s-deploy/agents/openai.yaml +3 -0
  194. package/dist/runtime/discipline/skills/aria-cognition/aria-ladduniframe/SKILL.md +60 -0
  195. package/dist/runtime/discipline/skills/aria-cognition/aria-ledger-fleet-execution/SKILL.md +126 -0
  196. package/dist/runtime/discipline/skills/aria-cognition/aria-live-ops/SKILL.md +54 -0
  197. package/dist/runtime/discipline/skills/aria-cognition/aria-mac-ssh-ops/SKILL.md +100 -0
  198. package/dist/runtime/discipline/skills/aria-cognition/aria-memory-index/SKILL.md +42 -0
  199. package/dist/runtime/discipline/skills/aria-cognition/aria-noor-cognitives/SKILL.md +120 -0
  200. package/dist/runtime/discipline/skills/aria-cognition/aria-ops/SKILL.md +60 -0
  201. package/dist/runtime/discipline/skills/aria-cognition/aria-ops/references/live-endpoints.md +59 -0
  202. package/dist/runtime/discipline/skills/aria-cognition/aria-quality-audit/SKILL.md +133 -0
  203. package/dist/runtime/discipline/skills/aria-cognition/aria-readable-output/SKILL.md +239 -0
  204. package/dist/runtime/discipline/skills/aria-cognition/aria-readable-output/references/layout-cookbook.md +366 -0
  205. package/dist/runtime/discipline/skills/aria-cognition/aria-reasoning/SKILL.md +67 -0
  206. package/dist/runtime/discipline/skills/aria-cognition/aria-reasoning/references/core-principles.md +42 -0
  207. package/dist/runtime/discipline/skills/aria-cognition/aria-repo-audit/SKILL.md +135 -0
  208. package/dist/runtime/discipline/skills/aria-cognition/aria-repo-audit/references/repo-audit-cookbook.md +375 -0
  209. package/dist/runtime/discipline/skills/aria-cognition/aria-research-orchestrator/SKILL.md +138 -0
  210. package/dist/runtime/discipline/skills/aria-cognition/aria-research-orchestrator/references/research-patterns.md +270 -0
  211. package/dist/runtime/discipline/skills/aria-cognition/aria-retention-engine/SKILL.md +120 -0
  212. package/dist/runtime/discipline/skills/aria-cognition/aria-retention-engine/references/retention-cookbook.md +271 -0
  213. package/dist/runtime/discipline/skills/aria-cognition/aria-revenue-engine/SKILL.md +128 -0
  214. package/dist/runtime/discipline/skills/aria-cognition/aria-revenue-engine/references/revenue-cookbook.md +227 -0
  215. package/dist/runtime/discipline/skills/aria-cognition/aria-senior-code-audit/SKILL.md +233 -0
  216. package/dist/runtime/discipline/skills/aria-cognition/aria-senior-code-audit/references/audit-checklist.md +369 -0
  217. package/dist/runtime/discipline/skills/aria-cognition/aria-senior-code-cookbook/SKILL.md +288 -0
  218. package/dist/runtime/discipline/skills/aria-cognition/aria-senior-code-cookbook/references/engineering-cookbook.md +489 -0
  219. package/dist/runtime/discipline/skills/aria-cognition/aria-soul-principles/SKILL.md +42 -0
  220. package/dist/runtime/discipline/skills/aria-cognition/aria-task-codex-executor/SKILL.md +86 -0
  221. package/dist/runtime/discipline/skills/aria-cognition/aristotle-engine/SKILL.md +42 -0
  222. package/dist/runtime/discipline/skills/aria-cognition/cross-domain-24/SKILL.md +42 -0
  223. package/dist/runtime/discipline/skills/aria-cognition/deepsoul-emotional/SKILL.md +42 -0
  224. package/dist/runtime/discipline/skills/aria-cognition/fitrah-guard/SKILL.md +78 -0
  225. package/dist/runtime/discipline/skills/aria-cognition/ghazali-8lens/SKILL.md +227 -29
  226. package/dist/runtime/discipline/skills/aria-cognition/ghazali-8lens/references/ghazali-8lens-cookbook.md +797 -0
  227. package/dist/runtime/discipline/skills/aria-cognition/ijtihad-novel/SKILL.md +42 -0
  228. package/dist/runtime/discipline/skills/aria-cognition/ilham-intuition/SKILL.md +42 -0
  229. package/dist/runtime/discipline/skills/aria-cognition/never-guess/SKILL.md +77 -0
  230. package/dist/runtime/discipline/skills/aria-cognition/noor-recognition/SKILL.md +45 -0
  231. package/dist/runtime/discipline/skills/aria-cognition/qiyas-analogy/SKILL.md +174 -14
  232. package/dist/runtime/discipline/skills/aria-cognition/ruh-basis/SKILL.md +42 -0
  233. package/dist/runtime/discipline/skills/aria-cognition/tadabbur/SKILL.md +506 -0
  234. package/dist/runtime/discipline/skills/aria-cognition/tadabbur/references/tadabbur-cookbook.md +921 -0
  235. package/dist/runtime/discipline/skills/aria-cognition/tadabbur-ops/SKILL.md +42 -0
  236. package/dist/runtime/discipline/skills/aria-cognition/tafakkur/SKILL.md +104 -0
  237. package/dist/runtime/doctrine_trigger_map.json +236 -25
  238. package/dist/runtime/embedded-public-key.mjs +27 -0
  239. package/dist/runtime/gated-ledger.mjs +41 -14
  240. package/dist/runtime/harness-daemon.mjs +85 -10
  241. package/dist/runtime/hive-wal-publisher.mjs +292 -0
  242. package/dist/runtime/hooks/README.md +58 -0
  243. package/dist/runtime/hooks/aria-agent-handoff.mjs +147 -2
  244. package/dist/runtime/hooks/aria-agent-ledger-merge.mjs +31 -7
  245. package/dist/runtime/hooks/aria-architect-fallback.mjs +10 -2
  246. package/dist/runtime/hooks/aria-claim-evidence-stop-gate.mjs +240 -0
  247. package/dist/runtime/hooks/aria-cognition-substrate-binding.mjs +84 -10
  248. package/dist/runtime/hooks/aria-first-class-coach.mjs +305 -10
  249. package/dist/runtime/hooks/aria-harness-via-sdk.mjs +93 -16
  250. package/dist/runtime/hooks/aria-import-resolution-gate.mjs +106 -20
  251. package/dist/runtime/hooks/aria-outcome-record.mjs +56 -20
  252. package/dist/runtime/hooks/aria-pre-emit-autoload.mjs +1809 -0
  253. package/dist/runtime/hooks/aria-pre-emit-autoload.mjs.before-orchestration-redesign +1400 -0
  254. package/dist/runtime/hooks/aria-pre-emit-dryrun.mjs +22 -3
  255. package/dist/runtime/hooks/aria-pre-text-gate.mjs +11 -2
  256. package/dist/runtime/hooks/aria-pre-tool-gate.mjs +477 -81
  257. package/dist/runtime/hooks/aria-pre-tool-use.mjs +70 -6
  258. package/dist/runtime/hooks/aria-preprompt-consult.mjs +23 -4
  259. package/dist/runtime/hooks/aria-repo-doctrine-gate.mjs +29 -3
  260. package/dist/runtime/hooks/aria-stop-gate.mjs +585 -76
  261. package/dist/runtime/hooks/aria-trigger-autolearn.mjs +17 -3
  262. package/dist/runtime/hooks/aria-universal-turn-packet.mjs +1165 -0
  263. package/dist/runtime/hooks/aria-userprompt-abandon-detect.mjs +9 -1
  264. package/dist/runtime/hooks/canonical-settings-block.json +172 -0
  265. package/dist/runtime/hooks/codex-native/aria-harness-ticker-sidecar.mjs +92 -0
  266. package/dist/runtime/hooks/codex-native/aria-hive-wal-consumer.mjs +86 -0
  267. package/dist/runtime/hooks/codex-native/aria-live-ticker.mjs +38 -0
  268. package/dist/runtime/hooks/codex-native/aria-post-tool-use.mjs +236 -0
  269. package/dist/runtime/hooks/codex-native/aria-pre-tool-use.mjs +362 -0
  270. package/dist/runtime/hooks/codex-native/aria-stop.mjs +691 -0
  271. package/dist/runtime/hooks/codex-native/aria-userprompt-submit.mjs +623 -0
  272. package/dist/runtime/hooks/codex-native/atlas-session-context.mjs +121 -0
  273. package/dist/runtime/hooks/codex-native/lib/evaluate-with-kernel.mjs +257 -0
  274. package/dist/runtime/hooks/codex-native/lib/hive-wal-consumer.mjs +452 -0
  275. package/dist/runtime/hooks/codex-native/lib/kernel/deterministic-cognitive-kernel.mjs +914 -0
  276. package/dist/runtime/hooks/codex-native/lib/project-boundary-cognition.mjs +143 -0
  277. package/dist/runtime/hooks/codex-native/lib/runtime-client.mjs +3567 -0
  278. package/dist/runtime/hooks/codex-native/lib/task-project-ledger.mjs +294 -0
  279. package/dist/runtime/hooks/doctrine_trigger_map.json +236 -25
  280. package/dist/runtime/hooks/doctrine_trigger_map.schema.json +46 -0
  281. package/dist/runtime/hooks/install.sh +84 -0
  282. package/dist/runtime/hooks/lib/action-ledger-core.mjs +269 -0
  283. package/dist/runtime/hooks/lib/aria-gate-ledger.mjs +143 -0
  284. package/dist/runtime/hooks/lib/ast-stub-shape-detector.mjs +107 -0
  285. package/dist/runtime/hooks/lib/atlas-dossier-client.mjs +151 -0
  286. package/dist/runtime/hooks/lib/atlas-orchestrator-postwire.mjs +221 -0
  287. package/dist/runtime/hooks/lib/canonical-lenses.mjs +83 -6
  288. package/dist/runtime/hooks/lib/coach-intent-classifier.mjs +248 -0
  289. package/dist/runtime/hooks/lib/cognitive-block-parser.mjs +111 -0
  290. package/dist/runtime/hooks/lib/doctrine-trigger-map-loader.mjs +137 -0
  291. package/dist/runtime/hooks/lib/domain-output-quality.mjs +132 -3
  292. package/dist/runtime/hooks/lib/empty-catch-scanner.mjs +91 -0
  293. package/dist/runtime/hooks/lib/end-phase-qa-autofire.mjs +426 -0
  294. package/dist/runtime/hooks/lib/evaluate-with-kernel.mjs +133 -0
  295. package/dist/runtime/hooks/lib/first-class-coach.mjs +454 -19
  296. package/dist/runtime/hooks/lib/gate-audit.mjs +12 -2
  297. package/dist/runtime/hooks/lib/gate-loop-state.mjs +11 -2
  298. package/dist/runtime/hooks/lib/goal-contract-quality.mjs +302 -0
  299. package/dist/runtime/hooks/lib/hook-message-window.mjs +101 -9
  300. package/dist/runtime/hooks/lib/invocation-required-verifier.mjs +184 -0
  301. package/dist/runtime/hooks/lib/kernel/deterministic-cognitive-kernel.mjs +906 -0
  302. package/dist/runtime/hooks/lib/obligation-ledger.mjs +147 -0
  303. package/dist/runtime/hooks/lib/orchestration-manifest-extract.mjs +217 -0
  304. package/dist/runtime/hooks/lib/owner-authorizations.mjs +269 -0
  305. package/dist/runtime/hooks/lib/probe-discipline-scanner.mjs +142 -0
  306. package/dist/runtime/hooks/lib/project-boundary-cognition.mjs +143 -0
  307. package/dist/runtime/hooks/lib/recovery-context.mjs +151 -0
  308. package/dist/runtime/hooks/lib/recovery-template-loader.mjs +154 -0
  309. package/dist/runtime/hooks/lib/self-doctrine-check.mjs +321 -0
  310. package/dist/runtime/hooks/lib/sensitive-shape-detector.mjs +64 -0
  311. package/dist/runtime/hooks/lib/skill-autoload-gate-impl.mjs +226 -1
  312. package/dist/runtime/hooks/lib/stop-hook-protocol.mjs +166 -0
  313. package/dist/runtime/hooks/lib/surface-caught.mjs +94 -0
  314. package/dist/runtime/hooks/recovery-templates/force-reauthor.md +67 -0
  315. package/dist/runtime/hooks/recovery-templates/handoff-recovery.md +25 -0
  316. package/dist/runtime/hooks/scripts/check-hard-risk-prefix.mjs +99 -0
  317. package/dist/runtime/hooks/skills/aria-conversational-doctrine-discipline/SKILL.md +101 -0
  318. package/dist/runtime/hooks/test-aria-preturn-memory-gate.mjs +2 -2
  319. package/dist/runtime/hooks/test-tier-lens-labeling.mjs +14 -3
  320. package/dist/runtime/lib/evaluate-with-kernel.mjs +133 -0
  321. package/dist/runtime/lib/kernel/deterministic-cognitive-kernel.mjs +906 -0
  322. package/dist/runtime/local-phase.mjs +10 -5
  323. package/dist/runtime/manifest.json +8 -8
  324. package/dist/runtime/packet-verifier.mjs +166 -0
  325. package/dist/runtime/provider-proxy.mjs +13 -0
  326. package/dist/runtime/quality-enforcer.mjs +40 -23
  327. package/dist/runtime/runtime-rails/registry.mjs +252 -0
  328. package/dist/runtime/sdk/BUNDLED.json +2 -2
  329. package/dist/runtime/sdk/index.d.ts +119 -4
  330. package/dist/runtime/sdk/index.js +138 -12
  331. package/dist/runtime/sdk/index.js.map +1 -1
  332. package/dist/runtime/service.mjs +8036 -764
  333. package/dist/runtime/sub-agent-enforcer.mjs +201 -0
  334. package/dist/runtime/task-project-ledger.mjs +5 -1
  335. package/dist/sdk/BUNDLED.json +2 -2
  336. package/dist/sdk/index.d.ts +119 -4
  337. package/dist/sdk/index.js +138 -12
  338. package/dist/sdk/index.js.map +1 -1
  339. package/hooks/README.md +58 -0
  340. package/hooks/aria-agent-handoff.mjs +147 -2
  341. package/hooks/aria-agent-ledger-merge.mjs +31 -7
  342. package/hooks/aria-architect-fallback.mjs +10 -2
  343. package/hooks/aria-claim-evidence-stop-gate.mjs +240 -0
  344. package/hooks/aria-cognition-substrate-binding.mjs +84 -10
  345. package/hooks/aria-first-class-coach.mjs +305 -10
  346. package/hooks/aria-harness-via-sdk.mjs +93 -16
  347. package/hooks/aria-import-resolution-gate.mjs +106 -20
  348. package/hooks/aria-outcome-record.mjs +56 -20
  349. package/hooks/aria-pre-emit-autoload.mjs +1809 -0
  350. package/hooks/aria-pre-emit-autoload.mjs.before-orchestration-redesign +1400 -0
  351. package/hooks/aria-pre-emit-dryrun.mjs +22 -3
  352. package/hooks/aria-pre-text-gate.mjs +11 -2
  353. package/hooks/aria-pre-tool-gate.mjs +477 -81
  354. package/hooks/aria-pre-tool-use.mjs +70 -6
  355. package/hooks/aria-preprompt-consult.mjs +23 -4
  356. package/hooks/aria-repo-doctrine-gate.mjs +29 -3
  357. package/hooks/aria-stop-gate.mjs +585 -76
  358. package/hooks/aria-trigger-autolearn.mjs +17 -3
  359. package/hooks/aria-universal-turn-packet.mjs +1165 -0
  360. package/hooks/aria-userprompt-abandon-detect.mjs +9 -1
  361. package/hooks/canonical-settings-block.json +172 -0
  362. package/hooks/codex-native/aria-harness-ticker-sidecar.mjs +92 -0
  363. package/hooks/codex-native/aria-hive-wal-consumer.mjs +86 -0
  364. package/hooks/codex-native/aria-live-ticker.mjs +38 -0
  365. package/hooks/codex-native/aria-post-tool-use.mjs +236 -0
  366. package/hooks/codex-native/aria-pre-tool-use.mjs +362 -0
  367. package/hooks/codex-native/aria-stop.mjs +691 -0
  368. package/hooks/codex-native/aria-userprompt-submit.mjs +623 -0
  369. package/hooks/codex-native/atlas-session-context.mjs +121 -0
  370. package/hooks/codex-native/lib/evaluate-with-kernel.mjs +257 -0
  371. package/hooks/codex-native/lib/hive-wal-consumer.mjs +452 -0
  372. package/hooks/codex-native/lib/kernel/deterministic-cognitive-kernel.mjs +914 -0
  373. package/hooks/codex-native/lib/project-boundary-cognition.mjs +143 -0
  374. package/hooks/codex-native/lib/runtime-client.mjs +3567 -0
  375. package/hooks/codex-native/lib/task-project-ledger.mjs +294 -0
  376. package/hooks/doctrine_trigger_map.json +236 -25
  377. package/hooks/doctrine_trigger_map.schema.json +46 -0
  378. package/hooks/install.sh +84 -0
  379. package/hooks/lib/action-ledger-core.mjs +269 -0
  380. package/hooks/lib/aria-gate-ledger.mjs +143 -0
  381. package/hooks/lib/ast-stub-shape-detector.mjs +107 -0
  382. package/hooks/lib/atlas-dossier-client.mjs +151 -0
  383. package/hooks/lib/atlas-orchestrator-postwire.mjs +221 -0
  384. package/hooks/lib/canonical-lenses.mjs +83 -6
  385. package/hooks/lib/coach-intent-classifier.mjs +248 -0
  386. package/hooks/lib/cognitive-block-parser.mjs +111 -0
  387. package/hooks/lib/doctrine-trigger-map-loader.mjs +137 -0
  388. package/hooks/lib/domain-output-quality.mjs +132 -3
  389. package/hooks/lib/empty-catch-scanner.mjs +91 -0
  390. package/hooks/lib/end-phase-qa-autofire.mjs +426 -0
  391. package/hooks/lib/evaluate-with-kernel.mjs +133 -0
  392. package/hooks/lib/first-class-coach.mjs +454 -19
  393. package/hooks/lib/gate-audit.mjs +12 -2
  394. package/hooks/lib/gate-loop-state.mjs +11 -2
  395. package/hooks/lib/goal-contract-quality.mjs +302 -0
  396. package/hooks/lib/hook-message-window.mjs +101 -9
  397. package/hooks/lib/invocation-required-verifier.mjs +184 -0
  398. package/hooks/lib/kernel/deterministic-cognitive-kernel.mjs +906 -0
  399. package/hooks/lib/obligation-ledger.mjs +147 -0
  400. package/hooks/lib/orchestration-manifest-extract.mjs +217 -0
  401. package/hooks/lib/owner-authorizations.mjs +269 -0
  402. package/hooks/lib/probe-discipline-scanner.mjs +142 -0
  403. package/hooks/lib/project-boundary-cognition.mjs +143 -0
  404. package/hooks/lib/recovery-context.mjs +151 -0
  405. package/hooks/lib/recovery-template-loader.mjs +154 -0
  406. package/hooks/lib/self-doctrine-check.mjs +321 -0
  407. package/hooks/lib/sensitive-shape-detector.mjs +64 -0
  408. package/hooks/lib/skill-autoload-gate-impl.mjs +226 -1
  409. package/hooks/lib/stop-hook-protocol.mjs +166 -0
  410. package/hooks/lib/surface-caught.mjs +94 -0
  411. package/hooks/recovery-templates/force-reauthor.md +67 -0
  412. package/hooks/recovery-templates/handoff-recovery.md +25 -0
  413. package/hooks/scripts/check-hard-risk-prefix.mjs +99 -0
  414. package/hooks/skills/aria-conversational-doctrine-discipline/SKILL.md +101 -0
  415. package/hooks/test-aria-preturn-memory-gate.mjs +2 -2
  416. package/hooks/test-tier-lens-labeling.mjs +14 -3
  417. package/opencode-plugins/harness-context/index.js +39 -6
  418. package/opencode-plugins/harness-context/task-project-ledger.mjs +5 -1
  419. package/opencode-plugins/harness-gate/index.js +36 -0
  420. package/opencode-plugins/harness-gate/lib/atlas-dossier-client.js +1 -0
  421. package/opencode-plugins/harness-gate/lib/recovery-grants.js +79 -0
  422. package/opencode-plugins/harness-outcome/index.js +12 -0
  423. package/opencode-plugins/harness-stop/index.js +97 -2
  424. package/opencode-plugins/harness-stop/lib/atlas-dossier-client.js +1 -0
  425. package/opencode-plugins/harness-stop/lib/domain-output-quality.js +15 -2
  426. package/opencode-plugins/lib/coach.js +148 -0
  427. package/package.json +71 -5
  428. package/runtime-src/coach-kernel.mjs +144 -7
  429. package/runtime-src/codex-bridge.mjs +254 -8
  430. package/runtime-src/embedded-public-key.mjs +27 -0
  431. package/runtime-src/gated-ledger.mjs +41 -14
  432. package/runtime-src/harness-daemon.mjs +85 -10
  433. package/runtime-src/hive-wal-publisher.mjs +292 -0
  434. package/runtime-src/lib/evaluate-with-kernel.mjs +133 -0
  435. package/runtime-src/lib/kernel/deterministic-cognitive-kernel.mjs +906 -0
  436. package/runtime-src/local-phase.mjs +10 -5
  437. package/runtime-src/packet-verifier.mjs +166 -0
  438. package/runtime-src/provider-proxy.mjs +13 -0
  439. package/runtime-src/quality-enforcer.mjs +40 -23
  440. package/runtime-src/runtime-rails/registry.mjs +252 -0
  441. package/runtime-src/service.mjs +8036 -764
  442. package/runtime-src/sub-agent-enforcer.mjs +201 -0
  443. package/scripts/aria-ledger-append.mjs +337 -0
  444. package/scripts/aria-task-cheap-worker-dispatch.mjs +234 -0
  445. package/scripts/audit-of-audit-prior-tasks.mjs +194 -0
  446. package/scripts/audit-of-audit-this-turn.mjs +116 -0
  447. package/scripts/bundle-sdk.mjs +31 -5
  448. package/scripts/check-cli-wrapper-provider-contract.mjs +160 -0
  449. package/scripts/check-client-compatibility.mjs +15 -5
  450. package/scripts/check-client-smoke.mjs +297 -0
  451. package/scripts/check-codex-orchestrator-adoption.mjs +150 -0
  452. package/scripts/check-glm-env-wired.mjs +131 -0
  453. package/scripts/check-hive-local-storage-contract.mjs +91 -0
  454. package/scripts/check-hook-mirror.mjs +150 -0
  455. package/scripts/check-install-sh-drift.mjs +152 -0
  456. package/scripts/check-kernel-sync.mjs +101 -0
  457. package/scripts/check-package-artifact.mjs +152 -0
  458. package/scripts/check-registry-mirror.mjs +71 -0
  459. package/scripts/drain-owner-airtable-sync-queue.mjs +287 -0
  460. package/scripts/export-owner-status-sheets.mjs +589 -0
  461. package/scripts/live-sidecar-receipt-canary.mjs +347 -0
  462. package/scripts/qiyas-tadabbur-model-matrix.mjs +970 -0
  463. package/scripts/quality-ab-live-provider.mjs +913 -0
  464. package/scripts/self-test-action-ledger-core.mjs +190 -0
  465. package/scripts/self-test-approval-receipt-binding.mjs +122 -0
  466. package/scripts/self-test-autofire-quality-output.mjs +110 -0
  467. package/scripts/self-test-claude-code-action-ledger.mjs +132 -0
  468. package/scripts/self-test-claude-code-mechanical-autofire-hive.mjs +138 -0
  469. package/scripts/self-test-claude-code-mechanical-autofire.mjs +234 -0
  470. package/scripts/self-test-codebase-awareness-atlas-delta.mjs +159 -0
  471. package/scripts/self-test-codebase-awareness-delta-ingest.mjs +179 -0
  472. package/scripts/self-test-codex-live-hook-parity.mjs +84 -0
  473. package/scripts/self-test-codex-native-action-ledger.mjs +167 -0
  474. package/scripts/self-test-codex-native-hook-json-contract.mjs +74 -0
  475. package/scripts/self-test-codex-orchestrator-continuity.mjs +113 -0
  476. package/scripts/self-test-codex-readable-recovery.mjs +94 -0
  477. package/scripts/self-test-codex-self-harness.mjs +538 -0
  478. package/scripts/self-test-compiled-workunit.mjs +214 -0
  479. package/scripts/self-test-continuation-output-smoke.mjs +101 -0
  480. package/scripts/self-test-cross-cli-fleet-ticker.mjs +85 -0
  481. package/scripts/self-test-cross-cli-hive-adoption.mjs +125 -0
  482. package/scripts/self-test-cross-cli-hive-learning.mjs +146 -0
  483. package/scripts/self-test-cross-phase-tool-failure.mjs +110 -0
  484. package/scripts/self-test-cross-surface-action-ledger.mjs +149 -0
  485. package/scripts/self-test-end-of-phase-qa-court.mjs +616 -0
  486. package/scripts/self-test-evaluate-with-kernel.mjs +111 -0
  487. package/scripts/self-test-first-class-output-delta-proof.mjs +307 -0
  488. package/scripts/self-test-goal-contract-output-qa.mjs +73 -0
  489. package/scripts/self-test-goal-contract.mjs +35 -0
  490. package/scripts/self-test-governed-adapters.mjs +105 -0
  491. package/scripts/self-test-governed-surface-runner.mjs +198 -0
  492. package/scripts/self-test-harness-gates.mjs +15 -12
  493. package/scripts/self-test-harness-ticker-sidecar.mjs +153 -0
  494. package/scripts/self-test-hive-org-kernel.mjs +233 -0
  495. package/scripts/self-test-hive-session-coordination.mjs +156 -0
  496. package/scripts/self-test-hive-wal-consumer.mjs +111 -0
  497. package/scripts/self-test-kernel-a3-a4-selection.mjs +179 -0
  498. package/scripts/self-test-ledger-append.mjs +175 -0
  499. package/scripts/self-test-live-codex-posttool-packet-smoke.mjs +111 -0
  500. package/scripts/self-test-live-codex-pretool-packet-smoke.mjs +101 -0
  501. package/scripts/self-test-live-codex-stop-qa-kernel-smoke.mjs +43 -0
  502. package/scripts/self-test-live-wrapper-substrate-inventory.mjs +149 -0
  503. package/scripts/self-test-local-main-sync-script.mjs +47 -0
  504. package/scripts/self-test-mechanical-autofire-resolver.mjs +296 -0
  505. package/scripts/self-test-no-consult-cognitive-skills-output.mjs +135 -0
  506. package/scripts/self-test-owner-airtable-sync-queue.mjs +196 -0
  507. package/scripts/self-test-owner-airtable-sync.mjs +181 -0
  508. package/scripts/self-test-owner-sheets-action-ledger.mjs +100 -0
  509. package/scripts/self-test-production-preflight.mjs +78 -0
  510. package/scripts/self-test-project-boundary-cognition.mjs +79 -0
  511. package/scripts/self-test-qa-exec-kernel.mjs +34 -0
  512. package/scripts/self-test-qa-recovery-learning-loop.mjs +113 -0
  513. package/scripts/self-test-qiyas-label-alignment.mjs +94 -0
  514. package/scripts/self-test-recovery-context.mjs +110 -0
  515. package/scripts/self-test-repo-guard.mjs +10 -0
  516. package/scripts/self-test-runtime-health-self-heal.mjs +161 -0
  517. package/scripts/self-test-runtime-postcondition.mjs +70 -0
  518. package/scripts/self-test-soul-precommit-hook.mjs +39 -0
  519. package/scripts/self-test-stop-gate-kernel-guards.mjs +185 -0
  520. package/scripts/self-test-stop-gate.mjs +128 -0
  521. package/scripts/self-test-substrate-kernel-execution-receipt.mjs +130 -0
  522. package/scripts/self-test-substrate-open-skill-floor.mjs +87 -0
  523. package/scripts/self-test-substrate-output-quality-eval.mjs +171 -0
  524. package/scripts/self-test-task-closeout-drift.mjs +97 -0
  525. package/scripts/self-test-task-project-ledger-readiness.mjs +43 -0
  526. package/scripts/self-test-task-runner-phase-consumer.mjs +134 -0
  527. package/scripts/self-test-task-worker-lane.mjs +256 -0
  528. package/scripts/self-test-turn-substrate-qa-kernel.mjs +188 -0
  529. package/scripts/self-test-universal-action-capture.mjs +153 -0
  530. package/scripts/self-test-universal-turn-packet-entrypoints.mjs +252 -0
  531. package/scripts/self-test-universal-turn-packet.mjs +320 -0
  532. package/scripts/session-quality-backfill.mjs +253 -0
  533. package/scripts/smoke-autofire-100-prompts.mjs +481 -0
  534. package/scripts/sync-local-main-on-task-complete.mjs +278 -0
  535. package/scripts/sync-owner-status-airtable.mjs +1158 -0
  536. package/scripts/validate-skill-prompts.mjs +12 -1
  537. package/scripts/verify-codex-native-mirror.mjs +262 -0
  538. package/skills/34-frameworks-unified/SKILL.md +42 -0
  539. package/skills/api-design/SKILL.md +123 -0
  540. package/skills/architecture-decision/SKILL.md +105 -0
  541. package/skills/aria-aristotle-cognitives/SKILL.md +128 -0
  542. package/skills/aria-aristotle-intra-phase/SKILL.md +99 -0
  543. package/skills/aria-aristotle-post-phase/SKILL.md +116 -0
  544. package/skills/aria-aristotle-pre-phase/SKILL.md +117 -0
  545. package/skills/aria-axioms-first-principles/SKILL.md +202 -0
  546. package/skills/aria-axioms-first-principles/agents/openai.yaml +4 -0
  547. package/skills/aria-axioms-first-principles/references/source-map.md +130 -0
  548. package/skills/aria-chat/SKILL.md +84 -0
  549. package/skills/aria-chat/scripts/aria-chat.sh +57 -0
  550. package/skills/aria-cognition/34-frameworks-unified/SKILL.md +42 -0
  551. package/skills/aria-cognition/aria-aristotle-cognitives/SKILL.md +128 -0
  552. package/skills/aria-cognition/aria-aristotle-intra-phase/SKILL.md +99 -0
  553. package/skills/aria-cognition/aria-aristotle-post-phase/SKILL.md +118 -0
  554. package/skills/aria-cognition/aria-aristotle-pre-phase/SKILL.md +117 -0
  555. package/skills/aria-cognition/aria-axioms-first-principles/SKILL.md +202 -0
  556. package/skills/aria-cognition/aria-axioms-first-principles/agents/openai.yaml +4 -0
  557. package/skills/aria-cognition/aria-axioms-first-principles/references/source-map.md +130 -0
  558. package/skills/aria-cognition/aria-backend-architect/SKILL.md +124 -0
  559. package/skills/aria-cognition/aria-backend-architect/references/backend-cookbook.md +417 -0
  560. package/skills/aria-cognition/aria-business-audit/SKILL.md +133 -0
  561. package/skills/aria-cognition/aria-business-audit/references/audit-cookbook.md +247 -0
  562. package/skills/aria-cognition/aria-business-frame/SKILL.md +138 -0
  563. package/skills/aria-cognition/aria-business-frame/references/business-cookbook.md +154 -0
  564. package/skills/aria-cognition/aria-chat/SKILL.md +84 -0
  565. package/skills/aria-cognition/aria-chat/scripts/aria-chat.sh +57 -0
  566. package/skills/aria-cognition/aria-cognition-autofire/SKILL.md +137 -0
  567. package/skills/aria-cognition/aria-cognition-batch/SKILL.md +264 -0
  568. package/skills/aria-cognition/aria-decision-mizan/SKILL.md +136 -0
  569. package/skills/aria-cognition/aria-decision-mizan/references/decision-frameworks.md +287 -0
  570. package/skills/aria-cognition/aria-first-class-operating-contract/SKILL.md +104 -0
  571. package/skills/aria-cognition/aria-frontend-architect/SKILL.md +123 -0
  572. package/skills/aria-cognition/aria-frontend-architect/references/frontend-cookbook.md +358 -0
  573. package/skills/aria-cognition/aria-fullstack-orchestrator/SKILL.md +127 -0
  574. package/skills/aria-cognition/aria-fullstack-orchestrator/references/fullstack-cookbook.md +383 -0
  575. package/skills/aria-cognition/aria-gtm-architect/SKILL.md +126 -0
  576. package/skills/aria-cognition/aria-gtm-architect/references/gtm-cookbook.md +235 -0
  577. package/skills/aria-cognition/aria-harness-deploy/SKILL.md +145 -0
  578. package/skills/aria-cognition/aria-harness-no-stripping/SKILL.md +135 -0
  579. package/skills/aria-cognition/aria-harness-onboarding/SKILL.md +130 -0
  580. package/skills/aria-cognition/aria-harness-output-discipline/SKILL.md +120 -0
  581. package/skills/aria-cognition/aria-harness-substrate-binding/SKILL.md +139 -0
  582. package/skills/aria-cognition/aria-http-harness-client/SKILL.md +85 -0
  583. package/skills/aria-cognition/aria-http-harness-client/scripts/smoke.mjs +47 -0
  584. package/skills/aria-cognition/aria-k8s-deploy/SKILL.md +174 -0
  585. package/skills/aria-cognition/aria-k8s-deploy/agents/openai.yaml +3 -0
  586. package/skills/aria-cognition/aria-ladduniframe/SKILL.md +60 -0
  587. package/skills/aria-cognition/aria-ledger-fleet-execution/SKILL.md +126 -0
  588. package/skills/aria-cognition/aria-live-ops/SKILL.md +54 -0
  589. package/skills/aria-cognition/aria-mac-ssh-ops/SKILL.md +100 -0
  590. package/skills/aria-cognition/aria-memory-index/SKILL.md +42 -0
  591. package/skills/aria-cognition/aria-noor-cognitives/SKILL.md +120 -0
  592. package/skills/aria-cognition/aria-ops/SKILL.md +60 -0
  593. package/skills/aria-cognition/aria-ops/references/live-endpoints.md +59 -0
  594. package/skills/aria-cognition/aria-quality-audit/SKILL.md +133 -0
  595. package/skills/aria-cognition/aria-readable-output/SKILL.md +239 -0
  596. package/skills/aria-cognition/aria-readable-output/references/layout-cookbook.md +366 -0
  597. package/skills/aria-cognition/aria-reasoning/SKILL.md +67 -0
  598. package/skills/aria-cognition/aria-reasoning/references/core-principles.md +42 -0
  599. package/skills/aria-cognition/aria-repo-audit/SKILL.md +135 -0
  600. package/skills/aria-cognition/aria-repo-audit/references/repo-audit-cookbook.md +375 -0
  601. package/skills/aria-cognition/aria-research-orchestrator/SKILL.md +138 -0
  602. package/skills/aria-cognition/aria-research-orchestrator/references/research-patterns.md +270 -0
  603. package/skills/aria-cognition/aria-retention-engine/SKILL.md +120 -0
  604. package/skills/aria-cognition/aria-retention-engine/references/retention-cookbook.md +271 -0
  605. package/skills/aria-cognition/aria-revenue-engine/SKILL.md +128 -0
  606. package/skills/aria-cognition/aria-revenue-engine/references/revenue-cookbook.md +227 -0
  607. package/skills/aria-cognition/aria-senior-code-audit/SKILL.md +233 -0
  608. package/skills/aria-cognition/aria-senior-code-audit/references/audit-checklist.md +369 -0
  609. package/skills/aria-cognition/aria-senior-code-cookbook/SKILL.md +288 -0
  610. package/skills/aria-cognition/aria-senior-code-cookbook/references/engineering-cookbook.md +489 -0
  611. package/skills/aria-cognition/aria-soul-principles/SKILL.md +42 -0
  612. package/skills/aria-cognition/aria-task-codex-executor/SKILL.md +86 -0
  613. package/skills/aria-cognition/aristotle-engine/SKILL.md +42 -0
  614. package/skills/aria-cognition/cross-domain-24/SKILL.md +42 -0
  615. package/skills/aria-cognition/deepsoul-emotional/SKILL.md +42 -0
  616. package/skills/aria-cognition/fitrah-guard/SKILL.md +78 -0
  617. package/skills/aria-cognition/ghazali-8lens/SKILL.md +227 -29
  618. package/skills/aria-cognition/ghazali-8lens/references/ghazali-8lens-cookbook.md +797 -0
  619. package/skills/aria-cognition/ijtihad-novel/SKILL.md +42 -0
  620. package/skills/aria-cognition/ilham-intuition/SKILL.md +42 -0
  621. package/skills/aria-cognition/never-guess/SKILL.md +77 -0
  622. package/skills/aria-cognition/noor-recognition/SKILL.md +45 -0
  623. package/skills/aria-cognition/qiyas-analogy/SKILL.md +174 -14
  624. package/skills/aria-cognition/ruh-basis/SKILL.md +42 -0
  625. package/skills/aria-cognition/tadabbur/SKILL.md +506 -0
  626. package/skills/aria-cognition/tadabbur/references/tadabbur-cookbook.md +921 -0
  627. package/skills/aria-cognition/tadabbur-ops/SKILL.md +42 -0
  628. package/skills/aria-cognition/tafakkur/SKILL.md +104 -0
  629. package/skills/aria-cognition-autofire/SKILL.md +109 -0
  630. package/skills/aria-cognition-batch/SKILL.md +264 -0
  631. package/skills/aria-conversational-doctrine-discipline/SKILL.md +125 -0
  632. package/skills/aria-essence/SKILL.md +81 -0
  633. package/skills/aria-essence/references/domain-matrix.md +80 -0
  634. package/skills/aria-essence/references/evolution-loop.md +30 -0
  635. package/skills/aria-essence/references/readable-cognition.md +27 -0
  636. package/skills/aria-first-class-operating-contract/SKILL.md +104 -0
  637. package/skills/aria-forge-guardrails/SKILL.md +53 -0
  638. package/skills/aria-forge-guardrails/references/checklist.md +31 -0
  639. package/skills/aria-harness-deploy/SKILL.md +145 -0
  640. package/skills/aria-harness-no-stripping/SKILL.md +135 -0
  641. package/skills/aria-harness-onboarding/SKILL.md +130 -0
  642. package/skills/aria-harness-output-discipline/SKILL.md +120 -0
  643. package/skills/aria-harness-substrate-binding/SKILL.md +139 -0
  644. package/skills/aria-http-harness-client/SKILL.md +85 -0
  645. package/skills/aria-http-harness-client/scripts/smoke.mjs +47 -0
  646. package/skills/aria-k8s-deploy/SKILL.md +174 -0
  647. package/skills/aria-k8s-deploy/agents/openai.yaml +3 -0
  648. package/skills/aria-ladduniframe/SKILL.md +60 -0
  649. package/skills/aria-ledger-fleet-execution/SKILL.md +126 -0
  650. package/skills/aria-live-ops/SKILL.md +54 -0
  651. package/skills/aria-mac-ssh-ops/SKILL.md +100 -0
  652. package/skills/aria-memory-index/SKILL.md +42 -0
  653. package/skills/aria-noor-cognitives/SKILL.md +120 -0
  654. package/skills/aria-ops/SKILL.md +60 -0
  655. package/skills/aria-ops/references/live-endpoints.md +59 -0
  656. package/skills/aria-quality-audit/SKILL.md +133 -0
  657. package/skills/aria-reasoning/SKILL.md +67 -0
  658. package/skills/aria-reasoning/references/core-principles.md +42 -0
  659. package/skills/aria-repo-doctrine/SKILL.md +57 -0
  660. package/skills/aria-soul-principles/SKILL.md +42 -0
  661. package/skills/aria-task-codex-executor/SKILL.md +86 -0
  662. package/skills/aristotle-engine/SKILL.md +42 -0
  663. package/skills/ci-cd-pipeline/SKILL.md +116 -0
  664. package/skills/code-review/SKILL.md +131 -0
  665. package/skills/cross-domain-24/SKILL.md +42 -0
  666. package/skills/database-design/SKILL.md +124 -0
  667. package/skills/deepsoul-emotional/SKILL.md +42 -0
  668. package/skills/deno-kv-raft-pubsub/SKILL.md +561 -0
  669. package/skills/deno-kv-raft-pubsub/reference/maelstrom-integration.md +393 -0
  670. package/skills/deno-kv-raft-pubsub/reference/pubsub-api.md +376 -0
  671. package/skills/deno-kv-raft-pubsub/reference/raft-spec.md +402 -0
  672. package/skills/deno-kv-raft-pubsub/reference/state-machine.md +182 -0
  673. package/skills/error-handling/SKILL.md +159 -0
  674. package/skills/firecrawl/SKILL.md +165 -0
  675. package/skills/firecrawl/rules/install.md +82 -0
  676. package/skills/firecrawl/rules/security.md +26 -0
  677. package/skills/firecrawl-agent/SKILL.md +86 -0
  678. package/skills/firecrawl-build-interact/SKILL.md +96 -0
  679. package/skills/firecrawl-build-onboarding/SKILL.md +131 -0
  680. package/skills/firecrawl-build-onboarding/references/auth-flow.md +39 -0
  681. package/skills/firecrawl-build-onboarding/references/project-setup.md +20 -0
  682. package/skills/firecrawl-build-onboarding/references/sdk-installation.md +17 -0
  683. package/skills/firecrawl-build-scrape/SKILL.md +97 -0
  684. package/skills/firecrawl-build-search/SKILL.md +97 -0
  685. package/skills/firecrawl-clone/SKILL.md +419 -0
  686. package/skills/firecrawl-crawl/SKILL.md +87 -0
  687. package/skills/firecrawl-download/SKILL.md +98 -0
  688. package/skills/firecrawl-interact/SKILL.md +112 -0
  689. package/skills/firecrawl-map/SKILL.md +79 -0
  690. package/skills/firecrawl-scrape/SKILL.md +97 -0
  691. package/skills/firecrawl-search/SKILL.md +88 -0
  692. package/skills/fitrah-guard/SKILL.md +78 -0
  693. package/skills/forge-quality-rules/SKILL.md +61 -0
  694. package/skills/ghazali-8lens/SKILL.md +56 -0
  695. package/skills/ijtihad-novel/SKILL.md +42 -0
  696. package/skills/ilham-intuition/SKILL.md +42 -0
  697. package/skills/imagegen/LICENSE.txt +201 -0
  698. package/skills/imagegen/SKILL.md +374 -0
  699. package/skills/imagegen/agents/openai.yaml +6 -0
  700. package/skills/imagegen/assets/imagegen-small.svg +5 -0
  701. package/skills/imagegen/assets/imagegen.png +0 -0
  702. package/skills/imagegen/references/cli.md +242 -0
  703. package/skills/imagegen/references/codex-network.md +33 -0
  704. package/skills/imagegen/references/image-api.md +90 -0
  705. package/skills/imagegen/references/prompting.md +118 -0
  706. package/skills/imagegen/references/sample-prompts.md +433 -0
  707. package/skills/imagegen/scripts/image_gen.py +995 -0
  708. package/skills/imagegen/scripts/remove_chroma_key.py +440 -0
  709. package/skills/istiqra-induction/SKILL.md +44 -0
  710. package/skills/ladunni-22/SKILL.md +53 -0
  711. package/skills/mizan/SKILL.md +90 -0
  712. package/skills/nadia/SKILL.md +56 -0
  713. package/skills/nadia-psi/SKILL.md +56 -0
  714. package/skills/never-guess/SKILL.md +75 -0
  715. package/skills/noor-recognition/SKILL.md +45 -0
  716. package/skills/observability/SKILL.md +133 -0
  717. package/skills/openai-docs/LICENSE.txt +201 -0
  718. package/skills/openai-docs/SKILL.md +100 -0
  719. package/skills/openai-docs/agents/openai.yaml +14 -0
  720. package/skills/openai-docs/assets/openai-small.svg +3 -0
  721. package/skills/openai-docs/assets/openai.png +0 -0
  722. package/skills/openai-docs/references/latest-model.md +37 -0
  723. package/skills/openai-docs/references/prompting-guide.md +244 -0
  724. package/skills/openai-docs/references/upgrade-guide.md +181 -0
  725. package/skills/openai-docs/scripts/resolve-latest-model-info.js +147 -0
  726. package/skills/pdf/LICENSE.txt +201 -0
  727. package/skills/pdf/SKILL.md +85 -0
  728. package/skills/pdf/agents/openai.yaml +5 -0
  729. package/skills/pdf/assets/pdf.png +0 -0
  730. package/skills/playwright/LICENSE.txt +201 -0
  731. package/skills/playwright/NOTICE.txt +14 -0
  732. package/skills/playwright/SKILL.md +165 -0
  733. package/skills/playwright/agents/openai.yaml +6 -0
  734. package/skills/playwright/assets/playwright-small.svg +3 -0
  735. package/skills/playwright/assets/playwright.png +0 -0
  736. package/skills/playwright/references/cli.md +116 -0
  737. package/skills/playwright/references/workflows.md +95 -0
  738. package/skills/playwright/scripts/playwright_cli.sh +25 -0
  739. package/skills/plugin-creator/SKILL.md +178 -0
  740. package/skills/plugin-creator/agents/openai.yaml +6 -0
  741. package/skills/plugin-creator/assets/plugin-creator-small.svg +3 -0
  742. package/skills/plugin-creator/assets/plugin-creator.png +0 -0
  743. package/skills/plugin-creator/references/plugin-json-spec.md +170 -0
  744. package/skills/plugin-creator/scripts/create_basic_plugin.py +301 -0
  745. package/skills/predictor/SKILL.md +43 -0
  746. package/skills/qiyas-analogy/SKILL.md +204 -0
  747. package/skills/refactoring/SKILL.md +137 -0
  748. package/skills/ruh-basis/SKILL.md +42 -0
  749. package/skills/security-review/SKILL.md +129 -0
  750. package/skills/skill-creator/SKILL.md +434 -0
  751. package/skills/skill-creator/agents/openai.yaml +5 -0
  752. package/skills/skill-creator/assets/skill-creator-small.svg +3 -0
  753. package/skills/skill-creator/assets/skill-creator.png +0 -0
  754. package/skills/skill-creator/license.txt +202 -0
  755. package/skills/skill-creator/references/openai_yaml.md +49 -0
  756. package/skills/skill-creator/scripts/generate_openai_yaml.py +226 -0
  757. package/skills/skill-creator/scripts/init_skill.py +400 -0
  758. package/skills/skill-creator/scripts/quick_validate.py +101 -0
  759. package/skills/skill-installer/LICENSE.txt +202 -0
  760. package/skills/skill-installer/SKILL.md +76 -0
  761. package/skills/skill-installer/agents/openai.yaml +5 -0
  762. package/skills/skill-installer/assets/skill-installer-small.svg +3 -0
  763. package/skills/skill-installer/assets/skill-installer.png +0 -0
  764. package/skills/skill-installer/scripts/github_utils.py +21 -0
  765. package/skills/skill-installer/scripts/install-skill-from-github.py +308 -0
  766. package/skills/skill-installer/scripts/list-skills.py +107 -0
  767. package/skills/skills-and-hooks-reference/SKILL.md +196 -0
  768. package/skills/soul-domains/SKILL.md +43 -0
  769. package/skills/tadabbur/SKILL.md +232 -0
  770. package/skills/tadabbur-ops/SKILL.md +42 -0
  771. package/skills/tafakkur/SKILL.md +104 -0
  772. package/skills/testing-strategy/SKILL.md +122 -0
  773. package/src/action-ledger-core.ts +1054 -0
  774. package/src/chat.ts +5 -6
  775. package/src/codebase-scanner.ts +2 -0
  776. package/src/connectors/claude-code.ts +149 -12
  777. package/src/connectors/codebase-awareness.ts +325 -25
  778. package/src/connectors/codex.ts +1225 -41
  779. package/src/connectors/cursor.ts +8 -0
  780. package/src/connectors/governed-adapter.ts +174 -0
  781. package/src/connectors/opencode.ts +18 -2
  782. package/src/connectors/repo-guard.ts +24 -12
  783. package/src/connectors/runtime.ts +99 -2
  784. package/src/connectors/shell.ts +125 -7
  785. package/src/cross-cli-hive-binding.ts +290 -0
  786. package/src/garden-control-plane.ts +24 -1
  787. package/src/governed-surface-runner.ts +1227 -0
  788. package/src/index.ts +104 -1
  789. package/src/task-runner.ts +3794 -0
  790. package/dist/aria-connector/src/install-hooks.d.ts +0 -18
  791. package/dist/aria-connector/src/install-hooks.d.ts.map +0 -1
  792. package/dist/aria-connector/src/install-hooks.js +0 -224
  793. package/dist/aria-connector/src/install-hooks.js.map +0 -1
  794. package/dist/aria-connector/src/onboarding-wizard.d.ts +0 -5
  795. package/dist/aria-connector/src/onboarding-wizard.d.ts.map +0 -1
  796. package/dist/aria-connector/src/onboarding-wizard.js +0 -188
  797. package/dist/aria-connector/src/onboarding-wizard.js.map +0 -1
  798. package/dist/cli-0.2.38.tgz +0 -0
  799. package/dist/install.sh +0 -13
  800. package/src/__tests__/anthropic-oauth.test.ts +0 -186
  801. package/src/__tests__/auth-commands.test.ts +0 -132
  802. package/src/__tests__/owner-login.test.ts +0 -311
@@ -18,6 +18,7 @@ import { connectShell } from './shell.js';
18
18
  import { installAriaCognitionSkills } from './cognitive-skills.js';
19
19
  import { syncDoctrineTriggerMap } from './doctrine-trigger-map.js';
20
20
  import { buildMustReadGuide, mustReadIntro } from './must-read.js';
21
+ import { requireGovernedConnectorMutation } from './governed-adapter.js';
21
22
 
22
23
  function packageSdkDir(): string {
23
24
  const here = path.dirname(fileURLToPath(import.meta.url));
@@ -27,12 +28,23 @@ function packageSdkDir(): string {
27
28
  function packageTaskProjectLedgerHelperPath(): string {
28
29
  const here = path.dirname(fileURLToPath(import.meta.url));
29
30
  const candidates = [
31
+ path.resolve(here, '..', '..', 'opencode-plugins', 'harness-context', 'task-project-ledger.mjs'),
30
32
  path.resolve(here, '..', '..', '..', '..', 'opencode-plugins', 'harness-context', 'task-project-ledger.mjs'),
31
33
  path.resolve(here, '..', '..', '..', 'assets', 'opencode-plugins', 'harness-context', 'task-project-ledger.mjs'),
32
34
  ];
33
35
  return candidates.find((candidate) => existsSync(candidate)) || candidates[0];
34
36
  }
35
37
 
38
+ function packageProjectBoundaryCognitionPath(): string {
39
+ const here = path.dirname(fileURLToPath(import.meta.url));
40
+ const candidates = [
41
+ path.resolve(here, '..', '..', 'hooks', 'lib', 'project-boundary-cognition.mjs'),
42
+ path.resolve(here, '..', '..', '..', '..', 'hooks', 'lib', 'project-boundary-cognition.mjs'),
43
+ path.resolve(here, '..', '..', '..', 'assets', 'hooks', 'lib', 'project-boundary-cognition.mjs'),
44
+ ];
45
+ return candidates.find((candidate) => existsSync(candidate)) || candidates[0];
46
+ }
47
+
36
48
  function installSdk(codexDir: string, logs: string[]): void {
37
49
  const sdkSrc = packageSdkDir();
38
50
  if (!existsSync(sdkSrc)) {
@@ -97,7 +109,25 @@ function tomlString(value: string): string {
97
109
  return JSON.stringify(value);
98
110
  }
99
111
 
112
+ function canonicalCodexHookPath(relativePath: string): string {
113
+ const here = path.dirname(fileURLToPath(import.meta.url));
114
+ const candidates = [
115
+ path.resolve(here, '..', '..', 'hooks', 'codex-native', relativePath),
116
+ path.resolve(here, '..', '..', '..', '..', 'hooks', 'codex-native', relativePath),
117
+ ];
118
+ return candidates.find((candidate) => existsSync(candidate)) || candidates[0];
119
+ }
120
+
121
+ function readCanonicalCodexHook(relativePath: string): string {
122
+ const hookPath = canonicalCodexHookPath(relativePath);
123
+ if (!existsSync(hookPath)) {
124
+ throw new Error(`Canonical Codex hook asset missing: ${hookPath}`);
125
+ }
126
+ return readFileSync(hookPath, 'utf8');
127
+ }
128
+
100
129
  function buildCodexHookRuntimeClient(): string {
130
+ return readCanonicalCodexHook('lib/runtime-client.mjs');
101
131
  return `import { readFileSync, existsSync, mkdirSync, writeFileSync, unlinkSync } from 'node:fs';
102
132
  import { spawnSync } from 'node:child_process';
103
133
  import { createHash, randomUUID } from 'node:crypto';
@@ -169,6 +199,15 @@ export function inferSessionId(event) {
169
199
  return \`codex:\${threadId}:\${turnId}\`;
170
200
  }
171
201
 
202
+ export function inferHiveThreadId(event = {}, sessionId = '') {
203
+ const threadId =
204
+ extractFirst(event, ['thread_id', 'threadId', 'conversation_id', 'conversationId']) ||
205
+ extractFirst(event?.metadata, ['thread_id', 'threadId', 'conversation_id', 'conversationId']);
206
+ if (threadId) return \`codex:\${threadId}\`;
207
+ const raw = sessionId || 'codex';
208
+ return \`codex:\${createHash('sha256').update(raw).digest('hex').slice(0, 16)}\`;
209
+ }
210
+
172
211
  export function ensureTraceId(state = {}) {
173
212
  return typeof state.traceId === 'string' && state.traceId ? state.traceId : \`trace_\${randomUUID()}\`;
174
213
  }
@@ -276,7 +315,41 @@ export async function runtimePost(route, body = {}) {
276
315
  return response.json();
277
316
  }
278
317
 
318
+ export async function runtimeGet(route) {
319
+ const token = readToken();
320
+ const headers = {};
321
+ if (token) headers.Authorization = \`Bearer \${token}\`;
322
+ const response = await fetch(\`\${DEFAULT_RUNTIME_URL}\${route}\`, {
323
+ method: 'GET',
324
+ headers,
325
+ });
326
+ if (!response.ok) {
327
+ const detail = await response.text().catch(() => response.statusText);
328
+ throw new Error(\`runtime \${route} failed (\${response.status}): \${detail}\`);
329
+ }
330
+ return response.json();
331
+ }
332
+
333
+ export function remoteCoachEnabled(env = process.env) {
334
+ return /^(?:1|true|yes|on)$/i.test(String(
335
+ env.ARIA_REMOTE_COACH_ENABLED ||
336
+ env.ARIA_RUNTIME_COACH_ENABLED ||
337
+ env.ARIA_COACH_REMOTE_ENABLED ||
338
+ ''
339
+ ));
340
+ }
341
+
279
342
  export async function recordCoachPhase(phase, body = {}) {
343
+ if (!remoteCoachEnabled()) {
344
+ return {
345
+ ok: true,
346
+ skipped: true,
347
+ permitted: true,
348
+ decision: 'allow',
349
+ phase,
350
+ reasons: ['remote_coach_disabled'],
351
+ };
352
+ }
280
353
  try {
281
354
  return await runtimePost('/coach/phase', {
282
355
  phase,
@@ -294,17 +367,82 @@ export async function recordCoachPhase(phase, body = {}) {
294
367
  }
295
368
  }
296
369
 
370
+ export async function ensurePreTurnMizanReceipt({ sessionId, traceId, state = {}, event = {}, action = '', target = '' } = {}) {
371
+ if (state?.preReceiptId) {
372
+ return { ok: true, state, healed: false };
373
+ }
374
+ const message = String(state?.userText || target || 'codex tool request').slice(0, 4000);
375
+ const packet = await getHarnessClient().getHarnessPacket({
376
+ sessionId,
377
+ platform: 'codex',
378
+ message,
379
+ });
380
+ const packetRef = makeEvidenceRef('harness_packet', packet, { sessionId, platform: 'codex', source: 'pre_tool_receipt_heal' });
381
+ const result = await runtimePost('/mizan/pre', {
382
+ sessionId,
383
+ packet,
384
+ packetRequest: {
385
+ sessionId,
386
+ platform: 'codex',
387
+ message,
388
+ stage: 'codex-pre-tool-receipt-heal',
389
+ actor: 'codex-hook',
390
+ system: 'codex-hook',
391
+ },
392
+ context: {
393
+ sessionId,
394
+ traceId,
395
+ surface: 'codex-hooks',
396
+ platform: 'codex',
397
+ userText: state?.userText || '',
398
+ action,
399
+ target,
400
+ event,
401
+ evidenceRefs: [packetRef],
402
+ },
403
+ });
404
+ const nextState = saveTurnState(sessionId, {
405
+ ...state,
406
+ traceId,
407
+ preReceiptId: result?.receipt?.receiptId || null,
408
+ packetTimestamp: packet?.timestamp || null,
409
+ packetRef,
410
+ preReceiptHealed: true,
411
+ preReceiptHealedAt: new Date().toISOString(),
412
+ lastEvent: 'PreToolUse',
413
+ });
414
+ return {
415
+ ok: Boolean(result?.receipt?.receiptId),
416
+ state: nextState,
417
+ healed: true,
418
+ receipt: result?.receipt || null,
419
+ };
420
+ }
421
+
297
422
  export function classifyAction(event) {
298
423
  const toolName = String(event?.tool_name || event?.toolName || '').trim();
299
- const toolCommand = String(
300
- event?.tool_input?.command ??
301
- event?.toolInput?.command ??
302
- ''
303
- ).trim();
304
- const haystack = \`\${toolName}\\n\${toolCommand}\\n\${JSON.stringify(event)}\`;
305
- if (/deploy|kubectl|docker\\s+push/i.test(haystack)) return 'deploy';
306
- if (/\\brm\\b|delete|unlink|drop\\s+table/i.test(haystack)) return 'delete';
307
- if (/build|test|tsc|jest|vitest|npm run|pnpm|yarn/i.test(haystack)) return 'build';
424
+ const toolInput = event?.tool_input || event?.toolInput || {};
425
+ const toolCommand = String(toolInput?.command ?? '').trim();
426
+ const lowerTool = toolName.toLowerCase();
427
+
428
+ if (/^(?:read|grep|glob|list_mcp_resources|list_mcp_resource_templates)$/i.test(toolName)) return 'read';
429
+ if (lowerTool.includes('apply_patch')) {
430
+ return /^\\*\\*\\* Begin Patch[\\s\\S]*^\\*\\*\\* Delete File:/m.test(toolCommand) ? 'delete' : 'write';
431
+ }
432
+ if (/^(?:edit|write|notebookedit)$/i.test(toolName) || toolInput?.file_path || toolInput?.notebook_path) {
433
+ return 'write';
434
+ }
435
+ if (/delete|destroy|drop|wipe|purge/i.test(toolName)) return 'delete';
436
+ if (/deploy|rollout|release/i.test(toolName)) return 'deploy';
437
+ if (/build|compile|test/i.test(toolName)) return 'build';
438
+ if (!toolCommand) return 'write';
439
+
440
+ if (/^(?:ls|cat|head|tail|grep|rg|sed\\s+-n|wc|find|tree|stat|file|ps|pgrep|du|df|env|printenv|date|pwd|which|type|whoami|id)\\b/.test(toolCommand)) return 'read';
441
+ if (/^git\\s+(?:status|log|diff|show|branch|remote|rev-parse|ls-tree|ls-files|stash\\s+list)\\b/.test(toolCommand)) return 'read';
442
+ if (/^(?:kubectl\\s+(?:get|describe|logs|top|version|api-resources)\\b|docker\\s+ps\\b)/.test(toolCommand)) return 'read';
443
+ if (/\\b(?:scripts\\/deploy-|kubectl\\s+(?:apply|set\\s+image|delete|patch|rollout|scale|drain|cordon)\\b|docker\\s+push\\b|helm\\s+(?:upgrade|install|rollback)\\b)/i.test(toolCommand)) return 'deploy';
444
+ if (/^(?:rm|rmdir|unlink|truncate)\\b|drop\\s+table|git\\s+(?:reset|clean)\\b/i.test(toolCommand)) return 'delete';
445
+ if (/\\b(?:npm|pnpm|yarn)\\s+(?:run\\s+)?(?:build|test|check|lint|typecheck)\\b|\\b(?:tsc|jest|vitest|eslint)\\b/i.test(toolCommand)) return 'build';
308
446
  return 'write';
309
447
  }
310
448
 
@@ -315,6 +453,104 @@ export function summarizeTarget(event) {
315
453
  }).slice(0, 4000);
316
454
  }
317
455
 
456
+ function normalizeTouchedPath(value) {
457
+ const raw = String(value || '').trim();
458
+ if (!raw) return '';
459
+ return raw.replace(/\\\\/g, '/').replace(/\\/+/, '/');
460
+ }
461
+
462
+ function pushTouchedFile(files, value, intent = 'touch') {
463
+ const pathValue = normalizeTouchedPath(value);
464
+ if (!pathValue) return;
465
+ if (!files.some((file) => file.path === pathValue && file.intent === intent)) {
466
+ files.push({ path: pathValue, intent });
467
+ }
468
+ }
469
+
470
+ export function extractToolTouchedFiles(event, action = '') {
471
+ const files = [];
472
+ const toolName = String(event?.tool_name || event?.toolName || '').trim();
473
+ const toolInput = event?.tool_input || event?.toolInput || {};
474
+ const intent = action || classifyAction(event);
475
+ pushTouchedFile(files, toolInput?.file_path, intent);
476
+ pushTouchedFile(files, toolInput?.filePath, intent);
477
+ pushTouchedFile(files, toolInput?.path, intent);
478
+ pushTouchedFile(files, toolInput?.notebook_path, intent);
479
+ pushTouchedFile(files, toolInput?.notebookPath, intent);
480
+ if (Array.isArray(toolInput?.files)) toolInput.files.forEach((file) => pushTouchedFile(files, file, intent));
481
+ if (Array.isArray(toolInput?.targetFiles)) toolInput.targetFiles.forEach((file) => pushTouchedFile(files, file, intent));
482
+ const command = String(toolInput?.command || '');
483
+ if (/apply_patch/i.test(toolName) || /^\\*\\*\\* Begin Patch/m.test(command)) {
484
+ for (const match of command.matchAll(/^\\*\\*\\* (?:Update|Add|Delete) File: (.+)$/gm)) {
485
+ pushTouchedFile(files, match[1], intent);
486
+ }
487
+ }
488
+ return files.slice(0, 200);
489
+ }
490
+
491
+ export async function recordHiveFileTouch({ sessionId, threadId = null, event = 'tool_request', files = [], source = 'codex-hook', body = {} } = {}) {
492
+ if (!sessionId || !Array.isArray(files) || files.length === 0) {
493
+ return { ok: true, skipped: true, reason: 'no files to record' };
494
+ }
495
+ try {
496
+ return await runtimePost('/api/hive/file-touch', {
497
+ session_id: sessionId,
498
+ thread_id: threadId,
499
+ event,
500
+ files,
501
+ source,
502
+ body: {
503
+ cwd: process.cwd(),
504
+ ...body,
505
+ },
506
+ });
507
+ } catch (error) {
508
+ return {
509
+ ok: false,
510
+ skipped: false,
511
+ error: error instanceof Error ? error.message : String(error),
512
+ };
513
+ }
514
+ }
515
+
516
+ export async function recordHiveSessionLifecycle({
517
+ sessionId,
518
+ threadId = null,
519
+ event = 'heartbeat',
520
+ status = null,
521
+ intentSummary = null,
522
+ sourceArtifact = null,
523
+ fileClaims = [],
524
+ doNotTouch = [],
525
+ source = 'codex-hook',
526
+ body = {},
527
+ } = {}) {
528
+ if (!sessionId) return { ok: true, skipped: true, reason: 'no session_id to record' };
529
+ try {
530
+ return await runtimePost('/api/hive/session-lifecycle', {
531
+ session_id: sessionId,
532
+ thread_id: threadId,
533
+ event,
534
+ status: status || event,
535
+ intent_summary: intentSummary || \`\${source} \${event}\`,
536
+ source_artifact: sourceArtifact,
537
+ file_claims: Array.isArray(fileClaims) ? fileClaims : [],
538
+ do_not_touch: Array.isArray(doNotTouch) ? doNotTouch : [],
539
+ body: {
540
+ cwd: process.cwd(),
541
+ source,
542
+ ...body,
543
+ },
544
+ });
545
+ } catch (error) {
546
+ return {
547
+ ok: false,
548
+ skipped: false,
549
+ error: error instanceof Error ? error.message : String(error),
550
+ };
551
+ }
552
+ }
553
+
318
554
  export function extractUserText(event) {
319
555
  return extractText(
320
556
  event?.input ??
@@ -337,11 +573,495 @@ export function extractAssistantText(event) {
337
573
  );
338
574
  }
339
575
 
576
+ export const ARIA_ALWAYS_ON_SKILLS = Object.freeze([
577
+ 'aria-axioms-first-principles',
578
+ 'aria-cognition-autofire',
579
+ 'aria-first-class-operating-contract',
580
+ 'aria-cognition-batch',
581
+ 'aria-forge-guardrails',
582
+ 'aria-harness-no-stripping',
583
+ 'aria-harness-output-discipline',
584
+ 'aria-quality-audit',
585
+ 'aria-readable-output',
586
+ 'aria-senior-code-audit',
587
+ 'ghazali-8lens',
588
+ 'mizan',
589
+ 'never-guess',
590
+ 'predictor',
591
+ 'qiyas-analogy',
592
+ 'tadabbur',
593
+ 'aria-repo-doctrine',
594
+ 'aria-senior-code-cookbook',
595
+ 'aria-http-harness-client',
596
+ 'aria-task-codex-executor',
597
+ 'aria-decision-mizan',
598
+ 'tadabbur-ops',
599
+ 'aria-repo-audit',
600
+ 'aria-backend-architect',
601
+ 'aria-live-ops',
602
+ 'aria-memory-index',
603
+ 'aria-ops',
604
+ ]);
605
+
606
+ export const ARIA_QIYAS_15_PERSPECTIVES = Object.freeze([
607
+ 'Owner-Hamza-tomorrow',
608
+ 'operator-client',
609
+ 'investor',
610
+ 'LLM-consumer',
611
+ 'human-end-user',
612
+ 'skeptic',
613
+ 'compliance',
614
+ 'engineering-quality',
615
+ 'cognitive-load',
616
+ 'scale',
617
+ 'Islamic-scholar',
618
+ 'clinical-scholar',
619
+ 'red-team-attacker',
620
+ '1-week-future-self',
621
+ '1-year-future-self',
622
+ ]);
623
+
624
+ export const ARIA_TADABBUR_12_STAGES = Object.freeze([
625
+ 'EMBED',
626
+ 'EXCAVATE',
627
+ 'ROOT TRACE',
628
+ 'MULTI-LENS',
629
+ 'PATTERN',
630
+ 'CONSEQUENCE',
631
+ 'DWELLING',
632
+ 'COLLAPSE',
633
+ 'PRINCIPLE',
634
+ 'INVERSION',
635
+ 'PERSONAL',
636
+ 'VOICE',
637
+ ]);
638
+
639
+ export const ARIA_QA_AUTOFIRE_CYCLE = Object.freeze([
640
+ 'qiyas_15_pass',
641
+ 'tadabbur_full_canonical_12_stage',
642
+ 'correct',
643
+ 'enhance',
644
+ 'harden',
645
+ 'verify',
646
+ ]);
647
+
648
+ export const ARIA_QA_METHOD_CONTRACT = Object.freeze({
649
+ qiyas: 'Qiyas means full Qiyas-15 only. Mini Qiyas is not acceptable for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
650
+ tadabbur: 'Tadabbur means the full canonical 12-stage Tadabbur path for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
651
+ });
652
+
653
+ export const UNIVERSAL_CONNECTOR_ACTUAL_GOAL =
654
+ 'Wire extracted books, doctrines, skills, runtimes, primitives, mappings, CLIs, connectors, hooks, sidecars, and agent surfaces into the operating system so agent output improves automatically.';
655
+
656
+ export const UNIVERSAL_CONNECTOR_HIGH_IMPACT_SKILLS = Object.freeze([
657
+ 'ghazali-tauba-kca-repair-contract',
658
+ 'ghazali-rights-before-balance-settlement',
659
+ 'ghazali-delay-is-risk-auditor',
660
+ 'ghazali-knowledge-condition-action-patience-bridge',
661
+ 'ghazali-cause-means-tawakkal-mizan',
662
+ 'ghazali-ultimate-cause-chain-tracer',
663
+ 'ghazali-necessity-vs-attachment-mizan',
664
+ 'ghazali-attachment-not-possession-auditor',
665
+ 'ghazali-acquaintance-before-love-diagnoser',
666
+ 'ghazali-love-cup-attachment-displacement-auditor',
667
+ 'ghazali-knowledge-will-strength-action-chain',
668
+ 'ghazali-means-do-not-cleanse-end-gate',
669
+ 'ghazali-six-register-truthfulness-audit',
670
+ 'ghazali-breath-capital-day-contract',
671
+ 'ghazali-two-premise-action-transduction',
672
+ 'ghazali-four-object-thought-ledger',
673
+ 'ghazali-one-vice-one-replacement-register',
674
+ 'ghazali-bounded-sign-observation',
675
+ 'ghazali-three-question-intention-gate',
676
+ 'ghazali-principal-profit-loss-muhasabah',
677
+ 'ghazali-self-rebuke-false-narrative-interrogator',
678
+ 'ghazali-death-remembrance-deception-breaker',
679
+ 'ghazali-condition-specific-hope-fear-medicine',
680
+ 'ghazali-fear-action-not-paralysis-gate',
681
+ 'ghazali-hope-requires-cultivation-auditor',
682
+ ]);
683
+
684
+ export const UNIVERSAL_CONNECTOR_REQUIRED_RUNTIMES = Object.freeze([
685
+ 'tafakkur-transduction-runtime',
686
+ 'six-stage-self-accounting-runtime',
687
+ 'mortality-accounting-runtime',
688
+ 'fear-hope-condition-regulation-runtime',
689
+ 'intention-to-action-integrity-runtime',
690
+ 'love-fruit-contentment-runtime',
691
+ 'patience-gratitude-purpose-mizan-runtime',
692
+ 'tauba-rights-repair-runtime',
693
+ 'tawakkal-cause-mizan-runtime',
694
+ 'zuhd-necessity-attachment-runtime',
695
+ ]);
696
+
697
+ function includesAny(text = '', terms = []) {
698
+ const source = String(text || '').toLowerCase();
699
+ return terms.some((term) => source.includes(String(term).toLowerCase()));
700
+ }
701
+
702
+ function countIncluded(text = '', terms = []) {
703
+ const source = String(text || '').toLowerCase();
704
+ return terms.reduce((count, term) => count + (source.includes(String(term).toLowerCase()) ? 1 : 0), 0);
705
+ }
706
+
707
+ function continuationRequested(text = '') {
708
+ return includesAny(text, [
709
+ 'continue',
710
+ 'next phase',
711
+ 'next step',
712
+ 'next best',
713
+ 'fire',
714
+ 'skills',
715
+ 'production',
716
+ 'ready',
717
+ 'what is left',
718
+ "what's left",
719
+ 'how far',
720
+ 'qa',
721
+ 'ledger',
722
+ 'autofire',
723
+ 'wire',
724
+ ]);
725
+ }
726
+
727
+ function actualGoalHits(text = '') {
728
+ return countIncluded(text, [
729
+ 'wire extracted',
730
+ 'books',
731
+ 'doctrines',
732
+ 'skills',
733
+ 'runtimes',
734
+ 'primitives',
735
+ 'mappings',
736
+ 'connectors',
737
+ 'hooks',
738
+ 'sidecars',
739
+ 'agent surfaces',
740
+ 'output improves automatically',
741
+ 'corpus',
742
+ 'forced-selection',
743
+ 'actual goal',
744
+ ]);
745
+ }
746
+
747
+ function supportMechanismHits(text = '') {
748
+ return countIncluded(text, ['receipt', 'gate', 'ledger', 'canary', 'drift check', 'phase ']);
749
+ }
750
+
751
+ export function buildUniversalConnectorGoalContract({ userText = '', phase = 'turn' } = {}) {
752
+ return {
753
+ id: 'universal-connector-corpus-runtime-goal-contract',
754
+ phase,
755
+ actualGoal: UNIVERSAL_CONNECTOR_ACTUAL_GOAL,
756
+ supportRule: 'Receipts, gates, ledgers, and canaries are support evidence only; they pass when they prove corpus-backed behavior changed action, QA, correction, verification, or learning.',
757
+ hardStopOnlyFor: ['secrets', 'destructive actions', 'deploy/publication boundary', 'owner-contradicted action', 'proven false completion risk'],
758
+ qaPacket: {
759
+ qiyas: 'Qiyas-15 over owner trust, operator value, engineering quality, cognitive load, scale, compliance, red-team, one-week future, and one-year future.',
760
+ tadabbur: 'Full consequence trace from current action to production behavior; reject motion that only improves receipts.',
761
+ mizan: 'Balance evidence, owner impact, throughput, and false-completion risk; repair low-risk misses before hard-blocking.',
762
+ ghazali8: 'Nur observed substrate, Mizan proportion, Hikma doctrine, Tafakkur structure, Tadabbur consequence, Ilham sensed drift, Wahi owner/corpus anchor, Firasah owner need.',
763
+ fitrah: 'Truth over deception, no harm, sacred trust, power obligates service, reflection before action.',
764
+ },
765
+ selectedSkills: [...UNIVERSAL_CONNECTOR_HIGH_IMPACT_SKILLS],
766
+ selectedRuntimes: [...UNIVERSAL_CONNECTOR_REQUIRED_RUNTIMES],
767
+ nextHighestImpactAction: 'Promote the sandbox corpus registry consumer into the real connector/hook forced-selection path, then run behavioral QA on actual Claude/Codex/OpenCode continuation prompts.',
768
+ continuation: continuationRequested(userText),
769
+ };
770
+ }
771
+
772
+ export function evaluateGoalContractOutput(text = '', { userText = '', goalContract = null } = {}) {
773
+ const source = String(text || '');
774
+ const contract = goalContract || buildUniversalConnectorGoalContract({ userText, phase: 'stop' });
775
+ const continuation = contract.continuation || continuationRequested(userText) || actualGoalHits(userText) > 0;
776
+ const blockers = [];
777
+ const warnings = [];
778
+ const repairs = [];
779
+ if (!continuation) return { pass: true, hardBlock: false, score: 1, blockers, warnings, repairs, contract };
780
+ const goalHits = actualGoalHits(source);
781
+ const supportHits = supportMechanismHits(source);
782
+ const hasEvidence = includesAny(source, ['verified', 'observed', 'evidence', 'smoke', 'test', 'audit', 'not production-ready', 'integration-ready', 'blocked', 'pending', 'unverified']);
783
+ const hasNextAction = includesAny(source, ['next highest', 'next best', 'next action', 'next step', 'continue by', 'promote the sandbox corpus', 'wire the registry', 'forced-selection']);
784
+ const hasQa = includesAny(source, ['qa', 'qiyas', 'tadabbur', 'mizan', 'ghazali', 'correct', 'enhance', 'harden', 'repair']);
785
+ if (goalHits === 0) {
786
+ warnings.push('goal-contract: output does not bind the turn to corpus-to-runtime wiring or automatic output improvement');
787
+ repairs.push('Name the actual goal or make the current action directly advance corpus registry, runtime, hook, connector, surface, or forced-selection wiring.');
788
+ }
789
+ if (!hasNextAction) {
790
+ warnings.push('goal-contract: continuation output does not name the next highest-impact action');
791
+ repairs.push('Add a concrete next action that advances real wiring or behavioral QA.');
792
+ }
793
+ if (!hasQa) {
794
+ warnings.push('goal-contract: QA/correction loop is missing from the visible state');
795
+ repairs.push('Add expected-vs-observed QA with correction, enhancement, hardening, or an explicit pass boundary.');
796
+ }
797
+ if (!hasEvidence) {
798
+ warnings.push('goal-contract: evidence boundary is missing');
799
+ repairs.push('State verified, blocked, pending, unverified, or the exact evidence class used before making status claims.');
800
+ }
801
+ if (supportHits >= 3 && supportHits > goalHits + 1) {
802
+ warnings.push('goal-contract: support mechanisms dominate the answer over the actual product goal');
803
+ repairs.push('Reframe receipts, gates, ledgers, and canaries as evidence only, then return to corpus-to-runtime wiring and output improvement.');
804
+ }
805
+ if (/\\bwhat would you like me to do next\\b|\\bhow would you like me to proceed\\b/i.test(source)) {
806
+ blockers.push('goal-contract: output asks the owner to choose the obvious continuation instead of naming the next highest-impact step');
807
+ }
808
+ if (/\\b(?:production ready|ready for production|release ready|promotion pass|complete|completed|done|verified|fixed)\\b/i.test(source) && !/\\b(?:not production-ready|not production ready|integration-ready|pending|blocked|unverified|bounded|evidence)\\b/i.test(source)) {
809
+ blockers.push('goal-contract: false completion or readiness claim without bounded evidence');
810
+ }
811
+ if (/\\b(?:\\/consult|consult api|consult response)\\b/i.test(source) && /\\b(?:quality source|core quality|dependency|required)\\b/i.test(source)) {
812
+ blockers.push('goal-contract: consult API is being treated as the core quality engine');
813
+ }
814
+ const score = [goalHits > 0, hasNextAction, hasQa, hasEvidence, !(supportHits >= 3 && supportHits > goalHits + 1), blockers.length === 0].filter(Boolean).length / 6;
815
+ return {
816
+ pass: blockers.length === 0 && score >= 0.67,
817
+ hardBlock: blockers.length > 0,
818
+ score,
819
+ blockers: [...new Set(blockers)],
820
+ warnings: [...new Set(warnings)],
821
+ repairs: [...new Set(repairs)],
822
+ nextHighestImpactAction: contract.nextHighestImpactAction,
823
+ selectedSkills: contract.selectedSkills,
824
+ selectedRuntimes: contract.selectedRuntimes,
825
+ contract,
826
+ };
827
+ }
828
+
829
+ export function inferRequiredAriaSkills(text = '') {
830
+ const raw = String(text || '');
831
+ const lower = raw.toLowerCase();
832
+ const required = new Set(ARIA_ALWAYS_ON_SKILLS);
833
+ const add = (skill) => required.add(skill);
834
+ const mentions = (skill) => new RegExp('(?:^|[^a-z0-9_-])\\\\$?' + skill.replace(/[.*+?^\${}()|[\\]\\\\]/g, '\\\\$&') + '(?:$|[^a-z0-9_-])', 'i').test(raw);
835
+
836
+ for (const skill of [
837
+ 'aria-axioms-first-principles',
838
+ 'aria-cognition-autofire',
839
+ 'aria-first-class-operating-contract',
840
+ 'aria-cognition-batch',
841
+ 'aria-readable-output',
842
+ 'tadabbur',
843
+ 'qiyas-analogy',
844
+ ]) {
845
+ if (mentions(skill)) add(skill);
846
+ }
847
+
848
+ if (/\\b(?:aria|harness|garden|claude code|codex|opencode|skill|skills|hook|hooks|runtime|connector|sdk|gate|quality|qa|audit|completion claim)\\b/i.test(raw)) {
849
+ add('aria-cognition-autofire');
850
+ add('aria-readable-output');
851
+ }
852
+ if (/\\b(?:first class|first-class|world class|world-class|revolutionary upgrade|full upgrade|substrate os|not just a watcher|serious upgrade)\\b/i.test(raw)) {
853
+ add('aria-first-class-operating-contract');
854
+ }
855
+ if (/\\b(?:axiom|axioms|first principles?|fitrah|source trust|evidence threshold)\\b/i.test(raw)) {
856
+ add('aria-axioms-first-principles');
857
+ }
858
+ if (/\\b(?:full cognition|batch cognition|28\\+15|mizan plus tadabbur|rich cognitives|cognitive batch)\\b/i.test(raw)) {
859
+ add('aria-cognition-batch');
860
+ }
861
+ if (/\\b(?:tadabbur|taddabur|12-stage|heart filter|consequence reasoning|cookbook|deep reflection)\\b/i.test(lower)) {
862
+ add('tadabbur');
863
+ }
864
+ if (/\\b(?:qiyas|analogy|analogical|qiyas-15|structural analogy|asl|hukm|illah|furuq)\\b/i.test(lower)) {
865
+ add('qiyas-analogy');
866
+ }
867
+ if (/\\b(?:fire named skills|fire skills|use aria skills|named skills)\\b/i.test(lower)) {
868
+ add('aria-axioms-first-principles');
869
+ add('aria-cognition-autofire');
870
+ add('aria-cognition-batch');
871
+ add('aria-readable-output');
872
+ add('tadabbur');
873
+ add('qiyas-analogy');
874
+ }
875
+ if (/\\b(?:readable output|readability|owner surface|owner-facing|scannable|stop gate|closeout|final answer)\\b/i.test(lower)) {
876
+ add('aria-readable-output');
877
+ }
878
+ if (/\\b(?:backend|api|server|database|auth|queue|worker|service)\\b/i.test(lower)) {
879
+ add('aria-backend-architect');
880
+ }
881
+ if (/\\b(?:frontend|ui|ux|component|page|screen|css|layout)\\b/i.test(lower)) {
882
+ add('aria-frontend-architect');
883
+ }
884
+ if (/\\b(?:fullstack|end-to-end|e2e|web app|application)\\b/i.test(lower)) {
885
+ add('aria-fullstack-orchestrator');
886
+ }
887
+ if (/\\b(?:deploy|k8s|kubernetes|kubectl|cluster|infra|infrastructure|rollout)\\b/i.test(lower)) {
888
+ add('aria-live-ops');
889
+ add('aria-k8s-deploy');
890
+ }
891
+ if (/\\b(?:repo audit|repository audit|codebase audit|refactor|review)\\b/i.test(lower)) {
892
+ add('aria-repo-audit');
893
+ }
894
+ if (/\\b(?:research|diligence|sources|market|competitor|public sources)\\b/i.test(lower)) {
895
+ add('aria-research-orchestrator');
896
+ }
897
+ if (/\\b(?:business|pricing|gtm|go-to-market|revenue|retention|launch)\\b/i.test(lower)) {
898
+ add('aria-business-frame');
899
+ add('aria-gtm-architect');
900
+ }
901
+ if (required.size > 0 && /\\b(?:aria|harness|codex|claude|hook|gate|runtime|skill|cognition|coach)\\b/i.test(raw)) {
902
+ add('aria-readable-output');
903
+ }
904
+
905
+ return [...required].sort();
906
+ }
907
+
908
+ export function summarizeForcedSkillLoad(promptBuild = null) {
909
+ if (!promptBuild || typeof promptBuild !== 'object') return null;
910
+ const loadedCookbooks = Array.isArray(promptBuild.loadedCookbooks) ? promptBuild.loadedCookbooks : [];
911
+ const missingCookbooks = Array.isArray(promptBuild.missingCookbooks) ? promptBuild.missingCookbooks : [];
912
+ const receipt = promptBuild.skillExecutionReceipt && typeof promptBuild.skillExecutionReceipt === 'object'
913
+ ? promptBuild.skillExecutionReceipt
914
+ : null;
915
+ const substrateKernelExecution = receipt?.substrateKernelExecution && typeof receipt.substrateKernelExecution === 'object'
916
+ ? receipt.substrateKernelExecution
917
+ : null;
918
+ const executedSkillIds = Array.isArray(receipt?.executedSkillIds)
919
+ ? receipt.executedSkillIds
920
+ : Array.isArray(substrateKernelExecution?.executedSkillIds)
921
+ ? substrateKernelExecution.executedSkillIds
922
+ : [];
923
+ const executedOperatorIds = Array.isArray(receipt?.executedOperatorIds)
924
+ ? receipt.executedOperatorIds
925
+ : Array.isArray(substrateKernelExecution?.executedOperatorIds)
926
+ ? substrateKernelExecution.executedOperatorIds
927
+ : [];
928
+ return {
929
+ ok: promptBuild.ok === true,
930
+ requiredSkillIds: Array.isArray(promptBuild.requiredSkillIds) ? promptBuild.requiredSkillIds : [],
931
+ loadedSkillIds: Array.isArray(promptBuild.loadedSkillIds) ? promptBuild.loadedSkillIds : [],
932
+ missingSkillIds: Array.isArray(promptBuild.missingSkillIds) ? promptBuild.missingSkillIds : [],
933
+ loadedSkillHashes: Array.isArray(promptBuild.loadedSkillHashes) ? promptBuild.loadedSkillHashes : [],
934
+ loadedCookbooks: loadedCookbooks.map((entry) => ({
935
+ skillId: entry.skillId || null,
936
+ requestedBy: entry.requestedBy || null,
937
+ cookbookName: entry.cookbookName || null,
938
+ path: entry.path || null,
939
+ hash: entry.hash || null,
940
+ chars: entry.chars || null,
941
+ })),
942
+ missingCookbooks: missingCookbooks.map((entry) => ({
943
+ skillId: entry.skillId || null,
944
+ requestedBy: entry.requestedBy || null,
945
+ cookbookName: entry.cookbookName || null,
946
+ path: entry.path || null,
947
+ })),
948
+ skillExecutionMode: typeof promptBuild.skillExecutionMode === 'string' ? promptBuild.skillExecutionMode : null,
949
+ skillExecutionReceipt: receipt
950
+ ? {
951
+ ok: receipt.ok === true,
952
+ mode: receipt.mode || null,
953
+ firedSkillIds: executedSkillIds.length
954
+ ? executedSkillIds
955
+ : Array.isArray(receipt.firedSkillIds) ? receipt.firedSkillIds : [],
956
+ executedSkillIds,
957
+ executedOperatorCount: executedOperatorIds.length,
958
+ substrateKernelExecution: substrateKernelExecution
959
+ ? {
960
+ ok: substrateKernelExecution.ok === true,
961
+ mode: substrateKernelExecution.mode || null,
962
+ executedOperatorIdsHash: substrateKernelExecution.executedOperatorIdsHash || null,
963
+ executionHash: substrateKernelExecution.executionHash || null,
964
+ }
965
+ : null,
966
+ receiptHash: receipt.receiptHash || null,
967
+ }
968
+ : null,
969
+ promptSha256: promptBuild.prompt ? createHash('sha256').update(String(promptBuild.prompt)).digest('hex') : null,
970
+ promptChars: promptBuild.prompt ? String(promptBuild.prompt).length : 0,
971
+ };
972
+ }
973
+
974
+ export function forcedSkillLoadGaps(state = {}) {
975
+ const summary = state?.forcedSkillLoad || null;
976
+ const required = Array.isArray(state?.requiredSkills) ? state.requiredSkills : [];
977
+ if (required.length === 0) return [];
978
+ if (!summary) return ['forced runtime skill/cookbook context was not built'];
979
+ const gaps = [];
980
+ if (Array.isArray(summary.missingSkillIds) && summary.missingSkillIds.length > 0) {
981
+ gaps.push('missing skill ids: ' + summary.missingSkillIds.join(', '));
982
+ }
983
+ if (Array.isArray(summary.missingCookbooks) && summary.missingCookbooks.length > 0) {
984
+ gaps.push('missing cookbooks: ' + summary.missingCookbooks.map((entry) => entry.path || entry.cookbookName).join(', '));
985
+ }
986
+ if (summary.skillExecutionMode === 'mechanical-receipt') {
987
+ const receipt = summary.skillExecutionReceipt || {};
988
+ const fired = Array.isArray(receipt.executedSkillIds) && receipt.executedSkillIds.length
989
+ ? receipt.executedSkillIds
990
+ : Array.isArray(receipt.firedSkillIds) ? receipt.firedSkillIds : [];
991
+ const missingFired = required.filter((skill) => !fired.includes(skill));
992
+ if (receipt.ok !== true) gaps.push('mechanical skill execution receipt did not pass');
993
+ if (receipt.substrateKernelExecution?.ok !== true) gaps.push('substrate kernel execution receipt did not pass');
994
+ if (missingFired.length > 0) gaps.push('mechanical receipt missing fired skill ids: ' + missingFired.join(', '));
995
+ if (summary.promptChars > 75000) gaps.push('mechanical receipt prompt exceeds compact prompt budget');
996
+ }
997
+ if (required.includes('tadabbur')) {
998
+ const cookbookNames = new Set((summary.loadedCookbooks || []).map((entry) => entry.cookbookName).filter(Boolean));
999
+ if (!cookbookNames.has('tadabbur-cookbook.md')) gaps.push('tadabbur required but tadabbur-cookbook.md was not loaded');
1000
+ }
1001
+ return gaps;
1002
+ }
1003
+
1004
+ export function requiresFullAriaCognition(userText = '', requiredSkills = []) {
1005
+ const text = String(userText || '');
1006
+ if (/\b(?:social|casual|small talk|quick reply)\b/i.test(text)) return false;
1007
+ if (/\b(?:qiyas|tadabbur|taddabur|full cognition|architecture|runtime|code|coding|repo|hook|hooks|sdk|worker|workers|queue|ledger|qa|quality|audit|harness|connector|gate|skills?|cookbooks?|daemon|telemetry)\b/i.test(text)) {
1008
+ return true;
1009
+ }
1010
+ return requiredSkills.includes('qiyas-analogy') || requiredSkills.includes('tadabbur');
1011
+ }
1012
+
1013
+ function ownerVisibleText(text = '') {
1014
+ return String(text || '')
1015
+ .replace(new RegExp('<!--[\\\\s\\\\S]*?-->', 'g'), '')
1016
+ .replace(new RegExp('<details\\\\b[\\\\s\\\\S]*?</details>', 'gi'), '')
1017
+ .replace(new RegExp('<gate\\\\b[\\\\s\\\\S]*?</gate>', 'gi'), '')
1018
+ .replace(new RegExp('<cognition\\\\b[\\\\s\\\\S]*?</cognition>', 'gi'), '')
1019
+ .replace(new RegExp('<applied_cognition\\\\b[\\\\s\\\\S]*?</applied_cognition>', 'gi'), '');
1020
+ }
1021
+
1022
+ export function fullCognitionMethodGaps({ state = {}, text = '' } = {}) {
1023
+ const required = Array.isArray(state?.requiredSkills) ? state.requiredSkills : [];
1024
+ const userText = state?.userText || '';
1025
+ if (!requiresFullAriaCognition(userText, required)) return [];
1026
+ const visible = ownerVisibleText(text);
1027
+ const gaps = [];
1028
+ const qiyasLabel = new RegExp('(^|\\\\n)\\\\s*qiyas_15_pass\\\\s*:', 'i');
1029
+ const tadabburLabel = new RegExp('(^|\\\\n)\\\\s*tadabbur_full_canonical_12_stage\\\\s*:', 'i');
1030
+ const tadabburStages = new RegExp('\\\\b(?:EMBED|EXCAVATE|ROOT TRACE|INTENT TRACE|CONTRACT TRACE|CONSEQUENCE|COLLAPSE|SEPARATE|VERIFY|RECORD|DECIDE|ACT)\\\\b', 'g');
1031
+ if (qiyasLabel.test(visible) || (visible.match(/Owner-Hamza-(?:now|tomorrow|future)|Repo integrity|Deploy integrity|Scope discipline/g) || []).length >= 4) {
1032
+ gaps.push('raw Qiyas method dump is on the owner surface; collapse it into the decision and keep method evidence off the visible answer');
1033
+ }
1034
+ if (tadabburLabel.test(visible) || (visible.match(tadabburStages) || []).length >= 4) {
1035
+ gaps.push('raw Tadabbur stage dump is on the owner surface; collapse it into consequence-aware guidance and keep method evidence off the visible answer');
1036
+ }
1037
+ // Method coverage is proven by runtime skill-load state, not by forcing
1038
+ // every Qiyas/Tadabbur label into the owner-visible answer.
1039
+ if (new RegExp('<applied_cognition\\\\b', 'i').test(visible) || new RegExp('</applied_cognition>', 'i').test(visible)) {
1040
+ gaps.push('raw applied_cognition XML is on the owner surface; summarize the decision delta in prose unless a gate explicitly asks for machine-readable XML');
1041
+ }
1042
+ return gaps;
1043
+ }
1044
+
340
1045
  function normalizeValidationIssue(issue) {
341
1046
  const raw = String(issue || '').replace(/\\s+/g, ' ').trim();
342
1047
  if (!raw) return '';
343
1048
  if (/No <cognition>/i.test(raw)) return 'missing readable cognition block';
344
1049
  if (/missing\\s+<applied_cognition>/i.test(raw)) return 'missing applied cognition contract';
1050
+ if (/owner_facing_cognition_first|owner[- ]readable|Leading with <cognition>|gate surface/i.test(raw)) {
1051
+ return 'owner-readable answer must come before gate XML; move <cognition>/<applied_cognition> after the headline, evidence, and next action';
1052
+ }
1053
+ if (/feedback_full_harness_binding_must_be_structural|just-context-I-read|SDK has primitives|just context|advisory|read[.-]?only/i.test(raw)) {
1054
+ return 'structural harness binding requires executed SDK primitive evidence: name the validateOutput/checkAction/inject/gardenTurn/verifyClaim receipt, or state that no SDK primitive has run and make the next action the exact primitive call; avoid ambiguous "read-only" wording when you mean "no production writes were performed"';
1055
+ }
1056
+ if (/feedback_pretoolgate_covers_all_action_tools/i.test(raw)) {
1057
+ return 'doctrine wording issue: requirements must not be framed as preferences, optional paths, or fallback layers';
1058
+ }
1059
+ if (/feedback_qa_binds_to_fix_not_question|QA finding has been emitted|Recovery Contract is BINDING/i.test(raw)) {
1060
+ return 'QA finding requires A/B/C/D closure with evidence: fixed in turn, tracked task, scoped Mizan choice, or invalidated';
1061
+ }
1062
+ if (/feedback_no_premature_task_closeout|premature_task_closeout/i.test(raw)) {
1063
+ return 'completion/readiness claim needs matching verification or bounded status';
1064
+ }
345
1065
  if (/qualitative_drift/i.test(raw)) return 'qualitative drift language needs a measurable predicate';
346
1066
  if (/premature_task_closeout|feedback_no_premature_task_closeout|done\\|complete\\|completed\\|ready\\|verified\\|fixed/i.test(raw)) {
347
1067
  return 'completion/readiness claim conflicts with unresolved blocker state';
@@ -369,26 +1089,36 @@ export function formatValidationFailure(result) {
369
1089
  }
370
1090
 
371
1091
  export function isAriaControlBlock(text) {
372
- return /^(?:ARIA CODEX RECOVERY CONTRACT|Aria runtime blocked final output for this Codex turn\\.|Aria stop gate blocked output:|Aria task\\/project ledger blocked output claim\\.|Aria stop hook failed closed:)/i.test(String(text || '').trim());
1092
+ return /^(?:ARIA CODEX RECOVERY CONTRACT|Aria held this Codex output for re-authoring\\.|Aria runtime blocked final output for this Codex turn\\.|Aria stop gate blocked output:|Aria task\\/project ledger blocked output claim\\.|Aria stop hook failed closed:)/i.test(String(text || '').trim());
373
1093
  }
374
1094
 
375
1095
  export function formatCodexRecoveryBlock({ surface = 'codex', reason = '', issues = [], next = '' } = {}) {
376
1096
  const blockers = uniqueStrings([reason, ...issues]);
1097
+ const hasStructuralHarnessBindingBlocker = blockers.some((item) => /structural harness binding/i.test(item));
1098
+ const recoveryLines = hasStructuralHarnessBindingBlocker
1099
+ ? [
1100
+ '4. Structural harness binding blocker: do not repeat "SDK primitives" as prose.',
1101
+ '5. In the owner answer, include one concrete line: SDK evidence: <primitive> <receipt/path/status> or SDK evidence: not run yet.',
1102
+ '6. If not run yet, the next action must be the exact primitive call, for example validateOutput, checkAction, inject, gardenTurn, or verifyClaim.',
1103
+ '7. Avoid ambiguous read-only wording; say no production writes were performed when that is the actual evidence.',
1104
+ ]
1105
+ : [
1106
+ next || '4. Re-submit the corrected answer; if this blocker repeats twice, escalate with this block report.',
1107
+ ];
377
1108
  return [
378
- 'ARIA CODEX RECOVERY CONTRACT',
379
- 'surface: ' + surface,
380
- 'status: output held for re-authoring',
1109
+ 'Aria held this Codex output for re-authoring.',
1110
+ '',
1111
+ 'Surface: ' + surface,
1112
+ 'Status: blocked before user release',
381
1113
  '',
382
1114
  'Observed blockers:',
383
1115
  ...(blockers.length ? blockers.map((item) => '- ' + item) : ['- Aria validation failed.']),
384
1116
  '',
385
- 'Recovery contract:',
386
- '1. Do not retry the same blocked text.',
387
- '2. Re-author the answer from the user request, not from this block report.',
388
- '3. Include <cognition> and <applied_cognition> when the answer is non-trivial.',
389
- '4. Use bounded status language when evidence is missing; do not use completion/readiness claims without proof.',
390
- '5. Name a measurable verification predicate, or explicitly state that verification has not run.',
391
- next || '6. Re-submit the corrected answer; if the same blocker repeats twice, escalate with this full recovery contract.',
1117
+ 'Rewrite shape:',
1118
+ '1. Start with the owner-readable answer: status, evidence, next action.',
1119
+ '2. Keep claims bounded unless verification evidence is present.',
1120
+ '3. Put raw gate XML after the answer only when the gate explicitly requires it.',
1121
+ ...recoveryLines,
392
1122
  ].join('\\n');
393
1123
  }
394
1124
 
@@ -416,10 +1146,12 @@ export function runGovernanceGate(payload = {}) {
416
1146
  }
417
1147
 
418
1148
  function buildCodexUserPromptHook(): string {
1149
+ return readCanonicalCodexHook('aria-userprompt-submit.mjs');
419
1150
  return `#!/usr/bin/env node
420
1151
  import {
421
1152
  getHarnessClient,
422
1153
  inferSessionId,
1154
+ inferHiveThreadId,
423
1155
  inferUserId,
424
1156
  ensureTraceId,
425
1157
  extractUserText,
@@ -429,19 +1161,41 @@ import {
429
1161
  recordCoachPhase,
430
1162
  loadTurnState,
431
1163
  saveTurnState,
1164
+ inferRequiredAriaSkills,
1165
+ summarizeForcedSkillLoad,
1166
+ forcedSkillLoadGaps,
1167
+ buildUniversalConnectorGoalContract,
432
1168
  runGovernanceGate,
1169
+ recordHiveSessionLifecycle,
433
1170
  updateTaskProjectLedger,
434
1171
  formatCodexRecoveryBlock,
435
1172
  emitJson,
436
1173
  } from './lib/runtime-client.mjs';
437
1174
 
1175
+ const ARIA_QA_AUTOFIRE_CYCLE = Object.freeze([
1176
+ 'qiyas_15_pass',
1177
+ 'tadabbur_full_canonical_12_stage',
1178
+ 'correct',
1179
+ 'enhance',
1180
+ 'harden',
1181
+ 'verify',
1182
+ ]);
1183
+
1184
+ const ARIA_QA_METHOD_CONTRACT = Object.freeze({
1185
+ qiyas: 'Qiyas means full Qiyas-15 only. Mini Qiyas is not acceptable for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1186
+ tadabbur: 'Tadabbur means the full canonical 12-stage Tadabbur path for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1187
+ });
1188
+
438
1189
  const event = readEventFromStdin();
439
1190
  const client = getHarnessClient();
440
1191
  const userText = extractUserText(event);
441
1192
  const sessionId = inferSessionId(event);
1193
+ const hiveThreadId = inferHiveThreadId(event, sessionId);
442
1194
  const userId = inferUserId(event);
443
1195
  const priorState = loadTurnState(sessionId);
444
1196
  const traceId = ensureTraceId(priorState);
1197
+ const requiredSkills = inferRequiredAriaSkills(userText);
1198
+ const goalContract = buildUniversalConnectorGoalContract({ userText, phase: 'pre_prompt' });
445
1199
  const ledgerResult = updateTaskProjectLedger({
446
1200
  platform: 'codex',
447
1201
  phase: 'pre_prompt_injection',
@@ -450,6 +1204,15 @@ const ledgerResult = updateTaskProjectLedger({
450
1204
  });
451
1205
 
452
1206
  try {
1207
+ const lifecycleStart = await recordHiveSessionLifecycle({
1208
+ sessionId,
1209
+ threadId: hiveThreadId,
1210
+ event: 'turn_start',
1211
+ status: 'active',
1212
+ intentSummary: userText.slice(0, 240) || 'Codex session turn started',
1213
+ source: 'codex-userprompt-hook',
1214
+ body: { traceId, userId, goalContract },
1215
+ });
453
1216
  await recordCoachPhase('pre_turn', {
454
1217
  requestId: traceId,
455
1218
  sessionId,
@@ -488,20 +1251,81 @@ try {
488
1251
  platform: 'codex',
489
1252
  userText,
490
1253
  userId,
1254
+ goalContract,
491
1255
  evidenceRefs: [packetRef],
492
1256
  },
493
1257
  });
1258
+ let forcedSkillLoad = null;
1259
+ if (requiredSkills.length > 0) {
1260
+ try {
1261
+ const promptBuild = await runtimePost('/build-system-prompt', {
1262
+ sessionId,
1263
+ message: userText || 'codex forced skill load',
1264
+ requiredSkills,
1265
+ metadata: {
1266
+ source: 'codex-userprompt-submit',
1267
+ cookbookMode: 'required-when-referenced',
1268
+ skillExecutionMode: 'mechanical-receipt',
1269
+ goalContract,
1270
+ },
1271
+ skillExecutionMode: 'mechanical-receipt',
1272
+ });
1273
+ forcedSkillLoad = summarizeForcedSkillLoad(promptBuild);
1274
+ forcedSkillLoad.gaps = forcedSkillLoadGaps({ requiredSkills, forcedSkillLoad });
1275
+ } catch (error) {
1276
+ forcedSkillLoad = {
1277
+ ok: false,
1278
+ requiredSkillIds: requiredSkills,
1279
+ loadedSkillIds: [],
1280
+ missingSkillIds: [],
1281
+ loadedSkillHashes: [],
1282
+ loadedCookbooks: [],
1283
+ missingCookbooks: [],
1284
+ promptSha256: null,
1285
+ promptChars: 0,
1286
+ gaps: ['forced skill autofire runtime call failed: ' + (error instanceof Error ? error.message : String(error))],
1287
+ };
1288
+ }
1289
+ }
494
1290
  await recordCoachPhase('post_cognition', {
495
1291
  requestId: traceId,
496
1292
  sessionId,
497
1293
  text: userText,
498
- evidenceRefs: [packetRef, makeEvidenceRef('mizan_pre_receipt', result?.receipt || null, { sessionId, traceId })],
499
- metadata: { source: 'codex-userprompt-hook', pre_receipt_id: result?.receipt?.receiptId || null },
1294
+ evidenceRefs: [
1295
+ packetRef,
1296
+ makeEvidenceRef('mizan_pre_receipt', result?.receipt || null, { sessionId, traceId }),
1297
+ ...(forcedSkillLoad ? [makeEvidenceRef('forced_skill_load', forcedSkillLoad, { sessionId, traceId })] : []),
1298
+ ],
1299
+ metadata: {
1300
+ source: 'codex-userprompt-hook',
1301
+ pre_receipt_id: result?.receipt?.receiptId || null,
1302
+ requiredSkills,
1303
+ forcedSkillLoad,
1304
+ goalContract,
1305
+ hiveThreadId,
1306
+ lifecycleStart,
1307
+ qaAutofire: {
1308
+ mode: 'always-on-15',
1309
+ phase: 'pre_turn',
1310
+ correctionCycle: ARIA_QA_AUTOFIRE_CYCLE,
1311
+ },
1312
+ },
500
1313
  });
501
1314
  saveTurnState(sessionId, {
502
1315
  traceId,
503
1316
  userId,
504
1317
  userText,
1318
+ requiredSkills,
1319
+ forcedSkillLoad,
1320
+ goalContract,
1321
+ forcedSkillLoadEnforced: false,
1322
+ forcedSkillAutofire: requiredSkills.length > 0,
1323
+ hiveThreadId,
1324
+ lifecycleStart,
1325
+ qaAutofire: {
1326
+ mode: 'always-on-15',
1327
+ correctionCycle: ARIA_QA_AUTOFIRE_CYCLE,
1328
+ },
505
1329
  preReceiptId: result?.receipt?.receiptId || null,
506
1330
  taskProjectLedgerId: ledgerResult.ledger.ledgerId,
507
1331
  packetTimestamp: packet?.timestamp || null,
@@ -522,9 +1346,18 @@ try {
522
1346
  `;
523
1347
  }
524
1348
 
1349
+ function buildCodexLiveTickerHook(): string {
1350
+ return readCanonicalCodexHook('aria-live-ticker.mjs');
1351
+ }
1352
+
1353
+ function buildCodexHarnessTickerSidecar(): string {
1354
+ return readCanonicalCodexHook('aria-harness-ticker-sidecar.mjs');
1355
+ }
1356
+
525
1357
  function buildCodexPreToolHook(): string {
1358
+ return readCanonicalCodexHook('aria-pre-tool-use.mjs');
526
1359
  return `#!/usr/bin/env node
527
- import {
1360
+ import {
528
1361
  inferSessionId,
529
1362
  classifyAction,
530
1363
  summarizeTarget,
@@ -532,30 +1365,86 @@ function buildCodexPreToolHook(): string {
532
1365
  loadTurnState,
533
1366
  makeEvidenceRef,
534
1367
  recordCoachPhase,
1368
+ ensurePreTurnMizanReceipt,
535
1369
  runGovernanceGate,
536
1370
  saveTurnState,
1371
+ forcedSkillLoadGaps,
1372
+ extractToolTouchedFiles,
1373
+ recordHiveFileTouch,
1374
+ recordHiveSessionLifecycle,
537
1375
  formatCodexRecoveryBlock,
538
1376
  emitJson,
539
1377
  } from './lib/runtime-client.mjs';
540
1378
 
1379
+ const ARIA_QA_AUTOFIRE_CYCLE = Object.freeze([
1380
+ 'qiyas_15_pass',
1381
+ 'tadabbur_full_canonical_12_stage',
1382
+ 'correct',
1383
+ 'enhance',
1384
+ 'harden',
1385
+ 'verify',
1386
+ ]);
1387
+
1388
+ const ARIA_QA_METHOD_CONTRACT = Object.freeze({
1389
+ qiyas: 'Qiyas means full Qiyas-15 only. Mini Qiyas is not acceptable for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1390
+ tadabbur: 'Tadabbur means the full canonical 12-stage Tadabbur path for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1391
+ });
1392
+
541
1393
  const event = readEventFromStdin();
542
1394
  const sessionId = inferSessionId(event);
543
1395
  const action = classifyAction(event);
544
1396
  const target = summarizeTarget(event);
545
- const state = loadTurnState(sessionId);
1397
+ let state = loadTurnState(sessionId);
546
1398
 
547
1399
  try {
548
- if (!state?.preReceiptId && !state?.userText) {
549
- emitJson({
550
- decision: 'block',
551
- reason: formatCodexRecoveryBlock({
552
- surface: 'codex-pre-tool',
553
- reason: 'this turn has no pre-turn Mizan receipt',
554
- next: '6. Re-submit the prompt so cognition is established before tool use, then request the tool again.',
555
- }),
556
- });
1400
+ if (!state?.preReceiptId) {
1401
+ try {
1402
+ const healed = await ensurePreTurnMizanReceipt({
1403
+ sessionId,
1404
+ traceId: state?.traceId || sessionId,
1405
+ state,
1406
+ event,
1407
+ action,
1408
+ target,
1409
+ });
1410
+ state = healed.state || state;
1411
+ if (!healed.ok) {
1412
+ emitJson({
1413
+ decision: 'block',
1414
+ reason: 'Codex pre-tool gate could not mint a real Mizan pre-turn receipt from the mounted runtime. Runtime returned no receipt id; tool use is blocked until the runtime receipt path is healthy.',
1415
+ });
1416
+ }
1417
+ } catch (error) {
1418
+ emitJson({
1419
+ decision: 'block',
1420
+ reason: 'Codex pre-tool gate could not mint a real Mizan pre-turn receipt from the mounted runtime: ' + (error instanceof Error ? error.message : String(error)),
1421
+ });
1422
+ }
557
1423
  }
1424
+ const forcedSkillGaps = forcedSkillLoadGaps(state);
558
1425
  const toolName = String(event?.tool_name || event?.toolName || '').trim() || null;
1426
+ const touchedFiles = extractToolTouchedFiles(event, action);
1427
+ const hiveThreadId = state?.hiveThreadId || null;
1428
+ const hiveTouch = await recordHiveFileTouch({
1429
+ sessionId,
1430
+ threadId: hiveThreadId,
1431
+ event: 'pre_tool',
1432
+ files: touchedFiles,
1433
+ source: 'codex-pre-tool-hook',
1434
+ body: { action, toolName, target },
1435
+ });
1436
+ const hiveLifecycle = touchedFiles.length > 0
1437
+ ? await recordHiveSessionLifecycle({
1438
+ sessionId,
1439
+ threadId: hiveThreadId,
1440
+ event: 'tool_claim',
1441
+ status: 'active',
1442
+ intentSummary: \`Codex tool requested \${action}\${toolName ? ' via ' + toolName : ''}\`,
1443
+ fileClaims: touchedFiles,
1444
+ source: 'codex-pre-tool-hook',
1445
+ body: { action, toolName, target },
1446
+ })
1447
+ : { ok: true, skipped: true, reason: 'no touched files' };
559
1448
  const requestRef = makeEvidenceRef('codex_tool_request', { action, toolName, target }, { sessionId });
560
1449
  const coach = await recordCoachPhase('pre_tool', {
561
1450
  requestId: state?.traceId || sessionId,
@@ -564,7 +1453,22 @@ try {
564
1453
  action,
565
1454
  target,
566
1455
  evidenceRefs: [requestRef],
567
- metadata: { source: 'codex-pre-tool-hook', toolName, requireVerify: action === 'deploy' || action === 'delete' },
1456
+ metadata: {
1457
+ source: 'codex-pre-tool-hook',
1458
+ toolName,
1459
+ requireVerify: action === 'deploy' || action === 'delete',
1460
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : [],
1461
+ forcedSkillLoad: state?.forcedSkillLoad || null,
1462
+ forcedSkillGaps,
1463
+ touchedFiles,
1464
+ hiveTouch,
1465
+ hiveLifecycle,
1466
+ qaAutofire: {
1467
+ mode: 'always-on-15',
1468
+ phase: 'pre_tool',
1469
+ correctionCycle: ARIA_QA_AUTOFIRE_CYCLE,
1470
+ },
1471
+ },
568
1472
  });
569
1473
  if (coach?.permitted === false) {
570
1474
  emitJson({
@@ -599,7 +1503,19 @@ try {
599
1503
  action,
600
1504
  target,
601
1505
  evidenceRefs: [requestRef, gateRef],
602
- metadata: { source: 'codex-pre-tool-hook', toolName, governanceGate: gateEvidence },
1506
+ metadata: {
1507
+ source: 'codex-pre-tool-hook',
1508
+ toolName,
1509
+ governanceGate: gateEvidence,
1510
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : [],
1511
+ forcedSkillLoad: state?.forcedSkillLoad || null,
1512
+ forcedSkillGaps,
1513
+ qaAutofire: {
1514
+ mode: 'always-on-15',
1515
+ phase: 'pre_tool_gate_signal',
1516
+ correctionCycle: ARIA_QA_AUTOFIRE_CYCLE,
1517
+ },
1518
+ },
603
1519
  });
604
1520
  if (gateCoach?.permitted === false) {
605
1521
  emitJson({
@@ -618,6 +1534,9 @@ try {
618
1534
  action,
619
1535
  toolName,
620
1536
  target,
1537
+ touchedFiles,
1538
+ hiveTouch,
1539
+ hiveLifecycle,
621
1540
  evidenceRef: makeEvidenceRef('tool_request', { action, toolName, target }, { sessionId }),
622
1541
  });
623
1542
  saveTurnState(sessionId, {
@@ -638,6 +1557,7 @@ try {
638
1557
  }
639
1558
 
640
1559
  function buildCodexPostToolHook(): string {
1560
+ return readCanonicalCodexHook('aria-post-tool-use.mjs');
641
1561
  return `#!/usr/bin/env node
642
1562
  import {
643
1563
  inferSessionId,
@@ -646,15 +1566,63 @@ import {
646
1566
  makeEvidenceRef,
647
1567
  recordCoachPhase,
648
1568
  saveTurnState,
1569
+ forcedSkillLoadGaps,
1570
+ classifyAction,
1571
+ extractToolTouchedFiles,
1572
+ recordHiveFileTouch,
1573
+ recordHiveSessionLifecycle,
649
1574
  updateTaskProjectLedger,
650
1575
  } from './lib/runtime-client.mjs';
651
1576
 
1577
+ const ARIA_QA_AUTOFIRE_CYCLE = Object.freeze([
1578
+ 'qiyas_15_pass',
1579
+ 'tadabbur_full_canonical_12_stage',
1580
+ 'correct',
1581
+ 'enhance',
1582
+ 'harden',
1583
+ 'verify',
1584
+ ]);
1585
+
1586
+ const ARIA_QA_METHOD_CONTRACT = Object.freeze({
1587
+ qiyas: 'Qiyas means full Qiyas-15 only. Mini Qiyas is not acceptable for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1588
+ tadabbur: 'Tadabbur means the full canonical 12-stage Tadabbur path for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1589
+ });
1590
+
652
1591
  const event = readEventFromStdin();
653
1592
  const sessionId = inferSessionId(event);
654
1593
  const state = loadTurnState(sessionId);
655
1594
 
656
1595
  try {
657
1596
  const toolResponse = JSON.stringify(event?.tool_response ?? event?.toolResponse ?? null).slice(0, 4000);
1597
+ const action = classifyAction(event);
1598
+ const touchedFiles = extractToolTouchedFiles(event, action);
1599
+ const hiveThreadId = state?.hiveThreadId || null;
1600
+ const hiveTouch = await recordHiveFileTouch({
1601
+ sessionId,
1602
+ threadId: hiveThreadId,
1603
+ event: 'post_tool',
1604
+ files: touchedFiles,
1605
+ source: 'codex-post-tool-hook',
1606
+ body: {
1607
+ action,
1608
+ toolName: event?.tool_name || event?.toolName || null,
1609
+ success: !event?.error,
1610
+ },
1611
+ });
1612
+ const hiveLifecycle = await recordHiveSessionLifecycle({
1613
+ sessionId,
1614
+ threadId: hiveThreadId,
1615
+ event: event?.error ? 'tool_error' : 'tool_complete',
1616
+ status: event?.error ? 'needs_review' : 'active',
1617
+ intentSummary: event?.error ? 'Codex tool returned an error' : 'Codex tool completed',
1618
+ fileClaims: touchedFiles,
1619
+ source: 'codex-post-tool-hook',
1620
+ body: {
1621
+ action,
1622
+ toolName: event?.tool_name || event?.toolName || null,
1623
+ success: !event?.error,
1624
+ },
1625
+ });
658
1626
  const evidenceRef = makeEvidenceRef('tool_response', event?.tool_response ?? event?.toolResponse ?? null, {
659
1627
  sessionId,
660
1628
  toolName: event?.tool_name || event?.toolName || null,
@@ -662,6 +1630,7 @@ try {
662
1630
  const toolOutputs = Array.isArray(state?.toolOutputs) ? state.toolOutputs.slice(-24) : [];
663
1631
  const verificationText = JSON.stringify(event).slice(0, 8000);
664
1632
  const verification = !event?.error && /\\b(?:npm\\s+run\\s+(?:check|test|build|lint|typecheck)|(?:npx\\s+)?(?:jest|vitest|tsc|eslint)|check:|test:|build:|passed|exit\\s*0|0\\s*failures?)\\b/i.test(verificationText);
1633
+ const forcedSkillGaps = forcedSkillLoadGaps(state);
665
1634
  await recordCoachPhase('post_tool', {
666
1635
  requestId: state?.traceId || sessionId,
667
1636
  sessionId,
@@ -672,12 +1641,27 @@ try {
672
1641
  toolName: event?.tool_name || event?.toolName || null,
673
1642
  verification,
674
1643
  error: event?.error || null,
1644
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : [],
1645
+ forcedSkillLoad: state?.forcedSkillLoad || null,
1646
+ forcedSkillGaps,
1647
+ touchedFiles,
1648
+ hiveTouch,
1649
+ hiveLifecycle,
1650
+ qaAutofire: {
1651
+ mode: 'always-on-15',
1652
+ phase: 'post_tool',
1653
+ correctionCycle: ARIA_QA_AUTOFIRE_CYCLE,
1654
+ },
675
1655
  },
676
1656
  });
677
1657
  toolOutputs.push({
678
1658
  at: new Date().toISOString(),
679
1659
  toolName: event?.tool_name || event?.toolName || null,
680
1660
  toolResponse,
1661
+ action,
1662
+ touchedFiles,
1663
+ hiveTouch,
1664
+ hiveLifecycle,
681
1665
  evidenceRef,
682
1666
  });
683
1667
  saveTurnState(sessionId, {
@@ -693,6 +1677,14 @@ try {
693
1677
  outcome_ref: evidenceRef,
694
1678
  verification,
695
1679
  commandResult: verification ? 'success' : '',
1680
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : [],
1681
+ forcedSkillLoad: state?.forcedSkillLoad || null,
1682
+ forcedSkillGaps,
1683
+ qaAutofire: {
1684
+ mode: 'always-on-15',
1685
+ phase: 'post_tool',
1686
+ correctionCycle: ARIA_QA_AUTOFIRE_CYCLE,
1687
+ },
696
1688
  },
697
1689
  });
698
1690
  process.exit(0);
@@ -703,16 +1695,23 @@ try {
703
1695
  }
704
1696
 
705
1697
  function buildCodexStopHook(): string {
1698
+ return readCanonicalCodexHook('aria-stop.mjs');
706
1699
  return `#!/usr/bin/env node
707
1700
  import {
708
1701
  inferSessionId,
709
1702
  extractAssistantText,
710
1703
  readEventFromStdin,
711
1704
  runtimePost,
1705
+ recordHiveSessionLifecycle,
712
1706
  recordCoachPhase,
713
1707
  loadTurnState,
714
1708
  makeEvidenceRef,
715
1709
  clearTurnState,
1710
+ inferRequiredAriaSkills,
1711
+ forcedSkillLoadGaps,
1712
+ fullCognitionMethodGaps,
1713
+ buildUniversalConnectorGoalContract,
1714
+ evaluateGoalContractOutput,
716
1715
  formatValidationFailure,
717
1716
  formatCodexRecoveryBlock,
718
1717
  isAriaControlBlock,
@@ -723,12 +1722,28 @@ import {
723
1722
  emitJson,
724
1723
  } from './lib/runtime-client.mjs';
725
1724
 
1725
+ const ARIA_QA_AUTOFIRE_CYCLE = Object.freeze([
1726
+ 'qiyas_15_pass',
1727
+ 'tadabbur_full_canonical_12_stage',
1728
+ 'correct',
1729
+ 'enhance',
1730
+ 'harden',
1731
+ 'verify',
1732
+ ]);
1733
+
1734
+ const ARIA_QA_METHOD_CONTRACT = Object.freeze({
1735
+ qiyas: 'Qiyas means full Qiyas-15 only. Mini Qiyas is not acceptable for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1736
+ tadabbur: 'Tadabbur means the full canonical 12-stage Tadabbur path for architecture, runtime, code, QA, hook, SDK, worker, or harness work.',
1737
+ });
1738
+
726
1739
  const event = readEventFromStdin();
727
1740
  const sessionId = inferSessionId(event);
728
1741
  const state = loadTurnState(sessionId);
729
1742
  const text = extractAssistantText(event);
1743
+
730
1744
  const outputRef = makeEvidenceRef('assistant_output', text, { sessionId, traceId: state?.traceId || null });
731
1745
  const toolRefs = Array.isArray(state?.toolOutputs) ? state.toolOutputs.map((entry) => entry.evidenceRef).filter(Boolean) : [];
1746
+ const inferredRequiredSkills = inferRequiredAriaSkills(state?.userText || '');
732
1747
  const ledgerResult = updateTaskProjectLedger({
733
1748
  platform: 'codex',
734
1749
  phase: 'stop',
@@ -744,12 +1759,60 @@ try {
744
1759
  clearTurnState(sessionId);
745
1760
  emitJson({ continue: true });
746
1761
  }
1762
+ const forcedSkillGaps = forcedSkillLoadGaps(state);
1763
+ const cognitionMethodGaps = fullCognitionMethodGaps({ state, text });
1764
+ if (cognitionMethodGaps.length > 0) {
1765
+ emitJson({
1766
+ decision: 'block',
1767
+ reason: formatCodexRecoveryBlock({
1768
+ surface: 'codex-stop-full-cognition-method',
1769
+ reason: 'owner-facing output contains raw cognition method dump',
1770
+ issues: cognitionMethodGaps,
1771
+ next: '4. Re-author as a professional owner-readable closeout: one status line, 2-4 evidence bullets, concrete next action. Do not paste qiyas_15_pass, Tadabbur stages, or raw applied_cognition into the visible answer.',
1772
+ }),
1773
+ });
1774
+ }
1775
+ const qaAutofire = {
1776
+ mode: 'always-on-15',
1777
+ phase: 'stop',
1778
+ correctionCycle: ARIA_QA_AUTOFIRE_CYCLE,
1779
+ methodContract: ARIA_QA_METHOD_CONTRACT,
1780
+ };
1781
+ const goalContract = state?.goalContract || buildUniversalConnectorGoalContract({
1782
+ userText: state?.userText || '',
1783
+ phase: 'stop',
1784
+ });
1785
+ const goalQa = evaluateGoalContractOutput(text, {
1786
+ userText: state?.userText || '',
1787
+ goalContract,
1788
+ });
1789
+ if (goalQa.hardBlock) {
1790
+ emitJson({
1791
+ decision: 'block',
1792
+ reason: formatCodexRecoveryBlock({
1793
+ surface: 'codex-stop-goal-contract',
1794
+ reason: 'active goal contract rejected drift or false completion risk',
1795
+ issues: [...goalQa.blockers, ...goalQa.repairs],
1796
+ next: '4. Re-author around the actual corpus-to-runtime wiring goal, name the next highest-impact action, include QA/correction/evidence, and keep receipts/gates as support only.',
1797
+ }),
1798
+ });
1799
+ }
747
1800
  const postGenerationCoach = await recordCoachPhase('post_generation', {
748
1801
  requestId: state?.traceId || sessionId,
749
1802
  sessionId,
750
1803
  text,
751
1804
  evidenceRefs: [outputRef],
752
- metadata: { source: 'codex-stop-hook', requireCognitionBlock: false, requireAppliedCognition: false },
1805
+ metadata: {
1806
+ source: 'codex-stop-hook',
1807
+ requireCognitionBlock: false,
1808
+ requireAppliedCognition: false,
1809
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
1810
+ forcedSkillLoad: state?.forcedSkillLoad || null,
1811
+ forcedSkillGaps,
1812
+ goalContract,
1813
+ goalQa,
1814
+ qaAutofire: { ...qaAutofire, phase: 'post_generation' },
1815
+ },
753
1816
  });
754
1817
  if (postGenerationCoach?.permitted === false) {
755
1818
  emitJson({
@@ -813,7 +1876,18 @@ try {
813
1876
  validation: validation?.validation || null,
814
1877
  layer3: validation?.layer3 || null,
815
1878
  evidenceRefs: [outputRef, makeEvidenceRef('runtime_validation', validation, { sessionId, traceId: state?.traceId || null }), ...(gateEvidence ? [makeEvidenceRef('governance_gate', gateEvidence, { sessionId })] : [])],
816
- metadata: { source: 'codex-stop-hook', requireCognitionBlock: false, requireAppliedCognition: false, governanceGate: gateEvidence || null },
1879
+ metadata: {
1880
+ source: 'codex-stop-hook',
1881
+ requireCognitionBlock: false,
1882
+ requireAppliedCognition: false,
1883
+ governanceGate: gateEvidence || null,
1884
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
1885
+ forcedSkillLoad: state?.forcedSkillLoad || null,
1886
+ forcedSkillGaps,
1887
+ goalContract,
1888
+ goalQa,
1889
+ qaAutofire: { ...qaAutofire, phase: 'pre_output' },
1890
+ },
817
1891
  });
818
1892
  if (preOutputCoach?.permitted === false) {
819
1893
  emitJson({
@@ -845,6 +1919,12 @@ try {
845
1919
  trace_id: state?.traceId || null,
846
1920
  output_ref: outputRef,
847
1921
  tool_refs: toolRefs,
1922
+ required_skills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
1923
+ forced_skill_load: state?.forcedSkillLoad || null,
1924
+ forced_skill_gaps: forcedSkillGaps,
1925
+ goal_contract: goalContract,
1926
+ goal_qa: goalQa,
1927
+ qa_autofire: { ...qaAutofire, phase: 'mizan_post' },
848
1928
  },
849
1929
  context: {
850
1930
  sessionId,
@@ -865,7 +1945,17 @@ try {
865
1945
  outputRef,
866
1946
  makeEvidenceRef('mizan_post_receipt', post?.receipt || null, { sessionId, traceId: state?.traceId || null }),
867
1947
  ],
868
- metadata: { source: 'codex-stop-hook', requireCognitionBlock: false, requireAppliedCognition: false },
1948
+ metadata: {
1949
+ source: 'codex-stop-hook',
1950
+ requireCognitionBlock: false,
1951
+ requireAppliedCognition: false,
1952
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
1953
+ forcedSkillLoad: state?.forcedSkillLoad || null,
1954
+ forcedSkillGaps,
1955
+ goalContract,
1956
+ goalQa,
1957
+ qaAutofire: { ...qaAutofire, phase: 'post_output' },
1958
+ },
869
1959
  });
870
1960
  await runtimePost('/decision/log', {
871
1961
  session_id: sessionId,
@@ -886,6 +1976,12 @@ try {
886
1976
  tool_count: Array.isArray(state?.tools) ? state.tools.length : 0,
887
1977
  validation_severity: validation?.validation?.severity || 'pass',
888
1978
  layer3_pass: validation?.layer3?.pass !== false,
1979
+ required_skills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
1980
+ forced_skill_load: state?.forcedSkillLoad || null,
1981
+ forced_skill_gaps: forcedSkillGaps,
1982
+ goal_contract: goalContract,
1983
+ goal_qa: goalQa,
1984
+ qa_autofire: { ...qaAutofire, phase: 'decision_log' },
889
1985
  },
890
1986
  });
891
1987
  if (typeof state?.userText === 'string' && state.userText.trim()) {
@@ -900,6 +1996,12 @@ try {
900
1996
  decision_category: 'codex-hooks',
901
1997
  trace_id: state?.traceId || null,
902
1998
  output_ref: outputRef,
1999
+ required_skills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
2000
+ forced_skill_load: state?.forcedSkillLoad || null,
2001
+ forced_skill_gaps: forcedSkillGaps,
2002
+ goal_contract: goalContract,
2003
+ goal_qa: goalQa,
2004
+ qa_autofire: { ...qaAutofire, phase: 'garden_turn' },
903
2005
  },
904
2006
  });
905
2007
  }
@@ -912,6 +2014,12 @@ try {
912
2014
  post_turn: true,
913
2015
  output_ref: outputRef,
914
2016
  verification: false,
2017
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
2018
+ forcedSkillLoad: state?.forcedSkillLoad || null,
2019
+ forcedSkillGaps,
2020
+ goalContract,
2021
+ goalQa,
2022
+ qaAutofire: { ...qaAutofire, phase: 'post_turn_ledger' },
915
2023
  },
916
2024
  });
917
2025
  const releaseCoach = await recordCoachPhase('claim_or_release', {
@@ -927,6 +2035,12 @@ try {
927
2035
  requireCognitionBlock: false,
928
2036
  requireAppliedCognition: false,
929
2037
  post_receipt_id: post?.receipt?.receiptId || null,
2038
+ requiredSkills: Array.isArray(state?.requiredSkills) ? state.requiredSkills : inferredRequiredSkills,
2039
+ forcedSkillLoad: state?.forcedSkillLoad || null,
2040
+ forcedSkillGaps,
2041
+ goalContract,
2042
+ goalQa,
2043
+ qaAutofire: { ...qaAutofire, phase: 'claim_or_release' },
930
2044
  },
931
2045
  });
932
2046
  if (releaseCoach?.permitted === false) {
@@ -938,6 +2052,28 @@ try {
938
2052
  }),
939
2053
  });
940
2054
  }
2055
+ const touchedFileMap = new Map();
2056
+ for (const entry of [...(Array.isArray(state?.tools) ? state.tools : []), ...(Array.isArray(state?.toolOutputs) ? state.toolOutputs : [])]) {
2057
+ for (const file of Array.isArray(entry?.touchedFiles) ? entry.touchedFiles : []) {
2058
+ if (file?.path && !touchedFileMap.has(file.path)) touchedFileMap.set(file.path, file);
2059
+ }
2060
+ }
2061
+ await recordHiveSessionLifecycle({
2062
+ sessionId,
2063
+ threadId: state?.hiveThreadId || null,
2064
+ event: 'turn_complete',
2065
+ status: 'completed',
2066
+ intentSummary: (state?.userText || text || 'Codex turn completed').slice(0, 240),
2067
+ fileClaims: [...touchedFileMap.values()],
2068
+ source: 'codex-stop-hook',
2069
+ body: {
2070
+ traceId: state?.traceId || null,
2071
+ outputRef,
2072
+ validationSeverity: validation?.validation?.severity || 'pass',
2073
+ layer3Pass: validation?.layer3?.pass !== false,
2074
+ goalQa,
2075
+ },
2076
+ });
941
2077
  clearTurnState(sessionId);
942
2078
  emitJson({ continue: true });
943
2079
  } catch (error) {
@@ -955,7 +2091,11 @@ try {
955
2091
 
956
2092
  function buildCodexHooksToml(codexDir: string): string {
957
2093
  const hooksDir = path.join(codexDir, 'hooks');
2094
+ const configPath = path.join(codexDir, 'config.toml');
958
2095
  const command = (name: string) => tomlString(`node ${path.join(hooksDir, name)}`);
2096
+ const stateKey = (event: string, index: number) => tomlString(`${configPath}:${event}:${index}:0`);
2097
+ const enabledState = (event: string, index: number) => `[hooks.state.${stateKey(event, index)}]
2098
+ enabled = true`;
959
2099
  return `# BEGIN ARIA MANAGED HOOKS
960
2100
  [hooks]
961
2101
  managed_dir = ${tomlString(hooksDir)}
@@ -963,6 +2103,9 @@ managed_dir = ${tomlString(hooksDir)}
963
2103
  [[hooks.UserPromptSubmit]]
964
2104
  hooks = [{ type = "command", command = ${command('aria-userprompt-submit.mjs')} }]
965
2105
 
2106
+ [[hooks.UserPromptSubmit]]
2107
+ hooks = [{ type = "command", command = ${command('aria-live-ticker.mjs')} }]
2108
+
966
2109
  [[hooks.PreToolUse]]
967
2110
  matcher = ".*"
968
2111
  hooks = [{ type = "command", command = ${command('aria-pre-tool-use.mjs')} }]
@@ -973,6 +2116,18 @@ hooks = [{ type = "command", command = ${command('aria-post-tool-use.mjs')} }]
973
2116
 
974
2117
  [[hooks.Stop]]
975
2118
  hooks = [{ type = "command", command = ${command('aria-stop.mjs')} }]
2119
+
2120
+ [hooks.state]
2121
+
2122
+ ${enabledState('user_prompt_submit', 0)}
2123
+
2124
+ ${enabledState('user_prompt_submit', 1)}
2125
+
2126
+ ${enabledState('pre_tool_use', 0)}
2127
+
2128
+ ${enabledState('post_tool_use', 0)}
2129
+
2130
+ ${enabledState('stop', 0)}
976
2131
  # END ARIA MANAGED HOOKS
977
2132
  `;
978
2133
  }
@@ -995,14 +2150,21 @@ function installCodexHooksConfig(codexDir: string, logs: string[]): void {
995
2150
  function installCodexHooks(codexDir: string, logs: string[]): void {
996
2151
  const hooksDir = path.join(codexDir, 'hooks');
997
2152
  mkdirSync(path.join(hooksDir, 'lib'), { recursive: true, mode: 0o755 });
2153
+ mkdirSync(path.join(codexDir, 'lib'), { recursive: true, mode: 0o755 });
998
2154
  const ledgerHelperSrc = packageTaskProjectLedgerHelperPath();
999
2155
  if (!existsSync(ledgerHelperSrc)) {
1000
2156
  throw new Error(`Task/project ledger helper missing: ${ledgerHelperSrc}`);
1001
2157
  }
2158
+ const projectBoundarySrc = packageProjectBoundaryCognitionPath();
2159
+ if (!existsSync(projectBoundarySrc)) {
2160
+ throw new Error(`Project boundary cognition helper missing: ${projectBoundarySrc}`);
2161
+ }
1002
2162
 
1003
2163
  const files: Array<[string, string]> = [
1004
2164
  [path.join(hooksDir, 'lib', 'runtime-client.mjs'), buildCodexHookRuntimeClient()],
1005
2165
  [path.join(hooksDir, 'aria-userprompt-submit.mjs'), buildCodexUserPromptHook()],
2166
+ [path.join(hooksDir, 'aria-live-ticker.mjs'), buildCodexLiveTickerHook()],
2167
+ [path.join(hooksDir, 'aria-harness-ticker-sidecar.mjs'), buildCodexHarnessTickerSidecar()],
1006
2168
  [path.join(hooksDir, 'aria-pre-tool-use.mjs'), buildCodexPreToolHook()],
1007
2169
  [path.join(hooksDir, 'aria-post-tool-use.mjs'), buildCodexPostToolHook()],
1008
2170
  [path.join(hooksDir, 'aria-stop.mjs'), buildCodexStopHook()],
@@ -1014,6 +2176,8 @@ function installCodexHooks(codexDir: string, logs: string[]): void {
1014
2176
  }
1015
2177
  copyFileSync(ledgerHelperSrc, path.join(hooksDir, 'lib', 'task-project-ledger.mjs'));
1016
2178
  try { chmodSync(path.join(hooksDir, 'lib', 'task-project-ledger.mjs'), 0o755); } catch {}
2179
+ copyFileSync(projectBoundarySrc, path.join(codexDir, 'lib', 'project-boundary-cognition.mjs'));
2180
+ try { chmodSync(path.join(codexDir, 'lib', 'project-boundary-cognition.mjs'), 0o755); } catch {}
1017
2181
 
1018
2182
  logs.push(`Installed Codex native hooks → ${hooksDir}`);
1019
2183
  installCodexHooksConfig(codexDir, logs);
@@ -1134,10 +2298,19 @@ Lens roles for decisions:
1134
2298
  ## Structural Cognition Contract
1135
2299
  - Cognition is not accepted as proof by itself. It must change the next action, tool call, or output claim.
1136
2300
  - Each lens must affect work selection or artifact shape; do not write lenses after the decision is already made.
1137
- - For every non-trivial output, include an \`<applied_cognition>\` block with \`decision_delta\`, \`dominant_domain\`, \`binds_to\`, \`expected_predicate\`, and \`artifact_change\`.
2301
+ - For every non-trivial output, applied cognition must change the answer, tool call, or claim boundary.
2302
+ - Owner-readable output comes first. Raw \`<applied_cognition>\` is required only when a gate or owner explicitly asks for machine-readable XML; otherwise fold the fields into concise prose.
1138
2303
  - Tool-bound cognition must name the exact tool/action it constrains and the measurable predicate that proves the action succeeded.
1139
2304
  - Deploy or destructive actions still require \`<verify>\` and \`<expected>\` blocks before execution.
1140
2305
  - If cognition did not change anything, stop and re-think; \`decision_delta: none\` is treated as performative.
2306
+
2307
+ ## Autofire Quality Continuation Contract
2308
+ - Actual goal: wire extracted books, doctrines, skills, runtimes, primitives, mappings, CLIs, connectors, and agent surfaces into the operating system so output improves automatically.
2309
+ - Receipts, gates, ledgers, and canaries are evidence, not the product. They pass only when they prove corpus-backed behavior changed the next action, QA, correction, verification, or learning loop.
2310
+ - For continuation work, name the next highest-quality, highest-impact step by default; do not make the owner ask for the obvious next action.
2311
+ - Forced QA is the ordinary gate: compare expected vs observed, name findings or explicit pass criteria, correct low-risk misses, verify with real evidence, and record Dalio-style lesson plus Reflexion-style next action.
2312
+ - Hard stops are reserved for secrets, destructive actions, deploy/publication boundaries, owner-contradicted actions, and proven false completion risk.
2313
+ - Final owner-facing output must be readable: status, evidence, QA/correction result, and next action. Do not dump lifecycle receipts or raw JSON unless the owner explicitly asks for raw receipt/debug evidence.
1141
2314
  `;
1142
2315
  }
1143
2316
 
@@ -1215,10 +2388,17 @@ function installAgentsMd(codexDir: string, config: AriaConfig, logs: string[]):
1215
2388
  logs.push(`Installed Codex must-read guide → ${mustReadPath}`);
1216
2389
  }
1217
2390
 
1218
- export async function connectCodex(config: AriaConfig): Promise<string[]> {
2391
+ export async function connectCodex(config: AriaConfig, opts: { installWrapper?: boolean } = {}): Promise<string[]> {
1219
2392
  const logs: string[] = [];
1220
2393
  const codexDir = path.join(homedir(), '.codex');
1221
2394
 
2395
+ await requireGovernedConnectorMutation({
2396
+ surfaceId: 'codex',
2397
+ action: 'install',
2398
+ targetPath: codexDir,
2399
+ reason: 'install Codex harness surface',
2400
+ });
2401
+
1222
2402
  if (!existsSync(codexDir)) {
1223
2403
  mkdirSync(codexDir, { recursive: true, mode: 0o700 });
1224
2404
  logs.push(`Created ${codexDir}`);
@@ -1231,6 +2411,10 @@ export async function connectCodex(config: AriaConfig): Promise<string[]> {
1231
2411
  installCodexHooks(codexDir, logs);
1232
2412
  installAriaCognitionSkills(codexDir, logs);
1233
2413
  syncDoctrineTriggerMap(logs);
1234
- logs.push(...await connectShell('codex', config));
2414
+ if (opts.installWrapper === true) {
2415
+ logs.push(...await connectShell('codex', config));
2416
+ } else {
2417
+ logs.push('Skipped Codex shell wrapper install; Codex direct login/default provider path remains untouched. Use aria connect --with-wrappers only when explicitly desired.');
2418
+ }
1235
2419
  return logs;
1236
2420
  }