Skip to content

Promote stage to bkt3: plan supersession (#317) and Claude account revive queue (#322) - #324

Merged
bk-agent-01 merged 25 commits into
bkmainfrom
promote/stage-2026-10-17
Oct 19, 2026
Merged

bk-agent-01 merged 25 commits into
bkmainfrom
promote/stage-2026-10-17

Conversation

@bk-agent-01

@bk-agent-01 bk-agent-01 commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Update 2026-10-19: On Tushar's instruction, the latest bkmain (b7af1e60) was merged into stage first (#327, no conflicts). stagebkt3 serves that result (a26a040f) since 12:34 UTC. This PR's head is now a26a040f. Against bkmain it still changes only the stage-only work below (43 files, +2430 / −171). The #325 freeze fix is also on stage, and its content is already in bkmain through #326.

Summary

This PR promotes the full stage branch (now a26a040f) to bkmain, on Tushar's instruction of 2026-10-17 ("merge full stage to bkmain"). It replaces #323, which carried only the Claude account commits. stage merges into bkmain with no conflicts. The bkmain-only commits (#296 to #318, #321) stay as they are.

Stage merges this PR carries

Stage PR What Already in bkmain? Code that the merge changes
#317 Only the newest plan stays actionable: one active plan per thread, a new turn ends the open plan, plan review write-back works on V2, versioned approval prompt No, new to production orchestration-v2/Orchestrator.ts, ProjectionStore.ts, ProviderEventIngestor.ts, Layers/OrchestrationEngine.ts, planreview/*, packages/shared/src/planReview.ts, contracts/orchestrationFork.ts, web/session-logic.ts
#319 Plan cards render like chat, go wide, and take comments Yes, through #321 none
#320 Questions left by a failed run can be answered or dismissed Yes, through #321 one small file merge only
#322 Claude accounts: duplicate-filter fix, notices that expire, durable revive queue (migration 1053), rebalance at turn ends, "Leave queue" No, new to production claudeAccounts/*, persistence/ThreadClaudeAccount.ts, migration 1053, contracts, web picker

Net change against bkmain: 43 files, +2430 / −171.

Commits (non-merge) on stage that are not in bkmain

  • 34d6ad4b5e fix(server): a revive skips its continue only when the shell shows a turn in flight
  • 4ca0a20b4c fix(server): revive skips the continue when a turn already started; every turn start forgets stale limit keys
  • bbe817cc2d fix(server): review fixes for the Claude account revive queue and rebalance
  • 50ed9eff86 fix(server): Claude accounts revive waiting threads after resets and spread load
  • 56e13066dc fix(server,web): review fixes for orphaned questions
  • 2a6abc88e0 chore(web): mark the plan review lookup as a fork edit
  • e8ee65f5ba fix(server,web): questions left by a failed run can be answered or dismissed
  • 09017432c4 fix(web): review fixes for plan cards
  • 9e3b3f8bc3 fix: keep replay input unchanged and fix plan citation types
  • a0d2255a52 chore(web): mark the plan citation predicate as a fork edit
  • 0d144384c4 feat(web): plan cards render like chat, go wide, and take comments
  • e925a5bf52 fix(web): the BK sidebar drops the PLAN tag once plan mode is off
  • 8dec884073 chore(server): mark the queued-run plan supersession as a fork edit (TEC-1331)
  • 650ab2332d fix(server): detect wakes from the message, including notifications (TEC-1331)
  • cc197621a2 fix(server): a queued continuation ends the open plan when it starts (TEC-1331)
  • f9554a0e8c fix(server): address review of plan supersession (TEC-1331)
  • 4753c0f4b8 fix(server): only the newest plan stays actionable (TEC-1331)

The #319 and #320 commits appear here because #321 promoted them as cherry-picks. Their content is already in bkmain.

How I tested

Risks and rollback

🤖 Generated with Claude Code (Claude Opus 5.5, T3 Code)

bk-agent-01 and others added 21 commits October 15, 2026 13:42
A superseded plan could come back as the thread's current plan and be
implemented instead of the approved revision.

- The provider event ingestor supersedes every other active proposed plan
  when a new one arrives, for every adapter (only Claude did it, in memory).
- Continuing a thread in any interaction mode completes the plan the turn
  implements and supersedes any other open plan. A background-task wake
  does not count as a continuation.
- Plan review's decided-plan write-back now reaches V2 through the new
  thread.proposed-plan.retire command; before, V2 rejected the legacy
  upsert and the error was swallowed.
- The web no longer falls back to an earlier run's plan.
- The approval prompt names the approved revision and plan id, and repeats
  the full plan when the agent wrote more than one revision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A retire that finds the plan already closed is an expected no-op, not a
  rejected command; plan review keeps closing the rest if one fails.
- `/compact`, `/logout` and background-task wakes do not end an open plan;
  a queued message completes only the plan it names.
- The web falls back to an earlier run's plan only while it is active, so a
  wake or a subagent thread keeps the banner and a closed plan never returns.
- Fix the web type narrowing, fork markers and formatting in ProjectionStore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(TEC-1331)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TEC-1331)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TEC-1331)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…331)

fix(server): only the newest plan stays actionable
A thread kept its PLAN pill, Plan Ready group and needs-human count for as
long as its plan stayed active, even after plan mode was turned off. A plan
now waits only while its thread is in plan mode, matching upstream's Plan
Ready rule, so stale tags clear without a migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remove the plan card's Preview button; Expand plan stays.
- New header: icon, title, state, step count, reading time, and a
  Widen plan toggle that lets cards use the free width beside the chat.
- Plan bodies get the chat's markdown features (skills, runnable shell
  commands, image preview, artifact templates).
- HTML in a plan renders as a live themed page, like html_render: a whole
  HTML plan, a raw HTML document, or an html-render fence.
- Selecting plan text offers Cite and the comment actions; highlights,
  pins and scroll-to-quote work on plans, and the panel labels them.
- Plan-mode turns tell the agent how to add an html-render visual.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The plan-format hint joins the fork's plan policy only when plan
  submission is off, so provider replays keep their recorded input.
- Compare a citation's message id with the plan id as plain strings.
- Type the comments panel's message list so plans can join it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Plan HTML loads inline through srcDoc, so a frame opened on its own
  cannot run with the app's origin. The reader's theme is written into
  the page for the first paint and posted on change.
- A remounted plan page starts at its last measured height, so the
  virtualised list does not jump.
- A wide card starts after the timeline minimap's clickable strip.
- Plan cards read a memoised slice of the timeline state.
- Comment gutter bars sit in the card padding, not over the text.
- Settings and docs no longer point at the removed Preview button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ke comments

feat(web): plan cards render like chat, go wide, and take comments
…smissed

When a run fails while the agent waits on a question (the provider stream
closes, an event fails to ingest), the run ends and its provider session is
detached, but the question stays pending with a live capability. Submit then
failed with "Provider session ... was not found", dismiss failed with
"This question needs an answer", and Stop was gone.

A request whose session is detached or whose run has ended is now handled in
message mode: an answer resolves it and reaches the agent as the next
message, a dismissal closes it, and an approval closes without a reply. The
composer marks such a question dismissible. Multi-select answers join their
choices when sent as a message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A completed run no longer counts as ended: its session stays live and a
  background subagent can still wait on an approval. Failed, interrupted
  and cancelled runs do.
- Read only the request's own run, and take it from the timeline item when
  the node has none.
- MCP lists a question whose run failed or stopped as non-blocking, so
  t3_answer can dismiss it and t3_send_message no longer refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed or dismissed

fix(server,web): questions left by a failed run can be answered or dismissed
…spread load

- A failed hard-limit move no longer leaves the rejection in the duplicate
  filter, so a new turn's rejection moves the thread (2026-10-16: a thread
  stayed on `sam` for 20 min while `tushar` had room).
- Limit notices expire at their reset; the "all accounts are at their limit"
  notice is derived live from a durable revive queue (migration 1053).
- A thread no account can take is parked and continued in waves as accounts
  reset (revive pass after every status poll); the 5-minute reset wait is now
  a queue entry, so a restart no longer loses it.
- Auto threads move off an account over its fair share at turn boundaries,
  at most once an hour.
- New claudeAccounts.leaveQueue RPC and a "Leave queue" item in the picker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alance

- A revive checks it still owns the queue entry before it moves or continues
  the thread, so Leave queue / a user message during placement wins.
- The duplicate filter forgets a condition after a successful move and when the
  first turn on the new account starts.
- Rebalance runs only at a real turn end, pre-checks the last status before
  asking the switcher, backs off 5 min after a probe finds nowhere better,
  moves at most one thread per source account per status read, and writes
  only the row so the old session keeps its own attribution.
- Parking no longer forks a revive pass; archived threads leave the queue;
  a passed reset time is no longer shown as expected.
- Test counts for the new RPC (237) and migration 1053; formatting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…very turn start forgets stale limit keys

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…turn in flight

The provider-level idle check also counted the failed turn that parked the
thread, so a mid-turn thread never got its continue. Test for the race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(server): Claude accounts revive waiting threads after resets and spread load
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Oct 17, 2026
…ezing bkt3

The minute pull-request sweep checked all 1,100 unsettled threads on bkt3.
Each check starts 6-7 git processes and every start forks the 1.4 GB server
on the event loop, so a sweep ran 50-95 s of every two minutes with the main
thread saturated (55% of samples in uv_spawn). Replies took 504 ms median
during a sweep against 2 ms outside it, and desktop connections hit their
15 s setup limit. A thread with no run or message for a day is now checked
once every 30 passes; its own events still queue an immediate check.

The agent toolkit's plan-flag correction read a run's turn items with an
`IN (...) OR (...)` filter, so SQLite walked every item of the thread in
ordinal order: 0.3-2.6 s per cold 30,000-item thread, measured as a 2.5 s
event-loop stall at 10:32 UTC. Run filters now read through the
(thread_id, run_id) index: 4 ms median on the same cold threads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bk-agent-01 and others added 2 commits October 19, 2026 16:40
fix(server): pull-request sweep and plan-flag reads no longer freeze the server
Tushar, 2026-10-19: pull the latest bkt3 before the stage -> bkmain merge,
and deploy to stage first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-10-19

Merge latest bkt3 (bkmain b7af1e6) into stage
@bk-agent-01
bk-agent-01 deployed to bk-desktop-staging October 19, 2026 12:36 — with GitHub Actions Active
@bk-agent-01
bk-agent-01 merged commit b244dbc into bkmain Oct 19, 2026
33 of 35 checks passed
@bk-agent-01

Copy link
Copy Markdown
Collaborator Author

Merged by bk-agent-01 on Tushar's approving review of head a26a040 (2026-10-19 14:51 UTC) and his "Merge when approved" / "i approved you can merge now" answers in the owning T3 session.

This branch was successfully deployed

1 active deployment
bk-desktop-staging — a26a040f Deployed Oct 19, 2026 by bk-agent-01 via Publish #259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants