Skip to content

CONTRACT: feat(ui-server, ui-react): review a sync's incoming governance policy instead of failing (#4256) - #4266

Merged
schlessera merged 22 commits into
mainfrom
feat/4256-sync-policy-review
Nov 20, 2026
Merged

schlessera merged 22 commits into
mainfrom
feat/4256-sync-policy-review

Conversation

@schlessera

@schlessera schlessera commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Closes #4256

What changes

Per the 2026-11-20 ruling (option 1), a hosted sync whose pull changes context/policies/governance.md no longer fails forever. It publishes nothing, and the owner reviews the incoming policy.

  • Typed refusal (ui-sdk, worker-native-output.ts): publication still refuses every tier A change, but now names all of them up front, before any lock or write, as ProtectedMaintenanceOutputError (paths, plus a bounded read(rel) of the stage's bytes, valid until cleanup). The message is unchanged.
  • Hosted sync (sync-mirror.ts):
    • When the only refused paths are the policy (and the context/policies directory a first policy creates), the host transport reads the upstream commit's policy blob (git cat-file, bounded like the stage read, with GIT_NO_REPLACE_OBJECTS=1, after the integrity fsck and fetch and before the sync's worker runs). Only when the stage's bytes equal it do they and the upstream main SHA go to the caller's onPolicyChange, and the sync ends paused, with nothing published or pushed. Worker output is never a policy source. A merged policy that differs from upstream's is refused with next steps. A sync without a remote pulls nothing and reviews nothing.
    • A scheduled sync has no callback. It verifies the same blob and refuses, naming the waiting review only when one would open.
    • Any other tier A change keeps its refusal, with next-step text: revert the upstream commit, and, under context/policies/, change the policy in chat with propose_policy_change. A JSON result is marked failed with the same reason.
  • Review (brain/owner-policy-reviews.ts): the Settings › Apify review flow, extracted unchanged into a shared helper that Apify now uses too. It hands complete content to the existing policy proposals, the only policy writer, and an approval writes inside a user journal window. Sync reviews use their own sync-policy-* family, and a newer sync's review replaces (declines) the owner's unanswered older one, so stale reviews never fill the four-review cap. The decide route reads only its own family and only for the proposing principal. The rationale is fixed host text: the brain's remote has this version at the named upstream commit.
  • Route (routes/brain.ts): after a paused sync (its Activity run ends cancelled with the reason, not as a failure, and logs ui sync paused for policy review), the stream sends { type: "policy_review", turn_id, request_id, review } and ends with { type: "done", success: false, reason: "policy_review" }. The new internal POST /api/brain/sync/policy/:turnId/:requestId takes { approve }. An incoming policy that is not UTF-8 or does not validate opens no review: a progress line names the next step.
  • UI (ui-react): a paused sync shows Waiting for your policy review rather than Failed (a new waiting stream state). The sync panel renders the review with the same exact-diff presentation as the chat policy card (kit ApprovalCard/DiffBlock/Disclosure, no new visual component), sends the one answer, and tells the owner to sync again once the policy is adopted.
  • Docs: docs/http-api.md (route row, frame and outcome), docs/integration-contract/http.md (additive entry), the ruling in docs/decisions/governed-writable-workers.md, and the ui-sdk API report.

Contract: additive (a new SSE frame and outcome, a new internal route). Changesets: ui-server and ui-react minor, ui-sdk patch.

Guard checklist (proportionate containment)

The tier A output guard is unchanged in what it refuses. This PR changes how a hosted sync responds to one refusal.

  • Trigger, and what it does not cover: a hosted sync's output whose only refused tier A paths are context/policies/governance.md (and the context/policies directory a first policy creates), on a sync with a remote, where the stage's bytes equal the upstream commit's blob. The host reads that blob after the integrity fsck and the fetch, before the sync's worker runs, with GIT_NO_REPLACE_OBJECTS=1. Every other tier A change, a merged policy that differs from upstream's, and any sync without a remote keep the plain refusal.
  • What it restricts, and why nothing narrower: that one sync publishes nothing and pushes nothing; the brain, other syncs and turns stay usable. Publishing the rest without the policy would leave the brain's tree out of step with the commit it merged, and the next sync would refuse again.
  • Restricted mode considered: none applies before the owner answers, because adopting a policy is an owner decision by rule (R33/R35). The restricted outcome is the review itself: the sync pauses rather than fails.
  • How it clears: an owner Approve writes the bytes through the existing policy writer, and the next sync merges cleanly. Decline leaves the upstream commit in place, and the next sync offers the review again. A human is needed because policy is owner authority.
  • Where the cause is recorded: the sync stream's policy_review frame and the paused done frame, the UI sync's Activity run (cancelled, with the reason), and the ui sync paused for policy review log line. A scheduled sync's failure reason names the waiting review.
  • Scope test: sync-policy-review.test.ts shows a paused sync releases the brain for the next sync (NEXT_SYNC_REVIEWS_AGAIN), and sync-mirror.test.ts shows another tier A change still refuses on its own (TIER_A_REFUSED).

Validation

  • tests/sync-policy-review.test.ts (real policy writer, stub boundary):
    • The review streams the exact incoming bytes, the sync ends paused, and nothing is written.
    • Approval writes exactly those bytes in a user window with one policy_change event, and the adopted policy admits outward.github.repositories.
    • Decline writes nothing, and the next sync reviews again.
    • Another principal, an unknown review and a recorded Settings-family review are each refused (404).
    • An invalid incoming policy opens no review and names the next step.
  • tests/sync-policy-app.test.ts (native, end to end through createApp, fixture corpus, local bare remote): a UI sync reviews the upstream policy commit (rationale names its SHA); approval through the decide route writes the exact bytes; the real journal records class: policy, actor: user; a policy_change governance event is recorded; /api/agent-policy (the next turn's facts) reports the adopted policy and its hash; the following sync completes.
  • tests/sync-mirror.test.ts (native, fixture corpus, real Git remote):
    • An upstream commit creating governance.md makes a scheduled sync refuse with "needs the owner's review".
    • A UI-style launch hands over exactly the incoming bytes and the upstream SHA, and publishes nothing (not even the pulled notes/sea.md).
    • After a real approval through createPolicyProposals, the next sync completes and pulls the rest.
    • An upstream commit that edits an existing policy pauses (a review with a base hash), its real approval writes, and the next sync completes.
    • An upstream bunfig.toml keeps its refusal with next-step text and is not reviewable.
  • tests/render/slide-panel.test.tsx: the panel renders the review, posts { approve: true } to the exact decide route once, and shows the adopted state.
  • Failing first, hosted: mutation commit 34ecb7ed4 made the host boundary drop onPolicyChange, which is the behaviour before this change. Draft CI run 44774074901 failed the native sync-mirror integration test at UI_SYNC_PAUSED_TEXT. The next commit restores the forwarding.
  • Mutations, each restored afterwards:
    • A panel that ignores policy_review fails SYNC_REVIEW_RENDERED.
    • A route that opens no review fails SYNC_STREAMS_POLICY_REVIEW, and all five route tests fail.
    • A decide route that reads any review family fails FOREIGN_REVIEW_FAMILY_REFUSED.
    • A paused sync recorded as a failure fails PAUSED_RUN_NOT_FAILED.
    • No supersede fails SYNC_4_REVIEWS_AGAIN.
    • A paused sync shown as an error fails the panel test.
  • The Apify settings tests pass unchanged on the extracted helper. bun run typecheck passes.
  • Local gap: the native sync-mirror tests need user namespaces, which this host lacks, so hosted CI is their proof.

Collisions

bun scripts/collisions.ts --json --pr 4266 at head 7c5eda572: closure-only overlaps with #3054, #3056, #3059, #3069, #3581, #4151, #4265, #4270, #4273 and #4312, through shared affected test closures. No path collisions.

Refreshed by a clean merge of origin/main (099683923). The check:pr receipt below is from the last real change, c1eebc46d, and the recorded review covers that head plus this clean merge.

{"version":1,"kind":"brain-check-pr-receipt","head":"c1eebc46d5e47aa82b511778c41a531c11d73e96","base":"origin/main","mode":"focused","startedAt":"2026-11-20T18:30:05.375Z","finishedAt":"2026-11-20T18:31:19.207Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13794.882373999999},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":120.04783800000223},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":66.91902299999856},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":20.22407000000021},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":59812.825744999995}]}

🤖 Generated with Claude Code

schlessera and others added 5 commits November 20, 2026 14:45
…stead of failing (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cs, decision and tests (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rt (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 20, 2026
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. area: ui-react React chat/files/voice components, stores, WebSocket transport. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. labels Nov 20, 2026
@uploads-sh

uploads-sh Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-react/src/components/quick-actions/streaming-modal.tsx, packages/ui-react/src/components/quick-actions/streaming-output.tsx, packages/ui-react/src/components/quick-actions/sync-policy-review.tsx and 1 more). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 4266
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 4266 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4266 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 4266 and the same screen, state and caption fields.

This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with uploads list --pr 4266. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 426177a against base cb42362. Reviewer: agent. 6 findings: 0 fixed, 0 filed, 0 rejected, 6 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "426177a545398cf0011f19d152bd34c6b1c4c75c",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-sdk/src/server/worker-native-output.ts:435 with packages/ui-server/src/brain/sync-mirror.ts:163: if the brain has no context/policies/ dir, the pull also creates that dir, a stage entry inside tier A (isWithin includes the root), so refused is [context/policies, context/policies/governance.md]. paths.length===1 fails, the first-policy case gets the generic refusal and no review, and tests/sync-mirror.test.ts:157 (corpus has no context/policies) should go red."
    },
    {
      "summary": "packages/ui-server/src/routes/brain.ts:388: failure is set from the non-zero exit before the policy_review branch, so run.end at :418 records the paused UI sync's activity run as failed and logs 'ui sync failed'. The issue asks for a distinct 'waiting for policy review' outcome, not a failure. The done frame says success:false too, and no test checks the recorded run outcome."
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:217: the no-remote local sync also passes onPolicyChange though nothing is pulled, so a governance.md change there can only come from the worker's own repository code. The host still opens a review whose fixed rationale (routes/brain.ts:151) says 'Incoming from the brain's remote'. On the remote path the bytes are also worker output, never checked against the named upstream commit's blob. Workers must not be a source of policy changes."
    },
    {
      "summary": "packages/ui-server/tests/sync-policy-review.test.ts:123: the approval test stubs the journal and recordEvent, then only parses the written file (:126). It never asserts journal class 'policy', a policy_change governance event through the app's activity.governanceWrites wiring, or that the next admitted turn's frozen policy admits outward.github.repositories, all of which the acceptance criteria require a test to assert."
    },
    {
      "summary": "packages/ui-server/tests/sync-mirror.test.ts:162: the 'next sync completes' step writes the adopted bytes with writeFileSync rather than approving through the policy writer. No test chains a real approval through createPolicyProposals into a following hosted sync completing, which the acceptance criterion 'A following sync completes' asks for after an approval."
    },
    {
      "summary": "docs/decisions/governed-writable-workers.md:856: the new ruling blockquote is inserted mid-paragraph with no blank line after it, so the existing text 'Within one server process, maintenance clients serialize...' (:857) becomes a lazy continuation inside the 2026-11-20 ruling quote. That misattributes an earlier rule to this ruling in the decision record."
    }
  ]
}

…oo; a paused sync is not a failure (#4256)

The incoming bytes must equal the upstream commit's policy blob, read by the
host transport, so worker output is never a policy source; a sync without a
remote reviews nothing. A first policy, whose pull also creates
context/policies, is reviewable. A paused UI sync's Activity run ends as
cancelled with its reason, not as a failure. Tests now approve through the
real policy writer and, end to end through createApp, assert the journal,
the governance event and the next turn's policy facts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 426177a against base cb42362. Reviewer: agent. 6 findings: 6 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "426177a545398cf0011f19d152bd34c6b1c4c75c",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-sdk/src/server/worker-native-output.ts:435 with packages/ui-server/src/brain/sync-mirror.ts:163: if the brain has no context/policies/ dir, the pull also creates that dir, a stage entry inside tier A (isWithin includes the root), so refused is [context/policies, context/policies/governance.md]. paths.length===1 fails, the first-policy case gets the generic refusal and no review, and tests/sync-mirror.test.ts:157 (corpus has no context/policies) should go red.",
      "disposition": "fixed",
      "commit": "f3320cf09fe13077007274a8c295b173915fd6a9"
    },
    {
      "summary": "packages/ui-server/src/routes/brain.ts:388: failure is set from the non-zero exit before the policy_review branch, so run.end at :418 records the paused UI sync's activity run as failed and logs 'ui sync failed'. The issue asks for a distinct 'waiting for policy review' outcome, not a failure. The done frame says success:false too, and no test checks the recorded run outcome.",
      "disposition": "fixed",
      "commit": "f3320cf09fe13077007274a8c295b173915fd6a9"
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:217: the no-remote local sync also passes onPolicyChange though nothing is pulled, so a governance.md change there can only come from the worker's own repository code. The host still opens a review whose fixed rationale (routes/brain.ts:151) says 'Incoming from the brain's remote'. On the remote path the bytes are also worker output, never checked against the named upstream commit's blob. Workers must not be a source of policy changes.",
      "disposition": "fixed",
      "commit": "f3320cf09fe13077007274a8c295b173915fd6a9"
    },
    {
      "summary": "packages/ui-server/tests/sync-policy-review.test.ts:123: the approval test stubs the journal and recordEvent, then only parses the written file (:126). It never asserts journal class 'policy', a policy_change governance event through the app's activity.governanceWrites wiring, or that the next admitted turn's frozen policy admits outward.github.repositories, all of which the acceptance criteria require a test to assert.",
      "disposition": "fixed",
      "commit": "f3320cf09fe13077007274a8c295b173915fd6a9"
    },
    {
      "summary": "packages/ui-server/tests/sync-mirror.test.ts:162: the 'next sync completes' step writes the adopted bytes with writeFileSync rather than approving through the policy writer. No test chains a real approval through createPolicyProposals into a following hosted sync completing, which the acceptance criterion 'A following sync completes' asks for after an approval.",
      "disposition": "fixed",
      "commit": "f3320cf09fe13077007274a8c295b173915fd6a9"
    },
    {
      "summary": "docs/decisions/governed-writable-workers.md:856: the new ruling blockquote is inserted mid-paragraph with no blank line after it, so the existing text 'Within one server process, maintenance clients serialize...' (:857) becomes a lazy continuation inside the 2026-11-20 ruling quote. That misattributes an earlier rule to this ruling in the decision record.",
      "disposition": "fixed",
      "commit": "f3320cf09fe13077007274a8c295b173915fd6a9"
    }
  ]
}

schlessera and others added 3 commits November 20, 2026 15:38
…4256)

The determinism job repeats a changed file in one process; its module-body
DOM registration ran once, so the second run had no window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he same typed error (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…readable covered file

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 551f333 against base cb42362. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "551f333f7c8fabf172417cae48955205505f25d6",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:251: verify() runs git cat-file in the mirror after the worker ran, but the worker can write mirror objects/ and refs/ (:257). The transport sets no GIT_NO_REPLACE_OBJECTS and runs no fsck in between, so repository code can add refs/replace/&lt;upstream sha&gt; or overwrite a loose object and pass its own bytes as the upstream blob, breaking 'worker output is never a policy source'."
    },
    {
      "summary": "packages/ui-server/tests/sync-mirror.test.ts:132 and tests/sync-policy-app.test.ts:66: the issue requires the fixture-corpus integration test to be shown failing on the tree before the change, but the PR body records no failing-first receipt for either test. It lists only mutation receipts and says the native sync-mirror tests never ran locally."
    },
    {
      "summary": "packages/ui-sdk/src/server/worker-native-output.ts:435 and packages/ui-server/src/brain/sync-mirror.ts:680: the PR changes an integrity guard (the tier A refusal now exposes refused bytes, and the host turns it into a paused sync and a review), but the PR body does not answer the checklist in docs/decisions/proportionate-containment.md that AGENTS.md requires for a changed guard."
    }
  ]
}

schlessera and others added 2 commits November 20, 2026 16:28
… without replace objects (#4256)

A sync worker can write the mirror's objects and refs, so the blob it is
compared with is now read after the integrity check and fetch and before the
worker, and every transport runs with GIT_NO_REPLACE_OBJECTS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nPolicyChange, as before #4256

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 551f333 against base cb42362. Reviewer: agent. 3 findings: 2 fixed, 0 filed, 1 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "551f333f7c8fabf172417cae48955205505f25d6",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:251: verify() runs git cat-file in the mirror after the worker ran, but the worker can write mirror objects/ and refs/ (:257). The transport sets no GIT_NO_REPLACE_OBJECTS and runs no fsck in between, so repository code can add refs/replace/&lt;upstream sha&gt; or overwrite a loose object and pass its own bytes as the upstream blob, breaking 'worker output is never a policy source'.",
      "disposition": "fixed",
      "commit": "02d944745a58b0d35e053ce85cc13e6797d9b6b9"
    },
    {
      "summary": "packages/ui-server/tests/sync-mirror.test.ts:132 and tests/sync-policy-app.test.ts:66: the issue requires the fixture-corpus integration test to be shown failing on the tree before the change, but the PR body records no failing-first receipt for either test. It lists only mutation receipts and says the native sync-mirror tests never ran locally.",
      "disposition": "fixed",
      "commit": "34ecb7ed45464e35b571451f27a3943335294597"
    },
    {
      "summary": "packages/ui-sdk/src/server/worker-native-output.ts:435 and packages/ui-server/src/brain/sync-mirror.ts:680: the PR changes an integrity guard (the tier A refusal now exposes refused bytes, and the host turns it into a paused sync and a review), but the PR body does not answer the checklist in docs/decisions/proportionate-containment.md that AGENTS.md requires for a changed guard.",
      "disposition": "rejected",
      "reason": "Not a code defect: the PR body now answers the proportionate-containment checklist in its Guard checklist section; no code change is needed."
    }
  ]
}

)

Reverts the mutation commit, whose hosted run 44774074901 failed the native
sync-mirror test at UI_SYNC_PAUSED_TEXT as expected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 551f333 against base cb42362. Reviewer: agent. 3 findings: 2 fixed, 0 filed, 1 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "551f333f7c8fabf172417cae48955205505f25d6",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:251: verify() runs git cat-file in the mirror after the worker ran, but the worker can write mirror objects/ and refs/ (:257). The transport sets no GIT_NO_REPLACE_OBJECTS and runs no fsck in between, so repository code can add refs/replace/&lt;upstream sha&gt; or overwrite a loose object and pass its own bytes as the upstream blob, breaking 'worker output is never a policy source'.",
      "disposition": "fixed",
      "commit": "02d944745a58b0d35e053ce85cc13e6797d9b6b9"
    },
    {
      "summary": "packages/ui-server/tests/sync-mirror.test.ts:132 and tests/sync-policy-app.test.ts:66: the issue requires the fixture-corpus integration test to be shown failing on the tree before the change, but the PR body records no failing-first receipt for either test. It lists only mutation receipts and says the native sync-mirror tests never ran locally.",
      "disposition": "fixed",
      "commit": "bb3d16c42844d11f64a32b157701ab3c2931dfd2"
    },
    {
      "summary": "packages/ui-sdk/src/server/worker-native-output.ts:435 and packages/ui-server/src/brain/sync-mirror.ts:680: the PR changes an integrity guard (the tier A refusal now exposes refused bytes, and the host turns it into a paused sync and a review), but the PR body does not answer the checklist in docs/decisions/proportionate-containment.md that AGENTS.md requires for a changed guard.",
      "disposition": "rejected",
      "reason": "Not a code defect: the PR body now answers the proportionate-containment checklist in its Guard checklist section; no code change is needed."
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head bb3d16c against base cb42362. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "bb3d16c42844d11f64a32b157701ab3c2931dfd2",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-react/src/components/quick-actions/streaming-modal.tsx:101: the paused sync's done frame (success:false, reason:\"policy_review\") goes to setState(\"error\"), so the sync panel's badge reads \"Failed\". The issue requires a distinct 'waiting for policy review' outcome, not a failure. The server records it as cancelled, but the owner sees Failed, and slide-panel.test.tsx (StreamingPanel sync policy review) never checks the panel state."
    },
    {
      "summary": "packages/ui-server/src/brain/owner-policy-reviews.ts:76 with routes/brain.ts:398: each UI sync opens a new pending review. An unanswered one (panel closed, or a failed decide POST whose UI says 'Sync again') stays pending for 10 min. After 4 of these, propose throws busy and the next sync fails with 'Answer the open policy reviews first', for reviews the UI can no longer show. This breaks 'a following sync opens the review again rather than failing'."
    },
    {
      "summary": "docs/decisions/governed-writable-workers.md:844-845: the new ruling says that when 'the only refused path is governance.md' the host 'reads the output's bytes' and reviews them. The code (sync-mirror.ts:170) also accepts the context/policies directory, and reviews only bytes equal to the upstream commit's blob read before the worker runs, refusing any other bytes. The record leaves out that upstream-blob rule, which is what keeps worker output from ever being a policy source."
    }
  ]
}

…reviews replace stale ones; state the blob rule (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head d751b95 against base cb42362. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "d751b95f77f4fbe8458ac71394f087ea06b1a523",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:181 with :252: a scheduled sync never reads the upstream blob (onPolicyChange absent), so it tells the owner to 'Run Sync in the app to review it' even when the merged governance.md differs from the upstream commit's (e.g. a clean 3-way merge with a local policy edit). The UI sync then refuses that same change as unreviewable at :177, so the scheduled refusal names a review that will never open."
    }
  ]
}

…fore naming a review (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head d751b95 against base cb42362. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "d751b95f77f4fbe8458ac71394f087ea06b1a523",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:181 with :252: a scheduled sync never reads the upstream blob (onPolicyChange absent), so it tells the owner to 'Run Sync in the app to review it' even when the merged governance.md differs from the upstream commit's (e.g. a clean 3-way merge with a local policy edit). The UI sync then refuses that same change as unreviewable at :177, so the scheduled refusal names a review that will never open.",
      "disposition": "fixed",
      "commit": "f92b99db1b587dac16fefdd38ffdbc9b1daa91e3"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head f92b99d against base cb42362. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "f92b99db1b587dac16fefdd38ffdbc9b1daa91e3",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:254: every remote sync now reads the upstream governance.md blob with git cat-file through transport(), which sets no outputBytes bound (runMaintenanceWorker defaults to Infinity), while the stage read is capped at INCOMING_POLICY_READ_BOUND. An upstream commit with a very large governance.md is buffered whole into host memory on each sync attempt, even a scheduled one, before the 1 MiB writer bound can refuse it by name."
    },
    {
      "summary": "packages/ui-react/src/components/quick-actions/streaming-modal.tsx:161: SyncPolicyReview is rendered as a sibling after StreamingOutput, whose root is 'flex h-full flex-col' filling the drawer's flex-1 overflow-y-auto box, so the Approve/Decline card starts below the log and its Close footer, out of view until the owner scrolls the outer container; the happy-dom test (slide-panel.test.tsx) cannot see layout."
    }
  ]
}

…view inside the panel's scroll area (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head f92b99d against base cb42362. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "f92b99db1b587dac16fefdd38ffdbc9b1daa91e3",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:254: every remote sync now reads the upstream governance.md blob with git cat-file through transport(), which sets no outputBytes bound (runMaintenanceWorker defaults to Infinity), while the stage read is capped at INCOMING_POLICY_READ_BOUND. An upstream commit with a very large governance.md is buffered whole into host memory on each sync attempt, even a scheduled one, before the 1 MiB writer bound can refuse it by name.",
      "disposition": "fixed",
      "commit": "c425cd8a85b7c25b3dc1a0ff6aaf80e7b2b16e5a"
    },
    {
      "summary": "packages/ui-react/src/components/quick-actions/streaming-modal.tsx:161: SyncPolicyReview is rendered as a sibling after StreamingOutput, whose root is 'flex h-full flex-col' filling the drawer's flex-1 overflow-y-auto box, so the Approve/Decline card starts below the log and its Close footer, out of view until the owner scrolls the outer container; the happy-dom test (slide-panel.test.tsx) cannot see layout.",
      "disposition": "fixed",
      "commit": "c425cd8a85b7c25b3dc1a0ff6aaf80e7b2b16e5a"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c425cd8 against base cb42362. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "c425cd8a85b7c25b3dc1a0ff6aaf80e7b2b16e5a",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:173: protectedRefusal reads the stage policy with INCOMING_POLICY_READ_BOUND before any check. readRefused (worker-native-output.ts:69) throws for a larger file, and nothing catches it. An upstream governance.md over 1 MiB+1 fails UI and scheduled syncs with a bare 'Refused output ... exceeds 1048577 bytes'. That drops the tier A refusal and its next-step text, and contradicts the :145 comment that the writer refuses it by name."
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:186: every other refused tier A change says 'revert the upstream commit that makes it'. That includes a no-remote sync (:228), where nothing is pulled, and a remote sync where the sync's own repository code wrote the file (e.g. bunfig.toml). In both cases no upstream commit makes the change, so the next-step text the issue requires points the owner at a commit that does not exist."
    }
  ]
}

…4256/#4259)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c425cd8 against base cb42362. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "c425cd8a85b7c25b3dc1a0ff6aaf80e7b2b16e5a",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:173: protectedRefusal reads the stage policy with INCOMING_POLICY_READ_BOUND before any check. readRefused (worker-native-output.ts:69) throws for a larger file, and nothing catches it. An upstream governance.md over 1 MiB+1 fails UI and scheduled syncs with a bare 'Refused output ... exceeds 1048577 bytes'. That drops the tier A refusal and its next-step text, and contradicts the :145 comment that the writer refuses it by name.",
      "disposition": "fixed",
      "commit": "d197e3377c49f79a53160feb89fa04886214df4b"
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:186: every other refused tier A change says 'revert the upstream commit that makes it'. That includes a no-remote sync (:228), where nothing is pulled, and a remote sync where the sync's own repository code wrote the file (e.g. bunfig.toml). In both cases no upstream commit makes the change, so the next-step text the issue requires points the owner at a commit that does not exist.",
      "disposition": "fixed",
      "commit": "d197e3377c49f79a53160feb89fa04886214df4b"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head d197e33 against base cb42362. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "d197e3377c49f79a53160feb89fa04886214df4b",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "docs/http-api.md:665: the new 'Incoming policy change (additive, #4256)' paragraph was inserted mid-paragraph, so the existing sentences 'Successful sync attempts voice keyterm rebuild; a rebuild failure is progress text...' and the following ones about degraded rebuilds and the 500 now continue inside the #4256 paragraph. That attributes general sync rules to this additive change in the HTTP reference that the contract index links to."
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:567: verify only checks that the stage bytes equal the upstream commit's governance.md blob, not that the pull changed the policy relative to the brain's pre-sync copy. Repository code in the sync worker can rewrite a locally adopted policy back to upstream's older blob. The host then opens a review whose fixed rationale (routes/brain.ts:726) says 'the pull changes' the policy, so worker output becomes a policy-change source."
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:548: refusedSync rewrites only JSON stdout and keeps the human-mode report. The UI sync runs 'sync --human' (routes/brain.ts:315), so the panel and the Activity job_output now stream the CLI's own report (committed and pushed to the mirror) before the paused or refused text, although nothing was published or pushed. Before this change the thrown refusal dropped stdout (host-boundary.ts:740)."
    }
  ]
}

…usals, lost writes and bounds recorded (review of #4256/#4259)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head d197e33 against base cb42362. Reviewer: agent. 3 findings: 3 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "d197e3377c49f79a53160feb89fa04886214df4b",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "docs/http-api.md:665: the new 'Incoming policy change (additive, #4256)' paragraph was inserted mid-paragraph, so the existing sentences 'Successful sync attempts voice keyterm rebuild; a rebuild failure is progress text...' and the following ones about degraded rebuilds and the 500 now continue inside the #4256 paragraph. That attributes general sync rules to this additive change in the HTTP reference that the contract index links to.",
      "disposition": "fixed",
      "commit": "cbf48210a13b43d00993dac9d930e0291beefd7c"
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:567: verify only checks that the stage bytes equal the upstream commit's governance.md blob, not that the pull changed the policy relative to the brain's pre-sync copy. Repository code in the sync worker can rewrite a locally adopted policy back to upstream's older blob. The host then opens a review whose fixed rationale (routes/brain.ts:726) says 'the pull changes' the policy, so worker output becomes a policy-change source.",
      "disposition": "fixed",
      "commit": "cbf48210a13b43d00993dac9d930e0291beefd7c"
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:548: refusedSync rewrites only JSON stdout and keeps the human-mode report. The UI sync runs 'sync --human' (routes/brain.ts:315), so the panel and the Activity job_output now stream the CLI's own report (committed and pushed to the mirror) before the paused or refused text, although nothing was published or pushed. Before this change the thrown refusal dropped stdout (host-boundary.ts:740).",
      "disposition": "fixed",
      "commit": "cbf48210a13b43d00993dac9d930e0291beefd7c"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head cbf4821 against base cb42362. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "cbf48210a13b43d00993dac9d930e0291beefd7c",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:658: verify decodes the stage policy with fatal UTF-8 and refuses on failure, so a non-UTF-8 upstream governance.md equal to the stage is refused as \"differs from the upstream commit's ... change the policy upstream so the brain's copy matches it\", wrong next-step text. The UTF-8 branch in routes/brain.ts:734 is unreachable, contradicting docs/http-api.md (not UTF-8 opens no review, progress names the next step)."
    }
  ]
}

…4256/#4259)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head cbf4821 against base cb42362. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "cbf48210a13b43d00993dac9d930e0291beefd7c",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:658: verify decodes the stage policy with fatal UTF-8 and refuses on failure, so a non-UTF-8 upstream governance.md equal to the stage is refused as \"differs from the upstream commit's ... change the policy upstream so the brain's copy matches it\", wrong next-step text. The UTF-8 branch in routes/brain.ts:734 is unreachable, contradicting docs/http-api.md (not UTF-8 opens no review, progress names the next step).",
      "disposition": "fixed",
      "commit": "0f091ba24fef08cb1e0aad1ae3784964a82a178a"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 0f091ba against base cb42362. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "0f091ba24fef08cb1e0aad1ae3784964a82a178a",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/routes/brain.ts:395,412: when a review cannot open (invalid or non-UTF-8 incoming policy, not_authorized, busy), `failure` is built from the output tail before the refusal is appended, so the Activity run reason and `ui sync failed` log carry sync-mirror.ts:190's \"Sync paused... Review the policy change; approving it adopts the policy\" for a review that does not exist, and omit the real cause."
    }
  ]
}

… relayed write in the run output (review of #4256/#4259)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 0f091ba against base cb42362. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "0f091ba24fef08cb1e0aad1ae3784964a82a178a",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/src/routes/brain.ts:395,412: when a review cannot open (invalid or non-UTF-8 incoming policy, not_authorized, busy), `failure` is built from the output tail before the refusal is appended, so the Activity run reason and `ui sync failed` log carry sync-mirror.ts:190's \"Sync paused... Review the policy change; approving it adopts the policy\" for a review that does not exist, and omit the real cause.",
      "disposition": "fixed",
      "commit": "bf7744157fd3daeabd50fd31766a39245e71a973"
    }
  ]
}

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head bf77441 against base cb42362. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "bf7744157fd3daeabd50fd31766a39245e71a973",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/tests/sync-mirror.test.ts:140 and packages/ui-server/tests/sync-policy-app.test.ts:51: the only native/end-to-end tests create a first governance.md (the fixture corpus has none). The criterion and incident are an upstream commit that edits an existing policy. That path (only the file refused, non-null review baseHash, next sync merging a change made on both sides) is never exercised natively, only by the stubbed route test."
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:179: the bare catch around error.read(GOVERNANCE_POLICY_PATH, ...) reports every read failure (EACCES/identity fallback, 'Native private output changed while hashing', I/O) as 'exceeds the policy writer's 1 MiB bound', so the refusal records a false cause and tells the owner to shrink a file that may be small, against the fail-closed rule to record the cause."
    }
  ]
}

…e edit-path test; relay settles in-flight writes and names settings (review of #4256/#4259)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head bf77441 against base cb42362. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "bf7744157fd3daeabd50fd31766a39245e71a973",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-server/tests/sync-mirror.test.ts:140 and packages/ui-server/tests/sync-policy-app.test.ts:51: the only native/end-to-end tests create a first governance.md (the fixture corpus has none). The criterion and incident are an upstream commit that edits an existing policy. That path (only the file refused, non-null review baseHash, next sync merging a change made on both sides) is never exercised natively, only by the stubbed route test.",
      "disposition": "fixed",
      "commit": "8f3bbd654a55fb2b043ac8b516f1d8e11e8b2a2d"
    },
    {
      "summary": "packages/ui-server/src/brain/sync-mirror.ts:179: the bare catch around error.read(GOVERNANCE_POLICY_PATH, ...) reports every read failure (EACCES/identity fallback, 'Native private output changed while hashing', I/O) as 'exceeds the policy writer's 1 MiB bound', so the refusal records a false cause and tells the owner to shrink a file that may be small, against the fail-closed rule to record the cause.",
      "disposition": "fixed",
      "commit": "8f3bbd654a55fb2b043ac8b516f1d8e11e8b2a2d"
    }
  ]
}

… pushing its policy (#4256)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head c1eebc4 against base cb42362. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4266,
  "head": "c1eebc46d5e47aa82b511778c41a531c11d73e96",
  "base": "cb4236234c1cce1f45d034e9eb34d15eda41f934",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

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

Labels

area: ui-react React chat/files/voice components, stores, WebSocket transport. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. 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. 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.

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

1 participant