Skip to content

refactor(tts): isolate streaming directive text from provider discovery - #189504

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/speech-s26-directive-text-owner
Oct 31, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/speech-s26-directive-text-owner

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Related: #188252

What Problem This Solves

Streaming directive-text consumers import a module that also loads provider discovery, even though the cleaner only processes text.

User Impact

No intended behavior change. Partial directives, hidden text, code fences, captioned replies and ACP delivery retain their existing behavior. Provider-aware directive parsing and public SDK exports are unchanged.

Why This Change Was Made

Move the complete cleaner, its private helper/type and retirement note into the existing host-free directive-facts owner. Migrate every production import, delivery type and test spy directly; remove the former export without a forwarding layer. Keep provider-aware parsing in its existing module.

Move existing behavior cases with the implementation and add a cold-import check that fails if provider discovery is loaded. Production is line-neutral; tests add 22 lines, covered by a separate 22-line allocation. Moved code is not counted as savings, and no startup-speed claim is made.

Evidence

  • Complete source, caller and history audit; the ten affected paths remain unchanged or absent at pinned current-owner snapshot b1f4495c58aaa6dbc7f96422e9c33edd69293d16, so the intended cut is still needed.
  • Native formatting, whitespace and normal signed hooks passed. Fresh independent full-range review of 5e407f5384f97a69d12761b51e3e48c9e50030c5..9a0be6c333e8ea6360e0e9f861cf4f9df321ec2d found no actionable correctness or security findings (confidence 0.95).
  • Qualified focused execution passed 76 tests across six files: directive facts, directives, captioned-final, dispatch TTS streaming, ACP delivery and ACP custody (90.118 seconds, four shards).
  • Production types and the owning TTS/auto-reply test typegraphs passed. All three targeted typed-lint commands passed; native SDK declaration preparation completed.
  • The full required pnpm build passed in 373.803 seconds, including SDK/export and bundle checks. Exact reviewed source, HEAD and frozen dependency/native binding inputs remained unchanged through focused proof; build left source clean.
  • Broad exact-head PR CI and native review/security gates remain required before landing. No live-provider validation or measured latency/memory improvement is claimed.

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc vincentkoc self-assigned this Oct 31, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Moves streaming TTS directive cleanup into the existing provider-independent text module and updates its consumers.

Example: A reply streams Hello [[tts:voice=alloy]]world.

  • Before: The user sees Hello world, while the cleaner imports provider-discovery code.
  • After: The user still sees Hello world, with cleanup owned by the provider-independent text module.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-equivalent, while execution evidence remains thin.
Proof confidence 🦪 silver shellfish (2/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; supplied evidence establishes source equivalence but explicitly leaves runtime tests and build pending, and this review executed no target code.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Partial
User problem: No user-visible behavior change is intended; text-only cleanup currently depends on provider-aware module loading.
Reason: The maintainer-authored direction fits the linked campaign and establishes a concrete dependency boundary without adding production machinery or changing public contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it is a focused, maintainer-authored refactor with a complete caller cutover and no actionable correctness or security findings.

Priority: P3
Reviewed head: 9a0be6c333e8ea6360e0e9f861cf4f9df321ec2d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Execution of the cold-import contract, normal and ACP streaming consumers, caption cleanup, and the changed build topology remains unverified in the supplied evidence.
Agent review details

How this fits together

Normal and ACP reply dispatch and final-caption cleanup feed assistant text through the incremental cleaner; provider-aware directive resolution remains separate.

flowchart LR
  A[Assistant reply chunks] --> B[Normal and ACP dispatch]
  B --> C[Directive facts text cleaner]
  D[Final caption text] --> C
  C --> E[Visible channel text]
  F[Final speech facts] --> G[Provider aware resolver]
Loading

Technical review

Best possible solution:

Keep the direct move into directive-facts, preserving the existing cleaner and provider-aware SDK parser as separate responsibilities.

Do we have a high-confidence way to reproduce the issue?

This PR reports an import-boundary problem rather than a runtime bug; source confirms that main's streaming consumers import a module with a runtime provider-registry dependency.

Is this the best way to solve the issue?

The move is the smallest complete refactor: it reuses the existing text owner, preserves the implementation and regression cases, migrates all consumers, and leaves public provider parsing intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 01d404f68843.

Provenance checked

  • Streaming cleaner and marker retirement keeps the original intent (cf834e2: Hide speech directives across streamed blocks while retaining raw text for synthesis; subsequent delimiter, free-text, and code-literal repairs refine that contract.)
  • Provider-independent directive facts keeps the original intent (7a3f40c: Extract structured speech facts at the assistant write boundary and keep the streaming cleaner as a transitional adapter.)
  • Caption and dispatch consumer lifecycles keeps the original intent (b8f6086: Defer eligible final speech text for caption delivery while preserving fallback and delivery settlement.)

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 56eaffa adds src/tts/directives.ts:207 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 56eaffa43c27; files: src/tts/directives.ts)
  • Peter Steinberger: Raw commit 4a79987 adds src/tts/directives.ts:206 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4a799871c1a5; files: src/tts/directives.ts)

PR surface

Source 0, Tests +22, Other +2. Total +24 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 133 133 0
Tests 3 70 48 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 10 205 181 +24

Review metrics

Metric Value Why it matters
Production versus test LOC Production +133/−133; tests +70/−48, net +22. Production growth is a relocation; the additional test protects the distinct cold-import boundary and has a matching 22-line allocation.

Labels

Label changes:

  • add P3: This is behavior-preserving ownership cleanup without an established user-facing failure or urgent regression.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is behavior-preserving ownership cleanup without an established user-facing failure or urgent regression.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the focused directive, caption, normal-dispatch and ACP tests, targeted checks, test-line ratchet, and build on this head.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 31, 2026, 11:36 AM ET / 15:36 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review October 31, 2026 16:05
@vincentkoc
vincentkoc enabled auto-merge (squash) October 31, 2026 16:10
@vincentkoc
vincentkoc merged commit ec004ac into main Oct 31, 2026
214 checks passed
@vincentkoc
vincentkoc deleted the refactor/speech-s26-directive-text-owner branch October 31, 2026 16:15
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant