Skip to content

fix(server): restore the reads and test isolation the 20261116 sync merge dropped - #466

Merged
tannerpolley merged 1 commit into
mainfrom
issue-449-11-server-tests-fail-on-main
Nov 17, 2026
Merged

tannerpolley merged 1 commit into
mainfrom
issue-449-11-server-tests-fail-on-main

Conversation

@tannerpolley

Copy link
Copy Markdown
Owner

14 server tests failed on main after the upstream sync merge 721ba11236 (#428). Both parents pass them, the fork parent d9c88282ab and the nightly 7d32075e37. Each failure comes from how the merge combined the two sides.

Root cause per failure group

FoundationPersistence: 9 tests

Merge hunk: FoundationPersistence.test.ts, "filters worker replay and live queues". The fork wrapped this test in Effect.scoped(…).pipe(Effect.provide(Layer.fresh(layerTest))) (added in 436c0d0). Upstream pingdotgg#35993 removed the Effect.scoped wrapper, and the merge took upstream's version, which dropped the fork's Layer.fresh.

The test writes completed runs that have no assistant reply. The fork's silent-completion check in EventSink.ts enqueues a run.silence.check effect for each one. Without a fresh layer, those two pending effects stay in the shared in-memory database for every later test in the it.layer block. The extra effects explain every failure in this group: two claims, never claiming provider-turn.start, title-cap misses, requeue counts of 2–4, and the 120 s lease hang. Logged before the first failing test:

[{"effect_id":"silent-wake:run:filtered-worker","effect_type":"run.silence.check","status":"pending",…},
 {"effect_id":"silent-wake:run:filtered-worker-other","effect_type":"run.silence.check","status":"pending",…}]

Fix: restore .pipe(Effect.scoped, Effect.provide(Layer.fresh(layerTest))). Effect.scoped must sit inside the provide so the test's acquireRelease restore runs before the fresh database closes. This was test isolation only; no product bug.

Orchestrator.control-reads: 2 tests

These tests come from upstream (nightly). They catch fork reads that walk a thread's history.

  1. "starts and finishes a delegated task without reading the parent's history" (49,655 VM steps against a limit of about 2,479). The merge resolved three hunks in favor of the fork's broad reads, dropping upstream's narrowed ones:
    • dispatchDelegatedTaskRequest: upstream reads getRunProviderRecords(parentThreadId, parentRunId, parentNodeId); the merge kept the fork's getThreadRecords(parent, [runs, nodes, subagents, providerThreads, providerTurns, attempts]). Fix: use upstream's run-scoped read. The fork's broad read stays only for a run-less delegation (parentRunId === null), minus subagents, which nothing used. reuseManagedChild reads only .thread, so its parameter type is now ProjectionRecords<never>.
    • finalizeAppOwnedSubagent: the merge dropped upstream's subagentChildThreadIds: [childThreadId] filter on the parent subagent read. Fix: restore the filter. The loop already skips other children.
    • offerDelegatedCompletionDelivery: upstream reads only the parent run and its provider thread; the merge kept the fork's read of all runs and provider threads. Fix: use runIds / providerThreadIds filters. The fork's parentRunId === null path (thread-level cohort) is kept.
  2. "queued-message commands read a long thread's history without walking all of it". Two fork reads matched the history-walk check:
    • message.dispatch: the fork's continueAdmissions (IssueWorkCommands.ts) loaded the full thread shell for each queued run just to read linkedIssue and role. Fix: read the thread row (getThread), keeping the deleted-thread skip that the shell read gave.
    • queued-run.cancel: the fork's EndedRunTurnItems reads by turnItemRunId plus a status filter, which seeks thread_ordinal_idx (thread_id=?). Fix: in ProjectionStore's turn-item read, use upstream's existing rowid IN (…) seek for a run filter too, not only a type filter.

ProjectionStore.fork: 3 tests

  • "subagent discovery retains usage-limit failures…": the SQL is identical on both sides, but upstream migration 088 added turn_items_thread_type_idx (thread_id, type, status), and the planner now picks it over the fork's partial usage_limit_idx. Fix: INDEXED BY orchestration_v2_projection_turn_items_usage_limit_idx on that fork subquery.
  • ":906 archived thread in limit recovery": not a runtime bug. The merge took upstream perf(server): active thread reads filter on the archived_at column pingdotgg/t3code#28992 (AND t.archived_at IS NULL in place of json_extract(payload_json,'$.archivedAt') IS NULL). Real archive events write the column: the thread upsert in ProjectionStore.ts sets archived_at from nullableStringField(payload, "archivedAt"). The test archived by json_set on payload_json alone. No test asserted the column after an archive event, so I added one assertion to the closest archive projection test, ProjectionSettlement.test.ts ("sql: a subagent thread becomes a candidate once its parent is done"):
    if (type === "thread.archived") {
      const [row] = yield* (yield* SqlClient.SqlClient)<{ readonly archived_at: string | null }>`SELECT archived_at FROM orchestration_v2_projection_threads WHERE thread_id = ${parent}`;
      assert.equal(row?.archived_at, DateTime.formatIso(now));
    }
    It passes, which shows that a thread.archived event applied through the projector writes archived_at. The fork test now sets the column with the payload, as a real archive does (owner-approved).
  • ":1222 live command records plan": the merge took upstream's turn-item read, which seeks rowid IN (…) through upstream's covering type index, and dropped the fork-only INDEXED BY …_recovery_idx branch. The new plan is bounded: SEARCH orchestration_v2_projection_turn_items USING COVERING INDEX orchestration_v2_projection_turn_items_thread_type_idx (thread_id=? AND type=? AND status=?). The expected plan line was updated (owner-approved); the filtering and order assertions stay. The test title still says "recovery index".
    • turn_items_recovery_idx usage: after this change, no query names it, on either side. The index is created by an upstream migration (Migrations/OrchestrationV2/RecoveryIndexes.ts), not a fork one, and nightly doesn't name it either. The planner may still pick it for queries without a hint. Not dropped here; that is a follow-up decision.

Evidence

On main 4a0f11ee58 (logs from the #449 investigation):

control-reads:        × starts and finishes a delegated task without reading the parent's history  (expected 49655 to be at most 2479.4)
                      × queued-message commands read a long thread's history without walking all of it
FoundationPersistence:× keeps one durable effect across command retries …   × allows only one worker to claim … (2 instead of 1)
                      × starts a provider turn while slow title generations are running   × holds pending titles at the running-title cap …
                      × does not reclaim a running effect after its process-local lease expires (120043ms)
                      × starts later thread work behind a delegated-task stop … (replayed: true)   × leaves restart continuation pending …
                      × retires … terminal.cleanup after process loss ({requeued: 4})   × retires … provider-runtime.continue … ({requeued: 2})
ProjectionStore.fork: × projects only the latest failed root turn's limit …   × live command records search the recovery index …
                      × subagent discovery retains usage-limit failures behind held continuations

On this branch:

vp test run FoundationPersistence.test.ts Orchestrator.control-reads.test.ts ProjectionStore.fork.test.ts ProjectionSettlement.test.ts
 Test Files  4 passed (4)
      Tests  123 passed (123)
vp run check:changed: format, lint, knip, typecheck (3 packages), test (8 files, 187 tests): all pass

No test was skipped or weakened. The branch merges cleanly onto the current origin/main (1077162d6d).

Closes #449

Done by Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

…erge dropped

The sync merge 721ba11 (#428) kept fork code where upstream had narrowed
reads, and dropped one fork test isolation, so 14 server tests failed on main:

- FoundationPersistence: a fork test lost Layer.fresh, so its run.silence.check
  effects leaked into later shared-database tests.
- control-reads: delegated tasks read the parent's whole history again
  (upstream getRunProviderRecords, subagentChildThreadIds and run-scoped
  completion delivery reads were dropped); fork continueAdmissions and
  EndedRunTurnItems walked the thread.
- ProjectionStore.fork: the subagent usage-limit lookup lost its partial index
  to upstream's new type index; two fork tests asserted fork-only details
  upstream replaced (archived_at column, type-index plan).

Closes #449

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

11 server tests fail on main: FoundationPersistence (9) and Orchestrator.control-reads (2)

1 participant