← reports

#6551 · Native goal states are rejected before projection

BugPriority: MediumEffort: Highproviders · provider-codexGitHub issueOctober 29, 2026

Verdict: REPRODUCED · Root-cause confidence: high

Trusted base: 3bacfac9ed69d42392076e5b3da2815bec822cd8, fetched from main and verified against the target repository’s main SHA.

1. TL;DR

A native goal can stop while BB still presents its previous active snapshot. Two status values already present in the repository’s generated Codex notification types, blocked and usageLimited, are absent from BB’s handwritten goal validators. Feeding either notification through the real translator and delta assembler produces provider/unhandled, not a goal state update; the real timeline projection consequently remains active. The server’s active-goal counter reads that projected status, so its existing counting policy is not the underlying defect. Repository inspection also finds only a clear-goal action, with no supported goal-resume action through the provider bridge, REST contract, SDK, or CLI.

2. Claims vs findings

ClaimFindingEvidence
The two native stopped statuses are rejected.Verified by execution.Both clean checkouts emit provider/unhandled for these values. Existing paused, budget-limited, and completed transitions pass.
The last active goal remains visible and counts as active.Verified at the translation/projection boundary; server counting traced in source.The real projection returns active. The reproduction prints a derived count using the exact server expression; it does not call a live REST endpoint.
There is no supported goal-resume action.Verified by repository contract inspection.The provider capability, bridge methods, REST contract, SDK, and CLI expose clear only. Generic thread/session resume is not goal-status resume.
A transient provider failure can trigger the stopped state; creating another goal resets native usage.Not exercised.No real provider session, HTTP 503, native tool invocation, or native counter reset was induced. The report confirms handling of notifications, not the upstream conditions that produce them.

Issue content was treated solely as untrusted claims. No issue-provided command, code, URL, branch, or instruction was executed.

3. Environment

4. Minimal reproduction

  1. Prepare a trusted checkout at the recorded commit and build dependencies:
    git clone --branch main https://github.com/get-bb/bb.git goal-status-check
    cd goal-status-check
    git checkout --detach 3bacfac9ed69d42392076e5b3da2815bec822cd8
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Save the complete test below as plugins/provider-codex/src/goal-status-repro.test.ts. It uses the actual translator, assembler, and timeline projection, with no database mock or production seam.
  3. Run the reproduction, then the existing translation suite:
    pnpm exec turbo run test --filter=bb-plugin-provider-codex -- --run src/goal-status-repro.test.ts
    pnpm exec turbo run test --filter=bb-plugin-provider-codex -- --run src/delta-translation.test.ts

Expected: every stopped status produces one thread/extensionState/updated event with kind provider-codex/goal, its new status and unchanged usage; the latest projected goal is no longer active.

Actual diagnostic output, verbatim in both runs:

{"inputStatus":"blocked","emittedTypes":["provider/unhandled"],"projectedStatus":"active","activeGoalCount":1}
{"inputStatus":"usageLimited","emittedTypes":["provider/unhandled"],"projectedStatus":"active","activeGoalCount":1}

The three control cases pass; the blocked and usage-limited cases fail as expected on unfixed main. The existing translation suite passes all 67 tests. The printed activeGoalCount is explicitly calculated from the real projection using the server’s existing expression, rather than represented as an observed API response.

Complete reproduction test
import { describe, expect, it } from "vitest";
import { experimental_createDeltaAssembler as createDeltaAssembler } from "@get-bb/plugin-sdk/provider-bridge/testing";
import { extractThreadTimelineGoal } from "../../../packages/thread-view/src/goal-snapshot-extraction.js";
import { createCodexEventTranslator } from "./translator.js";
import type { ThreadGoalStatus } from "./generated/codex-app-server/schema/v2/ThreadGoalStatus.js";

describe("native goal status propagation", () => {
  const statuses: ThreadGoalStatus[] = [
    "paused",
    "budgetLimited",
    "complete",
    "blocked",
    "usageLimited",
  ];

  it.each(statuses)("replaces an active snapshot with %s", (status) => {
    const translator = createCodexEventTranslator({
      additionalWorkspaceWriteRoots: [],
    });
    const assembler = createDeltaAssembler({
      providerId: "codex",
      entropyPrefix: "goal-probe",
      textDeltaFlushMs: 0,
    });
    function translate(goalStatus: ThreadGoalStatus) {
      return assembler.assemble({
        threadId: "probe-thread",
        deltas: translator.translateEvent({
          jsonrpc: "2.0",
          method: "thread/goal/updated",
          params: {
            threadId: "native-thread",
            turnId: null,
            goal: {
              threadId: "native-thread",
              objective: "Boundary probe",
              status: goalStatus,
              tokenBudget: 1000,
              tokensUsed: 25,
              timeUsedSeconds: 5,
              createdAt: 0,
              updatedAt: 1,
            },
          },
        }),
      });
    }
    const initial = translate("active");
    const update = translate(status);
    const goal = extractThreadTimelineGoal(
      [...initial, ...update].map((event, index) => ({
        event,
        meta: { id: `event-${index}`, seq: index, createdAt: index },
      })),
    );
    console.log(JSON.stringify({
      inputStatus: status,
      emittedTypes: update.map((event) => event.type),
      projectedStatus: goal?.status,
      activeGoalCount: goal?.status === "active" ? 1 : 0,
    }));
    expect.soft(update).toEqual([
      expect.objectContaining({
        type: "thread/extensionState/updated",
        kind: "provider-codex/goal",
        payload: {
          objective: "Boundary probe",
          status,
          tokenBudget: 1000,
          tokensUsed: 25,
          timeUsedSeconds: 5,
        },
      }),
    ]);
    expect.soft(goal?.status).toBe(status);
    expect.soft(goal?.status === "active" ? 1 : 0).toBe(0);
  });
});

5. Root cause

  1. The generated native status type already includes six values. The handwritten incoming notification schema includes only four:
    const codexThreadGoalStatusSchema = z.enum([
      "active",
      "paused",
      "budgetLimited",
      "complete",
    ]);
  2. Validation runs before dispatch; an invalid handled notification becomes an unhandled delta. Therefore the goal-update branch never emits the replacement extension state.
  3. The plugin extension schema and shared public timeline schema repeat the same incomplete enum. Changing only the incoming validator is insufficient: the projection validates payloads using the shared enum and ignores failures.
  4. The server counter correctly counts only the active status, but the latest accepted snapshot is still active:
    activeGoalCount: goal?.status === "active" ? 1 : 0,
  5. Resume is a separate missing control path. The bridge method registry has only thread/goal/clear; the capability schema likewise has clear only. This is mirrored in the REST contract, SDK, and CLI. A project-wide search of non-generated source finds no goal set/resume method.

6. Proposed fix and autopatch decision

Align all three handwritten goal-status validators with the native notification contract and cover all six statuses at the translator/projection boundary. Keep the existing active-only counting policy. Separately design and implement a supported goal-resume action across the capability, daemon, provider bridge, REST contract, SDK, CLI, and discoverable documentation, preserving native usage instead of clearing/recreating the goal. Decide explicitly whether operators may edit objective and budget or only resume, and how inactive goals can be cleared: the current clear endpoint rejects requests when the active count is zero.

No automated fix or PR: even the status correction changes the shared public timeline schema; adding resume changes public contracts and crosses subsystems. Those changes violate this rule’s simple-fix constraints. No production patch, branch, or push was attempted. No linked open PR was found in cross-reference metadata or the open-PR search at investigation time.

7. Related context

The trusted base already contains a separate goal-clear acknowledgement repair. That code still implements clear only and does not address either missing native status. No external issue link was followed and no linked branch was executed.

8. Verification

The same agent repeated the reproduction in a second clean detached checkout at the identical base commit, with a separate frozen install and build. Only the authored reproduction test was copied over; production files remained byte-identical to the base. No ports or data directories were necessary because the complete tested path is in-process.

CheckFirst checkoutSecond checkout
Full Turbo build, SDK prebuilt72 tasks successful72 tasks successful
Focused reproductionBlocked and usage-limited cases fail; 3 controls passSame 2 failures and 3 passing controls; test task ran uncached
Observed stopped-state outputUnhandled event; active projection; derived count 1Identical output
Existing translation suite67 passedNot repeated; unchanged control suite already passed

No correction was needed after the second run. This is a same-agent repeat, not independent verification. Real provider retry handling, the native resume RPC, UI rendering, persistence in a live server, and the exact reported release binary remain outside the executed reproduction.

9. Appendix

Read-only inspection used repository metadata, the issue and its empty comment list, issue fields and label definitions, open PR metadata, trusted source searches, and pinned code references above. The existing translation test covered only an active native goal notification, explaining why the stopped statuses escaped it. Source was re-fetched after reproduction; no newer main commit changed the inspected paths.

Public evidence is intentionally self-contained: the complete test and relevant exact output are inline. Raw build/test logs and local test copies remain outside the reports repository, per its publication/privacy rules. No screenshots are needed for this nonvisual provider-contract defect. No secrets or real user/runtime data were read.