SW-01 transcript 持久化:ModelRouter prompt/response 落 SQLite - #8
Merged
Conversation
- transcripts 表对齐 Lab 仓 ADR-0001 §接口 (ts, caller, model, prompt, response, tokens_in, tokens_out, cost_usd, experiment_id) - 库路径默认 out/transcripts.db,NSC_TRANSCRIPT_DB / 构造参数可改道, 实验号 NSC_EXPERIMENT_ID(Lab subprocess 接线口) - best-effort:写库失败静默降级,不影响路由(同 _trace 模式) - 测试:tests/test_transcripts.py(3 例,stub litellm,无网络)
Owner
Author
|
Copilot review 已重试两次均返回 "encountered an error"(动态 reviewer 侧故障,非 PR 内容问题)。本地等价审查要点:改动仅 models.py 单点 + 3 例无网络测试;best-effort 写库(失败静默不影响路由);transcripts 独立库 out/transcripts.db,不触碰 cases.db 真相层。如需人工/重放 review 请再触发。 |
There was a problem hiding this comment.
🟡 Changes recommended
The transcript write path can still impact routing latency and robustness (SQLite lock timeout + missing rollback/connection reset on failures), which conflicts with the stated best-effort guarantees.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
Comment on lines
+82
to
+86
| try: | ||
| self.transcript_db.parent.mkdir(parents=True, exist_ok=True) | ||
| self._tconn = sqlite3.connect(str(self.transcript_db)) | ||
| self._tconn.execute(_TRANSCRIPT_SCHEMA) | ||
| self._tconn.commit() |
Comment on lines
+122
to
+123
| except Exception: | ||
| pass |
| assert len(rows) == 1 | ||
| row = rows[0] | ||
| assert row["caller"] == "tier_bulk" | ||
| assert row["model"] == "openai/LongCat-2.0" |
Owner
Author
Copilot 复审意见处理(3/3,commit 0c533f7)
本地 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这个 PR 改的是哪一层?(必选其一)
spec/profiles/brands/cases/export/)→ 必须打标签asset-change并附 ADRsrc/tests/)→ 无需 ADR工单
Closes # · 工单号:SW-01(上游依赖卡,Lab 仓 docs/WORK_ORDERS.md §上游依赖卡)
改动
src/nsc/runtime/models.py单点改动:ModelRouter.complete返回前把每次 LLM 调用的 prompt/response 写入 SQLitetranscripts表。表结构对齐 Lab 仓 ADR-0001 §接口:(ts, caller, model, prompt, response, tokens_in, tokens_out, cost_usd, experiment_id)。transcript_db> 环境变量NSC_TRANSCRIPT_DB> 默认out/transcripts.db(out/ 已 gitignore;Lab 经 subprocess 调 SW 时用环境变量接线)NSC_EXPERIMENT_ID或构造参数_traceLangfuse 模式一致)验收命令(贴出你本地跑通的输出)
注:
test_db_export_fresh在本机失败源于工作树里一份未提交的 cases/cases.db 本地改动(禁止提交,见运行纪律);在 origin/main 的干净 worktree 上该测试通过,本 PR 未触碰该文件,远端 CI 不受影响。检查表
TypeError: unexpected keyword argument 'experiment_id',实现后转绿)prompts/spec/BUDGETS.yaml预算内(runtime+checker 增 ~60 行,远低于 1600 上限)影响生成结果吗?