Skip to content

refactor(server): project reads and replay stats leave ProjectionSnapshotQuery - #14012

Merged
juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
v2/project-reads-leave-snapshot-query
Sep 28, 2026
Merged

juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
v2/project-reads-leave-snapshot-query

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Stacked on #13960.

Project reads still went through the V1 ProjectionSnapshotQuery (and its ProjectionProjectRepository), and shell resume measured its replay range there too. That kept a V1 read service in every layer that touched a project, and it is the last thing blocking deletion of the snapshot query.

What changed

  • Unenriched reads use ProjectStoreV2. These callers need only the row, not repository identity: ws/http shell snapshots and the archived shell, startup auto-pull, storage cleanup, the auto-pull policy, thread settlement, the thread PR sweep, refreshPushedPullRequests, the agent-session scanner and the project-favicon asset lookup. listShells gains an optional projectIds filter.
  • Enriched reads use ProjectService.getShell / listShells. They return immediately available identity, as before. Callers are the shell-stream project delta, PR list/summary (PullRequestService), linkCreatedPullRequest, the MCP PR tools and ws PR-sync key resolution. Both methods live on ProjectService, not in free functions.
  • Replay stats. OrchestrationEventStore.getReplayStats({ afterSequence, throughSequence }) measures the same (after, through] range that readApplicationEvents replays: project events plus V2 thread events, via the application high-water index. The old query also counted V1 rows the resume never replays, so on imported installs it could fall back to a full snapshot early.
  • ProjectionProjectRepository is deleted. Orchestrator (PR-sync workspace check), RuntimePolicy (renamed layerFromProjectStore), thread title regeneration and the replay harness now read ProjectStoreV2. The V1 ProjectionPipeline's project projector was its last writer, and nothing has bootstrapped that pipeline since refactor(server): project commands commit through EventSinkV2 #13960 removed the V1 engine, so the projector is removed too. The repository's "model selection JSON" regression moved to ProjectStore.test.ts.
  • Wiring. server.ts provides ProjectStore.layer once at the runtime core. The auto-pull policy, settlement and PR workers no longer build their own OrchestrationInfrastructureLayerLive. The run-finalization observer gets ProjectServiceLayerLive by reference, so it shares the runtime's single ProjectService.

ProjectionSnapshotQuery now has two readers left, searchThreads and GitManager's thread → project lookup. Both are the next PR's scope.

No wire or contract change.

Verification

  • vp exec tsc --noEmit -p . (apps/server): 0 error TS / warning TS.
  • vpr knip:check: clean.
  • vp lint on touched files: no new warnings (the remaining ones predate this branch).
  • vp test run, in small groups, all passing:
    • project: ProjectService.test.ts, ProjectService.deletion.test.ts, ProjectStore.test.ts (new), ProjectCommands.test.ts, ProjectionRepositories.test.ts, http.test.ts, cli/project.test.ts
    • consumers: linkCreatedPullRequest.test.ts, MCP pullRequests/handlers.test.ts, McpHttpServer.test.ts, worktree/registration.test.ts, ThreadPullRequestService.test.ts, ThreadSettlementService.test.ts, PullRequestService.test.ts, PullRequestSyncReactor.test.ts, AgentSessionScanner.test.ts, RuntimePolicy.test.ts, ThreadTitleRegenerationService.test.ts, AgentAwarenessRelay.test.ts, GrokAdapterV2.test.ts, ThreadLaunchService.test.ts
    • runtime: runtimeLayer.test.ts, serverRuntimeStartup.test.ts, storageCleanup.test.ts, ws.test.ts, VcsStatusBroadcaster.test.ts, integration/transferBudgetV2.integration.test.ts
    • event store: OrchestrationEventStore.test.ts (adds a getReplayStats assertion that excludes V1 rows), OrchestrationEventStore.sequence.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:XL 500-999 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 PR reroutes numerous production project reads, removes a shared projection writer, and changes WebSocket replay budgeting across the runtime dependency graph. The targeted tests are helpful, but the scope and runtime impact exceed an auto-approvable refactor.

No code changes detected at d75890c. Prior analysis still applies.

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

@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.2 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅
Codex Live turn messages — 2 — 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.7 KiB — 29.3 KiB ✅
Claude Live turn messages — 1 — 8 ✅

Baseline: unavailable · PR result: d75890c · 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.

Base automatically changed from v2/projects-in-v2 to t3code/codex-turn-mapping September 28, 2026 17:10
…shotQuery

Project shells now come from ProjectStoreV2 when a caller needs only the
row, and from ProjectService.getShell/listShells when it reads repository
identity. Shell-resume replay stats come from
OrchestrationEventStore.getReplayStats, which measures only the retained
application events a resume replays.

The Orchestrator, RuntimePolicy, thread title regeneration and the replay
harness read ProjectStoreV2, so ProjectionProjectRepository is deleted along
with the V1 pipeline's project projector, which nothing has run since the V1
engine went away.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
},
) {
override get message(): string {
return `Active project '${this.conflictingProjectId}' already exists for workspace root '${this.workspaceRoot}'.`;

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.

This error persists and displays the unrestricted workspace root from a command. Please keep the raw value out of the error's public attributes/message (and rejected receipt), using bounded safe context such as the conflicting project ID instead.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/mcp/toolkits/pullRequests/tools.ts
Comment thread apps/server/src/git/linkCreatedPullRequest.ts
@macroscopeapp

macroscopeapp Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Correction to my Effect Service Conventions review: the comments on apps/server/src/git/linkCreatedPullRequest.ts and apps/server/src/mcp/toolkits/pullRequests/tools.ts were incorrect; both already import ProjectService as a namespace. Please disregard those two comments. The finding on ProjectCommands.ts remains applicable.

Posted via Macroscope — Effect Service Conventions

@juliusmarminge
juliusmarminge force-pushed the v2/project-reads-leave-snapshot-query branch from 13f83a8 to d75890c Compare September 28, 2026 17:13
@juliusmarminge
juliusmarminge merged commit 1d6bc0e into t3code/codex-turn-mapping Sep 28, 2026
24 checks passed
@juliusmarminge
juliusmarminge deleted the v2/project-reads-leave-snapshot-query branch September 28, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 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