# fix\(server\): archived threads no longer start work after setup finishes · PR \#14907 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/14907)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: closed

Source repository: Unavailable fork

Source branch: fix/server-archived-preparation

Target branch: main

Head commit: 6cf266d8f317e353fe936a6081d02c7c47bdd84b

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/14907)

[Commits](https://git.cafe/pingdotgg/t3code/pull/14907/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/14907/diffs?format=markdown)

## Description

---

## Problem

A workspace preparation completion can release a preparing V2 run after its thread was archived, transition it to `starting`, and enqueue `provider-turn.start`. The release path does not check the terminal thread state before preparing checkpoints and scheduling provider work.

Reproduced against `b4d3d51ac9`. Macroscope flagged this in the merged orchestrator V2 PR: [preparation-release finding](https://github.com/pingdotgg/t3code/pull/2829#discussion_r3885094831).

## Change

Reject `prepared-run.release` when its thread is archived or deleted, before preparing checkpoints, changing run state, or scheduling provider work. If preparation finishes while archived, `ThreadLaunchService` records its rejected release as a failed run through the existing failure path. After unarchive, a new send starts a new run; this change does not add suspended-setup resumption.

## Scope and approval

This is a small, focused fix for an obvious lifecycle invariant violation under CONTRIBUTING.md. It changes one existing command path, with no new capabilities, settings, product defaults, dependencies, wire changes, or diagnostic suppressions. The shared server path applies across clients and connection modes without provider-specific changes.

Duplicate search included open, merged, and closed PRs. #11635 already covers terminal-thread checks in `message.dispatch`; that overlapping fix is intentionally excluded here. Its diff does not cover `prepared-run.release`. #14240 addressed session teardown in the removed V1 reactor.

## Verification

- Red: `vp test run apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts --maxWorkers=1 --no-file-parallelism -t 'rejects prepared-run.release after thread.archive'` reproduces successful admission after archiving on the original code.
- Green: 46 passing focused tests in `Orchestrator.control-reads.test.ts` and `ThreadLaunchService.test.ts`, with one worker and no file parallelism. Command-level regressions cover archive/delete rejection, unchanged projection and an empty release outbox. The launcher regression blocks setup with deferred signals, archives the thread, completes setup, and waits on persisted events: the run fails without provider turns or checkpoint scopes. After unarchive, a new send starts a distinct run and enqueues provider work. It fails without the release guard (`starting` instead of `failed`). Real orchestration, persistence, projection and outbox run; external setup and provider execution are isolated.
- `GOMAXPROCS=1 tsc --noEmit -p apps/server/tsconfig.json` — passes. Effect emitted advisory suggestions; no compiler errors.
- `vp lint apps/server/src/orchestration-v2/Orchestrator.ts apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts apps/server/src/orchestration-v2/ThreadLaunchService.test.ts --threads 1 --report-unused-disable-directives` — passes with pre-existing warnings for unused `layerUnavailable` and optional chaining in an unchanged launcher test.
- `fallow audit --base bf7121d7a2 --threads 1 --format json --quiet --explain` (Fallow 3.31.0) — `pass`, three changed files, zero introduced dead-code, complexity, duplication, or styling findings. Existing findings remain outside this fix; the tool notes incomplete import-graph evidence from skipped vendored `.repos` sources.
- Scoped formatting and `git diff --check` pass.

No browsers, provider CLI sessions, or live user database were used. Repository-wide checks were not run.

Model: GPT-6.1-Sol. Harness: Codex in T3 Code.

