Files
encyclopedia-knowledge-graph/docs/plans/piecewise/PLAN-PIECEWISE-QUANT-VOICE-NARRATION-AND-SCENE-UI-INDICATORS.md
T

15 KiB
Raw Blame History

PLAN: Piecewise /quant/ Guided Tour Spoken Voice Narration, Explicit Per-Scene UI Element Indicators & Automatic Closeup Re-Rendering (Audit Points 1–4, Rule C Piecewise Specification)

Document ID: PLAN-PIECEWISE-QUANT-VOICE-NARRATION-AND-SCENE-UI-INDICATORS Status: PENDING AUDIT PIECEWISE (0/4 AUDIT POINTS AFFIRMED — READY FOR STEPWISE REVIEW) Target Ecosystem Version: v2.11.0 Target Repositories: hyperstitionstudio-core, encyclopedia-knowledge-graph Author: m00t & Hermes Agent Date: 2026-11-30


1. Ground-Truth Audit: Why Voice: ON Only Played Chimes & Why Ep 04 Failed to Indicate #lensSelect (Rule C.1)

Per Rule C of hyperstitionstudio-roadmap-and-release, we audited /workspace/hyperstitionstudio-core/site/quant/quant-tutorials.js, site/quant/quant-app.js, and src/hyperstitionstud_io/publishing/closeups_sync.py to pinpoint the exact root causes of the issues reported by the user:

Audit Point & Surface Root Cause Discovered in Live Code (v2.10.0) What Must Change to Fix It
Audit Point 1
Spoken Voice Narration (#tutSpeechBtn "Voice: ON" in site/quant/quant-tutorials.js)
1. Silent Abort When speechSynthesis.getVoices() Is Empty (lines 406–410):
speakSubtitle() calls playWebAudioTelemetryChime(curStepIdx) and then immediately checks:
`if (typeof window.speechSynthesis === "undefined"
Audit Point 2
Per-Scene UI Element Indicators (Ep 01–05, especially Ep 04 #lensSelect Dropdown)
1. highlightDomTarget() Only Knew 5 Bottom Panels (lines 454–466):
map = { panel2: "heatmapTable", lensCard: "lensProjectionCard", docCard: "docReferencesCard", wireTape: "wireEqTape", panel4: "lagBarsContainer" }.
• It never included #lensSelect (the Projection Lens dropdown list!), #guildFilterPills, #tickerSelect, #tickerQuickFilter, #metricModePills, #timeWindowPills, #openTradingViewBtn, #exportCsvBtn, #macroIndicatorsPanel, or #dailyBriefPanel!
• As a result, all 5 scenes of Ep 04 (4.1–4.5) only put a faint box-shadow on #lensProjectionCard and never pointed to or highlighted the #lensSelect Projection Lens dropdown list in the toolbar!
1. Explicit Floating UI Element Callout Badge (#tutUiElementIndicator) + Gold Pulse Ring on Every Scene's Target Control (25/25 Scenes):
• Give every single scene (1.1 through 5.5) an explicit uiTargets: [...] array mapping to the exact DOM control(s) being taught (e.g., Ep 04 scenes 4.1–4.5 highlight both #lensSelect (Projection Lens Dropdown List) AND #lensProjectionCard with a glowing Gold border + floating ▼ ACTIVE UI ELEMENT: Projection Lens Dropdown (#lensSelect) badge and smooth scroll-into-view!).
Audit Point 3
Spoken Text Normalization for Math, Symbols & Tickers (cleanTextForSpeech())
• Raw subtitle strings contain symbols like ` Δbps_{i, t+tau}
Audit Point 4
Deepening hs-closeups-sync (src/hyperstitionstud_io/publishing/closeups_sync.py) for /quant/ & All Pages
• While closeups_sync.py hashes HTML IDs/classes/buttons, it currently only inspects .html files (not quant-tutorials.js or quant-app.js dynamic pill arrays), and the Quadrant 02 closeups (quadrant-2-*.png) do not visually reflect the newly added /quant/ toolbar & tutorial controls (#quantTutorialBar, #lensSelect, #timeWindowPills, #tickerQuickFilter, #heatmapPaginationBar, #wireTapeFilterInput) when those elements are added or removed. • Upgrade closeups_sync.py so introspect_live_ui_elements() inspects both .html and companion .js files (quant-app.js, quant-tutorials.js, learn-app.js, hs-guile-scheme-repl.js) AND dynamically renders the live detected UI controls directly inside the 680×260 closeup canvases whenever any control is added or removed!

2. Four Factual Binary Engineering Gates (G1–G4, Zero Synthetic Data)

  • Gate G1 (100% Real Spoken Voice Output — Not Just Chimes): Clicking ▶ Play Guided Tour or 🔊 Voice: ON must produce real spoken human-intelligible voice narration of the scene's educational text (via pre-generated offline .mp3 voice clips + synchronous Web Speech API SpeechSynthesisUtterance without blocking on cachedVoices.length === 0).
  • Gate G2 (25/25 Scenes Explicitly Indicate Their Target DOM UI Element(s)): Every scene (1.1–5.5) highlights its exact DOM control(s) (including #lensSelect in Ep 04, #guildFilterPills in Ep 01, #metricModePills in Ep 02, #openTradingViewBtn / #heatmapTable in Ep 03, and #exportCsvBtn / #lagBarsContainer in Ep 05) with a high-visibility .tut-active-ui-highlight ring and a floating #tutUiElementCallout pointer banner.
  • Gate G3 (100% Dynamic hs-closeups-sync Reactivity Across HTML + JS): Adding or removing any UI element in /quant/, /learn/, /graph/, /calc/, /engineering/, or /math/ (in either .html or .js) triggers hs-closeups-sync and updates the rendered elements inside site/assets/closeups/*.png.
  • Gate G4 (ProtectSystem=strict EROFS & Offline file:// Safe): Works 100% offline over both HTTP and file://.

3. Piecewise Audit Points & Candidate Strategies (Strategies 1A–1C through 4A–4C)


Audit Point 1: Real Spoken Voice Narration for /quant/ Guided Tour (#tutSpeechBtn & speakSubtitle())

  • Strategy 1A (Dual-Engine Spoken Voice: Pre-Generated Offline Neural TTS .mp3 Clips for All 25 Scenes + Unblocked Synchronous Browser speechSynthesis.speak() Fallback — Recommended Candidate):
    • Uses the text_to_speech tool to generate crisp, offline-bundled spoken audio tracks (site/quant/audio/ep01-s1.mp3 .. ep05-s5.mp3) for all 25 scenes and plays them through a dedicated <audio id="tutVoicePlayer"> element when Voice: ON is enabled.
    • Simultaneously fixes the Web Speech API fallback in quant-tutorials.js by:
      1. Removing the fatal if (cachedVoices.length === 0) return; guard (calling window.speechSynthesis.speak(u) with the browser's default voice even when getVoices() is initially empty),
      2. Calling speechSynthesis.speak(u) synchronously inside the user click handler (instead of inside setTimeout(..., 60)), and
      3. Lowering or removing the chime so the spoken voice is the primary audio output controlled by 🔊 Voice: ON / 🔇 Voice: OFF.
  • Strategy 1B (Fix Browser window.speechSynthesis Guard & Synchronous Call Only — Zero .mp3 Files Candidate):
    • Fixes speakSubtitle() in quant-tutorials.js so window.speechSynthesis.speak(u) is called synchronously without aborting on cachedVoices.length === 0 and adds a spoken math/symbol normalizer, without bundling .mp3 files.
  • Strategy 1C (Keep WebAudio Chimes Only — Status Quo):
    • Plays only synthetic sine/triangle chimes when getVoices() is empty.

Audit Point 2: Explicit UI Element Indication Across All 25 Scenes (Especially Ep 04 #lensSelect Projection Lens Dropdown)

  • Strategy 2A (High-Visibility Gold Callout Ring .tut-ui-highlight + Floating ▼ INSPECTING UI ELEMENT Pointer Badge on Every Scene's Target Control(s), Including #lensSelect in Ep 04 — Recommended Candidate):
    • Expands highlightDomTarget() in site/quant/quant-tutorials.js to support all 18 interactive DOM controls on /quant/:
      • Ep 01 (1.1–1.5): Highlights #guildFilterPills (and the specific active pill ALL / S1 / S3 / S6), #tickerQuickFilter, #tickerSelect, and #periodicityAuditFooter.
      • Ep 02 (2.1–2.5): Highlights #metricModePills (Close Price (USD) / Move (BPS) / Spoken AQ), #timeWindowPills, #activeDateBadge, and the specific Top/Middle/Bottom pane of #tsCanvas.
      • Ep 03 (3.1–3.5): Highlights #heatmapTable (Panel 2), #openTradingViewBtn & #panel3TvBtn (TradingView ↗), #docReferencesCard, and #wireEqTape + #wireTapeFilterInput.
      • Ep 04 (4.1–4.5 — Projection Lenses): Explicitly highlights BOTH the #lensSelect Projection Lens <select> dropdown list in the toolbar AND #lensProjectionCard in Panel 3, attaches a floating Gold badge (▼ UI ELEMENT: Projection Lens Dropdown (#lensSelect) -> Active: <Lens Name>) directly above #lensSelect, and pulses #lensSelect so the viewer immediately sees where to change lenses!
      • Ep 05 (5.1–5.5): Highlights #lagBarsContainer (Panel 4), #exportCsvBtn & #exportJsonBtn, #macroIndicatorsPanel (Panel 5), and #dailyBriefPanel (Panel 6).
  • Strategy 2B (Add #lensSelect Box-Shadow Only Without Floating Callout Badge — Minimal Candidate):
    • Adds lensSelect to highlightDomTarget() with a CSS box-shadow only, without a floating label badge or multi-control highlighting.
  • Strategy 2C (Keep Existing 5-Panel Highlight Map — Status Quo):
    • Leaves #lensSelect and toolbar controls unhighlighted during the tour.

Audit Point 3: Spoken Script & Educational UI-Element Callout Normalization (speechText Per Keyframe)

  • Strategy 3A (Dedicated Natural-English speechText Per Scene Naming the Highlighted UI Control First — Recommended Candidate):
    • Adds a natural-English speechText field (and cleanTextForSpeech() normalizer) to each of the 25 scenes so the voice explicitly names the highlighted UI element and explains its educational function in clear spoken words (e.g. for Ep 04 Scene 4.1: "Scene 4.1. Highlighting the Projection Lens dropdown list in the top toolbar and the Lens Projection card in Panel 3. Under the hood, the workbench stores one hundred percent lens-neutral mathematical scores. Use the Projection Lens dropdown list to switch between Neutral Math, Fund Manager, Corporate Board, TierZoo, Fantasy Sabermetrics, and Pokedex Scanner.").
  • Strategy 3B (Regex Strip Punctuation from Existing subtitle Only — Partial Candidate):
    • Strips _*|= characters from kf.subtitle without explicitly naming the highlighted UI control in the spoken narration.
  • Strategy 3C (Pass Raw kf.subtitle Directly to TTS — Status Quo):
    • Passes raw code/math strings like |Δbps_{i, t+tau}| directly to TTS.

Audit Point 4: Deepening hs-closeups-sync (closeups_sync.py) to Track JS-Rendered Controls & Visually Reflect /quant/ UI Elements

  • Strategy 4A (Introspect Both .html and .js UI Control Definitions in hs-closeups-sync & Render Live Detected Controls Inside the 680×260 Closeup Canvases — Recommended Candidate):
    • Upgrades introspect_live_ui_elements() in src/hyperstitionstud_io/publishing/closeups_sync.py so it fingerprints both .html files and companion .js files (site/quant/quant-app.js, site/quant/quant-tutorials.js, site/learn/learn-app.js, site/assets/hs-guile-scheme-repl.js)—detecting any added/removed toolbar controls, tutorial episodes, lens options, or filter pills.
    • Updates the Quadrant 02 (quadrant-2-*.png) closeup renderer in closeups_sync.py so that each tab closeup dynamically draws the live controls present in site/quant/index.html and quant-tutorials.js (e.g., showing the #lensSelect dropdown, #tutSpeechBtn 🔊 Voice: ON, #timeWindowPills [30D|90D|180D|ALL], and #tickerQuickFilter when present in the live DOM, and omitting them if removed) and adds a unit test in tests/test_core_suite.py verifying that mutating a UI element triggers hs-closeups-sync re-rendering!
  • Strategy 4B (Add .js File Hashing to closeups_sync.py Only — Partial Candidate):
    • Hashes .js files to trigger re-renders without updating the visual control drawing inside quadrant-2-*.png.
  • Strategy 4C (Leave closeups_sync.py HTML-Only — Status Quo):
    • Only inspects .html files.

4. Summary Matrix of Audit Points 1–4 for Stepwise Review

Audit Point Target /quant/ & Tooling Surface Strategy A (Complete Fix & Live Introspection — Recommended) Strategy B (Lightweight / Partial Alternative) Strategy C (Status Quo)
Point 1 Spoken Voice Narration (#tutSpeechBtn) 1A: Pre-generated offline neural TTS .mp3 clips (25 scenes) + unblocked synchronous window.speechSynthesis.speak() fallback 1B: Unblocked synchronous window.speechSynthesis.speak() fix only (0 .mp3 files) 1C: Chimes only when getVoices() is empty
Point 2 Per-Scene UI Element Indicators (Ep 01–05 & Ep 04 #lensSelect) 2A: Highlight all 18 DOM controls (including #lensSelect dropdown + #lensProjectionCard in Ep 04) with .tut-ui-highlight + floating ▼ UI ELEMENT pointer badge 2B: Add #lensSelect box-shadow only (no floating pointer badge) 2C: Keep 5-panel highlight map
Point 3 Spoken Educational Script (speechText) 3A: Dedicated natural-English speechText per scene naming the highlighted UI element first + math/symbol pronunciation normalizer 3B: Regex punctuation strip on raw subtitle only 3C: Raw subtitle string
Point 4 hs-closeups-sync (closeups_sync.py) 4A: Introspect both .html + .js (quant-app.js, quant-tutorials.js, learn-app.js), dynamically draw live /quant/ controls in quadrant-2-*.png, & add mutation test in test_core_suite.py 4B: Hash .js files without updating quadrant-2-*.png control drawing 4C: HTML-only fingerprinting