Skip to content

feat+fix(sutta-studio): ?phaseLimit=N + 3 bug fixes surfaced by DN22 pilot#55

Merged
anantham merged 4 commits into
mainfrom
feat/opus-dn22-pilot
May 15, 2026
Merged

feat+fix(sutta-studio): ?phaseLimit=N + 3 bug fixes surfaced by DN22 pilot#55
anantham merged 4 commits into
mainfrom
feat/opus-dn22-pilot

Conversation

@anantham
Copy link
Copy Markdown
Owner

Summary

DN22 pilot attempt surfaced one feature and 3 real bug fixes. All shipped here as one coherent unit.

What's in

Commit What
`1b4ac65` feat: `?phaseLimit=N` URL param — pilot-mode cap on compilation phases
`76ea314` fix: null-safe `chapter?.translationResult` in SuttaStudioFallback (blank screen on fresh sutta visit)
`767e4f6` fix: Tooltip infinite render loop (useLayoutEffect had `leftPx` in deps; set+measure+set forever)
`5e00c1b` fix: phaseLimit truncation also applies after runSkeletonPass (was scoped only to chunkPhases fallback)

The arc

User asked to validate the architecture amortization claim by piloting DN22.
Each visit surfaced a real bug at increasingly later compile stages:

  1. `/sutta/dn22` → blank screen (Fallback null access on fresh chapter)
  2. Fix 1 → compile starts but crashes at phase-2 (Tooltip infinite loop)
  3. Fix 2 → compile runs but doesn't truncate (phaseLimit ignored on LLM-skeleton path)
  4. Fix 3 → `?phaseLimit=4` actually limits to 4 phases

These bugs would have surfaced for ANY new sutta. The pilot caught them cheaply.

Verification

After landing this PR + hard-refresh:
```
http://localhost:5180/sutta/dn22?lang=en&author=sujato&phaseLimit=4
```
Should show `Phase 0/4` (not 0/451), compile in ~3 min, cost ~$0.10.

Test plan

  • Visit `/sutta/dn22?phaseLimit=4` fresh → no blank screen, fallback view renders
  • Compile progresses past phase-2 without infinite-loop crash
  • Progress chip shows `Phase X/4` not `Phase X/451`
  • Total compile ~3 min, ~$0.10
  • Refresh after completion → packet renders from IndexedDB cache (no recompile)

🤖 Generated with Claude Code

anantham added 4 commits May 14, 2026 21:33
Trims phaseSkeleton to the first N phases when ?phaseLimit=N is in the
URL. Lets us validate architecture cheaply on new suttas (DN22 etc)
without paying full compile cost. Unset = all phases.

Flow: parseSuttaRoute() in SuttaStudioApp.tsx parses param → passes to
compileSuttaStudioPacket → compiler logs the cap + truncates phaseSkeleton
before the phase loop.

Use: http://localhost:5180/sutta/dn22?lang=en&author=sujato&phaseLimit=4
   → compiles first 4 DN22 phases (~$0.08, ~3 min) instead of all ~50.

Next: cost-aware preview-and-confirm UX (per user request) that pauses
at phaseLimit, shows estimate for remaining phases, asks user to confirm
before continuing. This commit ships the underlying mechanism;
the UI layer is a follow-up.
Component types chapter as 'EnhancedChapter | null' but line 78 read
chapter.translationResult directly without optional chaining. Triggered
when navigating to /sutta/{uid} for a sutta not yet in IndexedDB — the
fallback renders briefly with chapter=null while the compile pipeline
warms up.

Reproducer: visit /sutta/dn22 fresh → TypeError 'Cannot read properties
of null (reading translationResult)' → blank page.

One-line fix: (chapter as any)?.translationResult — proper optional chain.
useLayoutEffect deps included leftPx, but the effect ALSO sets leftPx.
Each set triggered a re-measurement of the (now-shifted) tooltip, which
computed a different newLeftPx because the tooltip was no longer at its
centered position. Cycle: measure → setLeftPx → re-measure → setLeftPx → ...

Symptom: 'Maximum update depth exceeded' crash on the second phase's
PaliWord rendering. Reproduced reliably on /sutta/dn22?phaseLimit=4 once
phase-2 compiled and its tooltips tried to mount.

Fix: drop leftPx from deps. We still read it inside the effect for
change-detection (avoid redundant setState), but we don't trigger
re-runs from its own changes. Verified by chain: deps now are only
the inputs that should re-trigger clamp computation (text/facet/flipBelow).
…ass output

Bug: prior truncation was scoped inside the 'chunkPhases fallback' branch,
so when runSkeletonPass succeeded (the normal path on real suttas with LLM
phase detection), no truncation fired.

Symptom: ?phaseLimit=4 on DN22 still showed 'Phase 0/451 · 173m 48s'
because all ~50 LLM-detected DN22 phases were retained (and 451 in the
progress chip is likely a stale prior state from in-progress build).

Fix: move truncation OUTSIDE the if-branch — applies after either path
populates phaseSkeleton.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexicon-forge Ready Ready Preview, Comment May 15, 2026 1:52am

anantham added a commit that referenced this pull request May 15, 2026
… find

Three durable artifacts capturing the high-marginal-value synthesis from
this context that a fresh agent couldn't cheaply re-derive:

1. RESEARCH_RESULTS.md — Verified 11 URLs from the deep-research prompt.
   Headline find: edhamma/vism github repo has TEI XML Visuddhimagga with
   a pre-parsed glossary (vism/gloss.tei, 116 KB). Phase 4 collapses from
   6-10 hr to ~2 hr. Includes 6-step wiring plan + licensing caveat.

2. AMORTIZATION.md backlog updated:
   - Visuddhimagga moved from NOT YET INVESTIGATED → VERIFIED via Eudoxos
   - CPD, Pali Translation Project, HKU Papañcasūdanī, DharmaNexus/MITRA
     all annotated with current status (verified live, parked, or watch)

3. HANDOVER.md replaced — full session capture including:
   - 3 commits arc (GROUNDING + v12-b + DN22 pilot fixes + research)
   - PR #55 open status with 4 unmerged bug fixes
   - Smart-caching-across-suttas observation as Pending Thread #3
   - Resume instructions ranking (A) verify DN22 → (C) persistent cache
     → (B) Phase 4 via Eudoxos

The next agent reading these three docs has everything needed to continue
without re-derivation. Mechanical follow-on work (persistent cache, Vism
extraction, Path B continuation) can be done with 0 context.
@anantham anantham merged commit 0df7911 into main May 15, 2026
3 checks passed
anantham added a commit that referenced this pull request May 16, 2026
Synthesized from JSONL after the model that did the work hit "Prompt is
too long" trying to act on the final "yep go ahead" and /compact ran.

Replaces 2026-05-14 handover (whose three Continue-Immediately threads —
DN22 pilot, persistent segmentCache, GROUNDING Phase 4 — all merged
2026-05-15 via PRs #55/#56/#57).

This session's work captured here:
- 9 issues investigated + closed under the new §6a Verification Ladder
- §6a Verification Ladder protocol itself (L1-L5 with hard gate)
- InterleavedReader feature (issue #15 + #3 anomaly E) with L5 verification
- 22 commits on feat/opus-issues-investigation, PR #60 opened (MERGEABLE)
- Verbatim user-quote section preserved (JSONL is local-only)

Immediate pending task: CI test gate PR (user authorized "yep go ahead"
but model could not respond before compaction).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant