Skip to content

feat(threads): archive owned work across projects at wrap-up - #764

Merged
lastobelus merged 11 commits into
lastcode/mainfrom
lastcode/archive-follows-owner
Nov 20, 2026
Merged

lastobelus merged 11 commits into
lastcode/mainfrom
lastcode/archive-follows-owner

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Part of #751

Problem

Agents launch threads in other projects, and #753 now records who owns them. Archiving the parent at wrap-up still left that owned work open, so it had to be archived thread by thread. This PR makes wrap-up follow ownership across projects, and keeps threads the user has written in open by default.

What gets archived

Within the current environment, archiving uses the existing placement and delegated family and follows getThreadOwner transitively across projects. Historical threads whose creator record has no ownership keep their existing archive behavior. Threads released from ownership stay outside the added cascade.

Unarchive uses the persisted archivedWith cohort. An already-archived intermediate keeps its prior restore cohort for legacy placement and lineage. A descendant reached only through recorded ownership restores with the operation that archived it.

Human-message rule

A child stays open by default when its stored shell records a message with user role and user authorship. The latestUserAuthoredMessageAt signal excludes agent relays and idle compaction. Renames and other actions that adopt the workspace do not set this message signal.

The child and its downstream family stay owned. If the child is already archived, its messages still protect the live branch. Web and desktop can include the branch with separate confirmation. Mobile previews the default selection and offers Review so the user can open and archive a conversation directly.

Preview and protections

  • Preview first. Web, desktop, mobile, and the tool show the family before the wider selection applies. Clients list titles and projects, what stays open, and active, unread, or protected state. The tool returns the environment ID and project IDs.
  • Server re-check. The server validates the exact selection again under its locks.
  • Saved workspaces. Each archive selection shows its own discardable and retained copies. The server binds disposal consent to the confirmed thread IDs. A copy shared with a thread that stays open remains available.
  • Bulk. An explicitly selected child still gets its own archive when the parent's default keeps it open. When two operations share a thread, the later one refreshes and can proceed only when its confirmed selection still matches after removing threads the batch already archived.
  • Existing activity, permission, shutdown, and retry protections apply to the selected family.

Groups

In an archive that uses the new ownership preview, a marked group is eligible when it has no conversations, runs, recorded Project Actions, user adoption, or protection, and every live member is in the same confirmed archive.

It then archives with the family and can be restored from the archive.

Scope and follow-ups

  • Current environment only. Linked environments can already preview or archive a known thread ID with the peer's authorization. They cannot enumerate a remote part of a family by owner, or record an offline destination as pending.
  • Cross-environment follow-up. Use an owner-qualified inventory and a durable operation record. Review the exact selection per reachable peer, use that peer’s authorization, and record its receipt. Show offline or denied peers as pending or blocked and retry idempotently. Restore the cohorts that actually committed.
  • Temporary projects. PR feat(projects): hide temporary agent projects by default #761 landed the project listing service. The orchestrator is scheduling removal at wrap-up separately. Promotion landed in feat(threads): promote owned threads to top level and return them to their owner #763 and is included through the base.

Archive performance

Measured on the same 4,866 real thread projections. The dev migration preserved complete histories for 191 visible, stopped threads. The benchmark added the remaining projection rows from a read-only snapshot and archived only the migrated threads.

Median wall time Original main Original PR Current main Guarded indexed PR
Candidate query 0.08 ms 33.85 ms 0.09 ms 0.43 ms
Family preview 12.76 ms 48.19 ms 13.47 ms 14.48 ms
Archive one 11-thread family 176 ms 425 ms 183 ms 178 ms
Archive 50 threads, including previews 654 ms 11.44 s 671 ms 778 ms

Across five alternating pairs per comparison, the original query added a median 10.70 seconds to the 50-thread batch. The guarded indexed query added 108 ms (range +66 to +139 ms). The traced statements account for a median 76 ms of this difference.

The 11-thread command runs the candidate query three times at dispatch and four times at completion. Preview adds one. The bulk ran 284 statements, including 50 previews.

SQLite's original plan materialized recorded_owner_candidates and scanned the thread table twice. The new plan seeks both partial expression indexes from the recursive family and group lookups. The expressions guard malformed JSON so legacy recovery can keep running. The recorded restore-cohort lookup runs only when the root has both cohort fields. Ownership qualification stays in getThreadOwner.

Verification

  • Seeded parity. On a LastCode database seed, current main and the indexed head selected and archived the same 27 threads across three real historical families. Archive events and exact restore cohorts matched. Each case used its own disposable copy, production dispatch, and the production archive runner, with the background worker disabled. The seed stayed byte-for-byte identical.
  • Tests. Archive and promotion server tests, the saved-workspace regression, Chromium confirmation tests, compiled web tests, and mobile and shared unit tests passed. Quick CI passed on the current head. Three bulk-archive regressions cover shared members in both orders and a refresh that finds new work. The database recovery, migration, and archive suites verify guarded lookups on legacy data and index selection.
  • Browser. The isolated browser applied the default cascade across two projects, and the user-authored conversation stayed open.
  • Evals. The new tool eval passed 0/4 on the baseline and 4/4 after the first tool change. The idle control passed 3/3 on both. The rebased tool text passed all 12 scored samples, including 3/3 for the typed-in branch and 2/2 for the idle control. The provider stream ended early on three samples, which remained unscored.
  • Context growth. The measured agent tool list grew by 314 bytes (85,690 → 86,004). The budget changes by one line.
Browser evidence

The existing archive menu on the synthetic fixture.

Archive option in the existing thread menu

The cross-project preview with the typed-in conversation kept open.

Archive preview with projects, selection, and a keep-open conversation

Opting in to archive the typed-in child now updates the saved-copy list to match the selection. Both captures use the same Chromium fixture.

Before After
After opt-in, the saved copy still appears under retained copies After opt-in, the shared saved copy appears in the list to discard

Upstream-owned files

File Added Removed
apps/mobile/src/features/home/useThreadListActions.test.ts 4 0
apps/server/src/mcp/toolkits/thread/handlers.ts 6 0
apps/server/src/mcp/toolkits/thread/tools.ts 4 2
apps/server/src/orchestration-v2/Orchestrator.ts 6 35
apps/server/src/orchestration-v2/ProjectionStore.ts 3 1
apps/server/src/orchestration-v2/ThreadManagementService.ts 2 1
apps/server/src/provider/agentContextBudget.json 1 1
packages/client-runtime/src/operations/commands.ts 8 0
packages/contracts/src/orchestrationV2.ts 4 0
Each of apps/mobile/src/i18n/translations/{de,en,es,fr,ja,ko,pt-BR,ru,sv,zh}.json 3 0
Each of apps/web/src/i18n/translations/{de,en,es,fr,ja,ko,pt-BR,ru,sv,zh}.json 5 0

🤖 Generated with Claude Code

Local review: 4 rounds with GPT-6.1 Terra (xhigh), approved. The fourth round reviewed the final safety changes after churn-gate. A separate scoped source review approved the archive query and index migration.

@lastobelus lastobelus changed the title Archive an orchestrator’s owned threads across projects feat(threads): archive owned work across projects at wrap-up Nov 20, 2026
@lastobelus
lastobelus marked this pull request as ready for review November 20, 2026 01:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 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-20T03:04:15.384369Z 51687d0 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79700290d3

ℹ️ 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".

Copy link
Copy Markdown
Owner Author

No description provided.

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: 1b0909a459

ℹ️ 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 force-pushed the lastcode/archive-follows-owner branch from 1b0909a to f926144 Compare November 20, 2026 01:36

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f926144cde

ℹ️ 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 force-pushed the lastcode/archive-follows-owner branch from f926144 to a05fbbd Compare November 20, 2026 01:56

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a05fbbdb14

ℹ️ 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 force-pushed the lastcode/archive-follows-owner branch from f6f7849 to 305b06c Compare November 20, 2026 02:08

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: 305b06c1f0

ℹ️ 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".

Use the recorded owner to find local archive participants across project
boundaries. Preview the exact selection and keep threads with human messages
open unless explicitly included. Restore the recorded archive cohort.

Carry-Group: incubator
Carry-Fix: #751
Carry-Observation: Archive preview and consent travel with the fork-owned family planner and client lifecycle.
Model: GPT-6.2 Sol (Codex)
Check every group affected by a widened archive before adding it to the
selected set. Preserve legacy restore cohorts when a family also has
newly discovered owned threads. Honor explicitly selected children in
bulk archive after applying the parent selection.

Carry-Group: incubator
Carry-Fix: #751
Model: GPT-6.2 Sol (Codex)
Keep live descendants of an archived owned thread open when the user
wrote in that thread. Verify that the archive RPC waits for its durable
result before a bulk client proceeds to separately selected children.

Carry-Group: incubator
Carry-Fix: #751
Model: GPT-6.2 Sol (Codex)
Keep a reachable legacy intermediate's restore cohort beneath a
cross-project owner and retain groups with an Action record. Recheck
the exact archive targets during shutdown. Preserve Review in the
mobile archive preview and retain typed-in branches there by default.

Carry-Group: incubator
Carry-Fix: #751
Model: GPT-6.2 Sol (Codex)
Stub project lookup in the isolated mobile and saved-workspace tests. Assert that the archive dialog omits typed-in consent on default submissions.

GPT-6.2 via Codex

Carry-Group: incubator
Use the same thread IDs to preview and commit saved-copy disposal. Keep shared copies available while any owner stays open, and show the matching saved-copy inventory when the user opts to archive conversations they wrote in.

GPT-6.2 via Codex

Carry-Group: incubator
The archive confirmation now uses the shared schema, which owns the project ID field.

GPT-6.2 via Codex

Carry-Group: incubator
Refresh a later archive preview when an earlier entry archived shared work. Run the later command only if its selection still matches the previously confirmed threads after removing the completed work.

GPT-6.2 via Codex

Carry-Group: incubator
Seek recorded owner edges from the current family or group instead of materializing them for every thread. Keep owner qualification in the archive planner and skip the cohort scan when the root has no saved cohort.

GPT-6.2 via Codex

Carry-Group: incubator
@lastobelus
lastobelus force-pushed the lastcode/archive-follows-owner branch from 305b06c to 6cd12b3 Compare November 20, 2026 02:44

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: 6cd12b30b3

ℹ️ 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".

Use guarded JSON extraction in both expression indexes and the matching candidate queries. A malformed legacy row can still reach recovery without entering either index.

GPT-6.2 via Codex

Carry-Group: incubator

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 2131f500b1

ℹ️ 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 the authority migration test checking the complete ordered upgrade through the new archive index migration.

GPT-6.2 via Codex

Carry-Group: incubator

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 51687d0e80

ℹ️ 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 added the agent-context-increase Intentional agent context growth approved by a maintainer label Nov 20, 2026
@lastobelus
lastobelus merged commit fba5fa4 into lastcode/main Nov 20, 2026
23 of 24 checks passed
@lastobelus
lastobelus deleted the lastcode/archive-follows-owner branch November 20, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-context-increase Intentional agent context growth approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant