Reports

#8033 · Provider archive rejection is not surfaced

BugPriority: MediumEffort: Mediumthreads · providers · provider-codex

GitHub issue · 2026-11-23 · trusted main 796cdcc0f4bf8a55e23664035c54e8db6fe9d272

Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high for BB's server-side failure visibility and repeat-archive behavior; no conclusion about the external lock owner.

1. TL;DR

BB archives a thread in its own database before its provider archive command settles. A failed provider command is logged, but the archive response remains successful and the ordinary thread-detail response does not contain the failure. Repeating the archive request on that archived thread returns an empty success and does not send another provider archive command. This mechanism was reproduced twice against unchanged production code using a real migrated SQLite database and an injected negative host-RPC response. The Windows/Desktop active-writer conflict, native archive state, and Desktop lists were not reproduced on this Linux host.

2. Claims vs findings

ClaimFindingEvidence
Local archive succeeds despite a provider failureVerified at the server boundaryBoth runs: HTTP 200, ok true, archivedAt set, idle status after negative RPC settlement.
Provider failure is only logged rather than surfaced with archive statusVerified for archive and thread-detail APIsWarning observed; no failure in thread detail or either archive response.
Retry/recovery needs improvementVerified for simply repeating archiveSecond archive returns an empty list and no new provider archive RPC. Other recovery approaches were not exercised.
CLI prints unconditional successSupported by trusted source; not executed liveCLI builds its headline from archivedThreadIds and archivedAt only.
Codex rejects an archive while Desktop holds a writerUnverifiedNo Windows or Codex Desktop session used. The fault response is synthetic, not a real Codex error.
Desktop remains unarchived after the grace periodUnverifiedNo Desktop, native thread-list query, lock-owner check, or real-time grace wait performed.

3. Environment

4. Minimal reproduction

  1. Use a clean checkout of trusted main at the recorded commit, install frozen dependencies, and prepare the existing build outputs:
    git clone https://github.com/get-bb/bb.git bb-repro
    cd bb-repro
    git checkout --detach 796cdcc0f4bf8a55e23664035c54e8db6fe9d272
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Copy the complete inline reproduction test into apps/server/test/threads/archive-provider-failure.repro.test.ts. This is an investigation-authored test, not code supplied by the issue.
  3. Run:
    pnpm exec turbo run test --filter=@bb/server -- test/threads/archive-provider-failure.repro.test.ts
  4. The test creates an idle Codex-backed thread with an identity, archives it through the real route, settles its captured archive RPC with a synthetic rejection, then repeats archive and reads thread detail.

Expected observability: a rejected provider archive should be discoverable to the caller, and repeating archive should not masquerade as a provider retry when none occurs. The final sentinel assertion specifically looks for the error text in thread detail; this is one possible future contract, not a decision that this exact API shape must be adopted.

Actual output, identical in both runs:

{"archiveHttpStatus":200,"archiveOk":true,"archivedLocally":true,"providerFailureLogged":true,"retryArchivedCount":0,"retryProviderCommandCount":0,"providerFailureInThreadDetail":false}
AssertionError: expected thread-detail JSON to contain 'synthetic provider refused archival'
Test Files  1 failed (1)
Tests       1 failed (1)

The JSON and test totals are verbatim; the assertion line is shortened here. See relevant sanitized first-run output and second-run output for exact Vitest failure rendering. A nonzero exit is intentional and demonstrates the absent observable error, not a setup failure.

Complete reproduction test
import { getThread } from "@bb/db";
import { expect, it, vi } from "vitest";
import {
  listQueuedThreadCommands,
  reportQueuedCommandError,
  waitForQueuedCommand,
} from "../helpers/commands.js";
import { seedThreadFixture, seedThreadIdentity } from "../helpers/seed.js";
import { withTestHarness } from "../helpers/test-app.js";

it("makes a rejected provider archive visible to the archive caller", async () => {
  await withTestHarness(async (harness) => {
    const { environment, thread } = seedThreadFixture(harness, {
      environment: { path: "/tmp/archive-provider-repro", status: "ready" },
      thread: { status: "idle", providerId: "codex" },
    });
    seedThreadIdentity(harness.deps, {
      environmentId: environment.id,
      threadId: thread.id,
      providerThreadId: "synthetic-provider-thread",
    });
    const warning = vi.spyOn(harness.deps.logger, "warn");
    try {
      const response = await harness.app.request(
        `/api/v1/threads/${thread.id}/archive-all`,
        { method: "POST" },
      );
      const archiveResult = await response.json();
      const command = await waitForQueuedCommand(
        harness,
        ({ command }) =>
          command.type === "thread.archive" && command.threadId === thread.id,
      );
      const providerFailure = "synthetic provider refused archival";
      await reportQueuedCommandError(harness, command, {
        errorCode: "synthetic_archive_rejection",
        errorMessage: providerFailure,
      });
      await vi.waitFor(() =>
        expect(warning).toHaveBeenCalledWith(
          expect.objectContaining({ threadId: thread.id }),
          "Live thread archive command failed",
        ),
      );
      expect(response.status).toBe(200);
      expect(archiveResult).toEqual({
        ok: true,
        archivedThreadIds: [thread.id],
      });
      expect(getThread(harness.db, thread.id)).toMatchObject({
        archivedAt: expect.any(Number),
        status: "idle",
      });
      const retry = await harness.app.request(
        `/api/v1/threads/${thread.id}/archive-all`,
        { method: "POST" },
      );
      const retryResult = await retry.json();
      expect(retryResult).toEqual({ ok: true, archivedThreadIds: [] });
      expect(
        listQueuedThreadCommands(harness, "thread.archive", thread.id),
      ).toEqual([]);
      const detail = await harness.app.request(`/api/v1/threads/${thread.id}`);
      expect(detail.status).toBe(200);
      const detailResult = await detail.json();
      console.log(
        JSON.stringify({
          archiveHttpStatus: response.status,
          archiveOk: archiveResult.ok,
          archivedLocally: getThread(harness.db, thread.id)?.archivedAt !== null,
          providerFailureLogged: true,
          retryArchivedCount: retryResult.archivedThreadIds.length,
          retryProviderCommandCount: listQueuedThreadCommands(
            harness,
            "thread.archive",
            thread.id,
          ).length,
          providerFailureInThreadDetail: JSON.stringify(detailResult).includes(
            providerFailure,
          ),
        }),
      );
      expect(JSON.stringify(detailResult)).toContain(providerFailure);
    } finally {
      warning.mockRestore();
    }
  });
});

5. Root cause

  1. Local archive precedes asynchronous provider forwarding: archiveThreadAndReleaseChildren commits local archive state; dispatchSettledArchivedThreadProviderArchiveCommand is then called without any returned provider outcome.
  2. The provider archive error callback only logs a warning. startLiveHostCommand runs detached and returns void.
  3. Live result settlement has no thread.archive handler: an archive success or failure returns empty side effects rather than recording a synchronization outcome.
  4. The archive route returns ok true with local archive IDs; the CLI derives success from local metadata only. The API/CLI success is therefore not proof of native-provider success.
  5. Already-archived candidates skip provider archive dispatch, explaining the observed no-op repeat request.
  6. The daemon awaits runtime archive; Codex maintenance forwards unrecognized failures and only retries rename; archive invokes native thread/archive. These source paths explain how a native rejection can reach BB's logged-only failure handler; they were inspected, not run against a live provider.

The root cause is a missing product-level synchronization outcome and recovery contract, not proof that BB owns the native writer lock. A valid local archive can coexist with a failed provider archive. Rolling back local archive, bypassing writer protection, or stopping unrelated runtimes is not justified by this evidence.

6. Proposed fix and simple-fix assessment

Define explicit provider-sync states and an idempotent retry action for an already locally archived thread. Surface the settled failure through the shared API/SDK path and user-facing controls, while preserving intentional local-archive and running-turn grace semantics. Specify behavior for offline hosts, unsupported providers, repeated requests, and delayed settlement before implementation.

No fix PR: a durable, recoverable cross-surface synchronization result requires a product/API or persistence decision and spans the lifecycle plus its presentation surfaces. That fails the autopilot's no-product-decision / single-subsystem simple-fix gate. A wording-only change would not make the failure recoverable. No production code was changed, and no fix branch was pushed.

7. PR review

No open linked PR was found through issue cross-reference/connection metadata or an open-PR search for issue 8033. No linked branch or patch was checked out or executed.

8. Related issues

No external issue-data links were fetched. Native writer ownership and Desktop catalog behavior are separate questions from the verified server-side outcome loss.

9. Verification

The same agent repeated the test in a second clean detached checkout at 796cdcc0f4bf8a55e23664035c54e8db6fe9d272, with a separate installation and a new harness temporary database/data directory. No production files were patched in either checkout. The command above again exited 1 at the final missing-error assertion after every setup, local-archive, warning, and no-op-retry assertion passed. The structured observation JSON was identical. This is repeat verification by the same agent, not an independent review.

No claim was upgraded to a complete Windows reproduction: the final verdict remains PARTIALLY REPRODUCED. The second run required no correction to the server-root-cause finding.

Relevant existing coverage also passed:

pnpm exec turbo run test --filter=@bb/server -- test/threads/archive-undo-grace.test.ts test/threads/archive-request-logging.test.ts
Test Files  2 passed (2)
Tests       8 passed (8)

10. Appendix and trust boundary

The complete reproduction test is inline above. The relevant exact test outputs are inline below. Raw evidence is retained outside the public repository, as required by its publication policy. All reproduction commands and required setup are documented above.

Outputs contain synthetic fixtures only. Checkout paths and synthetic generated identifiers were replaced with neutral labels; no user conversations, credentials, production logs, real provider thread IDs, home paths, or raw databases are published. Issue prose, examples, and links were treated only as untrusted claims. No issue-supplied command, script, patch, branch, binary, or external URL was run or fetched. The reproduction was derived from trusted repository source and uses no new dependency.

First run

@bb/server:test:  RUN  v4.1.12 <checkout-one>/apps/server
@bb/server:test: 
@bb/server:test: (node:8984) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test: stdout | test/threads/archive-provider-failure.repro.test.ts > makes a rejected provider archive visible to the archive caller
@bb/server:test: {"archiveHttpStatus":200,"archiveOk":true,"archivedLocally":true,"providerFailureLogged":true,"retryArchivedCount":0,"retryProviderCommandCount":0,"providerFailureInThreadDetail":false}
@bb/server:test: 
@bb/server:test:  ❯ |@bb/server| test/threads/archive-provider-failure.repro.test.ts (1 test | 1 failed) 777ms
@bb/server:test:    × makes a rejected provider archive visible to the archive caller 135ms
@bb/server:test: 
@bb/server:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@bb/server:test: 
@bb/server:test:  FAIL  |@bb/server| test/threads/archive-provider-failure.repro.test.ts > makes a rejected provider archive visible to the archive caller
@bb/server:test: AssertionError: expected '{"id":"thr_TEST","projectId":"p…' to contain 'synthetic provider refused archival'
@bb/server:test: 
@bb/server:test: Expected: "synthetic provider refused archival"
@bb/server:test: Received: "{"id":"thr_TEST","projectId":"proj_TEST","environmentId":"env_TEST","providerId":"codex","title":"Test Thread","titleFallback":"Test Thread","sectionId":null,"status":"idle","parentThreadId":null,"sourceThreadId":null,"lifecycleOwnerThreadId":null,"originKind":null,"originPluginId":null,"visibility":"visible","parentNotifications":"auto","archivedAt":1795424123910,"pinnedAt":null,"deletedAt":null,"lastReadAt":1795424123890,"latestAttentionAt":1795424123890,"createdAt":1795424123890,"updatedAt":1795424123910,"runtime":{"displayStatus":"idle"},"activeBackgroundAgentCount":0,"canRestoreEnvironment":false,"canEditMessages":false,"canSpawnChild":true,"queuedMessageCount":0}"
@bb/server:test: 
@bb/server:test:  ❯ test/threads/archive-provider-failure.repro.test.ts:83:44
@bb/server:test:      81|         }),
@bb/server:test:      82|       );
@bb/server:test:      83|       expect(JSON.stringify(detailResult)).toContain(providerFailure);
@bb/server:test:        |                                            ^
@bb/server:test:      84|     } finally {
@bb/server:test:      85|       warning.mockRestore();
@bb/server:test:  ❯ withTestHarness test/helpers/test-app.ts:430:12
@bb/server:test:  ❯ test/threads/archive-provider-failure.repro.test.ts:12:3
@bb/server:test: 
@bb/server:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
@bb/server:test: 
@bb/server:test: 
@bb/server:test:  Test Files  1 failed (1)
@bb/server:test:       Tests  1 failed (1)
@bb/server:test:    Start at  08:55:14
@bb/server:test:    Duration  9.55s (transform 4.90s, setup 1.90s, import 4.65s, tests 777ms, environment 0ms)
@bb/server:test: 
@bb/server:test:  ELIFECYCLE  Test failed. See above for more details.
@bb/server#test:  ERROR  command (<checkout-one>/apps/server) /usr/local/bin/pnpm run test test/threads/archive-provider-failure.repro.test.ts exited (1)

 Tasks:    10 successful, 11 total
Cached:    0 cached, 11 total
  Time:    47.22s 
Failed:    @bb/server#test

 ERROR  run failed: command  exited (1)

Second clean-checkout run

@bb/server:test:  RUN  v4.1.12 <checkout-two>/apps/server
@bb/server:test: 
@bb/server:test: (node:10072) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test: stdout | test/threads/archive-provider-failure.repro.test.ts > makes a rejected provider archive visible to the archive caller
@bb/server:test: {"archiveHttpStatus":200,"archiveOk":true,"archivedLocally":true,"providerFailureLogged":true,"retryArchivedCount":0,"retryProviderCommandCount":0,"providerFailureInThreadDetail":false}
@bb/server:test: 
@bb/server:test:  ❯ |@bb/server| test/threads/archive-provider-failure.repro.test.ts (1 test | 1 failed) 790ms
@bb/server:test:    × makes a rejected provider archive visible to the archive caller 141ms
@bb/server:test: 
@bb/server:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@bb/server:test: 
@bb/server:test:  FAIL  |@bb/server| test/threads/archive-provider-failure.repro.test.ts > makes a rejected provider archive visible to the archive caller
@bb/server:test: AssertionError: expected '{"id":"thr_TEST","projectId":"p…' to contain 'synthetic provider refused archival'
@bb/server:test: 
@bb/server:test: Expected: "synthetic provider refused archival"
@bb/server:test: Received: "{"id":"thr_TEST","projectId":"proj_TEST","environmentId":"env_TEST","providerId":"codex","title":"Test Thread","titleFallback":"Test Thread","sectionId":null,"status":"idle","parentThreadId":null,"sourceThreadId":null,"lifecycleOwnerThreadId":null,"originKind":null,"originPluginId":null,"visibility":"visible","parentNotifications":"auto","archivedAt":1795424186503,"pinnedAt":null,"deletedAt":null,"lastReadAt":1795424186482,"latestAttentionAt":1795424186482,"createdAt":1795424186482,"updatedAt":1795424186503,"runtime":{"displayStatus":"idle"},"activeBackgroundAgentCount":0,"canRestoreEnvironment":false,"canEditMessages":false,"canSpawnChild":true,"queuedMessageCount":0}"
@bb/server:test: 
@bb/server:test:  ❯ test/threads/archive-provider-failure.repro.test.ts:83:44
@bb/server:test:      81|         }),
@bb/server:test:      82|       );
@bb/server:test:      83|       expect(JSON.stringify(detailResult)).toContain(providerFailure);
@bb/server:test:        |                                            ^
@bb/server:test:      84|     } finally {
@bb/server:test:      85|       warning.mockRestore();
@bb/server:test:  ❯ withTestHarness test/helpers/test-app.ts:430:12
@bb/server:test:  ❯ test/threads/archive-provider-failure.repro.test.ts:12:3
@bb/server:test: 
@bb/server:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
@bb/server:test: 
@bb/server:test: 
@bb/server:test:  Test Files  1 failed (1)
@bb/server:test:       Tests  1 failed (1)
@bb/server:test:    Start at  08:56:16
@bb/server:test:    Duration  9.67s (transform 5.11s, setup 1.77s, import 5.12s, tests 790ms, environment 0ms)
@bb/server:test: 
@bb/server:test:  ELIFECYCLE  Test failed. See above for more details.
@bb/server#test:  ERROR  command (<checkout-two>/apps/server) /usr/local/bin/pnpm run test test/threads/archive-provider-failure.repro.test.ts exited (1)

 Tasks:    10 successful, 11 total
Cached:    6 cached, 11 total
  Time:    42.387s 
Failed:    @bb/server#test

 ERROR  run failed: command  exited (1)

Relevant existing suites

@bb/server:test:  RUN  v4.1.12 <checkout-one>/apps/server
@bb/server:test: 
@bb/server:test: (node:10253) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test: (node:10252) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test:  ✓ |@bb/server| test/threads/archive-request-logging.test.ts (2 tests) 958ms
@bb/server:test:  ✓ |@bb/server| test/threads/archive-undo-grace.test.ts (6 tests) 1150ms
@bb/server:test: 
@bb/server:test:  Test Files  2 passed (2)
@bb/server:test:       Tests  8 passed (8)
@bb/server:test:    Start at  08:56:31
@bb/server:test:    Duration  9.60s (transform 8.75s, setup 3.30s, import 9.60s, tests 2.11s, environment 0ms)
@bb/server:test: 

 Tasks:    11 successful, 11 total
Cached:    0 cached, 11 total
  Time:    43.086s 

 WARNING  no output files found for task @bb/server#test. Please check your `outputs` key in `turbo.json`

AGENT GENERATED