8000 fix(base): tier 1b of the stuck-pane sweep starved on two independent paths by simon-inkie · Pull Request #16 · simon-inkie/inkie-deck · GitHub
[go: up one dir, main page]

Skip to content

fix(base): tier 1b of the stuck-pane sweep starved on two independent paths - #16

Merged
simon-inkie merged 1 commit into
mainfrom
chore/port-stuck-sweep-starvation
Sep 4, 2026
Merged

simon-inkie merged 1 commit into
mainfrom
chore/port-stuck-sweep-starvation

Conversation

@simon-inkie
Copy link
Copy Markdown
Owner

Summary

Ports an internal fleet fix: the composer-pending tier (tier 1b) of stuck-pane-sweep.sh rode the whole-pane tick counter and escalation flag that every other tier uses, which starved it two independent ways:

  • Path A: the whole-pane hash resets on any background churn anywhere in the pane, so a pane with any such noise plus a genuinely stuck composer never met the tick floor, however long the composer sat unsubmitted.
  • Path B: the busy gate skipped the whole tier chain on any busy-classified read, so a pane reading busy on every tick was never asked either.

Fix: a second, composer-scoped tick counter (chash/cticks) that tier 1b gates on instead, consulted from inside the busy branch as well as after it, with its own dedupe flag (cescalated) so it can't be merged with the whole-pane escalated without reintroducing a wake-every-tick regression.

Notes

Ported from the internal deployment this package was extracted from; fleet-specific incident references, agent names and private document citations are not reproduced. One pre-existing test assertion was retargeted (escalated → cescalated for the composer-pending case, plus a new companion asserting escalated stays false), because that flag genuinely moved; the actual once-per-episode proof (send-keys count) is unchanged.

Test plan

  • node scripts/leak-gate.mjs clean
  • node scripts/licence-gate.mjs clean
  • stuck-pane-sweep.test.sh: 82 → 130 assertions, all pass
  • Revert-to-red against the pre-change script: 27 of the new assertions fail, all in the starving direction
  • Cross-checked unaffected suites: pane-idle (30/30), inbox-push (80/80), inbox (69/69), activity-sweep (84/84)

… paths

The composer-pending tier rode the whole-pane `ticks`/`escalated` bookkeeping
that every other tier uses, and that starved it two separate ways. Both end in
the same place: a pane holding genuinely unsubmitted composer text never
escalated at all, for as long as it sat there.

  PATH A. `ticks` resets whenever ANY byte of the pane changes, including
  background noise nowhere near the composer (a tool-call summary scrolling by,
  a spinner elsewhere in the transcript). A pane with any such churn never
  produced two consecutive identical whole-pane hashes, so the tick floor was
  never met however long the composer itself sat unsubmitted.

  PATH B. The busy gate skipped the whole tier chain on any busy-classified
  read, so a pane that reads busy on EVERY tick (a live elapsed counter, or a
  wholly static string that merely looks like one) was never asked either.

THE FIX. A second, composer-scoped tick counter: `chash` hashes the composer
line alone, `cticks` counts its own unchanged run, and tier 1b is gated on that
rather than on the whole-pane count. It is also consulted from INSIDE the busy
branch, before the `continue`, which is Path B. `ticks` and `escalated` are
untouched, so the model tier reads the whole-pane hash exactly as before: this
is a parallel counter, not a retiming of every tier at once.

`cescalated` RATHER THAN THE SHARED `escalated`, and that is the trap this
change would otherwise walk straight into. `escalated` resets on every
whole-pane hash change, so on a churning pane it reads "not yet escalated" on
every single tick; a composer-scoped tier deduping on it would wake somebody
every tick for ever, trading the starvation bug for a worse one. `cescalated` is
keyed on composer-hash stability instead. Named side effect: a pane that has
already taken a tier-1 wake this episode can take one further tier-1b wake for
the same wedge. Bounded at one, and independently informative.

The reduced state row written on a busy-with-no-finding tick now carries
chash/cticks/cescalated too. Without that, one such tick silently zeroes the new
counter on the next tick's comparison and re-starves the exact case Path B
exists to fix, by a third door.

WHAT A DEPLOYMENT SHOULD EXPECT TO SEE CHANGE:

  - A busy pane can now produce a finding. A genuinely busy long turn with a
    legitimately queued message staged across two or more ticks escalates once
    per episode. The reason string carries "busy=1" so whoever reads it can
    weigh "queued behind a long turn" before pressing anything. Report-only is
    still the default, and the model tier is still unreachable for a busy pane.
  - The main state row records the real busy classification instead of a
    hardcoded 0, because a pane reaching that row is no longer idle by
    construction.
  - chash/cticks/cescalated are ADDITIVE JSON fields; nothing in this repository
    reads the sweep's state file positionally or by field.
  - The first tick after upgrading is slightly MORE conservative, not less: a
    pre-change state file has no chash, so the composer counter restarts at 1
    and a pane already mid-episode waits one further tick. No migration needed,
    no crash.
  - One extra `capture-pane -e` per tick for a BUSY pane that has a non-empty
    composer candidate and has reached the tick floor. A busy pane with an empty
    composer still costs nothing extra.

TESTS: 82 -> 130 assertions. Every pre-existing case is unmodified except one,
whose subject genuinely moved: a composer episode now marks `cescalated`, so the
once-per-episode assertion follows the flag the tier actually rides, and the
send-keys count in that same case (the real proof of the property) is unchanged.
The new section covers Path A, the dedupe, Path B, both paths at once, the
busy-row persistence trap, a pre-change state file, and two controls proving the
new door into the busy branch did not widen what the tier fires on: an empty
composer is still nothing, and staged text with no raw capture is still no
evidence.

Revert-to-red against the pre-change script: 27 of the new assertions fail, each
one in the starving direction (tier "none" or absent where the fix reports
composer-pending).

Ported from the internal deployment this package was extracted from, and
genericised on the way: that change's fleet-specific incident references, agent
names and private document citations are not reproduced here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@simon-inkie
Copy link
Copy Markdown
Owner Author

Model-Diverse Peer Review: PR #16 (inkie-deck, commit e5b34fe)

Verdict: FULL APPROVAL


1. Audit of Ported Starvation Fix (packages/base/bin/stuck-pane-sweep.sh)

  • Starvation Path A Resolved (Whole-Pane Hash Churn):

    • Decouples Tier 1b from whole-pane hash churn by introducing the dedicated composer-scoped counter (chash, cticks, cescalated).
    • Unsubmitted composer text accumulates ticks reliably even when background output (spinners, live timers, streaming output) churns the whole-pane hash.
  • Starvation Path B Resolved (Busy-Gate Bypass):

    • Evaluates Tier 1b directly within the busy branch once cticks >= MIN_TICKS.
    • Fixes the bug where busy-classified panes were skipped entirely despite stranded composer text.
  • Traps Closed:

    • Dedup Trap: Independent cescalated flag prevents repeat wakes on whole-pane churn.
    • Busy-Row Persistence Trap: The reduced state row written during busy ticks retains chash, cticks, and cescalated, preventing intermittent busy ticks from resetting the composer counter.
    • Tier-Selection Guard (if [ -z "$source_tier" ]): Ensures a busy-branch Tier 1b hit cannot fall through to the model judge, keeping busy panes isolated from LLM classifier costs.

2. Test Verification

  • Executed packages/base/test/stuck-pane-sweep.test.sh: exactly 130 passed / 130 tests (clean pass).
  • Faithful, high-quality port of the internal fleet fix.

@simon-inkie
simon-inkie merged commit f5c7301 into main Sep 4, 2026
4 checks passed
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

0