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
@@ -0,0 +1,68 @@
1
+ export const RESEARCH_SOURCE_LAYERS = Object.freeze([
2
+ {
3
+ id: 'academic_literature',
4
+ label: 'Academic literature',
5
+ purpose: 'Find papers, preprints, reviews, citations, and archival scholarly evidence before synthesis.',
6
+ evidence_role: 'formal_evidence',
7
+ examples: ['arXiv', 'Semantic Scholar', 'OpenAlex', 'Crossref', 'PubMed'],
8
+ query_templates: ['"<topic>" arxiv', '"<topic>" Semantic Scholar', '"<topic>" OpenAlex Crossref PubMed']
9
+ },
10
+ {
11
+ id: 'official_government_data',
12
+ label: 'Official government data',
13
+ purpose: 'Ground claims in public datasets, policy papers, national statistics, and leading-institution sources.',
14
+ evidence_role: 'authoritative_baseline',
15
+ examples: ['World Bank', 'OECD', 'Eurostat', 'data.gov', 'NIST'],
16
+ query_templates: ['"<topic>" site:worldbank.org OR site:oecd.org', '"<topic>" site:data.gov', '"<topic>" site:nist.gov']
17
+ },
18
+ {
19
+ id: 'standards_primary_docs',
20
+ label: 'Standards and primary documents',
21
+ purpose: 'Check specifications, standards, RFCs, policy originals, and official project documents before relying on summaries.',
22
+ evidence_role: 'primary_source',
23
+ examples: ['IETF RFCs', 'W3C', 'ISO abstracts', 'official standards bodies'],
24
+ query_templates: ['"<topic>" RFC standard specification', '"<topic>" W3C IETF NIST standard', '"<topic>" official specification']
25
+ },
26
+ {
27
+ id: 'news_current_events',
28
+ label: 'News and current events',
29
+ purpose: 'Capture recent events, public impact, and regional framing from reputable news and current-event indices.',
30
+ evidence_role: 'recency_signal',
31
+ examples: ['GDELT', 'BBC', 'Reuters', 'AP', 'regional reputable outlets'],
32
+ query_templates: ['"<topic>" latest Reuters AP', '"<topic>" GDELT news', '"<topic>" BBC analysis']
33
+ },
34
+ {
35
+ id: 'public_discourse',
36
+ label: 'Public discourse',
37
+ purpose: 'Sample public practitioner and community discourse without treating popularity as truth.',
38
+ evidence_role: 'sentiment_and_edge_cases',
39
+ examples: ['X/Twitter', 'Reddit', 'Hacker News', 'public forums'],
40
+ query_templates: ['"<topic>" site:x.com OR site:twitter.com', '"<topic>" site:reddit.com', '"<topic>" "Hacker News"']
41
+ },
42
+ {
43
+ id: 'developer_practitioner',
44
+ label: 'Developer and practitioner knowledge',
45
+ purpose: 'Find implementation pitfalls, developer questions, bug reports, and operational lessons.',
46
+ evidence_role: 'practice_feedback',
47
+ examples: ['Stack Overflow', 'Stack Exchange', 'GitHub issues', 'release notes', 'engineering blogs'],
48
+ query_templates: ['"<topic>" site:stackoverflow.com', '"<topic>" site:stackexchange.com', '"<topic>" site:github.com issues']
49
+ },
50
+ {
51
+ id: 'counterevidence_factcheck',
52
+ label: 'Counterevidence and fact checking',
53
+ purpose: 'Actively search for failures, critiques, null results, retractions, fact checks, and source conflicts.',
54
+ evidence_role: 'falsification',
55
+ examples: ['Fact checks', 'Retraction Watch', 'critical reviews', 'benchmark failures', 'negative results'],
56
+ query_templates: ['"<topic>" critique failure limitation', '"<topic>" fact check retraction', '"<topic>" counterevidence null result']
57
+ },
58
+ {
59
+ id: 'local_project_evidence',
60
+ label: 'Local project evidence',
61
+ purpose: 'Inspect repository-local files, scripts, docs, schemas, and tests as implementation evidence for handoff.',
62
+ evidence_role: 'local_evidence',
63
+ examples: ['git ls-files', 'package scripts', 'source modules', 'docs', 'schemas'],
64
+ query_templates: ['git ls-files', 'rg "<topic>" src docs schemas package.json']
65
+ }
66
+ ]);
67
+ export const RESEARCH_SOURCE_LAYER_IDS = Object.freeze(RESEARCH_SOURCE_LAYERS.map((layer) => layer.id));
68
+ //# sourceMappingURL=research-source-layer-catalog.js.map
@@ -1,23 +1,33 @@
1
1
  import fsp from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { nowIso, readJson, writeJsonAtomic } from '../fsx.js';
3
+ import { nowIso, readJson, sha256, writeJsonAtomic } from '../fsx.js';
4
4
  import { writeSourceQualityReport } from './source-quality-report.js';
5
+ import { validateResearchSourceProvenance } from './research-source-evidence.js';
5
6
  import { RESEARCH_SOURCE_LAYERS, validateResearchSourceShardOutput } from './research-source-shards.js';
6
7
  export async function mergeResearchSourceShards(input) {
7
8
  const shardDir = path.join(input.dir, 'research', `cycle-${input.cycle}`, 'source-shards');
8
9
  const shardFiles = await listJsonFiles(shardDir);
9
10
  const shardOutputs = [];
11
+ const superSearchRuns = [];
10
12
  const blockers = [];
11
13
  for (const file of shardFiles) {
12
14
  const shard = await readJson(file, null);
13
15
  const validation = validateResearchSourceShardOutput(shard);
14
16
  if (!validation.ok)
15
17
  blockers.push(...validation.blockers.map((blocker) => `${path.basename(file)}:${blocker}`));
16
- shardOutputs.push(shard);
18
+ const materialized = await materializeShardSuperSearchProvenance(input.dir, shard);
19
+ blockers.push(...materialized.blockers.map((blocker) => `${path.basename(file)}:${blocker}`));
20
+ shardOutputs.push(materialized.shard);
21
+ if (materialized.run)
22
+ superSearchRuns.push(materialized.run);
17
23
  }
18
24
  const requiredLayers = sourceLayersForPlan(input.plan);
19
25
  const rows = dedupeSources(shardOutputs.flatMap((shard) => Array.isArray(shard?.sources) ? shard.sources : []));
20
- const counterRows = rows.filter((row) => row.layer === 'counterevidence_factcheck' || row.stance === 'undermines');
26
+ const counterCandidates = rows.filter((row) => row.stance === 'undermines');
27
+ const unstructuredCounterRows = counterCandidates.filter((row) => !structuredCounterevidence(row));
28
+ blockers.push(...unstructuredCounterRows.map((row) => `counterevidence_link_unstructured:${row.id || 'unknown'}`));
29
+ const counterRows = counterCandidates.filter((row) => structuredCounterevidence(row));
30
+ const counterRowIds = new Set(counterRows.map((row) => String(row.id || '')));
21
31
  const primaryRows = rows.filter((row) => !counterRows.some((counter) => counter.id === row.id));
22
32
  const coveredLayers = [...new Set(rows.map((row) => String(row.layer || '')).filter(Boolean))];
23
33
  const missingLayers = requiredLayers.map((layer) => layer.id).filter((id) => !coveredLayers.includes(id));
@@ -38,9 +48,10 @@ export async function mergeResearchSourceShards(input) {
38
48
  status: 'created'
39
49
  },
40
50
  web_search_passes: shardOutputs.length ? 1 : 0,
51
+ super_search_runs: superSearchRuns,
41
52
  source_layers: requiredLayers.map((layer) => {
42
- const sourceIds = rows.filter((row) => row.layer === layer.id && row.stance !== 'undermines').map((row) => row.id);
43
- const counterIds = rows.filter((row) => row.layer === layer.id && row.stance === 'undermines').map((row) => row.id);
53
+ const sourceIds = rows.filter((row) => row.layer === layer.id && !counterRowIds.has(String(row.id || ''))).map((row) => row.id);
54
+ const counterIds = rows.filter((row) => row.layer === layer.id && counterRowIds.has(String(row.id || ''))).map((row) => row.id);
44
55
  return {
45
56
  id: layer.id,
46
57
  label: layer.label,
@@ -90,6 +101,183 @@ export async function mergeResearchSourceShards(input) {
90
101
  blockers: [...new Set(blockers)]
91
102
  };
92
103
  }
104
+ export function linkSourceLedgerToClaimMatrix(sourceLedger, claimMatrix) {
105
+ const claims = Array.isArray(claimMatrix?.claims) ? claimMatrix.claims : [];
106
+ const keyClaimIds = Array.isArray(claimMatrix?.key_claim_ids) ? claimMatrix.key_claim_ids.map(String) : [];
107
+ const originalSources = Array.isArray(sourceLedger?.sources) ? sourceLedger.sources : [];
108
+ const originalCounterSources = Array.isArray(sourceLedger?.counterevidence_sources) ? sourceLedger.counterevidence_sources : [];
109
+ const originalCounterIds = new Set(originalCounterSources.map((source) => String(source?.id || '')).filter(Boolean));
110
+ const sourceRowsById = new Map([...originalSources, ...originalCounterSources]
111
+ .map((source) => [String(source?.id || ''), source]));
112
+ const sourceToClaims = new Map();
113
+ const linkBlockers = [];
114
+ for (const claim of claims) {
115
+ const claimId = String(claim?.id || '').trim();
116
+ if (!claimId)
117
+ continue;
118
+ for (const sourceId of normalizeStringList(claim?.source_ids)) {
119
+ const source = sourceRowsById.get(sourceId);
120
+ if (!source || !supportLinkAllowed(source, originalCounterIds.has(sourceId))) {
121
+ linkBlockers.push(`claim_support_source_untrusted:${claimId}:${sourceId}`);
122
+ continue;
123
+ }
124
+ const row = sourceToClaims.get(sourceId) || { supports: [], undermines: [], contradiction_rationales: [] };
125
+ row.supports.push(claimId);
126
+ sourceToClaims.set(sourceId, row);
127
+ }
128
+ for (const sourceId of normalizeStringList(claim?.counterevidence_ids)) {
129
+ const source = sourceRowsById.get(sourceId);
130
+ const structuredLink = (Array.isArray(claim?.counterevidence_links) ? claim.counterevidence_links : [])
131
+ .find((link) => String(link?.source_id || '') === sourceId && String(link?.target_claim_id || '') === claimId && String(link?.contradiction_rationale || '').trim());
132
+ if (!source || !structuredLink || !counterevidenceLinkAllowed(source)) {
133
+ linkBlockers.push(`claim_counterevidence_source_untrusted:${claimId}:${sourceId}`);
134
+ continue;
135
+ }
136
+ const row = sourceToClaims.get(sourceId) || { supports: [], undermines: [], contradiction_rationales: [] };
137
+ row.undermines.push(claimId);
138
+ row.contradiction_rationales.push(String(structuredLink.contradiction_rationale).trim());
139
+ sourceToClaims.set(sourceId, row);
140
+ }
141
+ }
142
+ const link = (source) => {
143
+ const mapped = sourceToClaims.get(String(source?.id || '')) || { supports: [], undermines: [], contradiction_rationales: [] };
144
+ const semanticCounterTargets = [...new Set(mapped.undermines)];
145
+ return {
146
+ ...source,
147
+ stance: semanticCounterTargets.length ? 'undermines' : source?.stance || 'context',
148
+ discovery_claim_ids: normalizeStringList(source?.discovery_claim_ids || source?.claim_ids),
149
+ supports: [...new Set(mapped.supports)],
150
+ undermines: semanticCounterTargets,
151
+ claim_ids: [...new Set([...mapped.supports, ...mapped.undermines])],
152
+ ...(semanticCounterTargets.length ? {
153
+ counterevidence_target_claim_id: semanticCounterTargets[0],
154
+ counterevidence_target_claim_ids: semanticCounterTargets,
155
+ contradiction_rationale: [
156
+ ...mapped.contradiction_rationales,
157
+ `Validated semantic claim synthesis links this source against ${semanticCounterTargets.join(', ')}.`
158
+ ].filter(Boolean).join(' ')
159
+ } : {}),
160
+ semantic_claim_linked: mapped.supports.length > 0 || mapped.undermines.length > 0
161
+ };
162
+ };
163
+ const rows = [
164
+ ...originalSources,
165
+ ...originalCounterSources
166
+ ].map(link);
167
+ const semanticCounterIds = new Set(rows.filter((row) => normalizeStringList(row?.undermines).length > 0).map((row) => String(row?.id || '')));
168
+ const counterevidenceSources = rows.filter((row) => semanticCounterIds.has(String(row?.id || '')));
169
+ const sources = rows.filter((row) => !semanticCounterIds.has(String(row?.id || '')));
170
+ const sourceLayers = (Array.isArray(sourceLedger?.source_layers) ? sourceLedger.source_layers : []).map((layer) => {
171
+ const layerRows = rows.filter((row) => row.layer === layer.id);
172
+ return {
173
+ ...layer,
174
+ source_ids: layerRows.filter((row) => !semanticCounterIds.has(String(row?.id || ''))).map((row) => row.id),
175
+ counterevidence_ids: layerRows.filter((row) => semanticCounterIds.has(String(row?.id || ''))).map((row) => row.id)
176
+ };
177
+ });
178
+ return {
179
+ ...sourceLedger,
180
+ sources,
181
+ counterevidence_sources: counterevidenceSources,
182
+ source_layers: sourceLayers,
183
+ claim_link_blockers: [...new Set(linkBlockers)],
184
+ triangulation: {
185
+ ...(sourceLedger?.triangulation || {}),
186
+ cross_layer_checks: buildCrossLayerChecks(rows),
187
+ conflicts: counterevidenceSources.flatMap((row) => normalizeStringList(row.claim_ids).map((claimId) => ({
188
+ id: `conflict-${row.id}-${claimId}`,
189
+ source_id: row.id,
190
+ claim_ids: [claimId],
191
+ notes: row.notes || ''
192
+ }))),
193
+ synthesis_notes: ['Semantic claim links were rebuilt from the validated claim-evidence matrix.']
194
+ },
195
+ citation_coverage: buildCitationCoverage(rows, keyClaimIds)
196
+ };
197
+ }
198
+ async function materializeShardSuperSearchProvenance(dir, shard) {
199
+ const sources = Array.isArray(shard?.sources) ? shard.sources : [];
200
+ const verifiedSources = sources.filter((source) => String(source?.acquisition_verdict || '') === 'verified_content');
201
+ const link = shard?.super_search;
202
+ if (link?.schema !== 'sks.research-super-search-link.v1') {
203
+ return {
204
+ shard,
205
+ run: null,
206
+ blockers: verifiedSources.map((source) => `super_search_provenance_missing:${String(source?.id || 'unknown')}`)
207
+ };
208
+ }
209
+ const [proofArtifact, sourceLedgerArtifact] = await Promise.all([
210
+ readMissionArtifact(dir, link.proof_artifact),
211
+ readMissionArtifact(dir, link.source_ledger_artifact)
212
+ ]);
213
+ const shared = {
214
+ schema: 'sks.research-super-search-source-provenance.v1',
215
+ layer_id: String(shard?.layer_id || ''),
216
+ proof_artifact: String(link?.proof_artifact || ''),
217
+ proof_sha256: proofArtifact?.sha256 || null,
218
+ source_ledger_artifact: String(link?.source_ledger_artifact || ''),
219
+ source_ledger_sha256: sourceLedgerArtifact?.sha256 || null
220
+ };
221
+ const validationBlockers = [];
222
+ const enrichedSources = await Promise.all(sources.map(async (source) => {
223
+ const provenance = {
224
+ ...shared,
225
+ source_id: String(source?.id || source?.source_id || ''),
226
+ validated: false,
227
+ blockers: []
228
+ };
229
+ const enriched = { ...source, super_search_provenance: provenance };
230
+ const validation = await validateResearchSourceProvenance(dir, enriched);
231
+ provenance.validated = validation.ok;
232
+ provenance.blockers = validation.blockers;
233
+ if (String(source?.acquisition_verdict || '') === 'verified_content' && !validation.ok)
234
+ validationBlockers.push(...validation.blockers);
235
+ return enriched;
236
+ }));
237
+ const verifiedSourceIds = enrichedSources
238
+ .filter((source) => source?.super_search_provenance?.validated === true)
239
+ .map((source) => String(source?.id || source?.source_id || ''))
240
+ .filter(Boolean);
241
+ const run = {
242
+ schema: 'sks.research-super-search-run-provenance.v1',
243
+ layer_id: shared.layer_id,
244
+ proof_artifact: shared.proof_artifact,
245
+ proof_sha256: shared.proof_sha256,
246
+ source_ledger_artifact: shared.source_ledger_artifact,
247
+ source_ledger_sha256: shared.source_ledger_sha256,
248
+ proof_ok: proofArtifact?.json?.schema === 'sks.super-search-proof.v1'
249
+ && proofArtifact.json.ok === true
250
+ && normalizeStringList(proofArtifact.json.blockers).length === 0,
251
+ verified_source_ids: verifiedSourceIds,
252
+ validated: verifiedSources.length > 0 && verifiedSourceIds.length === verifiedSources.length && validationBlockers.length === 0,
253
+ blockers: [...new Set(validationBlockers)]
254
+ };
255
+ return {
256
+ shard: { ...shard, sources: enrichedSources },
257
+ run,
258
+ blockers: run.blockers
259
+ };
260
+ }
261
+ async function readMissionArtifact(dir, artifact) {
262
+ const raw = String(artifact || '').trim();
263
+ if (!raw || path.isAbsolute(raw))
264
+ return null;
265
+ const root = path.resolve(dir);
266
+ const resolved = path.resolve(root, raw);
267
+ if (resolved !== root && !resolved.startsWith(`${root}${path.sep}`))
268
+ return null;
269
+ const bytes = await fsp.readFile(resolved).catch(() => null);
270
+ if (!bytes)
271
+ return null;
272
+ let json = null;
273
+ try {
274
+ json = JSON.parse(bytes.toString('utf8'));
275
+ }
276
+ catch {
277
+ json = null;
278
+ }
279
+ return { sha256: sha256(bytes), json };
280
+ }
93
281
  async function listJsonFiles(dir) {
94
282
  try {
95
283
  const entries = await fsp.readdir(dir, { withFileTypes: true });
@@ -122,6 +310,12 @@ function dedupeSources(rows) {
122
310
  if (existing) {
123
311
  existing.claim_ids = [...new Set([...(existing.claim_ids || []), ...(normalized.claim_ids || [])])];
124
312
  existing.notes = [existing.notes, normalized.notes].filter(Boolean).join('\n');
313
+ existing.counterevidence_target_claim_id ||= normalized.counterevidence_target_claim_id;
314
+ existing.counterevidence_target_claim_ids = [...new Set([...(existing.counterevidence_target_claim_ids || []), ...(normalized.counterevidence_target_claim_ids || [])])];
315
+ existing.contradiction_rationale ||= normalized.contradiction_rationale;
316
+ if (normalized.super_search_provenance?.validated === true && existing.super_search_provenance?.validated !== true) {
317
+ existing.super_search_provenance = normalized.super_search_provenance;
318
+ }
125
319
  byKey.set(existing.id, existing);
126
320
  byKey.set(key, existing);
127
321
  }
@@ -148,12 +342,53 @@ function normalizeSourceRow(row) {
148
342
  supports: normalizeStringList(row?.supports),
149
343
  undermines: normalizeStringList(row?.undermines),
150
344
  claim_ids: normalizeStringList(row?.claim_ids),
151
- notes: String(row?.notes || '').trim()
345
+ counterevidence_target_claim_id: row?.counterevidence_target_claim_id ? String(row.counterevidence_target_claim_id).trim() : null,
346
+ counterevidence_target_claim_ids: normalizeStringList(row?.counterevidence_target_claim_ids),
347
+ contradiction_rationale: row?.contradiction_rationale ? String(row.contradiction_rationale).trim() : null,
348
+ notes: String(row?.notes || '').trim(),
349
+ semantic_claim_linked: row?.semantic_claim_linked === true,
350
+ content_artifact: row?.content_artifact ? String(row.content_artifact) : null,
351
+ content_sha256: row?.content_sha256 ? String(row.content_sha256) : null,
352
+ content_length: Number.isFinite(Number(row?.content_length)) ? Number(row.content_length) : null,
353
+ acquisition_verdict: row?.acquisition_verdict ? String(row.acquisition_verdict) : null,
354
+ domain: row?.domain ? String(row.domain) : null,
355
+ authority_tier: row?.authority_tier ? String(row.authority_tier) : null,
356
+ primary_source: row?.primary_source === true,
357
+ independence_cluster_id: row?.independence_cluster_id ? String(row.independence_cluster_id) : null,
358
+ super_search_provenance: row?.super_search_provenance && typeof row.super_search_provenance === 'object'
359
+ ? { ...row.super_search_provenance }
360
+ : null
152
361
  };
153
362
  }
363
+ function fixtureEvidence(source) {
364
+ return /^(?:deterministic_fixture|mock|selftest(?:-|$))/i.test(String(source?.kind || ''));
365
+ }
366
+ function verifiedEvidence(source) {
367
+ return String(source?.acquisition_verdict || '') === 'verified_content'
368
+ && /^verified_content:/i.test(String(source?.credibility || ''))
369
+ && Boolean(String(source?.content_artifact || '').trim())
370
+ && /^[a-f0-9]{64}$/i.test(String(source?.content_sha256 || '').trim())
371
+ && Number(source?.content_length || 0) > 0
372
+ && source?.super_search_provenance?.validated === true;
373
+ }
374
+ function supportLinkAllowed(source, isCounterSource) {
375
+ return !isCounterSource && source?.stance !== 'undermines' && (verifiedEvidence(source) || fixtureEvidence(source));
376
+ }
377
+ function counterevidenceLinkAllowed(source) {
378
+ return verifiedEvidence(source) || fixtureEvidence(source);
379
+ }
380
+ function structuredCounterevidence(source) {
381
+ const targetClaimIds = normalizeStringList([
382
+ ...normalizeStringList(source?.counterevidence_target_claim_ids),
383
+ source?.counterevidence_target_claim_id
384
+ ]);
385
+ return targetClaimIds.length > 0 && String(source?.contradiction_rationale || '').trim().length >= 16;
386
+ }
154
387
  function buildCrossLayerChecks(rows) {
155
388
  const byClaim = new Map();
156
389
  for (const row of rows) {
390
+ if (row.semantic_claim_linked !== true && !/^(?:deterministic_fixture|selftest|mock)$/i.test(String(row.kind || '')))
391
+ continue;
157
392
  for (const claimId of normalizeStringList(row.claim_ids)) {
158
393
  const current = byClaim.get(claimId) || [];
159
394
  current.push(row);
@@ -165,19 +400,22 @@ function buildCrossLayerChecks(rows) {
165
400
  claim: claimId,
166
401
  source_ids: claimRows.map((row) => row.id),
167
402
  layers: [...new Set(claimRows.map((row) => row.layer))],
168
- result: 'cross_layer_evidence_recorded'
403
+ result: 'semantic_cross_layer_evidence_recorded'
169
404
  }));
170
405
  }
171
- function buildCitationCoverage(rows) {
406
+ function buildCitationCoverage(rows, keyClaimIds = []) {
172
407
  const cited = [...new Set(rows.flatMap((row) => normalizeStringList(row.claim_ids)))];
173
408
  const sourceClaimMap = Object.fromEntries(rows.map((row) => [row.id, normalizeStringList(row.claim_ids)]));
409
+ const keys = [...new Set(keyClaimIds.filter(Boolean))];
174
410
  return {
175
- all_key_claims_cited: cited.length >= 8,
176
- key_claim_ids: cited.slice(0, 8),
411
+ all_key_claims_cited: keys.length > 0 && keys.every((claimId) => cited.includes(claimId)),
412
+ key_claim_ids: keys,
177
413
  cited_claim_ids: cited,
178
- uncited_claim_ids: [],
414
+ uncited_claim_ids: keys.filter((claimId) => !cited.includes(claimId)),
179
415
  source_claim_map: sourceClaimMap,
180
- notes: ['Citation coverage was built from source shard claim_ids.']
416
+ notes: keys.length
417
+ ? ['Citation coverage was rebuilt from the validated claim-evidence matrix.']
418
+ : ['Source discovery rows are not treated as cited key claims until semantic claim synthesis completes.']
181
419
  };
182
420
  }
183
421
  function normalizeStringList(value) {
@@ -1,70 +1,6 @@
1
1
  import { nowIso } from '../fsx.js';
2
- export const RESEARCH_SOURCE_LAYERS = Object.freeze([
3
- {
4
- id: 'academic_literature',
5
- label: 'Academic literature',
6
- purpose: 'Find papers, preprints, reviews, citations, and archival scholarly evidence before synthesis.',
7
- evidence_role: 'formal_evidence',
8
- examples: ['arXiv', 'Semantic Scholar', 'OpenAlex', 'Crossref', 'PubMed'],
9
- query_templates: ['"<topic>" arxiv', '"<topic>" Semantic Scholar', '"<topic>" OpenAlex Crossref PubMed']
10
- },
11
- {
12
- id: 'official_government_data',
13
- label: 'Official government data',
14
- purpose: 'Ground claims in public datasets, policy papers, national statistics, and leading-institution sources.',
15
- evidence_role: 'authoritative_baseline',
16
- examples: ['World Bank', 'OECD', 'Eurostat', 'data.gov', 'NIST'],
17
- query_templates: ['"<topic>" site:worldbank.org OR site:oecd.org', '"<topic>" site:data.gov', '"<topic>" site:nist.gov']
18
- },
19
- {
20
- id: 'standards_primary_docs',
21
- label: 'Standards and primary documents',
22
- purpose: 'Check specifications, standards, RFCs, policy originals, and official project documents before relying on summaries.',
23
- evidence_role: 'primary_source',
24
- examples: ['IETF RFCs', 'W3C', 'ISO abstracts', 'official standards bodies'],
25
- query_templates: ['"<topic>" RFC standard specification', '"<topic>" W3C IETF NIST standard', '"<topic>" official specification']
26
- },
27
- {
28
- id: 'news_current_events',
29
- label: 'News and current events',
30
- purpose: 'Capture recent events, public impact, and regional framing from reputable news and current-event indices.',
31
- evidence_role: 'recency_signal',
32
- examples: ['GDELT', 'BBC', 'Reuters', 'AP', 'regional reputable outlets'],
33
- query_templates: ['"<topic>" latest Reuters AP', '"<topic>" GDELT news', '"<topic>" BBC analysis']
34
- },
35
- {
36
- id: 'public_discourse',
37
- label: 'Public discourse',
38
- purpose: 'Sample public practitioner and community discourse without treating popularity as truth.',
39
- evidence_role: 'sentiment_and_edge_cases',
40
- examples: ['X/Twitter', 'Reddit', 'Hacker News', 'public forums'],
41
- query_templates: ['"<topic>" site:x.com OR site:twitter.com', '"<topic>" site:reddit.com', '"<topic>" "Hacker News"']
42
- },
43
- {
44
- id: 'developer_practitioner',
45
- label: 'Developer and practitioner knowledge',
46
- purpose: 'Find implementation pitfalls, developer questions, bug reports, and operational lessons.',
47
- evidence_role: 'practice_feedback',
48
- examples: ['Stack Overflow', 'Stack Exchange', 'GitHub issues', 'release notes', 'engineering blogs'],
49
- query_templates: ['"<topic>" site:stackoverflow.com', '"<topic>" site:stackexchange.com', '"<topic>" site:github.com issues']
50
- },
51
- {
52
- id: 'counterevidence_factcheck',
53
- label: 'Counterevidence and fact checking',
54
- purpose: 'Actively search for failures, critiques, null results, retractions, fact checks, and source conflicts.',
55
- evidence_role: 'falsification',
56
- examples: ['Fact checks', 'Retraction Watch', 'critical reviews', 'benchmark failures', 'negative results'],
57
- query_templates: ['"<topic>" critique failure limitation', '"<topic>" fact check retraction', '"<topic>" counterevidence null result']
58
- },
59
- {
60
- id: 'local_project_evidence',
61
- label: 'Local project evidence',
62
- purpose: 'Inspect repository-local files, scripts, docs, schemas, and tests as implementation evidence for handoff.',
63
- evidence_role: 'local_evidence',
64
- examples: ['git ls-files', 'package scripts', 'source modules', 'docs', 'schemas'],
65
- query_templates: ['git ls-files', 'rg "<topic>" src docs schemas package.json']
66
- }
67
- ]);
2
+ import { RESEARCH_SOURCE_LAYERS } from './research-source-layer-catalog.js';
3
+ export { RESEARCH_SOURCE_LAYERS } from './research-source-layer-catalog.js';
68
4
  export function researchSourceLayerById(id) {
69
5
  return RESEARCH_SOURCE_LAYERS.find((layer) => layer.id === id) || RESEARCH_SOURCE_LAYERS[0];
70
6
  }
@@ -93,7 +29,7 @@ export function defaultResearchSourceShardOutput(plan, layer, cycle = 1) {
93
29
  const secondaryClaimIds = layer.id === 'counterevidence_factcheck'
94
30
  ? ['stage-claim-1', 'stage-claim-2', 'stage-claim-8']
95
31
  : layer.id === 'local_project_evidence' ? [secondClaim, 'stage-claim-7', 'stage-claim-8'] : [secondClaim];
96
- const stance = layer.id === 'counterevidence_factcheck' ? 'undermines' : layer.id === 'local_project_evidence' ? 'context' : 'supports';
32
+ const stance = layer.id === 'counterevidence_factcheck' ? 'undermines' : 'supports';
97
33
  return {
98
34
  schema: 'sks.research-source-shard-output.v1',
99
35
  mission_id: missionId,
@@ -107,7 +43,7 @@ export function defaultResearchSourceShardOutput(plan, layer, cycle = 1) {
107
43
  {
108
44
  id: `shard-${layer.id}-primary`,
109
45
  layer: layer.id,
110
- kind: layer.id === 'local_project_evidence' ? 'local_project' : 'deterministic_fixture',
46
+ kind: 'deterministic_fixture',
111
47
  title: `${layer.label} primary evidence for ${topic}`,
112
48
  locator: layer.id === 'local_project_evidence' ? 'git ls-files' : `deterministic://${layer.id}/primary`,
113
49
  publisher_or_author: layer.id === 'local_project_evidence' ? 'local repository' : 'SKS deterministic research shard',
@@ -117,12 +53,17 @@ export function defaultResearchSourceShardOutput(plan, layer, cycle = 1) {
117
53
  credibility: layer.id === 'public_discourse' ? 'contextual' : 'layer-appropriate',
118
54
  stance,
119
55
  claim_ids: primaryClaimIds,
56
+ ...(layer.id === 'counterevidence_factcheck' ? {
57
+ counterevidence_target_claim_id: primaryClaimIds[0],
58
+ counterevidence_target_claim_ids: [primaryClaimIds[0], 'stage-claim-7'],
59
+ contradiction_rationale: `Deterministic fixture challenges ${primaryClaimIds[0]} for counterevidence contract testing.`
60
+ } : {}),
120
61
  notes: `${layer.label} shard records reproducible evidence metadata for ${topic}.`
121
62
  },
122
63
  {
123
64
  id: `shard-${layer.id}-secondary`,
124
65
  layer: layer.id,
125
- kind: layer.id === 'local_project_evidence' ? 'local_project' : 'deterministic_fixture',
66
+ kind: 'deterministic_fixture',
126
67
  title: `${layer.label} secondary evidence for ${topic}`,
127
68
  locator: layer.id === 'local_project_evidence' ? 'package.json docs src schemas' : `deterministic://${layer.id}/secondary`,
128
69
  publisher_or_author: layer.id === 'local_project_evidence' ? 'local repository' : 'SKS deterministic research shard',
@@ -130,8 +71,13 @@ export function defaultResearchSourceShardOutput(plan, layer, cycle = 1) {
130
71
  accessed_at: nowIso(),
131
72
  reliability: 'medium',
132
73
  credibility: 'corroborating',
133
- stance: layer.id === 'counterevidence_factcheck' ? 'undermines' : 'mixed',
74
+ stance: layer.id === 'counterevidence_factcheck' ? 'undermines' : 'supports',
134
75
  claim_ids: secondaryClaimIds,
76
+ ...(layer.id === 'counterevidence_factcheck' ? {
77
+ counterevidence_target_claim_id: secondaryClaimIds[1] || secondaryClaimIds[0],
78
+ counterevidence_target_claim_ids: [secondaryClaimIds[1] || secondaryClaimIds[0], 'stage-claim-8'],
79
+ contradiction_rationale: `Deterministic fixture challenges ${secondaryClaimIds[1] || secondaryClaimIds[0]} for counterevidence contract testing.`
80
+ } : {}),
135
81
  notes: `${layer.label} shard adds a second row so merger and triangulation are observable.`
136
82
  }
137
83
  ],
@@ -157,6 +103,16 @@ export function validateResearchSourceShardOutput(output) {
157
103
  }
158
104
  if (!Array.isArray(source?.claim_ids) || source.claim_ids.length === 0)
159
105
  blockers.push(`source_shard_claim_ids_missing:${source?.id || 'unknown'}`);
106
+ if (source?.stance === 'undermines') {
107
+ const targetClaimIds = [
108
+ ...(Array.isArray(source?.counterevidence_target_claim_ids) ? source.counterevidence_target_claim_ids : []),
109
+ source?.counterevidence_target_claim_id
110
+ ].map((value) => String(value || '').trim()).filter(Boolean);
111
+ if (!targetClaimIds.length)
112
+ blockers.push(`source_shard_counterevidence_target_missing:${source?.id || 'unknown'}`);
113
+ if (!String(source?.contradiction_rationale || '').trim())
114
+ blockers.push(`source_shard_counterevidence_rationale_missing:${source?.id || 'unknown'}`);
115
+ }
160
116
  }
161
117
  return { ok: blockers.length === 0, blockers: [...new Set(blockers)] };
162
118
  }