Skip to content

refactor(server): thread search and git project lookup read V2 - #14015

Merged
juliusmarminge merged 2 commits into
t3code/codex-turn-mappingfrom
v2/thread-search-reads-v2
Sep 28, 2026
Merged

juliusmarminge merged 2 commits into
t3code/codex-turn-mappingfrom
v2/thread-search-reads-v2

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Stacked on #14012.

After #14012, ProjectionSnapshotQuery had two readers left, thread search and GitManager's per-project settings lookup. The lookup was also a bug (Bug 3 in the design): GitManager resolved a thread's project from the V1 projection_threads table, so a V2-native thread never matched. Per-project git settings (commit/PR writer model, writing style, worktree submodules) then silently fell back to the environment defaults for every thread created since V2.

What changed

  • Thread search reads V2 only. A new ThreadSearch service (orchestration-v2/ThreadSearch.ts) runs the same ranked query over the V2 projection: one best match per active thread in an active project, user messages over assistant ones, then newest first. It keeps the snippet rules, escaped LIKE and limit. It no longer searches V1 transcripts that haven't been imported yet (the approved design puts V1 search out of scope). ws searchThreads and the MCP t3_thread_search tool use it.
  • GitManager's project lookup reads V2. A thread's project comes from ProjectionStoreV2.getThreadShell, and a bare cwd resolves through ProjectStoreV2.findActiveByWorkspaceRoot. Both are required services now, not an optional snapshot query. server.ts provides them to the GitManager layer.
  • Deleted, with no readers left:
    • ProjectionSnapshotQuery (service, layer, and the tests of its search and enrichment)
    • ProjectionPipeline (service, layer, test)
    • orchestration/runtimeLayer.ts; OrchestrationEventInfrastructureLayerLive moved to orchestration-v2/runtimeLayer.ts
    • ThreadBackgroundLiveness and ThreadPlanProgress, registries only the snapshot query read
    • the repositories only the pipeline wrote: pending approvals, projection state, thread sessions, turns
    • now-dead helpers isPersistenceError, the exported parseAttachmentIdFromRelativePath, and the exports of MONITOR_TASK_TYPES / INERT_TASK_TYPES

No wire or contract schema change.

Verification

  • vp exec tsc --noEmit -p . in apps/server and packages/contracts: 0 error TS / warning TS.
  • vpr knip:check: clean.
  • vp lint on touched files: no new warnings.
  • vp test run, in small groups, all passing:
    • new ThreadSearch.test.ts (real SQLite): user over assistant, newest user wins, streaming/system/archived/deleted threads and deleted projects excluded, limit, literal %.
    • GitManager.test.ts (115), including a new case: a V2-native thread (created only through ProjectionStoreV2, cwd outside the project root) gets its project's textGenerationModelSelection override. It fails against the old V1 lookup and passes now.
    • McpHttpServer.test.ts, worktree/registration.test.ts, PullRequestSyncReactor.test.ts, ws.test.ts, serverRuntimeStartup.test.ts, runtimeLayer.test.ts, ProjectionRepositories.test.ts, integration/transferBudgetV2.integration.test.ts
    • importer and migrations: LegacyV1Cutover.integration.test.ts, LegacyV1ThreadImporter.test.ts, V1ImportBoundary.test.ts, ProjectSettingsUpgrade.integration.test.ts, 055_* (3 files), 056_*
    • replay: OrchestratorReplayFixtures.integration.test.ts + .contract.test.ts, OrchestratorReplayRecovery.integration.test.ts
  • Not run: the repo-wide suite, and a real client (no client changes).

Model: Claude Opus 5.5 (Claude Code)

🤖 Generated with Claude Code


Devin Review

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Sep 27, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This is a large production orchestration refactor that replaces legacy projection reads and infrastructure with V2 services, including a deliberate change to search visibility and GitManager settings resolution. The breadth of deleted shared infrastructure and changed runtime wiring warrants human review.

No code changes detected at 5095efd. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

Comment thread apps/server/src/orchestration-v2/ThreadSearch.ts Outdated
@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 4.9 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.1 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅
Codex Live turn messages — 1 — 8 ✅
Claude Total thread wire — 4.9 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅
Claude Live turn messages — 2 — 8 ✅

Baseline: unavailable · PR result: 5095efd · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 106.1 KiB
  • Claude decoded thread snapshot: 106.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@juliusmarminge
juliusmarminge force-pushed the v2/project-reads-leave-snapshot-query branch from 13f83a8 to d75890c Compare September 28, 2026 17:13
Base automatically changed from v2/project-reads-leave-snapshot-query to t3code/codex-turn-mapping September 28, 2026 17:19
juliusmarminge and others added 2 commits September 28, 2026 10:19
Thread search is a small ThreadSearch service over the V2 projection, so
it covers V2 threads only. GitManager resolves a thread's project through
ProjectionStoreV2 and a workspace root through ProjectStoreV2. The V1 lookup
missed V2-native threads, so per-project git settings silently fell back to
the environment for them.

With no readers left, ProjectionSnapshotQuery, ProjectionPipeline, the V1
orchestration runtime layer, the liveness and plan-progress registries only
the snapshot query read, and the pipeline-only repositories are deleted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ThreadSearchError carried only its cause. It now records whether the SQL
query or the row decode failed, so a log line is actionable without the
cause. The search query stays out of the error because it is user content.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Comment on lines +4 to +5
import { OrchestrationCommandReceiptRepositoryLive } from "../persistence/Layers/OrchestrationCommandReceipts.ts";
import { OrchestrationEventStoreLive } from "../persistence/Layers/OrchestrationEventStore.ts";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These newly added service-layer imports use named Live bindings rather than module namespaces. Could you import each service module as a namespace and reference its layer through that namespace in OrchestrationEventInfrastructureLayerLive? This keeps service wiring consistent with the Effect service boundary convention.

Posted via Macroscope — Effect Service Conventions

@macroscopeapp

macroscopeapp Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Correction to my Effect Service Conventions inline comment on apps/server/src/orchestration-v2/runtimeLayer.ts: the two Live imports come from legacy implementation-layer modules, rather than canonical service modules. The namespace convention does not apply to them. Please disregard that finding.

Posted via Macroscope — Effect Service Conventions

@juliusmarminge
juliusmarminge force-pushed the v2/thread-search-reads-v2 branch from 4631865 to 5095efd Compare September 28, 2026 17:21
@juliusmarminge
juliusmarminge merged commit 613a1b2 into t3code/codex-turn-mapping Sep 28, 2026
32 of 33 checks passed
@juliusmarminge
juliusmarminge deleted the v2/thread-search-reads-v2 branch September 28, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant