Skip to content

ui-server: changed trust policy waits behind automatic indexing #4404

Open

Description

@schlessera

Out of scope

No change to origin matching, policy publication authority, historical verdicts or the existing index lock scope without a separate design. No bypass of live policy verification.

Context

Follow-up to #3609 and PR #4270. Automatic indexing holds the shared brain-docs lock through the maintenance command (packages/ui-server/src/brain/client.ts:333, where brain index takes the brain-docs key; packages/ui-server/src/brain/host-boundary.ts:714-715, which runs the command inside execution.lock.keyed.withLock). Qualified turn preparation refreshes prospective trust before backend entry (packages/ui-server/src/ws/session-run/backend-entry.ts:180). The unchanged-policy refresh fast path (PR #4405) avoids waiting only when verified policy bytes match the healthy durable projection (live, packages/ui-server/src/brain/trust-settings.ts:160-172); otherwise it queues BRAIN_LOCK_KEY. packages/ui-server/tests/trust-settings.test.ts:542 pins that a diverged refresh still queues the held lock, and ADMISSION_NEVER_WAITS_ON_HELD_INDEX_LOCK (packages/ui-server/tests/trust-settings.test.ts:563) covers only the unchanged case. An out-of-band governance.md edit during indexing still requires a locked projection refresh and can therefore delay admission beyond the ten-second hosted contract.

The binding red-main triage accepted the unchanged-policy fix and deferred this remaining contention case. The index lock scope predates #4270.

Scope

Give the trust projection refresh its own serialization (a separate trust-projection lock, or an equivalent ordering) so a changed-policy refresh completes independently of a running index, while preserving protected publication and exact removal fences. Narrowing the index command's own critical section is excluded by the out-of-scope rule above (it changes the existing index lock scope and needs a separate design); if the implementer finds a separate lock cannot preserve publication serialization, stop and record the reason on this issue rather than changing the index lock.

Acceptance criteria

  • A valid out-of-band trusted_sources change during a held/running index does not delay turn admission behind the index command.
  • Admission observes the new durable trust revision and exact policy hash; removed rules never authorize dispatch.
  • Settings and policy-proposal publications retain serialization and enforced-removal guarantees.
  • Invalid, unreadable and changed-during-verification observations retain their documented containment behavior.
  • Cancellation releases only the waiting turn's resources, never the index holder's lock.
  • Real held-lock and hosted native first/warm admission tests pass, with a mutation proving the contention regression can fail.

Verification

Use the real trust projection, durable writer and index-lock integration, plus the hosted native admission fixture. Cover concurrent publishers, out-of-band edits, rule removal and abort while waiting. Do not loosen the ten-second product bound.

Contract impact

Document the chosen refresh/lock ordering in docs/integration-contract/package-api.md in the implementing CONTRACT commit; preserve existing caller shapes and authority rules.

2026-11-23 triage at main a3395c4: re-verified the contention path (a changed policy still queues the brain lock, pinned by the diverged-refresh test), refreshed drifted citations by anchor, and reconciled Scope with Out of scope: the separate trust-projection lock is the in-scope route; narrowing the index critical section is excluded. Retyped from type: bug to type: fix.

Activity

  1. added
    area: ui-server
    priority: p2
    on Nov 21, 2026
  2. added this to the 0.45.0 milestone on Nov 21, 2026
  3. 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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions