2sagaco48 1.0.0

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 (365) hide show
  1. package/diagnostics.mjs +141 -0
  2. package/dist/compute.worker-j5ahIpF-.js +1 -0
  3. package/dist/graph.worker-DG6iGCB9.js +1 -0
  4. package/dist/index.html +2314 -0
  5. package/flatten-guide.md +248 -0
  6. package/index.html +12 -0
  7. package/package.json +38 -0
  8. package/src/App.orig.tsx +204 -0
  9. package/src/App.orig1.tsx +27 -0
  10. package/src/App.orig2.tsx +25 -0
  11. package/src/App.tsx +3 -0
  12. package/src/BaseApp.tsx +18 -0
  13. package/src/INTEGRATION_LEDGER.md +22 -0
  14. package/src/PERSIST_CANARY.orig.txt +1 -0
  15. package/src/PERSIST_CANARY.txt +1 -0
  16. package/src/REGRESSION_LEDGER.md +651 -0
  17. package/src/TEMPLATE_PIPELINE_AUDIT.md +208 -0
  18. package/src/WILLIAMS_PERSONA_GUIDE.md +62 -0
  19. package/src/chat/VeritasChat.tsx +69 -0
  20. package/src/chat/synthesis.ts +31 -0
  21. package/src/chat/tier.ts +45 -0
  22. package/src/components/AdaptersPage.orig.tsx +99 -0
  23. package/src/components/AdaptersPage.tsx +3 -0
  24. package/src/components/AdversarialPanel.tsx +136 -0
  25. package/src/components/AnchorBaselinePanel.tsx +75 -0
  26. package/src/components/AnswerPanel.tsx +60 -0
  27. package/src/components/ArtifactPanel.tsx +43 -0
  28. package/src/components/ChatApp.orig.tsx +1582 -0
  29. package/src/components/ChatApp.orig1.tsx +722 -0
  30. package/src/components/ChatApp.tsx +95 -0
  31. package/src/components/ChatAugmentPanels.tsx +73 -0
  32. package/src/components/CitationLedgerPanel.tsx +313 -0
  33. package/src/components/ComputeSandboxPanel.tsx +130 -0
  34. package/src/components/ConfigPanel.tsx +110 -0
  35. package/src/components/ControlPlanePage.tsx +195 -0
  36. package/src/components/CreativeTreeLifePage.tsx +234 -0
  37. package/src/components/CreativeTreeOfLifePanel.tsx +149 -0
  38. package/src/components/DebugTracePanel.tsx +137 -0
  39. package/src/components/DeepReasoningTrace.tsx +48 -0
  40. package/src/components/EntitySheetPanel.tsx +51 -0
  41. package/src/components/FailureModesPanel.tsx +104 -0
  42. package/src/components/GBSDashboard.tsx +239 -0
  43. package/src/components/GraphView.tsx +116 -0
  44. package/src/components/HUD.tsx +125 -0
  45. package/src/components/HypothesisPanel.tsx +67 -0
  46. package/src/components/InnovationGenomeEngine.tsx +792 -0
  47. package/src/components/InnovationPersonaGuide.tsx +348 -0
  48. package/src/components/InnovationPersonaPanel.tsx +289 -0
  49. package/src/components/LiveResourceHUD.tsx +109 -0
  50. package/src/components/LongWriterPanel.tsx +112 -0
  51. package/src/components/MainPipelineV10Bridge.tsx +72 -0
  52. package/src/components/MarkdownLite.tsx +63 -0
  53. package/src/components/MemoryInspector.tsx +38 -0
  54. package/src/components/MemoryMonitor.tsx +52 -0
  55. package/src/components/MemoryStressPanel.tsx +176 -0
  56. package/src/components/ModulesPage.tsx +171 -0
  57. package/src/components/PipelineDebugConsole.orig.tsx +1856 -0
  58. package/src/components/PipelineDebugConsole.tsx +3 -0
  59. package/src/components/PreFlightHUD.tsx +67 -0
  60. package/src/components/PrismaFetchTracePanel.tsx +87 -0
  61. package/src/components/ReportOSPanel.tsx +165 -0
  62. package/src/components/ResourceEstimatorPage.tsx +327 -0
  63. package/src/components/RichText.tsx +181 -0
  64. package/src/components/SagaOsPanel.tsx +605 -0
  65. package/src/components/SagaOsReference.tsx +421 -0
  66. package/src/components/SagaOsV2Panel.tsx +594 -0
  67. package/src/components/SagaStyleTab.tsx +382 -0
  68. package/src/components/SageBlueprintPanel.tsx +416 -0
  69. package/src/components/SharedChatInput.tsx +77 -0
  70. package/src/components/StatFinancePanel.tsx +190 -0
  71. package/src/components/StylePersonaPanel.tsx +128 -0
  72. package/src/components/TemplatesPage.tsx +300 -0
  73. package/src/components/TestPanel.tsx +63 -0
  74. package/src/components/TraceLog.tsx +89 -0
  75. package/src/components/V15CalibrationAugment.tsx +1134 -0
  76. package/src/components/V15CalibrationDialog.tsx +1871 -0
  77. package/src/components/V15Overlay.orig.tsx +120 -0
  78. package/src/components/V15Overlay.tsx +4 -0
  79. package/src/components/V15OverlayWrapper.tsx +362 -0
  80. package/src/components/V15Toggle.tsx +34 -0
  81. package/src/console/DiagnosticRecoveryPanel.tsx +358 -0
  82. package/src/console/EngineeringConsole.tsx +103 -0
  83. package/src/console/FictionSystemPanels.tsx +882 -0
  84. package/src/console/InspectorPanels.tsx +254 -0
  85. package/src/console/ManuscriptGraderPanel.tsx +182 -0
  86. package/src/console/RecursiveReviserPanel.tsx +245 -0
  87. package/src/console/SeedControlPanel.tsx +135 -0
  88. package/src/console/StoryControllerPanel.tsx +443 -0
  89. package/src/console/engineBridge.ts +258 -0
  90. package/src/console/gemini.ts +106 -0
  91. package/src/console/grading.ts +250 -0
  92. package/src/console/util.ts +45 -0
  93. package/src/fiction/continuity.ts +372 -0
  94. package/src/fiction/crash-protection.ts +111 -0
  95. package/src/fiction/diagnostics.ts +208 -0
  96. package/src/fiction/diff.ts +74 -0
  97. package/src/fiction/entity-state-machine.ts +214 -0
  98. package/src/fiction/nive-engine.ts +404 -0
  99. package/src/fiction/pipeline-selftest.ts +132 -0
  100. package/src/fiction/seed-control.ts +193 -0
  101. package/src/fiction/story-engine.ts +326 -0
  102. package/src/fiction/types.ts +68 -0
  103. package/src/flatten-guide.md +379 -0
  104. package/src/index.css +14 -0
  105. package/src/index.orig.css +13 -0
  106. package/src/lib/academic-sources.base.ts +188 -0
  107. package/src/lib/academic-sources.orig.ts +28 -0
  108. package/src/lib/academic-sources.ts +10 -0
  109. package/src/lib/advanced-math.ts +119 -0
  110. package/src/lib/adversarial-engine.base.ts +409 -0
  111. package/src/lib/adversarial-engine.ts +82 -0
  112. package/src/lib/ai-revision.ts +623 -0
  113. package/src/lib/app-state.tsx +426 -0
  114. package/src/lib/artifact-registry.ts +97 -0
  115. package/src/lib/artifacts.ts +180 -0
  116. package/src/lib/atlas-dr.ts +167 -0
  117. package/src/lib/browser-mtls.ts +127 -0
  118. package/src/lib/browser-queue.ts +221 -0
  119. package/src/lib/browser-search-scraper.base.ts +382 -0
  120. package/src/lib/browser-search-scraper.orig.ts +90 -0
  121. package/src/lib/browser-search-scraper.ts +10 -0
  122. package/src/lib/calc-interceptor.ts +82 -0
  123. package/src/lib/citation-lane-tap.ts +78 -0
  124. package/src/lib/citation-ledger-store.ts +369 -0
  125. package/src/lib/citation-ledger.ts +203 -0
  126. package/src/lib/compute-sandbox.ts +215 -0
  127. package/src/lib/compute.worker.ts +153 -0
  128. package/src/lib/connectors/gemini.ts +120 -0
  129. package/src/lib/connectors/jina.ts +233 -0
  130. package/src/lib/connectors/marketdata.ts +51 -0
  131. package/src/lib/connectors/prismafetch.base.ts +175 -0
  132. package/src/lib/connectors/prismafetch.ts +1 -0
  133. package/src/lib/connectors/serpapi.ts +65 -0
  134. package/src/lib/connectors/wikidata.ts +44 -0
  135. package/src/lib/constraints.ts +331 -0
  136. package/src/lib/continuation-detector.base.ts +153 -0
  137. package/src/lib/continuation-detector.ts +48 -0
  138. package/src/lib/contradraft.ts +168 -0
  139. package/src/lib/cors-proxy.ts +120 -0
  140. package/src/lib/coverage.ts +81 -0
  141. package/src/lib/debug/architecture-prescription.ts +556 -0
  142. package/src/lib/debug/covea-repair.ts +543 -0
  143. package/src/lib/debug/helios-ground.ts +319 -0
  144. package/src/lib/debug/intent-decomposer.ts +281 -0
  145. package/src/lib/debug/intent-lattice.ts +349 -0
  146. package/src/lib/debug/pipeline-diagnosis.ts +1149 -0
  147. package/src/lib/debug/pipeline-trace-bus.ts +424 -0
  148. package/src/lib/debug/prompt-forge.ts +678 -0
  149. package/src/lib/debug/repair-sites.ts +513 -0
  150. package/src/lib/debug/research-phase.ts +266 -0
  151. package/src/lib/debug/retrieval-context.ts +76 -0
  152. package/src/lib/debug/retrieval-hardener.ts +142 -0
  153. package/src/lib/debug/scraper-debug-runner.ts +576 -0
  154. package/src/lib/debug/scraper-forensics.ts +418 -0
  155. package/src/lib/debug/scraper-lane-roadmap.ts +136 -0
  156. package/src/lib/debug/self-test.ts +415 -0
  157. package/src/lib/debug/step-attribution.ts +211 -0
  158. package/src/lib/debug/template-rubric.ts +301 -0
  159. package/src/lib/debug/unified-innovation.ts +126 -0
  160. package/src/lib/debug/veritas-hybrid-scraper.ts +335 -0
  161. package/src/lib/defense-registry.ts +104 -0
  162. package/src/lib/defenses.ts +162 -0
  163. package/src/lib/deterministic-citation-ledger.ts +174 -0
  164. package/src/lib/elo-registry.base.ts +117 -0
  165. package/src/lib/elo-registry.ts +1 -0
  166. package/src/lib/entity-resolver.ts +291 -0
  167. package/src/lib/failure-modes.ts +267 -0
  168. package/src/lib/feature-registry.ts +69 -0
  169. package/src/lib/flaw-registry.ts +143 -0
  170. package/src/lib/flaws/_template.ts +52 -0
  171. package/src/lib/flaws/builtins.ts +63 -0
  172. package/src/lib/flaws/finance.ts +169 -0
  173. package/src/lib/flaws/fixers.ts +10 -0
  174. package/src/lib/flaws/index.ts +32 -0
  175. package/src/lib/flaws/legal.ts +157 -0
  176. package/src/lib/flaws/medical.ts +188 -0
  177. package/src/lib/flaws/original-defenses-pack.ts +81 -0
  178. package/src/lib/flaws/sample-declarative-pack.json +38 -0
  179. package/src/lib/flaws/selftest.ts +201 -0
  180. package/src/lib/flaws/software-extended.ts +125 -0
  181. package/src/lib/flaws/software-rn-webgl.ts +182 -0
  182. package/src/lib/flaws/statistics-advanced.ts +46 -0
  183. package/src/lib/flaws/statistics.ts +61 -0
  184. package/src/lib/gbse/config.ts +20 -0
  185. package/src/lib/gbse/engine.ts +226 -0
  186. package/src/lib/gbse/graph.ts +118 -0
  187. package/src/lib/gbse/graph.worker.ts +21 -0
  188. package/src/lib/gbse/tests.ts +117 -0
  189. package/src/lib/gbse/tiers.ts +65 -0
  190. package/src/lib/gbse/types.ts +94 -0
  191. package/src/lib/innovation-genome-engine-v2.orig.ts +1001 -0
  192. package/src/lib/innovation-genome-engine-v2.ts +3 -0
  193. package/src/lib/innovation-genome-engine.orig.ts +330 -0
  194. package/src/lib/innovation-genome-engine.ts +3 -0
  195. package/src/lib/innovation-genome-v10.orig.ts +314 -0
  196. package/src/lib/innovation-genome-v10.ts +2 -0
  197. package/src/lib/innovation-genome-v3.orig.ts +2015 -0
  198. package/src/lib/innovation-genome-v3.ts +2 -0
  199. package/src/lib/innovation-genome-v4.orig.ts +1959 -0
  200. package/src/lib/innovation-genome-v4.ts +2 -0
  201. package/src/lib/innovation-genome-v5.orig.ts +1210 -0
  202. package/src/lib/innovation-genome-v5.ts +2 -0
  203. package/src/lib/innovation-genome-v7.orig.ts +2549 -0
  204. package/src/lib/innovation-genome-v7.ts +2 -0
  205. package/src/lib/innovation-genome-v8.orig.ts +1485 -0
  206. package/src/lib/innovation-genome-v8.ts +2 -0
  207. package/src/lib/innovation-genome-v9.orig.ts +643 -0
  208. package/src/lib/innovation-genome-v9.ts +2 -0
  209. package/src/lib/jina.base.ts +293 -0
  210. package/src/lib/jina.ts +1 -0
  211. package/src/lib/live-telemetry.ts +61 -0
  212. package/src/lib/longwriter.ts +84 -0
  213. package/src/lib/manuscript-grade-v2.ts +298 -0
  214. package/src/lib/memory-governor.ts +173 -0
  215. package/src/lib/memory-stress-tests.ts +248 -0
  216. package/src/lib/model-intelligence.ts +48 -0
  217. package/src/lib/model-rotator.ts +75 -0
  218. package/src/lib/models.orig.ts +513 -0
  219. package/src/lib/models.ts +151 -0
  220. package/src/lib/n-deep.base.ts +592 -0
  221. package/src/lib/n-deep.ts +51 -0
  222. package/src/lib/nih-simulator.ts +56 -0
  223. package/src/lib/nih-vulnerability-fixes.ts +460 -0
  224. package/src/lib/omega-templates.base.ts +294 -0
  225. package/src/lib/omega-templates.ts +225 -0
  226. package/src/lib/omni-nexus.ts +64 -0
  227. package/src/lib/oracle-adapters.ts +67 -0
  228. package/src/lib/oracle-registry.ts +163 -0
  229. package/src/lib/orchestrator.ts +357 -0
  230. package/src/lib/output-boundary.ts +235 -0
  231. package/src/lib/overrides/vite-native-chaos-harness.ts +154 -0
  232. package/src/lib/overrides/vite-native-contract-plane.ts +245 -0
  233. package/src/lib/overrides/vite-native-doctor-plane.ts +208 -0
  234. package/src/lib/overrides/vite-native-knowledge-store.ts +267 -0
  235. package/src/lib/overrides/vite-native-policy-plane.ts +190 -0
  236. package/src/lib/overrides/vite-native-replay-plane.ts +197 -0
  237. package/src/lib/overrides/vite-native-runtime-plane.ts +106 -0
  238. package/src/lib/overrides/vite-native-scraper.ts +848 -0
  239. package/src/lib/overrides/vite-native-selftest-functional.ts +217 -0
  240. package/src/lib/overrides/vite-native-selftest.ts +183 -0
  241. package/src/lib/overrides/vite-native-snapshot-plane.ts +123 -0
  242. package/src/lib/philosophy-toolkit.ts +75 -0
  243. package/src/lib/pipeline.orig.ts +659 -0
  244. package/src/lib/pipeline.ts +42 -0
  245. package/src/lib/precache.ts +128 -0
  246. package/src/lib/py-sandbox.ts +205 -0
  247. package/src/lib/quality-score.ts +96 -0
  248. package/src/lib/quant-engine.ts +231 -0
  249. package/src/lib/quant-lib.ts +80 -0
  250. package/src/lib/reportos.ts +175 -0
  251. package/src/lib/research-os.ts +306 -0
  252. package/src/lib/resource-estimator.ts +114 -0
  253. package/src/lib/rpm-governor.ts +93 -0
  254. package/src/lib/runtime-estimator.ts +135 -0
  255. package/src/lib/sage/empty-space-v6.ts +560 -0
  256. package/src/lib/sage/empty-space-v7.ts +222 -0
  257. package/src/lib/sage/empty-space.ts +733 -0
  258. package/src/lib/sage/engine.ts +786 -0
  259. package/src/lib/sage/index.ts +17 -0
  260. package/src/lib/sage/judge.ts +246 -0
  261. package/src/lib/sage/prng.ts +53 -0
  262. package/src/lib/sage/reality-grounding.ts +380 -0
  263. package/src/lib/sage/repetition.ts +151 -0
  264. package/src/lib/sage/saga-os-v2-engines.ts +1870 -0
  265. package/src/lib/sage/saga-os-v2.ts +274 -0
  266. package/src/lib/sage/saga-os-v3-core.ts +1491 -0
  267. package/src/lib/sage/saga-os-v3-release.ts +739 -0
  268. package/src/lib/sage/saga-os-v4-aureate.ts +1161 -0
  269. package/src/lib/sage/saga-os-v4.ts +212 -0
  270. package/src/lib/sage/saga-os-v5.ts +205 -0
  271. package/src/lib/sage/saga-os-v6.ts +346 -0
  272. package/src/lib/sage/saga-os-v7.ts +314 -0
  273. package/src/lib/sage/saga-os-v8.ts +505 -0
  274. package/src/lib/sage/saga-os.ts +329 -0
  275. package/src/lib/sage/taxonomy.ts +403 -0
  276. package/src/lib/sage/unified-roll.ts +524 -0
  277. package/src/lib/sage/worked-sketches.ts +44 -0
  278. package/src/lib/sage.ts +166 -0
  279. package/src/lib/scraper-debug-bus.ts +53 -0
  280. package/src/lib/scraper-enhanced.orig.ts +153 -0
  281. package/src/lib/scraper-enhanced.ts +10 -0
  282. package/src/lib/scraper-hardener.base.orig.ts +155 -0
  283. package/src/lib/scraper-hardener.base.ts +317 -0
  284. package/src/lib/scraper-hardener.ts +1 -0
  285. package/src/lib/scraper-palisade/palisade-adjudicator.orig.ts +419 -0
  286. package/src/lib/scraper-palisade/palisade-adjudicator.ts +13 -0
  287. package/src/lib/scraper-vnext/arbiter-omega.orig.ts +688 -0
  288. package/src/lib/scraper-vnext/arbiter-omega.ts +13 -0
  289. package/src/lib/scraper-vnext/canonical-portfolio-augments.ts +479 -0
  290. package/src/lib/scraper-vnext/canonical-portfolio-orchestrator.orig.ts +1529 -0
  291. package/src/lib/scraper-vnext/canonical-portfolio-orchestrator.ts +13 -0
  292. package/src/lib/scraper-vnext/conclave-omega.ts +1830 -0
  293. package/src/lib/scraper-vnext/content-extractor-v2.ts +226 -0
  294. package/src/lib/scraper-vnext/diagnostics-suite.ts +36 -0
  295. package/src/lib/scraper-vnext/epistemic-packer.ts +97 -0
  296. package/src/lib/scraper-vnext/fusion-v2.ts +65 -0
  297. package/src/lib/scraper-vnext/hydra-reader.orig.ts +1216 -0
  298. package/src/lib/scraper-vnext/hydra-reader.ts +13 -0
  299. package/src/lib/scraper-vnext/native-scraper-browser-vnext.orig.ts +91 -0
  300. package/src/lib/scraper-vnext/native-scraper-browser-vnext.ts +13 -0
  301. package/src/lib/scraper-vnext/nexus-consensus.orig.ts +905 -0
  302. package/src/lib/scraper-vnext/nexus-consensus.ts +13 -0
  303. package/src/lib/scraper-vnext/portfolio-consensus-adjudicator.ts +804 -0
  304. package/src/lib/scraper-vnext/portfolio-consensus-memory.ts +377 -0
  305. package/src/lib/scraper-vnext/portfolio-terminal-governor.ts +548 -0
  306. package/src/lib/scraper-vnext/query-strategist.orig.ts +224 -0
  307. package/src/lib/scraper-vnext/query-strategist.ts +423 -0
  308. package/src/lib/scraper-vnext/retrieval-accelerator.ts +708 -0
  309. package/src/lib/scraper-vnext/retrieval-audit-augments.ts +477 -0
  310. package/src/lib/scraper-vnext/retrieval-control-plane.ts +904 -0
  311. package/src/lib/scraper-vnext/retrieval-policy-augments.ts +358 -0
  312. package/src/lib/scraper-vnext/safe-fetch-v2.ts +157 -0
  313. package/src/lib/scraper-vnext/sentinel-omega.ts +56 -0
  314. package/src/lib/scraper-vnext/sentinel-orchestrator.ts +69 -0
  315. package/src/lib/scraper-vnext/sibyl-oracle.orig.ts +413 -0
  316. package/src/lib/scraper-vnext/sibyl-oracle.ts +13 -0
  317. package/src/lib/scraper-vnext/smart-read-v2.ts +55 -0
  318. package/src/lib/scraper-vnext/spa-rescue-bridge.ts +608 -0
  319. package/src/lib/scraper-vnext/strata-engine.orig.ts +2666 -0
  320. package/src/lib/scraper-vnext/strata-engine.ts +13 -0
  321. package/src/lib/scraper-vnext/structured-source-adapter.orig.ts +369 -0
  322. package/src/lib/scraper-vnext/structured-source-adapter.ts +34 -0
  323. package/src/lib/scraper-vnext/terminal-complete.ts +224 -0
  324. package/src/lib/scraper-vnext/terminal-final.ts +277 -0
  325. package/src/lib/scraper-vnext/terminal-saturation.ts +345 -0
  326. package/src/lib/scraper-vnext/terminal-wire.ts +425 -0
  327. package/src/lib/scraper-vnext/vanguard-titanium.orig.ts +467 -0
  328. package/src/lib/scraper-vnext/vanguard-titanium.ts +17 -0
  329. package/src/lib/search-cache.ts +138 -0
  330. package/src/lib/sloop-runner.base.ts +223 -0
  331. package/src/lib/sloop-runner.ts +104 -0
  332. package/src/lib/sloop.ts +114 -0
  333. package/src/lib/small-model-adapters.ts +82 -0
  334. package/src/lib/sscp.ts +86 -0
  335. package/src/lib/system-map.ts +54 -0
  336. package/src/lib/uni-node.ts +86 -0
  337. package/src/lib/universal-rigor-guard.ts +433 -0
  338. package/src/lib/v15-gate-testbed.ts +274 -0
  339. package/src/lib/v15-gemini.base.ts +89 -0
  340. package/src/lib/v15-gemini.ts +1 -0
  341. package/src/lib/v15-grounding.orig.ts +241 -0
  342. package/src/lib/v15-grounding.ts +79 -0
  343. package/src/lib/v15-pipeline.base.ts +769 -0
  344. package/src/lib/v15-pipeline.orig.ts +1154 -0
  345. package/src/lib/v15-pipeline.ts +674 -0
  346. package/src/lib/v15-questions.ts +64 -0
  347. package/src/lib/v15-rate-limiter.orig.ts +91 -0
  348. package/src/lib/v15-rate-limiter.ts +48 -0
  349. package/src/lib/v15-state.base.ts +87 -0
  350. package/src/lib/v15-state.ts +28 -0
  351. package/src/lib/visual-table-generator.tsx +207 -0
  352. package/src/lib/wasm-runtime.ts +133 -0
  353. package/src/lib/williams-persona-guide.ts +265 -0
  354. package/src/lib/williams-style.base.ts +464 -0
  355. package/src/lib/williams-style.ts +59 -0
  356. package/src/lib/worker-pool.ts +96 -0
  357. package/src/lib/writing-tiers.ts +125 -0
  358. package/src/main.orig.tsx +10 -0
  359. package/src/main.tsx +10 -0
  360. package/src/utils/cn.orig.ts +6 -0
  361. package/src/utils/cn.ts +6 -0
  362. package/src/vite-env.d.ts +1 -0
  363. package/tsconfig.json +31 -0
  364. package/unify.mjs +537 -0
  365. package/vite.config.ts +18 -0
@@ -0,0 +1,314 @@
1
+ /**
2
+ * innovation-genome-v10.ts — Creative Tree of Life plane.
3
+ * Additive over V1-V9. Offline-first. No model/web/solver dependency.
4
+ * Semantics preserved: novelty = workspace-local dissimilarity only; generated
5
+ * content = unverified proposal; rejected branches preserved as compost; human
6
+ * authorship/edits distinguishable from generated content.
7
+ */
8
+
9
+ import { seedToGenome } from "@/lib/innovation-genome-engine";
10
+ import { classifyPersonaExtended, selectPathExtended } from "@/lib/innovation-genome-engine-v2";
11
+ import { deriveSeed, sha256Text, canonicalJson, utcNow } from "@/lib/innovation-genome-v3";
12
+ import { V9CompliancePlaneStore } from "@/lib/innovation-genome-v9";
13
+
14
+ export const V10_SCHEMA_VERSION = 1;
15
+ export const V10_PROTOCOL_VERSION = "10.0-alpha-rc1";
16
+
17
+ export type CreativeMode = "idea" | "theory" | "product" | "code" | "research" | "story";
18
+ export type NodeKind = "root" | "idea" | "question" | "analogy" | "assumption" | "experiment" | "synthesis" | "note";
19
+ export type LifeStage = "seed" | "sprout" | "branch" | "bloom" | "fruit" | "compost";
20
+ export type NodeStatus = "active" | "favorite" | "parked" | "rejected" | "merged" | "archived";
21
+ export type EdgeRelation = "grows_from" | "refines" | "combines" | "asks" | "tests" | "supports" | "challenges" | "analogy_to" | "recycles" | "depends_on";
22
+ export type ConfirmationVerdict = "confirm" | "reject" | "uncertain";
23
+ export type ConfirmationDimension = "overall" | "problem_real" | "value_desirable" | "mechanism_plausible" | "feasible" | "validation_testable" | "differentiated" | "ethical" | "personal_energy";
24
+
25
+ export interface CreativeBrief {
26
+ challenge: string;
27
+ mode: CreativeMode;
28
+ audience: string[];
29
+ desiredOutcomes: string[];
30
+ constraints: string[];
31
+ resources: string[];
32
+ inspirationDomains: string[];
33
+ avoid: string[];
34
+ axes: Record<string, string[]>;
35
+ }
36
+
37
+ export interface IdeaCard {
38
+ title: string;
39
+ thesis: string;
40
+ beneficiary: string;
41
+ tension: string;
42
+ mechanism: string;
43
+ value: string;
44
+ differentiation: string;
45
+ assumptions: string[];
46
+ risks: string[];
47
+ validation: string[];
48
+ nextAction: string;
49
+ artifacts: string[];
50
+ openQuestions: string[];
51
+ operatorId: string;
52
+ operatorFamily: string;
53
+ mode: CreativeMode;
54
+ morphology: Record<string, string>;
55
+ modeFields: Record<string, unknown>;
56
+ tags: string[];
57
+ epistemicStatus: string;
58
+ }
59
+
60
+ export interface NodeRecord {
61
+ nodeId: string;
62
+ workspaceId: string;
63
+ nodeKind: NodeKind;
64
+ lifeStage: LifeStage;
65
+ status: NodeStatus;
66
+ title: string;
67
+ body: Record<string, unknown> | IdeaCard;
68
+ operatorId: string;
69
+ fingerprint: string;
70
+ localNovelty: number;
71
+ cohesion: number;
72
+ depth: number;
73
+ createdBy: string;
74
+ createdUtc: string;
75
+ updatedUtc: string;
76
+ }
77
+
78
+ export interface RankedIdea {
79
+ node: NodeRecord;
80
+ score: number;
81
+ humanScore: number;
82
+ preferenceScore: number;
83
+ noveltyScore: number;
84
+ cohesionScore: number;
85
+ }
86
+
87
+ export interface TreeHealth {
88
+ nodeCount: number; branchCount: number; bloomCount: number; fruitCount: number; compostCount: number;
89
+ operatorFamilyCount: number; meanLocalNovelty: number; meanCohesion: number; humanTouchRate: number; confirmationCount: number;
90
+ }
91
+
92
+ export interface BurstConfig { count: number; candidateMultiplier: number; maximumSimilarity: number; minimumOperatorFamilies: number; }
93
+
94
+ export interface OperatorSpec {
95
+ operatorId: string; family: string; name: string; principle: string;
96
+ mechanismTemplate: string; reflectionQuestion: string; validationTemplate: string;
97
+ }
98
+
99
+ export const OPERATORS: OperatorSpec[] = [
100
+ ["subtract","simplification","Radical Subtraction","Remove a step rather than adding another feature."],
101
+ ["invert","power_shift","Role Inversion","Reverse who initiates, owns, approves, or benefits."],
102
+ ["protocol","infrastructure","Protocol Instead of Product","Create an interoperable rule or interface."],
103
+ ["observability","information","Reveal the Hidden State","Make an invisible condition measurable."],
104
+ ["concierge","service","Concierge Before Automation","Deliver the value manually before automating it."],
105
+ ["composable","architecture","Composable Building Blocks","Replace a monolith with reusable pieces."],
106
+ ["local_first","ownership","Local-First Ownership","Move control and memory toward the user."],
107
+ ["collective","collective_intelligence","Collective Intelligence","Aggregate diverse partial judgments."],
108
+ ["counterfactual","simulation","Counterfactual Twin","Test consequences in a safe parallel representation."],
109
+ ["preventive","timing","Move Earlier","Intervene before the problem becomes expensive."],
110
+ ["reversible","risk","Reversible Commitments","Convert one large bet into inspectable reversible steps."],
111
+ ["cross_domain","analogy","Cross-Domain Transfer","Import a mechanism, not superficial vocabulary."],
112
+ ["market","coordination","Coordination Market","Match fragmented needs and underused capacity."],
113
+ ["proof_carrying","trust","Proof-Carrying Output","Make each important result carry its own evidence."],
114
+ ["accessibility","inclusion","Constraint as Design Material","Design first for the hardest access constraint."],
115
+ ["antifragile","resilience","Learn From Failure","Turn each failure into a reusable improvement."],
116
+ ["progressive","interaction","Progressive Disclosure","Give the smallest useful result first."],
117
+ ["ecology","ecology","Mutualistic Ecosystem","Create a loop where participants improve one another."],
118
+ ["ritual","behavior","Ritual and Rhythm","Turn an occasional intention into a repeated practice."],
119
+ ["two_speed","governance","Two-Speed System","Separate rapid exploration from slow irreversible commitment."],
120
+ ].map(([operatorId, family, name, principle]) => ({
121
+ operatorId, family, name, principle,
122
+ mechanismTemplate: `apply ${name.toLowerCase()} to “{challenge}” for {audience}, using {resource}, under {constraint}, toward {outcome}`,
123
+ reflectionQuestion: `What changes if ${principle.toLowerCase()}`,
124
+ validationTemplate: "Test smallest falsifiable version with one human reviewer and record disconfirming evidence.",
125
+ }));
126
+
127
+ const STOP = new Set("a an and are as at be by for from how in into is it of on or that the their this to use using with without we you your".split(" "));
128
+ const DEFAULT_SHAPES = ["a personal tool","a guided service","a reusable protocol","a small-team practice","a shared commons","an ambient layer","a modular platform","a temporary experiment"];
129
+ const DEFAULT_HORIZONS = ["at the moment of decision","before the first visible failure","once per working cycle","during onboarding","after every completed attempt","whenever uncertainty rises"];
130
+ const DEFAULT_SCALES = ["one person","a pair","a small team","a community","an organization","an ecosystem"];
131
+
132
+ function tokens(text: string): Set<string> {
133
+ return new Set((text.match(/[A-Za-z0-9_]{3,}/g) ?? []).map(t => t.toLowerCase()).filter(t => !STOP.has(t)));
134
+ }
135
+ function jaccard(a: Set<string>, b: Set<string>): number { const u = new Set([...a, ...b]); if (!u.size) return 1; let i = 0; for (const x of a) if (b.has(x)) i++; return i / u.size; }
136
+ function textOf(card: IdeaCard): string { return canonicalJson(card); }
137
+ function fingerprint(card: IdeaCard): string { return sha256Text(canonicalJson({ operator_id: card.operatorId, tokens: [...tokens(textOf(card))].sort(), morphology: card.morphology })); }
138
+ function rawFingerprint(body: Record<string, unknown>): string { return sha256Text(canonicalJson(body)); }
139
+ function concept(challenge: string): string { return (challenge.match(/[A-Za-z0-9]+/g) ?? []).filter(w => !STOP.has(w.toLowerCase())).slice(0,4).map(w => w[0].toUpperCase()+w.slice(1)).join(" ") || "New Concept"; }
140
+ function pick(values: string[], fallback: string, seed: number): string { return values.length ? values[Math.abs(seed) % values.length] : fallback; }
141
+
142
+ function modeScaffold(mode: CreativeMode, challenge: string, audience: string, outcome: string, mechanism: string): [string[], string, string[], Record<string, unknown>] {
143
+ if (mode === "product") return [["A one-page product concept","A concierge prototype","A five-question interview guide"], "Interview three target users, then deliver value manually to one before building software.", ["What narrow use case is urgent?", "What evidence would cause behavior switch?"], { job_to_be_done: `Help ${audience} make progress on ${challenge}.`, mvp: "Concierge or clickable version containing only load-bearing interaction.", mechanism }];
144
+ if (mode === "code") return [["A behavioral contract","An interface/data model","A vertical executable slice","A failure-oriented test plan"], "Write acceptance test first, then implement one end-to-end path with no hidden dependencies.", ["What state must survive restart?", "Which operation can cause irreversible harm?"], { behavioral_contract: `Given valid input related to ${challenge}, return inspectable result that advances ${outcome}.`, mechanism }];
145
+ if (mode === "research") return [["A falsifiable research question","A hypothesis and alternative","A minimal study protocol","A measurement table"], "Specify smallest study distinguishing hypothesis from baseline.", ["Which result makes hypothesis less likely?", "What confounder creates same observation?"], { research_question: challenge, hypothesis: `Applying mechanism improves ${outcome} for ${audience}.`, mechanism }];
146
+ if (mode === "story") return [["A premise card","A character-pressure map","A world-rule sheet","One opening scene"], "Write scene where protagonist chooses between mechanism benefit and hidden cost.", ["What price makes premise emotionally real?", "How does protagonist misunderstand mechanism?"], { premise: `World where mechanism behind ${challenge} becomes visible.`, protagonist: audience, mechanism }];
147
+ if (mode === "theory") return [["A one-page theory map","A prediction/falsifier table","A scope-condition register"], "Identify cheapest observation separating mechanism from alternative.", ["Which alternative predicts same result?", "Where should effect disappear?"], { phenomenon: challenge, hypothesis: `Outcome may arise because ${mechanism}.` }];
148
+ return [["A concept card","A mechanism diagram","A validation checklist"], "Show concept to one affected person and ask them to change one assumption.", ["What must be true for this to matter?", "What adjacent idea strengthens it?"], { change_model: "Current state -> mechanism -> observable result" }];
149
+ }
150
+
151
+ export class OfflineMorphologicalProvider {
152
+ generate(brief: CreativeBrief, genome: Record<string, number>, seed: number, candidateCount: number, operatorIds: string[] = [], parentContext = ""): IdeaCard[] {
153
+ if (!brief.challenge.trim()) throw new Error("Creative brief challenge cannot be empty");
154
+ const allowed = operatorIds.length ? OPERATORS.filter(o => operatorIds.includes(o.operatorId)) : OPERATORS;
155
+ const cards: IdeaCard[] = [];
156
+ for (let i = 0; i < candidateCount; i++) {
157
+ const op = allowed[Math.abs(deriveSeed(seed, i, "op")) % allowed.length];
158
+ const audience = pick(brief.audience, "the person most affected by the challenge", deriveSeed(seed, i, "aud"));
159
+ const outcome = pick(brief.desiredOutcomes, "a measurable improvement in clarity, agency, or outcome", deriveSeed(seed, i, "out"));
160
+ const constraint = pick(brief.constraints, "limited time, trust, attention, or resources", deriveSeed(seed, i, "con"));
161
+ const resource = pick(brief.resources, "existing knowledge, relationships, and underused capacity", deriveSeed(seed, i, "res"));
162
+ const domain = pick(brief.inspirationDomains, ["ecology","public infrastructure","craft apprenticeship","distributed systems","games","scientific instrumentation","mutual aid","logistics"][Math.abs(deriveSeed(seed,i,"dom"))%8], deriveSeed(seed, i, "dom2"));
163
+ const shape = DEFAULT_SHAPES[Math.abs(deriveSeed(seed,i,"shape")) % DEFAULT_SHAPES.length];
164
+ const horizon = DEFAULT_HORIZONS[Math.abs(deriveSeed(seed,i,"h")) % DEFAULT_HORIZONS.length];
165
+ const scale = DEFAULT_SCALES[Math.abs(deriveSeed(seed,i,"scale")) % DEFAULT_SCALES.length];
166
+ const morphology: Record<string,string> = { audience, outcome, constraint, resource, source_domain: domain, delivery_shape: shape, time_horizon: horizon, scale };
167
+ for (const [axis, opts] of Object.entries(brief.axes)) morphology[axis] = opts[Math.abs(deriveSeed(seed,i,axis)) % opts.length];
168
+ let mechanism = op.mechanismTemplate.replace("{challenge}", brief.challenge).replace("{audience}", audience).replace("{resource}", resource).replace("{constraint}", constraint).replace("{outcome}", outcome);
169
+ if (parentContext) mechanism += `. Preserve useful parent branch: ${parentContext.slice(0,240)}`;
170
+ const [artifacts, nextAction, qs, modeFields] = modeScaffold(brief.mode, brief.challenge, audience, outcome, mechanism);
171
+ cards.push({
172
+ title: `${op.name} · ${concept(brief.challenge)}${i >= allowed.length ? ` · ${shape.replace(/^a |^an /,"")}` : ""}`,
173
+ thesis: `For ${audience}, explore ${shape} that addresses “${brief.challenge.replace(/\.$/,"")}” by attempting to ${mechanism}. Use it ${horizon} at ${scale} scale.`,
174
+ beneficiary: audience,
175
+ tension: `Intended outcome is ${outcome}, but current approaches are constrained by ${constraint}.`,
176
+ mechanism,
177
+ value: `If mechanism works, it should improve ${outcome} while making important trade-offs visible.`,
178
+ differentiation: `Organized around ${op.principle} Tested combination: ${Object.entries(morphology).map(([k,v])=>`${k}=${v}`).join("; ")}.`,
179
+ assumptions: [`${audience} experiences challenge frequently enough to care.`, "Mechanism changes load-bearing part of current situation.", `Design can operate within ${constraint} by using ${resource}.`],
180
+ risks: ["Mechanism may sound coherent without changing behavior.", "Selected audience may not value intended outcome.", "Intervention may move effort or risk to less visible participant."],
181
+ validation: [op.validationTemplate, "Ask human reviewer to identify weakest causal link before implementation.", "Record disconfirming result rather than silently rewriting original claim."],
182
+ nextAction,
183
+ artifacts,
184
+ openQuestions: [op.reflectionQuestion, ...qs],
185
+ operatorId: op.operatorId,
186
+ operatorFamily: op.family,
187
+ mode: brief.mode,
188
+ morphology,
189
+ modeFields,
190
+ tags: [...new Set([op.family, op.operatorId, brief.mode, domain, shape, scale, ...tokens(brief.challenge)])],
191
+ epistemicStatus: "proposal — unverified until a human confirms or tests it",
192
+ });
193
+ void genome;
194
+ }
195
+ return cards;
196
+ }
197
+ }
198
+
199
+ function cohesion(card: IdeaCard, brief: CreativeBrief): number {
200
+ const req = [card.title, card.thesis, card.beneficiary, card.tension, card.mechanism, card.value, card.differentiation, card.nextAction];
201
+ const completeness = req.filter(v => v.trim()).length / req.length;
202
+ const briefTokens = tokens([brief.challenge, ...brief.desiredOutcomes, ...brief.audience].join(" "));
203
+ const cardTokens = tokens(textOf(card));
204
+ let align = 0; for (const t of briefTokens) if (cardTokens.has(t)) align++;
205
+ const alignment = align / Math.max(1, briefTokens.size);
206
+ return Math.round(Math.min(1, .4*completeness + .25*alignment + .2*(card.assumptions.length&&card.validation.length?1:0)+.15*(card.artifacts.length&&card.nextAction&&Object.keys(card.modeFields).length?1:0))*10000)/10000;
207
+ }
208
+ function novelty(card: IdeaCard, texts: string[]): number { if (!texts.length) return 1; const t = tokens(textOf(card)); return Math.round((1 - Math.max(...texts.map(x => jaccard(t, tokens(x))))) * 10000) / 10000; }
209
+
210
+ export function selectDiverseCards(candidates: IdeaCard[], brief: CreativeBrief, genome: Record<string, number>, config: BurstConfig, existingTexts: string[] = []): Array<[IdeaCard, number, number]> {
211
+ const map = new Map<string, IdeaCard>(); for (const c of candidates) if (!map.has(fingerprint(c))) map.set(fingerprint(c), c);
212
+ const remaining = [...map.values()]; const selected: Array<[IdeaCard, number, number]> = []; const comp = [...existingTexts]; const fams = new Set<string>();
213
+ while (remaining.length && selected.length < config.count) {
214
+ const scored = remaining.map(card => { const n = novelty(card, comp); const c = cohesion(card, brief); const fb = fams.has(card.operatorFamily) ? 0 : 1; const s = (.4+.2*(genome.novelty_vs_utility??.5))*n + (.35+.1*(genome.taste_weight??.5))*c + .2*fb; return { card, n, c, s }; }).sort((a,b)=>b.s-a.s || a.card.operatorId.localeCompare(b.card.operatorId));
215
+ const pick = scored.find(x => x.n >= 1-config.maximumSimilarity) ?? scored[0]; selected.push([pick.card,pick.n,pick.c]); fams.add(pick.card.operatorFamily); comp.push(textOf(pick.card)); remaining.splice(remaining.indexOf(pick.card),1);
216
+ }
217
+ return selected;
218
+ }
219
+
220
+ export class V10CreativeStore extends V9CompliancePlaneStore {
221
+ profiles = new Map<string, Record<string, unknown>>(); workspaces = new Map<string, Record<string, unknown>>(); nodes = new Map<string, NodeRecord>(); edges: Array<{edgeId:string; workspaceId:string; sourceNodeId:string; targetNodeId:string; relation:EdgeRelation; rationale:string; createdUtc:string}> = []; confirmations: any[] = [];
222
+ v10SchemaCurrent(): boolean { return true; }
223
+ }
224
+
225
+ export class CreativeStudio {
226
+ constructor(public store: V10CreativeStore, public provider = new OfflineMorphologicalProvider()) {}
227
+ bootstrapLocal(displayName = "Creator") { const runId = `run-v10-${sha256Text(displayName).slice(0,12)}`; const tenantId = `tenant-${sha256Text(displayName).slice(0,12)}`; const principalId = `principal-${sha256Text(displayName).slice(0,12)}`; const profileId = `profile-${sha256Text(displayName).slice(0,12)}`; this.store.createRun(runId, 42, "creative", "low", {version:V10_PROTOCOL_VERSION}); this.store.profiles.set(profileId,{profileId,displayName,tenantId,principalId,runId,createdUtc:utcNow()}); return {profileId,displayName,tenantId,principalId,runId}; }
228
+ createWorkspace(profile: any, title: string, brief: CreativeBrief, seed: number): string { if(!title.trim()) throw new Error("Workspace title cannot be empty"); const genome=seedToGenome(seed); const persona=classifyPersonaExtended(genome); const path=selectPathExtended(genome); const workspaceId=`workspace-${sha256Text(profile.profileId+title+seed).slice(0,24)}`; const rootNodeId=`node-root-${workspaceId.slice(-18)}`; const now=utcNow(); this.store.workspaces.set(workspaceId,{workspaceId,tenantId:profile.tenantId,principalId:profile.principalId,runId:profile.runId,title,brief,mode:brief.mode,seed,genome,persona,path,rootNodeId,status:"active",createdUtc:now,updatedUtc:now}); this.store.nodes.set(rootNodeId,{nodeId:rootNodeId,workspaceId,nodeKind:"root",lifeStage:"seed",status:"active",title,body:{brief,persona,path,epistemic_status:"human-supplied creative seed"},operatorId:"human-seed",fingerprint:rawFingerprint({brief,persona,path}),localNovelty:1,cohesion:1,depth:0,createdBy:"human",createdUtc:now,updatedUtc:now}); return workspaceId; }
229
+ workspaceBrief(workspaceId: string): CreativeBrief { return this.store.workspaces.get(workspaceId)?.brief as CreativeBrief; }
230
+ workspaceNodes(workspaceId: string): NodeRecord[] { return [...this.store.nodes.values()].filter(n=>n.workspaceId===workspaceId).sort((a,b)=>a.depth-b.depth || a.createdUtc.localeCompare(b.createdUtc)); }
231
+ private existingTexts(workspaceId:string){ return this.workspaceNodes(workspaceId).filter(n=>n.nodeKind==="idea"||n.nodeKind==="synthesis").map(n=>canonicalJson(n.body)); }
232
+ private insertCards(workspaceId:string,parentIds:string[],relation:EdgeRelation,cards:Array<[IdeaCard,number,number]>,createdBy:string,nodeKind:NodeKind="idea"): NodeRecord[]{ const depth=Math.max(0,...parentIds.map(id=>this.store.nodes.get(id)?.depth??0))+1; const now=utcNow(); return cards.map(([card,n,c])=>{ const nodeId=`node-${sha256Text(workspaceId+fingerprint(card)+now).slice(0,24)}`; const rec:NodeRecord={nodeId,workspaceId,nodeKind,lifeStage:"branch",status:"active",title:card.title,body:card,operatorId:card.operatorId,fingerprint:fingerprint(card),localNovelty:n,cohesion:c,depth,createdBy,createdUtc:now,updatedUtc:now}; this.store.nodes.set(nodeId,rec); for(const p of parentIds)this.store.edges.push({edgeId:`edge-${sha256Text(p+nodeId+relation).slice(0,18)}`,workspaceId,sourceNodeId:p,targetNodeId:nodeId,relation,rationale:"creative growth",createdUtc:now}); return rec; }); }
233
+ burst(workspaceId:string, config:BurstConfig={count:12,candidateMultiplier:4,maximumSimilarity:.82,minimumOperatorFamilies:6}, parentId?:string, operatorIds:string[]=[]):NodeRecord[]{ const w=this.store.workspaces.get(workspaceId)!; const parent=parentId??String(w.rootNodeId); const brief=this.workspaceBrief(workspaceId); const candidates=this.provider.generate(brief,w.genome as Record<string,number>,deriveSeed(w.seed,parent,this.workspaceNodes(workspaceId).length),Math.max(config.count,config.count*config.candidateMultiplier),operatorIds); return this.insertCards(workspaceId,[parent],parent===w.rootNodeId?"grows_from":"refines",selectDiverseCards(candidates,brief,w.genome as Record<string,number>,config,this.existingTexts(workspaceId)),"offline-morphological-engine"); }
234
+ sprout(workspaceId:string,count=8):NodeRecord[]{ const w=this.store.workspaces.get(workspaceId)!; const root=String(w.rootNodeId); const now=utcNow(); const out:NodeRecord[]=[]; for(let i=0;i<count;i++){const op=OPERATORS[i%OPERATORS.length]; const kinds:NodeKind[]=["question","analogy","assumption","note"]; const kind=kinds[i%4]; const body={text:`${op.reflectionQuestion} — ${op.principle}`,epistemic_status:"open sprout — no answer selected"}; const nodeId=`node-${sha256Text(workspaceId+kind+i+now).slice(0,24)}`; const rec:NodeRecord={nodeId,workspaceId,nodeKind:kind,lifeStage:"sprout",status:"active",title:`${kind} · ${op.name}`,body,operatorId:op.operatorId,fingerprint:rawFingerprint(body),localNovelty:1,cohesion:1,depth:1,createdBy:"offline-morphological-engine",createdUtc:now,updatedUtc:now}; this.store.nodes.set(nodeId,rec); this.store.edges.push({edgeId:`edge-${sha256Text(root+nodeId).slice(0,18)}`,workspaceId,sourceNodeId:root,targetNodeId:nodeId,relation:kind==="question"?"asks":"grows_from",rationale:"deterministic sprout",createdUtc:now}); out.push(rec);} return out; }
235
+ creativeExplosion(workspaceId:string,sproutCount=8,branchCount=16){ const sprouts=this.sprout(workspaceId,sproutCount); const branches=this.burst(workspaceId,{count:branchCount,candidateMultiplier:5,maximumSimilarity:.82,minimumOperatorFamilies:8}); return {workspaceId,sproutIds:sprouts.map(n=>n.nodeId),branchIds:branches.map(n=>n.nodeId),treeHealth:this.treeHealth(workspaceId),nextMoves:this.nextMoves(workspaceId)}; }
236
+ crossPollinate(leftId:string,rightId:string):NodeRecord{ const l=this.store.nodes.get(leftId)!; const r=this.store.nodes.get(rightId)!; const lc=l.body as IdeaCard; const rc=r.body as IdeaCard; const card:IdeaCard={...lc,title:`Synthesis · ${l.title} × ${r.title}`,thesis:`Combine ${l.title} with ${r.title}.`,mechanism:`${lc.mechanism} + ${rc.mechanism}`,differentiation:"Explicit two-parent lineage.",operatorId:"cross-pollination",operatorFamily:"synthesis",morphology:{left_parent:leftId,right_parent:rightId},modeFields:{interaction_test:"Combined performance must exceed stronger parent."},tags:[...new Set(["synthesis",...lc.tags,...rc.tags])]}; const brief=this.workspaceBrief(l.workspaceId); return this.insertCards(l.workspaceId,[leftId,rightId],"combines",[[card,novelty(card,this.existingTexts(l.workspaceId)),cohesion(card,brief)]],"offline-morphological-engine","synthesis")[0]; }
237
+ confirm(nodeId:string,dimension:ConfirmationDimension,verdict:ConfirmationVerdict,rating=3,rationale=""){ const node=this.store.nodes.get(nodeId)!; this.store.confirmations.push({nodeId,workspaceId:node.workspaceId,dimension,verdict,rating,rationale,createdUtc:utcNow()}); if(verdict==="reject"){node.status="rejected"; node.lifeStage="compost";} if(verdict==="confirm") node.status="favorite"; return `confirmation-${sha256Text(nodeId+dimension+verdict+Date.now()).slice(0,18)}`; }
238
+ rankIdeas(workspaceId:string):RankedIdea[]{ return this.workspaceNodes(workspaceId).filter(n=>n.nodeKind==="idea"||n.nodeKind==="synthesis").map(n=>{const human=n.status==="favorite"?.9:n.status==="rejected"?0:.5; const pref=.5; const score=.6*human+.18*pref+.11*n.localNovelty+.11*n.cohesion; return {node:n,score:Math.round(score*10000)/10000,humanScore:human,preferenceScore:pref,noveltyScore:n.localNovelty,cohesionScore:n.cohesion};}).sort((a,b)=>b.score-a.score); }
239
+ treeHealth(workspaceId:string):TreeHealth{ const nodes=this.workspaceNodes(workspaceId); const ideas=nodes.filter(n=>n.nodeKind==="idea"||n.nodeKind==="synthesis"); const fams=new Set(ideas.map(n=>(n.body as IdeaCard).operatorFamily)); const mean=(xs:number[])=>xs.length?xs.reduce((a,b)=>a+b,0)/xs.length:0; return {nodeCount:nodes.length,branchCount:nodes.filter(n=>n.lifeStage==="branch").length,bloomCount:nodes.filter(n=>n.lifeStage==="bloom").length,fruitCount:nodes.filter(n=>n.lifeStage==="fruit").length,compostCount:nodes.filter(n=>n.lifeStage==="compost").length,operatorFamilyCount:fams.size,meanLocalNovelty:Math.round(mean(ideas.map(n=>n.localNovelty))*10000)/10000,meanCohesion:Math.round(mean(ideas.map(n=>n.cohesion))*10000)/10000,humanTouchRate:Math.round(nodes.filter(n=>n.createdBy==="human"||this.store.confirmations.some(c=>c.nodeId===n.nodeId)).length/Math.max(1,nodes.length)*10000)/10000,confirmationCount:this.store.confirmations.filter(c=>this.store.nodes.get(c.nodeId)?.workspaceId===workspaceId).length}; }
240
+ nextMoves(workspaceId:string):string[]{ const h=this.treeHealth(workspaceId); const moves:string[]=[]; if(h.branchCount<8)moves.push("Run another creative burst to widen portfolio before selecting winner."); if(h.operatorFamilyCount<6)moves.push("Grow branches from underrepresented operator families."); const ranked=this.rankIdeas(workspaceId); for(const r of ranked.slice(0,3)) if(!this.store.confirmations.some(c=>c.nodeId===r.node.nodeId)) moves.push(`Confirm, reject, or revise “${r.node.title}”.`); return moves.length?moves:["Choose branch with most personal energy and perform smallest disconfirming test."]; }
241
+ exportTerminal(workspaceId:string):string{ const nodes=this.workspaceNodes(workspaceId); return nodes.map(n=>`${" ".repeat(n.depth)}${n.lifeStage}:${n.title}<${n.status}>`).join("\n"); }
242
+ exportJson(workspaceId:string):string{ return JSON.stringify({protocolVersion:V10_PROTOCOL_VERSION,workspace:this.store.workspaces.get(workspaceId),nodes:this.workspaceNodes(workspaceId),edges:this.store.edges.filter(e=>e.workspaceId===workspaceId),ranking:this.rankIdeas(workspaceId),treeHealth:this.treeHealth(workspaceId),nextMoves:this.nextMoves(workspaceId),semantics:{novelty:"workspace-local dissimilarity only",verification:"generated branches remain unverified proposals"}},null,2); }
243
+ /** 3D page adapter: get workspace record */
244
+ workspace(workspaceId: string) { const w = this.store.workspaces.get(workspaceId); if (!w) throw new Error(workspaceId); return w as Record<string, unknown> & { brief: CreativeBrief; seed: number; rootNodeId: string }; }
245
+ /** 3D page adapter: alias for workspaceNodes */
246
+ nodes(workspaceId: string) { return this.workspaceNodes(workspaceId); }
247
+ /** 3D page adapter: edges for workspace */
248
+ edgesFor(workspaceId: string) { return this.store.edges.filter(e => e.workspaceId === workspaceId).map(e => ({ source_node_id: e.sourceNodeId, target_node_id: e.targetNodeId, relation: e.relation })); }
249
+ /** 3D page adapter: list all workspaces */
250
+ listWorkspaces() { return [...this.store.workspaces.values()].map(w => ({ workspace_id: (w as any).workspaceId, title: (w as any).title, mode: (w as any).mode, seed: (w as any).seed })); }
251
+ /** 3D page adapter: expand a branch through a lens */
252
+ expand(nodeId: string, lens: string, count = 6) { const node = this.store.nodes.get(nodeId); if (!node) throw new Error(nodeId); const brief = this.workspaceBrief(node.workspaceId); const w = this.workspace(node.workspaceId); const expanded: CreativeBrief = { ...brief, challenge: `Explore "${node.title}" through lens: ${lens}`, axes: { ...brief.axes, expansion_lens: [lens] } }; const candidates = this.provider.generate(expanded, w.genome as Record<string, number>, deriveSeed(w.seed, nodeId, lens), count * 4); return this.insertCards(node.workspaceId, [nodeId], "refines", selectDiverseCards(candidates, expanded, w.genome as Record<string, number>, { count, candidateMultiplier: 4, maximumSimilarity: 0.82, minimumOperatorFamilies: 4 }, this.existingTexts(node.workspaceId)), "offline-morphological-engine"); }
253
+ /** 3D page adapter: fractal zoom — turn riskiest assumption into child problem */
254
+ fractalZoom(nodeId: string, count = 5) { const node = this.store.nodes.get(nodeId); if (!node) throw new Error(nodeId); const card = node.body as IdeaCard; const assumption = card?.assumptions?.[0] ?? node.title; const questionBody = { text: `What must be true for this assumption to hold: ${assumption}`, unlocks: nodeId, epistemic_status: "open question" }; const qId = `node-${sha256Text(node.workspaceId + "zoom" + nodeId + utcNow()).slice(0, 24)}`; const now = utcNow(); const qRec: NodeRecord = { nodeId: qId, workspaceId: node.workspaceId, nodeKind: "question", lifeStage: "sprout", status: "active", title: "Fractal bottleneck", body: questionBody, operatorId: "fractal-zoom", fingerprint: rawFingerprint(questionBody), localNovelty: 1, cohesion: 1, depth: node.depth + 1, createdBy: "offline-morphological-engine", createdUtc: now, updatedUtc: now }; this.store.nodes.set(qId, qRec); this.store.edges.push({ edgeId: `edge-${sha256Text(nodeId + qId).slice(0, 18)}`, workspaceId: node.workspaceId, sourceNodeId: nodeId, targetNodeId: qId, relation: "asks", rationale: "fractal zoom", createdUtc: now }); const branches = this.expand(qId, "resolve or reframe the active bottleneck", count); return { question: qRec, branches }; }
255
+ /** 3D page adapter: compost a branch (reject + preserve failure reason) */
256
+ compost(nodeId: string, reason: string) { const node = this.store.nodes.get(nodeId); if (!node) throw new Error(nodeId); if (node.nodeKind === "root") throw new Error("Cannot compost root"); this.confirm(nodeId, "overall", "reject", 5, reason || "composted"); return node; }
257
+ /** 3D page adapter: export in multiple formats */
258
+ exportWorkspace(workspaceId: string, format: string): string { if (format === "json") return this.exportJson(workspaceId); if (format === "terminal" || format === "tree") return this.exportTerminal(workspaceId); if (format === "markdown") return `# Tree of Life\n\n${this.exportTerminal(workspaceId)}\n\n## Ranking\n\n${this.rankIdeas(workspaceId).map((r, i) => `${i + 1}. ${r.node.title} (${r.score.toFixed(2)})`).join("\n")}`; if (format === "mermaid") { const nodes = this.workspaceNodes(workspaceId); const edges = this.edgesFor(workspaceId); return ["flowchart TD", ...nodes.map(n => ` ${n.nodeId.replace(/[^a-zA-Z0-9]/g, "_")}["${n.lifeStage}: ${n.title.slice(0, 30).replace(/"/g, "'")}"]`), ...edges.map(e => ` ${e.source_node_id.replace(/[^a-zA-Z0-9]/g, "_")} -->|${e.relation}| ${e.target_node_id.replace(/[^a-zA-Z0-9]/g, "_")}`)].join("\n"); } return this.exportJson(workspaceId); }
259
+ /** 3D page adapter: simplified createWorkspace without profile */
260
+ createWorkspaceSimple(title: string, brief: CreativeBrief, seed: number): string { const profile = this.bootstrapLocal("Creator"); return this.createWorkspace(profile, title, brief, seed); }
261
+ }
262
+
263
+ export interface V10DiscoveryContext {
264
+ seed: number;
265
+ mode: CreativeMode;
266
+ directive: string;
267
+ searchAngles: string[];
268
+ nextMoves: string[];
269
+ tree: string;
270
+ topBranches: Array<{ nodeId: string; title: string; thesis: string; mechanism: string; score: number }>;
271
+ }
272
+
273
+ /** Deterministic pipeline adapter. Produces directions and search angles, never truth claims. */
274
+ export function buildV10DiscoveryContext(challenge: string, mode: CreativeMode = "research", seed = deriveSeed(challenge, mode, "v10-pipeline")): V10DiscoveryContext {
275
+ const store = new V10CreativeStore();
276
+ const studio = new CreativeStudio(store);
277
+ const profile = studio.bootstrapLocal("Pipeline");
278
+ const brief: CreativeBrief = {
279
+ challenge,
280
+ mode,
281
+ audience: ["intended user or decision-maker"],
282
+ desiredOutcomes: ["an evidence-bound, useful answer"],
283
+ constraints: ["do not invent facts; preserve uncertainty"],
284
+ resources: ["retrieved evidence, existing tools, human judgment"],
285
+ inspirationDomains: ["scientific instrumentation", "distributed systems", "ecology", "craft apprenticeship"],
286
+ avoid: ["generic repetition", "unsupported novelty claims"],
287
+ axes: { evidence_strategy: ["primary sources", "counter-evidence", "implementation evidence", "failure evidence"] },
288
+ };
289
+ const workspaceId = studio.createWorkspace(profile, concept(challenge), brief, seed);
290
+ studio.creativeExplosion(workspaceId, 6, 10);
291
+ const ranked = studio.rankIdeas(workspaceId).slice(0, 5);
292
+ const topBranches = ranked.map(r => {
293
+ const card = r.node.body as IdeaCard;
294
+ return { nodeId: r.node.nodeId, title: card.title, thesis: card.thesis, mechanism: card.mechanism, score: r.score };
295
+ });
296
+ const searchAngles = topBranches.map((_b, i) => {
297
+ const card = ranked[i].node.body as IdeaCard;
298
+ return `${card.morphology.source_domain} ${card.operatorFamily} ${challenge} ${card.mechanism}`.replace(/\s+/g, " ").slice(0, 220);
299
+ });
300
+ const nextMoves = studio.nextMoves(workspaceId);
301
+ const directive = [
302
+ "## V10 CREATIVE TREE OF LIFE — DISCOVERY DIRECTIVE",
303
+ "Generated branches are unverified proposals. Novelty means workspace-local dissimilarity only.",
304
+ "Use branches as independent search/reasoning angles; do not merge until evidence supports them.",
305
+ ...topBranches.map((b, i) => `${i + 1}. ${b.title}: ${b.mechanism}`),
306
+ "SEARCH ANGLES:",
307
+ ...searchAngles.map((q, i) => `S${i + 1}. ${q}`),
308
+ "NEXT HUMAN/LOGIC MOVES:",
309
+ ...nextMoves.map((m, i) => `N${i + 1}. ${m}`),
310
+ ].join("\n");
311
+ return { seed, mode, directive, searchAngles, nextMoves, tree: studio.exportTerminal(workspaceId), topBranches };
312
+ }
313
+
314
+ export function runInnovationGenomeV10Diagnostics(){ const checks:{id:string;passed:boolean;detail:string}[]=[]; const add=(id:string,passed:boolean,detail:string)=>checks.push({id,passed,detail}); const store=new V10CreativeStore(); const studio=new CreativeStudio(store); const profile=studio.bootstrapLocal("Creator"); const brief:CreativeBrief={challenge:"Create local-first research notebook",mode:"product",audience:["independent researcher"],desiredOutcomes:["better synthesis"],constraints:["no cloud dependency"],resources:["local files"],inspirationDomains:["gardening","version control"],avoid:[],axes:{interaction:["command palette","canvas"]}}; const ws=studio.createWorkspace(profile,"Notebook",brief,42); const explosion=studio.creativeExplosion(ws,4,8); add("schema-current",store.v10SchemaCurrent(),"v10 schema ok"); add("operators-20",OPERATORS.length===20,`operators=${OPERATORS.length}`); add("explosion",explosion.branchIds.length===8&&explosion.sproutIds.length===4,`${explosion.branchIds.length}/${explosion.sproutIds.length}`); const ranked=studio.rankIdeas(ws); add("ranked",ranked.length>=8,`ranked=${ranked.length}`); const confirmId=studio.confirm(ranked[0].node.nodeId,"overall","confirm",5,"strong"); add("confirm",confirmId.startsWith("confirmation-"),confirmId); const cross=studio.crossPollinate(ranked[0].node.nodeId,ranked[1].node.nodeId); add("cross-pollinate",cross.nodeKind==="synthesis","synthesis"); add("export-json",studio.exportJson(ws).includes("workspace-local dissimilarity only"),"semantics present"); add("terminal",studio.exportTerminal(ws).includes("seed:"),"tree text"); return {ok:checks.every(c=>c.passed),checks}; }
@@ -0,0 +1,2 @@
1
+ export * from "./innovation-genome-v10.orig";
2
+ export { buildUnifiedInnovationPlan } from "@/lib/debug/unified-innovation";