Skip to content

ui-server: acquire authorized shared reference source with bounded refresh #2429

Closed

Description

@schlessera

Out of scope

No managed writable worktree publication, lifetime cleanup, new credentials policy, user-skill edits, blanket workspace exemption, provider-history mutation or new transport plugin. Do not use ambient host tokens as principal authorization.

Context

Part of #2390. The complete consolidated specification and its maintainer rulings are binding. The durable record is in draft PR #2427 at 6fc6183fe36125db1f465c9abb72eed0838d32ef (tree 212a1ec86ce0cb92bfbe254b4697c303de4ff3b1). That documentation is not product implementation or native qualification.

Code citations below were checked against 90a95123cfceb169bd2ecf7c213544db742eaed7. Recheck them when refreshing the implementation base. Preserve ROADMAP's concrete owners, deterministic CLI/host execution, unchanged brain-history accounting and append-only provider history. No policy ruling is requested by this issue.

Blocked by #2428

Sources:

  • syncTransportCommand, packages/ui-server/src/brain/sync-mirror.ts:89-128: fixed host-owned credentialed transport, separate from source evaluation; it is currently brain-sync-specific and is not already a principal/repository connection registry.
  • createHostBoundary, packages/ui-server/src/brain/host-boundary.ts:307-413: native input/credential/execution boundary; host-only helpers remain isolated.
  • transportMounts, packages/ui-sdk/src/server/worker-launcher.ts:255-273, and workerCommand, same file:456-598, enforce the empty transport root versus worker execution envelope.
  • principalManagementRoutes, packages/ui-server/src/middleware/principals.ts:66-79; local revocation at same file:168-182; reuse live principal resolution rather than cached byte presence.

Ruling — repository authority (2026-10-22)

Maintainer ruling 2026-10-22 (question, ruling): option 1, owner-managed grant records. An owner action records a grant of (brain, principal, repository prefix, named host credential). Private source is fetched only when a live grant covers the requesting principal and repository. Revoking a grant takes effect immediately, including for in-flight refreshes. A host credential existing never counts as authority. This adds an additive HTTP contract surface (CONTRACT:). The "already-authorized connection" and "connection revocation" in criteria 1–2 mean this grant and its revocation; the grant model is recorded in docs/decisions/reference-source-grants.md.

Scope

Implement the concrete host reference-source owner, using the foundation's capacity/recovery identities and existing transport/governance owners. Bind repository/revision and any existing authorized repository connection to the requesting brain/principal/profile. Implement the concrete missing authority binding in the host; do not introduce an abstract connection/provider registry or confuse the current sync token selector with authority.

Acceptance criteria

  1. Public source is reusable host-wide; private source is isolated per brain/principal. Validation covers the exact repository/revision. Local principal/connection revocation blocks new grants immediately. Configurable five-minute validation is independent of source freshness. Expired or failed validation refuses a new mount even if cached/stale bytes exist; public-to-private and inaccessible revision transitions cannot leak revisions under public authority.
  2. Acquire automatically through an already-authorized connection without another acquisition approval, while preserving profile/network/governance restrictions. Credentials are mounted only in the fixed transport; no repository helper/config/hook/filter or source-reading worker can evaluate with them. Host credential availability alone never grants access.
  3. Request-only refresh uses five minutes since last successful refresh; no timer/background refresh. Publish a complete validated revision atomically, retain honest exact commit/time/error reporting, and return stale authorized source on refresh failure without advancing successful refresh time. With no authorized usable source, refuse.
  4. Existing readers observe the new complete source on subsequent path reads. Prove the actual worker-visible directory publication/mount mechanism; replacing a root behind a bind mount is not sufficient. Allow multi-step reads to span revisions. Active readers prevent eviction, not refresh. No per-agent/turn full source copies or pinned shared-reader semantics.
  5. Host-wide configurable two-operation admission; requests in the same source/domain join one operation. Private domains do not reveal activity to one another. Bound queues, wait/cancel/reply state and ownership. Independent sources progress in parallel; ordinary readers are not capped at two. Do not hold the native manager's global mutation lock for an entire network fetch.
  6. Reserve foundation capacity before starting; account source/Git/checkout/staging, capacity-LRU evict only unleased eligible sources, protect worktree dependencies, and observe reclamation before retrying admission. No idle expiry. Cancellation or crash never publishes staging or releases still-owned bytes.
  7. Offline Odysseus repository with more than 1,000 files is acquired outside brain content/index/capture/sync and can be inspected read-only without charging acquisition as brain-content edits. Prove resource, acquisition, capacity and independent turn limits still apply. Source service is wired to host lifecycle, not merely a mock factory.

Parent acceptance mapping

Owns #2390 criteria 2 (source-side inspection), 4 (all authority/freshness behaviors), 6 (acquisition concurrency/cancellation), and source-side portions of 5 and 8. Supported agent tool exposure is delivered by E; no closing keyword for #2390.

Failing-first/mutation targets

Expired validation plus stale checkout, principal/domain substitution, public-to-private revision, credentials visible to source evaluation, partial publish, refresh failure advancing timestamp, reader pinned after refresh, duplicate same-domain fetch, third simultaneous admitted acquisition and premature reservation release must each fail a named assertion under an appropriate restored mutation.

Verification

Use only offline Odysseus repositories and keyless native worker/storage fixtures. Record named failing-first assertions and restored mutations, actual head/base/checkout tree, toolchain and fixture identities, commands, exit codes and retained output. Source inspection, parser/unit fixtures and documentation proof do not establish actual allocation, worker, mount or backend behavior. Complete affected package/type/contract checks and required current-candidate PR proof before readiness/merge. Do not launch native or container resources without the coordinator's explicit resource slot; installation/local feedback is separately owned. A missing slot leaves runtime proof pending, not passed.

Contract impact

Additive only. Any supported configuration, CLI JSON, HTTP, SDK or tool surface added by this slice owns the relevant integration-contract component and index link in the same CONTRACT: commit, plus a minor changeset naming actual affected package manifests. Load the release skill before those edits; do not version or publish here. Keep internal host-only protocol definitions concrete and private; adding one does not authorize a generic extension interface. Update changed code citations in the same slice.

Activity

  1. added this to the 0.44.0 milestone on Oct 19, 2026
  2. added
    type: featA new capability or a change in user-visible behaviour.
    area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p0Drop everything: a security hole, data loss, or a broken release.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    blockedWaiting on another issue or an upstream dependency. Say which in the body.
    contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.
    on Oct 19, 2026
  3. removed
    blockedWaiting on another issue or an upstream dependency. Say which in the body.
    on Oct 22, 2026
  4. self-assigned this
    on Oct 22, 2026
  5. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    Claim bk044-2429-r1: implementing on branch feat/2429-reference-source-044 from main 477c8f72a. Blocker #2428 is closed (merged via #2640), so blocked is cleared; the Blocked by #2428 line stays as satisfied history.

  6. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    Readiness: needs a decision before implementation (claim bk044-2429-r1, checked at main 477c8f72a).

    Acceptance criteria 1 and 2 require private acquisition "through an already-authorized connection" for the requesting brain/principal, with "local principal/connection revocation" blocking new grants. Host credential availability must not count as authority, and the scope forbids an abstract connection/provider registry, a new credentials policy and treating the sync token selector as authority.

    Evidence: no such connection exists in the product today.

    • Principals (packages/ui-server/src/db/principals.ts) carry kind, auth method, label and expiry. They have no repository or credential scope.
    • The only repository credentials are host-wide environment selectors with no principal binding: BRAIN_UI_SYNC_GITHUB_TOKEN / GITHUB_TOKEN, used by syncTransportCommand, packages/ui-server/src/brain/sync-mirror.ts:89-126, and BRAIN_UI_SKILLS_GITHUB_TOKEN, used by resolveGitHubToken, packages/ui-server/src/config/env.ts:1237-1239.
    • Neither the Epic: shared reference source and governed worktrees #2390 rulings nor docs/decisions/reference-worktrees.md define how a principal becomes authorized for a repository connection, or what revoking a "connection" means.

    That leaves nothing for the slice to bind to except host credential availability, which the Q2 ruling excludes. Choosing the authorizing act, who may perform it, and its revocation semantics is a policy and contract choice, not routine implementation.

    Question: what makes a repository connection "already authorized" for a principal?

    1. Owner-managed grant records. An owner-only principal-management action records a grant of (brain, principal, repository prefix, named existing host credential) in the UI database. Revoking the grant or the principal blocks new mounts immediately. Cost: an additive CONTRACT: HTTP surface, and UI later. It references existing credential variables only and adds no new credential storage.
    2. Owner-declared static configuration. Server configuration maps repository prefixes to an existing named host credential and to the principal kinds allowed to use it. Revocation means principal revocation, or a configuration change plus restart. Cost: an additive configuration contract; no per-principal granularity for delegated principals.
    3. Owner principal only. The live owner principal may use the host's configured repository credential; delegated principals are public-only. No new state. Risk: this sits close to "credential availability grants authority", so it needs an explicit ruling that owner authentication suffices.
    4. Public-only for now. This layer ships anonymous exact-revision public acquisition. Private requests refuse with "no authorized repository connection" until a connection model is ruled. Private-domain keying, revocation and validation plumbing still land. Consequence: criteria 1–2 are only partly met, so this would merge as Refs, with private acquisition left open.

    Recommendation (not approval): option 1. It is the only one that gives the "connection revocation" in criterion 1 a concrete local meaning without inventing credential storage. Option 4 is a viable interim step if the maintainer wants the public path first.

    Next action: a maintainer ruling on this comment that selects an option (or another one), names who may create or revoke the authorization, and says whether it adds an HTTP or configuration contract surface. Evidence needed to resume: that ruling, recorded on this issue and folded into the body. The remaining design is implementation work and needs no ruling: Btrfs-root publication visible to workers, single-flight admission, LRU eviction and the credential-isolated fetch.

  7. removed their assignment
    on Oct 22, 2026
  8. removed
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Oct 22, 2026
  9. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    Maintainer ruling 2026-10-22: option 1, owner-managed grant records (answering #2429 (comment)). An owner action records a grant of (brain, principal, repository prefix, named host credential). Private source is fetched only when a live grant covers the requesting principal and repository. Revoking a grant takes effect immediately, including for in-flight refreshes. A host credential existing never counts as authority. This adds an HTTP contract surface (CONTRACT:, additive).

  10. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    and removed
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    on Oct 22, 2026
  11. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    Claim bk044-2429-r2: resuming after the 2026-10-22 ruling (option 1, owner-managed grants), folded into the body. Plan: a native stack from main 477c8f72a — bottom feat/2429-reference-grants-044 (grant records + additive HTTP contract), upper layer(s) for publication, acquisition, refresh and eviction. Each layer Refs #2429; the last Closes.

  12. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    Progress (claim bk044-2429-r2): native stack is open as drafts:

    bun run check:pr passed for each layer against its parent, and the native reference-pool proof passed. That proof covers worker-visible publication and a real 1,200-file acquisition through the real transport workers. Each layer's draft gates are green on its current head. An independent gpt-6-astra review raised 9 findings; all are fixed, and each has a mutation receipt in the PR bodies. Not marked ready; the coordinator owns confirmation and merge.

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-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.priority: p0Drop everything: a security hole, data loss, or a broken release.type: featA new capability or a change in user-visible behaviour.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions