Conversation
|
Thank you so much for your attention and contribution! We will arrange an internal review for this PR shortly, and all feedback will be shared right here in the discussion. |
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
dac9c22 to
afe79a4
Compare
|
@Maxwell-Code07 Could a maintainer please approve the pending fork workflow for the refreshed head? Latest run: https://github.com/TencentCloud/TencentDB-Agent-Memory/actions/runs/33302053004 This PR supersedes #978 and is currently stacked on #1142. The two commits authored in this PR now carry DCO Local workflow-equivalent checks passed:
After #1142 merges, I will rebase this PR onto the refreshed |
yangjj-iso
left a comment
There was a problem hiding this comment.
概述:为 OpenCode 新增原生 TypeScript 插件适配器(非 Proxy 架构),同时在 MemoryCore 核心层引入 idempotency_key 幂等机制。+6907/-78,约 50 个文件,涵盖核心存储层幂等性、网关路由层、OpenCode 适配器(含安装脚本、测试、文档)。
必须更改(P1/P2)
P1 — 幂等路径丢失向量 Embedding
v2-router.ts 中,带 idempotency_key 的请求走 store.claimConversationAdd() 路径,该方法在 sqlite.ts 的 writeL0ForConversationAdmission 中只写入 L0 metadata + FTS,不写入向量索引。而非幂等路径调用 store.upsertL0(record, emb) 包含向量。
证据:
// 幂等路径 — 无 embedding
const claim = await store.claimConversationAdd!({ scope, payloadDigest, records: acceptedRecords, pipelineRounds });
// 非幂等路径 — 有 embedding
const emb = await embedding.embed(record.messageText);
await store.upsertL0(record, emb);
影响:启用了 Embedding 的部署中,通过幂等路径写入的 L0 记录将无法被向量搜索召回,仅 BM25 可用。需在 claim 成功后补算 embedding 并更新向量,或在 ClaimConversationAddInput 中增加 embedding 参数。
P2 — macOS/Linux 安装路径缺失
SELF_INSTALL.md 和 install-from-source.ps1 仅支持 Windows PowerShell。README 声称"adapter runtime supports macOS/Linux",USER_GUIDE 也说"those platforms must not copy the task's Windows steps yet",但没有提供 macOS/Linux 的替代安装路径。bin/tdai-opencode.mjs 本身是跨平台的(install/doctor/uninstall),应在文档中补充 macOS/Linux 用户使用 tdai-opencode install 的说明。
P2 — add-handler.ts 中 sessionChains Map 无清理
private readonly sessionChains = new Map<string, Promise>();
每个 session 的 key 加入后永不移除。长时间运行 + 大量 session 的进程中会持续增长。coordinator.ts 中的 sessionChains 有同样问题。建议在 promise 完成后删除已 settle 的 entry,或加 LRU 上限。
建议改进(P3)
add-handler.ts 第 297 行存在 pre-existing bug:instance_id: input.instance_id, instance_id: input.instance_id 重复字段。非本 PR 引入,建议顺手修复。
v2-schemas.ts 的 buildConversationIdempotencyScope() 是纯恒等函数(return { ...scope }),可移除或内联。
conversationAddRequestSchema 在 v2-schemas.ts 和 skill-schemas.ts 中重复定义且都加了相同的 idempotency_key regex,建议提取为共享常量。
capture.ts 的 completedTurns 对每个 index 调用 completedTurnAt,最坏 O(n²)。对长 session 可优化为单遍扫描,但典型场景可接受。
优点
幂等设计扎实:receipt + outbox + marker 三层恢复机制,SQLite 单事务原子保证(BEGIN IMMEDIATE),legacy processing 状态的 reclaim 逻辑非常严谨(校验 L0/FTS/vec/outbox scope 一致后才清理)。
测试覆盖全面:sqlite-idempotency.test.ts 519 行覆盖了 claim/replay/conflict/回滚/legacy recovery/FTS 清理/跨 scope 拒绝等边界;v2-router-idempotency.test.ts 覆盖了 503/409/pipeline 失败/unkeyed 保留等路由契约;adapter 侧有并发去重、跨进程 claim、重启恢复、e2e 等测试。
安全实践强:sanitize.ts 脱敏私有 key/bearer/credential URL/local path;format.ts 防止 recalled-block 注入;config 校验拒绝远程明文 HTTP 和 URL 内嵌凭证;installer 拒绝覆盖无关插件、切换 origin 时清除旧凭证。
fail-open 设计:Memory 故障不阻断 OpenCode 对话,失败写入保留在本地 outbox 等待恢复。
文档质量高:中英双语完整对称,含架构图、配置表、故障排查表、安全边界说明。
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
|
@yangjj-iso Thank you for the detailed review. I pushed commits Required changes
Suggested improvements
Validation
The live-Gateway E2E was not rerun because no Gateway was available at the local test endpoint. The fork workflow may still require maintainer approval. This PR remains stacked on #1142. Once #1142 is merged, I will rebase onto the latest Could you please take another look when convenient? Thank you. |
yangjj-iso
left a comment
There was a problem hiding this comment.
有 3 个阻塞问题:
- Skill 归档文件名不一致:返回 data-idem-*.jsonl,实际写入 data-.jsonl,任务会被当作 ghost 丢弃。
- OpenCode 始终发送 idempotency_key,但默认 TCVDB Store 不支持事务 claim,远程写入会直接返回 503。
- pending receipt 缺少恢复机制;通知失败或进程崩溃后,重试会直接返回成功,但不会重新通知 pipeline。
另外,Skill task ID 未包含 session,同一 idempotency key 跨 session 会冲突。请修复并补充对应回归测试后再合并。
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
|
已修复审查指出的 3 个阻塞问题。第 3 项原文还附带了 Skill task ID 跨 session 冲突,因此是 3 个编号、4 个修复点:
进一步按审查者视角复查后,又修复了这些恢复边界:
验证结果:
最新修复提交: |
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
Signed-off-by: diqierjia <jiahongcheng61@gmail.com>
|
@yangjj-iso I completed another reviewer-style pass after the previous approval and found one additional blocking concurrency gap plus one CI validation defect. Both are fixed in
Validation on the new head:
No package or lockfile changes and no new dependency in this follow-up. Could you please re-review the updated head when convenient? |
Supersession and dependency
Supersedes #978.
This PR carries forward the native OpenCode adapter from #978 and closes the accepted-write / local-ack crash window identified during review.
It is currently stacked on the unmerged Gateway idempotency implementation from #1142. The dependency commits retain their original authorship and will be removed after #1142 merges and this branch is rebased onto the refreshed
feat/server_team.Expected merge order:
feat/server_team.Summary
/v3/skill/conversation/add.503; unrelated503responses remain retryable failures.503while keyed pipeline notification or outbox acknowledgement remains pending, preserving the adapter's local retry state.Pipeline delivery is recoverable at-least-once. A crash after notification but before outbox acknowledgement can cause redelivery, so downstream consumers should deduplicate by the stable task or event identity.
Refs #926, #978, #1087, and #1142.
Validation
build:plugin: passed.pack:check: passed.node:fsprobe was correctly rejected.git diff --check: passed.The OpenCode adapter also retains the bilingual documentation, source-first installer, package checks, local Gateway contract test, and isolated real-host acceptance coverage documented in #978.
DCO note
All commits authored for this PR carry
Signed-off-bytrailers. The dependency commits retain their original #1142 authorship and will disappear from this PR after #1142 merges and this branch is rebased.