sneakoscope 6.0.3 → 6.1.2

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 (378) hide show
  1. package/README.md +29 -12
  2. package/config/codex-releases/{rust-v0.142.0.json → rust-v0.144.1.json} +6 -6
  3. package/crates/sks-core/Cargo.lock +1 -1
  4. package/crates/sks-core/Cargo.toml +1 -1
  5. package/dist/bin/fast-inline.js +18 -14
  6. package/dist/bin/sks-dispatch.js +2 -4
  7. package/dist/cli/args.js +2 -0
  8. package/dist/cli/command-manifest-lite.js +2 -3
  9. package/dist/cli/command-registry.js +3 -4
  10. package/dist/cli/help-fast.js +1 -1
  11. package/dist/cli/install-helpers.js +348 -763
  12. package/dist/cli/install-tool-helpers.js +287 -0
  13. package/dist/cli/router.js +91 -6
  14. package/dist/commands/codex-lb.js +188 -53
  15. package/dist/commands/codex.js +44 -5
  16. package/dist/commands/doctor.js +302 -46
  17. package/dist/commands/tmux.js +5 -1
  18. package/dist/commands/versioning.js +7 -0
  19. package/dist/commands/zellij-monitor-pane.js +2 -0
  20. package/dist/commands/zellij-viewport-pane.js +3 -1
  21. package/dist/commands/zellij.js +1 -1
  22. package/dist/config/skills-manifest.json +59 -59
  23. package/dist/core/agent-bridge/agent-manifest.js +48 -0
  24. package/dist/core/agents/agent-central-ledger.js +9 -0
  25. package/dist/core/agents/agent-cleanup-executor.js +334 -41
  26. package/dist/core/agents/agent-cleanup.js +20 -1
  27. package/dist/core/agents/agent-command-surface.js +3 -1
  28. package/dist/core/agents/agent-effort-policy.js +30 -38
  29. package/dist/core/agents/agent-janitor.js +9 -10
  30. package/dist/core/agents/agent-namespace-safety.js +56 -0
  31. package/dist/core/agents/agent-orchestrator.js +25 -3
  32. package/dist/core/agents/agent-output-validator.js +1 -1
  33. package/dist/core/agents/agent-plan.js +100 -21
  34. package/dist/core/agents/agent-role-config.js +43 -49
  35. package/dist/core/agents/agent-runner-codex-exec.js +18 -3
  36. package/dist/core/agents/agent-runner-process.js +1 -0
  37. package/dist/core/agents/agent-schema.js +3 -2
  38. package/dist/core/agents/fast-mode-policy.js +3 -5
  39. package/dist/core/agents/native-cli-session-swarm.js +1 -1
  40. package/dist/core/agents/native-worker-backend-router.js +2 -1
  41. package/dist/core/agents/work-partition/repo-inventory.js +68 -7
  42. package/dist/core/agents/zellij-right-lane-cockpit.js +2 -2
  43. package/dist/core/code-structure.js +5 -4
  44. package/dist/core/codex/agent-config-file-repair.js +94 -193
  45. package/dist/core/codex/codex-cli-update.js +723 -0
  46. package/dist/core/codex/codex-config-guard.js +38 -11
  47. package/dist/core/codex/codex-project-config-policy.js +3 -6
  48. package/dist/core/codex/codex-startup-config-postcheck.js +52 -42
  49. package/dist/core/codex-adapter.js +35 -22
  50. package/dist/core/codex-app/codex-agent-role-sync.js +13 -54
  51. package/dist/core/codex-app/codex-app-fast-ui-repair.js +51 -20
  52. package/dist/core/codex-app/codex-app-launcher.js +48 -17
  53. package/dist/core/codex-app/codex-app-restart.js +23 -2
  54. package/dist/core/codex-app/codex-app-ui-state-snapshot.js +11 -3
  55. package/dist/core/codex-app/sks-menubar.js +136 -5
  56. package/dist/core/codex-app.js +35 -14
  57. package/dist/core/codex-compat/codex-hook-warning-detector.js +10 -1
  58. package/dist/core/codex-compat/codex-release-manifest.js +6 -6
  59. package/dist/core/codex-control/codex-0139-doctor-real-probe.js +7 -1
  60. package/dist/core/codex-control/codex-0139-image-path-real-probe.js +29 -12
  61. package/dist/core/codex-control/codex-0139-probe-runner.js +103 -28
  62. package/dist/core/codex-control/codex-0139-real-probe-summary.js +7 -3
  63. package/dist/core/codex-control/codex-0139-real-probes.js +21 -6
  64. package/dist/core/codex-control/codex-0139-sandbox-real-probe.js +39 -13
  65. package/dist/core/codex-control/codex-0139-web-search-probe.js +28 -14
  66. package/dist/core/codex-control/{codex-0142-capability.js → codex-0144-capability.js} +22 -22
  67. package/dist/core/codex-control/codex-0144-collab-agent-real-probe.js +63 -0
  68. package/dist/core/codex-control/codex-lb-launch-recovery.js +278 -0
  69. package/dist/core/codex-control/codex-multi-agent-event-normalizer.js +5 -1
  70. package/dist/core/codex-control/codex-reliability-shield.js +93 -30
  71. package/dist/core/codex-control/codex-sdk-adapter.js +96 -13
  72. package/dist/core/codex-control/codex-sdk-config-policy.js +2 -1
  73. package/dist/core/codex-control/codex-sdk-sandbox-policy.js +6 -3
  74. package/dist/core/codex-control/codex-task-runner.js +62 -9
  75. package/dist/core/codex-control/python-codex-sdk-adapter.js +30 -3
  76. package/dist/core/codex-exec-output-schema.js +35 -6
  77. package/dist/core/codex-lb/codex-lb-env.js +30 -1
  78. package/dist/core/codex-lb/codex-lb-tool-catalog.js +478 -0
  79. package/dist/core/codex-lb/codex-lb-tool-output-recovery.js +291 -0
  80. package/dist/core/codex-native/codex-native-feature-broker.js +31 -38
  81. package/dist/core/codex-native/codex-native-feature-matrix.js +2 -2
  82. package/dist/core/codex-native/codex-native-repair-transaction.js +1 -1
  83. package/dist/core/codex-native/core-skill-manifest.js +8 -4
  84. package/dist/core/codex-native/native-capability-postcheck.js +16 -8
  85. package/dist/core/codex-native/native-capability-repair-matrix.js +76 -27
  86. package/dist/core/codex-plugins/codex-plugin-json.js +67 -21
  87. package/dist/core/codex-plugins/codex-plugin-repair.js +118 -0
  88. package/dist/core/codex-runtime/codex-desktop-config-policy.js +305 -0
  89. package/dist/core/commands/agent-bridge-command.js +23 -2
  90. package/dist/core/commands/agent-command.js +38 -5
  91. package/dist/core/commands/basic-cli.js +77 -30
  92. package/dist/core/commands/command-utils.js +1 -1
  93. package/dist/core/commands/gc-command.js +27 -4
  94. package/dist/core/commands/image-ux-review-command.js +55 -24
  95. package/dist/core/commands/mad-sks-command.js +182 -137
  96. package/dist/core/commands/naruto-command.js +643 -1153
  97. package/dist/core/commands/pipeline-command.js +1 -0
  98. package/dist/core/commands/research-command.js +293 -231
  99. package/dist/core/commands/run-command.js +100 -23
  100. package/dist/core/commands/team-command.js +2 -3
  101. package/dist/core/commands/team-legacy-observe-command.js +94 -359
  102. package/dist/core/commands/wiki-command.js +179 -83
  103. package/dist/core/computer-use-live-evidence.js +166 -3
  104. package/dist/core/computer-use-status.js +5 -2
  105. package/dist/core/daemon/sksd-hook-daemon-entrypoint.js +2 -2
  106. package/dist/core/daemon/sksd-hook-daemon.js +171 -28
  107. package/dist/core/daemon/sksd-hook-dispatch.js +2 -2
  108. package/dist/core/db-safety.js +2 -2
  109. package/dist/core/decision-lattice.js +6 -6
  110. package/dist/core/dfix/verification-selector.js +6 -4
  111. package/dist/core/doctor/browser-use-repair.js +54 -13
  112. package/dist/core/doctor/codex-0139-doctor.js +3 -2
  113. package/dist/core/doctor/codex-startup-config-repair.js +8 -3
  114. package/dist/core/doctor/computer-use-repair.js +28 -39
  115. package/dist/core/doctor/doctor-codex-startup-repair.js +24 -149
  116. package/dist/core/doctor/doctor-context7-repair.js +1 -1
  117. package/dist/core/doctor/doctor-dirty-planner.js +1 -1
  118. package/dist/core/doctor/doctor-native-capability-repair.js +74 -3
  119. package/dist/core/doctor/imagegen-repair.js +47 -12
  120. package/dist/core/doctor/legacy-global-hook-cleanup.js +179 -0
  121. package/dist/core/feature-fixture-executor.js +71 -7
  122. package/dist/core/feature-fixture-runner.js +53 -12
  123. package/dist/core/feature-fixtures.js +47 -14
  124. package/dist/core/feature-registry.js +53 -58
  125. package/dist/core/fsx.js +54 -6
  126. package/dist/core/harness-conflicts.js +19 -10
  127. package/dist/core/hooks-runtime/code-pack-freshness-preflight.js +5 -4
  128. package/dist/core/hooks-runtime/hook-invocation-dedupe.js +147 -0
  129. package/dist/core/hooks-runtime/hook-io.js +14 -4
  130. package/dist/core/hooks-runtime/light-turn.js +70 -0
  131. package/dist/core/hooks-runtime/payload-signals.js +270 -0
  132. package/dist/core/hooks-runtime/team-digest.js +0 -1
  133. package/dist/core/hooks-runtime/tool-output-quarantine.js +93 -0
  134. package/dist/core/hooks-runtime.js +418 -250
  135. package/dist/core/image/image-artifact-path-contract.js +8 -6
  136. package/dist/core/image/image-artifact-registry.js +5 -1
  137. package/dist/core/image-ux-review/imagegen-adapter.js +5 -2
  138. package/dist/core/imagegen/imagegen-capability.js +10 -13
  139. package/dist/core/imagegen/require-imagegen.js +37 -11
  140. package/dist/core/init/skills.js +16 -30
  141. package/dist/core/init.js +144 -36
  142. package/dist/core/managed-assets/managed-assets-manifest.js +417 -14
  143. package/dist/core/mission.js +24 -1
  144. package/dist/core/naruto/naruto-work-graph.js +70 -4
  145. package/dist/core/ops/reporting.js +3 -0
  146. package/dist/core/pipeline-internals/runtime-core.js +578 -180
  147. package/dist/core/pipeline-internals/runtime-gates.js +191 -49
  148. package/dist/core/ppt/style-tokens.js +1 -1
  149. package/dist/core/ppt-review/index.js +1 -1
  150. package/dist/core/ppt-review/slide-exporter.js +23 -17
  151. package/dist/core/ppt-review/slide-imagegen-review.js +1 -1
  152. package/dist/core/ppt-review/slide-issue-extraction.js +4 -2
  153. package/dist/core/preflight/parallel-preflight-engine.js +50 -1
  154. package/dist/core/product-design-plugin.js +2 -2
  155. package/dist/core/proof/route-finalizer.js +1 -1
  156. package/dist/core/proof/route-proof-gate.js +7 -2
  157. package/dist/core/proof-field.js +3 -3
  158. package/dist/core/provider/model-router.js +38 -32
  159. package/dist/core/recallpulse/policy.js +12 -28
  160. package/dist/core/recallpulse.js +11 -6
  161. package/dist/core/release/gate-manifest.js +18 -12
  162. package/dist/core/release/gate-pack-manifest.js +1 -1
  163. package/dist/core/release/npm-pack-proof.js +247 -0
  164. package/dist/core/release/package-dist-snapshot.js +151 -0
  165. package/dist/core/release/package-size-budget.js +5 -0
  166. package/dist/core/release/release-authorization-snapshot.js +115 -0
  167. package/dist/core/release/release-gate-affected-selector.js +15 -3
  168. package/dist/core/release/release-gate-cache-v2.js +30 -0
  169. package/dist/core/release/release-gate-contract.js +161 -0
  170. package/dist/core/release/release-gate-dag.js +44 -3
  171. package/dist/core/release/release-gate-hermetic-env.js +28 -17
  172. package/dist/core/release/release-real-contract.js +496 -0
  173. package/dist/core/release-parallel-full-coverage.js +31 -143
  174. package/dist/core/research/claim-evidence-matrix.js +41 -6
  175. package/dist/core/research/experiment-plan.js +14 -10
  176. package/dist/core/research/falsification.js +9 -2
  177. package/dist/core/research/implementation-blueprint-densifier.js +82 -60
  178. package/dist/core/research/implementation-blueprint.js +32 -26
  179. package/dist/core/research/mock-result.js +122 -11
  180. package/dist/core/research/replication-pack.js +15 -8
  181. package/dist/core/research/research-adversarial-review.js +1068 -0
  182. package/dist/core/research/research-claim-builder.js +69 -17
  183. package/dist/core/research/research-claim-synthesizer.js +343 -0
  184. package/dist/core/research/research-cycle-runner.js +53 -3
  185. package/dist/core/research/research-falsification-runner.js +176 -0
  186. package/dist/core/research/research-final-reviewer.js +44 -125
  187. package/dist/core/research/research-realistic-report.js +14 -6
  188. package/dist/core/research/research-review-artifact-digest.js +66 -0
  189. package/dist/core/research/research-source-evidence.js +144 -0
  190. package/dist/core/research/research-source-layer-catalog.js +68 -0
  191. package/dist/core/research/research-source-ledger-merge.js +250 -12
  192. package/dist/core/research/research-source-shards.js +26 -70
  193. package/dist/core/research/research-stage-runner.js +237 -247
  194. package/dist/core/research/research-super-search.js +184 -0
  195. package/dist/core/research/research-synthesis-prompt.js +20 -1
  196. package/dist/core/research/research-synthesis-writer.js +86 -5
  197. package/dist/core/research/research-work-graph.js +25 -18
  198. package/dist/core/research/source-quality-report.js +21 -0
  199. package/dist/core/research.js +429 -280
  200. package/dist/core/retention/retention-budget.js +25 -6
  201. package/dist/core/retention.js +980 -101
  202. package/dist/core/routes/constants.js +1 -1
  203. package/dist/core/routes/dollar-manifest-lite.js +11 -11
  204. package/dist/core/routes/evidence.js +4 -4
  205. package/dist/core/routes/ppt-policy.js +1 -1
  206. package/dist/core/routes.js +92 -64
  207. package/dist/core/runtime/task-profile.js +66 -0
  208. package/dist/core/runtime/verification-budget.js +12 -0
  209. package/dist/core/secret-redaction.js +4 -0
  210. package/dist/core/security/high-risk-contracts.js +6 -6
  211. package/dist/core/stop-gate/stop-gate-check.js +49 -12
  212. package/dist/core/subagents/agent-catalog.js +215 -0
  213. package/dist/core/subagents/model-policy.js +118 -0
  214. package/dist/core/subagents/naruto-help-contract.js +40 -0
  215. package/dist/core/subagents/official-subagent-config.js +488 -0
  216. package/dist/core/subagents/official-subagent-preparation.js +251 -0
  217. package/dist/core/subagents/official-subagent-prompt.js +137 -0
  218. package/dist/core/subagents/official-subagent-runner.js +129 -0
  219. package/dist/core/subagents/subagent-evidence.js +663 -0
  220. package/dist/core/subagents/terminology.js +16 -0
  221. package/dist/core/subagents/thread-budget.js +21 -0
  222. package/dist/core/subagents/triwiki-attention.js +65 -0
  223. package/dist/core/super-search/runtime-helpers.js +173 -19
  224. package/dist/core/super-search/runtime.js +140 -15
  225. package/dist/core/super-search/source-records.js +49 -8
  226. package/dist/core/team-review-policy.js +15 -0
  227. package/dist/core/triwiki/code-pack.js +8 -2
  228. package/dist/core/triwiki/triwiki-cache-key.js +108 -29
  229. package/dist/core/triwiki/triwiki-module-card.js +1 -1
  230. package/dist/core/triwiki-attention.js +13 -6
  231. package/dist/core/triwiki-provenance.js +274 -0
  232. package/dist/core/triwiki-runtime.js +21 -7
  233. package/dist/core/triwiki-wrongness/wrongness-ledger.js +187 -61
  234. package/dist/core/triwiki-wrongness/wrongness-retrieval.js +11 -2
  235. package/dist/core/triwiki-wrongness/wrongness-trust-policy.js +2 -0
  236. package/dist/core/update-check.js +23 -15
  237. package/dist/core/version-manager.js +51 -1
  238. package/dist/core/version.js +1 -1
  239. package/dist/core/wiki-coordinate.js +128 -12
  240. package/dist/core/work-order-ledger.js +208 -10
  241. package/dist/core/zellij/zellij-command.js +12 -1
  242. package/dist/core/zellij/zellij-dashboard-pane.js +3 -3
  243. package/dist/core/zellij/zellij-fake-adapter.js +3 -1
  244. package/dist/core/zellij/zellij-launcher.js +51 -21
  245. package/dist/core/zellij/zellij-layout-builder.js +14 -5
  246. package/dist/core/zellij/zellij-official-subagent-activity.js +477 -0
  247. package/dist/core/zellij/zellij-official-subagent-telemetry.js +264 -0
  248. package/dist/core/zellij/zellij-pane-proof.js +32 -6
  249. package/dist/core/zellij/zellij-slot-pane-renderer.js +17 -5
  250. package/dist/core/zellij/zellij-slot-telemetry.js +15 -3
  251. package/dist/core/zellij/zellij-ui-mode.js +1 -1
  252. package/dist/core/zellij/zellij-viewport-binder.js +3 -0
  253. package/dist/core/zellij/zellij-worker-pane-manager.js +5 -3
  254. package/dist/scripts/agent-fast-mode-default-check.js +48 -29
  255. package/dist/scripts/agent-role-config-repair-check.js +34 -15
  256. package/dist/scripts/agent-wiki-context-proof-check.js +16 -2
  257. package/dist/scripts/all-feature-deep-completion-check.js +14 -4
  258. package/dist/scripts/architecture-guard-check.js +8 -1
  259. package/dist/scripts/build-dist.js +17 -5
  260. package/dist/scripts/canonical-test-runner.js +188 -0
  261. package/dist/scripts/check-command-module-budget.js +38 -16
  262. package/dist/scripts/check-legacy-free.js +1 -1
  263. package/dist/scripts/check-route-modularity.js +0 -1
  264. package/dist/scripts/check-ts-contracts.js +1 -1
  265. package/dist/scripts/codex-0139-interrupt-agent-check.js +5 -1
  266. package/dist/scripts/{codex-0142-app-server-v2-check.js → codex-0144-app-server-v2-check.js} +11 -10
  267. package/dist/scripts/{codex-0142-binary-identity-check.js → codex-0144-binary-identity-check.js} +4 -4
  268. package/dist/scripts/codex-0144-capability-check.js +21 -0
  269. package/dist/scripts/{codex-0139-real-probes-check.js → codex-0144-core-real-probes-check.js} +19 -5
  270. package/dist/scripts/{codex-0142-doctor-wiring-check.js → codex-0144-doctor-wiring-check.js} +6 -6
  271. package/dist/scripts/{codex-0142-manifest-check.js → codex-0144-manifest-check.js} +11 -3
  272. package/dist/scripts/{codex-0142-policy-check.js → codex-0144-policy-check.js} +2 -2
  273. package/dist/scripts/{codex-0142-thread-store-check.js → codex-0144-thread-store-check.js} +3 -3
  274. package/dist/scripts/codex-app-provider-model-ui-check.js +53 -19
  275. package/dist/scripts/codex-app-ui-preservation-check.js +35 -4
  276. package/dist/scripts/codex-control-all-pipelines-check.js +7 -3
  277. package/dist/scripts/codex-control-side-effect-scope-check.js +2 -2
  278. package/dist/scripts/codex-control-tool-output-continuity-audit-check.js +27 -0
  279. package/dist/scripts/codex-effort-auto-discovery-check.js +1 -1
  280. package/dist/scripts/codex-lb-fast-mode-truth-check.js +1 -0
  281. package/dist/scripts/{codex-lb-gpt55-fast-profile-check.js → codex-lb-gpt56-fast-profile-check.js} +56 -5
  282. package/dist/scripts/codex-model-metadata-check.js +1 -1
  283. package/dist/scripts/codex-native-agent-role-content-check.js +15 -7
  284. package/dist/scripts/codex-native-repair-transaction-check.js +3 -1
  285. package/dist/scripts/codex-sdk-all-pipelines-check.js +7 -4
  286. package/dist/scripts/codex-sdk-research-pipeline-check.js +30 -8
  287. package/dist/scripts/codex-sdk-sandbox-policy-check.js +5 -1
  288. package/dist/scripts/codex-sdk-version-compat-check.js +2 -1
  289. package/dist/scripts/db-route-materialization-check.js +33 -0
  290. package/dist/scripts/dfix-fixture-check.js +1 -1
  291. package/dist/scripts/docs-truthfulness-check.js +4 -2
  292. package/dist/scripts/doctor-codex-startup-repair-check.js +47 -25
  293. package/dist/scripts/doctor-context7-repair-check.js +2 -1
  294. package/dist/scripts/doctor-fix-production-blackbox.js +12 -2
  295. package/dist/scripts/doctor-fixes-codex-app-fast-ui-check.js +34 -7
  296. package/dist/scripts/doctor-imagegen-repair-check.js +14 -4
  297. package/dist/scripts/doctor-startup-config-repair-blackbox.js +9 -3
  298. package/dist/scripts/doctor-startup-config-repair-check.js +13 -3
  299. package/dist/scripts/install-update-preserves-config-check.js +7 -2
  300. package/dist/scripts/legacy-gate-inventory-check.js +7 -5
  301. package/dist/scripts/legacy-strong-inventory-check.js +7 -5
  302. package/dist/scripts/legacy-upgrade-matrix-check.js +4 -4
  303. package/dist/scripts/lib/native-cli-session-swarm-check-lib.js +173 -13
  304. package/dist/scripts/mad-sks-app-ui-no-mutation-check.js +165 -6
  305. package/dist/scripts/managed-role-manifest-parity-check.js +5 -4
  306. package/dist/scripts/mutation-callsite-coverage-check.js +0 -11
  307. package/dist/scripts/naruto-codex-e2e-check.js +14 -7
  308. package/dist/scripts/naruto-shadow-clone-swarm-check.js +4 -201
  309. package/dist/scripts/npm-publish-performance-check.js +20 -12
  310. package/dist/scripts/official-subagent-workflow-check.js +145 -0
  311. package/dist/scripts/package-published-contract-check.js +6 -20
  312. package/dist/scripts/packlist-performance-check.js +17 -3
  313. package/dist/scripts/parallel-verification-engine-check.js +2 -2
  314. package/dist/scripts/postinstall-safe-side-effects-check.js +8 -3
  315. package/dist/scripts/ppt-no-mock-as-real-check.js +3 -1
  316. package/dist/scripts/prepublish-release-check-or-fast.js +23 -86
  317. package/dist/scripts/product-design-plugin-routing-check.js +1 -1
  318. package/dist/scripts/release-affected-selector-check.js +74 -1
  319. package/dist/scripts/release-check-stamp.js +324 -239
  320. package/dist/scripts/release-dag-full-coverage-check.js +7 -15
  321. package/dist/scripts/release-dynamic-presets-check.js +10 -1
  322. package/dist/scripts/release-gate-dag-runner-check.js +3 -3
  323. package/dist/scripts/release-gate-dag-runner.js +35 -11
  324. package/dist/scripts/release-gate-existence-audit.js +1 -2
  325. package/dist/scripts/release-gate-script-parity-check.js +1 -1
  326. package/dist/scripts/release-parallel-full-coverage-check.js +12 -6
  327. package/dist/scripts/release-parallel-speed-budget-check.js +18 -2
  328. package/dist/scripts/release-real-check.js +390 -157
  329. package/dist/scripts/release-registry-check.js +61 -16
  330. package/dist/scripts/release-runtime-truth-matrix-check.js +22 -0
  331. package/dist/scripts/research-blueprint-densifier-check.js +2 -2
  332. package/dist/scripts/research-real-cycle-no-legacy-final-md-check.js +11 -7
  333. package/dist/scripts/route-proof-artifact-structure-check.js +1 -0
  334. package/dist/scripts/search-visibility-gate-lib.js +1 -1
  335. package/dist/scripts/seo-geo-route-identity-check.js +30 -4
  336. package/dist/scripts/sizecheck.js +4 -4
  337. package/dist/scripts/sks-1-11-gate-lib.js +53 -6
  338. package/dist/scripts/sks-3-1-4-directive-check-lib.js +8 -2
  339. package/dist/scripts/sks-3-1-5-directive-check-lib.js +3 -2
  340. package/dist/scripts/sks-3-1-6-directive-check-lib.js +5 -3
  341. package/dist/scripts/sks-menubar-install-check.js +8 -0
  342. package/dist/scripts/sks-uninstall-regression-check.js +1 -1
  343. package/dist/scripts/sksd-daemon-check.js +16 -6
  344. package/dist/scripts/trust-fixture-check.js +32 -10
  345. package/dist/scripts/write-build-manifest.js +2 -1
  346. package/dist/scripts/wrongness-fixture-check.js +1 -1
  347. package/dist/scripts/zellij-layout-valid-check.js +36 -11
  348. package/dist/scripts/zellij-pane-proof-check.js +33 -2
  349. package/dist/scripts/zellij-real-session-cleanup-check.js +122 -2
  350. package/dist/scripts/zellij-real-session-launch-check.js +76 -5
  351. package/dist/scripts/zellij-slot-pane-renderer-check.js +4 -4
  352. package/dist/scripts/zellij-spawn-on-demand-layout-check.js +3 -3
  353. package/docs/demo.tape +1 -1
  354. package/infra-harness-gates.json +1486 -0
  355. package/package.json +32 -19
  356. package/release-gates.v2.json +4060 -0
  357. package/runtime-required-scripts.json +9 -0
  358. package/schemas/codex/{app-server-0.142 → app-server-0.144}/codex_app_server_protocol.v2.schemas.json +1146 -781
  359. package/schemas/codex/codex-0139-real-probe-result.schema.json +39 -5
  360. package/schemas/codex/ppt-slide-issue-ledger.schema.json +2 -1
  361. package/dist/commands/db.js +0 -6
  362. package/dist/core/codex-control/codex-0139-multi-agent-real-probe.js +0 -107
  363. package/dist/core/commands/db-command.js +0 -146
  364. package/dist/core/research/prompt.js +0 -15
  365. package/dist/scripts/agent-native-release-gate.js +0 -274
  366. package/dist/scripts/codex-0142-capability-check.js +0 -21
  367. package/dist/scripts/codex-control-tool-call-sequence-repair-check.js +0 -14
  368. package/dist/scripts/command-performance-scorecard-check.js +0 -204
  369. package/dist/scripts/config-managed-merge-callsite-coverage-check.js +0 -212
  370. package/dist/scripts/dollar-performance-scorecard-check.js +0 -257
  371. package/dist/scripts/gate-timing-check.js +0 -16
  372. package/dist/scripts/ops-maturity-scorecard-check.js +0 -12
  373. package/dist/scripts/performance-baseline-check.js +0 -12
  374. package/dist/scripts/performance-improvement-report-check.js +0 -58
  375. package/dist/scripts/release-parallel-check.js +0 -389
  376. package/dist/scripts/release-runner-efficiency-check.js +0 -15
  377. package/dist/scripts/retention-long-run-smoke-check.js +0 -299
  378. package/docs/assets/sneakoscope-architecture-pipeline.jpg +0 -0
@@ -1,21 +1,26 @@
1
1
  import path from 'node:path';
2
- import { appendJsonlBounded, nowIso, readJson, writeJsonAtomic, writeTextAtomic } from '../fsx.js';
2
+ import { appendJsonlBounded, exists, nowIso, readJson, readText, writeJsonAtomic, writeTextAtomic } from '../fsx.js';
3
3
  import { runCodexTask } from '../codex-control/codex-task-runner.js';
4
4
  import { buildClaimEvidenceMatrixFromSourceShards } from './research-claim-builder.js';
5
5
  import { writeClaimEvidenceMatrix, validateClaimEvidenceMatrix } from './claim-evidence-matrix.js';
6
+ import { synthesizeResearchClaimEvidenceMatrix } from './research-claim-synthesizer.js';
6
7
  import { defaultExperimentPlan, writeExperimentPlan } from './experiment-plan.js';
7
8
  import { defaultReplicationPack, writeReplicationPack } from './replication-pack.js';
8
9
  import { densifyImplementationBlueprint } from './implementation-blueprint-densifier.js';
9
10
  import { renderImplementationBlueprintMarkdown } from './implementation-blueprint-markdown.js';
10
11
  import { readImplementationBlueprint, validateImplementationBlueprint, writeImplementationBlueprint } from './implementation-blueprint.js';
11
12
  import { writeResearchHandoffArtifacts } from './research-handoff.js';
12
- import { runResearchCodexFinalReviewer, runResearchFinalReviewer, runResearchStaticFinalReview } from './research-final-reviewer.js';
13
+ import { runResearchFinalReviewer, runResearchStaticFinalReview } from './research-final-reviewer.js';
13
14
  import { runResearchCodexSynthesisWriter, validateResearchSynthesisOutput } from './research-synthesis-writer.js';
14
15
  import { buildResearchSourceShardPrompt, defaultResearchSourceShardOutput, researchSourceLayerById, researchSourceShardOutputSchema, validateResearchSourceShardOutput } from './research-source-shards.js';
15
- import { mergeResearchSourceShards } from './research-source-ledger-merge.js';
16
- import { evaluateResearchGate, researchPaperArtifactForPlan, RESEARCH_AGENT_COUNCIL, RESEARCH_GENIUS_SUMMARY_ARTIFACT, researchAgentAgentName, RESEARCH_PAPER_SECTION_GROUPS } from '../research.js';
16
+ import { linkSourceLedgerToClaimMatrix, mergeResearchSourceShards } from './research-source-ledger-merge.js';
17
+ import { writeSourceQualityReport } from './source-quality-report.js';
18
+ import { runResearchFalsification } from './research-falsification-runner.js';
19
+ import { evaluateResearchGate, researchPaperArtifactForPlan, RESEARCH_PAPER_SECTION_GROUPS, RESEARCH_REVIEWER_CUSTOM_AGENT } from '../research.js';
20
+ import { runResearchSuperSearchShard } from './research-super-search.js';
21
+ import { RESEARCH_ADVERSARIAL_PLAN_ARTIFACT, RESEARCH_ADVERSARIAL_REVIEW_ARTIFACT, RESEARCH_CONVERGENCE_GATE_ARTIFACT, RESEARCH_HONEST_MODE_ARTIFACT, RESEARCH_REVISION_LEDGER_ARTIFACT, runResearchAdversarialReviewLoop } from './research-adversarial-review.js';
17
22
  export async function runResearchStage(inputOrDir, legacyStage = null, legacyOpts = {}) {
18
- const input = typeof inputOrDir === 'string'
23
+ let input = typeof inputOrDir === 'string'
19
24
  ? {
20
25
  root: process.cwd(),
21
26
  dir: inputOrDir,
@@ -28,45 +33,56 @@ export async function runResearchStage(inputOrDir, legacyStage = null, legacyOpt
28
33
  mock: legacyOpts.mock === true
29
34
  }
30
35
  : inputOrDir;
36
+ if (Number.isFinite(Number(input.cycleDeadlineMs))) {
37
+ input = {
38
+ ...input,
39
+ timeoutMs: Math.max(0, Math.min(Number(input.timeoutMs || 0), Number(input.cycleDeadlineMs) - Date.now()))
40
+ };
41
+ }
31
42
  const startedAt = nowIso();
32
43
  const stageKind = inferStageKind(input.stage);
33
44
  const stageId = String(input.stage?.id || `${stageKind}-${input.cycle}`);
34
45
  let result;
35
- try {
36
- switch (stageKind) {
37
- case 'source_shard':
38
- result = await runSourceShardStage(input, startedAt);
39
- break;
40
- case 'source_merge':
41
- result = await runSourceMergeStage(input, startedAt);
42
- break;
43
- case 'claim_matrix_build':
44
- result = await runClaimMatrixStage(input, startedAt);
45
- break;
46
- case 'falsification':
47
- result = await runFalsificationStage(input, startedAt);
48
- break;
49
- case 'implementation_blueprint':
50
- result = await runImplementationBlueprintStage(input, startedAt);
51
- break;
52
- case 'experiment_plan':
53
- result = await runExperimentPlanStage(input, startedAt);
54
- break;
55
- case 'synthesis':
56
- result = await runSynthesisStage(input, startedAt);
57
- break;
58
- case 'final_review':
59
- result = await runFinalReviewStage(input, startedAt);
60
- break;
61
- case 'verification':
62
- result = await runVerificationStage(input, startedAt);
63
- break;
64
- default:
65
- result = baseResult(input, startedAt, stageKind, 'blocked', [], [`unknown_stage_kind:${stageKind}`]);
66
- }
46
+ if (input.timeoutMs <= 0) {
47
+ result = baseResult(input, startedAt, stageKind, 'failed', [], ['research_cycle_timeout_exceeded']);
67
48
  }
68
- catch (err) {
69
- result = baseResult(input, startedAt, stageKind, 'failed', [], [err instanceof Error ? err.message : String(err)]);
49
+ else {
50
+ try {
51
+ switch (stageKind) {
52
+ case 'source_shard':
53
+ result = await runSourceShardStage(input, startedAt);
54
+ break;
55
+ case 'source_merge':
56
+ result = await runSourceMergeStage(input, startedAt);
57
+ break;
58
+ case 'claim_matrix_build':
59
+ result = await runClaimMatrixStage(input, startedAt);
60
+ break;
61
+ case 'falsification':
62
+ result = await runFalsificationStage(input, startedAt);
63
+ break;
64
+ case 'implementation_blueprint':
65
+ result = await runImplementationBlueprintStage(input, startedAt);
66
+ break;
67
+ case 'experiment_plan':
68
+ result = await runExperimentPlanStage(input, startedAt);
69
+ break;
70
+ case 'synthesis':
71
+ result = await runSynthesisStage(input, startedAt);
72
+ break;
73
+ case 'final_review':
74
+ result = await runFinalReviewStage(input, startedAt);
75
+ break;
76
+ case 'verification':
77
+ result = await runVerificationStage(input, startedAt);
78
+ break;
79
+ default:
80
+ result = baseResult(input, startedAt, stageKind, 'blocked', [], [`unknown_stage_kind:${stageKind}`]);
81
+ }
82
+ }
83
+ catch (err) {
84
+ result = baseResult(input, startedAt, stageKind, 'failed', [], [err instanceof Error ? err.message : String(err)]);
85
+ }
70
86
  }
71
87
  if (result.status === 'passed' && result.output_artifacts.length === 0) {
72
88
  result = { ...result, status: 'blocked', blockers: [...result.blockers, 'stage_output_artifacts_missing'] };
@@ -93,6 +109,29 @@ async function runSourceShardStage(input, startedAt) {
93
109
  await writeTextAtomic(path.join(input.dir, 'research', `cycle-${input.cycle}`, 'source-notes', `${layer.id}.md`), `# Source shard: ${layer.label}\n\n${output.sources.map((source) => `- ${source.id}: ${source.title}`).join('\n')}\n`);
94
110
  return baseResult(input, startedAt, 'source_shard', validation.ok ? 'passed' : 'blocked', [artifact, `research/cycle-${input.cycle}/source-notes/${layer.id}.md`], validation.blockers, { layer_id: layer.id, source_count: output.sources.length, source_tool_route: researchSourceToolRoute(input.plan) });
95
111
  }
112
+ if (layer.id !== 'local_project_evidence') {
113
+ const output = await runResearchSuperSearchShard({
114
+ root: input.root,
115
+ dir: input.dir,
116
+ plan: input.plan,
117
+ layer,
118
+ cycle: input.cycle,
119
+ timeoutMs: input.timeoutMs,
120
+ ...(input.cycleDeadlineMs === undefined ? {} : { deadlineMs: input.cycleDeadlineMs })
121
+ });
122
+ const validation = validateResearchSourceShardOutput(output);
123
+ const blockers = [...new Set([...validation.blockers, ...output.blockers])];
124
+ await writeJsonAtomic(path.join(input.dir, artifact), output);
125
+ await writeTextAtomic(path.join(input.dir, 'research', `cycle-${input.cycle}`, 'source-notes', `${layer.id}.md`), `# Super Search source shard: ${layer.label}\n\n${output.sources.map((source) => `- ${source.id}: ${source.title} (${source.locator})`).join('\n')}\n\nBlockers: ${blockers.join(', ') || 'none'}\n`);
126
+ return baseResult(input, startedAt, 'source_shard', blockers.length ? 'blocked' : 'passed', [artifact, `research/cycle-${input.cycle}/source-notes/${layer.id}.md`, output.super_search?.proof_artifact || ''].filter(Boolean), blockers, {
127
+ layer_id: layer.id,
128
+ source_count: output.sources.length,
129
+ verified_source_count: output.super_search?.verified_sources || 0,
130
+ source_tool_route: output.super_search?.provider_independent
131
+ ? 'super-search-provider-independent'
132
+ : 'super-search-verified-runtime'
133
+ });
134
+ }
96
135
  const codex = await runResearchCodexStage({
97
136
  root: input.root,
98
137
  dir: input.dir,
@@ -102,7 +141,8 @@ async function runSourceShardStage(input, startedAt) {
102
141
  outputSchema: researchSourceShardOutputSchema,
103
142
  outputArtifact: artifact,
104
143
  backendPreference: input.backend === 'python-codex-sdk' ? ['python-codex-sdk', 'codex-sdk'] : input.backend === 'local-llm' ? ['local-llm', 'codex-sdk'] : ['codex-sdk', 'python-codex-sdk'],
105
- timeoutMs: input.timeoutMs
144
+ timeoutMs: input.timeoutMs,
145
+ ...(input.cycleDeadlineMs === undefined ? {} : { deadlineMs: input.cycleDeadlineMs })
106
146
  });
107
147
  return codex;
108
148
  }
@@ -114,14 +154,56 @@ async function runClaimMatrixStage(input, startedAt) {
114
154
  const sourceLedger = await readJson(path.join(input.dir, 'source-ledger.json'), null);
115
155
  const noveltyLedger = await readJson(path.join(input.dir, 'novelty-ledger.json'), null);
116
156
  const falsificationLedger = await readJson(path.join(input.dir, 'falsification-ledger.json'), null);
117
- const matrix = await buildClaimEvidenceMatrixFromSourceShards({ dir: input.dir, cycle: input.cycle, plan: input.plan, sourceLedger, noveltyLedger, falsificationLedger });
157
+ const generated = input.mock || input.backend === 'mock' || input.backend === 'deterministic'
158
+ ? {
159
+ matrix: await buildClaimEvidenceMatrixFromSourceShards({ dir: input.dir, cycle: input.cycle, plan: input.plan, sourceLedger, noveltyLedger, falsificationLedger }),
160
+ blockers: [],
161
+ worker_result_path: null
162
+ }
163
+ : await synthesizeResearchClaimEvidenceMatrix({
164
+ root: input.root,
165
+ dir: input.dir,
166
+ plan: input.plan,
167
+ sourceLedger,
168
+ timeoutMs: input.timeoutMs,
169
+ ...(input.cycleDeadlineMs === undefined ? {} : { deadlineMs: input.cycleDeadlineMs }),
170
+ backendPreference: input.backend === 'python-codex-sdk' ? ['python-codex-sdk', 'codex-sdk'] : ['codex-sdk', 'python-codex-sdk']
171
+ });
172
+ const matrix = generated.matrix;
118
173
  await writeClaimEvidenceMatrix(input.dir, matrix);
119
- const validation = validateClaimEvidenceMatrix(matrix, sourceLedger, falsificationLedger);
120
- return baseResult(input, startedAt, 'claim_matrix_build', validation.ok ? 'passed' : 'blocked', ['claim-evidence-matrix.json'], validation.blockers, { key_claims: matrix.key_claim_ids.length, triangulated_claims: matrix.triangulated_claim_count });
174
+ const linkedSourceLedger = linkSourceLedgerToClaimMatrix(sourceLedger, matrix);
175
+ await writeJsonAtomic(path.join(input.dir, 'source-ledger.json'), linkedSourceLedger);
176
+ await writeSourceQualityReport(input.dir, linkedSourceLedger, matrix);
177
+ const validation = validateClaimEvidenceMatrix(matrix, linkedSourceLedger, falsificationLedger);
178
+ const blockers = [...new Set([...(generated.blockers || []), ...validation.blockers])];
179
+ return baseResult(input, startedAt, 'claim_matrix_build', blockers.length ? 'blocked' : 'passed', ['claim-evidence-matrix.json', 'source-ledger.json', 'source-quality-report.json'], blockers, {
180
+ key_claims: matrix.key_claim_ids.length,
181
+ triangulated_claims: matrix.triangulated_claim_count,
182
+ semantic_claim_synthesis: !(input.mock || input.backend === 'mock' || input.backend === 'deterministic'),
183
+ worker_result_path: generated.worker_result_path
184
+ });
121
185
  }
122
186
  async function runFalsificationStage(input, startedAt) {
123
187
  const matrix = await readJson(path.join(input.dir, 'claim-evidence-matrix.json'), null);
124
188
  const sourceLedger = await readJson(path.join(input.dir, 'source-ledger.json'), null);
189
+ if (!(input.mock || input.backend === 'mock' || input.backend === 'deterministic')) {
190
+ const ledger = await runResearchFalsification({
191
+ root: input.root,
192
+ dir: input.dir,
193
+ plan: input.plan,
194
+ claimMatrix: matrix,
195
+ sourceLedger,
196
+ timeoutMs: input.timeoutMs,
197
+ ...(input.cycleDeadlineMs === undefined ? {} : { deadlineMs: input.cycleDeadlineMs }),
198
+ backendPreference: input.backend === 'python-codex-sdk' ? ['python-codex-sdk', 'codex-sdk'] : ['codex-sdk', 'python-codex-sdk']
199
+ });
200
+ await writeJsonAtomic(path.join(input.dir, 'falsification-ledger.json'), ledger);
201
+ return baseResult(input, startedAt, 'falsification', ledger.blockers.length ? 'blocked' : 'passed', ['falsification-ledger.json'], ledger.blockers, {
202
+ cases: ledger.cases.length,
203
+ execution_class: 'real',
204
+ worker_result_path: ledger.worker_result_path
205
+ });
206
+ }
125
207
  const counterIds = (Array.isArray(sourceLedger?.counterevidence_sources) ? sourceLedger.counterevidence_sources : []).map((source) => source.id).filter(Boolean);
126
208
  const claims = Array.isArray(matrix?.claims) ? matrix.claims : [];
127
209
  const cases = claims.slice(0, 4).map((claim, index) => ({
@@ -129,19 +211,22 @@ async function runFalsificationStage(input, startedAt) {
129
211
  target_claim: claim.id,
130
212
  attack: `Stress ${claim.id} against missing layer coverage, counterevidence absence, and replication failure.`,
131
213
  source_ids: [counterIds[index % Math.max(1, counterIds.length)] || claim.counterevidence_ids?.[0] || claim.source_ids?.[0]].filter(Boolean),
132
- result: 'survives_with_explicit_gate_requirement',
214
+ result: 'survives',
215
+ reasoning: 'Deterministic mock fixture only; no live scientific conclusion is implied.',
216
+ limitations: ['mock_fixture'],
133
217
  next_decisive_test: claim.test_or_probe || `Run decisive falsification probe ${index + 1}.`
134
218
  }));
135
219
  const ledger = {
136
220
  schema_version: 1,
137
221
  schema: 'sks.falsification-ledger.v1',
138
222
  created_at: nowIso(),
223
+ execution_class: 'mock_fixture',
139
224
  cases,
140
225
  unresolved_failures: [],
141
226
  next_decisive_tests: cases.map((row) => row.next_decisive_test)
142
227
  };
143
228
  await writeJsonAtomic(path.join(input.dir, 'falsification-ledger.json'), ledger);
144
- return baseResult(input, startedAt, 'falsification', cases.length >= 4 ? 'passed' : 'blocked', ['falsification-ledger.json'], cases.length >= 4 ? [] : ['falsification_cases_below_contract'], { cases: cases.length });
229
+ return baseResult(input, startedAt, 'falsification', cases.length >= 4 ? 'passed' : 'blocked', ['falsification-ledger.json'], cases.length >= 4 ? [] : ['falsification_cases_below_contract'], { cases: cases.length, execution_class: 'mock_fixture' });
145
230
  }
146
231
  async function runImplementationBlueprintStage(input, startedAt) {
147
232
  const claimMatrix = await readJson(path.join(input.dir, 'claim-evidence-matrix.json'), null);
@@ -163,8 +248,10 @@ async function runImplementationBlueprintStage(input, startedAt) {
163
248
  return baseResult(input, startedAt, 'implementation_blueprint', validation.ok ? 'passed' : 'blocked', ['implementation-blueprint.json', 'implementation-blueprint.md', 'team-handoff-goal.md'], validation.blockers, validation);
164
249
  }
165
250
  async function runExperimentPlanStage(input, startedAt) {
166
- const experimentPlan = defaultExperimentPlan(input.plan);
167
- const replicationPack = defaultReplicationPack(input.plan);
251
+ const claimMatrix = await readJson(path.join(input.dir, 'claim-evidence-matrix.json'), null);
252
+ const sourceLedger = await readJson(path.join(input.dir, 'source-ledger.json'), null);
253
+ const experimentPlan = defaultExperimentPlan(input.plan, { claimMatrix, sourceLedger });
254
+ const replicationPack = defaultReplicationPack(input.plan, { experimentPlan, claimMatrix });
168
255
  await writeExperimentPlan(input.dir, experimentPlan);
169
256
  await writeReplicationPack(input.dir, replicationPack);
170
257
  return baseResult(input, startedAt, 'experiment_plan', 'passed', ['experiment-plan.json', 'experiment-plan.md', 'replication-pack.json'], [], { steps: experimentPlan.steps.length, replication_commands: replicationPack.commands.length });
@@ -189,15 +276,13 @@ async function runSynthesisStage(input, startedAt) {
189
276
  falsifiability: 3,
190
277
  source_ids: claim.source_ids || [],
191
278
  counterevidence_ids: claim.counterevidence_ids || [],
279
+ counterevidence_links: claim.counterevidence_links || [],
192
280
  evidence: claim.source_ids || [],
193
281
  falsifiers: claim.counterevidence_ids || [],
194
282
  next_experiment: claim.test_or_probe || `Replicate ${claim.id} against source shard evidence.`
195
283
  }))
196
284
  };
197
285
  await writeJsonAtomic(path.join(input.dir, 'novelty-ledger.json'), noveltyLedger);
198
- await writeJsonAtomic(path.join(input.dir, 'agent-ledger.json'), buildAgentLedger(input.plan, sourceIds));
199
- await writeJsonAtomic(path.join(input.dir, 'debate-ledger.json'), buildDebateLedger(sourceIds));
200
- await writeTextAtomic(path.join(input.dir, RESEARCH_GENIUS_SUMMARY_ARTIFACT), buildGeniusSummary(input.plan));
201
286
  if (input.mock || input.backend === 'mock' || input.backend === 'deterministic') {
202
287
  return runDeterministicMockSynthesisStage(input, startedAt, { claimMatrix, sourceLedger, contract, claims, sourceIds });
203
288
  }
@@ -207,6 +292,7 @@ async function runSynthesisStage(input, startedAt) {
207
292
  plan: input.plan,
208
293
  cycle: input.cycle,
209
294
  timeoutMs: input.timeoutMs,
295
+ ...(input.cycleDeadlineMs === undefined ? {} : { deadlineMs: input.cycleDeadlineMs }),
210
296
  backendPreference: input.backend === 'python-codex-sdk' ? ['python-codex-sdk', 'codex-sdk'] : ['codex-sdk', 'python-codex-sdk']
211
297
  });
212
298
  const validation = validateResearchSynthesisOutput(synthesis, contract, claimMatrix, sourceLedger);
@@ -219,13 +305,14 @@ async function runDeterministicMockSynthesisStage(input, startedAt, artifacts) {
219
305
  plan: { ...input.plan, backend: input.backend },
220
306
  cycle: input.cycle,
221
307
  timeoutMs: input.timeoutMs,
308
+ ...(input.cycleDeadlineMs === undefined ? {} : { deadlineMs: input.cycleDeadlineMs }),
222
309
  mock: true
223
310
  });
224
311
  const validation = validateResearchSynthesisOutput(synthesis, artifacts.contract, artifacts.claimMatrix, artifacts.sourceLedger);
225
312
  return synthesisStageResult(input, startedAt, synthesis, validation, input.backend === 'deterministic' ? 'deterministic' : 'mock');
226
313
  }
227
314
  function synthesisStageResult(input, startedAt, synthesis, validation, writer) {
228
- const artifacts = ['research-synthesis-output.json', 'research-report.md', researchPaperArtifactForPlan(input.plan), RESEARCH_GENIUS_SUMMARY_ARTIFACT, 'agent-ledger.json', 'debate-ledger.json', 'novelty-ledger.json'];
315
+ const artifacts = ['research-synthesis-output.json', 'research-report.md', researchPaperArtifactForPlan(input.plan), 'novelty-ledger.json'];
229
316
  const blockers = [...new Set([...(validation.blockers || []), ...(synthesis.blockers || [])])];
230
317
  return baseResult(input, startedAt, 'synthesis', validation.ok && blockers.length === 0 ? 'passed' : 'blocked', artifacts, blockers, {
231
318
  synthesis_writer: writer === 'codex' ? 'codex-sdk' : writer,
@@ -236,21 +323,42 @@ function synthesisStageResult(input, startedAt, synthesis, validation, writer) {
236
323
  }
237
324
  async function runFinalReviewStage(input, startedAt) {
238
325
  const staticReview = await runResearchStaticFinalReview(input.dir, { plan: input.plan });
239
- const codexReview = await runResearchCodexFinalReviewer({
326
+ const adversarial = await runResearchAdversarialReviewLoop({
240
327
  root: input.root,
241
328
  dir: input.dir,
242
329
  plan: input.plan,
243
- staticReview,
244
- backendPreference: input.backend === 'python-codex-sdk' ? ['python-codex-sdk', 'codex-sdk'] : ['codex-sdk', 'python-codex-sdk'],
245
330
  timeoutMs: input.timeoutMs,
246
- mock: input.mock || input.backend === 'mock' || input.backend === 'deterministic'
331
+ ...(input.cycleDeadlineMs === undefined ? {} : { deadlineMs: input.cycleDeadlineMs }),
332
+ ...(input.maxReviewCycles === undefined ? {} : { maxCycles: input.maxReviewCycles }),
333
+ ...(input.maxReviewThreads === undefined ? {} : { maxThreads: input.maxReviewThreads }),
334
+ mock: input.mock || input.backend === 'mock' || input.backend === 'deterministic',
335
+ preliminaryBlockers: staticReview.approved === true ? [] : staticReview.blockers
247
336
  });
248
337
  const merged = await runResearchFinalReviewer(input.dir, { plan: input.plan, root: input.root, mock: input.mock || input.backend === 'mock' || input.backend === 'deterministic' });
249
- const status = merged.approved === true && codexReview?.verdict === 'approve' ? 'passed' : 'blocked';
250
- return baseResult(input, startedAt, 'final_review', status, ['research-final-review.static.json', 'research-final-review.codex.json', 'research-final-review.json'], merged.blockers || [], { approved: merged.approved === true, codex_verdict: codexReview?.verdict || null });
338
+ const status = merged.approved === true && adversarial.gate?.passed === true ? 'passed' : 'blocked';
339
+ return baseResult(input, startedAt, 'final_review', status, [
340
+ 'research-final-review.static.json',
341
+ 'research-final-review.codex.json',
342
+ 'research-final-review.json',
343
+ RESEARCH_ADVERSARIAL_PLAN_ARTIFACT,
344
+ RESEARCH_ADVERSARIAL_REVIEW_ARTIFACT,
345
+ RESEARCH_REVISION_LEDGER_ARTIFACT,
346
+ RESEARCH_CONVERGENCE_GATE_ARTIFACT,
347
+ RESEARCH_HONEST_MODE_ARTIFACT,
348
+ 'agent-ledger.json',
349
+ 'debate-ledger.json',
350
+ 'genius-opinion-summary.md'
351
+ ], merged.blockers || [], {
352
+ approved: merged.approved === true,
353
+ official_subagent_review: true,
354
+ review_cycles: adversarial.gate?.review_cycles || 0,
355
+ revision_cycles: adversarial.gate?.revision_cycles || 0,
356
+ unresolved_critical_objections: adversarial.gate?.unresolved_critical_objections ?? null,
357
+ all_reviewers_approved: adversarial.gate?.all_reviewers_approved === true
358
+ });
251
359
  }
252
360
  async function runVerificationStage(input, startedAt) {
253
- const gateSeed = await buildResearchGateSeed(input.dir, input.plan);
361
+ const gateSeed = await buildResearchGateSeed(input.dir, input.plan, input);
254
362
  await writeJsonAtomic(path.join(input.dir, 'research-gate.json'), gateSeed);
255
363
  const evaluated = await evaluateResearchGate(input.dir);
256
364
  return baseResult(input, startedAt, 'verification', evaluated.passed ? 'passed' : 'blocked', ['research-gate.json', 'research-gate.evaluated.json'], evaluated.reasons || [], evaluated.metrics || {});
@@ -285,7 +393,12 @@ export async function runResearchCodexStage(input) {
285
393
  allowLocalLlm: input.backendPreference.includes('local-llm'),
286
394
  localLlmPolicy: input.backendPreference.includes('local-llm') ? { mode: 'local_preferred', requiresGptFinal: true } : { mode: 'disabled', requiresGptFinal: true },
287
395
  mutationLedgerRoot: path.join(input.dir, 'research', 'codex-stage-control', stageId),
288
- reliabilityPolicy: { timeoutClass: 'standard', idleTimeoutMs: input.timeoutMs }
396
+ reliabilityPolicy: {
397
+ timeoutClass: 'standard',
398
+ idleTimeoutMs: input.timeoutMs,
399
+ hardTimeoutMs: input.timeoutMs,
400
+ ...(input.deadlineMs === undefined ? {} : { deadlineEpochMs: input.deadlineMs })
401
+ }
289
402
  });
290
403
  const worker = await readJson(result.workerResultPath, null);
291
404
  if (Array.isArray(worker?.patch_envelopes) && worker.patch_envelopes.length) {
@@ -343,206 +456,83 @@ function baseResult(input, startedAt, stageKind, status, outputArtifacts, blocke
343
456
  function researchSourceToolRoute(plan) {
344
457
  return plan?.web_research_policy?.source_tool_routing?.mode || (plan?.codex_app_execution_profile?.plugin_mcp_inventory_ready ? 'plugin-mcp-inventory-first' : 'codex-cli-or-web-fallback');
345
458
  }
346
- async function buildResearchGateSeed(dir, plan) {
459
+ async function buildResearchGateSeed(dir, plan, input) {
347
460
  const sourceLedger = await readJson(path.join(dir, 'source-ledger.json'), null);
348
461
  const claimMatrix = await readJson(path.join(dir, 'claim-evidence-matrix.json'), null);
349
462
  const finalReview = await readJson(path.join(dir, 'research-final-review.json'), null);
463
+ const adversarialGate = await readJson(path.join(dir, RESEARCH_CONVERGENCE_GATE_ARTIFACT), null);
464
+ const honest = await readJson(path.join(dir, RESEARCH_HONEST_MODE_ARTIFACT), null);
465
+ const agentLedger = await readJson(path.join(dir, 'agent-ledger.json'), null);
466
+ const debateLedger = await readJson(path.join(dir, 'debate-ledger.json'), null);
467
+ const falsificationLedger = await readJson(path.join(dir, 'falsification-ledger.json'), null);
468
+ const experimentPlan = await readJson(path.join(dir, 'experiment-plan.json'), null);
350
469
  const paper = researchPaperArtifactForPlan(plan);
470
+ const sourceRows = [
471
+ ...(Array.isArray(sourceLedger?.sources) ? sourceLedger.sources : []),
472
+ ...(Array.isArray(sourceLedger?.counterevidence_sources) ? sourceLedger.counterevidence_sources : [])
473
+ ];
474
+ const agents = Array.isArray(agentLedger?.agents) ? agentLedger.agents : [];
475
+ const exchanges = Array.isArray(debateLedger?.exchanges) ? debateLedger.exchanges : [];
476
+ const sourceLayers = Array.isArray(sourceLedger?.source_layers) ? sourceLedger.source_layers : [];
477
+ const falsificationCases = Array.isArray(falsificationLedger?.cases) ? falsificationLedger.cases : [];
478
+ const experimentSteps = Array.isArray(experimentPlan?.steps) ? experimentPlan.steps : [];
479
+ const reportPresent = await exists(path.join(dir, 'research-report.md'));
480
+ const paperText = await readText(path.join(dir, paper), '');
481
+ const summaryPresent = await exists(path.join(dir, 'genius-opinion-summary.md'));
351
482
  return {
352
- passed: finalReview?.approved === true,
353
- report_present: true,
483
+ passed: finalReview?.approved === true && adversarialGate?.passed === true,
484
+ execution_class: input.mock || input.backend === 'mock' || input.backend === 'deterministic' ? 'mock_fixture' : 'real',
485
+ report_present: reportPresent,
354
486
  research_paper_artifact: paper,
355
- paper_present: true,
356
- paper_sections: RESEARCH_PAPER_SECTION_GROUPS.length,
357
- genius_opinion_summary_present: true,
358
- genius_opinion_summaries: RESEARCH_AGENT_COUNCIL.length,
359
- research_source_skill_present: true,
360
- source_ledger_present: true,
361
- agent_ledger_present: true,
362
- debate_ledger_present: true,
363
- novelty_ledger_present: true,
364
- falsification_ledger_present: true,
365
- web_search_passes: 1,
366
- source_entries: (Array.isArray(sourceLedger?.sources) ? sourceLedger.sources.length : 0) + (Array.isArray(sourceLedger?.counterevidence_sources) ? sourceLedger.counterevidence_sources.length : 0),
367
- source_layers_required: Array.isArray(sourceLedger?.source_layers) ? sourceLedger.source_layers.length : 0,
368
- source_layers_covered: Array.isArray(sourceLedger?.source_layers) ? sourceLedger.source_layers.filter((layer) => layer.status === 'covered').length : 0,
487
+ paper_present: Boolean(paperText.trim()),
488
+ paper_sections: RESEARCH_PAPER_SECTION_GROUPS.filter((group) => group.some((heading) => paperText.toLowerCase().includes(heading))).length,
489
+ genius_opinion_summary_present: summaryPresent,
490
+ genius_opinion_summaries: agents.length,
491
+ research_source_skill_present: await exists(path.join(dir, 'research-source-skill.md')),
492
+ source_ledger_present: Boolean(sourceLedger),
493
+ agent_ledger_present: Boolean(agentLedger),
494
+ debate_ledger_present: Boolean(debateLedger),
495
+ novelty_ledger_present: await exists(path.join(dir, 'novelty-ledger.json')),
496
+ falsification_ledger_present: Boolean(falsificationLedger),
497
+ web_search_passes: Number(sourceLedger?.web_search_passes || 0),
498
+ source_entries: sourceRows.length,
499
+ source_layers_required: sourceLayers.length,
500
+ source_layers_covered: sourceLayers.filter((layer) => layer.status === 'covered').length,
369
501
  triangulation_checks: Array.isArray(sourceLedger?.triangulation?.cross_layer_checks) ? sourceLedger.triangulation.cross_layer_checks.length : 0,
370
- independent_agents: RESEARCH_AGENT_COUNCIL.length,
371
- xhigh_agents: RESEARCH_AGENT_COUNCIL.length,
372
- eureka_moments: RESEARCH_AGENT_COUNCIL.length,
373
- agent_findings: RESEARCH_AGENT_COUNCIL.length,
374
- debate_participants: RESEARCH_AGENT_COUNCIL.length,
375
- debate_exchanges: RESEARCH_AGENT_COUNCIL.length,
376
- consensus_iterations: 1,
377
- unanimous_consensus: true,
502
+ independent_agents: agents.filter((agent) => Array.isArray(agent.findings) && agent.findings.length > 0).length,
503
+ xhigh_agents: 0,
504
+ sol_max_policy_agents: agents.filter((agent) => {
505
+ const policy = agent?.model_policy && typeof agent.model_policy === 'object' ? agent.model_policy : agent;
506
+ return policy.custom_agent === RESEARCH_REVIEWER_CUSTOM_AGENT && policy.model === 'gpt-5.6-sol' && (policy.reasoning_effort === 'max' || policy.model_reasoning_effort === 'max');
507
+ }).length,
508
+ eureka_moments: agents.filter((agent) => agent.eureka?.exclamation === 'Eureka!' && String(agent.eureka?.idea || '').trim()).length,
509
+ agent_findings: agents.reduce((sum, agent) => sum + (Array.isArray(agent.findings) ? agent.findings.length : 0), 0),
510
+ debate_participants: new Set(exchanges.flatMap((exchange) => [exchange?.from, exchange?.to].filter(Boolean))).size,
511
+ debate_exchanges: exchanges.length,
512
+ consensus_iterations: Number(debateLedger?.consensus_iterations || adversarialGate?.review_cycles || 0),
513
+ unanimous_consensus: adversarialGate?.passed === true && debateLedger?.unanimous_consensus === true,
378
514
  counterevidence_sources: Array.isArray(sourceLedger?.counterevidence_sources) ? sourceLedger.counterevidence_sources.length : 0,
379
515
  candidate_insights: Array.isArray(claimMatrix?.claims) ? claimMatrix.claims.length : 0,
380
- falsification_passes: 1,
381
- falsification_cases: 4,
382
- testable_predictions: 5,
383
- citation_coverage: true,
384
- web_search_blockers: [],
516
+ falsification_passes: falsificationCases.length ? 1 : 0,
517
+ falsification_cases: falsificationCases.length,
518
+ testable_predictions: experimentSteps.length,
519
+ citation_coverage: sourceLedger?.citation_coverage?.all_key_claims_cited === true,
520
+ web_search_blockers: Array.isArray(sourceLedger?.blockers) ? sourceLedger.blockers : [],
385
521
  unsafe_or_destructive_actions: false,
386
- unsupported_breakthrough_claims: 0,
387
- evidence: ['stage-aware research cycle artifacts'],
388
- notes: ['Research gate seed is re-evaluated deterministically before completion.']
389
- };
390
- }
391
- function buildAgentLedger(plan, sourceIds) {
392
- return {
393
- schema_version: 1,
394
- council_mode: 'persona_inspired_agents_not_impersonation',
395
- created_at: nowIso(),
396
- agents: RESEARCH_AGENT_COUNCIL.map((agent, index) => ({
397
- id: agent.id,
398
- agent_name: researchAgentAgentName(agent),
399
- display_name: agent.display_name || agent.label,
400
- historical_inspiration: agent.historical_inspiration || null,
401
- persona: agent.persona || agent.role,
402
- persona_boundary: agent.persona_boundary || 'persona-inspired cognitive lens only',
403
- role: agent.role,
404
- mandate: agent.mandate,
405
- effort: 'xhigh',
406
- reasoning_effort: 'xhigh',
407
- service_tier: 'fast',
408
- eureka: {
409
- exclamation: 'Eureka!',
410
- idea: `${researchAgentAgentName(agent)} links source shard ${sourceIds[index % Math.max(1, sourceIds.length)] || 'source'} to a falsifiable research runtime claim.`,
411
- why_it_matters: 'It keeps synthesis tied to evidence rather than summary length.',
412
- source_ids: [sourceIds[index % Math.max(1, sourceIds.length)]].filter(Boolean)
413
- },
414
- query_set: [],
415
- findings: [{ id: `${agent.id}-stage-finding`, claim: `Stage-aware research runtime requires cited source shards for ${plan?.prompt || 'the mission'}.`, source_ids: [sourceIds[index % Math.max(1, sourceIds.length)]].filter(Boolean), status: 'supported' }],
416
- falsifiers: ['A summary-only report without source shard evidence must fail.'],
417
- cheap_probes: ['Run the stage-cycle runtime blackbox and check source shard outputs.'],
418
- challenge_or_response: 'Participated in the evidence-bound stage runtime debate.'
419
- })),
420
- synthesis: {
421
- surviving_claims: ['stage-aware-runtime'],
422
- downgraded_claims: [],
423
- unresolved_conflicts: []
424
- }
425
- };
426
- }
427
- function buildDebateLedger(sourceIds) {
428
- return {
429
- schema_version: 1,
430
- created_at: nowIso(),
431
- mode: 'vigorous_evidence_bound_debate_until_unanimous_consensus',
432
- required_participants: RESEARCH_AGENT_COUNCIL.map((agent) => agent.id),
433
- participant_display_names: RESEARCH_AGENT_COUNCIL.map((agent) => researchAgentAgentName(agent)),
434
- consensus_iterations: 1,
435
- unanimous_consensus: true,
436
- agent_agreements: RESEARCH_AGENT_COUNCIL.map((agent) => ({
437
- agent_id: agent.id,
438
- agent_name: researchAgentAgentName(agent),
439
- display_name: agent.display_name || agent.label,
440
- agrees: true,
441
- final_position: 'Agrees that source-shard runtime evidence is required before synthesis.',
442
- source_ids: sourceIds.slice(0, 2)
443
- })),
444
- exchanges: RESEARCH_AGENT_COUNCIL.map((agent, index) => ({
445
- id: `stage-debate-${index + 1}`,
446
- from: agent.id,
447
- to: RESEARCH_AGENT_COUNCIL[(index + 1) % RESEARCH_AGENT_COUNCIL.length]?.id || 'research_verifier',
448
- stance: index % 2 ? 'response' : 'challenge',
449
- claim: 'The research package must fail if source shards, claim matrix, or final review are missing.',
450
- source_ids: [sourceIds[index % Math.max(1, sourceIds.length)]].filter(Boolean)
451
- })),
452
- synthesis_pressure: {
453
- strongest_disagreement: 'Whether deterministic gates are enough without a Codex/GPT reviewer.',
454
- changed_minds: ['Accepted that final review must include static plus Codex/GPT evidence.'],
455
- unresolved_conflicts: []
456
- }
522
+ unsupported_breakthrough_claims: Array.isArray(honest?.overclaims) ? honest.overclaims.length : 1,
523
+ official_subagent_review: adversarialGate,
524
+ honest_mode: honest,
525
+ evidence: [
526
+ 'source-ledger.json',
527
+ 'claim-evidence-matrix.json',
528
+ RESEARCH_ADVERSARIAL_REVIEW_ARTIFACT,
529
+ RESEARCH_REVISION_LEDGER_ARTIFACT,
530
+ RESEARCH_CONVERGENCE_GATE_ARTIFACT,
531
+ RESEARCH_HONEST_MODE_ARTIFACT
532
+ ],
533
+ notes: ['Counts and consensus are projected from recorded artifacts; no reviewer success is inferred from lifecycle completion alone.']
457
534
  };
458
535
  }
459
- function buildGeniusSummary(plan) {
460
- return [
461
- '# Genius Opinion Summary',
462
- '',
463
- `Prompt: ${plan?.prompt || ''}`,
464
- '',
465
- ...RESEARCH_AGENT_COUNCIL.flatMap((agent) => [
466
- `## ${researchAgentAgentName(agent)} (${agent.id})`,
467
- 'Final opinion: stage-aware research must produce source shard evidence before synthesis.',
468
- 'Strongest evidence: merged source-ledger and claim-evidence matrix.',
469
- 'Disagreement: deterministic gates still need Codex/GPT final reviewer in real mode.',
470
- 'Changed mind: accepted blackbox rejection of summary-only reports as a release requirement.',
471
- ''
472
- ])
473
- ].join('\n');
474
- }
475
- function buildDeterministicMockResearchReport(plan, claims, sourceIds) {
476
- return [
477
- '# SKS Research Report',
478
- '',
479
- `Prompt: ${plan?.prompt || ''}`,
480
- '',
481
- '## Question',
482
- 'Can Research close only after a real stage-aware cycle executes source shards, merges evidence, builds a claim matrix, produces a blueprint, and passes final review?',
483
- '',
484
- '## Methodology',
485
- 'The cycle executes dependency-aware stages. Source shards run before merge, claim matrix follows merged source evidence, falsification attacks key claims, blueprint densification uses repository file maps, and final review combines deterministic checks with Codex/GPT review.',
486
- '',
487
- '## Source Map',
488
- `Merged source ids: ${sourceIds.join(', ')}.`,
489
- '',
490
- '## Key Claims',
491
- ...claims.slice(0, 8).map((claim) => `- ${claim.id}: ${claim.claim} Sources: ${(claim.source_ids || []).join(', ')}. Counterevidence: ${(claim.counterevidence_ids || []).join(', ')}.`),
492
- '',
493
- '## Evidence Matrix Summary',
494
- 'The claim-evidence matrix separates facts, inferences, hypotheses, implementation guidance, source ids, counterevidence ids, triangulation layers, and test probes.',
495
- '',
496
- '## Counterevidence',
497
- 'Counterevidence rows are merged from the counterevidence_factcheck source shard and later used by falsification cases.',
498
- '',
499
- '## Falsification',
500
- 'The falsification stage records at least four attacks against missing layer coverage, missing counterevidence, missing replication, and summary-only synthesis.',
501
- '',
502
- '## Implementation Blueprint',
503
- 'The blueprint is repository-aware and lists existing files, possible new files, API/schema changes, implementation steps, test commands, rollback steps, and parallel work decomposition.',
504
- '',
505
- '## Experiment / Validation Plan',
506
- 'The experiment and replication artifacts define commands and expected outputs for rerunning the research package gates.',
507
- '',
508
- '## Limitations',
509
- 'Deterministic or mock stages prove runtime contract behavior only. Real non-mock runs must keep the gate blocked if Codex/GPT reviewer or source access is unavailable.',
510
- '',
511
- '## References',
512
- ...sourceIds.map((id) => `- ${id}`),
513
- ''
514
- ].join('\n\n') + '\n';
515
- }
516
- function buildDeterministicMockResearchPaper(plan, sourceIds) {
517
- return [
518
- `# Research Paper: ${plan?.prompt || 'Stage-aware research runtime'}`,
519
- '',
520
- '## Abstract',
521
- 'A research runtime is public-ready only when source evidence and final review are executed as stages rather than inferred from long prose.',
522
- '',
523
- '## Introduction',
524
- `This paper summarizes the stage-aware research package with references such as ${sourceIds.slice(0, 3).join(', ')}.`,
525
- '',
526
- '## Methodology',
527
- 'Source shard stages run in parallel, source merge deduplicates rows, claim matrix construction uses merged sources, and final review follows synthesis.',
528
- '',
529
- '## Findings',
530
- 'The core finding is that a summary-only report must remain blocked even if it is fluent or long.',
531
- '',
532
- '## Discussion',
533
- 'Parallel source shard execution gives the gate concrete evidence to inspect, while the blueprint keeps implementation separate from Research.',
534
- '',
535
- '## Limitations and Falsification',
536
- 'The claim fails if the run lacks counterevidence, missing-source blockers, or Codex/GPT review evidence.',
537
- '',
538
- '## Conclusion and Next Experiment',
539
- 'Run the blackbox fixtures and compare summary-only rejection against a complete package pass.',
540
- '',
541
- '## References',
542
- ...sourceIds.slice(0, 12).map((id) => `- [${id}] Source ledger row.`),
543
- ''
544
- ].join('\n');
545
- }
546
536
  function normalizeStringList(value) {
547
537
  return [...new Set((Array.isArray(value) ? value : value == null ? [] : [value]).map((item) => String(item || '').trim()).filter(Boolean))];
548
538
  }