Skip to content

refactor(sutta-studio): consolidate LLM caller (PR B / Phase 3)#63

Open
anantham wants to merge 1 commit into
mainfrom
feat/opus-llm-caller-phase3
Open

refactor(sutta-studio): consolidate LLM caller (PR B / Phase 3)#63
anantham wants to merge 1 commit into
mainfrom
feat/opus-llm-caller-phase3

Conversation

@anantham
Copy link
Copy Markdown
Owner

Summary

  • Creates canonical `services/sutta-studio/llm.ts` — single source of truth for the Sutta Studio LLM caller
  • Converts `services/suttaStudioLLM.ts` and `services/compiler/llm.ts` to thin re-export shims (Phase 4 deletes them)
  • Updates `services/sutta-studio/passes/_defaultCaller.ts` + `types.ts` to import canonical directly
  • Updates CONSOLIDATION.md status header to reflect merged reality (per-phase table)

Why this PR exists

CONSOLIDATION.md and task tracking both marked Phase 3 complete after Phase 2 landed, but no `services/sutta-studio/llm.ts` ever existed and both legacy callers remained concrete with divergent signatures (compiler/llm.ts returned string; suttaStudioLLM.ts returned the richer `CompilerLLMResult` + supported `providerPreferences`). The 2026-05-16 doc audit (doc-audit skill, scoped to Sutta Studio) caught this and surfaced it as the only P0 finding — same failure mode as the schema divergence #62 fixed.

Behavior preservation

The legacy compiler/llm.ts contract returned `Promise`. Seven existing call sites (compiler/index.ts:394,490,529,571,596,646 + compiler/skeleton.ts:63) destructure it that way. To preserve that contract with zero call-site churn the shim aliases `callCompilerLLMText AS callCompilerLLM` — same string return, no behavioral delta. Those consumers move to the rich `CompilerLLMResult` signature when the orchestrator is ported (Phase 2d / PR D).

Test plan

  • `npx vitest run` — 1718 passed / 83 skipped / 0 failed
  • All TS errors are pre-existing on main; none touch the files modified here
  • Manual UI smoke (compile a sutta) — recommended before merging into a release cut, not blocking for refactor PR

Doc audit follow-ups (out of scope for this PR)

The 2026-05-16 audit surfaced additional P1 findings (CONSOLIDATION.md pass-order missing grounding step, SUTTA-007 ADR contradiction needing amendment, GROUNDING.md filename references wrong, FEATURES.md "Key Files" stale). Those should land in a separate doc-fix PR — scope discipline.

🤖 Generated with Claude Code

…ion (PR B / Phase 3)

CONSOLIDATION.md and task tracking both marked Phase 3 complete after Phase 2
landed, but no services/sutta-studio/llm.ts ever existed and both legacy callers
remained concrete and divergent. The 2026-05-16 doc audit (doc-audit skill,
scoped to Sutta Studio) caught this and surfaced it as the only P0 finding.

Same failure mode as the schema divergence that PR #62 fixed: phase marked
complete based on partial scope rather than completed work. This PR actually
closes Phase 3.

What landed:
- NEW services/sutta-studio/llm.ts: canonical caller, based on the richer
  suttaStudioLLM shape — exports CompilerLLMOptions / CompilerLLMResult types,
  passes providerPreferences through to chatJSON, and exposes both the rich
  callCompilerLLM (returns CompilerLLMResult) and a callCompilerLLMText helper.
- services/suttaStudioLLM.ts: thin re-export shim. Phase 4 deletes it.
- services/compiler/llm.ts: thin re-export shim that aliases
  callCompilerLLMText AS callCompilerLLM, preserving the legacy string-return
  contract for the 7 existing call sites in compiler/index.ts (lines 394, 490,
  529, 571, 596, 646) and compiler/skeleton.ts (line 63) with zero call-site
  churn. Those consumers move to the rich signature when the orchestrator is
  ported (Phase 2d / PR D).
- services/sutta-studio/passes/_defaultCaller.ts + passes/types.ts: imports
  updated to point at the canonical path instead of the (now-shim)
  suttaStudioLLM path.

CONSOLIDATION.md status header rewritten with a per-phase table reflecting
merged reality (Phases 0, 1, 2a, 2b, 2c, 3 done; 2d + 4 pending).

Tests: 1718 passed / 83 skipped / 0 failed (vitest, full suite).
Net diff: +78 / -320 (262 lines of duplication removed).

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

vercel Bot commented May 17, 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 17, 2026 1:49am

anantham added a commit that referenced this pull request May 17, 2026
* docs(sutta-studio): close 2026-05-16 audit P1 findings

The doc-audit skill scan of the Sutta Studio subsystem (2026-05-16, code hash
11e7bb2) surfaced one P0 (Phase 3 caller divergence — closed by PR #63) and
9 P1 findings. This PR closes 5 of those P1s. The remaining 4 are either
already addressed inline by PR #63's CONSOLIDATION.md status rewrite or are
larger structural follow-ups not appropriate to bundle here.

Fixes in this PR:

- GROUNDING.md §"File layout": corrected filenames to match reality —
  commentarialProvider → commentarialGlossProvider, translatorBankProvider →
  translatorBank, removed nonexistent urlMinter.ts (URL minting is inlined in
  services/providers/citationHelpers.ts), added types.ts entry, noted that
  translator-bank wires in separately, not via buildDefaultProviders.

- IR.md: replaced soft "staleness warning" with stronger SUPERSEDED banner.
  The 2026-03-05 verification date is 2.5 months stale; in the interim
  SUTTA-008 ratified Sense.epistemicBasis / sourceCitationIds / Provenance /
  ParallelRef / CompoundType and the grounding pass landed. New banner
  directs readers to types/suttaStudio.ts, FEATURES.md, SUTTA-008, TEXT_GRAPH.md
  rather than relying on the MVP schema as documentation.

- CONSOLIDATION.md §"What does NOT change": added Grounding step to the pass
  order. Earlier formulation omitted it because Grounding was inserted into
  the live compiler in 2026-05-14 (task #47), after CONSOLIDATION.md was
  originally drafted.

- SUTTA-007 ADR: added an Amendment section per CONVENTIONS.md §9. The
  original "should not be merged" claim was reversed by CONSOLIDATION.md,
  which merged the two stacks because operational experience showed silent
  drift at schema-contract and prompt-content boundaries. ADR is immutable,
  so the original text is preserved and the amendment explains the reversal +
  current state (both files are now shims).

- FEATURES.md §"Compiler Service" + §"Key Files Reference": rewrote to
  reflect the post-decomposition tree. The old §Compiler Service named a
  1900-line file that's been a 3-line shim since March 2026; the §Key Files
  table omitted the entire services/sutta-studio/ canonical layer + the
  grounding providers + the CONSOLIDATION/GROUNDING/SUTTA-008 docs.

Deferred to follow-up PRs:

- Quote-corner integrations of the audit's P2/P3 findings (naming
  inconsistency in grounding/translatorBank.ts, postPasses/syllabify.ts
  GAP coverage, archived-status header on assembly-line-roadmap.md and
  sutta-studio-case-studies.md, P3 component coverage gaps).

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

* docs(sutta-studio): mark SUTTA_STUDIO.md as historical, point at authoritative FEATURES.md

Per review feedback on PR #65: this file's own §Key Files Reference table
declared docs/sutta-studio/FEATURES.md as the authoritative architecture
doc, leaving the file the audit was editing in self-contradiction. Added
a top-of-file banner directing readers to the canonical doc.

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

---------

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