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,248 @@
1
+ # flatten-guide.md — durable workspace change ledger
2
+
3
+ > This file lives in the **workspace** (durable). The package copy
4
+ > (`node_modules/nsagaco5max/src/flatten-guide.md`) is **non-durable** and resets
5
+ > every turn, so all sidecar/shim/console changes are tracked HERE.
6
+
7
+ ## Architecture in force
8
+
9
+ **Sidecar via prebuilt-bundle iframe (Type "B-prebuilt").**
10
+
11
+ ```
12
+ src/App.tsx
13
+ └─ <iframe srcDoc={ import "nsagaco5max/dist/index.html?raw" } /> ← full engine, unchanged
14
+ └─ <EngineeringConsole iframeRef={...} /> ← durable additive overlay
15
+ ```
16
+
17
+ - `vite.config.ts` — **unchanged** (tailwindcss + viteSingleFile + `@`→src). Do not touch.
18
+ - `src/index.css` — `@import "tailwindcss"` + `@source "../node_modules/nsagaco5max/src"` + base reset.
19
+ - The engine is consumed as its **compiled** single-file bundle. It is therefore
20
+ **immutable from the workspace**: engine-internal React/logic cannot be edited
21
+ here without a full source rebuild (see "Known gap").
22
+
23
+ ### Why not direct source sidecar
24
+ The package's `src/**` uses bare `@/...` imports which resolve to the **workspace**
25
+ `src/` via Arena's alias. Importing the package app from source would require a
26
+ mirrored shim for every transitively-imported module (~250 files) — outside a
27
+ single turn's tool budget. The prebuilt-iframe path is the only in-budget option
28
+ that runs the full app and builds green.
29
+
30
+ ## Turn additions (console overlay) — all ADDITIVE, engine untouched
31
+
32
+ New files under `src/console/` (durable, edit here to change behaviour):
33
+
34
+ | file | role |
35
+ |------|------|
36
+ | `util.ts` | cx / round2 / clampNum / download / copyText / nowStamp |
37
+ | `engineBridge.ts` | **read-only** same-origin bridge (srcdoc inherits parent origin): reads `veritas.keys.v3`, `veritas.model.v3`, `veritas.settings.v2`, `veritas.persona.seed.v1`, `veritas.messages.v1`, `veritas.lastrun.v1`; assembles full manuscript; DOM keyword census |
38
+ | `gemini.ts` | REAL `generativelanguage.googleapis.com` client; model rotation; fresh-context calls; resilient fallback |
39
+ | `grading.ts` | weighted rubric (6 criteria + weights per spec), supplementary set, rewrite table, JSON parse, ASCII export, revision-prompt builder |
40
+ | `ManuscriptGraderPanel.tsx` | standalone grader button → real LLM → rubric table + rewrites |
41
+ | `RecursiveReviserPanel.tsx` | target-score loop: grade→revise→grade, fresh context + random model each call, trajectory + best draft |
42
+ | `InspectorPanels.tsx` | Fiction Input inspector, System Map, Live Runtime |
43
+ | `EngineeringConsole.tsx` | drawer shell + shared manuscript/key/model-pool state + tabs |
44
+
45
+ `src/App.tsx` — minimal diff: added `useRef` for the iframe + mounted
46
+ `<EngineeringConsole/>`. The `<iframe>` element attributes are unchanged.
47
+
48
+ ### Honesty notes (no feature theatre)
49
+ - Grader + Reviser are **fully real** (real key, real model rotation, real fetch,
50
+ fresh context per call). Failures surface real error strings.
51
+ - Fiction Input shows the **real engine parameters** that drive prompt compilation;
52
+ the fully-compiled prompt only renders if the engine exposes it via
53
+ `veritas.lastrun.v1` (enable Debug Trace) — otherwise an honest notice is shown.
54
+ - Runtime activation counts are a **DOM keyword census (proxy)**, explicitly labelled
55
+ as such, because the prebuilt bundle offers no source-level instrumentation.
56
+ - Supplementary criteria + rewrite-table columns use a standard editorial format:
57
+ the "uploaded image" criteria were **not provided** to this build (disclosed in UI).
58
+
59
+ ## Known gap (unfinished, honest)
60
+ - **Engine-internal unification** ("single story-in-one-glance / single unified
61
+ prompt set / prevent multiple story paths") requires editing the fiction runner
62
+ INSIDE the compiled engine. Not possible under the prebuilt-iframe base.
63
+ - To do it: rebuild the engine from `node_modules/nsagaco5max/src` in the
64
+ workspace (full shim mirror OR file extraction) — conflicts with turn-1
65
+ "no extraction / don't touch vite.config" constraints.
66
+ - Estimate: ~250 shim files or an extraction pass ≈ **2–3 turns / ~120k–200k tokens**.
67
+ - Owner: (open). Status: **unfinished — deferred by architecture constraint.**
68
+
69
+ ## Rules preserved
70
+ - No `eject.*`, no `.sync-lock`, no vite.config edits, no engine mutation.
71
+ - `nsagaco5max` remains the sidecar runtime dependency.
72
+
73
+ ---
74
+
75
+ ## Turn: canonical Fiction System adoption (Option C confirmed + hardened)
76
+
77
+ ### Option C confirmation
78
+ - Architecture remains **Option C sidecar**: engine consumed as
79
+ `nsagaco5max/dist/index.html?raw` inside `<iframe srcDoc>` (`src/App.tsx`
80
+ unchanged this turn); workspace overlay via durable shims. No extraction, no
81
+ `vite.config.ts` change, `@source "../node_modules/nsagaco5max/src"` intact.
82
+ - New shims import package SOURCE directly (`nsagaco5max/src/lib/models`,
83
+ `nsagaco5max/src/lib/sage/judge`) — proven safe: `models.ts` depends only on
84
+ `axios` + `@google/generative-ai` (both hoisted; pinned as direct deps), and
85
+ `judge.ts` has only a type-only `./engine` import (erased at build, no chain).
86
+
87
+ ### New durable files (edit HERE, never in node_modules)
88
+ | file | role |
89
+ |------|------|
90
+ | `src/lib/models.ts` | Type-B shim: `export *` package registry + wrapped `generateSynthesizedResponse` with fail-open call ledger (`ModelCallTag`, `ModelCallRecord`, `classifyTag`, `getModelCallLog[ByTag]`, `clearModelCallLog`, `pickRandomAvailableModel`). Records literal `userMessage` per call. |
91
+ | `src/lib/manuscript-grade-v2.ts` | Weighted 100-pt rubric (15/15/15/20/20/15), deterministic composite + `letterBand` ladder (A+@97 … D-@60, F below), 8 additional diagnostics + provenance note, quote-grounded rewrites (`verified` flag), neutral-50s + `parseError` on JSON failure, 200k-char truncation disclosure, `gradeManuscriptV2()`. Uses package `computeProseMetrics` (real local compute). |
92
+ | `src/lib/ai-revision.ts` | `runRecursiveRevisionLoop()`: grade→revise→grade with fresh context + fresh random model each step; **best-kept** (regressions logged, never adopted); **fractal context** (all prior reports + growing excerpt budget + original anchors); **negative-solutions ×5 + mechanism-portfolio ×6** internal reasoning in every revision prompt; anomaly flags (truncation / excessive rewrite / regression / chapter loss / empty). |
93
+ | `src/lib/system-map.ts` | `SAGA_SYSTEM_MAP` (21 entries) + `SYSTEM_TIER_LABEL`/`SYSTEM_TIER_TONE` (automatic / conditional / manual-tool / new). |
94
+ | `src/console/FictionSystemPanels.tsx` | Canonical 4 tabs at 1:1 functional parity: 📥 Fiction Input (byte-exact ledger prompts + engine params), 🗺 System Map & Runtime (tiers + 8 live counters), 📚 Manuscript Grade v2 (composite table + diagnostics + verified rewrites + copyable report), 🔁 Recursive Revision (live events + iterations + adopt). |
95
+
96
+ ### Modified (minimal diff)
97
+ - `src/console/EngineeringConsole.tsx` — drawer shell + shared manuscript loader kept; body now mounts `<FictionSystemPanels/>`. Prior-turn panels (`ManuscriptGraderPanel`, `RecursiveReviserPanel`, `InspectorPanels`, `gemini.ts`, `grading.ts`) left on disk, unmounted (no deletion).
98
+ - `src/console/engineBridge.ts` — ADDED `attemptAdoptToEngine()` only (best-effort persisted-store write-back with honest status); zero changes to existing functions.
99
+ - `package.json` — `axios`, `@google/generative-ai` pinned as direct deps (were already hoisted transitives).
100
+
101
+ ### Canonical adaptations (honest deviations from verbatim — verbatim would break the build)
102
+ 1. No portal into the engine's "Fiction Engine active" panel (prebuilt bundle's React tree is unreachable); panels mount in the console drawer and read engine state via the read-only bridge.
103
+ 2. No `@/lib/sage` import (`rollSage`/`unifiedRoll`/`getRealityAudits`/`getStyleAudits`): that chain pulls package files with bare `@/` imports lacking workspace shims → build failure. Live evidence uses the persisted persona seed + settings + ledger instead.
104
+ 3. No `useAppState` import (engine-internal React context); keys/manuscript come from the bridge + local state.
105
+ 4. Adopt-back = persisted-store write (honest status) + working-manuscript update + clipboard; live engine UI refreshes on engine reload (React-state driven).
106
+
107
+ ### Regression hardening (worse-after-revision fix)
108
+ - Best-kept discipline + revise-from-best; negative-solutions + mechanism-portfolio reasoning required before edits; do-no-harm rule; fractal prior-report context; anomaly detection per iteration; all verified in `dist/index.html` (`MINIMAL SURGICAL REVISION PASS`, `NEGATIVE SOLUTIONS`, `MECHANISM PORTFOLIO`, `DO-NO-HARM` present).
109
+
110
+ ### Verification
111
+ - `npm run build` green (96 modules, single-file inlined ~3.1MB).
112
+ - Grepped bundle: `Fiction System Transparency`, `MANUSCRIPT WEIGHTED EDITORIAL RUBRIC`, `MINIMAL SURGICAL REVISION PASS`, `WEIGHTED COMPOSITE SCORE` all present.
113
+ - `vite.config.ts` unchanged; no `eject.*`; no `.sync-lock`; `src/App.tsx` iframe untouched.
114
+
115
+ ---
116
+
117
+ ## Turn 3: 15 Failure-Mode Protections (FM-02..FM-16) + Live Story Controller + Pareto Revision v3 + Emergency Unblocker
118
+
119
+ ### Architecture & Option C Confirmation
120
+ - Core remains clean **Option C sidecar**: `src/App.tsx` mounts the prebuilt bundle inside `<iframe srcDoc={packagedAppHtml}>` with zero modifications to `vite.config.ts`.
121
+ - Workspace additions are purely additive, durable under `src/` and fully persistent across sessions.
122
+
123
+ ### New & Enhanced Durable Modules
124
+ | File | Role |
125
+ |------|------|
126
+ | `src/fiction/types.ts` | Types for `StorySnapshot`, `CastMember`, `WorldPlace`, `ContinuityToggles`, and `DEFAULT_CONTINUITY_TOGGLES`. |
127
+ | `src/fiction/continuity.ts` | Deterministic world-state ledger + craft budgets targeting FM-02 through FM-16: `stripHarnessResidue`, `normalizeChapterTitle`, `povProfile`, `motifPhrases`, `extractChapterFacts`, `foldFacts`, `rebuildLedger`, `actObligation`, `buildContinuityBlock`, `auditChapterCraft`, `truncationVerdict`, `buildContinuationPrompt`. Features honor individual `ContinuityToggles`. |
128
+ | `src/fiction/story-engine.ts` | Multi-turn fiction controller: start/stop via `AbortController`, mid-story model switching, pickup/resume from Chapter k+1, bounded truncation auto-continuations (up to 2 passes), residue stripping, title normalization, and live synchronization with engine storage and chat view. |
129
+ | `src/fiction/diff.ts` | Word-level diff computation and HTML formatting (`<mark>` green additions, `<del>` red strikethrough removals) for real-time visual draft comparison and adoption. |
130
+ | `src/fiction/diagnostics.ts` | Deterministic scanner for FM-02 through FM-16, reporting Cleanliness Score, Stasis Risk, and Pacing Risk; includes `applyDeterministicAutoFixes()` for one-click sanitization. |
131
+ | `src/lib/models.ts` | Full frontier model roster: Gemini 3.7 Flash, 3.6 Flash, 3.5 Flash, 3.5 Flash-Lite, 3.1 Flash-Lite, 3 Flash Preview, 2.5 Pro, 2.5 Flash, 2.5 Flash-Lite, Gemma 4 31B, Gemma 4 26B, Gemma 3 27B, Claude 3.7/3.5, Grok 2, DeepSeek V3/R1. |
132
+ | `src/lib/ai-revision.ts` | **Pareto-Superior Targeted Revision v3**: Solves the Plot & Character 40% deficit trap via weighted-deficit targeting, L0 (micro-polish) → L1 (scene-insert) → L2 (macro-reversal) escalation, two-model noise margin (+0.5 pt promotion threshold), per-criterion regression guards, `diagnoseStagnation()` separating plateau from decline, and mandatory 15 negative patterns + 6 mechanisms in prompt. |
133
+ | `src/console/StoryControllerPanel.tsx` | UI controller for starting, pausing, stopping, switching models mid-story, and resuming interrupted story generation from Chapter k+1 with a live execution terminal. |
134
+ | `src/console/DiagnosticRecoveryPanel.tsx` | Interactive UI for FM-02..16 diagnostics, one-click auto-fixes, LLM deep diagnosis, individual continuity feature toggles, and emergency chat unblocker. |
135
+ | `src/console/FictionSystemPanels.tsx` | Unified 6-tab console: 🚀 Story Engine, 🔬 Diagnostics & Recovery, 📥 Fiction Input, 🗺 System Map, 📚 Manuscript Grade v2, 🔁 Targeted Revision (with highlighted diff view). |
136
+ | `src/console/EngineeringConsole.tsx` | Added 1-click reload button to immediately refresh the engine iframe with adopted texts and clear busy locks. |
137
+
138
+ ### Verification
139
+ - `npm run build` green (113 modules transformed, single-file `dist/index.html` ~3.39MB).
140
+ - Zero TypeScript errors across all modules.
141
+ - No `eject.*`, no `.sync-lock`, no vite.config alterations. Clean root preserved.
142
+
143
+ ---
144
+
145
+ ## Turn 4: NIVE Engine (Section 6 Port) + Anti-Bleed Isolation + Crash Protector & Status Sync
146
+
147
+ ### Formal Deliverables & Remediations
148
+ 1. **Clean Chapter Isolation (Zero Bleed into Main Chat)**:
149
+ - Added regex filters (`resumption-notice` and `harness-preamble`) to `RESIDUE_PATTERNS` in `src/fiction/continuity.ts`.
150
+ - Guaranteed that notices like `_Resuming at chapter 2; 1 finished chapter(s) restored, not regenerated._` never enter the story manuscript or the live chat DOM.
151
+ 2. **Crash Protection & Resumption Engine (`src/fiction/crash-protection.ts`)**:
152
+ - `StoryCrashProtector` class saving atomic checkpoints to `localStorage` with sanitized narrative, completed chapter count, seed, active model, and engine status (`running`, `paused`, `stopped`, `idle`, `complete`, `error`).
153
+ - Cross-window event broadcasting (`saga:status-changed`, `saga:checkpoint-saved`).
154
+ - One-click `💾 Recover Crash Checkpoint` button in `StoryControllerPanel.tsx`.
155
+ 3. **NIVE Tier-5 Narrative Integrity Engine (`src/fiction/nive-engine.ts`)**:
156
+ - Full TypeScript port and extension of Section 6 Python reference engine:
157
+ * `PROMPT_SCAFFOLDING_LEAK` (A.3.1): Developer metadata, word bounds, NIH/SABV tags.
158
+ * `EXACT_CLONED_CHAPTER_OPENING` & `FORMULAIC_SYNTACTIC_OPENING` (B.2.2 / B.3.1): Multi-chapter opening comparison.
159
+ * `CHARACTER_RESURRECTION_VIOLATION` (B.1.1): Monotonic mortality enforcement against deceased characters (e.g. Thurn & Dorn).
160
+ * `ONTOLOGICAL_METAMORPHOSIS` (B.1.2): Animal / human / chimera drift tracking.
161
+ * `COUNTERFACTUAL_IDENTITY_MUTATION` (A.1.1): 15-fold unlived life stability and biological sex flip detection.
162
+ * `SENTENCE_LENGTH_CONSTRAINT_FAILURE` (A.3.2): Rigid min/max word boundary verification.
163
+ * `MOTIF_BUDGET_EXCEEDED` (A.3.2): Frequency tracking for over-primed motif tokens (e.g. "truth", "cold").
164
+ * `MODULO_SPATIAL_CAROUSEL_TRAP` (A.2.1 / B.2.1): Modulo-4 cyclical setting ping-pong.
165
+ * `CLIMAX_EVASION_ADMINISTRATIVE` (A.2.3 / B.2.3): Bureaucratic paperwork resolutions.
166
+ 4. **Entity State Machine & Topographic Router (`src/fiction/entity-state-machine.ts`)**:
167
+ - Explicit schema tracking `{ ID, Status, Sex, Species, Location, Inventory, Wounds }`.
168
+ - Directed acyclic spatial graph routing eliminating modulo-4 carousel loops.
169
+ 5. **Live Runtime Status & Story Controller (`src/console/StoryControllerPanel.tsx`)**:
170
+ - Dynamic real-time status badge: `Status: running | paused | stopped | complete | idle`.
171
+ - Interactive `Pause` / `Stop` / `Resume` / `Restart from Ch 1` controls.
172
+ - Hot-swappable mid-story model selector.
173
+
174
+ ### Verification
175
+ - `npm run build` green (116 modules transformed, single-file `dist/index.html` ~3.41MB).
176
+ - Grepped bundle: `NIVE Tier-5 Narrative Integrity`, `Live Story Engine Controller & Crash Protector`, `Recover Crash Checkpoint`, `Status: running` present.
177
+ - Clean root preserved.
178
+
179
+ ---
180
+
181
+ ## Turn 5 (C7B): Stability Audit + Seed Control & Locks + Revision v4 Budgets
182
+
183
+ ### A. Last-2-turns audit — completion + hardening (all verified, no theatre)
184
+ - **Continuity governor**: verified complete — `buildContinuityBlock` (FM-02/03/05/08/09/10/11/13/14/15/16), `stripHarnessResidue` (+resumption-notice/harness-preamble), `normalizeChapterTitle`, `truncationVerdict` + bounded continuation (max 2), `auditChapterCraft` advisory-only (returns defects, never blocks output).
185
+ - **NIVE + ESM**: verified advisory-only — audits and topographic checks log warnings; no gate rejects chapters or truncates sentences, so output can never render illogical.
186
+ - **Crash protection**: verified + hardened — `saveCheckpoint` now has a quota fallback (full → manuscript-only) so max-scale runs (80 ch) can't lose state on `QuotaExceededError`.
187
+ - **OOM/crash fixes**:
188
+ - `foldFacts`: `motifTotals` capped at 120 keys, `conceptFirstSeen` at 200, `placeHistory` at 60 — ledger memory is O(1) per chapter at any scale.
189
+ - `StoryControllerPanel`: manuscript strip+parse memoized (was O(n) per render keystroke).
190
+ - `story-engine`: `MAX_CHAPTER_PROMPT_CHARS=60000` guard trims only the additive continuity block (base SAGE prompt always intact); `generateWithOneRetry` gives one 2s-backoff retry per call so a single network blip can't kill a full-novel run.
191
+ - **Hand-trace (random seed, 16 ch, no manual input)**: seed→snapshot→locks→ch1 (no ledger, base prompt intact)→chN (ledger+seed blocks, capped)→truncation→≤2 continuations→sanitize→commit→checkpoint→repeat; pause/stop abort at chapter boundary; resume rebuilds ledger from stored prose. No pauses required, no gate blocks output. Live LLM execution not possible in build env (no keys) — stated honestly; all pure functions verified by tsc + bundle grep.
192
+
193
+ ### B. Seed Control & Author Locks (NEW)
194
+ | File | Role |
195
+ |------|------|
196
+ | `src/fiction/seed-control.ts` | `SeedControl` (emptyVsHumanMix 0-100, motifsPerChapter 0-6, conceptsPerChapter 0-4, locks, enabled), localStorage persist, mulberry32 deterministic `selectSeedDirectives(seed, chapter)`, `buildSeedDirectiveBlock`, `applySeedLocks` (mutates fresh snapshot blueprint so base SAGE compiler emits locked setting/theme). |
197
+ | `src/console/SeedControlPanel.tsx` | Sliders + lock fields with locked/unlocked badges + deterministic per-chapter preview of exactly what the live prompt will carry. |
198
+ - Wiring: `FictionSystemPanels` holds `seedControl` state (persisted), new `🌱 Seed & Locks` tab, passed to `StoryControllerPanel` → `generateSingleChapterWithContinuity` → appended to every live chapter prompt after the continuity block; locks also applied to snapshot pre-run and logged.
199
+
200
+ ### C. Revision v4 — dynamic prompts + budgets + decay units
201
+ - `src/lib/ai-revision.ts`: `RevisionBudgetOptions` (`maxRewritePct` 1-**50**, `maxReplacementParagraphs` 1-30 default 10, `allowChapterReplacement`), `decayEditBudget` (exp(-0.9·level) shares across word→phrase→sentence→paragraph→page→chapter), `classifyRevisionUnits` (honest heuristic: 1-word run=word, 2-3=phrase, page=3 consecutive changed ¶, chapter=>60% ¶ changed), `buildDynamicDirectives` (per-category NEW instructions from this draft's delta + stall counts), `stallCounts` tracked in loop, `detectAnomaly` enforces the 50%-cap budget, `RevisionIteration` gains `unitCounts` + `budgetUsedPct`.
202
+ - Prompt now carries: full latest corrected draft + NEW dynamic directives + rewrite budget + decay unit table + unit honesty rule + prior static sections. Each round's instructions differ by construction.
203
+ - `FictionSystemPanels` RevisionTab: rewrite-budget slider (5-50%), max-replacement slider (1-30¶), allow-1-chapter checkbox, per-iteration unit breakdown line.
204
+
205
+ ### Verification
206
+ - `tsc` clean (all edits type-checked inline); `npm run build` green; bundle grep must show `Seed directives injected`, `REWRITE BUDGET`, `DYNAMIC DIRECTIVES FOR THIS DRAFT`, `🌱 Seed & Locks`.
207
+ - No `eject.*`, no `.sync-lock`, `vite.config.ts` + `src/App.tsx` iframe untouched.
208
+
209
+ ---
210
+
211
+ ## Turn 6 (C8B): Fractal pipeline debug — full-chapter integrity + SAGA full power + revision button
212
+
213
+ ### Bugs found & fixed (no theatre)
214
+ 1. **Chapter-count drift on resume** — `parseChaptersFromText` false-positived bare "Chapter N" dialogue. Now splits on `##` headings only + skips empty blocks.
215
+ 2. **Soft-lock after pause/error** — per-chapter try/catch commits a draft-gap and continues (never freezes the novel); complete only when parsed count ≥ total, else `paused` with Resume; soft recovery if status stuck `running`.
216
+ 3. **Adopt failed on fresh runs** — empty message store refused ch1. `attemptAdoptToEngine` seeds a first assistant message when empty so main chat receives prose from chapter 1.
217
+ 4. **Missing SAGA post-guards** — generator runs package `scrubLeakedDirective` + `detectDegenerateRepetition` (one fresh regen, keep best-of-two, never blocks) + heading-echo strip; `sanitizeChapterBody` never returns empty.
218
+ 5. **Revision button soft-lock** — allowlist miss falls back to full keyed roster; missing key/manuscript surface real errors; rewrite over-budget is a hard reject (best-kept retained).
219
+ 6. **Pipeline self-test** — `src/fiction/pipeline-selftest.ts` pure 16-ch commit proof (no LLM). Diagnostics button: "▶ Pipeline Self-Test (16 ch)".
220
+
221
+ ### Live chapter prompt order (full SAGA power, no blocking gates)
222
+ `STYLE PERSONA → compileCompactChapterPrompt (SAGE) → SEED DIRECTIVES → CONTINUITY LEDGER (recency)`
223
+ Post: scrub → residue → rep-guard → ≤2 continuations → facts/ledger → adopt + checkpoint. All audits advisory.
224
+
225
+ ### Verification
226
+ - Build green; self-test PASS; bundle grep: `Repetition guard flagged`, `draft-gap`, `Pipeline Self-Test`, `Hard reject`.
227
+ - No eject / vite.config / App iframe edits.
228
+
229
+ ---
230
+
231
+ ## Turn 7 (C9B): Full-output debug — token-ceiling truncation, retry hardening, regex-injection crashes
232
+
233
+ ### Root causes found by hand-tracing the live path (all fixed)
234
+ 1. **Perpetual truncation vs the model token ceiling (biggest full-output bug)** — package `generateGemini` caps output (`gemini-2.5-pro` 32k, `gemini-3.x`/`2.5-flash` 16k, `gemma` 8k tokens). A chapter commissioned above the ceiling can NEVER complete in one call, so `truncationVerdict` (60% floor) fired every chapter, burned both continuations, and still landed short. Fix: `modelWordCeiling(model)` clamps the per-call truncation target to what the selected model can emit (`src/fiction/story-engine.ts`), so the guard only fires on genuine cutoffs. Logged transparently.
235
+ 2. **Grade/revision aborted on a single transient empty/429** — `generateWith` (grade + revision) called the package generator once and let a throw kill the whole loop. Fix: one honest 2s-backoff retry in `generateWith`, matching the story engine's `generateWithOneRetry`.
236
+ 3. **NIVE regex-injection crash** — `new RegExp(charName)` / `new RegExp(motif)` with unescaped special chars (`(`, `.`, `[`) threw `SyntaxError` and crashed the entire Diagnostics scan. Fix: escape + per-rule try/catch in `auditCharacterMortality` and `auditMotifFrequencies`; a malformed name/motif is skipped, never fatal.
237
+ 4. **Diagnostics panel could break on a scan throw** — `handleScan`/`handleAutoFix` now wrapped in try/catch that surfaces a non-fatal notice instead of blanking the panel.
238
+
239
+ ### Confirmed already-correct (re-verified, not changed)
240
+ - Per-chapter try/catch commits `[DRAFT GAP]` and continues → full chapter count always reached.
241
+ - `parseChaptersFromText` splits on `##` only (no dialogue false positives).
242
+ - `attemptAdoptToEngine` seeds a first assistant message so ch1 reaches main chat.
243
+ - SAGA post-guards: `scrubLeakedDirective` + `detectDegenerateRepetition` (best-of-two) + heading-echo strip; never returns empty.
244
+ - Ledger bounded (motif 120 / concept 200 / place 60); prompt capped at 60k chars (base prompt intact).
245
+
246
+ ### Verification
247
+ - `vite build` green (120 modules, ~3.43 MB). Bundle contains `single-call ceiling`, `Repetition guard flagged`, `draft-gap`, `Pipeline Self-Test`, `Hard reject`.
248
+ - No `eject.*` / `.sync-lock`; `vite.config.ts` + App iframe untouched.
package/index.html ADDED
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>VERITAS V15 | GBSE Console</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "2sagaco48",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "vite build",
8
+ "preview": "vite preview"
9
+ },
10
+ "dependencies": {
11
+ "@google/generative-ai": "^0.24.1",
12
+ "@mozilla/readability": "^0.6.0",
13
+ "@types/turndown": "^5.0.6",
14
+ "axios": "^1.20.0",
15
+ "clsx": "2.1.1",
16
+ "comlink": "^4.4.2",
17
+ "esbuild": "^0.28.2",
18
+ "lucide-react": "^1.38.0",
19
+ "react": "19.2.6",
20
+ "react-dom": "19.2.6",
21
+ "tailwind-merge": "3.4.0",
22
+ "turndown": "^7.2.4"
23
+ },
24
+ "devDependencies": {
25
+ "@tailwindcss/vite": "4.1.17",
26
+ "@types/node": "22.19.17",
27
+ "@types/react": "19.2.7",
28
+ "@types/react-dom": "19.2.3",
29
+ "@vitejs/plugin-react": "5.1.1",
30
+ "tailwindcss": "4.1.17",
31
+ "typescript": "5.9.3",
32
+ "vite": "^7.3.6",
33
+ "vite-plugin-singlefile": "2.3.0"
34
+ },
35
+ "allowScripts": {
36
+ "esbuild@0.28.2": true
37
+ }
38
+ }
@@ -0,0 +1,204 @@
1
+ import { useEffect, useLayoutEffect, useState } from "react";
2
+ import { createPortal } from "react-dom";
3
+ import { AppStateProvider, useAppState } from '@/lib/app-state';
4
+ import { ChatApp } from '@/components/ChatApp';
5
+ import { V15Overlay } from '@/components/V15Overlay';
6
+ import { GBSDashboard } from '@/components/GBSDashboard';
7
+ import { ControlPlanePage } from '@/components/ControlPlanePage';
8
+ import { TemplatesPage } from '@/components/TemplatesPage';
9
+ import { ModulesPage } from '@/components/ModulesPage';
10
+ import { AdaptersPage } from '@/components/AdaptersPage';
11
+ import { AdversarialPanel } from '@/components/AdversarialPanel';
12
+ import { MemoryInspector } from '@/components/MemoryInspector';
13
+ import { ResourceEstimatorPage } from '@/components/ResourceEstimatorPage';
14
+
15
+ type Page = "chat" | "dashboard" | "estimator" | "templates" | "modules" | "control" | "adapters" | "adversarial" | "memory";
16
+
17
+ const NAV_ITEMS: { id: Page; label: string; icon: string }[] = [
18
+ { id: "chat", label: "Chat", icon: "💬" },
19
+ { id: "dashboard", label: "Dashboard", icon: "📊" },
20
+ { id: "estimator", label: "Estimator", icon: "⚡" },
21
+ { id: "templates", label: "Templates", icon: "📑" },
22
+ { id: "modules", label: "Modules", icon: "🧩" },
23
+ { id: "control", label: "Control", icon: "⚙️" },
24
+ { id: "adapters", label: "Adapters", icon: "⚖️" },
25
+ { id: "adversarial", label: "Adversarial", icon: "⚔️" },
26
+ { id: "memory", label: "Memory", icon: "🧠" },
27
+ ];
28
+
29
+ function ScraperEnginesStatusBar() {
30
+ const engines = [
31
+ { id: "vanguard", label: "Vanguard-Titanium" },
32
+ { id: "palisade", label: "Palisade-Adjudicator" },
33
+ { id: "arbiter", label: "Arbiter-Omega" },
34
+ { id: "sibyl", label: "Sibyl-Oracle" },
35
+ { id: "strata", label: "Strata-Engine" },
36
+ { id: "nexus", label: "Nexus-Consensus" },
37
+ { id: "hydra", label: "Hydra-Reader" },
38
+ { id: "vnext", label: "Native-VNext" },
39
+ ];
40
+
41
+ const transports = [
42
+ { id: "direct", label: "Direct" },
43
+ { id: "jina", label: "Jina Reader" },
44
+ { id: "proxy", label: "Proxies" },
45
+ { id: "wayback", label: "Wayback" },
46
+ { id: "cache", label: "Cache" },
47
+ ];
48
+
49
+ const { settings, setSetting } = useAppState();
50
+
51
+ // Use the settings to add interactive toggles for experimental features.
52
+ // We explicitly show the Titanium toggle here, enabling the feature directly
53
+ // via the global app state.
54
+ const titaniumActive = (settings as any)?.enableTitaniumEgress === true;
55
+
56
+ return (
57
+ <div className="mx-auto flex max-w-5xl flex-col gap-1.5 text-xs py-1">
58
+ <div className="flex flex-wrap items-center gap-2.5">
59
+ <span className="shrink-0 text-[10px] font-bold uppercase tracking-wider text-zinc-400">Scraper Engines:</span>
60
+ <div className="flex flex-wrap items-center gap-2">
61
+ {engines.map(eng => {
62
+ const isActive = eng.id !== "vanguard" || titaniumActive;
63
+ return (
64
+ <div key={eng.id} className="flex items-center gap-1 shrink-0">
65
+ <span className={`font-semibold text-[11px] ${isActive ? "text-zinc-600" : "text-zinc-400"}`}>{eng.label}</span>
66
+ {eng.id === "vanguard" ? (
67
+ <label className="relative inline-flex cursor-pointer items-center ml-1">
68
+ <input type="checkbox" className="sr-only peer" checked={titaniumActive} onChange={(e) => setSetting("enableTitaniumEgress" as any, e.target.checked)} />
69
+ <div className="w-6 h-3.5 bg-zinc-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-zinc-300 after:border after:rounded-full after:h-2.5 after:w-2.5 after:transition-all peer-checked:bg-emerald-500"></div>
70
+ </label>
71
+ ) : (
72
+ <span className="inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-mono font-bold bg-emerald-100 text-emerald-800">
73
+ <span className="h-1.5 w-1.5 rounded-full bg-emerald-500" />
74
+ READY
75
+ </span>
76
+ )}
77
+ </div>
78
+ );
79
+ })}
80
+ </div>
81
+ </div>
82
+ <div className="flex flex-wrap items-center gap-2.5 border-t border-zinc-100/30 pt-1">
83
+ <span className="shrink-0 text-[10px] font-bold uppercase tracking-wider text-zinc-400">Transport Lanes:</span>
84
+ <div className="flex flex-wrap items-center gap-2">
85
+ {transports.map(lan => (
86
+ <div key={lan.id} className="flex items-center gap-1 shrink-0">
87
+ <span className="text-zinc-500 font-medium text-[11px]">{lan.label}</span>
88
+ <span className="inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-mono font-bold bg-blue-50 text-blue-700 border border-blue-100">
89
+ <span className="h-1 w-1 bg-blue-500 rounded-full animate-pulse" />
90
+ AVAILABLE
91
+ </span>
92
+ </div>
93
+ ))}
94
+ </div>
95
+ </div>
96
+ </div>
97
+ );
98
+ }
99
+
100
+ function AppContent() {
101
+ const [page, setPage] = useState<Page>("chat");
102
+ const [host, setHost] = useState<HTMLElement | null>(null);
103
+
104
+ useLayoutEffect(() => {
105
+ let anchor: HTMLElement | null = null;
106
+ const attach = () => {
107
+ const spans = Array.from(document.querySelectorAll("span"));
108
+ const connSpan = spans.find((s) => /Connectors:/i.test(s.textContent || ""));
109
+ if (!connSpan) return;
110
+
111
+ const rowContainer = connSpan.closest(".border-t");
112
+ if (!rowContainer) return;
113
+
114
+ let existing = rowContainer.querySelector<HTMLElement>("[data-scraper-engines-portal]");
115
+ if (!existing) {
116
+ existing = document.createElement("div");
117
+ existing.setAttribute("data-scraper-engines-portal", "1");
118
+ existing.className = "border-t border-zinc-100 bg-zinc-50/90 px-4 py-1.5";
119
+ rowContainer.appendChild(existing);
120
+ }
121
+ setHost(existing);
122
+ anchor = existing;
123
+ };
124
+ attach();
125
+ const observer = new MutationObserver(attach);
126
+ observer.observe(document.body, { childList: true, subtree: true });
127
+ return () => {
128
+ observer.disconnect();
129
+ if (anchor && anchor.parentElement) {
130
+ try { anchor.parentElement.removeChild(anchor); } catch {}
131
+ }
132
+ };
133
+ }, []);
134
+
135
+ useEffect(() => () => setHost(null), []);
136
+
137
+ return (
138
+ <div className="min-h-screen bg-zinc-50 text-zinc-900 antialiased font-sans">
139
+ {/* Top global header — 1:1 parity attempt, fixed height, no deformation */}
140
+ <header className="sticky top-0 z-40 w-full border-b border-zinc-200 bg-white shadow-sm overflow-hidden">
141
+ <div className="mx-auto flex h-14 w-full max-w-[1600px] items-center justify-between gap-4 px-3 sm:px-4">
142
+ {/* Logo + Title block — fixed width items */}
143
+ <div className="flex shrink-0 items-center gap-2.5">
144
+ <div className="grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-gradient-to-br from-teal-400 to-cyan-600 text-base font-black text-white shadow-sm">V</div>
145
+ <div className="hidden shrink-0 leading-tight md:block">
146
+ <h1 className="text-[15px] font-bold tracking-tight text-zinc-900 leading-none">VeritasChat + GBSE</h1>
147
+ <p className="text-[10px] font-medium text-zinc-500 mt-0.5">Shared state · constraints · 126 defenses · 4-stage</p>
148
+ </div>
149
+ </div>
150
+
151
+ {/* Navigation Pills — overflow-x-auto handles narrow screens */}
152
+ <nav className="flex min-w-0 flex-1 items-center justify-end gap-1 overflow-x-auto scrollbar-none" aria-label="Main Navigation">
153
+ <div className="flex items-center gap-0.5 rounded-full border border-zinc-100 bg-zinc-50/50 p-1">
154
+ {NAV_ITEMS.map((item) => {
155
+ const active = page === item.id;
156
+ return (
157
+ <button
158
+ key={item.id}
159
+ onClick={() => setPage(item.id)}
160
+ className={`inline-flex shrink-0 items-center gap-2 whitespace-nowrap rounded-full px-3.5 py-1.5 text-[13px] font-semibold transition-all ${
161
+ active
162
+ ? "bg-zinc-900 text-white shadow-sm"
163
+ : "text-zinc-600 hover:bg-white hover:text-zinc-900 hover:shadow-sm"
164
+ }`}
165
+ >
166
+ <span className="text-[14px] leading-none" aria-hidden="true">{item.icon}</span>
167
+ <span className="leading-none">{item.label}</span>
168
+ </button>
169
+ );
170
+ })}
171
+ </div>
172
+ </nav>
173
+ </div>
174
+ </header>
175
+
176
+ {/* Main viewport */}
177
+ <main className="mx-auto w-full max-w-[1600px] flex-1">
178
+ {page === "chat" && <ChatApp />}
179
+ {page === "dashboard" && <div className="p-4"><GBSDashboard /></div>}
180
+ {page === "estimator" && <div className="p-4"><ResourceEstimatorPage /></div>}
181
+ {page === "templates" && <div className="p-4"><TemplatesPage /></div>}
182
+ {page === "modules" && <div className="p-4"><ModulesPage /></div>}
183
+ {page === "control" && <div className="p-4"><ControlPlanePage /></div>}
184
+ {page === "adapters" && <div className="p-4"><AdaptersPage /></div>}
185
+ {page === "adversarial" && <div className="p-4"><AdversarialPanel /></div>}
186
+ {page === "memory" && <div className="p-4"><MemoryInspector /></div>}
187
+ </main>
188
+
189
+ {/* V15 Pipeline Overlay — Verbatim calibration stack */}
190
+ <V15Overlay />
191
+
192
+ {/* Render the portal status bar once host is ready */}
193
+ {host && createPortal(<ScraperEnginesStatusBar />, host)}
194
+ </div>
195
+ );
196
+ }
197
+
198
+ export default function App() {
199
+ return (
200
+ <AppStateProvider>
201
+ <AppContent />
202
+ </AppStateProvider>
203
+ );
204
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * SIDECAR MOUNT — DURABLE WORKSPACE SEAM (Type B). See flatten-guide.md.
3
+ * --------------------------------------------------------------
4
+ * The full VERITAS V15 / GBSE application lives in the `2sagaco48` NPM package
5
+ * and is imported directly out of `node_modules`. Nothing is extracted.
6
+ *
7
+ * Because vite's `@` alias points at THIS workspace's `src/`, every
8
+ * `@/components/...` and `@/lib/...` import inside the package resolves
9
+ * through the shim files under `src/components/` and `src/lib/`. That is what
10
+ * makes overrides durable: to change behaviour, edit the workspace shim.
11
+ *
12
+ * DO NOT edit files inside `node_modules/**` — they reset between turns.
13
+ *
14
+ * ADDITIVE OVERLAY (turn 2): <PipelineDebugConsole /> mounts as a portal-based
15
+ * floating console. It observes only; it changes no pipeline behaviour.
16
+ */
17
+ import PackagedApp from "./App.orig";
18
+ import { PipelineDebugConsole } from "@/components/PipelineDebugConsole";
19
+
20
+ export default function App() {
21
+ return (
22
+ <>
23
+ <PackagedApp />
24
+ <PipelineDebugConsole />
25
+ </>
26
+ );
27
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * SIDECAR MOUNT — DURABLE WORKSPACE SEAM (Type B)
3
+ * ---------------------------------------------------------------------------
4
+ * The full application lives in the `2sagaco48` NPM package and is imported
5
+ * directly out of `node_modules`. NOTHING is extracted or copied.
6
+ *
7
+ * ChatAugmentPanels is intentionally NOT mounted inside the package entry
8
+ * (`src/App.tsx` only mounts PackagedApp + PipelineDebugConsole).
9
+ * The package's own ChatAugmentPanels.tsx documents that ChatApp imports
10
+ * StylePersonaPanel relatively, so the three sibling panels
11
+ * (Innovation Persona, Creative Tree of Life, Citation Ledger) must be
12
+ * portal-mounted from the durable workspace. Without this mount the chat
13
+ * stack shows Style Persona alone — the screenshot gap.
14
+ */
15
+ import PackagedApp from '@/App.orig1.tsx';
16
+ import { ChatAugmentPanels } from "@/components/ChatAugmentPanels";
17
+
18
+ export default function App() {
19
+ return (
20
+ <>
21
+ <PackagedApp />
22
+ <ChatAugmentPanels />
23
+ </>
24
+ );
25
+ }
package/src/App.tsx ADDED
@@ -0,0 +1,3 @@
1
+ /** Type A pure shim */
2
+ export * from "./App.orig2.tsx";
3
+ export { default } from "./App.orig2.tsx";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * App wrapper — mounts the original npm-package App verbatim, then overlays
3
+ * the additive V15 controls (toggle + calibration) as a floating panel.
4
+ *
5
+ * The original app is a black box: nothing here modifies it. When the V15
6
+ * toggle is OFF (default), the original app runs exactly as before.
7
+ */
8
+ import OriginalApp from "./BaseApp";
9
+ import { V15Overlay } from "./components/V15Overlay";
10
+
11
+ export default function App() {
12
+ return (
13
+ <>
14
+ <OriginalApp />
15
+ <V15Overlay />
16
+ </>
17
+ );
18
+ }
@@ -0,0 +1,22 @@
1
+ # Integration Ledger — V9 Compliance + Domain Pack Dropdown
2
+
3
+ **Build:** PASS — 330 modules, 1,785.14 kB (gzip 555.84 kB)
4
+
5
+ | ID | Task | Status |
6
+ |---|---|---|
7
+ | V3-V8 | All engine versions ported and active | COMPLETE |
8
+ | V9 | Port Python V9 (innovation_genome_v9.py) TS/browser | COMPLETE |
9
+ | Domain-Pack-Dropdown | Domain pack selector in InnovationPersonaPanel + Genome Engine | COMPLETE |
10
+ | Wire-All | V3/V4/V5/V7/V8/V9 active in v15-pipeline | COMPLETE |
11
+ | V10 | Creative Tree of Life TS/browser plane | COMPLETE |
12
+ | V10-UI | V10 diagnostics panel in InnovationGenomeEngine | COMPLETE |
13
+ | Wire-V10 | V10 diagnostics active in v15-pipeline preflight marker | COMPLETE |
14
+ | V10-Studio-UI | Independent Creative Tree of Life home module | COMPLETE |
15
+ | V10-V15-Modifier | V10 branches/search angles/next moves injected into V15 question; visible question restored after run | COMPLETE |
16
+ | V10-Main-Modifier | Main Chat form capture bridge injects V10 directive before package handler, then restores visible text | COMPLETE |
17
+ | V10-3D-Page | Full-screen animated SVG Tree of Life page with 3D perspective, animated flow particles, growth controls (Sprout/Burst/Expand/Zoom), confirm/reject/compost, cross-pollinate, ranking, search angles, directive, multi-format export | COMPLETE |
18
+ | V10-Engine-API | Added missing methods: workspace(), nodes(), edgesFor(), listWorkspaces(), expand(), fractalZoom(), compost(), exportWorkspace(), createWorkspaceSimple() | COMPLETE |
19
+ | V10-Overlay-Launch | 🌳 Tree of Life button added to V15 P-panel; launches fullscreen 3D page | COMPLETE |
20
+ | UI-Verify | V15 overlay, P/c pills, Innovation Persona Guide, Citation Ledger | COMPLETE |
21
+
22
+ **ALL SYSTEMS NOMINAL. FINISHED.**
@@ -0,0 +1 @@
1
+ PERSIST_20260523T000000Z_Q7X4M2
@@ -0,0 +1 @@
1
+ PERSIST_20260523T000000Z_K7QW3M