fix(core): drop stale dag node terminal events via db status cross-check - #133
Merged
Conversation
Loop handlers for NodeCompleted/NodeSkipped/NodeFailed now confirm the node row still reflects the event's terminal status before touching fibers or runtime state, so events from a previous generation (after NodeRestarted/replan) are dropped. Schema capture validation additionally enforces const/enum via structural equality.
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.
What
Generation arbitration for DAG node terminal events, using the DB row as source of truth (projection is transactional with publish):
loop.ts: NodeCompleted/NodeSkipped handlers now cross-check the node row still matches the event's terminal status before deleting fibers or settling runtime state — mirroring and extending the NodeFailed guard. NodeFailed additionally requiresstatus === "failed"before aborting the child, so a stale failure event after NodeRestarted/replan cannot kill the new generation's fiber.capture.ts:validateAgainstSchemanow enforcesconst/enumvia structural deepEqual (JSON.stringify is key-order-sensitive).Tests
test/dag/dag-replan-stale-nodefailed.test.tscovering the stale-event drop pathspackages/opencode/test/dag/: 261 pass / 0 fail locally