Skip to content

ui-server: cron checks a smaller private-state layout than the server #4498

Open

Description

@schlessera

Part of #4426. Found in the second independent review of PR #4490, which fixes #4486 and #4487. It can start independently: PR #4490 does not touch the files below.

Context

Line numbers are at main 356fa7d (unchanged at PR #4490's head c1f7103a1).

  • cronHostExecution (packages/ui-server/src/bin/brain-ui-cron.ts:110-118) checks only the native lease path (:117) plus the database paths that operationalStateRefusal derives from dbPath. Both cron entry points use it (:166, :202).
  • Cron module discovery (persistModuleDiscovery, packages/ui-server/src/cron/module-discovery.ts:193-198) checks only { brainPath, dbPath }.
  • The server also checks the inbox poke token, transfer cache, turn journal, native lease, web executor state and, when configured, compute state (packages/ui-server/src/app.ts:398-422, checked at :427).

A private-state alias or a scan failure in one of the paths cron skips is invisible to cron jobs and cron module discovery. main has the same gap.

Scope

One shared builder for the private-state layout, used by the server, both cron entry points and cron module discovery. The builder derives each path from the same configuration the server uses (dbPath, native lease path, inbox poke token file, compute state directory), keeping the server's conditions: compute state only when configured, and, for an ephemeral database ("" or :memory:, app.ts:398), the server's fresh temporary journal directory, which cron cannot share and does not need to check.

Exclusions: what the check does with each path (#4494, #4499); creating directories (the server's mkdirSync for compute state stays in app.ts).

Acceptance criteria

  • The server and cron derive privateStatePaths from the same exported function; neither builds the list inline.
  • A test with an alias only in the turn journal makes cron refuse (OperationalStateInBrainError or private_state_in_brain), and fails first on the current code.
  • A test pins that the server's layout is unchanged (same settings and paths as today for a durable database, an ephemeral database and a host with compute state).

Verification

bun run test on the targeted cron and operational-state test files, with failing-first and mutation receipts in the PR.

Contract impact

None: no wire, CLI or status shape changes. Cron can newly refuse on a host whose journal or other private state already aliases into the brain, which the server already refuses.

2026-11-23 triage at main 356fa7d: re-pointed citations at main, added cron module discovery to the gap, stated that it does not wait on #4490, added scope details, exclusions, a no-regression criterion, verification and contract impact.

Activity

  1. added
    area: ui-server
    priority: p2
    on Nov 23, 2026
  2. added
    type: fix
    agent-ready
    and removed on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-serverpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions