Skip to content

ui-server: reject ambiguous policy frontmatter before approval #3666

Closed

Description

@schlessera

Context

#3649 (the fix for #2507) made hosted policy review split frontmatter where the shared parser ends it. It deliberately retained acceptance of parser-valid proposals with ambiguous fences. The maintainer has now selected stricter proposal validation.

Verified at main 1619741f291f525d17cde4970a5ada40644117c1:

  • (function split, packages/ui-server/src/brain/policy-proposal.ts:57-63) uses the shared parser-aligned boundary.
  • (const checked = validate(bytes), packages/ui-server/src/brain/policy-proposal.ts:176-179) validates proposed policy content before constructing/raising its approval review.
  • (export function frontmatterBlock, packages/common/src/frontmatter-block.ts:42-54) reports the parser's actual opening/closing offsets and unclosed state.
  • (function splitFrontmatter, packages/core/src/lib/hygiene.ts:785-801) refuses ambiguous rewriting boundaries; this issue does not change that owner or the shared parser.
  • (test("the review splits frontmatter where the policy parser ends it (#2507)", packages/ui-server/tests/policy-proposal.test.ts:44-63) currently demonstrates accepted unclosed and closing-prefix proposals; those acceptance expectations must change under the approved break.

The tool's supported input/error/approval behavior is in docs/integration-contract/mcp.md, “Hosted policy proposal.”

Maintainer decision — 2026-11-08

Reject ambiguous proposal frontmatter before an approval card is raised. Ship this as a breaking change in 0.45.0. Inputs accepted before this change will be refused. The maintainer explicitly approves this contract narrowing; apply breaking, a CONTRACT: implementation commit, authoritative contract documentation and a changeset naming the break.

The strict rule is limited to the newly proposed bytes supplied to propose_policy_change. Do not globally change parser semantics or prevent a valid replacement proposal merely because the existing policy has unusual/malformed fences.

Scope

Validate unambiguous frontmatter boundaries before creating an actionable review. Use the shared frontmatterBlock to locate parser-recognized boundaries and validate their delimiter lines; do not add an independent fence-finding parser or change the shared parser's behavior.

  • Refuse an unclosed proposed block.
  • Refuse opening or parser-recognized closing delimiters with non-whitespace suffixes, including ---x, ---yaml, and a closing ----. Annotated opening delimiters such as ---yaml are rejected by this tool's selected strict policy even where the shared data-only parser supports the language elsewhere.
  • Accept standalone --- delimiter lines with optional trailing spaces/tabs. Preserve existing valid YAML/schema behavior, BOM, LF/CRLF, and closing-fence-at-end-of-file forms. Existing governance-schema validation still applies; this ruling does not make an invalid policy valid.
  • Return a clear validation error before approval is requested or a pending actionable card is created. Refused proposals publish no file bytes, journal edit or policy-change event.
  • Keep parser-aligned review of the old policy and exact proposed bytes for every accepted replacement. Never normalize or silently repair the submitted content.

Out of scope

Changing the shared parser/data-only language rules or hygiene semantics, migrating existing policy files, normalizing proposal bytes, changing policy schema/approval authority, granting voice/autonomous access, or publishing a release from this task.

Acceptance criteria

  • The MCP/integration documentation states the strict proposal fence rule, rejected classes and pre-approval error behavior, identifying this as a pre-1.0 breaking change approved for 0.45.0. Use a CONTRACT: commit and a breaking changeset with migration guidance: submit standalone, closed --- fences.
  • Real proposal-service/bridge tests prove unclosed, suffixed opening/closing and closing-prefix proposals are refused before the approval callback/card, with no publication or policy edit/event. Exercise ---x, ---yaml and ---- in their relevant positions.
  • Valid standalone fences, trailing spaces/tabs, BOM, LF/CRLF and EOF closing fences still produce the correct parser-aligned review and retain exact bytes after approval. A valid new proposal can repair an old ambiguous policy without silently rewriting the old bytes in the review.
  • Approval decline, stale base/authority, exact input identity and publication revalidation keep their existing guarantees. Reapply the selected validation at the existing publication check where required; no remembered grant can bypass it.
  • Update earlier acceptance fixtures deliberately: the current malformed-input approval cases become rejection expectations, while parser-aligned old-policy/valid-new-policy review coverage remains.
  • A named regression fails on the pre-change tree for the claimed pre-approval rejection assertion, then passes; removing the new strict guard reproduces that failure and restoration passes. A module-load error is not a receipt.
  • Record the binding proposal-specific policy/rationale in the relevant decision documentation as part of implementation, preserving the shared parser's intentionally broader semantics.

Verification

Run focused policy-proposal and bridge/route tests through bun run test, the relevant frontmatter/parser regression tests, typecheck/lint, the provider-history guard for affected turn paths, and bun run check:pr --base origin/main before a PR. Use keyless Odysseus fixtures and the pinned example date. Record exact failing-first/restored evidence; no runtime result is claimed by this ruling.

Contract impact

Breaking MCP input-contract narrowing, approved for 0.45.0. Required: breaking and contract labels, a CONTRACT: implementation commit, the authoritative MCP component updated in that commit, and a changeset explicitly naming previously accepted inputs now refused. Per docs/decisions/contract-versioning.md, the approved pre-1.0 break ships in a minor. Existing supported input/output shapes and other parser callers are unchanged.

2026-11-08 decision reconciliation: the maintainer selected rejection, breaking classification and 0.45.0 delivery. This supersedes the earlier deferral/acceptance recommendation. The issue is now an implementation brief; no guard or release is claimed as delivered.

Activity

  1. added
    type: feat
    area: ui-server
    priority: p3
    needs: decision
    contract
    on Nov 8, 2026
  2. added this to the 0.45.0 milestone on Nov 8, 2026
  3. changed the title [-]ui-server: decide whether propose_policy_change refuses ambiguous frontmatter fences[/-] [+]ui-server: reject ambiguous policy frontmatter before approval[/+] on Nov 8, 2026
  4. schlessera commented on Nov 8, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-08): Reject ambiguous propose_policy_change frontmatter fences before any approval card. Classify this as a breaking input-contract change and target 0.45.0.

    Refuse unclosed blocks and delimiter lines with non-whitespace suffixes, including the relevant ---x/---yaml/closing-prefix cases. Accept unambiguous standalone --- lines (optional trailing spaces/tabs), preserving valid BOM/line-ending/EOF cases and exact-byte publication. Scope strictness to proposed policy content; keep the shared parser/hygiene semantics and the ability to propose a valid repair of an old ambiguous policy.

    The body now contains the selected implementation scope, exclusions, error/approval behavior, valid/malformed fixture matrix, failing-first/mutation proof and required contract/breaking changeset. This is the maintainer ruling required before coding the break; the earlier deferral is superseded.

    Remove needs: decision, add agent-ready and breaking, and assign the chosen 0.45.0 milestone. Raise priority to p1 because the maintainer now commits this work to that upcoming release; no implementation or publication is claimed.

  5. added
    breaking
    priority: p1
    agent-ready
    and removed
    priority: p3
    needs: decision
    on Nov 8, 2026
  6. self-assigned this
    on Nov 15, 2026
  7. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-c750c054. Branch: feat/3666-strict-policy-frontmatter.

    Path overlap with #3622 in policy-proposal.ts; closure overlap with #4002 and other open PRs. Scope is proposal fence validation only; no edits to their branches.

  8. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Delivered in PR #4016, squash 3988a9bf9aab8c3730ca8e1228a63c169d17cab8, verified as an ancestor of main.

    New proposed policy bytes require closed standalone frontmatter fences before approval and at publication revalidation. Accepted BOM/line-ending/EOF/whitespace forms preserve exact bytes, and valid replacements can repair old ambiguous policies without changing shared parser semantics. The contract, decision record and breaking minor changeset carry the approved 0.45.0 migration guidance.

    Evidence:

    • Failing-first service and real Claude/Pi bridge rejection assertions; bypassing the strict guard reproduced eight failures, then restoration passed. Final focused proposal/bridge run: 57 tests, 524 assertions.
    • Local focused service/bridge/parser/receipt/pause regressions: 124 passed. Typecheck passed with the documented larger Node heap. Local provider-history guards encountered the same namespace prerequisite failure on the change and base; no local runtime success is claimed.
    • Final local preflight: all gates and 797 invariants passed. Later unrelated base advancement retained that actual receipt; fresh candidate CI proved the refreshed combined tree.
    • Candidate run https://github.com/schlessera/brain-kit/actions/runs/43729313115 passed. Its checkout c6ebfbc51383d754744a6b9318c9e528b87e0892 has parents c6f98e8d9d2f63d144ff82d6d1d6ff0db128547c and 1c865602028ed9be4a0b5c0c7780d1102dc682f3, and tree 4961e4744877a58d2631b69686d723f1873075f3. The squash has that exact base parent and tree.
    • Automatic main run https://github.com/schlessera/brain-kit/actions/runs/43731503582 passed on the squash, including every selected unit, runtime, native-host, browser, layout, capture and endurance category. Job checkout logs identify the squash SHA.

    PR and closed issue retain milestone 0.45.0. No dependent blocked issues or review findings remain. Follow-up #4017 records the observed temporary-storage quota failure and separate successful recovery; it has no release milestone. Nothing remains in this implementation's scope.

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-serverbreakingcontractpriority: p1type: feat

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions