(content clusters continued across delta turns) and give the lane what it was
designed to receive — the host's own session-scoped message ids.
What was wrong with the premise: opencode 2.x was assumed to expose no host
ids ("weakest of the four host seams"). It does: ctx.session.hook("context")
fires immediately before EVERY provider-request assembly carrying the full
{ id, role, content }[] conversation plus sessionID (verified live on
@opencode/cli 2.0.4, anthropic AND openai-compatible providers). V1 keeps
its experimental.chat.messages.transform seam as before; both now feed one
per-session store. With real ids riding, byte-identical repeated prompts get
distinct vouched ids (msg_r1 vs msg_r2), so the server-side pin creates one
row per occurrence and the collision class of #5741 disappears at the root.
Changes:
- opencode-v2.ts: register the "context" hook in createOpencodeV2Setup
(shared by V1+V2 hosts; try/catch — hosts without the seam keep the
documented id-less degrade; never fail startup over it)
- opencode-msgids.ts: deriveEntry now proves BOTH event shapes onto the wire
1:1 with semantic part tokens (text bytes; tool call/result anchored by
provider tool-use id, not input bytes; reasoning↔thinking; media↔image);
host role "tool" normalizes to wire "user"; bookkeeping parts skip; ANY
unrecognized shape still drops the whole field (宁可降级不可错位)
- tests/opencode-msgids.test.ts: tool-session end-to-end through the V2 seam,
the #5741 repeated-prompt scenario (distinct fresh ids per occurrence),
reasoning/thinking alignment, unknown-part and duplicate-id degrade paths
Server side needed NO changes: the claimed-set validation and pin remap
landed with #5742/#5743 already. continueContentClusters stays as the
fallback path for hosts/turns without a usable harvest.
Verified: tsc --noEmit clean; opencode-incremental/msgids/rolling-marks,
incremental-content-clusters, msgid-pin/algebra/lane-flow, dsh/pi-msgids,
incremental-lane, issue5403 fastpath, pins-wire-id-mints all green.
(cherry picked from commit 2fa9dc47cc)
opencode-native.ts had the same claim-before-guard order as dsh/omp
(planIncrementalTurn with the harvested msgIds at :979, the #3378
single-flight guard below it). A guard-blocked turn burned its
harvested ids the same way; hoist the guard above the planning call.
alignedMsgIdsForWire() is a pure read of the harvest map, so it is
safe to keep inline in the (now post-guard) plan call.
Regression test mirrors the dsh one: blocked attempt must not burn
the ids; after the seed acks, the retry still pins them
(pre-fix: actual undefined).