feat(polish): add context safeguards, layered prompts, and output validation

Use redacted cursor neighborhood and pause-aware chunks for more natural polish,
validate protected terms with retry/local fallback, and structure bilingual prompts
for consistency and provider prefix caching.
This commit is contained in:
Rocky
2026-07-29 17:45:11 +08:00
parent 2d44423f4c
commit 34be2e8dd1
40 changed files with 1827 additions and 183 deletions
@@ -24,6 +24,14 @@ final class UtteranceStreamChunkerTests: XCTestCase {
XCTAssertLessThanOrEqual(split, config.maxChunkSamples + config.pauseExtensionSamples)
}
func testPauseAwareSplitReportsPauseDuration() {
var buffer = [Float](repeating: 0.2, count: config.maxChunkSamples)
buffer.append(contentsOf: [Float](repeating: 0.001, count: 200))
let result = UtteranceStreamChunker.pauseAwareSplit(in: buffer, config: config)
XCTAssertGreaterThan(result.pauseSamples, 0)
XCTAssertGreaterThan(result.index, config.maxChunkSamples)
}
func testFirstChunkUsesShorterWindow() async {
let config = FlowUtteranceChunkConfig(
firstChunkDurationSeconds: 0.5,