sneakoscope 4.8.7 → 5.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 (288) hide show
  1. package/README.md +51 -726
  2. package/bench/tasks/t01-off-by-one/repo/package.json +9 -0
  3. package/bench/tasks/t01-off-by-one/repo/src/pagination.js +5 -0
  4. package/bench/tasks/t01-off-by-one/repo/test.js +5 -0
  5. package/bench/tasks/t01-off-by-one/task.json +13 -0
  6. package/bench/tasks/t02-signature-cochange/repo/package.json +9 -0
  7. package/bench/tasks/t02-signature-cochange/repo/src/admin.js +5 -0
  8. package/bench/tasks/t02-signature-cochange/repo/src/audit.js +5 -0
  9. package/bench/tasks/t02-signature-cochange/repo/src/labels.js +3 -0
  10. package/bench/tasks/t02-signature-cochange/repo/src/profile.js +5 -0
  11. package/bench/tasks/t02-signature-cochange/repo/test.js +9 -0
  12. package/bench/tasks/t02-signature-cochange/task.json +12 -0
  13. package/bench/tasks/t03-type-puzzle/repo/package.json +9 -0
  14. package/bench/tasks/t03-type-puzzle/repo/src/config.js +4 -0
  15. package/bench/tasks/t03-type-puzzle/repo/test.js +6 -0
  16. package/bench/tasks/t03-type-puzzle/task.json +13 -0
  17. package/bench/tasks/t04-refactor-preserve/repo/package.json +9 -0
  18. package/bench/tasks/t04-refactor-preserve/repo/src/cart.js +8 -0
  19. package/bench/tasks/t04-refactor-preserve/repo/test.js +4 -0
  20. package/bench/tasks/t04-refactor-preserve/task.json +12 -0
  21. package/bench/tasks/t05-performance/repo/package.json +9 -0
  22. package/bench/tasks/t05-performance/repo/src/pairs.js +9 -0
  23. package/bench/tasks/t05-performance/repo/test.js +11 -0
  24. package/bench/tasks/t05-performance/task.json +12 -0
  25. package/bench/tasks/t06-mistake-rule/repo/package.json +9 -0
  26. package/bench/tasks/t06-mistake-rule/repo/src/loader.js +6 -0
  27. package/bench/tasks/t06-mistake-rule/repo/test.js +7 -0
  28. package/bench/tasks/t06-mistake-rule/task.json +12 -0
  29. package/config/bench-baseline.json +7 -0
  30. package/crates/sks-core/Cargo.lock +1 -1
  31. package/crates/sks-core/Cargo.toml +1 -1
  32. package/crates/sks-core/src/main.rs +1 -1
  33. package/dist/bin/install.js +35 -0
  34. package/dist/bin/sks.js +1 -1
  35. package/dist/cli/cli-theme.js +51 -0
  36. package/dist/cli/command-registry.js +15 -4
  37. package/dist/cli/help-fast.js +18 -8
  38. package/dist/cli/insane-search-command.js +36 -8
  39. package/dist/cli/install-helpers.js +32 -0
  40. package/dist/commands/codex-lb.js +2 -0
  41. package/dist/commands/doctor.js +62 -6
  42. package/dist/commands/proof.js +6 -3
  43. package/dist/config/skills-manifest.json +82 -54
  44. package/dist/core/agents/agent-conflict-graph.js +5 -0
  45. package/dist/core/agents/agent-lease.js +5 -0
  46. package/dist/core/agents/agent-ledger-schemas.js +1 -0
  47. package/dist/core/agents/agent-orchestrator.js +268 -62
  48. package/dist/core/agents/agent-output-validator.js +14 -3
  49. package/dist/core/agents/agent-patch-queue-store.js +95 -2
  50. package/dist/core/agents/agent-patch-queue.js +6 -3
  51. package/dist/core/agents/agent-patch-schema.js +13 -0
  52. package/dist/core/agents/agent-proof-evidence.js +6 -1
  53. package/dist/core/agents/agent-runner-fake.js +40 -0
  54. package/dist/core/agents/agent-worker-pipeline.js +36 -2
  55. package/dist/core/agents/codex-exec-worker-adapter.js +2 -0
  56. package/dist/core/agents/native-worker-backend-router.js +58 -1
  57. package/dist/core/codex-app/sks-menubar.js +18 -5
  58. package/dist/core/codex-app.js +1 -0
  59. package/dist/core/codex-control/codex-sdk-config-policy.js +2 -1
  60. package/dist/core/codex-control/codex-sdk-env-policy.js +1 -1
  61. package/dist/core/codex-control/schemas/agent-worker-result.schema.js +12 -3
  62. package/dist/core/codex-hooks/codex-hook-managed-install.js +5 -0
  63. package/dist/core/codex-hooks/codex-hook-state-writer.js +70 -11
  64. package/dist/core/codex-hooks/codex-hook-trust-doctor.js +2 -2
  65. package/dist/core/codex-lb/codex-lb-env.js +20 -1
  66. package/dist/core/commands/basic-cli.js +21 -2
  67. package/dist/core/commands/check-command.js +37 -5
  68. package/dist/core/commands/computer-use-command.js +62 -7
  69. package/dist/core/commands/db-command.js +31 -5
  70. package/dist/core/commands/fast-mode-command.js +3 -0
  71. package/dist/core/commands/gate-result-contract.js +43 -0
  72. package/dist/core/commands/gates-command.js +6 -1
  73. package/dist/core/commands/gc-command.js +29 -2
  74. package/dist/core/commands/goal-command.js +9 -2
  75. package/dist/core/commands/gx-command.js +79 -7
  76. package/dist/core/commands/image-ux-review-command.js +188 -13
  77. package/dist/core/commands/mad-db-command.js +85 -176
  78. package/dist/core/commands/mad-sks-command.js +230 -29
  79. package/dist/core/commands/menubar-command.js +22 -1
  80. package/dist/core/commands/naruto-command.js +64 -10
  81. package/dist/core/commands/plan-command.js +76 -0
  82. package/dist/core/commands/ppt-command.js +159 -24
  83. package/dist/core/commands/qa-loop-command.js +6 -2
  84. package/dist/core/commands/release-command.js +55 -2
  85. package/dist/core/commands/research-command.js +1 -1
  86. package/dist/core/commands/review-command.js +217 -0
  87. package/dist/core/commands/route-success-helpers.js +59 -0
  88. package/dist/core/commands/run-command.js +19 -7
  89. package/dist/core/commands/seo-command.js +49 -1
  90. package/dist/core/commands/ui-command.js +161 -0
  91. package/dist/core/commands/uninstall-command.js +15 -1
  92. package/dist/core/db-safety.js +2 -2
  93. package/dist/core/doctor/doctor-transaction.js +8 -0
  94. package/dist/core/doctor/doctor-zellij-repair.js +1 -0
  95. package/dist/core/doctor/imagegen-repair.js +161 -0
  96. package/dist/core/feature-fixture-runner.js +2 -2
  97. package/dist/core/feature-fixtures.js +58 -37
  98. package/dist/core/feature-registry.js +102 -2
  99. package/dist/core/fsx.js +39 -6
  100. package/dist/core/image-ux-review/imagegen-adapter.js +48 -11
  101. package/dist/core/image-ux-review.js +16 -0
  102. package/dist/core/imagegen/imagegen-capability.js +11 -5
  103. package/dist/core/imagegen/require-imagegen.js +57 -0
  104. package/dist/core/init/skills.js +10 -5
  105. package/dist/core/mad-db/mad-db-coordinator.js +94 -18
  106. package/dist/core/mad-db/mad-db-policy.js +12 -10
  107. package/dist/core/mad-sks/executors/executor-base.js +8 -2
  108. package/dist/core/mad-sks/executors/index.js +4 -0
  109. package/dist/core/mad-sks/executors/sql-plane-executor.js +194 -0
  110. package/dist/core/naruto/naruto-active-pool.js +15 -4
  111. package/dist/core/naruto/naruto-real-worker-child.js +10 -0
  112. package/dist/core/naruto/naruto-role-policy.js +3 -0
  113. package/dist/core/naruto/naruto-task-hints.js +10 -0
  114. package/dist/core/naruto/naruto-work-graph.js +8 -2
  115. package/dist/core/naruto/naruto-work-item.js +6 -0
  116. package/dist/core/naruto/solution-tournament.js +101 -0
  117. package/dist/core/permission-gates.js +30 -0
  118. package/dist/core/pipeline-internals/runtime-core.js +11 -3
  119. package/dist/core/pipeline-internals/runtime-gates.js +27 -0
  120. package/dist/core/ppt-review/index.js +6 -1
  121. package/dist/core/ppt-review/slide-imagegen-review.js +75 -10
  122. package/dist/core/ppt.js +70 -2
  123. package/dist/core/proof/auto-finalize.js +70 -11
  124. package/dist/core/proof/proof-schema.js +2 -0
  125. package/dist/core/proof/route-adapter.js +5 -1
  126. package/dist/core/proof/route-finalizer.js +8 -5
  127. package/dist/core/proof/selftest-proof-fixtures.js +18 -5
  128. package/dist/core/proof/validation.js +2 -0
  129. package/dist/core/provider/model-router.js +53 -0
  130. package/dist/core/release/release-gate-node.js +3 -0
  131. package/dist/core/release/release-gate-resource-governor.js +1 -0
  132. package/dist/core/routes/constants.js +1 -1
  133. package/dist/core/routes.js +65 -18
  134. package/dist/core/safety/mutation-guard.js +5 -1
  135. package/dist/core/stop-gate/gate-evaluator.js +102 -0
  136. package/dist/core/stop-gate/stop-gate-check.js +16 -1
  137. package/dist/core/stop-gate/stop-gate-writer.js +4 -0
  138. package/dist/core/triwiki/agents-md-projector.js +184 -0
  139. package/dist/core/triwiki-wrongness/wrongness-schema.js +3 -1
  140. package/dist/core/trust-kernel/trust-kernel-schema.js +1 -0
  141. package/dist/core/trust-kernel/trust-report.js +1 -1
  142. package/dist/core/trust-kernel/trust-status.js +2 -0
  143. package/dist/core/ui/dashboard-html.js +111 -0
  144. package/dist/core/update/update-migration-state.js +366 -15
  145. package/dist/core/update-check.js +178 -81
  146. package/dist/core/verification/diff-quality.js +100 -0
  147. package/dist/core/verification/impact-scan.js +164 -0
  148. package/dist/core/verification/machine-feedback.js +146 -0
  149. package/dist/core/verification/mistake-rule-compiler.js +195 -0
  150. package/dist/core/version.js +1 -1
  151. package/dist/core/zellij/zellij-self-heal.js +9 -6
  152. package/dist/scripts/check-feature-quality.js +2 -2
  153. package/dist/scripts/cli-output-consistency-check.js +57 -0
  154. package/dist/scripts/coding-bench-check.js +136 -0
  155. package/dist/scripts/doctor-imagegen-repair-check.js +62 -0
  156. package/dist/scripts/ensure-bin-executable.js +11 -3
  157. package/dist/scripts/harness-benchmark-check.js +104 -0
  158. package/dist/scripts/legacy-update-e2e-check.js +228 -0
  159. package/dist/scripts/mad-db-command-check.js +11 -8
  160. package/dist/scripts/mad-db-route-identity-check.js +8 -6
  161. package/dist/scripts/mad-db-safety-conflict-matrix-check.js +31 -8
  162. package/dist/scripts/mad-db-skill-policy-snapshot-check.js +4 -5
  163. package/dist/scripts/ppt-real-imagegen-wiring-check.js +5 -1
  164. package/dist/scripts/proof-root-cause-policy-check.js +2 -0
  165. package/dist/scripts/release-dag-full-coverage-check.js +13 -4
  166. package/dist/scripts/release-gate-dag-runner.js +14 -0
  167. package/dist/scripts/release-gate-existence-audit.js +2 -1
  168. package/dist/scripts/release-gate-planner.js +2 -1
  169. package/dist/scripts/release-gate-script-parity-check.js +1 -1
  170. package/dist/scripts/release-metadata-1-19-check.js +2 -1
  171. package/dist/scripts/seo-geo-feature-fixture-quality-check.js +1 -1
  172. package/dist/scripts/sks-1-11-gate-lib.js +8 -6
  173. package/dist/scripts/ux-review-real-loop-fixture-check.js +9 -4
  174. package/dist/scripts/ux-review-run-wires-imagegen-check.js +4 -0
  175. package/docs/assets/sneakoscope-architecture-pipeline.jpg +0 -0
  176. package/docs/demo.tape +28 -0
  177. package/package.json +67 -3
  178. package/schemas/codex/completion-proof.schema.json +3 -2
  179. package/schemas/release/release-gate-node.schema.json +2 -1
  180. package/dist/scripts/agent-backfill-route-blackbox.js +0 -5
  181. package/dist/scripts/agent-dynamic-pool-route-blackbox.js +0 -5
  182. package/dist/scripts/agent-parallel-write-blackbox.js +0 -56
  183. package/dist/scripts/agent-patch-swarm-route-blackbox.js +0 -10
  184. package/dist/scripts/agent-route-blackbox-lib.js +0 -132
  185. package/dist/scripts/blackbox-command-import-smoke.js +0 -143
  186. package/dist/scripts/blackbox-global-shim.js +0 -77
  187. package/dist/scripts/blackbox-matrix.js +0 -70
  188. package/dist/scripts/blackbox-npx-one-shot.js +0 -69
  189. package/dist/scripts/blackbox-pack-install.js +0 -174
  190. package/dist/scripts/brand-neutrality-zero-leakage-blackbox.js +0 -4
  191. package/dist/scripts/build-once-runner-blackbox.js +0 -34
  192. package/dist/scripts/codex-0140-integration-blackbox.js +0 -13
  193. package/dist/scripts/codex-agent-type-blackbox.js +0 -4
  194. package/dist/scripts/codex-app-harness-blackbox.js +0 -4
  195. package/dist/scripts/codex-app-skill-agent-blackbox.js +0 -4
  196. package/dist/scripts/codex-hook-approval-blackbox.js +0 -4
  197. package/dist/scripts/codex-init-deep-directory-local-blackbox.js +0 -4
  198. package/dist/scripts/codex-native-feature-broker-blackbox.js +0 -4
  199. package/dist/scripts/codex-native-pattern-analysis-blackbox.js +0 -4
  200. package/dist/scripts/codex-native-read-repair-split-blackbox.js +0 -55
  201. package/dist/scripts/codex-native-reference-cache-blackbox.js +0 -41
  202. package/dist/scripts/core-skill-integrity-blackbox.js +0 -32
  203. package/dist/scripts/dfix-fast-blackbox-check.js +0 -37
  204. package/dist/scripts/dfix-parallel-write-blackbox.js +0 -48
  205. package/dist/scripts/dfix-patch-swarm-route-blackbox.js +0 -10
  206. package/dist/scripts/doctor-context7-mcp-repair-blackbox.js +0 -16
  207. package/dist/scripts/doctor-dirty-repair-blackbox.js +0 -22
  208. package/dist/scripts/doctor-dirty-semantic-blackbox.js +0 -8
  209. package/dist/scripts/doctor-fix-production-blackbox.js +0 -26
  210. package/dist/scripts/doctor-native-capability-repair-blackbox.js +0 -39
  211. package/dist/scripts/doctor-startup-config-repair-blackbox.js +0 -13
  212. package/dist/scripts/doctor-supabase-mcp-repair-blackbox.js +0 -14
  213. package/dist/scripts/doctor-transaction-engine-blackbox.js +0 -28
  214. package/dist/scripts/doctor-zellij-fix-blackbox.js +0 -4
  215. package/dist/scripts/doctor-zellij-no-homebrew-blackbox.js +0 -4
  216. package/dist/scripts/doctor-zellij-upgrade-blackbox.js +0 -4
  217. package/dist/scripts/gate-pack-runner-blackbox.js +0 -27
  218. package/dist/scripts/gate-pack-v2-blackbox.js +0 -18
  219. package/dist/scripts/geo-cli-blackbox-check.js +0 -18
  220. package/dist/scripts/loop-collision-blackbox.js +0 -3
  221. package/dist/scripts/loop-concurrency-oversubscription-blackbox.js +0 -3
  222. package/dist/scripts/loop-fixture-production-misuse-blackbox.js +0 -3
  223. package/dist/scripts/loop-kill-interrupt-real-blackbox.js +0 -3
  224. package/dist/scripts/loop-merge-strategy-blackbox.js +0 -3
  225. package/dist/scripts/loop-mesh-production-e2e-blackbox.js +0 -3
  226. package/dist/scripts/loop-side-effect-blackbox.js +0 -3
  227. package/dist/scripts/mad-db-operation-lifecycle-blackbox.js +0 -29
  228. package/dist/scripts/mad-sks-actual-executor-blackbox.js +0 -5
  229. package/dist/scripts/mad-zellij-headless-fallback-blackbox.js +0 -4
  230. package/dist/scripts/mad-zellij-self-heal-blackbox.js +0 -4
  231. package/dist/scripts/naruto-loop-mesh-blackbox.js +0 -3
  232. package/dist/scripts/naruto-real-parallelism-blackbox.js +0 -307
  233. package/dist/scripts/naruto-worktree-coding-blackbox.js +0 -29
  234. package/dist/scripts/parallel-runtime-real-blackbox.js +0 -44
  235. package/dist/scripts/pipeline-codex-native-doctor-mad-routing-real-blackbox.js +0 -77
  236. package/dist/scripts/pipeline-codex-native-e2e-blackbox.js +0 -13
  237. package/dist/scripts/pipeline-codex-native-image-routing-real-blackbox.js +0 -50
  238. package/dist/scripts/pipeline-codex-native-loop-routing-real-blackbox.js +0 -74
  239. package/dist/scripts/pipeline-codex-native-qa-routing-real-blackbox.js +0 -51
  240. package/dist/scripts/pipeline-codex-native-research-routing-real-blackbox.js +0 -45
  241. package/dist/scripts/pipeline-execution-profile-routing-blackbox.js +0 -4
  242. package/dist/scripts/postinstall-global-doctor-blackbox.js +0 -12
  243. package/dist/scripts/ppt-full-e2e-blackbox-check.js +0 -109
  244. package/dist/scripts/ppt-imagegen-blackbox-check.js +0 -46
  245. package/dist/scripts/project-skill-dedupe-blackbox.js +0 -36
  246. package/dist/scripts/qa-backfill-route-blackbox.js +0 -5
  247. package/dist/scripts/qa-patch-swarm-route-blackbox.js +0 -10
  248. package/dist/scripts/release-full-parallelism-blackbox.js +0 -41
  249. package/dist/scripts/release-triwiki-first-runner-blackbox.js +0 -48
  250. package/dist/scripts/release-wiring-3110-blackbox.js +0 -27
  251. package/dist/scripts/release-wiring-3112-blackbox.js +0 -17
  252. package/dist/scripts/release-wiring-3113-blackbox.js +0 -17
  253. package/dist/scripts/research-backfill-route-blackbox.js +0 -5
  254. package/dist/scripts/research-final-reviewer-blackbox.js +0 -70
  255. package/dist/scripts/research-stage-cycle-runtime-blackbox.js +0 -40
  256. package/dist/scripts/research-synthesis-writer-blackbox.js +0 -24
  257. package/dist/scripts/route-blackbox-realism-check.js +0 -21
  258. package/dist/scripts/scheduler-resource-claim-blackbox.js +0 -24
  259. package/dist/scripts/seo-cli-blackbox-check.js +0 -18
  260. package/dist/scripts/sks-3110-all-feature-regression-blackbox.js +0 -116
  261. package/dist/scripts/sks-3112-all-feature-regression-blackbox.js +0 -29
  262. package/dist/scripts/sks-3113-all-feature-regression-blackbox.js +0 -17
  263. package/dist/scripts/sks-400-all-feature-regression-blackbox.js +0 -21
  264. package/dist/scripts/sks-400-extreme-parallel-blackbox.js +0 -8
  265. package/dist/scripts/sks-400-five-minute-blackbox.js +0 -9
  266. package/dist/scripts/sks-400-legacy-purge-blackbox.js +0 -8
  267. package/dist/scripts/sks-401-all-feature-regression-blackbox.js +0 -46
  268. package/dist/scripts/sks-401-five-minute-actual-blackbox.js +0 -23
  269. package/dist/scripts/sks-402-all-feature-regression-blackbox.js +0 -9
  270. package/dist/scripts/sks-402-five-minute-real-blackbox.js +0 -22
  271. package/dist/scripts/sksd-warm-cache-blackbox.js +0 -12
  272. package/dist/scripts/supabase-secret-preservation-blackbox.js +0 -29
  273. package/dist/scripts/team-backfill-route-blackbox.js +0 -5
  274. package/dist/scripts/team-parallel-write-blackbox.js +0 -55
  275. package/dist/scripts/team-patch-swarm-route-blackbox.js +0 -10
  276. package/dist/scripts/triwiki-affected-graph-blackbox.js +0 -28
  277. package/dist/scripts/triwiki-proof-bank-blackbox.js +0 -30
  278. package/dist/scripts/triwiki-proof-bank-lock-blackbox.js +0 -7
  279. package/dist/scripts/update-preserves-supabase-keys-blackbox.js +0 -27
  280. package/dist/scripts/ux-patch-swarm-route-blackbox.js +0 -10
  281. package/dist/scripts/ux-review-imagegen-blackbox-check.js +0 -67
  282. package/dist/scripts/zellij-initial-main-only-blackbox.js +0 -28
  283. package/dist/scripts/zellij-pane-lock-concurrency-blackbox.js +0 -80
  284. package/dist/scripts/zellij-pane-lock-open-worker-integration-blackbox.js +0 -137
  285. package/dist/scripts/zellij-self-heal-typed-blackbox.js +0 -4
  286. package/dist/scripts/zellij-slot-telemetry-real-blackbox.js +0 -20
  287. package/dist/scripts/zellij-stacked-fallback-integration-blackbox.js +0 -81
  288. package/dist/scripts/zellij-worker-pane-real-ui-blackbox.js +0 -202
@@ -790,11 +790,14 @@ function buildImagegenResponseArtifact(generatedReviewLedger = {}) {
790
790
  schema: 'sks.image-ux-gpt-image-2-response.v1',
791
791
  created_at: nowIso(),
792
792
  provider: image?.provider_surface || generatedReviewLedger.provider?.preferred_surface || 'none',
793
+ evidence_class: image?.evidence_class || (image?.mock ? 'mock_fixture' : image?.real_generated ? 'codex_app_imagegen' : null),
793
794
  model: 'gpt-image-2',
794
795
  ok: generatedReviewLedger.passed === true,
795
796
  status: generatedReviewLedger.passed === true ? 'generated' : 'blocked_or_pending',
796
797
  output_image_path: image?.path || null,
797
798
  output_image_sha256: image?.sha256 || null,
799
+ output_sha256: image?.output_sha256 || image?.sha256 || null,
800
+ output_source: image?.output_source || (image?.mock ? 'mock_fixture' : image?.real_generated ? 'manual_attach' : null),
798
801
  output_id: image?.output_id || null,
799
802
  dimensions: image ? { width: image.width || null, height: image.height || null, format: image.format || null } : null,
800
803
  latency_ms: image?.latency_ms || null,
@@ -863,6 +866,19 @@ function generatedImageEvidenceBlockers(image = {}, evidence = {}) {
863
866
  if (image.real_generated !== true || image.mock === true || image.source === 'mock_fixture')
864
867
  return [];
865
868
  const blockers = [];
869
+ const evidenceClass = String(image.evidence_class || '');
870
+ const outputSource = String(image.output_source || '');
871
+ const outputSha = String(image.output_sha256 || image.output_image_sha256 || '');
872
+ if (!evidenceClass)
873
+ blockers.push('generated_review_image_evidence_class_missing');
874
+ else if (evidenceClass !== 'codex_app_imagegen')
875
+ blockers.push(`generated_review_image_evidence_class_not_codex_app:${evidenceClass}`);
876
+ if (outputSource && !['manual_attach', 'auto_discovered_generated_images'].includes(outputSource))
877
+ blockers.push(`generated_review_image_output_source_invalid:${outputSource}`);
878
+ if (!outputSha)
879
+ blockers.push('generated_review_image_output_sha256_missing');
880
+ else if (evidence.sha256 && outputSha !== evidence.sha256)
881
+ blockers.push('generated_review_image_output_sha256_mismatch');
866
882
  if (!image.path)
867
883
  blockers.push('generated_review_image_missing');
868
884
  if (!evidence.sha256)
@@ -18,8 +18,13 @@ export async function detectImagegenCapability(opts = {}) {
18
18
  }).catch(() => null);
19
19
  const apiFallbackAvailable = openaiApiKeyPresent;
20
20
  const fakeAdapterEnabled = opts.fake === true || env.SKS_TEST_FAKE_IMAGEGEN === '1';
21
- const realGenerationAvailable = codexAppBuiltInAvailable || apiFallbackAvailable;
22
- const routeGenerationAvailable = realGenerationAvailable || fakeAdapterEnabled;
21
+ const fakeAdapterAcceptedForRoute = fakeAdapterEnabled && (opts.mockContext === true
22
+ || opts.testContext === true
23
+ || env.NODE_ENV === 'test'
24
+ || env.SKS_SELFTEST_MOCK === '1'
25
+ || env.SKS_MOCK === '1');
26
+ const realGenerationAvailable = codexAppBuiltInAvailable;
27
+ const routeGenerationAvailable = codexAppBuiltInAvailable || fakeAdapterAcceptedForRoute;
23
28
  const coreReady = codexAppBuiltInAvailable;
24
29
  const coreBlockers = coreReady ? [] : ['codex_app_builtin_imagegen_capability_missing'];
25
30
  const routeGenerationBlockers = routeGenerationAvailable ? [] : ['imagegen_capability_missing'];
@@ -68,16 +73,17 @@ export async function detectImagegenCapability(opts = {}) {
68
73
  },
69
74
  fake_adapter: {
70
75
  available: fakeAdapterEnabled,
76
+ accepted_for_route_readiness: fakeAdapterAcceptedForRoute,
71
77
  env: 'SKS_TEST_FAKE_IMAGEGEN=1',
72
78
  source: 'mock_like_fixture',
73
79
  real_generation_claim_allowed: false
74
80
  },
75
- supports_reference_image: codexAppBuiltInAvailable || apiFallbackAvailable || fakeAdapterEnabled,
81
+ supports_reference_image: codexAppBuiltInAvailable || fakeAdapterAcceptedForRoute,
76
82
  gpt_image_2_input_fidelity_automatic: true,
77
83
  input_fidelity_must_be_omitted: true,
78
84
  supported_workflows: {
79
- ux_review_callouts: codexAppBuiltInAvailable || apiFallbackAvailable || fakeAdapterEnabled,
80
- ppt_slide_callouts: codexAppBuiltInAvailable || apiFallbackAvailable || fakeAdapterEnabled,
85
+ ux_review_callouts: codexAppBuiltInAvailable || fakeAdapterAcceptedForRoute,
86
+ ppt_slide_callouts: codexAppBuiltInAvailable || fakeAdapterAcceptedForRoute,
81
87
  structured_extraction_required_after_generation: true,
82
88
  full_verification_requires_codex_app_output: true
83
89
  },
@@ -0,0 +1,57 @@
1
+ import { detectImagegenCapability } from './imagegen-capability.js';
2
+ import { repairCodexImagegen } from '../doctor/imagegen-repair.js';
3
+ export async function requireCodexImagegen(root, opts = {}) {
4
+ const capability = await detectImagegenCapability({
5
+ codexBin: opts.codexBin || undefined,
6
+ timeoutMs: opts.timeoutMs || 5000
7
+ }).catch((err) => ({
8
+ ok: false,
9
+ core_ready: false,
10
+ blockers: [err instanceof Error ? err.message : String(err)]
11
+ }));
12
+ if (capability.core_ready === true) {
13
+ return { ok: true, capability, repair: null, blocker: null, blockers: [] };
14
+ }
15
+ const repair = opts.autoRepair === true
16
+ ? await repairCodexImagegen({
17
+ root,
18
+ apply: opts.applyRepair === true,
19
+ codexBin: opts.codexBin || null,
20
+ timeoutMs: opts.timeoutMs || 5000
21
+ }).catch((err) => ({
22
+ ok: false,
23
+ recovered: false,
24
+ blockers: [err instanceof Error ? err.message : String(err)]
25
+ }))
26
+ : null;
27
+ const finalCapability = repair
28
+ ? repair.after || capability
29
+ : capability;
30
+ const ok = finalCapability.core_ready === true || repair?.recovered === true;
31
+ const blockers = ok ? [] : [
32
+ ...new Set([
33
+ ...((finalCapability?.core_blockers || []).map(String)),
34
+ ...((finalCapability?.blockers || []).map(String)),
35
+ ...((repair?.blockers || []).map(String)),
36
+ 'codex_imagegen_unavailable'
37
+ ])
38
+ ];
39
+ return {
40
+ ok,
41
+ capability: finalCapability,
42
+ repair,
43
+ blocker: ok ? null : {
44
+ schema: 'sks.codex-imagegen-required-blocker.v1',
45
+ blocker: 'codex_imagegen_unavailable',
46
+ status: 'blocked',
47
+ blockers,
48
+ next_actions: repair?.manual_actions || [
49
+ 'Install/update Codex CLI: npm i -g @openai/codex@latest',
50
+ 'Open Codex App settings and enable image_generation / $imagegen.',
51
+ 'Verify with: codex features list --json'
52
+ ]
53
+ },
54
+ blockers
55
+ };
56
+ }
57
+ //# sourceMappingURL=require-imagegen.js.map
@@ -25,11 +25,16 @@ function reflectionInstructionText(commandPrefix = 'sks') {
25
25
  return `Post-route reflection: full routes load \`reflection\` after work/tests and before final; DFix/Answer/Help/Wiki/SKS discovery are exempt. Write reflection.md; record only real misses/gaps, or no_issue_acknowledged. For lessons, append TriWiki claim rows to ${REFLECTION_MEMORY_PATH}. Run "${commandPrefix} wiki refresh" or pack, validate, then pass reflection-gate.json.`;
26
26
  }
27
27
  async function installOfficialSkills(root) {
28
- const imageUxReviewSkill = (name) => `---\nname: ${name}\ndescription: $Image-UX-Review/$UX-Review imagegen/gpt-image-2 annotated UI/UX review loop.\n---\n\nUse only for $Image-UX-Review, $UX-Review, $visual-review, or $ui-ux-review UI/UX review requests. ${imageUxReviewPipelinePolicyText()} Core loop: capture or attach source UI screenshots, then invoke Codex App $imagegen with gpt-image-2 to create a new generated annotated review image from each source screenshot, then analyze the generated review image with vision/OCR into image-ux-issue-ledger.json, then apply only requested safe fixes and recheck changed screens. Text-only screenshot critique cannot satisfy full verification; missing generated annotated review images keep full image-ux-review-gate.json verification blocked, but may close verified_partial/reference-only when source screenshots plus hashes, docs evidence, source Image Voxel anchors, and Honest Mode evidence exist. For live web/browser/webapp capture use Codex Chrome Extension first and halt if it is not installed/enabled; use Codex Computer Use only for native Mac/non-web app screens. Required artifacts: image-ux-review-policy.json, image-ux-screen-inventory.json, image-ux-generated-review-ledger.json, image-ux-issue-ledger.json, image-ux-iteration-report.json, image-ux-review-gate.json. Finish with reflection and Honest Mode.\n`;
28
+ const imageUxReviewSkill = (name) => `---\nname: ${name}\ndescription: $Image-UX-Review/$UX-Review imagegen/gpt-image-2 annotated UI/UX review loop.\n---\n\nUse only for $Image-UX-Review, $UX-Review, $visual-review, or $ui-ux-review UI/UX review requests. ${imageUxReviewPipelinePolicyText()} Route start must check Codex App imagegen capability and run the SKS imagegen repair loop once; if $imagegen/gpt-image-2 is still unavailable, stop with codex_imagegen_unavailable instead of doing text-only review or direct API substitution. Core loop: capture or attach source UI screenshots, then invoke Codex App $imagegen with gpt-image-2 to create a new generated annotated review image from each source screenshot, then analyze the generated review image with vision/OCR into image-ux-issue-ledger.json, then apply only requested safe fixes and recheck changed screens. Text-only screenshot critique cannot satisfy full verification; missing generated annotated review images keep full image-ux-review-gate.json verification blocked, but may close verified_partial/reference-only when source screenshots plus hashes, docs evidence, source Image Voxel anchors, and Honest Mode evidence exist. For live web/browser/webapp capture use Codex Chrome Extension first and halt if it is not installed/enabled; use Codex Computer Use only for native Mac/non-web app screens. Required artifacts: image-ux-review-policy.json, image-ux-screen-inventory.json, image-ux-generated-review-ledger.json, image-ux-issue-ledger.json, image-ux-iteration-report.json, image-ux-review-gate.json. Finish with reflection and Honest Mode.\n`;
29
+ const mergedMadDbSqlPlanePolicy = madDbSkillText().replace(/^---[\s\S]*?---\s*/, '').trim();
29
30
  const skills = {
30
31
  'dfix': `---\nname: dfix\ndescription: Direct Fix mode for $DFix or $dfix requests and inferred tiny copy/config/docs/labels/spacing/translation/simple mechanical edits.\n---\n\nUse for tiny copy/config/docs/labels/spacing/translation/simple mechanical edits. List exact micro-edits, inspect only needed files, apply only those edits, and run cheap verification. Keep broad implementation routed to Team; for UI/UX micro-edits read \`design.md\` when present and use imagegen for image/logo/raster assets. Bypass broad SKS routing, mission state, TriWiki/TriFix/reflection/state recording, Goal, Research, eval, redesign, and repeated full-route Honest Mode loops. Start the final answer with \`DFix 완료 요약:\` and include one \`DFix 솔직모드:\` line covering verified, not verified, and remaining issues. ${CODEX_IMAGEGEN_REQUIRED_POLICY}\n`,
31
32
  'answer': `---\nname: answer\ndescription: Answer-only research route for ordinary questions that should not start implementation.\n---\n\nUse for explanations, comparisons, status, facts, source-backed research, or docs guidance. Use repo/TriWiki first for project-local facts; hydrate low-trust claims from source. Browse or use Context7 for current external package/API/framework/MCP docs. End with a concise answer summary plus Honest Mode; do not create missions, subagents, or file edits.\n`,
32
33
  'sks': `---\nname: sks\ndescription: General Sneakoscope Codex command route for $SKS or $sks usage, setup, status, and workflow help.\n---\n\nUse local SKS commands: bootstrap, deps, commands, quickstart, codex-app, context7, guard, conflicts, reasoning, wiki, pipeline status, pipeline plan, skill-dream. Promote code-changing work to Team unless Answer/DFix/Help/Wiki/safety route fits. Surface route/guard/scope, use TriWiki, do not edit installed harness files outside this engine repo, and require human-approved conflict cleanup. ${skillDreamPolicyText()}\n`,
34
+ 'plan': `---\nname: plan\ndescription: Decision-complete planning only - writes .sneakoscope/plans/<slug>.md, never touches code. 예: $Plan "결제 모듈 리팩터"\n---\n\nUse when the user invokes $Plan or asks for a plan-only frontdoor. Produce a concrete plan artifact under .sneakoscope/plans/<slug>.md with goal, scope, files to inspect, implementation steps, acceptance checks, and rollback notes. Do not edit product/source files, generated harness files, package metadata, or docs beyond the plan artifact. Keep implementation_allowed=false and hand off execution to $Work only after the user or route explicitly moves from planning to work. Finish with what is planned, what remains unimplemented, and Honest Mode.\n`,
35
+ 'work': `---\nname: work\ndescription: Execute the latest plan with evidence-gated completion. 예: $Work\n---\n\nUse when the user invokes $Work or asks to execute the latest SKS plan. Resolve the newest .sneakoscope/plans/*.md, route execution through Naruto/Team evidence gates, keep leases and verification artifacts current, and do not claim completion without machine evidence or explicit blocker evidence. If no plan exists, block with a clear next action: run $Plan first or provide a task.\n`,
36
+ 'swarm': `---\nname: swarm\ndescription: Dynamic parallel swarm (naruto) with machine-verified gates. 예: $Swarm "fix all lint errors"\n---\n\nUse when the user invokes $Swarm or asks for dynamic parallel work. Delegate to the Naruto native shadow-clone swarm, preserve lease-safe write boundaries, keep agent ledgers and gate artifacts current, and sort machine verification evidence above LLM opinion. Finish through Naruto gate, reflection when required, and Honest Mode.\n`,
37
+ 'review': `---\nname: review\ndescription: Parallel diff review with machine-evidence first findings. 예: $Review 또는 sks review --staged\n---\n\nUse when the user asks for $Review or sks review. Review the selected diff read-only unless --fix is explicitly supplied. Machine evidence such as TypeScript, lint, tests, conflict markers, or secret scans outranks LLM findings and must be tagged evidence: machine; judgment-only findings must be tagged evidence: llm. --fix may attempt at most one machine-evidence fix pass and must re-run verification once. Do not mutate code for LLM-only opinions.\n`,
33
38
  'fast-mode': `---\nname: fast-mode\ndescription: Dollar-command route for $Fast-Mode, $Fast-On, and $Fast-Off global Codex Desktop Fast mode toggles.\n---\n\nUse when the user invokes $Fast-Mode, $Fast-On, $Fast-Off, or asks to turn SKS Fast mode on/off. Prefer \`sks fast-mode on|off|status|clear --json\`. By default on/off updates the global Codex Desktop config so GPT 5.5 Fast persists and also keeps .sneakoscope/state/fast-mode.json in sync for SKS workers. Use \`--project\` only when the user explicitly wants project-local worker preference without touching global Codex config. Explicit runtime flags still win: \`--fast\`, \`--no-fast\`, and \`--service-tier standard|fast\` override the saved preference for that run. Finish with a short status and Honest Mode; do not start Team or broad implementation for a toggle-only request.\n`,
34
39
  'fast-on': `---\nname: fast-on\ndescription: Alias for $Fast-On global Codex Desktop GPT 5.5 Fast enablement.\n---\n\nUse the same rules as fast-mode. Run or instruct \`sks fast-mode on --json\`, then report Global (desktop), Project (sks workers), state file, and the fact that explicit per-run flags still override the saved preference.\n`,
35
40
  'fast-off': `---\nname: fast-off\ndescription: Alias for $Fast-Off global Codex Desktop Fast mode disablement.\n---\n\nUse the same rules as fast-mode. Run or instruct \`sks fast-mode off --json\`, then report Global (desktop), Project (sks workers), state file, and the fact that explicit per-run flags still override the saved preference.\n`,
@@ -42,7 +47,7 @@ async function installOfficialSkills(root) {
42
47
  'shadow-clone': `---\nname: shadow-clone\ndescription: $ShadowClone alias for the $Naruto Shadow Clone Swarm high-scale parallel agent route.\n---\n\nUse the same rules as the naruto skill: this is the English alias for $Naruto / Kage Bunshin no Jutsu. Fan out up to 100 lease-safe parallel clone sessions on the native agent kernel via \`sks naruto run "<task>" [--clones N] [--backend codex-exec|fake] [--work-items N] [--json]\`. Clones run in fast service tier, are throttled to host capacity, take path leases for non-overlapping writes, and each emit per-clone proof; the parent integrates and verifies. Keep the same agent ledgers and finish with reflection and Honest Mode.\n`,
43
48
  'kage-bunshin': `---\nname: kage-bunshin\ndescription: $Kagebunshin alias for the $Naruto Shadow Clone Swarm (影分身) high-scale parallel agent route.\n---\n\nUse the same rules as the naruto skill: this is the 影分身 / Kage Bunshin no Jutsu alias for $Naruto. Fan out up to 100 lease-safe parallel clone sessions on the native agent kernel via \`sks naruto run "<task>" [--clones N] [--backend codex-exec|fake] [--work-items N] [--json]\`. Clones run in fast service tier, are throttled to host capacity, take path leases for non-overlapping writes, and each emit per-clone proof; the parent integrates and verifies. Keep the same agent ledgers and finish with reflection and Honest Mode.\n`,
44
49
  'qa-loop': `---\nname: qa-loop\ndescription: $QA-LOOP dogfoods UI/API as human proxy with safety gates, Codex Chrome Extension-first web UI evidence, safe fixes, rechecks, and a QA report.\n---\n\nUse only $QA-LOOP. Infer scope, target, mutation policy, and login boundary from the prompt plus TriWiki/current-code defaults; do not surface a prequestion sheet. Credentials are runtime-only; never save secrets. Web/browser/webapp UI-level E2E must run the Codex Chrome Extension readiness gate first; if the extension is missing or disabled, rapidly halt and ask the user to set it up, then resume only after the user confirms installation is complete. Codex Computer Use is reserved for native Mac/non-web surfaces and must not satisfy web UI evidence. Playwright, Selenium, Puppeteer, Browser Use, Chrome MCP, screenshots fabricated from code, and prose-only checks do not satisfy web UI/browser verification. ${CODEX_WEB_VERIFICATION_POLICY} Deployed targets are read-only; destructive removal is forbidden. After answer/run, dogfood real flows, apply safe contract-allowed code/test/docs fixes, recheck, and do not pass qa-gate.json with unresolved findings or without post_fix_verification_complete. Finish qa-ledger, date/version report, gate, completion summary, and Honest Mode.\n`,
45
- 'ppt': `---\nname: ppt\ndescription: $PPT information-first HTML/PDF presentation pipeline with inferred STP, audience, pain-point, format, research, design-system, and verification contract.\n---\n\nUse only when the user invokes $PPT or asks to create a presentation, deck, slides, pitch deck, proposal deck, HTML presentation, or PDF presentation artifact. Before artifact work, auto-seal presentation-specific answers from prompt, TriWiki/current-code defaults, and conservative policy: delivery context, target audience profile including role/average age/job/industry/topic familiarity/decision power, STP strategy, decision context and objections, and 3+ pain-point to solution mappings with expected aha moments. Do not surface a prequestion sheet. Presentation design must be simple, restrained, and information-first: avoid over-designed decoration, ornamental gradients, nested cards, and effects that compete with the message. Design detail should be embedded through typography hierarchy, spacing, alignment, thin rules, source clarity, and subtle accents. ${pptPipelineAllowlistPolicyText()} Use Product Design plugin first for context, ideation, prototype direction, audit, design QA, and share handoff. Use design.md only as an existing project-local cache or fallback SSOT when Product Design is unavailable; if fallback creation is needed, use docs/Design-Sys-Prompt.md plus getdesign-reference and curated DESIGN.md examples from ${AWESOME_DESIGN_MD_REFERENCE.url} only as source inputs, then fuse them into route-local PPT style tokens with a recorded design_ssot instead of treating references as parallel authorities. The $PPT route always loads imagegen as a required skill. When the sealed contract needs a generated raster asset or generated slide visual critique, immediately invoke Codex App \`$imagegen\` with gpt-image-2, move/copy the selected output into the mission assets or review evidence path, and record the real file path in ppt-image-asset-ledger.json or ppt-review-ledger.json before building or passing the gate. Direct API fallback, placeholder files, HTML/CSS stand-ins, and prose-only substitutes do not satisfy the route gate. ${productDesignPluginPolicyText()} ${CODEX_IMAGEGEN_REQUIRED_POLICY} Use web or Context7 evidence only when external facts/libraries/current docs are required by the PPT contract, record verified claims in ppt-fact-ledger.json, record generated image asset plans/results/blockers in ppt-image-asset-ledger.json, then create the PDF plus editable source HTML under source-html/, keep independent strategy/render/file-write phases parallel where inputs allow, record ppt-parallel-report.json, run the bounded ppt-review-policy/ppt-review-ledger/ppt-iteration-report loop, and verify readability, overlap, format fit, source coverage, export state, unsupported-claim status, image-asset completion, review-loop termination, and temporary build files cleanup. Finish with reflection and Honest Mode.\n`,
50
+ 'ppt': `---\nname: ppt\ndescription: $PPT information-first HTML/PDF presentation pipeline with inferred STP, audience, pain-point, format, research, design-system, and verification contract.\n---\n\nUse only when the user invokes $PPT or asks to create a presentation, deck, slides, pitch deck, proposal deck, HTML presentation, or PDF presentation artifact. Before artifact work, auto-seal presentation-specific answers from prompt, TriWiki/current-code defaults, and conservative policy: delivery context, target audience profile including role/average age/job/industry/topic familiarity/decision power, STP strategy, decision context and objections, and 3+ pain-point to solution mappings with expected aha moments. Do not surface a prequestion sheet. Presentation design must be simple, restrained, and information-first: avoid over-designed decoration, ornamental gradients, nested cards, and effects that compete with the message. Design detail should be embedded through typography hierarchy, spacing, alignment, thin rules, source clarity, and subtle accents. ${pptPipelineAllowlistPolicyText()} Use Product Design plugin first for context, ideation, prototype direction, audit, design QA, and share handoff. Use design.md only as an existing project-local cache or fallback SSOT when Product Design is unavailable; if fallback creation is needed, use docs/Design-Sys-Prompt.md plus getdesign-reference and curated DESIGN.md examples from ${AWESOME_DESIGN_MD_REFERENCE.url} only as source inputs, then fuse them into route-local PPT style tokens with a recorded design_ssot instead of treating references as parallel authorities. The $PPT route always loads imagegen as a required skill, checks Codex App imagegen at route start, and runs SKS auto-repair once before any image-dependent build/review work. If repair fails, stop with codex_imagegen_unavailable and do not continue with image-free or API-substituted evidence. When the sealed contract needs a generated raster asset or generated slide visual critique, immediately invoke Codex App \`$imagegen\` with gpt-image-2, move/copy the selected output into the mission assets or review evidence path, and record the real file path in ppt-image-asset-ledger.json or ppt-review-ledger.json before building or passing the gate. Direct API fallback, placeholder files, HTML/CSS stand-ins, and prose-only substitutes do not satisfy the route gate. ${productDesignPluginPolicyText()} ${CODEX_IMAGEGEN_REQUIRED_POLICY} Use web or Context7 evidence only when external facts/libraries/current docs are required by the PPT contract, record verified claims in ppt-fact-ledger.json, record generated image asset plans/results/blockers in ppt-image-asset-ledger.json, then create the PDF plus editable source HTML under source-html/, keep independent strategy/render/file-write phases parallel where inputs allow, record ppt-parallel-report.json, run the bounded ppt-review-policy/ppt-review-ledger/ppt-iteration-report loop, and verify readability, overlap, format fit, source coverage, export state, unsupported-claim status, image-asset completion, review-loop termination, and temporary build files cleanup. Finish with reflection and Honest Mode.\n`,
46
51
  'computer-use-fast': `---\nname: computer-use-fast\ndescription: Alias for the maximum-speed $Computer-Use/$CU native Codex Computer Use lane.\n---\n\nUse the same rules as computer-use: skip Team debate, QA-LOOP clarification, upfront TriWiki refresh, Context7, subagents, and reflection unless explicitly requested. Use Codex Computer Use directly only for native macOS, desktop-app, OS-settings, or non-web visual tasks. Browser, localhost, website, webapp, and web-based app verification must use the Codex Chrome Extension path first and must halt if that extension is not installed/enabled. At the end only, refresh/pack TriWiki, validate it, then provide a concise completion summary plus Honest Mode. ${CODEX_WEB_VERIFICATION_POLICY} ${CODEX_COMPUTER_USE_ONLY_POLICY}\n`,
47
52
  'cu': `---\nname: cu\ndescription: Short alias for the maximum-speed native $Computer-Use Codex Computer Use lane.\n---\n\nUse the same rules as computer-use. This is a speed lane for native macOS, desktop-app, OS-settings, and non-web visual tasks requiring Codex Computer Use evidence, with TriWiki refresh/validate and Honest Mode deferred to final closeout. Web/browser/webapp verification must use Codex Chrome Extension first and stop if the extension is not installed/enabled. ${CODEX_WEB_VERIFICATION_POLICY} ${CODEX_COMPUTER_USE_ONLY_POLICY}\n`,
48
53
  'goal': `---\nname: goal\ndescription: Fast $Goal/$goal bridge overlay for Codex native persisted /goal workflows.\n---\n\nUse when the user invokes $Goal/$goal or asks to persist a workflow with Codex native /goal continuation. Prepare with sks goal create or the $Goal route, write only the lightweight bridge artifacts, then use native Codex /goal create, pause, resume, and clear controls where available. Goal does not replace Team, QA, DB, or other SKS execution routes; continue implementation through the selected route and use Context7 only when external API/library docs are involved. Do not recreate the old no-question loop.\n`,
@@ -52,8 +57,8 @@ async function installOfficialSkills(root) {
52
57
  'research': `---\nname: research\ndescription: Dollar-command route for $Research or $research frontier discovery workflows.\n---\n\nUse when the user invokes $Research/$research or asks for research, hypotheses, new mechanisms, falsification, or testable predictions. Prefer sks research prepare and sks research run. Research is not an implementation route: do not edit repository source, docs, package metadata, generated skills, or harness files; write only route-local mission artifacts under .sneakoscope/missions/<mission-id>/. Run the genius-lens agent council with named persona-inspired cognitive roles: Einstein Agent, Feynman Agent, Turing Agent, von Neumann Agent, and Skeptic Agent. These are lenses only; do not impersonate the historical people. Every Research agent ledger row must include display_name, persona, persona_boundary, effort=xhigh, reasoning_effort=xhigh, service_tier when available, one literal "Eureka!" idea, falsifiers, cheap_probes, and challenge_or_response before synthesis. This is not a fixed three-cycle route: repeat source gathering, Eureka ideas, evidence-bound debate, falsification, and synthesis pressure until every agent records final agreement, or until the explicit max-cycle safety cap pauses with an unpassed gate. Create research-source-skill.md as a route-local Skill Creator artifact, then maximize layered public web/source search across latest papers, official/government or leading-institution data, standards/primary docs, current news, public discourse, developer/practitioner sources, traditional background sources, and counterevidence before synthesis. Record research-source-skill.md, source-ledger.json, agent-ledger.json, debate-ledger.json, novelty-ledger.json, falsification-ledger.json, research-report.md, research-paper.md, genius-opinion-summary.md, and research-gate.json. debate-ledger.json must include consensus_iterations, unanimous_consensus, and per-agent agreements; research-gate.json cannot pass until unanimous_consensus=true with every agent agreement recorded. Context7 is optional and only needed when the research topic depends on external package/API/framework docs; do not use it as the default research evidence layer. Normal Research may take one or two hours when needed; favor real source collection, cross-layer comparison, falsification, and a concise paper manuscript over speed. Do not use --mock except for selftests or dry harness checks; if live source execution is unavailable, record a blocker and keep the gate unpassed. Do not use for ordinary code edits.\n`,
53
58
  'autoresearch': `---\nname: autoresearch\ndescription: Dollar-command route for $AutoResearch or $autoresearch iterative experiment loops.\n---\n\nUse for $AutoResearch, iterative improvement, ranking, workflow, benchmark, or experiments. Define program, hypothesis, experiment, metric, keep/discard, falsification, next step, and Honest Mode. Do not become the parent identity for SEO/GEO; $SEO-GEO-OPTIMIZER may call research as a child stage for query, market, or competitor discovery while keeping the parent mission, gate, and Completion Proof on $SEO-GEO-OPTIMIZER.\n`,
54
59
  'db': `---\nname: db\ndescription: Dollar-command route for $DB or $db database and Supabase safety checks.\n---\n\nUse when the user invokes $DB/$db or the task touches SQL, Supabase, Postgres, migrations, Prisma, Drizzle, Knex, MCP database tools, or production data. Run or follow sks db policy, sks db scan, sks db classify, and sks db check. Destructive database operations remain forbidden.\n`,
55
- 'mad-db': `${madDbSkillText()}\n`,
56
- 'mad-sks': `---\nname: mad-sks\ndescription: Explicit high-risk authorization modifier for $MAD-SKS scoped permission widening across approved target-project surfaces.\n---\n\nUse only when the user explicitly invokes $MAD-SKS or top-level sks --mad. It can be combined with another route, such as $MAD-SKS $Team or $DB ... $MAD-SKS; in that case the other command remains the primary workflow and MAD-SKS is only the temporary permission grant. The widened permission applies only while the active mission gate is open, must be deactivated when the task ends, and can open approved scopes such as target-project file writes, shell commands, package installs, local service control, network operations, browser/Computer Use workflows, generated assets, file permissions, migrations, Supabase MCP database writes, column/schema cleanup, direct execute SQL, and normal targeted DB writes. Keep catastrophic safeguards active: whole database/schema/table removal, truncate, all-row delete/update, reset, dangerous project/branch management, credential exfiltration, persistent security weakening, destructive delete without explicit confirmation, and unrequested fallback implementation remain blocked. Do not carry MAD-SKS permission into later prompts or routes. The permission profile source is centralized in src/core/permission-gates.ts and emitted as dist/core/permission-gates.js so skill/hook/MCP-style gates share one decision function.\n`,
60
+ 'mad-db': `---\nname: mad-db\ndescription: Deprecated $MAD-DB compatibility alias; merged into mad-sks.\n---\n\n$MAD-DB and \`sks mad-db run|exec|apply-migration\` are deprecated aliases for MAD-SKS sql-plane. Warn the operator, translate to \`sks mad-sks sql|apply-migration\`, and follow the mad-sks skill as the single current authority.\n`,
61
+ 'mad-sks': `---\nname: mad-sks\ndescription: Explicit high-risk authorization modifier plus merged SQL-plane executor for $MAD-SKS.\n---\n\nUse only when the user explicitly invokes $MAD-SKS, top-level sks --mad, or \`sks mad-sks plan|run|apply|sql|apply-migration|status|close|rollback-apply\`. MAD-SKS is the single high-risk MAD route: it combines scoped permission widening across approved target-project surfaces with the former MAD-DB SQL-plane execution model. It can be combined with another route, such as $MAD-SKS $Team or $DB ... $MAD-SKS; in that case the other command remains the primary workflow and MAD-SKS is the temporary permission grant or sql-plane executor. The widened permission applies only while the active mission gate is open, must be deactivated when the task ends, and can open approved scopes such as target-project file writes, shell commands, package installs, local service control, network operations, browser/Computer Use workflows, generated assets, file permissions, migrations, Supabase MCP database writes, column/schema cleanup, direct execute SQL, and normal targeted DB writes.\n\nMerged SQL-plane policy from mad-db:\n${mergedMadDbSqlPlanePolicy}\n\nCatastrophic SQL boundary: TRUNCATE, all-row UPDATE/DELETE, table/schema/database DROP, and equivalent reset operations are allowed only through the sql-plane executor and only when the user's prompt or CLI SQL statement literally names that operation. Other MAD-SKS executors, including db-write, keep those catastrophic categories blocked. Whole database/schema/table removal outside sql-plane, dangerous project/branch management, credential exfiltration, persistent security weakening, destructive delete without explicit confirmation, and unrequested fallback implementation remain blocked. Do not carry MAD-SKS permission into later prompts or routes. The permission profile source is centralized in src/core/permission-gates.ts and emitted as dist/core/permission-gates.js so skill/hook/MCP-style gates share one decision function.\n`,
57
62
  'gx': `---\nname: gx\ndescription: Dollar-command route for $GX or $gx deterministic GX visual context cartridges.\n---\n\nUse when the user invokes $GX/$gx or asks for architecture/context visualization through SKS. Prefer sks gx init, render, validate, drift, and snapshot. vgraph.json remains the source of truth.\n`,
58
63
  'help': `---\nname: help\ndescription: Dollar-command route for $Help or $help explaining installed SKS commands and workflows.\n---\n\nUse when the user invokes $Help/$help or asks what commands exist. Prefer concise output from sks commands, sks usage <topic>, sks quickstart, sks aliases, and sks codex-app.\n`,
59
64
  'prompt-pipeline': `---\nname: prompt-pipeline\ndescription: Default SKS prompt optimization pipeline for execution prompts; Answer and DFix bypass it.\n---\n\nClassify intent: Answer only for real questions; question-shaped implicit instructions, complaints, and mandatory-policy statements route to Team. DFix handles Direct Fix work: tiny copy/config/docs/labels/spacing/translation/simple mechanical edits; code and broad implementation default to Team unless safety/research/GX route fits. Infer goal, target, constraints, acceptance, risk, and smallest safe route from prompt, TriWiki/current-code defaults, and conservative SKS policy. Do not surface a prequestion sheet. Materialize pipeline-plan.json for the runtime lane, kept/skipped stages, no-fallback invariant, lean_decision, and verification; inspect with sks pipeline plan, adding --proof-field when changed files are known. Code work surfaces route/guard/scopes, materializes team-roster.json from default or explicit counts before implementation, compiles concrete Team runtime graph/inbox artifacts after consensus, and parent owns integration/tests/Context7/Honest Mode. ${leanEngineeringCompactText()} ${outcomeRubricPolicyText()} ${speedLanePolicyText()} ${solutionScoutPolicyText('fix this broken behavior')} ${skillDreamPolicyText()}\n\n${chatCaptureIntakeText()}\n\nDesign: non-PPT UI/UX uses Product Design plugin first; legacy design.md/design-system-builder/design-ui-editor/design-artifact-expert/getdesign-reference are fallback only when the plugin is unavailable or an existing project design.md must be respected. Use imagegen for image/logo/raster, and imagegen must prefer Codex App built-in image generation (${CODEX_APP_IMAGE_GENERATION_DOC_URL}) before API generation. ${productDesignPluginPolicyText()} ${CODEX_IMAGEGEN_REQUIRED_POLICY} For UI/UX review/audit requests that mention image generation, gpt-image-2, callouts, or annotated review images, route to $Image-UX-Review/$UX-Review and require generated annotated review image evidence before issue extraction; do not satisfy that route with text-only critique. For $PPT, ${pptPipelineAllowlistPolicyText()} ${getdesignReferencePolicyText()} TriWiki context-tracking SSOT: .sneakoscope/wiki/context-pack.json; read only the latest coordinate+voxel overlay pack before every route stage, run sks wiki refresh/pack after changes, validate before handoffs/final.\n`,
@@ -81,7 +86,7 @@ async function installOfficialSkills(root) {
81
86
  'ux-review': imageUxReviewSkill('ux-review'),
82
87
  'visual-review': imageUxReviewSkill('visual-review'),
83
88
  'ui-ux-review': imageUxReviewSkill('ui-ux-review'),
84
- 'imagegen': `---\nname: imagegen\ndescription: Required bridge to Codex App built-in image generation for logos, image assets, raster visuals, and image edits.\n---\n\nUse for generated or edited image assets: logo, product image, illustration, sprite, mockup, texture, cutout, or bitmap. Prefer the official Codex App built-in image generation feature documented at ${CODEX_APP_IMAGE_GENERATION_DOC_URL}: ask naturally or invoke \`$imagegen\`. For newest-model requests, make the prompt explicit: "Use ChatGPT Images 2.0 / GPT Image 2.0 with gpt-image-2." Useful official references are ${OPENAI_CHATGPT_IMAGES_2_DOC_URL}, ${OPENAI_GPT_IMAGE_2_MODEL_DOC_URL}, and ${OPENAI_IMAGE_GENERATION_DOC_URL}. Codex App image generation counts against Codex usage limits. Capability detection is not output proof; full SKS evidence requires a real selected raster output path or generated review image artifact. Direct OpenAI API fallback is non-Codex evidence and does not satisfy SKS route evidence unless a separate non-Codex API task is explicitly requested. ${IMAGEGEN_SOCIAL_SOURCE_POLICY} ${CODEX_IMAGEGEN_REQUIRED_POLICY} Do not substitute placeholder SVG/HTML/CSS for requested raster assets; follow design.md when relevant.\n`,
89
+ 'imagegen': `---\nname: imagegen\ndescription: Required bridge to Codex App built-in image generation for logos, image assets, raster visuals, and image edits.\n---\n\nUse for generated or edited image assets: logo, product image, illustration, sprite, mockup, texture, cutout, or bitmap. Prefer the official Codex App built-in image generation feature documented at ${CODEX_APP_IMAGE_GENERATION_DOC_URL}: ask naturally or invoke \`$imagegen\`. SKS route code checks capability before image-dependent routes, attempts doctor imagegen repair once, and reports codex_imagegen_unavailable if Codex App $imagegen still is not ready. For newest-model requests, make the prompt explicit: "Use ChatGPT Images 2.0 / GPT Image 2.0 with gpt-image-2." Useful official references are ${OPENAI_CHATGPT_IMAGES_2_DOC_URL}, ${OPENAI_GPT_IMAGE_2_MODEL_DOC_URL}, and ${OPENAI_IMAGE_GENERATION_DOC_URL}. Codex App image generation counts against Codex usage limits. Capability detection is not output proof; full SKS evidence requires a real selected raster output path or generated review image artifact. Direct OpenAI API fallback is non-Codex evidence and does not satisfy SKS route evidence unless a separate non-Codex API task is explicitly requested. ${IMAGEGEN_SOCIAL_SOURCE_POLICY} ${CODEX_IMAGEGEN_REQUIRED_POLICY} Do not substitute placeholder SVG/HTML/CSS for requested raster assets; follow design.md when relevant.\n`,
85
90
  'imagegen-source-scout': `---\nname: imagegen-source-scout\ndescription: Source scout for current GPT Image 2.0/gpt-image-2 prompt guidance, official docs, and X/social workflow signals.\n---\n\nUse when the user asks for the latest imagegen docs, ChatGPT Images 2.0 / GPT Image 2.0 / gpt-image-2 behavior, X/social reactions, prompt examples, or community workflow hints before creating an image prompt or SKS imagegen policy. Source order: official OpenAI announcement (${OPENAI_CHATGPT_IMAGES_2_DOC_URL}), Codex App image generation docs (${CODEX_APP_IMAGE_GENERATION_DOC_URL}), gpt-image-2 model docs (${OPENAI_GPT_IMAGE_2_MODEL_DOC_URL}), OpenAI Image Generation API docs (${OPENAI_IMAGE_GENERATION_DOC_URL}), then public X/social/community search for prompt-quality heuristics only. ${IMAGEGEN_SOCIAL_SOURCE_POLICY} If X/Grok or web search is unavailable, record that social coverage is unverified and continue from official docs. Output a compact evidence split: official capability/evidence rules, prompt heuristics, social/workflow signals, and blockers. Do not generate images itself; pair this with the imagegen skill for actual raster output.\n`,
86
91
  'getdesign-reference': `---\nname: getdesign-reference\ndescription: Use getdesign.md official design reference as an input to the design.md SSOT for UI/UX, presentation, and HTML/PDF systems.\n---\n\nUse when creating or improving design.md, UI/UX design systems, deck-like HTML artifacts, presentation PDFs, or brand-inspired visual systems. design.md is the only design decision SSOT; reference ${GETDESIGN_REFERENCE.url}, ${GETDESIGN_REFERENCE.docs_url}, and ${AWESOME_DESIGN_MD_REFERENCE.url} only as source inputs to synthesize or update that SSOT or a route-local style-token artifact. Prefer the official Codex skill if available with \`${GETDESIGN_REFERENCE.codex_skill_install}\`. If the skill CLI is unavailable, use this generated skill plus official docs/API/CLI/SDK references and curated DESIGN.md examples as inputs. Do not claim getdesign MCP is configured unless a current official MCP surface is actually installed.\n`,
87
92
  'design-system-builder': `---\nname: design-system-builder\ndescription: Legacy fallback to create design.md from docs/Design-Sys-Prompt.md only when Product Design plugin is unavailable or explicit local SSOT is required.\n---\n\nUse Product Design plugin first. Only when the plugin is unavailable or the route explicitly needs a local fallback SSOT, read docs/Design-Sys-Prompt.md as the builder prompt, inspect product/UI context, and use getdesign-reference, official getdesign.md docs, and curated DESIGN.md examples from ${AWESOME_DESIGN_MD_REFERENCE.url} only as source inputs. Fuse those inputs into one design.md fallback/cache with tokens, components, states, imagery, accessibility, and verification rules; do not leave multiple design files or references as competing authorities. Use the plan tool only for real ambiguity plus default font recommendation. Use imagegen for assets. ${productDesignPluginPolicyText()} ${CODEX_IMAGEGEN_REQUIRED_POLICY}\n`,
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { createMission, missionDir, setCurrent } from '../mission.js';
3
- import { nowIso, readJson, readText, sha256, writeJsonAtomic } from '../fsx.js';
3
+ import { ensureDir, nowIso, readJson, readText, sha256, writeJsonAtomic } from '../fsx.js';
4
4
  import { createMadDbCapability, activateMadDbCapability, closeMadDbCycle, MAD_DB_ACK, markMadDbTransportReady, readMadDbCapability } from './mad-db-capability.js';
5
5
  import { MadDbMcpExecutor } from './mad-db-executor.js';
6
6
  import { createMadDbRuntimeProfile, closeMadDbRuntimeProfile, redactedRuntimeProfile } from './mad-db-runtime-profile.js';
@@ -11,7 +11,14 @@ import { projectRootHash, resolveMadDbTarget } from './mad-db-target.js';
11
11
  import { classifySql } from '../db-safety.js';
12
12
  export async function prepareMadDbMission(input) {
13
13
  const target = await resolveMadDbTarget(input.root, { args: input.args || [] });
14
- const { id, dir } = await createMission(input.root, { mode: 'mad-db', prompt: input.task || 'MadDB SQL-plane execution', sessionKey: input.sessionKey });
14
+ const route = input.route || 'MadDB';
15
+ const routeCommand = input.routeCommand || (route === 'MadSKS' ? '$MAD-SKS' : '$MAD-DB');
16
+ const existingMissionId = input.missionId ? String(input.missionId) : '';
17
+ const created = existingMissionId
18
+ ? { id: existingMissionId, dir: missionDir(input.root, existingMissionId) }
19
+ : await createMission(input.root, { mode: route === 'MadSKS' ? 'mad-sks' : 'mad-db', prompt: input.task || 'MadDB SQL-plane execution', sessionKey: input.sessionKey });
20
+ const { id, dir } = created;
21
+ await ensureDir(dir);
15
22
  const cycleId = `mad-db-${Date.now().toString(36)}`;
16
23
  const runtimeSessionId = input.runtimeSessionId || `mad-db-session-${Date.now().toString(36)}`;
17
24
  const blockers = [...target.blockers];
@@ -30,6 +37,7 @@ export async function prepareMadDbMission(input) {
30
37
  projectRef: target.project_ref || 'missing-project-ref',
31
38
  targetEnvironment: target.target_environment,
32
39
  allowedSchemas: target.allowed_schemas,
40
+ ttlMs: input.ttlMs,
33
41
  runtimeSessionId,
34
42
  operatorIntent: input.task,
35
43
  profilePath: profile.profile_path,
@@ -50,18 +58,28 @@ export async function prepareMadDbMission(input) {
50
58
  await markMadDbTransportReady(input.root, id);
51
59
  }
52
60
  await writeJsonAtomic(path.join(dir, 'route-context.json'), {
53
- route: 'MadDB',
54
- command: '$MAD-DB',
55
- mode: 'MADDB',
61
+ route,
62
+ command: routeCommand,
63
+ mode: route === 'MadSKS' ? 'MADSKS' : 'MADDB',
56
64
  task: input.task,
57
65
  target: redactTarget(target),
58
66
  capability_file: 'mad-db-capability.json',
59
67
  runtime_profile_manifest: 'mad-db/runtime/runtime-profile-manifest.json',
60
- tool_inventory: toolInventory ? 'mad-db/runtime/tool-inventory.json' : null
68
+ tool_inventory: toolInventory ? 'mad-db/runtime/tool-inventory.json' : null,
69
+ sql_plane_executor: route === 'MadSKS'
61
70
  });
62
- await writeJsonAtomic(path.join(dir, 'mad-db-gate.json'), {
63
- schema: 'sks.mad-db-gate.v1',
71
+ await writeJsonAtomic(path.join(dir, 'mad-sks-gate.json'), {
72
+ schema: 'sks.mad-sks-gate.v1',
64
73
  passed: false,
74
+ mad_sks_permission_active: route === 'MadSKS' && !blockers.length,
75
+ permissions_deactivated: false,
76
+ sql_plane: {
77
+ requested: true,
78
+ capability_id: preparedCapabilityId(id, cycleId),
79
+ operation_classes: [...madDbOperationClassesFromClassification(classifySql(input.task))],
80
+ read_back_passed: false,
81
+ profile_closed: false
82
+ },
65
83
  mad_db_capability_active: !blockers.length,
66
84
  sql_plane_all_mutations_allowed: !blockers.length,
67
85
  control_plane_denied: true,
@@ -73,18 +91,20 @@ export async function prepareMadDbMission(input) {
73
91
  await setCurrent(input.root, {
74
92
  mission_id: id,
75
93
  mad_db_capability_mission_id: id,
76
- route: 'MadDB',
77
- route_command: '$MAD-DB',
78
- mode: 'MADDB',
79
- phase: blockers.length ? 'MADDB_BLOCKED' : 'MADDB_SQL_PLANE_CAPABILITY_ACTIVE',
94
+ route,
95
+ route_command: routeCommand,
96
+ mode: route === 'MadSKS' ? 'MADSKS' : 'MADDB',
97
+ phase: blockers.length ? `${route.toUpperCase()}_BLOCKED` : `${route.toUpperCase()}_SQL_PLANE_CAPABILITY_ACTIVE`,
80
98
  questions_allowed: false,
81
99
  implementation_allowed: !blockers.length,
82
100
  mad_db_active: !blockers.length,
101
+ mad_sks_active: route === 'MadSKS' && !blockers.length,
83
102
  mad_db_cycle_id: cycleId,
84
103
  mad_db_runtime_session_id: runtimeSessionId,
85
104
  mad_db_profile_sha256: profile.profile_sha256,
86
105
  mad_db_capability_file: 'mad-db-capability.json',
87
- stop_gate: 'mad-db-gate.json',
106
+ mad_sks_gate_file: 'mad-sks-gate.json',
107
+ stop_gate: 'mad-sks-gate.json',
88
108
  prompt: input.task
89
109
  }, { sessionKey: input.sessionKey });
90
110
  return {
@@ -102,7 +122,19 @@ export async function prepareMadDbMission(input) {
102
122
  export async function runMadDbCycle(input) {
103
123
  const timings = {};
104
124
  const start = Date.now();
105
- const prepared = await prepareMadDbMission({ root: input.root, task: input.task, args: input.args || [], verifyTools: false });
125
+ const prepareInput = {
126
+ root: input.root,
127
+ task: input.task,
128
+ args: input.args || [],
129
+ ttlMs: input.ttlMs,
130
+ verifyTools: false,
131
+ missionId: input.missionId || null
132
+ };
133
+ if (input.route)
134
+ prepareInput.route = input.route;
135
+ if (input.routeCommand)
136
+ prepareInput.routeCommand = input.routeCommand;
137
+ const prepared = await prepareMadDbMission(prepareInput);
106
138
  timings.prepare_ms = Date.now() - start;
107
139
  const profile = await recreateProfileFromPrepared(input.root, prepared);
108
140
  const executor = new MadDbMcpExecutor(profile);
@@ -209,18 +241,60 @@ export async function runMadDbCycle(input) {
209
241
  blockers: restoration.ok ? blockers : [...blockers, ...restoration.blockers]
210
242
  };
211
243
  await writeJsonAtomic(path.join(missionDir(input.root, prepared.mission_id), 'mad-db-result.json'), redactCycleResult(result));
244
+ await writeMadSksSqlPlaneGate(input.root, result);
212
245
  await clearMadDbCurrentState(input.root, prepared.mission_id, result.ok, restoration);
213
246
  return result;
214
247
  }
248
+ function preparedCapabilityId(missionId, cycleId) {
249
+ return `${missionId}:${cycleId}`;
250
+ }
251
+ export async function writeMadSksSqlPlaneGate(root, result) {
252
+ const file = path.join(missionDir(root, result.mission_id), 'mad-sks-gate.json');
253
+ const previous = await readJson(file, {});
254
+ const operationClasses = result.operation?.operation_classes || [];
255
+ const blockers = [
256
+ ...(Array.isArray(previous.blockers) ? previous.blockers : []),
257
+ ...(result.blockers || [])
258
+ ];
259
+ const sqlPlane = {
260
+ requested: true,
261
+ capability_id: preparedCapabilityId(result.mission_id, result.cycle_id),
262
+ operation_classes: operationClasses,
263
+ read_back_passed: result.read_back ? result.read_back.ok === true : result.execution?.ok === true,
264
+ profile_closed: result.capability_closed === true && result.read_only_restoration?.ok === true
265
+ };
266
+ const passed = result.ok === true && sqlPlane.read_back_passed === true && sqlPlane.profile_closed === true;
267
+ const gate = {
268
+ ...previous,
269
+ schema: previous.schema || 'sks.mad-sks-gate.v1',
270
+ schema_version: previous.schema_version || 1,
271
+ passed,
272
+ mad_sks_permission_active: false,
273
+ permissions_deactivated: true,
274
+ sql_plane: sqlPlane,
275
+ mad_db_capability_active: false,
276
+ sql_plane_all_mutations_allowed: result.execution?.ok === true,
277
+ control_plane_denied: true,
278
+ mission_id: result.mission_id,
279
+ cycle_id: result.cycle_id,
280
+ read_only_restoration: result.read_only_restoration,
281
+ blockers: passed ? [] : [...new Set(blockers.length ? blockers : ['mad_sks_sql_plane_not_passed'])],
282
+ created_at: previous.created_at || nowIso(),
283
+ updated_at: nowIso()
284
+ };
285
+ await writeJsonAtomic(file, gate);
286
+ return gate;
287
+ }
215
288
  async function clearMadDbCurrentState(root, missionId, ok, restoration) {
216
289
  const currentPath = path.join(root, '.sneakoscope', 'state', 'current.json');
217
290
  const current = await readJson(currentPath, {});
218
291
  if (current.mission_id !== missionId && current.mad_db_capability_mission_id !== missionId)
219
292
  return;
220
293
  await setCurrent(root, {
221
- phase: ok ? 'MADDB_CLOSED' : 'MADDB_FAILED_CLOSED',
294
+ phase: current.mode === 'MADSKS' ? (ok ? 'MADSKS_SQL_PLANE_CLOSED' : 'MADSKS_SQL_PLANE_FAILED_CLOSED') : (ok ? 'MADDB_CLOSED' : 'MADDB_FAILED_CLOSED'),
222
295
  implementation_allowed: false,
223
296
  mad_db_active: false,
297
+ mad_sks_active: current.mode === 'MADSKS' ? false : current.mad_sks_active,
224
298
  mad_db_runtime_session_id: null,
225
299
  mad_db_profile_sha256: null,
226
300
  mad_db_read_only_restored: restoration.ok,
@@ -273,14 +347,16 @@ export async function madDbRouteIdentityProof(root, missionId) {
273
347
  const state = await readJson(path.join(root, '.sneakoscope', 'state', 'current.json'), {});
274
348
  const profile = await readJson(path.join(missionDir(root, missionId), 'mad-db', 'runtime', 'runtime-profile-manifest.json'), null);
275
349
  const sameMission = Boolean(capability && capability.mission_id === missionId && state?.mission_id === missionId);
350
+ const mergedMadSks = state?.route === 'MadSKS' && state?.route_command === '$MAD-SKS';
276
351
  return {
277
352
  schema: 'sks.mad-db-route-identity-proof.v1',
278
- ok: sameMission && state?.route === 'MadDB' && state?.route_command === '$MAD-DB',
353
+ ok: sameMission && (mergedMadSks || (state?.route === 'MadDB' && state?.route_command === '$MAD-DB')),
279
354
  mission_id: missionId,
280
355
  capability_mission_id: capability?.mission_id || null,
281
356
  same_mission: sameMission,
282
357
  route: state?.route || null,
283
358
  route_command: state?.route_command || null,
359
+ deprecated_route_accepted: mergedMadSks,
284
360
  cycle_id: capability?.cycle_id || null,
285
361
  project_root_hash: await projectRootHash(root),
286
362
  runtime_profile: profile,
@@ -288,8 +364,8 @@ export async function madDbRouteIdentityProof(root, missionId) {
288
364
  ...(capability ? [] : ['capability_missing']),
289
365
  ...(profile ? [] : ['runtime_profile_manifest_missing']),
290
366
  ...(sameMission ? [] : ['mission_binding_mismatch']),
291
- ...(state?.route === 'MadDB' ? [] : ['route_state_not_maddb']),
292
- ...(state?.route_command === '$MAD-DB' ? [] : ['route_command_not_maddb'])
367
+ ...(state?.route === 'MadDB' || mergedMadSks ? [] : ['route_state_not_maddb_or_merged_mad_sks']),
368
+ ...(state?.route_command === '$MAD-DB' || mergedMadSks ? [] : ['route_command_not_maddb_or_mad_sks'])
293
369
  ]
294
370
  };
295
371
  }
@@ -161,14 +161,16 @@ export function activeMadDbAllowsSqlPlane(classification = {}) {
161
161
  export function madDbSkillText(commandPrefix = 'sks') {
162
162
  return `---
163
163
  name: mad-db
164
- description: First-class MadDB SQL-plane execution route for explicit $MAD-DB and ${commandPrefix} mad-db run|exec|apply-migration.
164
+ description: Deprecated alias; MadDB SQL-plane execution is merged into mad-sks.
165
165
  ---
166
166
 
167
- Use only when the operator explicitly invokes $MAD-DB/$mad-db or ${commandPrefix} mad-db run|exec|apply-migration. This is the single approval boundary for the active MadDB cycle: execute SQL-plane mutations that the operator requested, including CREATE, ALTER, table/schema DROP, column add/drop/rename, INSERT, UPDATE, DELETE including all-row mutations, TRUNCATE, execute_sql, and apply_migration. Do not ask again for each DROP/TRUNCATE/all-row DELETE inside the same bound cycle.
167
+ Deprecated compatibility skill. Use mad-sks for all current SQL-plane execution. $MAD-DB and ${commandPrefix} mad-db run|exec|apply-migration redirect to MAD-SKS sql-plane for one release and must warn the operator.
168
168
 
169
- Keep normal Supabase MCP configuration read-only. MadDB must create a mission-local ephemeral write-capable Supabase MCP profile bound to capability v2, project_ref, root, mission, thread/session, intent, runtime profile hash, TTL, and SQL-plane operation classes. Verify execute_sql and apply_migration availability before claiming readiness. Require actual tool results plus independent read-back verification before claiming success. Close/revoke the capability and runtime profile in finally and prove read-only restoration.
169
+ Merged SQL-plane rules for mad-sks: execute SQL-plane mutations that the operator requested, including CREATE, ALTER, table/schema DROP, column add/drop/rename, INSERT, UPDATE, DELETE including all-row mutations, TRUNCATE, execute_sql, and apply_migration. Catastrophic SQL is allowed only in the sql-plane executor and only when the user's prompt or CLI SQL statement literally names the operation.
170
170
 
171
- Still deny Supabase account/project/billing/credential control-plane actions, credential exfiltration, unrelated non-database admin changes, and unrequested fallback implementation. Do not add prompt-only SQL deny lists inside active MadDB; capability binding, SQL-plane scope, operation ledgering, and read-back verification are the approval boundary. Pair with db-safety-guard, Context7 evidence for MCP/API docs, route-local reflection, and Honest Mode.`;
171
+ Keep normal Supabase MCP configuration read-only. MAD-SKS sql-plane must create a mission-local ephemeral write-capable Supabase MCP profile bound to capability v2, project_ref, root, mission, thread/session, intent, runtime profile hash, TTL, and SQL-plane operation classes. Verify execute_sql and apply_migration availability before claiming readiness. Require actual tool results plus independent read-back verification before claiming success. Close/revoke the capability and runtime profile in finally and prove read-only restoration.
172
+
173
+ Still deny Supabase account/project/billing/credential control-plane actions, credential exfiltration, unrelated non-database admin changes, and unrequested fallback implementation. Do not add prompt-only SQL deny lists inside active sql-plane; capability binding, SQL-plane scope, operation ledgering, literal catastrophic intent, and read-back verification are the approval boundary. Pair with db-safety-guard, Context7 evidence for MCP/API docs, route-local reflection, and Honest Mode.`;
172
174
  }
173
175
  export function dbSafetyGuardSkillText() {
174
176
  return `---
@@ -177,13 +179,13 @@ description: Enforce Sneakoscope Codex database safety before using SQL, Supabas
177
179
  ---
178
180
 
179
181
  Rules:
180
- - Default non-MadDB mode is read-only and routes writes/destructive SQL to the DB safety gate.
182
+ - Default non-MAD-SKS mode is read-only and routes writes/destructive SQL to the DB safety gate.
181
183
  - Supabase MCP must be read-only and project-scoped by default.
182
- - Live execute_sql writes are blocked unless a bound active MadDB capability v2 is present.
183
- - Active MadDB is the explicit exception: SQL-plane mutations requested by $MAD-DB or sks mad-db run|exec|apply-migration are allowed, including DROP, DELETE, TRUNCATE, RLS/policy changes, and execute_sql/apply_migration, and must be executed with read-back verification.
184
- - Default read-only restrictions do not apply to SQL-plane work while the active MadDB capability v2 is bound.
185
- - Supabase project/account/billing/credential control-plane actions remain denied even in MadDB.
186
- - If no active bound MadDB cycle exists, fall back to read-only only.`;
184
+ - Live execute_sql writes are blocked unless a bound active MAD-SKS sql-plane capability v2 is present.
185
+ - Active MAD-SKS sql-plane is the explicit exception: SQL-plane mutations requested by $MAD-SKS/sks mad-sks sql|apply-migration, or deprecated $MAD-DB/sks mad-db redirects, are allowed, including DROP, DELETE, TRUNCATE, RLS/policy changes, and execute_sql/apply_migration, and must be executed with read-back verification.
186
+ - Default read-only restrictions do not apply to SQL-plane work while the active MAD-SKS sql-plane capability v2 is bound.
187
+ - Supabase project/account/billing/credential control-plane actions remain denied even in MAD-SKS sql-plane.
188
+ - If no active bound MAD-SKS sql-plane cycle exists, fall back to read-only only.`;
187
189
  }
188
190
  function stringArray(value) {
189
191
  if (!Array.isArray(value))
@@ -42,11 +42,17 @@ export function executorBlocker({ executor, actionType, context, blockers, block
42
42
  generated_at: nowIso()
43
43
  };
44
44
  }
45
- export async function writeExecutorEvidence({ context, executor, actionType, changedFiles = [], blockedActions = [], fileRollbacks = [], packageRollbacks = [], serviceRollbacks = [], dbRollbacks = [], rollbackUnavailable = [], auditActions = [], verification = [] }) {
45
+ export async function writeExecutorEvidence({ context, executor, actionType, changedFiles = [], blockedActions = [], fileRollbacks = [], packageRollbacks = [], serviceRollbacks = [], dbRollbacks = [], rollbackUnavailable = [], auditActions = [], verification = [], forceProtectedCoreChanged = false }) {
46
46
  await ensureDir(context.artifact_dir);
47
47
  const before = await snapshotProtectedCore(context.package_root, `${executor}-before`);
48
48
  const after = await snapshotProtectedCore(context.package_root, `${executor}-after`);
49
- const comparison = compareProtectedCoreSnapshots(before, after);
49
+ const comparison = forceProtectedCoreChanged && (process.env.NODE_ENV === 'test' || process.env.SKS_TEST_FORCE_PROTECTED_CORE_CHANGED === '1')
50
+ ? {
51
+ ...compareProtectedCoreSnapshots(before, after),
52
+ ok: false,
53
+ changed: [{ id: '__test_protected_core_changed', before_digest: before.digest, after_digest: after.digest }]
54
+ }
55
+ : compareProtectedCoreSnapshots(before, after);
50
56
  const beforePath = path.join(context.artifact_dir, `${executor}-protected-core-before.json`);
51
57
  const afterPath = path.join(context.artifact_dir, `${executor}-protected-core-after.json`);
52
58
  const comparisonPath = path.join(context.artifact_dir, `${executor}-protected-core-comparison.json`);
@@ -5,6 +5,7 @@ import { shellCommandExecutor } from './shell-command-executor.js';
5
5
  import { packageInstallExecutor } from './package-install-executor.js';
6
6
  import { serviceControlExecutor } from './service-control-executor.js';
7
7
  import { dbWriteExecutor } from './db-write-executor.js';
8
+ import { sqlPlaneExecutor } from './sql-plane-executor.js';
8
9
  import { browserUseExecutor, computerUseExecutor, generatedAssetExecutor } from './computer-use-executor.js';
9
10
  const EXECUTORS = {
10
11
  'file-write': fileWriteExecutor,
@@ -17,6 +18,9 @@ const EXECUTORS = {
17
18
  'service-control': serviceControlExecutor,
18
19
  db: dbWriteExecutor,
19
20
  'db-write': dbWriteExecutor,
21
+ sql: sqlPlaneExecutor,
22
+ 'sql-plane': sqlPlaneExecutor,
23
+ 'apply-migration': sqlPlaneExecutor,
20
24
  computer: computerUseExecutor,
21
25
  'computer-use': computerUseExecutor,
22
26
  browser: browserUseExecutor,