Skip to content

[Bug] Atomically deliver S15 background results - #525

Merged
Bill-Billion merged 2 commits into
shareAI-lab:mainfrom
wxj006007:fix/issue-524-s15-background-results
Aug 15, 2026
Merged

Bill-Billion merged 2 commits into
shareAI-lab:mainfrom
wxj006007:fix/issue-524-s15-background-results

Conversation

@wxj006007

Copy link
Copy Markdown
Contributor

Fixes #524

Problem

Concurrent consumers can race while collecting completed S15 background tasks, allowing duplicate or inconsistent result delivery. Concurrent task starts also allocate IDs separately from task registration.

Changes

  • Allocate the background task ID and register the task under one lock.
  • Atomically remove completed/failed tasks and their stored output before formatting notifications.
  • Add a regression test proving concurrent consumers deliver each result exactly once.

Verification

  • python -m py_compile s15_integrated_harness/code.py tests/test_agent_teams_runtime.py
  • Targeted concurrency regression test passes.

Scope

Only s15_integrated_harness/code.py and its focused test are included. Windows-only compatibility is outside scope.

@Bill-Billion Bill-Billion left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the two atomicity gaps: moving ID allocation plus registration into one critical section and claiming completed results under the same lock is the right approach. Before merging, please run cd web && npm run extract and commit the updated web/src/data/generated/versions.json (the full suite currently has one stale-snapshot failure and becomes 208 passed, 84 subtests passed after regeneration), and add a deterministic concurrent-start regression test proving two callers cannot receive the same background ID, since the new test only covers concurrent consumers.

Please also make the background-task lifecycle fail-safe: a PostToolUse hook exception must not bypass the terminal status/result write, and a Thread.start() exception should roll back or mark the registered task failed, as S11 already does; both paths currently leave a permanent running entry with no deliverable result and can indefinitely block worktree removal.

@Bill-Billion
Bill-Billion dismissed their stale review August 15, 2026 16:19

Submitted by mistake; withdrawing this review.

@Bill-Billion
Bill-Billion merged commit 2b5fc57 into shareAI-lab:main Aug 15, 2026
0 of 2 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.

[Bug] Make S15 background-result delivery atomic

2 participants