Skip to content

fix(cat): break the bootstrap deadlock that would have kept @cat inert - #768

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/cat-account-bootstrap
Aug 26, 2026
Merged

fix(cat): break the bootstrap deadlock that would have kept @cat inert#768
github-actions[bot] merged 1 commit into
mainfrom
fix/cat-account-bootstrap

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

Caught by checking production rather than reading the code: the queue had deployed, and the Cat still had no account. Following it through, it never would have got one.

The circularity

resolveMentions can only flag @cat when a Cat profile exists → with no account, nothing is ever queued. And the worker called ensureCatAccount after its empty-queue early return → an empty queue established nothing.

nothing queued → nothing established → nothing queued

A freshly deployed platform would sit there with @cat resolving to nobody — looking exactly like a working feature nobody had used yet. Which is the worst kind of broken, because there's nothing to notice.

The worker now establishes the account before it looks at the queue. One primary-key lookup per tick when it's a no-op — every tick after the first — and the every-minute timer becomes what brings the Cat into existence.

The second half, in the timer

Persistent=true only replays a run missed while the machine was down. A timer enabled for the first time simply waits for the next OnCalendar — for a daily timer, up to 24 hours.

Production confirmed exactly that:

NEXT                            LEFT   LAST
Thu 2026-08-27 00:06:55 UTC     12h    -        orangecat-cron@cat-account.timer

Installed, enabled, never run, next run half a day away. OnActiveSec=1min makes a freshly deployed Cat exist within the minute.

Pinned so it can't be tidied back

The test asserts the ordering, not just that the call happens:

expect(order).toEqual(['ensure', 'claim']);

Proven by restoring the old arrangement — two tests go red, including "establishes the account even when the queue is empty".

Verification

  • npm run verify — exit 0 (2364 tests)
  • 5 new tests; deadlock reproduced and re-fixed to confirm they catch it

🤖 Generated with Claude Code

Caught by checking production rather than by reading the code: the queue
had deployed, and the Cat still had no account. Following that through,
it never would have got one.

The circularity: resolveMentions can only flag @cat when a Cat PROFILE
exists, so with no account nothing is ever queued — and the worker called
ensureCatAccount AFTER its empty-queue early return, so an empty queue
established nothing. Nothing queued, so nothing was established, so
nothing queued. A freshly deployed platform would sit there with @cat
resolving to nobody, looking exactly like a working feature that nobody
had used yet.

The worker now establishes the account before it looks at the queue. One
primary-key lookup per tick when it is a no-op, which is every tick after
the first, and the every-minute timer therefore becomes what brings the
Cat into existence.

Second half of the same bug, in the timer: `Persistent=true` only
replays a run MISSED while the machine was down. A timer enabled for the
first time just waits for the next OnCalendar — for a daily timer, up to
24 hours. Production confirmed it: the unit was installed and enabled,
LAST was "-", NEXT was 12 hours away. OnActiveSec=1min makes a freshly
deployed Cat exist within the minute.

Pinned by a test that asserts the ORDERING, not just the call, and proven
by restoring the old arrangement — two tests go red.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions
github-actions Bot merged commit 9036cb3 into main Aug 26, 2026
7 checks passed
@github-actions
github-actions Bot deleted the fix/cat-account-bootstrap branch August 26, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant