fix(lifecycle): T3 history compaction no longer stalls lifecycle tracking
T3 Code's history compaction (pingdotgg/t3code#19435) deletes events that a newer event of the same thread supersedes. If the event the lifecycle reader saved as its anchor was one of them, every later reconcile threw "source history changed" and lifecycle state froze until repaired by hand. Compaction runs a minute after T3 starts and every six hours.
Fix: when the saved anchor's row is missing, the reader looks its event id up anywhere in the table. Not found means compaction deleted it, so tracking continues. Found at another sequence, a different event at the saved sequence, or a lower watermark still fail as a rewrite. event_id is UNIQUE in T3's event tables, so the lookup is indexed, and it only runs when the anchor is missing. One limit: a rebuilt database that lacks the saved event and has a higher watermark looks like a compaction.
Docs: orchestration_events is the table for T3 0.1.0 and later (orchestration_v2_events stays accepted for earlier releases); one non-GitHub link on a thread makes pr-sessions exit 1 for the whole project; Muse and Pi are listed with what Swarmail does for them today. CHANGELOG has an Unreleased entry.
Verification:
- New test "a saved anchor deleted by T3 history compaction does not stop tracking" fails on the old code (
status: "unavailable") and passes with the fix; the source-failure test gains a case where the anchor moves to another sequence. bun run checkandbun test(1293 pass, 0 fail) pass.
Summary by cubic
T3 Code's history compaction deletes events that a newer event of the same thread supersedes, which could remove the event the lifecycle reader used as its reconcile anchor and freeze lifecycle tracking with "source history changed". The reader now treats a missing saved anchor as a deletion when its event id appears nowhere else in the table; the anchor at another sequence, a different event at the saved sequence, or a lower watermark still fail as a rewrite.
The lookup only runs when the anchor is missing and uses the indexed event_id column. Docs now specify orchestration_events for T3 Code 0.1.0 and later, note that one non-GitHub link makes pr-sessions exit 1 for the whole project, and list what Swarmail does for T3's Muse and Pi providers.
Summary by CodeRabbit
-
Bug Fixes
- Lifecycle tracking now continues after a saved event is removed through compaction, while still preserving the last verified state when event history changes unexpectedly or moves backward.
- Pull request lookups now fail for the project if any linked pull request uses a non-GitHub host.
-
Documentation
- Clarified T3 Code event history guidance by version and added provider coverage details for Muse and Pi.