Repository navigation
ui-server: acquire authorized shared reference source with bounded refresh #2429
Description
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, andworkerCommand, 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
schlessera commentedon Oct 22, 2026
Claim
bk044-2429-r1: implementing on branchfeat/2429-reference-source-044from main477c8f72a. Blocker #2428 is closed (merged via #2640), soblockedis cleared; theBlocked by #2428line stays as satisfied history.schlessera commentedon Oct 22, 2026
Readiness: needs a decision before implementation (claim
bk044-2429-r1, checked at main477c8f72a).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.
packages/ui-server/src/db/principals.ts) carry kind, auth method, label and expiry. They have no repository or credential scope.BRAIN_UI_SYNC_GITHUB_TOKEN/GITHUB_TOKEN, used bysyncTransportCommand,packages/ui-server/src/brain/sync-mirror.ts:89-126, andBRAIN_UI_SKILLS_GITHUB_TOKEN, used byresolveGitHubToken,packages/ui-server/src/config/env.ts:1237-1239.docs/decisions/reference-worktrees.mddefine 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?
CONTRACT:HTTP surface, and UI later. It references existing credential variables only and adds no new credential storage.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.
schlessera commentedon Oct 22, 2026
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).schlessera commentedon Oct 22, 2026
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 main477c8f72a— bottomfeat/2429-reference-grants-044(grant records + additive HTTP contract), upper layer(s) for publication, acquisition, refresh and eviction. Each layerRefs #2429; the lastCloses.schlessera commentedon Oct 22, 2026
Progress (claim
bk044-2429-r2): native stack is open as drafts:bun run check:prpassed 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.CONTRACT: feat(ui-server): record owner-managed reference-source gran…
CONTRACT: feat(ui-sdk): publish sealed reference roots through per-do…
CONTRACT: feat(ui-server): acquire authorized shared reference source…