Address review feedback from Bugbot and Macroscope

- Stop prepareMcpSession ending the active monitor on session start
  (session recycles no longer kill their own babysit)
- Fail closed at the wake send boundary: a failed fresh PR fetch discards
  the wake instead of falling back to the stale poll state
- Correlate provider.turn.start.failed releases by dispatch time and
  rewind wakeCount alongside the cursor
- Monotonic generation allocator; generation-conditional
  updateCursor/incrementWake/remove so stale polls can't mutate a
  newer monitor
- Dispatch thread.monitor.end before removing the registration in
  session teardown; end monitors on thread.archived
- Preserve wakeCount on idempotent monitor.start replay (breaker can't
  be reset)
- Key check-run cursors by head SHA + name + run id; detect
  resolved→unresolved thread reopens
- Human changes-requested reviews now block readiness
- Thread monitoringStartedAt from the registration so pre-existing
  unresolved threads don't block readiness forever
- Use the PR's base ref in the wake prompt instead of hard-coded main
- Boot reconcile: threads projecting "monitoring" with no registration
  are ended as session-ended

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Theo BrowneandClaude Fable 5 committed 2026-07-26 19:39:42 -07:00
1 parent f1185df227
commit e5ea2c65d2
17 files changed
+402 -60

No files matched your search

@@ -60,6 +60,7 @@ export interface PullRequestMonitorSnapshot {
readonly state: "open" | "closed" | "merged";
readonly draft: boolean;
readonly headSha: string;
readonly baseRefName: string;
readonly mergeability: "mergeable" | "conflicting" | "unknown";
readonly behindBaseBy: number | null;
readonly requiredChecksKnown: boolean;
@@ -107,6 +108,7 @@ const PullRequestPageSchema = Schema.Struct({
merged: Schema.Boolean,
mergeable: Schema.String,
headRefOid: Schema.String,
baseRefName: Schema.String,
reviews: Schema.Struct({
nodes: Schema.Array(ReviewSchema),
pageInfo: Schema.Struct({
@@ -259,10 +261,13 @@ export const getPullRequestMonitorSnapshot = Effect.fn("getPullRequestMonitorSna
let reviewsComplete = false;
let threadsComplete = false;
let metadata:
| Pick<PullRequestMonitorSnapshot, "state" | "draft" | "headSha" | "mergeability">
| Pick<
PullRequestMonitorSnapshot,
"state" | "draft" | "headSha" | "baseRefName" | "mergeability"
>
| undefined;
do {
const query = `query($owner:String!,$name:String!,$number:Int!,$reviews:String,$threads:String){repository(owner:$owner,name:$name){pullRequest(number:$number){state isDraft merged mergeable headRefOid reviews(first:100,after:$reviews){nodes{id author{login __typename} state submittedAt commit{oid}} pageInfo{hasNextPage endCursor}} reviewThreads(first:100,after:$threads){nodes{id isResolved comments(last:1){nodes{author{login __typename} body path line createdAt updatedAt}}} pageInfo{hasNextPage endCursor}}}}}`;
const query = `query($owner:String!,$name:String!,$number:Int!,$reviews:String,$threads:String){repository(owner:$owner,name:$name){pullRequest(number:$number){state isDraft merged mergeable headRefOid baseRefName reviews(first:100,after:$reviews){nodes{id author{login __typename} state submittedAt commit{oid}} pageInfo{hasNextPage endCursor}} reviewThreads(first:100,after:$threads){nodes{id isResolved comments(last:1){nodes{author{login __typename} body path line createdAt updatedAt}}} pageInfo{hasNextPage endCursor}}}}}`;
const result: VcsProcess.VcsProcessOutput = yield* github.execute({
cwd: input.cwd,
args: [
@@ -301,6 +306,7 @@ export const getPullRequestMonitorSnapshot = Effect.fn("getPullRequestMonitorSna
state: pr.merged ? "merged" : pr.state === "CLOSED" ? "closed" : "open",
draft: pr.isDraft,
headSha: pr.headRefOid,
baseRefName: pr.baseRefName,
mergeability:
pr.mergeable === "MERGEABLE"
? "mergeable"