GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(server): one completion decision for both cohort owners by tannerpolley · Pull Request #471 · tannerpolley/t3code

Conversation

@tannerpolley

@tannerpolley tannerpolley commented Nov 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner

Problem

Step 3 of #418 asks for one completion path for both cohort owners: ordinary delegation keeps its cohort on the parent run, and run-less managed admissions keep it on the parent thread. Three pieces still sat in the wrong place or were duplicated:

  • issue closeout policy lived in the orchestration completion helper;
  • the "is this result still owed work" check behind task_status, wait and the parent wake was split between Orchestrator.ts and the fork helper;
  • finalize built its wake events inline instead of using the shared delegatedCompletionPlanEvents.

Writing tests for both owners also found a real defect. A late, unobserved result read of a thread-owned task (observedByRunId: null, for example a wait that ends after its turn did) acknowledged the result and dropped it from the queued wake, so the parent never saw it. Upstream's rule from PR pingdotgg#32573 (36d0dcbf55, wake idle parents for late delegated results) says an unseen read must not acknowledge a result; the fork's 2026-11-11 sync merge (436c0d0f32) had exempted run-less tasks from it.

Fix

finalize / recovery ──▶ planDelegatedCompletionDelivery (one planner, completionCohort picks run or thread)
                   ├──▶ delegatedCompletionPlanEvents (shared; inline copy removed)
                   └──▶ issueCloseout.publish / publishUntagged   (issues/IssueCommentEffects.ts)
task_status · wait · parent wake ──▶ ForkDelegatedCompletion.taskResultPending (single owner)
late unobserved read ──▶ upstream rule for both owners (claimed stays claimed; pending is offered)
  • Issue closeout moves into issue policy: makeIssueCloseout in issues/IssueCommentEffects.ts. issueCloseoutEffect is now private to it, and ForkDelegatedCompletion no longer imports issue code. The span name Orchestrator.publishIssueCloseout is kept.
  • One pending decision: taskResultPending now also covers the untagged case (progress with shell background tasks, then recovery continuation). Orchestrator.delegatedTaskResultPending reads the child and calls it.
  • Late read fix: removed the fork's task.runId !== null exemption in dispatchDelegatedTaskCompletionDeliveryResolution. Run-less tasks now follow the same late-read branch as run-owned ones. The existing post-commit offerDelegatedCompletionDeliveries already covers the thread cohort.
  • Narrowed reads (Server event loop stalls for up to 11 s every few minutes, and every request in flight stalls with it #367):
    • run-less admission reads only the parent thread row; it used no parent run, node, provider thread, turn or attempt;
    • reuseManagedChild reads only the current owner's task (subagentChildThreadIds), not all of the previous parent's subagents;
    • the closed-child branch of taskResultPending reads only this task (subagentIds), not all of the parent's subagents.
    • 11 server tests fail on main: FoundationPersistence (9) and Orchestrator.control-reads (2) #449's run-scoped delegated-task reads are untouched.
  • Kept as they were:
    • both persisted cohort owners and all their IDs (owner decision);
    • the Sync with upstream nightly v0.1.10-nightly.20261116.4800, with a behavior replacement ledger #417 selective reader (readDelegatedCompletionPlanRecords);
    • upstream's follow-up hold;
    • the One definition of "done" for a delegated task: task_status, waits and the parent wake agree #350 background-work hold;
    • Fork An issue owner's result from a wake-up run is dropped when its task already published a result #396 (wake results reach the parent after the task already reported): untouched by this PR; its test covers the run owner only.
  • No schema, event, outbox or model-facing text change. Nothing in issue links or backfill (#451 step 4: Move thread issue links onto upstream thread.issues #455).

Closes #435. Part of #418 (step 3 of 4).

Rollout (owner decision)

The late-read fix changes result hand-back, so before the first rollout that includes it:

  1. Pause new admissions (set_repository_work_paused).
  2. Drain: let active workers finish and their results reach their parents.
  3. Install the build.
  4. Resume admissions.

In-flight restart recovery is still covered by the fixture tests below; the pause and drain are the owner's choice, not a substitute for them.

Evidence

Case ledger. All new tests are in DelegatedCompletionDelivery.fork.test.ts and run each case for both owners (run and thread). They extend the existing thread-owned restart test rather than adding a parallel file.

Case Test
Concurrent siblings restart recovery adds a second worker to a queued {run,thread}-owned delivery and settles both: a second worker joins the queued wake without a new message ID or generation
Restart at pending / claimed / delivered Same test: the second worker is finished-but-unpublished at restart; the first is reserved with no dispatched wake (one offer, same ID and generation); the delivery run ended before the listener attached; a further restart offers nothing and leaves exactly one delegated message
Explicit result read a {observed,late} result read of a {run,thread}-owned task settles its queued wake only when seen. An observed read acknowledges and cancels the wake. A late read leaves the result claimed in the queued wake.
Stopped, archived or deleted parent a {run,thread}-owned worker that finishes after its parent was {archived,deleted,stopped}. Archived and deleted give disposed with no offer. A stopped run cohort gives disposed.
Old-format fixture The same test's thread-owned stopped case is the pre-#418 whole-mailbox stop. It reopens, and the result is reserved and offered with one message ID and generation. All fixtures are committed events, recovered by recoverDelegatedTasks.
Failed workspace preparation a {run,thread}-owned worker whose workspace preparation fails wakes its parent with the failure: real defer_start then prepared-run.fail; waits on the persisted subagent.updated event
Untagged descendant wake Owner-independent child-side logic, already covered: DelegatedCompletionDelivery.test.ts "holds a follow-up open while the child's own subagent still runs"
Background task (#350) Already covered: "finalizes a child whose run ended before a background command / nested subagent settled", "... keeps while an unawaited background command runs"

No sleeps: tests use committed events, recoverDelegatedTasks, and persisted-event streams.

Failing first. Before the fix, a late result read of a thread-owned task … failed with expected 'acknowledged' to equal 'claimed'. The run-owned variant passed. After the fix, all 35 tests in the file pass.

One changed expectation. ThreadLaunchService.repositoryHandoff.fork.test.ts sent an unobserved acknowledgement to an idle root, which has no run, and expected the result to leave the root's wake. That encoded the defect. It now expects the result to stay in the wake.

Runs (agent-heavy, Node from vite-plus fallback-bin):

  • Focused set, 17 files, 345 passed. The only 2 failures were the handoff expectation above, since corrected; a rerun of the handoff, fork completion and IssueCommentEffects files gave 81/81. Files:
    • DelegatedCompletionDelivery and its .fork copy;
    • ManagedFollowupRecovery, RestartContinuation, SilentWake, ProjectionRecovery;
    • IssueCommentEffects, IssueReviewDelegation.fork;
    • ThreadLaunchService fork suites: issueWork, usageSprint, repositoryHandoff, readOnlyLimit, workerLimit;
    • ProviderRuntimeRecoveryService and its .fork copy;
    • OrchestratorMcpToolkit.integration.fork, RemoteDelegatedTask.
  • vp run check:changed: format, lint, both knip runs and GraphQL pass. Tests: 118 passed across 7 files.
    • Typecheck: scripts and evals pass. apps/server fails only on McpHttpServer.test.ts(1711) (TS2375/TS377004), in a file this PR does not touch. Restoring origin/main's versions of all six changed files reproduces the same two errors.
    • That error was a chore(sync): merge upstream nightly v0.1.11-nightly.20261117.4851, adopting upstream Issues #469 sync leftover, tracked as Server typecheck fails on main: McpHttpServer.test.ts tool-hiding test misses issue services #472 and fixed on main by df594d7fcb (PR fix(server): tool-hiding test provides the issue services it needs #473).
    • No new failures from 16 tests already fail on main in files check:changed rarely selects #470, 11 server tests fail on main: FoundationPersistence (9) and Orchestrator.control-reads (2) #449 or the Webhook test fails when an extra migration is registered (interrupt point moves) #468 quarantine.

Footprint: whole-file Orchestrator.ts numstat. These are fork totals, not issue-only counts.

Upstream base Before (main) +/− After +/−
7d32075e37 (plan pin) 1690 / 775 1671 / 771
b387e3a179 (newest sync, #469) 1497 / 687 1478 / 683

ForkDelegatedCompletion.ts: +16 / −90. The other five shared files are unchanged.

What remains, and which step owns it:

  • Orchestrator.ts keeps the cohort-owner accessor (completionCohort/completionCohortEvent) and the null-parentRunId branches the persisted thread cohort requires.
  • recoverDeletedChildren still reads all of a recovering parent's subagents at startup. It was not in the two reads flagged in Server event loop stalls for up to 11 s every few minutes, and every request in flight stalls with it #367, so it is left as is.
  • Provider and MCP policy is step 4.

Merge Danger

Door: two-way. No migration and no persisted-format change. Rolling back restores the old late-read behavior.

Blast radius: delegated result hand-back for run-less managed workers. A late, unobserved read no longer acknowledges a result, so the parent sees it through its wake instead. Live userdata was not read or copied, and no dev server was started.

Implemented with Claude Opus 5.5 through the Claude Code harness in T3 Code.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tannerpolley and others added 2 commits November 17, 2026 18:22
@tannerpolley @claude
refactor(server): one completion decision for both cohort owners
27dac66
Issue closeout moves from ForkDelegatedCompletion into IssueCommentEffects.
The "result still owed work" decision behind task_status, wait and the parent
wake now has one owner (ForkDelegatedCompletion.taskResultPending). Finalize
reuses delegatedCompletionPlanEvents instead of an inline copy.

Fix: a late, unobserved result read of a thread-owned (run-less managed) task
acknowledged it and dropped it from the queued wake. It now follows upstream's
late-read rule for both owners.

Narrows reads: run-less admission reads only the parent thread row,
reuseManagedChild reads only the current owner's task, and the
closed-child pending check reads only this task.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tannerpolley @claude
test(server): type the preparation-failure worker setup
22f5cdf
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tannerpolley tannerpolley mentioned this pull request Nov 18, 2026
#418 step 3: Unify managed completion and restart recovery with upstream delegation #435
Closed
@tannerpolley
tannerpolley marked this pull request as ready for review November 18, 2026 01:43
@tannerpolley
tannerpolley merged commit a93975b into main Nov 18, 2026
@tannerpolley
tannerpolley deleted the issue-435-418-step-3-unify-managed-completion-and branch November 18, 2026 01:43
This was referenced Nov 18, 2026
feat(issues): move thread issue links onto thread.issues #474
Merged
Run managed issue work through upstream delegation primitives #418
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

#418 step 3: Unify managed completion and restart recovery with upstream delegation

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@tannerpolley
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.