Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
439cf2c
Keep failed sends visible in conversation on unary RPC transport errors
Fei2411 Dec 4, 2026
2977d47
Harden failed-send reconciliation, retry locking, and RPC delivery cl…
Fei2411 Dec 4, 2026
31173b5
Merge remote-tracking branch 'origin/dev' into fix/2299-rework-r2
Fei2411 Dec 4, 2026
e7210f1
Fix group rpcId receipts, legacy replay dedup, queue durability, send…
Fei2411 Dec 4, 2026
92d7ea6
Require durable requestId receipts, retry failed-send lazy chunk, and…
Fei2411 Dec 4, 2026
07d3b4f
Merge remote-tracking branch 'origin/dev' into fix/2299-rework-r2
Fei2411 Dec 4, 2026
5bbf720
Persist group ledger before inbox dequeue, unify ledger durability ev…
Fei2411 Dec 4, 2026
609fc66
Merge remote-tracking branch 'origin/dev' into fix/2299-rework-r5
Fei2411 Dec 5, 2026
e4a33f7
Hand off group inbox-to-ledger ownership atomically across DSH turns …
Fei2411 Dec 5, 2026
b45c381
Harden group inbox handover, pending dispatch recovery, and pre-step …
Fei2411 Dec 5, 2026
4e5832a
Merge origin/dev into fix/2299-rework-r5 and regenerate contracts
Fei2411 Dec 5, 2026
8006526
Merge remote-tracking branch 'origin/dev' into fix/2299-rework-r5
Fei2411 Dec 5, 2026
ec53081
Deduplicate ledger group dispatches on member receipt and persist sto…
Fei2411 Dec 5, 2026
d3de5df
Enforce cancellation and fail-closed receipt verification at group le…
Fei2411 Dec 5, 2026
ff2d62b
Harden parked room ledger wake recheck and add backoff retry for unre…
Fei2411 Dec 5, 2026
912e502
Release room ledger recovery claim and retry after opening round failure
Fei2411 Dec 5, 2026
89b74c3
Require persisted member receipt before marking group ledger dispatched
Fei2411 Dec 5, 2026
75d7ad0
Require persisted native user/message before room supersede or member…
Fei2411 Dec 5, 2026
8138b46
Share ledger dispatch identity and persist stop across provisional ro…
Fei2411 Dec 5, 2026
0736a27
fix(ds-bot): decouple room supersede from member dispatch and bind pe…
Fei2411 Dec 5, 2026
91e14da
fix(ds-bot): hand off orphaned roomInbox posts on native turn exit an…
Fei2411 Dec 5, 2026
db37d00
fix(ds-bot): guarantee ledger prompt text, persist before roomInbox d…
Fei2411 Dec 5, 2026
5f9b1bc
fix(ds-bot): reconstruct failed ledger handovers per session, persist…
Fei2411 Dec 5, 2026
5db17ab
fix(groups): reconstruct rolled-back native turns from persisted even…
Fei2411 Dec 5, 2026
57d3603
fix(groups): handle unstarted/unknown relay crashes with identity ded…
Fei2411 Dec 5, 2026
41bc542
fix(groups): recover unfinished async group_relay rounds per member a…
Fei2411 Dec 5, 2026
9d7c403
fix(groups): bind round ownership to exact anchors/identities and res…
Fei2411 Dec 5, 2026
87d9570
fix(groups): enforce per-message userIdentities over shared relay anchor
Fei2411 Dec 5, 2026
30951cc
fix(groups): preserve persisted session-reference snapshots across ro…
Fei2411 Dec 5, 2026
ba19e94
fix(groups): isolate reference rounds bidirectionally and resolve eve…
Fei2411 Dec 5, 2026
a01e1cb
fix(groups): enforce unified reference-round isolation across drainRo…
Fei2411 Dec 5, 2026
ca440f2
fix(groups): hand over orphaned laterPosts user entries when ledger r…
Fei2411 Dec 5, 2026
8586269
fix(groups): bind reconstructed laterPosts user entries in-place to p…
Fei2411 Dec 5, 2026
1d5d037
fix(groups): preserve bound laterPosts FIFO across consecutive openin…
Fei2411 Dec 5, 2026
9a31eb0
fix(groups): hold FIFO behind unready head and cancel in-flight Bot c…
Fei2411 Dec 5, 2026
8be78b9
fix(groups): hold partial head FIFO, abort opening before call creati…
Fei2411 Dec 5, 2026
85d9ab9
fix(groups): enforce pending-head barrier, drain bot-only suffix, and…
Fei2411 Dec 5, 2026
7c1652c
fix(ds-bot): enforce pending-head FIFO on postToRoom/holdForNextRound…
Fei2411 Dec 5, 2026
d742f7b
fix(ds-bot): guard partial in-flight heads, keep completed room claim…
Fei2411 Dec 5, 2026
d6dc092
fix(ds-bot): tighten room handoff admission, cold FIFO recovery, and …
Fei2411 Dec 6, 2026
2006932
fix(ds-bot): preserve in-flight and cold-rebuild room FIFO barriers a…
Fei2411 Dec 6, 2026
3d49a4c
fix(ds-bot): guard concurrent unpersisted rebuilds and abort mixed st…
Fei2411 Dec 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(ds-bot): tighten room handoff admission, cold FIFO recovery, and …
…pre-transcript stop cancellation
  • Loading branch information
Fei2411 committed Dec 6, 2026
commit d6dc0925821b71b14ff61278495652b7591a521d
37 changes: 24 additions & 13 deletions ds-bot/src/host/bot-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,19 @@ export function install(rt) {
return typeof current === 'string' && current !== '' && current !== sid
}

// A completed empty turn on a retired room part can be a `parts.js` handoff takeover
// (where the message was forwarded onto the replacement part and must be proven there),
// never permanent transcript proof on the superseded part.
const canTrustCompletedRoomClaims = (sid) => isRoomSessionId(sid) && !isSupersededPart(sid)

const hasSessionAdmission = (agent, ...ids) => {
const candidates = new Set(ids.filter(id => id !== undefined))
if (agent === undefined || candidates.size === 0) return false
for (const list of [agent.inbox?.nextStep ?? [], agent.inbox?.nextTurn ?? []]) {
if (list.some(msg => candidates.has(msg?.id) || candidates.has(msg?.source?.rpcId))) return true
}
const admitted = collectAdmittedIdsFromEvents(agent.session?.snapshotEvents?.(), undefined, {
includeCompletedRoomClaims: isRoomSessionId(agent.id),
includeCompletedRoomClaims: canTrustCompletedRoomClaims(agent.id),
})
return [...candidates].some(id => admitted.has(id))
}
Expand Down Expand Up @@ -428,7 +433,7 @@ export function install(rt) {
// evidence once earned.
const liveAdmissionKind = (sid, requestId) => {
if (typeof sid !== 'string' || sid === '' || requestId === undefined) return undefined
const includeCompletedRoomClaims = isRoomSessionId(sid)
const includeCompletedRoomClaims = canTrustCompletedRoomClaims(sid)
const inspectEvents = (events) => {
if (!Array.isArray(events)) return undefined
const claimed = new Set()
Expand All @@ -440,7 +445,7 @@ export function install(rt) {
))
if (userMessage) return 'userMessage'
if (includeCompletedRoomClaims && classifyAdmittedEvidence(events, { includeCompletedRoomClaims: true }).completedClaims.has(requestId)) {
return 'userMessage'
return 'inbox'
}
// Pending-in-inbox outranks the claim: both are reconstructed from the
// same splice history, so an id still pending is the durable shape.
Expand Down Expand Up @@ -557,8 +562,7 @@ export function install(rt) {
|| ev.data?.source?.rpcId === requestId
),
)
const includeCompletedRoomClaims = owner?.roomId !== undefined
const hasCompletedRoomClaimIn = events => includeCompletedRoomClaims
const hasCompletedRoomClaimIn = events => canTrustCompletedRoomClaims(sessionId)
&& classifyAdmittedEvidence(events, { includeCompletedRoomClaims: true }).completedClaims.has(requestId)
const hasUserMessageNow = () => hasUserMessageIn(session.snapshotEvents?.() ?? [])
// Inbox-only evidence acks durable only while the part is still live: if a part
Expand All @@ -572,10 +576,11 @@ export function install(rt) {
for (let pass = 0; pass < 4; pass += 1) {
if (hasPersistedRoomLedger()) return true
let before = session.snapshotEvents?.() ?? []
let hadUserMessageBeforeFlush = hasUserMessageIn(before) || hasCompletedRoomClaimIn(before)
const hadDurableInboxBeforeFlush = !hadUserMessageBeforeFlush
let hadUserMessageBeforeFlush = hasUserMessageIn(before)
const hadCompletedRoomClaimBeforeFlush = !hadUserMessageBeforeFlush && hasCompletedRoomClaimIn(before)
const hadDurableInboxBeforeFlush = !hadUserMessageBeforeFlush && !hadCompletedRoomClaimBeforeFlush
&& collectAdmittedIdsFromEvents(before).has(requestId)
if (!hadUserMessageBeforeFlush && !hadDurableInboxBeforeFlush) {
if (!hadUserMessageBeforeFlush && !hadCompletedRoomClaimBeforeFlush && !hadDurableInboxBeforeFlush) {
if (hasPersistedRoomLedger()) return true
if (agent === undefined || !isClaimedInTurn(agent, requestId)) return false
if (!(await waitForClaimedAdmission(sessionId, agent, requestId, hasUserMessageNow))) {
Expand All @@ -592,6 +597,12 @@ export function install(rt) {
noteLogicalAdmittedRpc(sessionId, requestId, { durable: true, userMessage: true })
return true
}
if (hadCompletedRoomClaimBeforeFlush) {
if (supersededWithInboxOnlyEvidence()) return false
noteSessionRpcDurability(sessionId, requestId, { durable: true, userMessage: false })
noteLogicalAdmittedRpc(sessionId, requestId, { durable: true, userMessage: false })
return true
}
if (hasPersistedRoomLedger()) return true
const after = session.snapshotEvents?.() ?? []
const spliceMutatedDuringFlush = after.length < beforeLen
Expand Down Expand Up @@ -823,7 +834,7 @@ export function install(rt) {
}
const session = ctx.sessions?.get?.(sid)
if (session !== undefined) {
if (collectAdmittedIdsFromEvents(session.snapshotEvents?.(), undefined, { includeCompletedRoomClaims: isRoomSessionId(sid) }).has(requestId)) {
if (collectAdmittedIdsFromEvents(session.snapshotEvents?.(), undefined, { includeCompletedRoomClaims: canTrustCompletedRoomClaims(sid) }).has(requestId)) {
noteAdmittedRpc(sid, requestId)
return { admitted: true, sessionId: sid, durable: false }
}
Expand Down Expand Up @@ -896,19 +907,19 @@ export function install(rt) {
if (meta.scoped !== false && readFailure === undefined) readFailure = read.error
continue
}
const classified = classifyAdmittedEvidence(read.events, { includeCompletedRoomClaims: isRoomSessionId(sid) })
const classified = classifyAdmittedEvidence(read.events, { includeCompletedRoomClaims: canTrustCompletedRoomClaims(sid) })
const foundIds = classified.admitted
const isPersisted = read.persisted === true
if (meta.immutable && read.status === 'ok' && isPersisted) {
const entries = new Map()
for (const id of foundIds) entries.set(id, { userMessage: classified.userMessages.has(id) || classified.completedClaims.has(id) })
for (const id of foundIds) entries.set(id, { userMessage: classified.userMessages.has(id) })
inspectedSettledSessionRpcIds.set(sid, entries)
while (inspectedSettledSessionRpcIds.size > MAX_INSPECTED_SESSIONS) {
inspectedSettledSessionRpcIds.delete(inspectedSettledSessionRpcIds.keys().next().value)
}
}
if (foundIds.has(requestId)) {
const userMessage = classified.userMessages.has(requestId) || classified.completedClaims.has(requestId)
const userMessage = classified.userMessages.has(requestId)
const durable = isPersisted && durableOnColdPart(sid, userMessage)
noteAdmittedRpc(sid, requestId, { durable, userMessage })
return { admitted: true, sessionId: sid, durable, userMessage }
Expand All @@ -926,7 +937,7 @@ export function install(rt) {
return { admitted: true, sessionId: sid, durable: false }
}
const attachedSession = ctx.sessions?.get?.(sid)
if (attachedSession !== undefined && collectAdmittedIdsFromEvents(attachedSession.snapshotEvents?.(), undefined, { includeCompletedRoomClaims: isRoomSessionId(sid) }).has(requestId)) {
if (attachedSession !== undefined && collectAdmittedIdsFromEvents(attachedSession.snapshotEvents?.(), undefined, { includeCompletedRoomClaims: canTrustCompletedRoomClaims(sid) }).has(requestId)) {
noteAdmittedRpc(sid, requestId)
return { admitted: true, sessionId: sid, durable: false }
}
Expand Down
17 changes: 10 additions & 7 deletions ds-bot/src/host/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2162,15 +2162,16 @@ export function install(rt) {
}
if (typeof session?.snapshotEvents === 'function') {
const evState = eventsHaveRequestState(session.snapshotEvents(), requestId)
const hasUserMessage = evState.hasUserMessage || (isRoomSession(sid) && evState.hasCompletedRoomClaim)
const hasUserMessage = evState.hasUserMessage
const hasCompletedRoomClaim = isRoomSession(sid) && !isSupersededPart(sid) && evState.hasCompletedRoomClaim
hasPendingInbox = hasPendingInbox || evState.hasPendingInbox
const hasClaimed = agent?.status === 'running' && evState.hasClaimed && !hasUserMessage && !hasPendingInbox
const hasClaimed = agent?.status === 'running' && evState.hasClaimed && !hasUserMessage && !hasPendingInbox && !hasCompletedRoomClaim
return {
live: true,
hasUserMessage,
hasPendingInbox,
hasClaimed,
hasEvidence: hasUserMessage || hasPendingInbox || hasClaimed,
hasEvidence: hasUserMessage || hasPendingInbox || hasClaimed || hasCompletedRoomClaim,
}
}
let hasUserMessage = false
Expand Down Expand Up @@ -2410,8 +2411,9 @@ export function install(rt) {
const read = await rt.readSessionEvidence(sid, AbortSignal.timeout(5000), { preferPersisted: true })
if (read?.status === 'ok' && read.persisted === true) {
const disk = eventsHaveRequestState(read.events, confirmedRequestId)
const hasTranscript = disk.hasUserMessage || (isRoomSession(sid) && disk.hasCompletedRoomClaim)
if (hasTranscript || (disk.hasPendingInbox && !isSupersededPart(sid))) {
const hasTranscript = disk.hasUserMessage
const hasLivePartEvidence = (disk.hasPendingInbox || (isRoomSession(sid) && disk.hasCompletedRoomClaim)) && !isSupersededPart(sid)
if (hasTranscript || hasLivePartEvidence) {
rt.noteAdmittedRpc?.(sid, confirmedRequestId, { durable: true, userMessage: hasTranscript })
return recordConfirmed(sid, hasTranscript)
}
Expand All @@ -2431,8 +2433,9 @@ export function install(rt) {
const recheck = await rt.readSessionEvidence(sid, AbortSignal.timeout(5000), { preferPersisted: true })
if (recheck?.status === 'ok' && recheck.persisted === true) {
const disk = eventsHaveRequestState(recheck.events, confirmedRequestId)
const hasTranscript = disk.hasUserMessage || (isRoomSession(sid) && disk.hasCompletedRoomClaim)
if (hasTranscript || (disk.hasPendingInbox && !isSupersededPart(sid))) {
const hasTranscript = disk.hasUserMessage
const hasLivePartEvidence = (disk.hasPendingInbox || (isRoomSession(sid) && disk.hasCompletedRoomClaim)) && !isSupersededPart(sid)
if (hasTranscript || hasLivePartEvidence) {
rt.noteAdmittedRpc?.(sid, confirmedRequestId, { durable: true, userMessage: hasTranscript })
return recordConfirmed(sid, hasTranscript)
}
Expand Down
Loading
Loading