Skip to content

CONTRACT: feat(ui-server): bind managed source to turn authority - #4002

Merged
schlessera merged 46 commits into
mainfrom
feat/3613-immutable-source-20261114
Nov 17, 2026
Merged

schlessera merged 46 commits into
mainfrom
feat/3613-immutable-source-20261114

Conversation

@schlessera

@schlessera schlessera commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Refs #3613

What changed

Production GitHub reference acquisition now uses the admitted turn's bounded host wire for metadata, branch/tag discovery, fetches and cache validation. Each turn pays for its own checks and retains its own live principal, repository grant and separate API credential-recipient permission. Public acquisition stays anonymous.

The source catalog records the acquiring brain/principal/turn, stable repository and owner IDs, full ref, commit/tree, native sealed-root identity and charged wire bytes. Recovery refuses contradictory retained roots. Retained source/worktree guards recheck authority after waits and wire shutdown.

Publication and revocation now coordinate through shared repository/revision invalidation versions in the UI database. Requests and validation/publication transactions reject changed versions. Other app/cron owners can discover pending staging roots before the first source catalog receipt; sealed invalidated identities are retired so delayed native publication cannot expose them. Managed roots opt into permanent native publication withdrawal. Once hidden, that identity cannot be published again, even after restart or by a delayed RPC. Fresh authorized acquisition gets a new sealed root; live published roots still use the cache. Shared invalidation atomically expires catalog validation and captures the roots to hide, preserving newer authorized publications. Recovery keeps invalidated roots masked without unbound metadata requests. Failed-attempt cleanup affects its own root. Worktree cleanup conditions native parking on its own generation, preserving a foreign holder and still withdrawing an own grant whose reply was lost.

Stored grant and worktree repository keys retain literal suffixes, and raw clone locations stay distinct from canonical identity when wiring metadata, Git requests, revocation and worktree revalidation. A grant for a double-suffix location cannot dispatch metadata credentials to its neighboring repository. Worktrees durably retain the actual source URL, validate its canonical-key binding before dispatch, and keep it after grant revocation removes the source catalog row. Historical legacy records without any retained endpoint refuse an unknown URL instead of guessing a clone suffix.

Native publication conditionally compares the previous alias target under the keeper mutation lock, and the catalog transaction compares the previous root again. An older concurrent fetch cannot replace a newer commit. Concurrent acquisition of the exact same independently resolved commit can validate the new cache on its own turn budget. Failed staging cleanup never suppresses a later authority refusal.

Bind preparation associates suspension and withdrawal with the exact root and validation timestamp whose native hiding was confirmed. Other owners' replacements and renewals expire independently. Failed writes and uncertain native hiding are retried before binding. Startup recovery rereads the catalog and conditions suspension on the observed root and validation timestamp. Native hiding confirmation survives another bind only for permanently withdrawn or released roots. Reversible roots and catalog orphans need fresh hiding confirmation for each bind, because another owner may republish them. Bind preparation checks native state before treating staging as an exposed orphan: a root still outside publication views can finish its valid fetch/seal/publication. Already-exposed staging still requires settlement or hiding. Expiry compares the root, validation timestamp and freshness in one catalog transaction. It retires that managed publication without invalidating another turn's independently authorized staging. Retired roots cannot renew cache validation, including after recovery. Exposed staging is retired atomically before native hiding, and only staging identities can commit publication; a delayed reply cannot create a fresh lease for withdrawn bytes.

Why this shape

This is the managed-only acquisition slice selected by #3613 and the fixed private-metadata ruling. Acquisition facts enable no source trust, actual-read provenance or approved-owner capability. Existing source/worktree tools keep their schemas and ordinary workspace restrictions. The optional conditional native parking and permanent source-withdrawal controls are recorded in the native contract/API report; SDK/server minor changesets cover it.

All five original #3613 acceptance criteria remain open. Immutable returned range/digest evidence, both backend/read entry points, honest capabilities and stable approved-owner/rename/transfer/name-reuse matching remain. #3622 still depends on the complete resolver and independent Settings publication authority.

Proof

Candidate 7d8f8387b3acee5fa32690ce6a51af2c6de3ae3b, clean-merged base d2b0a814bb0a9750fc76c7602c1a41df58579284. Fix ea8f20b7bf7529e34edd6ee31a2de8d749841925 contains the reviewed changes. The latest independent renewal-race finding is reproduced and fixed by that commit; the original finding remains unchanged in the review record. Independent review of 77ab703ab7e556479d3756c82718620d35c43cf5 returned no findings. The subsequent merges of main are clean; the recorded review covers this refreshed candidate.

  • Supported offline execution on the refreshed head: 476 tests / 2550 assertions / 24 files, including real Git/TLS composition, separate database connections and the source/tool/worktree callers. Two failing-first cases inject a newer validation after the failed bind scan and immediately before the expiry transaction. Both preserve the newer validation and readable root.
  • A separate failing-first case pauses the native publication reply while another service binds and retires the exposed staging root. The publisher now refuses an authoritative lease instead of returning a missing path. Two additional failing-first refresh cases preserve independently authorized acquisition while the previous source expires, during fetch and after sealing. Recovery preserves retirement until a fresh authorized root replaces it.
  • Eight final mutation controls fail on the expected assertions: atomic expiry comparison, staged-orphan retirement, publication staging check, discard retirement, retired-root validation, independent staging preservation, recovery retirement and native-withdrawal failure handling. The root-withdrawal fault test retains its fail-closed and retry assertions. Earlier failures, reviews and mutations retain their own identities; directory-pool fixtures establish no native kernel equivalence.
  • Strict typechecking passed on the fix with an 8 GiB Node heap. The clean main refresh adds writer-clock, chat-ownership and CI/browser-repeat changes. The acquisition code is identical to the typed fix; the full focused source/caller suite passed again on this refreshed head. Dependency lock bdd8093610c9ef4891d4957e4c16158fcb0c4ff8259ea72a08406283f707c0be and existing isolated frozen installations remain applicable. SDK/server minor changesets cover the changes.

All five contribution preflight gates passed on the refreshed candidate.

{"version":1,"kind":"brain-check-pr-receipt","head":"7d8f8387b3acee5fa32690ce6a51af2c6de3ae3b","base":"origin/main","mode":"focused","startedAt":"2026-11-17T16:44:09.025Z","finishedAt":"2026-11-17T16:47:02.027Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":16125.900838000001},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":142.78792600000088},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":103.92800100000022},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":30.000545000002603},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":156581.51679}]}

Native managed-source, permanent-withdrawal/restart, conditional Btrfs holder, installed-provider-history and managed-worker proof remain unqualified locally because permitted loop-control is unavailable. The earlier native run failed before acquisition because its image omitted OpenSSL; the image now includes OpenSSL/CA certificates. No runtime prerequisite or guard was disabled.

Under the approved hybrid route, ordinary exact-candidate confirmation must pass all selected fast categories before merge. The actual squash's automatic main run must provide all selected heavy/native/provider-history proof, with independent checkout/parent/tree/result reconciliation.

Integration state

The independent review is complete and covers the clean refresh. Declared fix #4187 merged as e982c1c0d998dced8dfaeb7f82ea02002f0edad6; its automatic main run 44107659969 passed and incident #4186 has cleared. The branch includes the fix and is ready for ordinary exact-candidate confirmation through the shared integration lease. PR and advanced issue #3613 retain release milestone 0.45.0; the registry currently publishes 0.44.0. This session owns no integration reservation. Other sessions continue using the shared lease.

Guard scope and recovery

  • Trigger: lost or unknown repository metadata, lapsed validation, a revoked live private grant, or missing native conditional-publication/permanent-withdrawal support. Publication conflicts refuse only the older attempt; an exact same-commit cache may be independently validated. These guards establish no source trust or outward recipient permission.
  • Restriction: withhold only the affected source identities in their sharing domain. A name-only removal is insufficient because a bound reader can address the root by identity; native withdrawal masks both paths. Retained sealed storage stays charged instead of disabling the host.
  • Recovery: a fresh authorized request automatically creates a new publication identity; unrelated repositories, private domains and newer authorized roots remain usable. No human reset is needed. Legacy native calls retain reversible withdrawal; managed acquisition refuses an older keeper rather than falling back.
  • Durable evidence: shared invalidation versions and expired catalog validation, plus the native record's publicationRevoked field; the requesting tool reports its authority/metadata refusal. Recovery never clears invalidation merely by starting a service.
  • Scope proof: separate-database concurrency cases preserve a newer owner's publication, shared-authority tests preserve other domains and the literal-suffix case refuses the neighboring grant before metadata or Git dispatch.

Checklist

  • Scoped implementation, contract records and minor changesets.
  • Supported runtime proof, strict types, failing-first/mutation evidence and preflight.
  • Fresh independent review of the final head.
  • Complete selected candidate proof through ordinary confirmation.
  • Actual squash and automatic-main qualification.

Anything left open

All five #3613 criteria, remaining native/installed-backend qualification, #3622's resolver/publication dependencies and the two separately reserved final combined-epic reviews remain open. Acquisition mapping alone grants none of those capabilities.

@schlessera schlessera added this to the 0.45.0 milestone Nov 14, 2026
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. security Auth, isolation, egress, secrets, or anything in the threat model. labels Nov 14, 2026
@schlessera
schlessera force-pushed the feat/3613-immutable-source-20261114 branch from 7463e17 to 1b1d7bb Compare November 15, 2026 13:35
@schlessera
schlessera force-pushed the feat/3613-immutable-source-20261114 branch from 1b1d7bb to 0b9d600 Compare November 15, 2026 13:57
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 24d4553 against base df1e105. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "24d45535828144d44fa397d009f863b40c72a21b",
  "base": "df1e10569f561af8d8545fe9b768470a89146fb2",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:573: Concurrent managed publications can roll back newer source. Reproduced: pause request A after fetching commit A, let request B publish commit C, then resume A. A overwrites the catalog and view with commit A and reports it fresh; invalidation fences never changed.",
      "disposition": "fixed",
      "commit": "1170652f2c67200d60de13e9c0861ad77749573e"
    },
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:765: Reconstructing a stored repository key appends .git when its source catalog row is absent. Reproduced: allocate a private worktree from an unsuffixed legacy HTTP endpoint, revoke and recreate its grant, then access it. Revalidation requests /ithaca.git instead of the original /ithaca and incorrectly refuses the authorized worktree.",
      "disposition": "fixed",
      "commit": "1170652f2c67200d60de13e9c0861ad77749573e"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 352f711 against base df1e105. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "352f711ee89378dc00b177f7d9bce369d3134cb0",
  "base": "df1e10569f561af8d8545fe9b768470a89146fb2",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:855: Suspension is tracked only by source key. If service A suspends an expired root and service B publishes a fresh replacement, A retains suspended.has(key). Its settleView/admissible checks then skip the replacement even after validation expires, allowing a new bind with expired source still readable. Reproduced with two database connections."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 352f711 against base df1e105. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "352f711ee89378dc00b177f7d9bce369d3134cb0",
  "base": "df1e10569f561af8d8545fe9b768470a89146fb2",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:855: Suspension is tracked only by source key. If service A suspends an expired root and service B publishes a fresh replacement, A retains suspended.has(key). Its settleView/admissible checks then skip the replacement even after validation expires, allowing a new bind with expired source still readable. Reproduced with two database connections.",
      "disposition": "fixed",
      "commit": "5ddadd45ed147a722d7cd3c7483cbee47ff3f31d"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head a31bcd7 against base 94f5580. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "a31bcd76a73706dd59ee9466d468afd6e58f7890",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:239: hiddenRoots confirms only a root ID. After another owner renews and republishes a previously hidden legacy root, a failed withdrawal write installs a matching validation stamp without clearing that old confirmation. bindable() then exposes revoked, expired files without retrying native hiding. Reproduced with two database connections; the underlying legacy hole also appears present on the base."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head a31bcd7 against base 94f5580. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "a31bcd76a73706dd59ee9466d468afd6e58f7890",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:239: hiddenRoots confirms only a root ID. After another owner renews and republishes a previously hidden legacy root, a failed withdrawal write installs a matching validation stamp without clearing that old confirmation. bindable() then exposes revoked, expired files without retrying native hiding. Reproduced with two database connections; the underlying legacy hole also appears present on the base.",
      "disposition": "fixed",
      "commit": "8bf9a7bd092b73e03ca2ac6daf6ec7007c282338"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 8bf9a7b against base 94f5580. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "8bf9a7bd092b73e03ca2ac6daf6ec7007c282338",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:997: bindable() treats a first acquisition's still-writing staging root as an orphan and calls hideRoot(). Managed withdrawal is now permanent, so starting another turn while fetch is pending sets publicationRevoked=true and makes the valid acquisition fail at publication. The same acquisition succeeds without the concurrent bind."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 8bf9a7b against base 94f5580. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "8bf9a7bd092b73e03ca2ac6daf6ec7007c282338",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:997: bindable() treats a first acquisition's still-writing staging root as an orphan and calls hideRoot(). Managed withdrawal is now permanent, so starting another turn while fetch is pending sets publicationRevoked=true and makes the valid acquisition fail at publication. The same acquisition succeeds without the concurrent bind.",
      "disposition": "fixed",
      "commit": "55143cbe21dddb212f734cf89e0e5f469a00a44e"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 55143cb against base 94f5580. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "55143cbe21dddb212f734cf89e0e5f469a00a44e",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:881: Bind expiry fences the current publication from an earlier lapsed snapshot without comparing root/validated_at or rechecking freshness. Another owner can renew the root before suspension, yet this transaction resets validation to 0 and permanently withdraws it, invalidating the renewed source. Reproduced with separate database connections."
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 55143cb against base 94f5580. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "55143cbe21dddb212f734cf89e0e5f469a00a44e",
  "base": "94f55806c3fe2686c5e026d368fbe0683fac265a",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/reference-source.ts:881: Bind expiry fences the current publication from an earlier lapsed snapshot without comparing root/validated_at or rechecking freshness. Another owner can renew the root before suspension, yet this transaction resets validation to 0 and permanently withdraws it, invalidating the renewed source. Reproduced with separate database connections.",
      "disposition": "fixed",
      "commit": "ea8f20b7bf7529e34edd6ee31a2de8d749841925"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 77ab703 against base 146dfb4. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4002,
  "head": "77ab703ab7e556479d3756c82718620d35c43cf5",
  "base": "146dfb4b398c5c8d313a48dbd9e745327ba5c51f",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

@schlessera
schlessera marked this pull request as ready for review November 17, 2026 16:55
@schlessera
schlessera merged commit 5abac4c into main Nov 17, 2026
62 of 64 checks passed
@schlessera

Copy link
Copy Markdown
Owner Author

Post-merge qualification — 2026-11-17. #4002 is merged as 5abac4ce5545a612abe1fc09fd1423d9abe0a517, with exact parent d2b0a814bb0a9750fc76c7602c1a41df58579284 and tree af3df6ac8c71cf047348e4922fd200ea516b246d, matching the confirmed candidate. Remote-main ancestry and milestone 0.45.0 on both the PR and #3613 are verified.

Candidate run 44131301010 passed all thirteen selected jobs. Automatic main run 44134586911, attempt 1, passed all seventeen selected jobs, and every successful job's actual checkout is the squash above. The complete inventory matches the aggregate's nine fresh categories. Main's two determinism jobs were intentionally unselected; candidate determinism ran and passed.

Downloaded artifacts confirm all four healthy native backend/UID cells and cleanup, the separate expected index-failure/recovery control, complete separate-UID worker qualification, and the actual managed-source maintenance worker with sealed EROFS, bound root/commit/tree/generation, measured network use, revocation refusal and pool cleanup. The managed-source case retains backendEquivalence: false and readTrustExemption: false. JUnit evidence confirms 35 installed-provider-history cases across Claude and Pi and three production real-Git transport cases passed without skips. Main coordination has no open red-main incident.

This is a partial Refs #3613 delivery. All five original criteria remain open, including immutable returned range/digest evidence, both read/backend entry points and stable approved-owner matching. #3622 still needs the complete qualified resolver; no source-trust capability or downstream unblock is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. security Auth, isolation, egress, secrets, or anything in the threat model. type: feat A new capability or a change in user-visible behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant