Skip to content

refactor(harness): persist on-demand audio analysis - #160

Merged
nanzhi84 merged 1 commit into
mainfrom
codex/issue-157-pr3-on-demand-audio-analysis
Aug 2, 2026
Merged

nanzhi84 merged 1 commit into
mainfrom
codex/issue-157-pr3-on-demand-audio-analysis

Conversation

@nanzhi84

@nanzhi84 nanzhi84 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • internalize beat, pause, and transcript analyzers behind visible Harness steps
  • persist immutable content-addressed analyses with normalized identities and cross-draft singleflight reuse
  • inject authoritative beat evidence for BGM insert and replacement, and ensure transcripts before read-only speech search
  • remove three analyzer schemas from the model tool surface and simplify obsolete live workflow cases

Acceptance

  • ordinary import creates no beat, pause, or transcript analysis
  • same content hash across distinct asset handles and drafts executes one analyzer and materializes draft-local transcript rows
  • BGM insert and replacement ignore model beat grids and project the persisted Harness result
  • Harness steps stream started/progress/finished metadata and persist across refresh

Local gates

  • make contracts
  • make test
  • make coverage: 90.2% handwritten
  • make lint: 0 issues
  • make vet-integration
  • make web: 232 tests passed, bundle within budget
  • make e2e: 9 tests passed

Part of #157 (PR 3/7).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86d3f9f075

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
}
}
if err := service.prepareOnDemandAudioAnalysis(ctx, draftID, name, input); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Honor the decision barrier before starting analysis

When a prior tool call in the same turn has created a blocking decision, prepareOnDemandAudioAnalysis still runs before beginToolCall checks blockingDecisionID. A subsequent speech.search or BGM mutation can therefore invoke paid ASR/media analysis, persist analysis/transcript rows, and emit successful Harness steps even though the tool is ultimately returned as waiting; concurrent provider tool calls make this scenario reachable. Acquire/check the turn barrier before performing these side effects.

Useful? React with 👍 / 👎.

Comment on lines +1351 to +1354
if cached, cacheErr := storage.LatestTranscript(ctx, exec.database.Read(), asset.ID); cacheErr == nil &&
(TranscriptHasWordSchema(cached.Utterances) || cached.ProviderID == "sidecar-srt" ||
exec.speechRecognizer == nil) {
return summarizeSpeechTranscript(cached, asset, true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate the analyzer identity before reusing a transcript

When an asset already has any word-schema transcript, this early return bypasses speechTranscriptAnalyzerVersion and the content-addressed identity lookup below. After changing the configured ASR model—or editing a sidecar SRT—the Harness therefore keeps serving the old transcript indefinitely, despite the new model/sidecar digest being intended to invalidate the cache; the model can no longer request speech.transcribe to refresh it. Reuse should be conditioned on an analysis matching the current analyzer identity.

Useful? React with 👍 / 👎.

@nanzhi84

nanzhi84 commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

内置浏览器与持久化验收通过

隔离栈:Web 15273 / API 18100 / Metrics 18102,独立 workspace 与 SQLite。

  • 启动日志中的模型目录为 16 tools / 16,972 runes;目录不含 audio.analyze_beats、audio.analyze_speech_pauses、speech.transcribe、timeline.check。
  • 卡点任务只要求插入 pr3_visual 与 pr3_bgm,模型未传 beat_grid。UI 可见 Harness 分析音乐节拍 ×2、检查时间线 ×2 与两次业务插入;BGM 最终持久化 beat_analysis_id=analysis_946d3d6b60776ae88fad7e47178b2f3a 及完整权威 beat grid。
  • SQLite:BGM 首次分析 219ms,后续插入与第二草稿均为 cache hit / 0ms;跨草稿仍只有 1 条 beat_grid。未使用的 pr3_ordinary 保持 0 条分析。
  • 刷新页面后 Harness 步骤、耗时、工具汇总和最终答复完整恢复。
  • speech.search 前由 Harness 自动执行 speech.transcribe,UI 返回 sidecar SRT 的句级帧证据并明确无词级时间戳;时间线未改变。SQLite 最终只有 1 条 transcript、1 条 speech pause,第二草稿转写 Harness 为 0ms。
  • 第二草稿能从 WorldState 直接回答 BPM=120.66、beat/downbeat/strong beat;证明持久化分析可跨草稿复用。
  • 浏览器 console:0 error(仅 Vite/React DevTools 与无 Core key 的预期 info)。

本地门禁:make contracts、make test(race)、make coverage(90.2%)、make lint(0 issues)、make vet-integration、make web(232 tests + build)、make e2e(9/9)全部通过。

CI run 30758579103:Go quality/contracts/coverage、macOS Go、Ubuntu Go、Web、Playwright 五项全部通过。

@nanzhi84
nanzhi84 merged commit 8ced309 into main Aug 2, 2026
5 checks passed
@nanzhi84
nanzhi84 deleted the codex/issue-157-pr3-on-demand-audio-analysis branch August 9, 2026 17:24
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