Repository navigation
Keep post-turn compaction pending while idle - #1542
Conversation
|
🚨 SLOP COP 🚨 · I am SlopCop. I am reviewing this pull request now. I will check security, code quality, performance, architecture, duplication, and relevant tests. I will post one final review after the checks finish. |
| // interruption settles it. | ||
| if ( | ||
| args.options?.threadStatus === "idle" && | ||
| args.state.threadInterruptedAt === null && |
There was a problem hiding this comment.
🚨 slopcop/review — A past interruption stops a later compaction
threadInterruptedAt records all prior interruptions and never clears. After any old interruption, this condition stays false for later turns. The finalizer then changes a valid later compaction from pending to interrupted. I reproduced this with interrupted turn A, completed turn B, and turn B compaction. Track the event order, and add a two-turn regression test.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
ELI5
The code remembers an old stop sign forever. It then stops a new cleanup job. It is like ending today’s game because yesterday’s game ended.
Finding
- Medium — An old interruption stops a later compaction.
threadInterruptedAtremains set after an earlier interruption. A later valid compaction then fails the new condition and becomes interrupted. I reproduced this with interrupted turn A, completed turn B, and turn B compaction. Track the event order, and add this two-turn regression test.
Review results
- The security and quality reviews found the same state defect.
- The performance review proposed a timer risk. The final gate rejected it because no production path proved repeated missing terminal events.
- The architecture scan found no duplicate compaction rule to reuse. The central finalizer is the correct location, but the condition needs interruption order.
- All 370
@bb/thread-viewtests passed. The Turbo type check, Prettier check, andgit diff --checkpassed. - The dev app loaded in Chromium without page errors. The clean dev database had no Pi event history, so the browser check could not reproduce this event sequence.
The GPT-5.6 review gate did not clear the change because of the medium defect. I posted this as a comment-only review.
Settle open compactions when the interruption event is processed instead of consulting sticky thread interruption state during finalization. This keeps later post-turn compactions pending and records the real interruption completion time. Builds on Michael Yong's original post-turn compaction fix in 1da548c.
1da548c to
f1efed2
Compare
Pi's threshold compaction runs after agent_end and attaches its contextCompaction item to the turn that just closed, with no second turn/completed (#1542). isRootTurnWorkItem counted it as root work, so every compacted pi thread flipped active and stayed there until a stop. Compaction is provider maintenance, not agent work; exclude it at the one shared rule so the server status, the daemon grammar, and the runtime active-turn state all agree. The server reopen check memoizes thread rows per event batch and evicts a row whenever the loop applies a lifecycle change, so root items on an active thread cost one lookup per thread rather than one per item. The root turn/started lookup is inlined because main removed the unused @bb/db helper in #2140. Co-Authored-By: Claude <[email protected]>
Summary
Testing
pnpm exec turbo run test --filter=@bb/thread-view --forcepnpm exec turbo run typecheck --filter=@bb/thread-viewpnpm exec prettier --check packages/thread-view/src/event-projection-state.ts packages/thread-view/test/timeline-interruption.test.tsgit diff --check