Repository navigation
Description
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 completegovernance.mdbytes, and
the owner approves the exact diff on a per-use card. This already lets an
owner setoutward.github.repositorieson 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 auserjournal window, decided by the owner
throughPOST /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
userjournal window, throughcreatePolicyProposals, with a fixed host
rationale naming the upstream commit SHA. Model-written or upstream text
never supplies that rationale. POST /brain/syncstreams 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 undercontext/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'spropose_policy_change.
Out of scope
- Letting any agent runtime, worker or autonomous turn write policy
(R33/R35 stay binding; no agent runtime writes policy). The review is
host-owned and owner-decided. Voice never approves. - Weakening the tier A output check for worker output in general. The
worker's publish still refuses, and only the host decides. - A Settings control for
outward.github.repositories(option 2 was not
taken). Chat'spropose_policy_changealready covers editing. - The sync stall and 409 diagnostics (ui-server: a UI sync whose launch never settles holds "already running" until restart, and its failure is never recorded #4257).
Acceptance criteria
- An integration test against the fixture corpus adds an upstream commit that
editscontext/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 actoruser, classpolicy, with apolicy_change
governance event. A following sync completes, and the next turn's frozen
policy admits the newoutward.github.repositoriesentry. 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 examplebunfig.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.mddocuments the new sync event, outcome
and decide route.docs/decisions/governed-writable-workers.mdrecords 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
schlessera commentedon Nov 20, 2026
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'spropose_policy_changealready 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.schlessera commentedon Nov 20, 2026
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.
fix(ui-server): review only an upstream policy blob, a first policy t…
test(ui-react): register the slide-panel DOM again on a repeated run (#…
fix(ui-sdk): the plain output publisher refuses tier A changes with t…
6 remaining items
fix(ui-server): name the right next step for every refusal (review of #…
fix(ui-server): name the right next step for every refusal (review of #…
fix(ui-server): truthful sync review rationale and reports; relay ref…
fix(ui-server): truthful sync review rationale and reports; relay ref…
fix(ui-server): name the right refusals and launch class (review of #…
fix(ui-server): name the right refusals and launch class (review of #…
fix(ui-server): record the real cause of a refused sync review; every…
fix(ui-server): record the real cause of a refused sync review; every…
fix(ui-server): record a sync policy read failure by its cause; nativ…
fix(ui-server): record a sync policy read failure by its cause; nativ…
test(ui-server): the edit-path fixture takes the upstream note before…
CONTRACT: feat(ui-server, ui-react): review a sync's incoming governa…
schlessera commentedon Nov 20, 2026
Delivered by #4266, squash
a94e8f05f3e5ae1fbeb42c1116c6972023093c2e, milestone 0.45.0 (maintainer ruling option 1).context/policies/governance.md(with thecontext/policiesdirectory a first policy creates) publishes nothing and pushes nothing.userjournal window, and the next sync completes. Declining writes nothing, and the next sync offers the review again.CONTRACT: feat(ui-server, ui-sdk): a host GitHub API relay for module…