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,4 +1,5 @@
1
1
  import { normalizeClaimEvidenceMatrix } from './claim-evidence-matrix.js';
2
+ import { sha256 } from '../fsx.js';
2
3
  export async function buildClaimEvidenceMatrixFromSourceShards(input) {
3
4
  const sources = [
4
5
  ...(Array.isArray(input.sourceLedger?.sources) ? input.sourceLedger.sources : []),
@@ -17,50 +18,77 @@ export async function buildClaimEvidenceMatrixFromSourceShards(input) {
17
18
  importance: candidates.size < 2 ? 'critical' : 'high',
18
19
  source_ids: normalizeStringList(entry?.source_ids || entry?.evidence),
19
20
  counterevidence_ids: normalizeStringList(entry?.counterevidence_ids || entry?.falsifiers),
20
- test_or_probe: String(entry?.next_experiment || entry?.test_or_probe || '').trim()
21
+ counterevidence_links: normalizeCounterevidenceLinks(entry?.counterevidence_links),
22
+ test_or_probe: String(entry?.next_experiment || entry?.test_or_probe || '').trim(),
23
+ trusted_grouping: true
21
24
  });
22
25
  }
23
26
  for (const source of sources) {
24
27
  const claimIds = normalizeStringList(source?.claim_ids);
25
- if (claimIds.length) {
28
+ const usable = usableEvidenceSource(source);
29
+ if (claimIds.length && usable) {
26
30
  for (const claimId of claimIds) {
31
+ const sourceSpecific = claimId.startsWith('source-claim-');
27
32
  const existing = candidates.get(claimId) || {
28
33
  id: claimId,
29
34
  claim: claimTextFromSource(source, claimId),
30
35
  claim_type: 'inference',
31
- importance: candidates.size < 2 ? 'critical' : candidates.size < 8 ? 'high' : 'medium',
36
+ importance: sourceSpecific ? 'medium' : candidates.size < 2 ? 'critical' : candidates.size < 8 ? 'high' : 'medium',
32
37
  source_ids: [],
33
38
  counterevidence_ids: [],
34
- test_or_probe: ''
39
+ counterevidence_links: [],
40
+ test_or_probe: '',
41
+ trusted_grouping: sourceSpecific ? false : deterministicFixtureSource(source)
35
42
  };
36
- if (source?.stance === 'undermines')
43
+ if (source?.stance === 'undermines') {
37
44
  existing.counterevidence_ids = [...new Set([...(existing.counterevidence_ids || []), source.id])];
38
- else
45
+ const targetClaimIds = normalizeStringList([
46
+ ...normalizeStringList(source?.counterevidence_target_claim_ids),
47
+ source?.counterevidence_target_claim_id
48
+ ]);
49
+ if (targetClaimIds.includes(claimId) && String(source?.contradiction_rationale || '').trim()) {
50
+ existing.counterevidence_links = normalizeCounterevidenceLinks([
51
+ ...(existing.counterevidence_links || []),
52
+ { source_id: source.id, target_claim_id: claimId, contradiction_rationale: source.contradiction_rationale }
53
+ ]);
54
+ }
55
+ }
56
+ else if (source?.stance === 'supports') {
39
57
  existing.source_ids = [...new Set([...(existing.source_ids || []), source.id])];
58
+ }
40
59
  if (!existing.test_or_probe)
41
60
  existing.test_or_probe = `Probe ${claimId} against supporting and undermining source layers.`;
42
61
  candidates.set(claimId, existing);
43
62
  }
44
63
  }
45
64
  else if (String(source?.notes || '').trim()) {
46
- const id = `hypothesis-${candidates.size + 1}`;
65
+ const id = `unlinked-source-${sha256(`${String(source?.id || '')}\0${String(source?.notes || '')}`).slice(0, 12)}`;
47
66
  candidates.set(id, {
48
67
  id,
49
68
  claim: String(source.notes).slice(0, 240),
50
69
  claim_type: 'hypothesis',
51
70
  importance: 'medium',
52
- source_ids: source?.stance === 'undermines' ? [] : [source.id].filter(Boolean),
53
- counterevidence_ids: source?.stance === 'undermines' ? [source.id].filter(Boolean) : [],
54
- test_or_probe: `Turn ${source.id || id} notes into a decisive source-backed probe.`
71
+ source_ids: [],
72
+ counterevidence_ids: [],
73
+ counterevidence_links: [],
74
+ test_or_probe: `Establish a semantic claim and direct evidence link for ${source.id || id} before using it.`,
75
+ trusted_grouping: false
55
76
  });
56
77
  }
57
78
  }
58
- const falsificationCounterIds = new Set((Array.isArray(input.falsificationLedger?.cases) ? input.falsificationLedger.cases : [])
59
- .flatMap((row) => [...normalizeStringList(row?.counterevidence_source_ids), ...normalizeStringList(row?.source_ids)]));
60
79
  const claims = [...candidates.values()].slice(0, Math.max(8, candidates.size)).map((candidate, index) => {
61
80
  const sourceIds = normalizeStringList(candidate.source_ids).filter((id) => sourceById(sources, id));
62
- const counterIds = normalizeStringList(candidate.counterevidence_ids).filter((id) => sourceById(sources, id) || falsificationCounterIds.has(id));
81
+ const counterevidenceLinks = normalizeCounterevidenceLinks(candidate.counterevidence_links)
82
+ .filter((link) => link.target_claim_id === candidate.id && sourceById(sources, link.source_id));
83
+ const linkedCounterIds = new Set(counterevidenceLinks.map((link) => link.source_id));
84
+ const counterIds = normalizeStringList(candidate.counterevidence_ids)
85
+ .filter((id) => sourceById(sources, id) && linkedCounterIds.has(id));
63
86
  const layers = sourceLayersForSourceIds(sources, [...sourceIds, ...counterIds]);
87
+ const independentConfirmations = new Set([...sourceIds, ...counterIds]).size;
88
+ const highConfidence = candidate.trusted_grouping === true
89
+ && layers.length >= 3
90
+ && independentConfirmations >= 3
91
+ && counterIds.length > 0;
64
92
  return {
65
93
  id: candidate.id,
66
94
  claim: candidate.claim,
@@ -69,12 +97,13 @@ export async function buildClaimEvidenceMatrixFromSourceShards(input) {
69
97
  source_ids: sourceIds,
70
98
  local_evidence_ids: sources.filter((source) => source.layer === 'local_project_evidence' && normalizeStringList(source.claim_ids).includes(candidate.id)).map((source) => source.id),
71
99
  counterevidence_ids: counterIds,
100
+ counterevidence_links: counterevidenceLinks.filter((link) => counterIds.includes(link.source_id)),
72
101
  triangulation: {
73
102
  source_layers: layers,
74
- independent_confirmation_count: layers.length,
103
+ independent_confirmation_count: independentConfirmations,
75
104
  conflicts: counterIds.length ? [`counterevidence:${counterIds.join(',')}`] : []
76
105
  },
77
- confidence: layers.length >= 3 && counterIds.length ? 'high' : layers.length >= 2 ? 'medium' : 'low',
106
+ confidence: highConfidence ? 'high' : layers.length >= 2 && independentConfirmations >= 2 ? 'medium' : 'low',
78
107
  falsifiable: true,
79
108
  test_or_probe: candidate.test_or_probe || `Run a source-layer replication probe for ${candidate.id}.`
80
109
  };
@@ -85,16 +114,31 @@ export async function buildClaimEvidenceMatrixFromSourceShards(input) {
85
114
  return important && (claim.triangulation.source_layers.length < 2 || (claim.importance === 'critical' && claim.counterevidence_ids.length === 0));
86
115
  })
87
116
  .map((claim) => claim.id);
117
+ const evidenceLinkedClaims = claims.filter((claim) => claim.source_ids.length > 0 || claim.counterevidence_ids.length > 0);
88
118
  return normalizeClaimEvidenceMatrix({
89
119
  schema: 'sks.claim-evidence-matrix.v1',
90
120
  mission_id: input.plan?.mission_id || '',
91
121
  claims,
92
- key_claim_ids: claims.slice(0, 8).map((claim) => claim.id),
122
+ key_claim_ids: evidenceLinkedClaims.slice(0, 8).map((claim) => claim.id),
93
123
  unsupported_claims: unsupported,
94
- triangulated_claim_count: claims.filter((claim) => claim.triangulation.source_layers.length >= 2).length,
124
+ triangulated_claim_count: claims.filter((claim) => claim.triangulation.source_layers.length >= 2 && claim.triangulation.independent_confirmation_count >= 2).length,
95
125
  blockers: unsupported.map((id) => `unsupported_important_claim:${id}`)
96
126
  });
97
127
  }
128
+ function usableEvidenceSource(source) {
129
+ if (!source || !String(source.id || '').trim())
130
+ return false;
131
+ if (source.stance !== 'supports' && source.stance !== 'undermines')
132
+ return false;
133
+ if (deterministicFixtureSource(source))
134
+ return true;
135
+ return String(source?.acquisition_verdict || '') === 'verified_content'
136
+ && /^verified_content:/i.test(String(source.credibility || ''))
137
+ && source?.super_search_provenance?.validated === true;
138
+ }
139
+ function deterministicFixtureSource(source) {
140
+ return /^(?:deterministic_fixture|selftest|mock)$/i.test(String(source?.kind || ''));
141
+ }
98
142
  function claimTextFromSource(source, claimId) {
99
143
  const notes = String(source?.notes || '').trim();
100
144
  if (notes)
@@ -108,6 +152,14 @@ function sourceLayersForSourceIds(sources, ids) {
108
152
  const idSet = new Set(ids);
109
153
  return [...new Set(sources.filter((source) => idSet.has(String(source?.id || ''))).map((source) => String(source?.layer || '')).filter(Boolean))];
110
154
  }
155
+ function normalizeCounterevidenceLinks(value) {
156
+ const rows = Array.isArray(value) ? value : [];
157
+ return rows.map((row) => ({
158
+ source_id: String(row?.source_id || '').trim(),
159
+ target_claim_id: String(row?.target_claim_id || '').trim(),
160
+ contradiction_rationale: String(row?.contradiction_rationale || '').trim()
161
+ })).filter((row) => row.source_id && row.target_claim_id && row.contradiction_rationale);
162
+ }
111
163
  function normalizeStringList(value) {
112
164
  return [...new Set((Array.isArray(value) ? value : value == null ? [] : [value]).map((item) => String(item || '').trim()).filter(Boolean))];
113
165
  }
@@ -0,0 +1,343 @@
1
+ import path from 'node:path';
2
+ import { readJson } from '../fsx.js';
3
+ import { runCodexTask } from '../codex-control/codex-task-runner.js';
4
+ import { THINKING_SUBAGENT_MODEL, SUBAGENT_EFFORT } from '../subagents/model-policy.js';
5
+ import { normalizeClaimEvidenceMatrix, validateClaimEvidenceMatrix } from './claim-evidence-matrix.js';
6
+ export async function synthesizeResearchClaimEvidenceMatrix(input) {
7
+ const result = await runCodexTask({
8
+ route: '$Research',
9
+ tier: 'orchestrator',
10
+ missionId: String(input.plan?.mission_id || 'research-claim-synthesis'),
11
+ workItemId: 'research_claim_semantic_synthesis',
12
+ cwd: input.root,
13
+ prompt: buildResearchClaimSynthesisPrompt(input),
14
+ inputFiles: [path.join(input.dir, 'source-ledger.json')],
15
+ outputSchema: researchClaimEvidenceMatrixOutputSchema,
16
+ outputSchemaId: 'sks.claim-evidence-matrix.v1',
17
+ sandboxPolicy: 'read-only',
18
+ requestedScopeContract: {
19
+ id: 'research-claim-semantic-synthesis',
20
+ route: '$Research',
21
+ read_only: true,
22
+ allowed_paths: [`.sneakoscope/missions/${input.plan?.mission_id || ''}/`],
23
+ write_paths: [],
24
+ allowed_write_prefixes: [`.sneakoscope/missions/${input.plan?.mission_id || ''}/`],
25
+ source_mutation_allowed: false
26
+ },
27
+ backendPreference: input.backendPreference || ['codex-sdk', 'python-codex-sdk'],
28
+ allowLocalLlm: false,
29
+ localLlmPolicy: { mode: 'disabled', requiresGptFinal: true },
30
+ mutationLedgerRoot: path.join(input.dir, 'research', 'claim-synthesis-codex-control'),
31
+ reliabilityPolicy: {
32
+ timeoutClass: 'standard',
33
+ idleTimeoutMs: input.timeoutMs,
34
+ hardTimeoutMs: input.timeoutMs,
35
+ ...(input.deadlineMs === undefined ? {} : { deadlineEpochMs: input.deadlineMs })
36
+ },
37
+ model: THINKING_SUBAGENT_MODEL,
38
+ reasoningEffort: SUBAGENT_EFFORT,
39
+ modelReasoningEffort: SUBAGENT_EFFORT,
40
+ serviceTier: 'fast'
41
+ });
42
+ const worker = await readJson(result.workerResultPath, null);
43
+ const recalculated = recalculateResearchClaimEvidenceMatrix(worker, input.plan, input.sourceLedger);
44
+ const validation = validateClaimEvidenceMatrix(recalculated, input.sourceLedger, null);
45
+ const blockers = unique([
46
+ ...(Array.isArray(result.blockers) ? result.blockers.map(String) : []),
47
+ ...(Array.isArray(worker?.blockers) ? worker.blockers.map(String) : []),
48
+ ...recalculated.blockers,
49
+ ...validation.blockers
50
+ ]);
51
+ return {
52
+ matrix: normalizeClaimEvidenceMatrix({ ...recalculated, blockers }),
53
+ blockers,
54
+ worker_result_path: typeof result.workerResultPath === 'string' ? result.workerResultPath : null
55
+ };
56
+ }
57
+ export function recalculateResearchClaimEvidenceMatrix(value, plan, sourceLedger) {
58
+ const normalized = normalizeClaimEvidenceMatrix(value);
59
+ const sources = allSources(sourceLedger);
60
+ const byId = new Map(sources.map((source) => [String(source?.id || ''), source]));
61
+ const claims = normalized.claims.map((claim) => {
62
+ const evidenceBlockers = [];
63
+ const counterevidenceLinks = claim.counterevidence_links.filter((link) => {
64
+ if (link.target_claim_id !== claim.id) {
65
+ evidenceBlockers.push(`claim_counterevidence_target_mismatch:${claim.id}:${link.source_id}`);
66
+ return false;
67
+ }
68
+ if (link.contradiction_rationale.length < 32 || !sourceSemanticallyOverlapsClaim({ notes: link.contradiction_rationale }, claim.claim)) {
69
+ evidenceBlockers.push(`claim_counterevidence_rationale_not_claim_relative:${claim.id}:${link.source_id}`);
70
+ return false;
71
+ }
72
+ return true;
73
+ });
74
+ const counterevidenceLinksBySource = new Map(counterevidenceLinks.map((link) => [link.source_id, link]));
75
+ const sourceIds = unique(claim.source_ids).filter((sourceId) => {
76
+ const source = byId.get(sourceId);
77
+ if (!source) {
78
+ evidenceBlockers.push(`claim_source_unknown:${claim.id}:${sourceId}`);
79
+ return false;
80
+ }
81
+ if (!trustworthyVerifiedEvidence(source)) {
82
+ evidenceBlockers.push(`claim_source_not_verified:${claim.id}:${sourceId}`);
83
+ return false;
84
+ }
85
+ if (!sourceSemanticallyOverlapsClaim(source, claim.claim)) {
86
+ evidenceBlockers.push(`claim_source_semantic_overlap_missing:${claim.id}:${sourceId}`);
87
+ return false;
88
+ }
89
+ return true;
90
+ });
91
+ const counterevidenceIds = unique(claim.counterevidence_ids).filter((sourceId) => {
92
+ const source = byId.get(sourceId);
93
+ if (!source) {
94
+ evidenceBlockers.push(`claim_counterevidence_unknown:${claim.id}:${sourceId}`);
95
+ return false;
96
+ }
97
+ if (!trustworthyVerifiedEvidence(source)) {
98
+ evidenceBlockers.push(`claim_counterevidence_not_verified:${claim.id}:${sourceId}`);
99
+ return false;
100
+ }
101
+ if (!counterevidenceLinksBySource.has(sourceId)) {
102
+ evidenceBlockers.push(`claim_counterevidence_link_missing:${claim.id}:${sourceId}`);
103
+ return false;
104
+ }
105
+ if (sourceIds.includes(sourceId)) {
106
+ evidenceBlockers.push(`claim_counterevidence_also_used_as_support:${claim.id}:${sourceId}`);
107
+ return false;
108
+ }
109
+ if (!sourceSemanticallyOverlapsClaim(source, claim.claim)) {
110
+ evidenceBlockers.push(`claim_counterevidence_semantic_overlap_missing:${claim.id}:${sourceId}`);
111
+ return false;
112
+ }
113
+ return true;
114
+ });
115
+ const supportRows = sourceIds.map((id) => byId.get(id)).filter(Boolean);
116
+ const counterRows = counterevidenceIds.map((id) => byId.get(id)).filter(Boolean);
117
+ const supportLayers = unique(supportRows.map((row) => String(row?.layer || '')).filter(Boolean));
118
+ const layers = unique([...supportRows, ...counterRows].map((row) => String(row?.layer || '')).filter(Boolean));
119
+ const independenceKeys = unique(supportRows.map(sourceIndependenceKey).filter(Boolean));
120
+ const authoritativeSupportCount = supportRows.filter(authoritativeSupportingEvidence).length;
121
+ const independentConfirmationCount = independenceKeys.length;
122
+ const highConfidence = sourceIds.length >= 3
123
+ && independentConfirmationCount >= 3
124
+ && supportLayers.length >= 3
125
+ && authoritativeSupportCount >= 2
126
+ && counterevidenceIds.length > 0
127
+ && evidenceBlockers.length === 0;
128
+ const mediumConfidence = sourceIds.length >= 2
129
+ && independentConfirmationCount >= 2
130
+ && supportLayers.length >= 2
131
+ && authoritativeSupportCount >= 1
132
+ && evidenceBlockers.length === 0;
133
+ return {
134
+ ...claim,
135
+ source_ids: sourceIds,
136
+ counterevidence_ids: counterevidenceIds,
137
+ counterevidence_links: counterevidenceLinks.filter((link) => counterevidenceIds.includes(link.source_id)),
138
+ local_evidence_ids: sourceIds.filter((id) => byId.get(id)?.layer === 'local_project_evidence'),
139
+ triangulation: {
140
+ source_layers: layers,
141
+ independent_confirmation_count: independentConfirmationCount,
142
+ conflicts: counterevidenceIds.length ? [`counterevidence:${counterevidenceIds.join(',')}`] : []
143
+ },
144
+ confidence: highConfidence ? 'high' : mediumConfidence ? 'medium' : 'low',
145
+ evidence_blockers: unique(evidenceBlockers),
146
+ support_layer_count: supportLayers.length,
147
+ authoritative_support_count: authoritativeSupportCount
148
+ };
149
+ });
150
+ const unsupported = unique([
151
+ ...normalized.unsupported_claims,
152
+ ...claims.filter((claim) => {
153
+ const important = claim.importance === 'high' || claim.importance === 'critical';
154
+ return important && (claim.source_ids.length < 2
155
+ || claim.triangulation.independent_confirmation_count < 2
156
+ || claim.support_layer_count < 2
157
+ || claim.authoritative_support_count < 1
158
+ || claim.evidence_blockers.length > 0
159
+ || (claim.importance === 'critical' && claim.counterevidence_ids.length === 0));
160
+ }).map((claim) => claim.id)
161
+ ]);
162
+ const evidenceBlockers = claims.flatMap((claim) => claim.evidence_blockers);
163
+ const outputClaims = claims.map(({ evidence_blockers: _evidenceBlockers, support_layer_count: _supportLayerCount, authoritative_support_count: _authoritativeSupportCount, ...claim }) => claim);
164
+ return normalizeClaimEvidenceMatrix({
165
+ schema: 'sks.claim-evidence-matrix.v1',
166
+ mission_id: String(value?.mission_id || plan?.mission_id || ''),
167
+ claims: outputClaims,
168
+ key_claim_ids: normalized.key_claim_ids,
169
+ unsupported_claims: unsupported,
170
+ triangulated_claim_count: outputClaims.filter((claim) => claim.triangulation.source_layers.length >= 2 && claim.triangulation.independent_confirmation_count >= 2).length,
171
+ blockers: unique([
172
+ ...normalized.blockers,
173
+ ...evidenceBlockers,
174
+ ...unsupported.map((id) => `unsupported_important_claim:${id}`)
175
+ ])
176
+ });
177
+ }
178
+ function buildResearchClaimSynthesisPrompt(input) {
179
+ const contract = input.plan?.quality_contract || {};
180
+ return [
181
+ 'Build a semantic claim-evidence matrix for this Research mission.',
182
+ 'This is a judgment-heavy task: use GPT-5.6 Sol with max reasoning.',
183
+ 'Return exactly one JSON object matching sks.claim-evidence-matrix.v1.',
184
+ 'Never reuse or merge discovery claim IDs merely because their strings match.',
185
+ 'Group sources only when their hydrated notes/content actually support the same written claim.',
186
+ 'Every supporting and counterevidence source id must exist in the supplied source ledger.',
187
+ 'A source title alone is not evidence. Use locator, author/date, credibility, notes/snippet, and content artifact/hash when present.',
188
+ 'Context, weak, partial, public-discourse-only, or discovery-only rows cannot support a high/critical claim.',
189
+ 'Critical claims require direct counterevidence or must be downgraded/blocked.',
190
+ 'Every counterevidence id must have a counterevidence_links row whose target_claim_id exactly equals the current claim id and whose contradiction_rationale explains the claim-relative conflict.',
191
+ 'Do not infer counterevidence from generic negative keywords; select it only when the hydrated source meaning directly challenges the written claim.',
192
+ 'Mark uncertainty and return explicit blockers when the evidence cannot satisfy the requested minimums.',
193
+ `Mission: ${input.plan?.mission_id || 'unknown'}`,
194
+ `Question: ${input.plan?.prompt || ''}`,
195
+ `Target key claims: ${Number(contract.min_key_claims || 8)}`,
196
+ `Target triangulated claims: ${Number(contract.min_trianguled_claims || 6)}`,
197
+ '',
198
+ 'Evidence pack:',
199
+ JSON.stringify(compactSourceLedger(input.sourceLedger), null, 2).slice(0, 30000)
200
+ ].join('\n');
201
+ }
202
+ function compactSourceLedger(sourceLedger) {
203
+ return {
204
+ sources: allSources(sourceLedger).map((source) => ({
205
+ id: source.id,
206
+ layer: source.layer,
207
+ kind: source.kind,
208
+ title: source.title,
209
+ locator: source.locator,
210
+ publisher_or_author: source.publisher_or_author,
211
+ published_at: source.published_at || null,
212
+ accessed_at: source.accessed_at,
213
+ reliability: source.reliability,
214
+ credibility: source.credibility,
215
+ stance: source.stance,
216
+ notes: source.notes,
217
+ content_artifact: source.content_artifact || null,
218
+ content_sha256: source.content_sha256 || null,
219
+ content_length: source.content_length || null,
220
+ acquisition_verdict: source.acquisition_verdict || null,
221
+ domain: source.domain || null,
222
+ authority_tier: source.authority_tier || null,
223
+ primary_source: source.primary_source === true,
224
+ independence_cluster_id: source.independence_cluster_id || null
225
+ })),
226
+ blockers: Array.isArray(sourceLedger?.blockers) ? sourceLedger.blockers : []
227
+ };
228
+ }
229
+ function allSources(sourceLedger) {
230
+ return [
231
+ ...(Array.isArray(sourceLedger?.sources) ? sourceLedger.sources : []),
232
+ ...(Array.isArray(sourceLedger?.counterevidence_sources) ? sourceLedger.counterevidence_sources : [])
233
+ ];
234
+ }
235
+ function trustworthyVerifiedEvidence(source) {
236
+ const verified = String(source?.acquisition_verdict || '') === 'verified_content'
237
+ && /^verified_content:/i.test(String(source?.credibility || ''));
238
+ const hydrated = Boolean(String(source?.content_artifact || '').trim())
239
+ && /^[a-f0-9]{64}$/i.test(String(source?.content_sha256 || '').trim())
240
+ && Number(source?.content_length || 0) > 0;
241
+ return verified && hydrated && source?.super_search_provenance?.validated === true;
242
+ }
243
+ function authoritativeSupportingEvidence(source) {
244
+ if (!source || source?.layer === 'public_discourse')
245
+ return false;
246
+ const tier = String(source?.authority_tier || '').toUpperCase();
247
+ const reliability = String(source?.reliability || '').toLowerCase();
248
+ return source?.primary_source === true
249
+ || ['A0', 'A1', 'B'].includes(tier)
250
+ || reliability === 'high'
251
+ || reliability === 'medium-high';
252
+ }
253
+ function sourceIndependenceKey(source) {
254
+ const explicit = String(source?.independence_cluster_id || source?.domain || '').trim().toLowerCase();
255
+ if (explicit)
256
+ return explicit;
257
+ try {
258
+ return new URL(String(source?.locator || '')).hostname.toLowerCase();
259
+ }
260
+ catch {
261
+ return String(source?.publisher_or_author || '').trim().toLowerCase();
262
+ }
263
+ }
264
+ function sourceSemanticallyOverlapsClaim(source, claim) {
265
+ const claimTokens = semanticTokens(claim);
266
+ if (claimTokens.length === 0)
267
+ return false;
268
+ const sourceTokens = new Set(semanticTokens([
269
+ source?.title,
270
+ source?.notes,
271
+ source?.publisher_or_author,
272
+ source?.locator
273
+ ].filter(Boolean).join(' ')));
274
+ const overlap = claimTokens.filter((token) => sourceTokens.has(token)).length;
275
+ const minimumOverlap = claimTokens.length <= 2 ? claimTokens.length : claimTokens.length <= 5 ? 2 : 3;
276
+ const minimumCoverage = claimTokens.length <= 3 ? 1 : 0.3;
277
+ return overlap >= minimumOverlap && overlap / claimTokens.length >= minimumCoverage;
278
+ }
279
+ function semanticTokens(value) {
280
+ const stop = new Set(['about', 'after', 'before', 'been', 'being', 'could', 'evidence', 'finding', 'from', 'have', 'into', 'research', 'result', 'should', 'source', 'study', 'that', 'their', 'there', 'these', 'this', 'through', 'using', 'with']);
281
+ return unique(String(value || '').toLowerCase().normalize('NFKC').match(/[\p{L}\p{N}]{4,}/gu) || [])
282
+ .filter((token) => !stop.has(token));
283
+ }
284
+ function unique(values) {
285
+ return [...new Set(values)];
286
+ }
287
+ export const researchClaimEvidenceMatrixOutputSchema = {
288
+ type: 'object',
289
+ additionalProperties: false,
290
+ required: ['schema', 'mission_id', 'claims', 'key_claim_ids', 'unsupported_claims', 'triangulated_claim_count', 'blockers'],
291
+ properties: {
292
+ schema: { const: 'sks.claim-evidence-matrix.v1' },
293
+ mission_id: { type: 'string' },
294
+ claims: {
295
+ type: 'array',
296
+ items: {
297
+ type: 'object',
298
+ additionalProperties: false,
299
+ required: ['id', 'claim', 'claim_type', 'importance', 'source_ids', 'local_evidence_ids', 'counterevidence_ids', 'counterevidence_links', 'triangulation', 'confidence', 'falsifiable', 'test_or_probe'],
300
+ properties: {
301
+ id: { type: 'string' },
302
+ claim: { type: 'string' },
303
+ claim_type: { enum: ['fact', 'inference', 'hypothesis', 'recommendation', 'implementation_guidance'] },
304
+ importance: { enum: ['low', 'medium', 'high', 'critical'] },
305
+ source_ids: { type: 'array', items: { type: 'string' } },
306
+ local_evidence_ids: { type: 'array', items: { type: 'string' } },
307
+ counterevidence_ids: { type: 'array', items: { type: 'string' } },
308
+ counterevidence_links: {
309
+ type: 'array',
310
+ items: {
311
+ type: 'object',
312
+ additionalProperties: false,
313
+ required: ['source_id', 'target_claim_id', 'contradiction_rationale'],
314
+ properties: {
315
+ source_id: { type: 'string' },
316
+ target_claim_id: { type: 'string' },
317
+ contradiction_rationale: { type: 'string' }
318
+ }
319
+ }
320
+ },
321
+ triangulation: {
322
+ type: 'object',
323
+ additionalProperties: false,
324
+ required: ['source_layers', 'independent_confirmation_count', 'conflicts'],
325
+ properties: {
326
+ source_layers: { type: 'array', items: { type: 'string' } },
327
+ independent_confirmation_count: { type: 'number' },
328
+ conflicts: { type: 'array', items: { type: 'string' } }
329
+ }
330
+ },
331
+ confidence: { enum: ['low', 'medium', 'high'] },
332
+ falsifiable: { type: 'boolean' },
333
+ test_or_probe: { type: 'string' }
334
+ }
335
+ }
336
+ },
337
+ key_claim_ids: { type: 'array', items: { type: 'string' } },
338
+ unsupported_claims: { type: 'array', items: { type: 'string' } },
339
+ triangulated_claim_count: { type: 'number' },
340
+ blockers: { type: 'array', items: { type: 'string' } }
341
+ }
342
+ };
343
+ //# sourceMappingURL=research-claim-synthesizer.js.map
@@ -22,6 +22,7 @@ export async function runResearchCycle(inputOrDir, legacyGraph = null, legacyOpt
22
22
  const running = new Map();
23
23
  const blockers = [];
24
24
  const maxParallel = Math.max(1, Math.min(16, Number(input.maxParallelStages || 4)));
25
+ const cycleDeadlineMs = Date.now() + Math.max(1, Number(input.timeoutMs || 1));
25
26
  let maxObservedParallel = 0;
26
27
  while (pending.size || running.size) {
27
28
  const ready = readyStages([...pending.values()], completed);
@@ -30,7 +31,15 @@ export async function runResearchCycle(inputOrDir, legacyGraph = null, legacyOpt
30
31
  if (!stage)
31
32
  break;
32
33
  pending.delete(String(stage.id));
33
- const promise = runResearchStage({ ...input, stage }).catch((err) => failureStage(input, stage, err));
34
+ const remainingMs = Math.max(0, cycleDeadlineMs - Date.now());
35
+ if (remainingMs <= 0) {
36
+ const failed = failureStage(input, stage, new Error('research_cycle_timeout_exceeded'));
37
+ completed.set(String(stage.id), failed);
38
+ blockers.push(`${String(stage.id)}:research_cycle_timeout_exceeded`);
39
+ continue;
40
+ }
41
+ const promise = runResearchStage({ ...input, stage, timeoutMs: remainingMs, cycleDeadlineMs })
42
+ .catch((err) => failureStage(input, stage, err));
34
43
  running.set(String(stage.id), promise);
35
44
  maxObservedParallel = Math.max(maxObservedParallel, running.size);
36
45
  }
@@ -44,7 +53,24 @@ export async function runResearchCycle(inputOrDir, legacyGraph = null, legacyOpt
44
53
  pending.clear();
45
54
  break;
46
55
  }
47
- const done = await Promise.race([...running.entries()].map(async ([id, promise]) => ({ id, result: await promise })));
56
+ const done = await raceResearchStagesUntilDeadline(running, cycleDeadlineMs);
57
+ if (!done) {
58
+ for (const [id, promise] of running.entries()) {
59
+ promise.catch(() => undefined);
60
+ const stage = stages.find((candidate) => String(candidate.id) === id);
61
+ const failed = failureStage(input, stage, new Error('research_cycle_timeout_exceeded'));
62
+ completed.set(id, failed);
63
+ blockers.push(`${id}:research_cycle_timeout_exceeded`);
64
+ }
65
+ for (const [id, stage] of pending.entries()) {
66
+ const failed = failureStage(input, stage, new Error('research_cycle_timeout_exceeded'));
67
+ completed.set(id, failed);
68
+ blockers.push(`${id}:research_cycle_timeout_exceeded`);
69
+ }
70
+ running.clear();
71
+ pending.clear();
72
+ break;
73
+ }
48
74
  running.delete(done.id);
49
75
  completed.set(done.id, done.result);
50
76
  if (done.result.status !== 'passed' && pendingStageRequired(stages.find((stage) => String(stage.id) === done.id))) {
@@ -70,13 +96,37 @@ export async function runResearchCycle(inputOrDir, legacyGraph = null, legacyOpt
70
96
  stage_count: stageResults.length,
71
97
  critical_path_length: criticalPathLength(stages)
72
98
  },
73
- legacy_final_md_loop: false
99
+ legacy_final_md_loop: false,
100
+ timeout: {
101
+ budget_ms: Math.max(1, Number(input.timeoutMs || 1)),
102
+ deadline_epoch_ms: cycleDeadlineMs,
103
+ exhausted: Date.now() >= cycleDeadlineMs
104
+ }
74
105
  };
75
106
  await writeJsonAtomic(path.join(input.dir, 'research', `cycle-${input.cycle}`, 'research-cycle-runner.json'), record);
76
107
  await writeJsonAtomic(path.join(input.dir, 'research-cycle-runner.json'), record);
77
108
  await appendJsonlBounded(path.join(input.dir, 'events.jsonl'), { ts: nowIso(), type: 'research.cycle_runner.completed', cycle: record.cycle, stage_count: record.stage_count, status: record.status, max_observed_parallel: maxObservedParallel });
78
109
  return record;
79
110
  }
111
+ export async function raceResearchStagesUntilDeadline(running, deadlineEpochMs) {
112
+ const remainingMs = Math.max(0, Math.floor(deadlineEpochMs - Date.now()));
113
+ if (remainingMs <= 0)
114
+ return null;
115
+ let timer = null;
116
+ try {
117
+ return await Promise.race([
118
+ ...[...running.entries()].map(async ([id, promise]) => ({ id, result: await promise })),
119
+ new Promise((resolve) => {
120
+ timer = setTimeout(() => resolve(null), remainingMs);
121
+ timer.unref?.();
122
+ })
123
+ ]);
124
+ }
125
+ finally {
126
+ if (timer)
127
+ clearTimeout(timer);
128
+ }
129
+ }
80
130
  export function readyStages(pending, completed) {
81
131
  return pending.filter((stage) => (Array.isArray(stage.dependencies) ? stage.dependencies : []).every((id) => completed.has(String(id))));
82
132
  }