fix(orchestrator): timestamp-based comment-walk for input-required (#35)#36
Open
nitzanvolman wants to merge 1 commit into
Open
fix(orchestrator): timestamp-based comment-walk for input-required (#35)#36nitzanvolman wants to merge 1 commit into
nitzanvolman wants to merge 1 commit into
Conversation
…novick#35) `recoverInputRequired` and `checkTrackerReplies` walked comments by array position, implicitly assuming chronological order. Linear's GraphQL `comments(first: 50, orderBy: createdAt)` returns newest-first, inverting the logic: the "last" 🤖 comment becomes the oldest in the array, and any non-🤖 comment in the issue's history is misread as a fresh user reply. `checkTrackerReplies` then deletes `state.InputRequiredIssues` and dispatches a "resumed" worker; `recoverInputRequired` returns nil for the same reason. Both safety paths fail simultaneously, producing the 49-loop documented in vnovick#35. Replace the index-walks with two helpers — `findLatestItervoxComment` and `firstReplyAfter` — that compare `domain.Comment.CreatedAt` timestamps. Result is correct regardless of whether the tracker returns comments ascending or descending, and conservatively skips comments with nil CreatedAt rather than mistreating them. Adds 9 whitebox tests in a new same-package file covering Linear-descending, GitHub-ascending, real user replies, nil CreatedAt, and the empty-comments edge case. The two descending-order regression cases failed against the previous logic and pass under the fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #35.
recoverInputRequiredandcheckTrackerReplies(internal/orchestrator/event_loop.go) walkeddetailed.Commentsby array position, implicitly assuming chronological order. Linear's GraphQLcomments(first: 50, orderBy: createdAt)(internal/tracker/linear/queries.go:53) returns comments newest-first by default. On Linear, the reverse-index walk finds the oldest 🤖 comment, then the forward walk traverses older comments — so any non-🤖 comment in the issue's history is misread as a fresh user reply.checkTrackerRepliesdeletes thestate.InputRequiredIssuesentry and dispatches a "resumed" worker;recoverInputRequiredreturns nil for the same reason. Both safety paths fail simultaneously, producing the 49-loop documented in the issue.Fix
Replace the two index-walks with helpers that compare
domain.Comment.CreatedAttimestamps:findLatestItervoxComment— scans the full slice, returns the index/CreatedAtof the most recently created 🤖-prefixed comment. No ordering assumption.firstReplyAfter(comments, t)— returns the body of the first non-🤖 comment withCreatedAt > t. Conservatively skips comments withnil CreatedAt.recoverInputRequiredandcheckTrackerRepliesare rewritten to use these helpers. Behaviour is correct on Linear (descending), GitHub (ascending), and any other ordering.Test plan
internal/orchestrator/event_loop_internal_test.go(9 cases): descending-order Linear-style with no reply, descending with reply, ascending with no reply, ascending with reply, no comments, nilCreatedAt, andcheckTrackerRepliesregression cases for both orderings.main'sevent_loop.goand pass under this fix.go test -race ./internal/orchestrator/...— greengo test -race -count=5 ./internal/orchestrator/...— green (no flakes)make verify— exit 0 (fmt, vet, golangci-lint, full Go race tests, web 45 files / 409 tests, spelling guard)Out of scope (follow-ups, not in this PR)
event_loop.go:967-973) has no retry; if the tracker rejects the comment, recovery still loses its anchor.worker.go:452runs before:461) can drop the input-required signal entirely for Codex when the sentinel isn't in the last 3 text blocks of the final agent message.🤖 Generated with Claude Code