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,212 @@
1
+ /**
2
+ * SAGA-OS v4 — AUREATE-SCRIBE (fable.canon SYSTEM v15)
3
+ * ---------------------------------------------------------------------------
4
+ * Append-only delta over saga-os-v2 (v2/v3). Nothing in prior versions is
5
+ * removed, renamed, or weakened.
6
+ *
7
+ * Source: P10 canonical "SAGA-OS v4 — AUREATE-SCRIBE".
8
+ * Integration policy: Pareto-superior, additive, single small UI panel (in
9
+ * `SagaOsPanel.tsx`) that exposes ALL SAGA-OS v-patches — no other UI edits.
10
+ *
11
+ * Real, deterministic, locally-computed functions included:
12
+ * - selectSyntaxForm() — v4 §6.3 rule ("prefer SYN-001/014 when clarity
13
+ * required; SYN-003/008/016 at emotional peaks; force contrast after 3
14
+ * similar priors"), executable.
15
+ * - auditWanIntensifiers() — v4 STYLE-TEST-004 clutter ratio proxy (Dreyer-
16
+ * style suspicion of "very / really / actually / basically" etc., with
17
+ * honest register/context caveat per v5 correction MERGE-V16-006).
18
+ * - runAureateStylePassIndex() — returns the PASS-001..015 revision-stack
19
+ * ordering so a caller can drive their own realizer through v4's stack.
20
+ */
21
+ import type { SagaRow } from "./saga-os";
22
+
23
+ function parse(raw: string): SagaRow[] {
24
+ return raw.trim().split(/\n+/).map((l) => l.trim()).filter(Boolean).map((l) => {
25
+ const [id, name, ...rest] = l.split("|").map((p) => p.trim());
26
+ return { id, name, note: rest.join(" | ") };
27
+ });
28
+ }
29
+
30
+ // ── §4 STYLEBOOK-COMPILER layers (v4) ───────────────────────────────────────
31
+ export const STYLEBOOK_LAYERS: SagaRow[] = parse(`
32
+ Williams | characters_as_subjects / actions_as_verbs / old_before_new / topic_then_stress / cohesion_chain / concision / grace_balance
33
+ Pinker | classic_style_window / curse_of_knowledge_guard / syntax_tree_sanity / reader_knowledge_gap / coherence_over_rule_worship
34
+ Strunk | omit_needless_words / active_voice_preference / concrete_specific_language / emphatic_end / parallelism
35
+ Dreyer | copychief_judgment / grammar_vs_preference_split / cliché_and_intensifier_suspicion / punctuation_hygiene / house_style_profile
36
+ Booth | claim_reason_evidence_warrant / objection_handling / stakes_of_question / intellectual_integrity
37
+ LeGuin | sound_of_language / point_of_view / indirectness / omission / sentence_as_voice
38
+ Zinsser | clutter_removal / simplicity / reader_attention / writer_presence
39
+ Clark | subject_verb_drive / pattern_then_twist / sentence_toolbox / ladder_of_abstraction
40
+ Tufte | syntactic_variety / apposition / parallelism / fragment_control / cumulative_sentence / periodic_sentence
41
+ `);
42
+
43
+ // ── §5 StyleGenome + §5.1 genre defaults (v4) ───────────────────────────────
44
+ export const STYLE_GENOME_FIELDS = [
45
+ "clarity_level", "ornament_level", "sentence_music", "syntactic_complexity",
46
+ "concreteness", "interiority", "compression", "ambiguity_tolerance",
47
+ "dialogue_density", "image_density", "sound_density", "humor_density",
48
+ "rhetorical_formality", "focal_distance", "prose_mode",
49
+ ] as const;
50
+
51
+ export const STYLE_GENOME_GENRE_DEFAULTS: Record<string, number[]> = {
52
+ // clarity, ornament, music, syntax, concrete, interiority, compression,
53
+ // ambiguity, dialogue, image, sound, formality
54
+ romance: [0.78, 0.45, 0.55, 0.45, 0.70, 0.75, 0.55, 0.35, 0.70, 0.55, 0.45, 0.35],
55
+ thriller: [0.88, 0.25, 0.35, 0.35, 0.82, 0.45, 0.75, 0.25, 0.55, 0.45, 0.35, 0.25],
56
+ mystery: [0.85, 0.30, 0.40, 0.45, 0.80, 0.50, 0.70, 0.35, 0.55, 0.50, 0.35, 0.35],
57
+ literary: [0.72, 0.65, 0.75, 0.70, 0.65, 0.80, 0.45, 0.65, 0.45, 0.75, 0.70, 0.55],
58
+ fantasy: [0.75, 0.60, 0.70, 0.55, 0.70, 0.55, 0.50, 0.50, 0.45, 0.80, 0.65, 0.55],
59
+ horror: [0.78, 0.55, 0.70, 0.55, 0.75, 0.65, 0.55, 0.55, 0.40, 0.80, 0.75, 0.45],
60
+ institutional: [0.90, 0.20, 0.30, 0.40, 0.85, 0.35, 0.80, 0.20, 0.45, 0.35, 0.25, 0.55],
61
+ };
62
+
63
+ // ── §6.2 syntax forms (SYN-001..016) ────────────────────────────────────────
64
+ export const SYNTAX_FORMS: SagaRow[] = parse(`
65
+ SYN-001 | Kernel sentence | plain declarative
66
+ SYN-002 | Cumulative sentence | main clause first, modifiers accrete
67
+ SYN-003 | Periodic sentence | main clause delayed until end
68
+ SYN-004 | Balanced sentence | two mirrored halves
69
+ SYN-005 | Antithetical sentence | thesis vs antithesis in one arc
70
+ SYN-006 | Appositive expansion | noun then re-naming clause
71
+ SYN-007 | Parallel triad | three coordinate elements
72
+ SYN-008 | Fragment with prior license | intentional non-sentence for stress
73
+ SYN-009 | Question sentence | interrogative
74
+ SYN-010 | Negative sentence | polarity-negative for weight
75
+ SYN-011 | Inverted sentence | non-canonical order for emphasis
76
+ SYN-012 | Dialogue beat sentence | speaker action + speech
77
+ SYN-013 | Image sentence | perception-first
78
+ SYN-014 | Procedural sentence | tool-first, step-list voice
79
+ SYN-015 | Lyrical long sentence | extended cumulative or periodic
80
+ SYN-016 | Hard stop sentence | one-clause blow
81
+ `);
82
+
83
+ // ── §7 paragraph types + §7.2 paragraph audits ──────────────────────────────
84
+ export const PARAGRAPH_TYPES: SagaRow[] = parse(`
85
+ PAR-001 | Action paragraph | forward physical/decisional motion
86
+ PAR-002 | Sensory paragraph | perception-primary
87
+ PAR-003 | Interior-processing paragraph | reflection/decision-work
88
+ PAR-004 | Argument / reflection paragraph | claim-reason-evidence-warrant
89
+ PAR-005 | Dialogue paragraph | exchange
90
+ PAR-006 | Institutional paragraph | rule invoked / ruling given
91
+ PAR-007 | Transition paragraph | scene/temporal bridge
92
+ PAR-008 | Ritual paragraph | performed sequence
93
+ PAR-009 | Memory paragraph | retrieved past
94
+ PAR-010 | Shock paragraph | rupture / reversal
95
+ `);
96
+
97
+ // ── §13 AUREATE revision stack (PASS-001..015) ──────────────────────────────
98
+ export const AUREATE_REVISION_STACK: SagaRow[] = parse(`
99
+ PASS-001 | Logic-to-prose alignment | plan matches text
100
+ PASS-002 | Characters-as-subjects / actions-as-verbs | Williams AGENCY
101
+ PASS-003 | Old-new information flow | Williams COHESION
102
+ PASS-004 | Topic-stress / emphatic endings | Williams EMPHASIS
103
+ PASS-005 | Concision and clutter removal | Zinsser/Strunk
104
+ PASS-006 | Concrete-language strengthening | Strunk SPECIFICITY
105
+ PASS-007 | Copy-chief grammar hygiene | Dreyer COPYCHIEF
106
+ PASS-008 | POV/focalization consistency | Le Guin/Genette
107
+ PASS-009 | Image-chain coherence | motif discipline
108
+ PASS-010 | Sound/rhythm variation | Le Guin/Tufte
109
+ PASS-011 | Dialogue idiolect and subtext | voice-DNA gate
110
+ PASS-012 | Argument/warrant check | Booth
111
+ PASS-013 | Cliché and stale phrase removal | TELL-PURGE risk profile
112
+ PASS-014 | KALLOS-S style scoring | soft-dim score
113
+ PASS-015 | Human-readability gate | final release gate
114
+ `);
115
+
116
+ // ── §14 KALLOS-S soft-dimension weights (v4) — v2 refines these in v5 ──────
117
+ export const KALLOS_S_V4_WEIGHTS: Record<string, number> = {
118
+ clarity: 0.14, cohesion: 0.10, concision: 0.10, concreteness: 0.09,
119
+ rhythm: 0.09, image_chain: 0.08, voice_distinction: 0.08,
120
+ dialogue_subtext: 0.08, focal_integrity: 0.08, syntactic_variety: 0.07,
121
+ argument_warranting: 0.05, surprise_without_confusion: 0.04,
122
+ };
123
+
124
+ // ── §17 production style packs ──────────────────────────────────────────────
125
+ export const STYLE_PACKS: SagaRow[] = parse(`
126
+ STYLEPACK-SPARE | Strunk/Zinsser-heavy | high compression, low ornament
127
+ STYLEPACK-CLASSIC | Pinker/Williams-heavy | reader gaze, clear syntax, topic-stress
128
+ STYLEPACK-GRACE | Williams/Tufte-heavy | balanced syntax, emphatic endings, cadence
129
+ STYLEPACK-LYRICAL | Le Guin/Tufte-heavy | sound, image, long curves, omission
130
+ STYLEPACK-COPYCHIEF | Dreyer-heavy | grammar hygiene, house style, punctuation judgment
131
+ STYLEPACK-ARGUMENT | Booth-heavy | claim-reason-evidence-warrant passages
132
+ STYLEPACK-POPULAR | Clark/Zinsser/Pinker hybrid | subject/verb drive, low clutter
133
+ `);
134
+
135
+ // ── §19 acceptance tests (STYLE-TEST-001..015 v4) ───────────────────────────
136
+ export const STYLE_TESTS_V4: SagaRow[] = parse(`
137
+ STYLE-TEST-001 | agency alignment | characters/actions alignment ≥ threshold
138
+ STYLE-TEST-002 | old-new chain | old-new information chain valid
139
+ STYLE-TEST-003 | topic-stress endings | valid
140
+ STYLE-TEST-004 | clutter ratio | below profile cap
141
+ STYLE-TEST-005 | concrete density | above profile floor
142
+ STYLE-TEST-006 | cliché blacklist | zero unless character-marked
143
+ STYLE-TEST-007 | POV metaphor ownership | valid
144
+ STYLE-TEST-008 | idiolect distance | leads above threshold
145
+ STYLE-TEST-009 | image-chain recurrence | transformed
146
+ STYLE-TEST-010 | sound/rhythm variance | within genre profile
147
+ STYLE-TEST-011 | argument warranting | passages complete
148
+ STYLE-TEST-012 | hard grammar | zero
149
+ STYLE-TEST-013 | placeholders/truncation | zero
150
+ STYLE-TEST-014 | KALLOS-S | ≥ release threshold
151
+ STYLE-TEST-015 | seed replay | byte-identical
152
+ `);
153
+
154
+ // ── REAL FUNCTION 1: syntax-form selector (v4 §6.3) ─────────────────────────
155
+ type PriorForm = string | undefined;
156
+ export function selectSyntaxForm(
157
+ ctx: { clarityRequired?: boolean; emotionalPeak?: boolean; lyricalMode?: boolean; argumentMode?: boolean },
158
+ priorForms: PriorForm[],
159
+ ): string {
160
+ // "if three similar prior forms: force contrast"
161
+ const last3 = priorForms.slice(-3).filter(Boolean);
162
+ const monotone = last3.length === 3 && last3.every((f) => f === last3[0]);
163
+
164
+ if (ctx.argumentMode) return monotone && priorForms[priorForms.length - 1] === "SYN-004" ? "SYN-007" : "SYN-004";
165
+ if (ctx.emotionalPeak) {
166
+ const pool = ["SYN-003", "SYN-008", "SYN-016"];
167
+ return monotone ? pool.find((f) => f !== last3[0])! : pool[0];
168
+ }
169
+ if (ctx.lyricalMode) {
170
+ const pool = ["SYN-002", "SYN-005", "SYN-015"];
171
+ return monotone ? pool.find((f) => f !== last3[0])! : pool[0];
172
+ }
173
+ if (ctx.clarityRequired) {
174
+ const pool = ["SYN-001", "SYN-014"];
175
+ return monotone ? pool.find((f) => f !== last3[0])! : pool[0];
176
+ }
177
+ // Default: cycle through a small varied set to preserve rhythm variance.
178
+ const fallback = ["SYN-001", "SYN-002", "SYN-006", "SYN-007"];
179
+ return fallback[(priorForms.length) % fallback.length];
180
+ }
181
+
182
+ // ── REAL FUNCTION 2: Dreyer-style wan-intensifier audit ─────────────────────
183
+ export type WanFinding = { word: string; count: number };
184
+ const WAN_INTENSIFIERS = ["very", "really", "actually", "basically", "quite", "just", "somewhat", "rather", "kind of", "sort of", "literally"];
185
+ export function auditWanIntensifiers(text: string): { total: number; density: number; findings: WanFinding[] } {
186
+ const words = text.toLowerCase().match(/[a-z']+/g) || [];
187
+ const total = words.length;
188
+ const counts = new Map<string, number>();
189
+ for (const w of WAN_INTENSIFIERS) {
190
+ const parts = w.split(" ");
191
+ let hits = 0;
192
+ if (parts.length === 1) {
193
+ hits = words.filter((x) => x === parts[0]).length;
194
+ } else {
195
+ for (let i = 0; i <= words.length - parts.length; i++) {
196
+ if (parts.every((p, j) => words[i + j] === p)) hits += 1;
197
+ }
198
+ }
199
+ if (hits > 0) counts.set(w, hits);
200
+ }
201
+ const findings: WanFinding[] = Array.from(counts.entries())
202
+ .map(([word, count]) => ({ word, count }))
203
+ .sort((a, b) => b.count - a.count);
204
+ const totalHits = findings.reduce((a, f) => a + f.count, 0);
205
+ return { total, density: total ? totalHits / total : 0, findings };
206
+ }
207
+
208
+ export function aureateRevisionOrder(): string[] {
209
+ return AUREATE_REVISION_STACK.map((r) => r.id);
210
+ }
211
+
212
+ export const SAGA_OS_V4_VERSION = "SAGA-OS v4 (SYSTEM v15) — AUREATE-SCRIBE tables + syntax selector + wan-intensifier audit";
@@ -0,0 +1,205 @@
1
+ /**
2
+ * SAGA-OS v5 — AUREATE FORGE (fable.canon SYSTEM v16)
3
+ * ---------------------------------------------------------------------------
4
+ * Append-only over v4. Adds: fractal style inheritance, STYLE-OP registry,
5
+ * SEMANTIC-MESH schema, PUBLIC-DOMAIN STYLE ATLAS anti-imitation invariants,
6
+ * SERENDIPITY-ORCHARD deterministic surprise, VOICE-DNA v2 fields, quality
7
+ * modes + hardware profiles, KALLOS-S v2 weights, STYLE-001..025 tests.
8
+ *
9
+ * Real, deterministic functions:
10
+ * - fractalStyleInherit() — v5 §5.2 clamped child-genome computation.
11
+ * - serendipityPick() — v5 §9.2 seeded low-discrepancy selection from
12
+ * a Pareto envelope of already-hard-gated candidates. No dice can pick
13
+ * an invalid option because the caller supplies only survivors.
14
+ * - blindSpeakerDistance() — v5 §11.2 voice-distinction proxy (edit
15
+ * distance over VoiceGenome vectors) used by GAUNTLET STYLE-008/009.
16
+ */
17
+ import type { SagaRow } from "./saga-os";
18
+
19
+ function parse(raw: string): SagaRow[] {
20
+ return raw.trim().split(/\n+/).map((l) => l.trim()).filter(Boolean).map((l) => {
21
+ const [id, name, ...rest] = l.split("|").map((p) => p.trim());
22
+ return { id, name, note: rest.join(" | ") };
23
+ });
24
+ }
25
+
26
+ // ── §5.1 style-priority order (conflict-resolution rank) ────────────────────
27
+ export const STYLE_PRIORITY_ORDER: string[] = [
28
+ "LOGIC", "CHARACTER/READER KNOWLEDGE", "GRAMMATICALITY", "REFERENCE CLARITY",
29
+ "POV INTEGRITY", "GENRE CONTRACT", "CHARACTER VOICE", "COHESION",
30
+ "RHYTHM", "IMAGE", "CONCISION", "ORNAMENT",
31
+ ];
32
+
33
+ // ── §6.1 STYLE-OP registry (v5) — 15 operators ──────────────────────────────
34
+ export const STYLE_OPERATORS: SagaRow[] = parse(`
35
+ STYLE-OP-001 | AGENCY | narrative agent → grammatical subject; action → finite verb
36
+ STYLE-OP-002 | INFORMATION FLOW | established before new unless disruption intended
37
+ STYLE-OP-003 | END WEIGHT | highest-pressure constituent near clause close
38
+ STYLE-OP-004 | CONCISION | delete only if meaning/voice/rhythm/inference/affect preserved
39
+ STYLE-OP-005 | CONCRETENESS | translate abstraction into observable action/sensation/consequence
40
+ STYLE-OP-006 | PARALLELISM | equivalent semantic units → equivalent grammatical structures
41
+ STYLE-OP-007 | COHESION | maintain referring-expression + topic chains across sentences
42
+ STYLE-OP-008 | COGNITIVE LOAD | limit center embedding, ambiguous attachment, dense intro
43
+ STYLE-OP-009 | ARGUMENT | require claim→reason→evidence→warrant for argumentative reflection only
44
+ STYLE-OP-010 | COPYCHIEF | separate hard errors, house-style preferences, character-voice exceptions
45
+ STYLE-OP-011 | SOUND | stress, syllables, clusters, alliteration, pause pattern, read-aloud flow
46
+ STYLE-OP-012 | IMAGE SYSTEM | bind figurative to POV + concrete source + scene purpose + motif family
47
+ STYLE-OP-013 | POV OWNERSHIP | diction/metaphor/judgment/sensory/vocab belong to narrator or focal
48
+ STYLE-OP-014 | SUBTEXT | in pressure dialogue distinguish stated content / hidden intent / power move / relation delta
49
+ STYLE-OP-015 | STRATEGIC VIOLATION | any rule broken only via explicit StyleOverride record
50
+ `);
51
+
52
+ // ── §7 SEMANTIC-MESH stack (design; backends are v6 originals) ──────────────
53
+ export const SEMANTIC_MESH_STACK: SagaRow[] = parse(`
54
+ LEX | WordNet-family lexical relations | v6 replaces with HELIOS-LEX
55
+ VRB | VerbNet-family class + frames | v6 replaces with KINETICON
56
+ FRM | FrameNet-family semantic frames | v6 replaces with AXIS-FRAMES
57
+ PHN | CMU-style pronunciation & prosody | v6 replaces with RESONA
58
+ RLZ | SimpleNLG-family surface realizer | v6 replaces with MORPHEA
59
+ VAL | LanguageTool-family grammar/style | v6 replaces with VERIDICT
60
+ `);
61
+
62
+ // ── §8 PUBLIC-DOMAIN STYLE ATLAS — anti-imitation invariants (verbatim) ────
63
+ export const ATLAS_INVARIANTS: SagaRow[] = parse(`
64
+ ATLAS-001 | no source-sentence retrieval | no source sentence may be retrieved for output
65
+ ATLAS-002 | max shared n-gram | no source n-gram of length ≥ 5 unless independently common
66
+ ATLAS-003 | aggregation floor | profiles aggregate across ≥ 20 works and ≥ 5 authors
67
+ ATLAS-004 | no living-author imitation | living-author imitation profiles forbidden
68
+ ATLAS-005 | provenance metadata | every source has jurisdiction, provenance, license metadata
69
+ ATLAS-006 | feature-named profiles only | profiles named by features, never authors (e.g. "lyrical-periodic-gothic")
70
+ `);
71
+
72
+ // ── §9.5 ORCHARD reroll contract ────────────────────────────────────────────
73
+ export const ORCHARD_CONTRACT: SagaRow[] = parse(`
74
+ ORCHARD-001 | hard-gate legal | all reroll outcomes are hard-gate legal
75
+ ORCHARD-002 | canon lock | reroll cannot alter locked canon
76
+ ORCHARD-003 | no early leak | reroll cannot reveal future information early
77
+ ORCHARD-004 | no unpaid promises | reroll cannot create an unpaid mandatory promise
78
+ ORCHARD-005 | soft-strict | reroll must increase at least one soft dim without reducing any hard dim
79
+ ORCHARD-006 | reproducible | every selection reproducible from seed and version
80
+ ORCHARD-007 | audit history | reroll history emitted in BuildManifest
81
+ `);
82
+
83
+ // ── §13 KALLOS-S v2 dimensions + weights ────────────────────────────────────
84
+ export const KALLOS_S_V2_WEIGHTS: Record<string, number> = {
85
+ clarity: 0.10, cohesion: 0.09, specificity: 0.08, concreteness: 0.07,
86
+ cadence: 0.09, syntax_variety: 0.07, image_system: 0.09,
87
+ voice_distinction: 0.10, dialogue_subtext: 0.08, emotional_pressure: 0.09,
88
+ thematic_warrant: 0.06, surprise_without_noise: 0.08,
89
+ };
90
+
91
+ // ── §11 VOICE-DNA v2 fields ─────────────────────────────────────────────────
92
+ export const VOICE_DNA_FIELDS = [
93
+ "preferred_syntax", "forbidden_syntax", "sentence_length_distribution",
94
+ "clause_depth", "contraction_rate", "directness", "hedge_rate",
95
+ "question_rate", "interruption_rate", "emotional_naming",
96
+ "sensory_priority", "metaphor_source_domains", "occupation_lexicon",
97
+ "taboo_words", "humor_mode", "politeness_strategy", "filler_words",
98
+ "silence_rate", "pronoun_preferences", "narrator_distance", "historical_version",
99
+ ] as const;
100
+
101
+ // ── §15.3 quality modes (search-width profiles) ─────────────────────────────
102
+ export const QUALITY_MODES: SagaRow[] = parse(`
103
+ CONTROLLED | 4-8 sentence beam / 1-2 para alternatives / 3-5 revision passes | grammar-guaranteed within grammar
104
+ LITERARY | 32-64 / 4-8 / 8-12 | stronger validation required
105
+ LAUREATE | 128-256 / 8-16 / 12-20 | corpus + panel calibration required
106
+ `);
107
+
108
+ // ── §15.2 hardware profiles (unbenchmarked target configs) ──────────────────
109
+ export const HARDWARE_PROFILES: SagaRow[] = parse(`
110
+ Minimum laptop | 4-6 cores, 16GB, 15-30GB SSD | CONTROLLED
111
+ Recommended laptop | 8-12 cores, 32GB, 40-100GB NVMe | CONTROLLED / LITERARY
112
+ Production workstation | 24-32 cores, 64GB, 100-250GB NVMe | LAUREATE search / multi-project
113
+ Corpus-builder | 32+ cores, 128GB, 0.5-2TB | building public-domain atlases
114
+ `);
115
+
116
+ // ── §20 STYLE-001..025 production acceptance tests (v5) ─────────────────────
117
+ export const STYLE_TESTS_V5: SagaRow[] = parse(`
118
+ STYLE-001 | required propositions realized | all required propositions realized
119
+ STYLE-002 | no placeholders | zero placeholder tokens
120
+ STYLE-003 | no truncation | no truncated units
121
+ STYLE-004 | controlled grammar clean | hard grammar errors = 0
122
+ STYLE-005 | literary blocking clean | literary-mode blocking errors = 0
123
+ STYLE-006 | reader-safe boundary | intact
124
+ STYLE-007 | character knowledge boundary | intact
125
+ STYLE-008 | voice divergence | VoiceGenome divergence above threshold
126
+ STYLE-009 | blind speaker accuracy | above threshold
127
+ STYLE-010 | cliché-risk profile | passes
128
+ STYLE-011 | metaphor POV ownership | passes
129
+ STYLE-012 | image-chain transformations | logged
130
+ STYLE-013 | sentence/paragraph rhythm | in profile
131
+ STYLE-014 | no unlicensed overlap | no source-phrase overlap
132
+ STYLE-015 | build determinism | same build identity → byte-identical manuscript
133
+ STYLE-016 | volume closure | every volume has local closure
134
+ STYLE-017 | saga promise closure | all mandatory saga promises settled
135
+ STYLE-018 | crash recovery | resumes from last atomic chapter
136
+ STYLE-019 | memory ceiling | stays under configured ceiling
137
+ STYLE-020 | budget without padding | output length meets budget without padding
138
+ STYLE-021 | surprise reproducible | seeded surprise history reproducible
139
+ STYLE-022 | weakest-dim disclosure | KALLOS report lists weakest dimension
140
+ STYLE-023 | overrides justified | all StyleOverrides have explicit justifications
141
+ STYLE-024 | screen adaptation | retains every required causal delta
142
+ STYLE-025 | human sample gate | blind human sample meets release threshold
143
+ `);
144
+
145
+ // ── REAL FUNCTION 1: fractal style-genome inheritance (v5 §5.2) ─────────────
146
+ export type StyleGenomeVec = Record<string, number>;
147
+ function clamp01(x: number): number { return Math.max(0, Math.min(1, x)); }
148
+
149
+ /**
150
+ * Deterministic clamped child-genome computation per v5 §5.2:
151
+ * G_child = clamp(G_parent + required_deltas + seeded_bounded_mutation)
152
+ * Mutation range is capped so a gothic volume cannot randomly become comic.
153
+ */
154
+ export function fractalStyleInherit(
155
+ parent: StyleGenomeVec,
156
+ deltas: StyleGenomeVec,
157
+ seed: number,
158
+ mutationCap = 0.05,
159
+ ): StyleGenomeVec {
160
+ const out: StyleGenomeVec = {};
161
+ const keys = new Set([...Object.keys(parent), ...Object.keys(deltas)]);
162
+ let s = seed | 0;
163
+ for (const k of keys) {
164
+ // seeded bounded mutation (Mulberry32-lite; deterministic)
165
+ s = (s + 0x6d2b79f5) | 0;
166
+ let t = Math.imul(s ^ (s >>> 15), 1 | s);
167
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
168
+ const r = ((t ^ (t >>> 14)) >>> 0) / 4294967296;
169
+ const mutation = (r * 2 - 1) * mutationCap;
170
+ const base = parent[k] ?? 0.5;
171
+ const delta = deltas[k] ?? 0;
172
+ out[k] = Math.round(clamp01(base + delta + mutation) * 1000) / 1000;
173
+ }
174
+ return out;
175
+ }
176
+
177
+ // ── REAL FUNCTION 2: SERENDIPITY-ORCHARD deterministic pick ─────────────────
178
+ /**
179
+ * Selects deterministically from a Pareto envelope of already-hard-gated
180
+ * candidates. The dice cannot pick an invalid option because the caller
181
+ * supplies only survivors. Reproducible: same (seed, unitId, envelope.length)
182
+ * always returns the same index.
183
+ */
184
+ export function serendipityPick<T>(
185
+ survivors: T[],
186
+ seed: number,
187
+ unitId: number,
188
+ ): T | null {
189
+ if (survivors.length === 0) return null;
190
+ // Low-discrepancy step per unit; keeps consecutive picks well-spread.
191
+ const phi = 0x9e3779b1;
192
+ const mixed = ((seed >>> 0) ^ Math.imul(unitId + 1, phi)) >>> 0;
193
+ return survivors[mixed % survivors.length];
194
+ }
195
+
196
+ // ── REAL FUNCTION 3: blind-speaker VoiceGenome distance (v5 §11.2 gate) ─────
197
+ export function blindSpeakerDistance(a: number[], b: number[]): number {
198
+ const n = Math.max(a.length, b.length);
199
+ if (n === 0) return 0;
200
+ let sum = 0;
201
+ for (let i = 0; i < n; i++) sum += Math.abs((a[i] ?? 0) - (b[i] ?? 0));
202
+ return Math.round((sum / n) * 1000) / 1000;
203
+ }
204
+
205
+ export const SAGA_OS_V5_VERSION = "SAGA-OS v5 (SYSTEM v16) — AUREATE FORGE tables + fractal inheritance + ORCHARD picker + blind-speaker distance";