Skip to content

Avoid duplicate Tasks startup reconciliation - #3213

Merged
SawyerHood merged 1 commit into
mainfrom
slopcop/issue-3209
Sep 14, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
slopcop/issue-3209

Conversation

@bb-slop-cop

@bb-slop-cop bb-slop-cop Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

Tasks lifecycle registration awaited the same tracked-thread reconciliation twice. Each pass performs one SDK lookup for every tracked row that remains non-terminal, so startup repeated the full lookup pass without any intervening work. The direct reproduction and root-cause report is at https://get-bb.github.io/reports/issues/3209.html.

The previous CI run's only failure was the Linux AppImage lifecycle smoke: the packaged desktop runtime exited before becoming ready. That job does not exercise the Tasks lifecycle patch; all Tasks, server, app, integration, package, and macOS package-smoke jobs passed on that run.

What changed

Removed the duplicate startup reconciliation call and added a focused lifecycle regression test that requires one lookup for one non-terminal tracked thread. Updated existing lifecycle expectations and periodic-sweep setup to reflect the intended single startup pass.

The branch was refreshed onto current lifecycle code after the indexed lifecycle lookup work landed. The resulting patch remains 20 changed text lines across 2 files and does not change any wire contract, CLI surface, dependency, generated file, migration, or stored data.

How you verified

  • The focused regression test failed on unchanged original base 06aeaa994942ae7527dc49d2268c1f801e8542a0: one tracked thread recorded two threads.get calls instead of one.
  • pnpm exec turbo run test typecheck build --filter=bb-plugin-tasks — build and typecheck passed; 36 files and 389 tests passed.
  • git diff --check — passed.
  • GitHub CI on 2dac99d10c31c884832588a543378cb9da82d48e — 14 checks passed, with 2 platform-inapplicable jobs skipped and no failures or pending checks.

Fixes #3209

AGENT GENERATED

ymichael added a commit that referenced this pull request Sep 10, 2026
## Human comments

## What was wrong

Every global thread lifecycle event made Tasks enumerate all tasks and
query each task's worker mappings before filtering by the event's thread
ID. On current main `f41d564163180f87304986b61706db6d69314759`, an
unrelated event executes 202 SQL statements with 200 tasks and 505 with
501 tasks. The task-list method itself performs two statements per page,
so method-call counts understated the database work. Original
investigation: https://get-bb.github.io/reports/issues/3210.html.

## What changed

Use an internal lookup returning every mapping for the event's thread ID
through the existing `idx_task_threads_thread` index. Unrelated events
now execute one lookup; legitimate multi-task fan-out, comments,
notifications, recovery, and terminal protection remain intact. Startup
and periodic reconciliation are unchanged; #3213 addresses the separate
duplicate-startup issue.

Added SQL-level coverage using real in-memory SQLite and the Tasks
schema migrations, alongside the original no-scan regression. Removed
two existing non-semantic comments to satisfy repository lint. No
schema/index, public SDK/CLI, configuration, or server/daemon wire
changes; no host-daemon protocol bump is needed.

## How you verified

- Before production changes, eight SQL-budget regressions failed on
unchanged current main; two reconciliation checks passed.
- Compared baseline and fixed behavior with zero, one, 200, and 501
mappings, all five event types, and one thread mapped to 1, 3, or 200
tasks. Verified created-event status mapping, task status changes,
deletion cascade, comments, recovery, idempotence, and notifications.
- SQLite EXPLAIN confirms the existing thread-ID index is used. Sorting
is limited to matching rows. These are structural SQL improvements; no
end-user latency improvement was measured.
- An expanded 21-case audit passed with each implementation's measured
SQL budgets. The two startup/periodic audit cases remain outside the
patch to avoid adding expectations that constrain #3213.
- `pnpm exec turbo run test typecheck build lint
--filter=bb-plugin-tasks`: 388 tests passed in 36 files, plus
typecheck/build. Tasks has no lint script, so explicit changed-file
oxlint was also run.
- Separately typechecked the new regression through Turbo. Changed-file
oxlint, oxfmt check, and `git diff --check` passed.
- Started `pnpm start:worktree`; server and daemon health checks passed.
Installed/enabled the bundled Tasks plugin and confirmed 12 sample tasks
across 3 projects through the running API/CLI. No browser-driven UI
verification is claimed.

Fixes #3210

> AGENT GENERATED

---------

Co-authored-by: Sawyer Hood <[email protected]>
Co-authored-by: Michael Yong <[email protected]>
Co-authored-by: Fabio <[email protected]>
Co-authored-by: Jason Son <[email protected]>
Co-authored-by: vznh <[email protected]>
Co-authored-by: Michael Yong <[email protected]>
Co-authored-by: Hemanth Soni <[email protected]>
Co-authored-by: Scott <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Ilya Martynov <[email protected]>
Co-authored-by: Tom <[email protected]>
Co-authored-by: brsbl <[email protected]>
Co-authored-by: noih <[email protected]>
Co-authored-by: bb-slop-cop[bot] <316425484+bb-slop-cop[bot]@users.noreply.github.com>
Co-authored-by: Andrew Chan <[email protected]>
Co-authored-by: kongenpei <[email protected]>
@SawyerHood
SawyerHood merged commit 69b8a39 into main Sep 14, 2026
16 checks passed
@SawyerHood
SawyerHood deleted the slopcop/issue-3209 branch September 14, 2026 23:18
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.

Tasks plugin reconciles every tracked worker thread twice on each plugin load

1 participant