Skip to content

core: read a governance policy from context/policies/governance.md, validated, read-only to agents #1650

Closed

Description

@schlessera

Guardrail class: this is the configuration surface for every class (G1–G7). By itself it adds no block.

Context

Decision: docs/decisions/governed-writable-workers.md ("The policy file"). Ruling 2 on #1636 places policy in the brain, versioned, and mounted read-only in every worker. It reverses R33's no-read rule, and R35 stays.

context/policies/ is already refused by the application route (if (folded[0] === "context", packages/ui-server/src/brain/application.ts:38) and by schedule definitions. The precedent for host-parsed Markdown under context/ is context/scheduled-tasks, which is excluded from the index (DEFAULT_EXCLUDE, packages/core/src/lib/config.ts:475).

Scope

  • A zod schema, schema_version: 1, in core, covering the keys in the decision's example: profiles, protect, release, budgets, scope, commands, egress, outward, taint, providers.
    • Unknown keys are refused.
    • release may name only tier B paths.
    • profiles cannot name restricted, and no key reaches autonomous turns.
    • Command patterns follow docs/decisions/confirm-patterns.md.
  • Parsing goes through parseFrontmatter. The Markdown body is ignored.
  • A read-only brain policy check --json command, with a contract-tested envelope, reports whether the file is valid, any errors, the content hash and the resolved effective policy.
  • The server loads the policy at every turn start.
    • When the file is invalid, the server keeps the last valid policy loaded in this process, or else the built-in defaults, and records a notice with the validation error.
    • The policy hash is recorded on the turn.
  • Profile selection for interactive and voice turns reads profiles.
  • context/policies is added to DEFAULT_EXCLUDE.dirs.
  • protect is added to the launcher's protected list from the profile issue. The confirmed authoritative-application bypass is corrected by ui-server: enforce admitted policy protection on authoritative agent writes #1743 in the same PR CONTRACT: read immutable governance policy at turn admission (#1650) #1741: captured protection also applies to curated Markdown and submitted PNG writes and their scratch cleanup. Both slices must be complete before readiness; this adds no new policy choice.
  • docs/supported-inputs.md and the integration contract list the file as a supported input.

Out of scope

  • Enforcement of budgets, scope, commands, egress, outward actions, taint and providers. Each has its own sibling issue, which consumes the parsed policy.
  • The approved-change route for agents (sibling issue).
  • R34 grant files.

Acceptance criteria

  • With a valid fixture policy that sets profiles.interactive: strict, an interactive turn runs strict. A test asserts this.
  • An invalid policy (an unknown key, a release that names .git/config, profiles.voice: restricted) keeps the previous effective policy. A test asserts the notice and that the hash is unchanged.
  • brain policy check --json returns the documented envelope for valid, invalid and missing files, under contract tests.
  • context/policies/governance.md is not indexed. A test runs brain index over the fixture.
  • Mutation receipt: remove the release tier check and the .git/config test fails.

Verification

bun run test in core and ui-server, the contract tests, then bun run check:pr --base origin/main.

Contract impact

Additive. A new supported input (the policy file, schema v1) and a new CLI --json envelope. CONTRACT: commit, minor changeset.

Blocked by #1649

Activity

  1. added this to the 0.42.0 milestone on Oct 11, 2026
  2. added
    type: feat
    area: core
    area: ui-server
    priority: p1
    agent-ready
    blocked
    on Oct 11, 2026
  3. added
    contract
    on Oct 12, 2026
  4. self-assigned this
    on Oct 12, 2026
  5. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    Claim: policy-1650-20261012-78381f66; branch feat/1650-policy-reader-78381f66. Coordinated independent stacked implementation begins from the immutable #1649 candidate 3eb4fc39ef8778ff978249480fa4edb4ef68731f. The existing #1649 dependency remains: any PR stays draft with Refs until corrected foundation integration and qualification. Scope is the read-only policy reader, profile/protection plumbing and their proof; sibling enforcement remains excluded. Milestone: 0.42.0.

  6. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #1649 is closed, so scripts/sync-project.ts is removing the blocked label.

  7. removed
    blocked
    on Oct 12, 2026
  8. removed
    agent-ready
    on Oct 12, 2026
  9. removed their assignment
    on Oct 12, 2026
  10. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    Merged #1741 as 185803c4a67e1074a06007c88402cd3fdcfee0c2 for 0.42.0, completing #1650, #1743 and #1744. The squash is on main with parent 5876df6c81e8fe5e32f6bf1b97fa41397b29492e; tree 2fd0ccc16e1ce09f3cca50ad26b9d46ab63fa9c7 exactly matches the qualified combined checkout.

    PR CI run38297907419, attempt1, passed all14 selected jobs. Every actual checkout was b9cfeaf182b9f7588590118e424b2d485494dbf4, with the recorded main/head parents; retention ledger was empty. The PR records original semantic failures, restored native/Docker/packed-consumer proof, independent review and job identities. Final contract and synchronization gates passed before the matching-head squash.

    The policy reader, admitted protection on authoritative agent writes and optional-core package correction are delivered. Separate command, policy-proposal, journal/revert, budget and scope enforcement remain programme work. Main CI run38300980826 passed all 14 selected jobs at the actual squash checkout 185803c4a67e1074a06007c88402cd3fdcfee0c2 (attempt 1), including packaging, runtime, four unit shards, both browser/layout shards, captures and the final proof gate. The three closed issues and PR retain milestone0.42.0; this coordinator's claims are released. Publishing remains a maintainer-terminal action.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corearea: ui-servercontractpriority: p1type: feat

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions