Skip to content

ui-server: a hosted brain has no supported way to change its governance policy; an upstream policy commit blocks every sync #4256

Closed

Description

@schlessera

Context

A hosted brain cannot receive a governance policy change through sync. When the
brain's remote has a commit that edits context/policies/governance.md, every
hosted brain sync fails after the pull with:

maintenance output cannot change protected input context/policies/governance.md

The policy file is tier A (PROTECTED_TIER_A, packages/common/src/protected-paths.ts:14-22),
and maintenance output may never change tier A inputs (publish,
packages/ui-sdk/src/server/worker-output.ts:129-131;
packages/ui-sdk/src/server/worker-native-output.ts:416-418). That rule is
right for workers. But the pull is where a versioned policy change arrives, so
a single upstream policy commit leaves every later sync failing until the
commit is reverted upstream. The error reaches only the browser's sync stream;
nothing is logged on the server (#4257).

The host already has one privileged policy writer: the policy proposals
(createPolicyProposals, packages/ui-server/src/brain/policy-proposal.ts:100-276).
Two callers use it today:

  • Chat's propose_policy_change (docs/integration-contract/mcp.md, "Hosted
    policy proposal"). The agent proposes complete governance.md bytes, and
    the owner approves the exact diff on a per-use card. This already lets an
    owner set outward.github.repositories on a hosted brain without shell
    access.
  • Settings › Apify (createApifyPolicyEdits, packages/ui-server/src/apify/settings.ts:262-320).
    It opens a host-owned review with no agent behind it: a synthetic
    settings-apify-* turn in a user journal window, decided by the owner
    through POST /apify/policy/:turnId/:requestId
    (packages/ui-server/src/routes/apify.ts:107-116).

Observed on a hosted install at main bd751d434. A one-line upstream policy
commit adding outward: { github: { repositories: [owner/*] } } made the next
sync fail as above. A revert commit (net-zero change to the file) restored sync.

Scope

Per the 2026-11-20 maintainer ruling (option 1: the host adopts an incoming
policy change through an approval card
):

  • When the only tier A change in a hosted sync's output is
    context/policies/governance.md, the host stops before publishing anything.
    Instead of failing, it opens a host-owned policy-change review of the
    incoming bytes, the way Settings › Apify does: a synthetic sync turn in a
    user journal window, through createPolicyProposals, with a fixed host
    rationale naming the upstream commit SHA. Model-written or upstream text
    never supplies that rationale.
  • POST /brain/sync streams the review as a new event (identity plus
    PolicyChangeReview) and ends with a distinct "waiting for policy review"
    outcome, not a failure. A new owner-only route takes { approve }, as the
    Apify decide route does. Approval writes the incoming bytes through the
    existing writer. Decline writes nothing.
  • After an approval, the next sync completes, and the next admitted turn reads
    the adopted policy.
  • The sync panel in ui-react renders the review with the existing
    policy-change presentation (base hash, frontmatter diff, changed sections,
    body diff, rationale) and Approve/Decline. It adds no new visual component.
  • A scheduled sync has no owner present, so it opens no review. It ends with a
    refusal that says a policy change is waiting and that a UI sync will review
    it.
  • Any other refused tier A change (.git/config, hooks, bunfig.toml, any
    other file under context/policies/, an env file) keeps its refusal, and the
    message says what to do next: revert the upstream commit, or change the
    policy through chat's propose_policy_change.

Out of scope

Acceptance criteria

  • An integration test against the fixture corpus adds an upstream commit that
    edits context/policies/governance.md, then runs a hosted UI sync. Today it
    fails with the refusal above; after the change it streams a policy review
    and publishes nothing. It is shown failing on the tree before the change.
  • Approving that review writes exactly the incoming bytes through the policy
    writer, journaled as actor user, class policy, with a policy_change
    governance event. A following sync completes, and the next turn's frozen
    policy admits the new outward.github.repositories entry. A test asserts
    each step.
  • Declining it writes nothing. A following sync opens the review again rather
    than failing. A test asserts it.
  • A scheduled sync with the same upstream commit opens no review and records a
    refusal naming the waiting policy change. Another tier A change
    (for example bunfig.toml) keeps its refusal, with the next-step text. A
    test covers each.
  • A request to the decide route by a principal other than the one who started
    the sync, or for an unknown review, is refused, and nothing is written.
  • docs/integration-contract/http.md documents the new sync event, outcome
    and decide route. docs/decisions/governed-writable-workers.md records the
    ruling.

Verification

Integration test against the fixture corpus: an upstream commit editing the
policy, then a hosted sync. Assert the review, the approval write, the
following sync and the policy the next turn admits. Plus a ui-react test that
the sync panel renders the review and sends the decision.

Contract impact

Additive: a new SSE event and outcome on POST /brain/sync, and a new
owner-only decide route.

2026-11-20: Scoped by the maintainer ruling recorded in the comment below
(option 1). Corrected "nothing can set outward.github.repositories":
propose_policy_change already can. Priority set to p1.

Activity

  1. added
    type: feat
    area: ui-sdk
    area: ui-server
    on Nov 20, 2026
  2. added
    priority: p1
    agent-ready
    area: ui-react
    contract
    on Nov 20, 2026
  3. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-20): option 1. The host adopts an incoming policy change through an approval card. When a hosted sync's only tier A change is context/policies/governance.md, the host publishes nothing and opens a host-owned policy-change review of the incoming bytes, using the existing policy writer the way Settings › Apify does. The owner approves or declines it in the sync panel. Approval writes through the existing writer, and the next sync completes. Other tier A changes keep their refusal, with next-step text.

    Option 2 (a Settings control for outward.github.repositories) was not taken. Chat's propose_policy_change already lets an owner set it without a shell, so the body's "nothing can set it" was wrong and is corrected. Priority: p1. The body now carries the scope and acceptance criteria for this branch. Contract impact is additive.

  4. self-assigned this
    on Nov 20, 2026
  5. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-54d33cfb. Branch: feat/4256-sync-policy-review.

    Builds on #4257's sync route change (PR #4258); will start from main after it merges.

  6. added this to the 0.45.0 milestone on Nov 20, 2026
  7. 6 remaining items

  8. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Delivered by #4266, squash a94e8f05f3e5ae1fbeb42c1116c6972023093c2e, milestone 0.45.0 (maintainer ruling option 1).

    • A hosted sync whose only tier A change is context/policies/governance.md (with the context/policies directory a first policy creates) publishes nothing and pushes nothing.
    • When the stage's bytes equal the upstream commit's own blob, which the host reads before the worker runs, the owner gets a review in the sync panel. Approving writes those bytes through the existing policy writer in a user journal window, and the next sync completes. Declining writes nothing, and the next sync offers the review again.
    • Worker output is never a policy source. A scheduled sync opens no review and names the waiting change. Other tier A changes keep their refusal, with next-step text.
    • Proof:
      • Route, app-level (real journal, governance event, next-turn policy facts) and native mirror tests (create and edit).
      • Hosted failing-first and mutation receipts.
      • Recorded fresh-context reviews, the last one clean.
    • Automatic main proof for the squash was pending at merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-reactarea: ui-sdkarea: ui-servercontractpriority: p1type: feat

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions