Skip to content

Wire V2 amendments into live compiler (activates 2d198f6)#50

Closed
anantham wants to merge 3 commits into
feat/opus-batch4-curationfrom
feat/opus-v2-pipeline-wire
Closed

Wire V2 amendments into live compiler (activates 2d198f6)#50
anantham wants to merge 3 commits into
feat/opus-batch4-curationfrom
feat/opus-v2-pipeline-wire

Conversation

@anantham
Copy link
Copy Markdown
Owner

Summary

Activates the V2 prompt overlay shipped in 2d198f6 (PR #49). Until this PR, the v2 amendments were a standalone module imported nowhere — protocol learnings codified but not delivered to the LLM at compile time.

Base note: Stacked on #49 (batch-4). GitHub will auto-rebase to main as #48#49 → this merge.

Commits

  1. b99828eWire SUTTA_STUDIO_V2_AMENDMENTS into 3 passes

    • Anatomist: ARROW_EARNING_RULE + TOOLTIP_REGISTER + ANCHOR (relations, tooltips, isAnchor)
    • Lexicographer: SENSE_METADATA + TRANSLATOR_DEBATE (epistemicBasis, sourceCitationIds, confidence, multi-sense)
    • Phase: full overlay (comprehensive pass)

    Injected after v1 pass-specific context, before per-phase state envelope. Skeleton/Weaver/Morphology/Typesetter unchanged — their concerns don't intersect with V2 additions. Unconditional wiring (no feature flag); amendments codify ratified protocol, not experiments.

  2. d0b6b06Bump SUTTA_STUDIO_PROMPT_VERSION → v11-mn10-amendments
    Tracks the wiring in benchmark-comparison version key. v10 vs v11 outputs in the leaderboard will surface quality deltas attributable to the amendments.

Target file note

Wired into services/suttaStudioPassPrompts.ts (LIVE prompt builder, called by suttaStudioPassRunners.ts). Prior planning docs referenced services/compiler/prompts.ts but that file has zero imports — appears orphaned. Dead-code cleanup tracked as a follow-up.

What this PR does NOT do

  • No prompt caching yet. Deferred until A2 (this PR's actual test on phase-2) confirms v2 amendments lift quality. Premature optimization avoided.
  • No post-processing passes. Tracked separately. Will be evaluated after A2.
  • No automatic re-compile of existing fixtures. The hand-curated demoPacket.json is unchanged. To see v11 output, the compiler must be run anew.

Test plan

  • A2 (the real test): run the compiler on phase-2 of MN10 (sattānaṁ visuddhiyā). Compare output to the v1 baseline and to the projected hand-curation diff documented in COMPILER_STRATEGY.md §2.
  • Decision: if v11 output reaches ~65% of hand-curation quality → proceed to post-passes (A3). If underwhelms → revert this PR and stay on hand-curation.
  • Sanity: confirm prompt-length budget still fits within model context (the V2 amendments add ~3000 tokens to each amended pass; should be well within all supported models).

References

🤖 Generated with Claude Code

anantham and others added 2 commits May 13, 2026 15:46
…mpt builders

Activates the v2 prompt overlay shipped in 2d198f6. Until now the overlay
was a standalone module imported nowhere — protocol learnings codified but
not delivered to the LLM at compile time. This commit appends the 6
amendment blocks to the three passes that produce structured semantic
content:

  - buildAnatomistPrompt    — receives ARROW_EARNING_RULE + TOOLTIP_REGISTER
                              + ANCHOR (relations / tooltips / isAnchor)
  - buildLexicographerPrompt — receives SENSE_METADATA + TRANSLATOR_DEBATE
                              (epistemicBasis / sourceCitationIds / confidence
                              / multi-sense curatorial pattern)
  - buildPhasePrompt        — receives the full overlay (comprehensive pass)

The amendments are injected AFTER the v1 pass-specific context and BEFORE
the per-phase state envelope, so the LLM sees: base → v1 pass guidance →
v2 amendments (the new learnings) → current phase state → task.

Skeleton / Weaver / Morphology / Typesetter passes are NOT amended —
their concerns (phase grouping, English↔Pāli mapping, morph hints,
layout blocks) don't intersect with the V2 protocol additions.

The amendments are baked in unconditionally (no feature flag). They
codify protocol the curation logs have already ratified — they're not
experimental. If a future regression is detected, revert this commit
or comment out the import.

Target file note:
  Wired into services/suttaStudioPassPrompts.ts (the LIVE prompt builder,
  called by services/suttaStudioPassRunners.ts). Prior planning docs
  referenced services/compiler/prompts.ts but that file has zero imports
  — appears to be orphaned. Tracked as a follow-up cleanup task.

Verification:
  - No existing tests cover these builders directly (they're pure string
    builders); the real test is A2 — run the compiler on phase-2 and diff
    against expected hand-curation. See COMPILER_STRATEGY.md §5.
  - Type safety: import path matches the existing v1 context import; the
    V2 module is shipped in 2d198f6 and exports SUTTA_STUDIO_V2_AMENDMENTS.

Companion to:
  - 2d198f6 (the V2 overlay module — staged previously, now active)
  - docs/sutta-studio/COMPILER_STRATEGY.md §2 (pipeline-vs-hand matrix)
  - PR #49 (batch-4 — where the overlay was first shipped)

Next: phase-2 compile run to empirically test v2 quality (~$1-3 API).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ndments

Tracks the v2-amendments wiring (b99828e) in the benchmark-comparison
version key. Future quality-scorer runs against benchmark fixtures will
distinguish v10 (pre-amendment) vs v11 (post-amendment) outputs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 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 13, 2026 7:50pm

The prior commit (b99828e) wired V2 into services/suttaStudioPassPrompts.ts
on the assumption that services/compiler/prompts.ts was dead code (its
direct grep on "compiler/prompts" returned no hits). That assumption was
wrong.

The actual architecture:
  Production UI compile path:
    SuttaStudioApp.tsx:395
      → services/suttaStudioCompiler.ts (re-export)
        → services/compiler/index.ts (compileSuttaStudioPacket)
          → services/compiler/prompts.ts (buildAnatomistPrompt, etc.)
            ← THIS FILE — the one users actually hit.

  Benchmark CLI path:
    scripts/sutta-studio/benchmark.ts
      → services/suttaStudioPassRunners.ts
        → services/suttaStudioPassPrompts.ts
          ← The file b99828e wired V2 into. Used by benchmarks only.

Without this commit, clicking "compile" in the UI would still use the v10
prompts. Only benchmark runs would see v11. This commit closes that gap by
also injecting SUTTA_STUDIO_V2_AMENDMENTS into the production builder
(buildAnatomistPrompt, buildLexicographerPrompt, buildPhasePrompt in
services/compiler/prompts.ts).

Architectural finding worth flagging (tracked as a follow-up):
  The two prompt builders have DIVERGED. Benchmark has additional
  anatomist examples (B + REFRAIN) and a lexico ripple example that
  production lacks. This means benchmark quality scores may overstate
  what production users actually see. Consolidate into a single
  source-of-truth in a follow-up — too out-of-scope for this PR.

Verification path unchanged: A2 runs the compiler on phase-2 (via either
UI or benchmark CLI) and compares output against hand-curation. With this
commit, both paths receive v11 prompts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
anantham added a commit that referenced this pull request May 13, 2026
…o services/sutta-studio/prompts/

Per CONSOLIDATION.md (dc57a63). The two parallel compiler stacks
(services/compiler/ and services/suttaStudio*) had drifted: each had its
own prompt builders that diverged on examples, parameters, and which
features were supported. As of PR #50 they were briefly aligned on V2
amendments — this commit locks in the alignment by establishing a SINGLE
SOURCE OF TRUTH.

NEW canonical location:
  services/sutta-studio/prompts/
    skeleton.ts        — buildSkeletonPrompt
    anatomist.ts       — buildAnatomistPrompt (3 examples, V2 amendments)
    lexicographer.ts   — buildLexicographerPrompt (DPD context + ripples + V2)
    weaver.ts          — buildWeaverPrompt (with ANTI_PATTERN guard)
    typesetter.ts      — buildTypesetterPrompt (optional logger injection)
    morphology.ts      — buildMorphologyPrompt
    phase.ts           — buildPhasePrompt (full V2 overlay)
    index.ts           — barrel

Merge decisions (best-of-both for each pass):
  Anatomist: take benchmark's 3 examples (PHASE_A + PHASE_B + REFRAIN)
    rather than production's single example. The phase-b morph-data
    example and the refrain-formula example are pedagogically critical.
  Lexicographer: KEEP production's DPD context + renderDpdBlock helper
    AND benchmark's RIPPLES instruction block + ripple example. Neither
    stack had both. Merged here.
  Weaver: take benchmark's version with DUPLICATE-MAPPING rule + the
    SUTTA_STUDIO_WEAVER_ANTI_PATTERN reference. Production lacked these.
  Typesetter: take benchmark's optional logger param (vs production's
    inline log() spamming every call). Defaults to no-op.
  Skeleton / Morphology / Phase: byte-identical between stacks; no
    merge needed beyond moving.

V2 amendments wired into THREE passes (Anatomist, Lexicographer, Phase) —
one place, not two. Future protocol amendments land in one place.

OLD files become re-export shims:
  services/compiler/prompts.ts        382L → 24L re-export shim
  services/suttaStudioPassPrompts.ts  725L → 528L (schemas/types/parseJsonResponse
                                       kept inline pending Phase 2; only the 7
                                       builder functions removed, replaced by
                                       re-exports from the new canonical path)

Consumers don't change:
  - services/compiler/index.ts continues to import from './prompts'
  - services/suttaStudioPassRunners.ts continues to import from './suttaStudioPassPrompts'
  - scripts/sutta-studio/benchmark.ts continues to import from suttaStudioPassPrompts
  All those imports now resolve through the shims to the canonical builders.

Verification:
  - npx tsc --noEmit -p . — ZERO errors in the touched files (all reported
    errors are pre-existing TS strictness issues in unrelated files:
    AboutThisText.tsx React namespace, build-dpd.ts better-sqlite3 type,
    smoke-real-fojin.ts playwright export, etc.)
  - npx vitest run — 1332 passed, 16 skipped, 0 functional failures.
    Single failure is build-dpd.test.ts because main's node_modules
    (symlinked for the test run) lacks better-sqlite3 — that package
    was added on the not-yet-merged batch-3 branch. Unrelated to refactor.

What this commit does NOT do (deferred per CONSOLIDATION.md):
  - DOES NOT consolidate schemas. compiler/schemas.ts and the schemas in
    suttaStudioPassPrompts.ts still differ on skeleton.wordRange and
    anatomist.refrainId fields (Phase 2).
  - DOES NOT consolidate the duplicated buildPhaseStateEnvelope or
    buildBoundaryContext functions (still byte-identical duplicates,
    Phase 2 cleans up alongside pass runner consolidation).
  - DOES NOT consolidate the parseJsonResponse helper (also duplicated;
    Phase 2).
  - DOES NOT change LLM-visible prompt content. The V2-amended Anatomist /
    Lexicographer / Phase prompts produce the exact same string as PR #50
    (currently paused) would. Benchmark output should be byte-identical
    pre/post this commit.
  - DOES NOT bump SUTTA_STUDIO_PROMPT_VERSION. Content unchanged means
    no benchmark cache invalidation. Phase 4 will bump if needed.

Companion to:
  - docs/sutta-studio/CONSOLIDATION.md (dc57a63) — full design doc
  - PR #50 paused — its V2-wire commits become redundant once this lands

Next: Phase 2 — canonical pass functions in services/sutta-studio/passes/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@anantham
Copy link
Copy Markdown
Owner Author

Closing — the goal of this PR (V2 amendments active in the production compiler) is now achieved transitively through PR #51 (compiler consolidation). The canonical prompt builders at services/sutta-studio/prompts/ have V2 amendments wired in exactly once, and the old paths are re-export shims, so production picks them up automatically. The dual-wire approach this PR took (V2 into both compiler/prompts.ts and suttaStudioPassPrompts.ts) is no longer needed.

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