Skip to content

refactor(archive): isolate family archive policy and add agent consultation - #742

Merged
lastobelus merged 7 commits into
lastcode/mainfrom
lastcode/family-archive-policy
Nov 16, 2026
Merged

lastobelus merged 7 commits into
lastcode/mainfrom
lastcode/family-archive-policy

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Ready to merge. Local checks, GitHub CI and exact-head review pass. The paired model eval meets all four case thresholds.

Problem

Family archive logic is spread through upstream-owned files (Orchestrator.ts, ThreadManagementService.ts, useThreadActions.ts and the mobile equivalents). Every upstream checkpoint carries that code, so each carry is expensive.

When archive is blocked by work that looks stuck, the user also has no way to ask the agent doing it whether it is finished.

Change

Fork-owned seam. The archive planner, shutdown runner, reads/contracts and client archive controls now live in fork-owned modules (LastCodeArchivePlanner, LastCodeArchiveRunner, ThreadArchiveReader, lastcodeThreadArchiveActions on web and mobile). Upstream files keep thin call sites.

Optional Ask the agent. In the archive dialog, Ask the agent sends a question to the agent that actually owns the blocked work.

  • It uses the existing ordinary message queue, with a fresh ID per click.
  • If the owner is busy, the user gets Review/stop alternatives instead.
  • No new consultation persistence or tool, and no automatic archive.

Preserved behavior

  • Strict shutdown.
  • Exact failed-attempt recovery.
  • Historical restore cohorts.

Upstream's cascade (https://redirect.github.com/pingdotgg/t3code/pull/33921) is intentionally not imported.

Also adds four family-archive eval cases and a short Ask the agent note in docs/user/thread-sidebar.md.

Scope

Part of #720. This is a refactor plus one small optional feature, driven by that issue.

Carry measurement. With the same upstream ref, changed lines in the touched upstream-owned paths fall from 21,559 to 18,061 (−3,498); contextual diff hunks fall from 527 to 523. That is not the whole archive denominator, and it is below the original 6–8k estimate.

Verification

Server

  • The 166-test archive run passed; the final consultation and retention checks pass all 15 tests.
  • All 210 tests in the server suites affected by the CI lock-fixture repairs pass.

Client

  • Web: 138 focused tests pass, plus 18 browser tests.
  • Mobile archive/navigation and dependency checks: 73 tests pass.
  • Shared: 20 tests pass.
  • React compiler coverage: 4 tests pass.

Gates

  • check:changed: format, lint, dependency analysis, GraphQL generation, 37 package typechecks, 1,106 tests and 11 React compiler checks passed.
  • Agent-facing context is below the existing size budget; its focused tests pass.

Real-model comparison

  • Fixed three samples per case, head first with identical strict fixtures: 11/12 on head versus 6/12 on base. All four head cases meet the two-of-three threshold; base passes only the idle and recipient controls.
  • Used the cheapest model settings in a linked environment with the eval proxy. No provider, code-cell or ID errors. One head sample still skipped inspection; every question reached the correct owner through the ordinary queue, and busy owners were left alone.
  • Cases and graders retain exact inspection IDs, inspection-before-send ordering and all no-stop/no-archive guards. No retry-until-green sampling.

Browser acceptance passed for busy and eligible consultation, delivery of the ordinary question, stop/archive, and Settings restore through an archived child. Failed archive visibility was checked in a separate synthetic projection fixture; server tests cover the actual shutdown failure path.

Local review: 3 rounds with gpt-6.1-terra (xhigh) and claude-opus-5-5 (high), approved.

UI evidence

Before sending, a busy owner gets Review and Stop alternatives; an idle owner can receive Ask:

Busy owner

Ask available

Question delivery through the ordinary conversation:

archive-ask-delivery.mp4

Stop and archive:

archive-stop.mp4

Failed archive remains visible with retry and dismissal (synthetic visual fixture):

Failed archive controls

Implemented with GPT-6.1 Sol (xhigh), Codex through LastCode.

…tation

Move family planning, shutdown, archive reads and client controls into fork-owned modules while preserving receipt locks, durable attempts and historical restore cohorts. Offer optional consultation with the actual execution owner through ordinary queued messages.

Part of #720

Carry-Group: incubator
Carry-Fix: #720
Carry-Observation: Archive policy, shared contracts, multi-surface controls and their regression tests form one inseparable feature extraction.

Implemented with GPT-6.1 Sol (xhigh) in Codex through LastCode.
Keep stale pending tasks and failed archive attempts consultable, while holding questions for background work or unavailable provider runtimes. Preserve mobile archive failure feedback.

Part of #720

Carry-Group: incubator
Carry-Fix: #720
Carry-Observation: Consultation eligibility is part of the family archive policy extraction.

Implemented with GPT-6.1 Sol (xhigh) in Codex through LastCode.
Exclude app-owned delegated-task display rows when checking whether an execution owner can answer an archive question. Keep native subagents and background tools busy, and cover actual delegated turn-item rows.

Part of #720

Carry-Group: incubator
Carry-Fix: #720
Carry-Observation: Recipient execution checks must distinguish owned task rows from independent background execution.

Implemented with GPT-6.1 Sol (xhigh) in Codex through LastCode.
@lastobelus
lastobelus force-pushed the lastcode/family-archive-policy branch from 258a0c3 to 3690fb3 Compare November 16, 2026 20:28
@lastobelus
lastobelus marked this pull request as ready for review November 16, 2026 20:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T21:50:31.755533Z 77a51bd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 3690fb318b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Keep archive family, thread reads, listings and delegated-task state consistent so the eval reaches the intended consultation choices. Prompts and graders are unchanged.

Carry-Group: incubator
Carry-Fix: #720
Observe actual lock acquisition in regression fixtures, select the ordinary mobile conversation without an import cycle, and direct archive questions through authoritative consultation targets and the ordinary queue. Preserve the eval safety guards while fixing inconsistent fallback data and completion capitalization.

Carry-Group: incubator
Carry-Fix: #720
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: d7ad51b726

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Consolidate duplicated archive instructions without dropping consultation safeguards. Require exact inspection IDs in model eval fixtures, match the production response and use synthetic UUIDs.

Carry-Group: incubator
Carry-Fix: #720
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 462224674e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Direct archive readiness checks and blocked-work questions to the authoritative family inspection at the read entry point. Move the hint from Send without increasing agent context.

Carry-Group: incubator
Carry-Fix: #720
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 77a51bd0ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus
lastobelus merged commit ac07ead into lastcode/main Nov 16, 2026
43 checks passed
@lastobelus
lastobelus deleted the lastcode/family-archive-policy branch November 16, 2026 22:00
lastobelus added a commit that referenced this pull request Nov 30, 2026
## Why

Deleting owned descendants with their parent is fork-only behavior. It grew from upstream's side-chat cleanup into owned descendants and worktree cleanup, and all of it sat inline in the delete case of the `Orchestrator.ts` dispatcher. That block keeps showing up in upstream replay diffs. This is part of [the Orchestrator conflict-reduction work](#720) and follows [the archive planner extraction](#742).

## What changed

Worktree planning, descendant deletion and effect collection now live in one fork-owned module, `apps/server/src/orchestration-v2/LastCodeThreadFamilyDeletion.ts`. The delete case calls it.

- **Dispatcher** owns locks, the receipt, the participant guard and the commit.
- **Deletion planner** produces each thread's events and effects.
- **Protected-descendant test** (`ThreadFamilyLifecycle.integration.test.ts`) now asserts that every thread in the family stays active and that the root command queues no effects.

## Measured effect

Against the shared upstream baseline:

| | Before | After |
| --- | --- | --- |
| Downstream lines added in the delete case | 139 | 2 |
| Changed lines in the `Orchestrator.ts` diff | 7,361 | 7,219 |
| Total lines in `Orchestrator.ts` | 23,128 | 22,984 |

In the 14-day sample, two upstream changes touched the delete case or its three-line context. The table measures the diff against that baseline. Nightly conflict frequency remains to be measured.

## Verification

- 148 focused tests passed.
- Quick CI passed.
- The changed-file check passed, including 158 tests.

Local review: 1 round with GPT-6.1 Terra (xhigh), approved at `dca9ceef530b5866e90f89192c92827e03dae79f`.

Implemented with GPT-6.2 Sol (xhigh), Codex through LastCode.

Carry-Source-Ref: refs/lastcode/carry-sources/pr-911/dca9ceef530b5866e90f89192c92827e03dae79f
Carry-Source-Base: f8085a1
Carry-Source-Head: dca9cee
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.

1 participant