Skip to content
Merge policies

Merge policies

Every served Repository evaluates Maku’s shipped catalog of three bounded MergePolicy objects (docs-links, deps-patch, docs) in shadow from its first pull request, with no binding and no .policy.yml rule. The merge gate picks the policy from the diff, records shadow evidence for every shadow policy that holds, and merges under the strictest live one that holds. A binding in Repository.spec.mergePolicies or .github/agent-factory.yaml is an exception: it takes a policy live, disables a catalog policy (mode: disabled), or narrows its paths and caps. The factory’s central guardrails cap every resolved policy. policyManagement.stage (read, simulate, manage; manage by default) sets how far repository-file management is rolled out. Until a repository sets classAuthority: repository, the factory’s own config and objects alone decide its merges: the repository’s file is read, compared, re-decided and simulated, never acted on.

You want toGo to
Know what a decision, a count or a word meansHolds, agreed, signal-checked
Onboard a repository with zero policy YAMLStart here
Understand selection, resolution and conceptsConcepts
Configure policyManagement.stageRepository-file authority
Look up field tiers, check names or fieldsReference
Copy one of the three worked examplesWorked examples
Browse repository-file binding recipesRecipes
Check, simulate, promote, save a grantWorkflows
Read a decision, a metric or a reasonOperating it
Fix somethingTroubleshooting
Undo somethingRollback
Define a policy, bind it from a RepositoryFactory resources

The merge gate itself (the fixed base, the decision record, adopted classes, the monitor) is in the factory. This page covers merge policies, bindings and promotion.

Holds, agreed, signal-checked

A policy decides one thing: whether a pull request holds, meaning every row of the gate passes on one head and the change stays inside the policy. Holding does not mean the change is right. What can check that is a correctness signal: something independent of the author that checks what the change means. After a merge, the monitor hears only loud trouble: a merge it watched to the end with no revert, no regression and no follow-up is quiet, not right. Every count on the settings pages, in maku policy and in the comments names who judged it: a signal, a maintainer, or nobody.

WordMeansDoes not meanWire name, unchanged
holdsEvery row of the gate passes on one head: the change is inside the policyThe change is rightdecision=arm, shadow_would_arm
correctness signalSomething independent of the author that checks what the change means, from the closed list belowA green checksignal=
signal-checkedA decision a correctness signal judged, and passedProven correctsignal=<kind>:ok
uncheckedA decision nothing judged for meaning. Also a policy with no correctness signalWrongsignal=none
agreedA maintainer merged a shadow decision unchanged, at the judged headThe maintainer read every lineclean, mergedUnchanged
quietThe monitor’s window ended with no revert, no regression, no follow-upRightverdict=healthy
regressionA monitor signal turned bad inside the windowEvery bad mergeverdict=regression
wrong callA merge under a policy later found wrongA drillbad

“Verified” is never shown alone: merged_verified reads “main stayed green”, and the monitor’s verified reads “RunLore: resolved”.

    flowchart TD
  PR["Pull request, head reported"] --> BASE{"Fixed base<br/>CI, fence"}
  BASE -- red --> H["Waits for a maintainer"]
  BASE -- ok --> HOLDS{"A policy holds?<br/>files, caps, reviewer, holdouts"}
  HOLDS -- no --> H
  HOLDS -- yes --> SIG{"Correctness signal?"}
  SIG -- "shape, oracle<br/>or contract: ok" --> CHK["signal-checked"]
  SIG -- none --> UNC["unchecked"]
  CHK --> MODE{"Mode"}
  UNC --> MODE
  MODE -- shadow --> REC["Would-merge record"]
  MODE -- live --> MERGE["Merged by the policy"]
  REC --> HUM{"Maintainer merges it unchanged?"}
  HUM -- yes --> AGREED["agreed"]
  MERGE --> MON{"Monitor window"}
  MON -- "revert, regression, follow-up" --> WRONG["wrong call"]
  MON -- nothing --> QUIET["quiet"]
  AGREED --> EV["Evidence"]
  QUIET --> EV
  WRONG --> EV
  WRONG --> BRK["Breaker: the policy goes back to a maintainer"]
  EV --> PROMO["Promotion, by a maintainer's merge"]
  

The correctness-signals design also describes rules this page does not: an unchecked policy kept in shadow, an audit of live prose, the factory/wrong label and sensitive kinds. The gate does not enforce them yet, and no page or comment promises them.

What checks the meaning

The signal comes from fields the policy already has. Nobody declares it twice.

SignalDerived fromEstablishesLeaves open
Determining shapediffShape: links-only, semver-patch, semver-minor (and docs-links’ built-in shape)Every changed line has one mechanical meaningThe target: the new page’s words, the upstream release
OracleoracleA detector outside the pull request named the defect, and the diff removes exactly thatThe detector’s own errors
Contractrequires holds both plan and tests, and the task ran under a test contractA test written before the change, from a plan a maintainer approved, is red at the base and green at the headBehaviour the plan did not name

These are bounds or supporting evidence, never a signal:

WhatWhy not
allowedFiles, caps, modifyOnly, protectedFilesThey say where and how much, not what
diffShape: added-entryStructure only: the entry’s words are free
holdoutChecks, required CIThey say something still works, and can pass without reading the changed lines
A reviewer’s verdictA veto, not an approval
Monitor: main’s CI, Flux, RunLore’s resolvedLoud breakage only; a silenced alert also resolves

A policy whose every allowedFiles pattern ends in \.md$, \.mdx?$, \.rst$, \.txt$ or \.adoc$ is prose: nothing checks its meaning, and the pages say so.

Each decision that holds records its signal: signal=links-only:ok, signal=contract:ok, or signal=none. A refusal records none. The same one sentence about a policy, built by one function, appears on its settings page, in maku policy explain, in the promotion pull request and in the decision comments. For docs-links bound live with a holdout, under the repository’s default verifyFor and revertWindow:

Merges without you when an agent changes only link targets in Markdown, at most 20 lines, and Check the documentation links 🔗 passes. Meaning checked by the links-only shape: every changed line is a link target on the same host. Not checked: what the new page says. After the merge Maku watches main for 30 minutes and opens a revert on red. Undo: factory/revert within 7 days.

Start here

A new Repository binds nothing. Leave spec.mergePolicies unset on the Repository, and put only the ownership fence in .github/agent-factory.yaml (factory: <name>). No MergePolicy manifest and no .policy.yml rule is needed (maku/merge-gate is the gate status by default):

  1. Every served Repository automatically evaluates the catalog (docs-links, deps-patch, docs) in shadow.
  2. On every agent pull request, the gate evaluates the diff against all candidate policies (selection from the diff) and writes a shadow_would_arm record for each shadow policy that holds, regardless of any issue label.
  3. Merge the pull requests you agree with unchanged. For the first drill, choose one merged shadow pull request and run maku policy drill owner/name#PR: the merger opens a revert labelled factory/drill, and you review and merge it. (The factory/revert label reverts only a pull request the factory merged, so it cannot drill a shadow pull request a maintainer merged.) That single drill covers the repository: evidence now accumulates only from maintainer merges at the exact judged head. Once a policy reaches its minimum of agreed decisions (5 for evidence: low, 20 for standard), promote it with a one-line mode: live binding.

A binding overrides the catalog default for that policy: mode: live promotes it, mode: disabled turns a catalog policy off for the repository, and allowedFiles, protectedFiles, holdoutChecks or lower caps tighten it.

# before: 11 bindings, 7 of which merge nothing
# after: a new repository has no mergePolicies key at all; a repository with exceptions lists only those
mergePolicies:
  - {name: docs-links, mode: live, holdoutChecks: ["Check the documentation links 🔗"]}
  - {name: alert-rules, mode: shadow, allowedFiles: ['^observability/.+\.ya?ml$']}
  - {name: dead-links,  mode: shadow, allowedFiles: ['^(docs|website/content)/.+\.md$'], oracleWorkflow: dead-links.yaml}
  - {name: deps-patch,  mode: shadow, protectedFiles: ['^security/base/zitadel/']}

The catalog

Rendered by the agent-factory chart with the factory (mergePolicies.catalog.enabled, on by default), in the factory’s namespace, labelled maku.ogenki.io/catalog: "true". Each carries its own bound, since no binding supplies one:

PolicyWhat it mergesBoundevidence
docs-linksLink targets in Markdown, nothing else, 20 linesdiffShape: links-onlylow (5)
deps-patchRenovate patch updates after their release age (renovate/stability-days): adopted from renovate[bot] on renovate/ branches, 3 files, 10 lines, 2 a daydiffShape: semver-patchlow (5)
docsProse in Markdown files (^.+\.mdx?$), 5 files, 100 lines, 2 a dayallowedFilesstandard (20)
kind: MergePolicy
metadata: {name: docs-links}
spec:
  description: Link targets in Markdown, nothing else.
  diffShape: links-only
  modifyOnly: true
  maxModifiedLines: 20
  evidence: low
---
kind: MergePolicy
metadata: {name: deps-patch}
spec:
  description: Renovate patch updates, after their release age.
  author: {adopt: {logins: ["renovate[bot]"], branches: ['^renovate/']}}
  diffShape: semver-patch
  modifyOnly: true
  maxPatchFiles: 3
  maxModifiedLines: 10
  releaseAgeCheck: renovate/stability-days
  maxPerDay: 2
  evidence: low
---
kind: MergePolicy
metadata: {name: docs}
spec:
  description: Prose in Markdown files, small changes.
  allowedFiles: ['^.+\.mdx?$']
  maxPatchFiles: 5
  maxModifiedLines: 100
  maxPerDay: 2
  evidence: standard

A binding narrows a catalog policy like any other: allowedFiles on a docs binding must match as well as the policy’s. A platform that keeps its own object of a catalog name lists it in mergePolicies.catalog.exclude; an unlabelled MergePolicy of a catalog name fails the install, naming it, until it is listed there or deleted.

The catalog, worked

Each example uses the repository’s defaults: verifyFor 30 minutes, revertWindow 7 days, autoRevert off. A merge found wrong is reported by reverting it with factory/revert inside the window, or by a follow-up fix the monitor reads: either is a wrong call against the policy.

docs-links. A pull request that changes [guide](https://example.com/old) to [guide](https://example.com/new) in docs/setup.md holds. One that also rewords the link text does not: class_mismatch (not a links-only diff).

Merges without you when an agent changes only link targets in Markdown, at most 20 lines. Meaning checked by the links-only shape: every changed line is a link target on the same host. Not checked: what the new page says. After the merge Maku watches main for 30 minutes and opens a revert on red. Undo: factory/revert within 7 days.

The record reads class=docs-links decision=arm:armed files=1/0 lines=2/20 shape=ok … signal=links-only:ok. The monitor then reads main’s CI on the merge commit: green for 30 minutes is quiet.

deps-patch. Renovate’s renovate/foo-1.x branch moving version: 1.4.2 to 1.4.3 in one file holds once renovate/stability-days passes. A move to 1.5.0 does not: class_mismatch.

Would merge without you when renovate[bot] moves only a patch version, at most 3 files and 10 lines, 2 a day, and renovate/stability-days passes. Meaning checked by the semver-patch shape: only a patch version moves. Not checked: the release itself; Maku waits for its release age. After the merge Maku watches main for 30 minutes and opens a revert on red. Undo: factory/revert within 7 days.

In shadow the record reads decision=shadow:shadow_would_arm … signal=semver-patch:ok. A maintainer who merges it unchanged makes it an agreed decision: 5 promote the policy.

docs. An agent’s rewording of two paragraphs in README.md (18 lines) holds once a reviewer approves. Six changed files do not: patch_too_large, “6 files changed, limit 5”.

Would merge without you when an agent changes Markdown files, at most 5 files and 100 lines, 2 a day, and a reviewer approves. Meaning checked by nothing: this is prose.

The record reads … signal=none: nothing judged the meaning. Twenty agreed decisions promote it, and every merge of it is unchecked.

Required workflow stages (spec.requires)

A MergePolicy may declare requires: [plan, tests, judge, review] (at most 4 items) to require stages for tasks touching its paths. Class requirements add stages to whatever workflow a task runs and never remove one (quick under a class requiring review runs the reviewer). Requirements are applied at triage for the predicted class and evaluated late against the scoper’s touches list and against the first pull request diff so label-path tasks touching regulated paths run each newly required stage once. tests is added only when the repository configures both tests.paths and merge.contractCheck; otherwise the factory narrates the unmet requirement and the merge gate hands the pull request to a maintainer with required_stage_missing.

Two-human sign-off on a pull request is enforced by a GitHub branch ruleset requiring two approvals, without the merger App on that ruleset’s bypass list: merge.approveToMerge merges via an ordinary mergePullRequest call, so GitHub refuses the merge until two people have approved. The plan gate’s Approve approves the scope before implementation and is not an approval of the pull request.

Every bound and catalog policy also inherits the central guardrails (MergeGuardrails.WithDefaults): when mergeGuardrails is unset on the Factory, protectedFiles starts with ^\.github/, ^\.policy\.yml$ and ^CODEOWNERS$, and maxPatchFiles, maxModifiedLines and maxPerDay default to 10, 300 and 5. A platform can customize them centrally:

workflows:
  plain: {}
  checked: {checks: true}
  adopted-none: {template: none}
mergeGuardrails:
  protectedFiles:                       # the self-modification fence, once instead of per rule
    - '^\.github/'
    - '^\.policy\.yml$'
    - '(^|/)(AGENTS|CLAUDE)\.md$'
    - '^\.(agents|claude)/'
    - '(^|/)(go\.sum|package-lock\.json|pnpm-lock\.yaml|uv\.lock|Cargo\.lock)$'
  maxPatchFiles: 20
  maxModifiedLines: 400
  maxPerDay: 5
  # maxGrantLifetime 90 days is the code's default; a policy's evidence sets its promotion minimum

Guardrails cap every bound class, a file’s or a Repository’s (config.Resolve), including a repository-authoritative file with no central classes. A policy cap above one is clamped; an explicit binding value above one is refused alone (GuardrailMismatch). An unset merge.maxPerDay inherits the guardrail’s daily cap.

DefaultValue
Zero-binding RepositoryEvaluates all three catalog policies in shadow
SelectionStrictest live policy whose conditions hold on the diff
Guardrails when unset^\.github/, ^\.policy\.yml$, ^CODEOWNERS$; 10 files, 300 lines, 5 per day
Promotion minimum5 agreed decisions (evidence: low) or 20 (standard), plus one drill per repository
Unreviewed prose (MR12)A policy with no diffShape and no oracle requires a reviewer’s approve
Everything elseno_policy_matched: a human merges

Concepts

    flowchart LR
  subgraph central["Central config and objects (operators, Flux-managed)"]
    mg["mergeGuardrails"]
    pm["policyManagement.stage"]
    ca["Repository.spec.classAuthority"]
    cat["Catalog + platform MergePolicy objects"]
  end
  subgraph repo["Repository default branch"]
    file[".github/agent-factory.yaml<br/>factory + optional mergePolicies"]
  end
  file -->|"fence read, every 5 min"| watch["Watch<br/>Parse → Validate → resolve each binding"]
  cat --> watch
  mg --> watch
  watch -->|"snapshot + hash"| gate["Merge gate<br/>DecideArm / select.go"]
  ca --> gate
  pm --> gate
  gate -->|"maku/merge-gate + comment"| record["Decision record<br/>class= considered= policy= dual= grant="]
  
TermMeaningCode
PolicyA MergePolicy object: one bounded merge rule, named by the object. What it may say is in policies and bindingsconfig.PolicySpec
CatalogThe three MergePolicy objects (docs-links, deps-patch, docs) shipped by the agent-factory chart and evaluated in shadow by every served Repository unless bound otherwiseinternal/factory/resources/bindings.go
BindingOne entry of mergePolicies (on a Repository or in .github/agent-factory.yaml): a policy’s name, its mode (live, shadow, disabled), and this repository’s narrowing parametersconfig.Binding
Repository policyThe mergePolicies bindings of .github/agent-factory.yaml on the default branch. A file with factory: alone is the ownership fence and binds no policyinternal/factory/mergepolicy/policy.go
Central configFactory and config-file settings: workflows, mergeDefaults, mergeGuardrails, policyManagement.stage, and per repository classAuthority, maintainers, merge, workflow, schedules, budgetsinternal/factory/config/mergepolicy.go
Modelive merges, shadow records what it would have done, disabled turns a catalog or bound policy off. Always the binding’sconfig.Binding.Mode
Author modeagents: the factory’s agents App wrote it through a task’s runs. adopt: another App’s pull requests (Renovate), adopted by login and branch prefixClass.Author
ConditionsThe fields that must all hold on the diff, plus protectedFiles, the paths that refuseconfig.Class
requiresApprovalPaths that send an otherwise-arming pull request to a maintainer, even in a live policy. A saved grant can let a later one armApprovalLeaf
maxPerDayThe policy’s own daily cap, at most the guardrail’s (merge.maxPerDay caps the repository whole)Class.MaxPerDay
MonitorThe post-merge monitor settings, declared on the policyconfig.Monitor
GuardrailsCentral bounds: protected paths and mandatory checks every resolved policy gains, caps no policy or binding may exceedMergeGuardrails
SnapshotOne read of .github/agent-factory.yaml: its sha256, the resolved classes, the error. Each decision binds to it (policy=<12 hex>)mergepolicy.Snapshot

How a binding resolves

config.Resolve turns a policy and one repository’s binding of it into the config.Class the gate decides on. Each binding resolves on its own: one that does not drops its policy, never the Repository or the file.

  1. The binding names a MergePolicy the factory serves (MissingRef otherwise; disabled drops the policy before resolution).
  2. The policy’s meaning, the binding’s mode, each fill-once parameter from where it is set, a binding’s allowedFiles narrowing the policy’s, the additive lists unioned and the lower cap (the combination rules).
  3. The guardrails are applied: their protectedFiles and mandatoryChecks are appended (mandatoryChecks become holdout checks, so GitHub Actions must report them); a cap left unset inherits the guardrail’s; a policy cap above it is clamped, while an explicit binding cap above it is refused (GuardrailMismatch).
  4. The resolved policy must carry allowedFiles or a diffShape (Unbounded otherwise) and pass the gate’s class rules (Invalid otherwise).

Resolution order

The order the code decides in (DecideArm in internal/factory/reconciler/arm.go, the selection in select.go, then withApproval in evaluate.go). The first row that refuses names the reason.

    flowchart TD
  pr["Pull request, exact head"] --> base{"Fixed base<br/>leak scan, required CI, contract,<br/>ownership fence, policy-bot, factory/hold"}
  base -->|refuse or wait| out1["human / escalate / wait"]
  base -->|pass| author{"Author mode<br/>agents login, or adopted login + branch;<br/>a maintainer's approval"}
  author -->|fail| out2["human"]
  author -->|approved, approveToMerge| ap["arm: maintainer_approved"]
  author -->|pass| one{"Findings, or adopted?"}
  one -->|yes| cls["Its one class, as below"]
  one -->|no| evidence{"Evidence<br/>verdict, reported head, trailer"}
  evidence -->|fail| out4["human"]
  evidence -->|pass| each["Each candidate policy:<br/>live or shadow, not adopted, no oracle"]
  each --> conds{"Conditions, in order:<br/>allowedFiles, protectedFiles,<br/>modifyOnly, maxPatchFiles, maxModifiedLines,<br/>diffShape, releaseAgeCheck, holdoutChecks;<br/>then a reviewer's verdict (MR12)"}
  conds -->|refuse| cons["considered=policy:reason"]
  conds -->|hold| pick{"Strictest live policy that holds"}
  pick -->|none, a shadow one holds| shadow["shadow: shadow_would_arm"]
  pick -->|none at all| none["human: no_policy_matched"]
  pick -->|paused / capped| out7["human: class_paused / auto_merge_cap"]
  pick -->|pass| arm["arm"]
  shadow --> subset{"requiresApproval<br/>caught a file?"}
  arm --> subset
  subset -->|no| done["as decided"]
  subset -->|yes, shadow| wsa["shadow: shadow_would_require_approval"]
  subset -->|yes, live| grant{"Active grant covers it?<br/>(approvalMemory)"}
  grant -->|yes| armg["arm, grant=id:version"]
  grant -->|no| appr["human: approval_required"]
  

Selection from the diff

RuleDetail
CandidatesEvery policy the repository evaluates in live or shadow, the catalog’s included, except adopted ones and those with an oracle. A task with findings (a schedule’s probe) or an adopted pull request is decided on its one class instead
A policy holdsEvery condition it declares holds on the diff. A policy with no diffShape and no oracle also needs a reviewer’s approve: without a reviewer in the workflow it refuses reviewer_verdict_missing (MR12)
StrictestA diffShape first; then the lower maxModifiedLines; then the lower maxPatchFiles (0, no cap, sorts last in both); then the name
No fall-throughWhen the strictest live policy that holds is paused or at its maxPerDay, a human merges: a looser policy never takes over
ShadowEach shadow policy that holds records its own shadow_would_arm line, whether or not a live policy merged
PendingA pending holdout waits only when its policy would decide: stricter than every policy of its tier that holds
No matchno_policy_matched; the record’s considered= names each policy’s refusal
RuleDetail
The diffConditions on the diff hold until it is read: the first pass decides without it, and only a decision that would arm or shadow reads it and decides again
The approval subsetApplies to a policy’s own arm or shadow, never to a maintainer’s approval, which is already a human’s. It is decided after the caps: a capped pull request says auto_merge_cap, not approval_required
DenyprotectedFiles is the second condition checked, after allowedFiles: a file both outside the allow list and protected reports file_not_allowed. Either way a human merges
Built-in shapedocs-links is held to diffShape: links-only when it declares none, and may declare no other. links-only reads .md and .mdx files only; any other changed path refuses class_mismatch even when allowedFiles admits it

description

A policy’s description says, in one plain sentence, what the policy is for: “Fixes a broken link in the docs, and nothing else.” It is optional plain text of at most 280 characters, set on the MergePolicy (spec.description) or on a class of the central config; a binding has none. The gate never reads it: two policies that differ only in their description decide every pull request alike. A policy’s settings page shows it.

Shadow and live

A shadow policy runs every row a live one does and records shadow_would_arm (or shadow_would_require_approval) with the head it judged; a maintainer merges. Those records are the promotion evidence: only shadow_would_arm decisions merged unchanged at their head count. Grants are never consulted in shadow.

Repository-file authority and the legacy rollout stages are documented in upgrading.

Reference

Field tiers

TierPolicy fieldsBinding fields
EssentialallowedFiles, maxPatchFiles, maxModifiedLines, maxPerDay, evidence, descriptionname, mode (live, shadow, disabled)
Shape and checksdiffShape, modifyOnly, protectedFiles, holdoutChecks, releaseAgeCheck, monitorthe same lists, added to the policy’s; the three caps, lowered
Expertoracle, companionFiles, requiredLabel, author.adopt, requiresApprovaloracleWorkflow, the fill-once fields

The seven check names

Maku reads seven check-name fields across repository merge settings, central guardrails and merge policies:

FieldWhere setReported byWhen read and what happens
requiredChecksRepository.spec.merge, Factory.spec.mergeDefaultsAny CI check or status on the PR headFixed base before any policy runs: pending waits; cancelled re-runs up to merge.checkReruns; red starts a fix run up to merge.fixRuns, then hands off ci_red
verifyChecksRepository.spec.merge, Factory.spec.mergeDefaultsMain-branch push CI on the merge commitWatched after an auto-merge for merge.verifyFor: green ends Done; red reverts the merge (main_red)
leakScanCheckRepository.spec.merge, Factory.spec.mergeDefaultsSecret scanner check run (must also appear in requiredChecks and verifyChecks)First check in the fixed base and post-merge verification: red escalates immediately (secret_scan_red) with no fix run
contractCheckRepository.spec.merge, Factory.spec.mergeDefaultsTest-contract job (must not appear in requiredChecks; required when workflow.testFirst is set)Fixed base on tasks that carry a test contract (reports only on other tasks): pending waits, red triggers a fix run
mandatoryChecksFactory.spec.mergeGuardrailsGitHub Actions check run (SUCCESS)Appended centrally to every bound policy’s holdoutChecks during resolution
holdoutChecksMergePolicy.spec, BindingGitHub Actions check run (SUCCESS) on the PR headPolicy condition on the head (its workflow file is a gate path): missing or running waits holdout_pending; red, skipped, neutral or non-Actions refuses holdout_red
releaseAgeCheckMergePolicy.spec (author.adopt only)Commit status posted by an adopted login (for example renovate/stability-days)Policy condition on an adopted PR head: pending waits release_age_pending; failure or another author refuses release_age_red

.github/agent-factory.yaml

Parsed strictly (mergepolicy.Parse): unknown keys, duplicate keys, a key in another case (Mode:) and a key at the wrong layer are each an error. Then mergepolicy.Validate checks it against the central config.

KeyTypeDefaultConstraint
factorystringrequiredA factory name (DNS label). Must equal the config’s factory. Maku never edits it
mergePolicieslist of bindingsabsent: fence onlyEach item binds a MergePolicy the factory serves, by name, at most once. Names: lowercase letters, digits, -, at most 40, starting and ending alphanumeric (review is refused)

A file with a classes key is refused whole (ErrClassesRemoved). Under central authority, maku policy export writes the Repository’s bindings; under repository authority the Repository binds nothing, and .github/agent-factory.yaml holds the bindings.

Rules a file that sets mergePolicies must meet:

RuleErrorFix
mode is live, shadow or disabled ("off" and review are refused)binding docs-links: mode "off" is not live, shadow or disabledUse disabled for a catalog policy, or delete the binding

An unknown key names where it is, the key meant when it is close or another tool’s name for it, and every key valid there:

mergepolicy: mergePolicies[2]: key "maxFiles" is not a field (did you mean "maxPatchFiles"?); keys are matched exactly, in their documented case: one of allowedFiles, …
BoundValue
File size256 KiB
Bindings32
Patterns per list64
Patterns in the file256
Pattern length512 bytes
requiresApproval entries per binding16

A binding

The file’s mergePolicies is the same list as a Repository’s spec.mergePolicies (factory resources): it names a MergePolicy of the factory’s namespace and supplies the mode (live, shadow or disabled) and this repository’s parameters (allowedFiles, companionFiles, requiredLabel, oracleWorkflow, holdoutChecks, protectedFiles, requiresApproval, maxPatchFiles, maxModifiedLines, maxPerDay). Each binding resolves on its own: one that does not resolve drops its policy, never the file, and a file that does not parse pauses auto-merge (policy_invalid). The guardrails cap every binding.

factory: aws-0
mergePolicies:
  - {name: docs-links, mode: live, holdoutChecks: ['Check the documentation links 🔗']}
  - {name: docs,       mode: disabled}
  - name: alert-rules
    mode: shadow
    allowedFiles: ['^observability/.+\.ya?ml$']
    requiresApproval: [{changedFiles: ['^observability/base/']}]

Conditions

What a resolved policy may require, set on the policy, the binding, or both as the combination rules allow. An empty value is refused rather than read as absent.

FieldMeaning and unitDefault and who sets itRefusal reasonExample
allowedFilesRegular expressions for paths that may change, each anchored ^…$Unset: unbounded unless a diffShape bounds it; policy and/or bindingfile_not_allowed; admission also rejects an unanchored pattern['^website/content/.+\.md$']
maxPatchFilesChanged file count, integer ≥ 0 (0 means no cap)Guardrail default 10; policy or binding may lowerpatch_too_large; an explicit binding raise is OverPolicy5
maxModifiedLinesAdditions plus deletions, integer ≥ 0Guardrail default 300; policy or binding may lowerpatch_too_large100
maxPerDayAutomatic merges per UTC day, integer ≥ 0Guardrail default 5, also an unset repository merge.maxPerDay; policy or binding may lowerauto_merge_cap2
merge.pausedOperator pause for all automatic policy decisions: {reason}Unset; Repository.spec.merge or central merge defaults. A maintainer’s approve-to-merge still workspaused; alerts after 24 hours{reason: Incident freeze}
merge.autoRevertMerge the factory’s green revert only at the head GitHub createdfalse; Repository.spec.merge or central merge defaults. No revert policy neededRevert waits for a maintainer on a missing or moved headtrue
evidenceAgreed decisions before promotion: low 5, standard 20standard; policy only, low needs diffShape or oracleAdmission: evidence: low needs diffShape or oraclestandard
descriptionPlain sentence for settings and kubectl get, ≤ 280 charactersEmpty; policy only, never read by the gateNoneFixes broken links in docs
diffShapeMechanical diff shape: links-only, semver-patch, semver-minor, added-entryUnset; policy only (docs-links is links-only built in)class_mismatch; Unsupported value at admissionlinks-only
modifyOnlyForbid add/delete/rename/copy/mode changefalse; policy onlyfile_added_or_deletedtrue
protectedFilesUnanchored regular expressions for paths that always refuseCentral guardrails add ^\.github/, ^\.policy\.yml$, ^CODEOWNERS$; policy and binding add morefile_protected['^docs/superpowers/']
holdoutChecksGitHub Actions check names that must return SUCCESSmergeGuardrails.mandatoryChecks plus policy/binding additionsholdout_red; waits holdout_pending['Check the documentation links 🔗']
releaseAgeCheckCommit status proving an adopted release has agedUnset; policy only, needs author.adoptrelease_age_red; waits release_age_pendingrenovate/stability-days
monitorPost-merge checks: {verification, oracleRuns, flux, followUpWindow}No monitor; policy only, flux uses Repository.spec.merge.fluxSourcePost-merge revert or regression; missing source is MissingParameter{followUpWindow: 168h}
oracleDetector findings and cap: {probe: dead-links, maxFindings: 1..16}; binding supplies oracleWorkflowNo oracle; policy and bindingoracle_finding_open, oracle_unrequested{probe: dead-links, maxFindings: 2}
companionFilesAnchored paths an added-entry PR may append toEmpty; policy or binding, needs added-entryclass_mismatch['^index\.md$']
requiredLabelLabel an adopted PR must carry from an adopted loginEmpty; policy or binding, needs author.adoptlabel_missing, label_not_adoptedready-to-merge
author.adoptExternal authors and branches adopted instead of the agents App: {logins, branches}Agents App; policy onlynot_adopted_author, branch_not_allowed{logins: ['renovate[bot]'], branches: ['^renovate/']}
requiresApproval[].changedFilesUnanchored paths that still need a maintainer, even when liveEmpty; policy and binding unionapproval_required; shadow_would_require_approval in shadow[{changedFiles: ['^docs/architecture/']}]

Names from other tools

The parser refuses another tool’s name for a binding key and suggests the key meant. The ones it recognizes:

You may knowToolHere
only_changed_files, pathspolicy-bot, MergifyallowedFiles
no_changed_files, protectedPaths, denyFilespolicy-botprotectedFiles
modified_lines, maxLines, maxChangedLinespolicy-botmaxModifiedLines
files_count, maxFiles, maxChangedFilesMergifymaxPatchFiles
check-success, checks, requiredChecksMergify, GitHubholdoutChecks
label, labels, requiredLabelsMergifyrequiredLabel
has_workflow_resultpolicy-botholdoutChecks (no suggestion: write it)

A suggestion is matched case-insensitively; a key within two edits of a valid one (allowedFile) is suggested too.

Central config

All three blocks live at the top level of the factory’s config (or Factory.spec).

KeyTypeDefaultConstraint
workflows.<name>{template, tier, checks, loop, escalation, effort, models, description}the shipped quick, standard, careful, noneName like a policy name. template: solo, pair, investigate or none; tier: a tier; loop: off or a loops row; escalation: {outOfBudget, notConverged}, each a workflow; effort and models map non-implementer roles to low/medium/high and a model alias (internal runs: tier aliases only); none takes no other key; description ≤ 120 bytes
mergeGuardrails.protectedFileslist of regexp^\.github/, ^\.policy\.yml$, ^CODEOWNERS$, always firstAppended to every bound policy’s protectedFiles
mergeGuardrails.mandatoryCheckslist of check namesnoneAppended to every bound policy’s holdoutChecks
mergeGuardrails.maxPatchFiles, maxModifiedLines, maxPerDayint0, read as 10, 300 and 5A policy cap above it is clamped; an explicit binding cap above it is GuardrailMismatch; one without it inherits it
mergeGuardrails.maxGrantLifetimeduration0, read as 2160h (90 days)0 to 8760h. Every lookup expires a grant older than this since its creation or last renewal
policyManagement.stageread | simulate | managemanageSee the stages
policyManagement.operatorslist of GitHub loginsnone: no exception can be approvedRead by the broker
repositories[].classAuthoritycentral | repositorycentralrepository needs policyManagement.stage: manage and no central classes or mergePolicies

The broker reads policyManagement (stage and operators) and human.approvalMemory (bool, default false) from its own config.

A policy selects no workflow: a task’s workflow comes from a maintainer’s workflow:<name> label, its source or the Repository’s workflow.default (how the workflow is chosen). Workflow fields (harness, harnessAllowed, escalation, checks, testFirst), requires, mode: "off", and the review policy were removed from MergePolicy and bindings (upgrading). The default workflow’s template is read for coordination checks.

workflows:
  plain: {}
  checked: {checks: true}
  adopted-none: {template: none}
mergeGuardrails:
  protectedFiles: ['^\.github/', '^\.policy\.yml$']
  mandatoryChecks: ['Security scanning 🔒']
  maxPatchFiles: 20
  maxModifiedLines: 400
  maxPerDay: 5
  maxGrantLifetime: 720h
policyManagement:
  stage: simulate

A fuller example of the three blocks. The repository files on this page are validated against the central block in Start here instead (see how).

Worked examples

1. Restrict docs to the site and take it live. Need: ANR wants prose fixes under website/content/ merged, and nothing under docs/superpowers/.

# Repository ai-native-ref
mergePolicies:
  - {name: docs, mode: shadow, allowedFiles: ['^website/content/.+\.md$'], maxModifiedLines: 60}

The binding’s allowedFiles is a second filter: a path must match the policy’s list and the binding’s, so a binding can only narrow (MR3). Shadow shows: class=docs decision=shadow:shadow_would_arm files=2/5 lines=31/60. Promotion: at 20 agreed decisions the Evidence page proposes the one-line change mode: live; a maintainer merges it.

2. Create alert-rules around a test contract. Need: threshold tweaks in alert YAML, with something that checks what each tweak means. Nothing in the diff says whether a new threshold is the intended one, so a shape cannot; a test written from an approved plan can.

kind: MergePolicy
metadata: {name: alert-rules}
spec:
  description: Alert rule changes whose intent a test states.
  allowedFiles: ['^observability/.+\.ya?ml$']
  modifyOnly: true
  maxPatchFiles: 3
  maxModifiedLines: 40
  requires: [plan, tests]          # a plan you approve, then tests written before the change
  monitor: {verification: {within: 2h}, followUpWindow: 2h}
---
# Repository cloud-native-ref
mergePolicies:
  - {name: alert-rules, mode: shadow}

The plan says “fire HighErrorRate above 5 % for 10 minutes”, and a maintainer approves it. The tester writes that as a rule test (promtool test rules over the VMRule’s groups) before any change: red at the base, since the rule still says 10 %. The implementer changes the threshold; the contract check proves the test red at the base and green at the head, and the implementer cannot touch it. A change that raises the threshold out of reach fails the test. The record reads class=alert-rules decision=shadow:shadow_would_arm … signal=contract:ok.

Would merge after you approve the plan, without a review of the diff, when an agent changes YAML under observability/, at most 3 files and 40 lines, and a reviewer approves. Meaning checked by the test contract: red before the change, green after. Not checked: behaviour the plan did not name. After the merge Maku watches main for 30 minutes and opens a revert on red; waits 2 hours for RunLore’s verdict; reads follow-up fixes for 2 hours. Undo: factory/revert within 7 days.

With requires: [plan] alone, the same pull request records signal=none and the page says “Meaning checked by nothing”. A task that ran without a contract records signal=none too, and in considered= the others show why they did not hold (alert-rules:file_added_or_deleted). Promotion: standard, 20 agreed decisions. RunLore’s verdict stays as supporting evidence: an alert silenced by a raised threshold also resolves, so resolved is never a signal.

3. Create dead-links with an oracle. Need: a daily scan lists dead links; the fix must remove exactly those and touch nothing else.

kind: MergePolicy
metadata: {name: dead-links}
spec:
  description: Fixes for the dead links the scan reported.
  diffShape: links-only
  modifyOnly: true
  maxModifiedLines: 20
  oracle: {probe: dead-links, maxFindings: 10}
  monitor: {oracleRuns: 2, followUpWindow: 168h}
  maxPerDay: 1
  evidence: low
---
# Repository
schedules:
  - {name: dead-links, cron: "0 7 * * *", class: dead-links, probe: dead-links, workflow: quick, text: Fix the dead external links listed below.}
mergePolicies:
  - {name: dead-links, mode: shadow, allowedFiles: ['^(docs|website/content)/.+\.md$'], oracleWorkflow: dead-links.yaml}

Shadow shows oracle=ok only when every finding is gone from the head. Promotion: 5 decisions, about five weeks at one finding a week instead of five months.

Recipes

Start every new binding in shadow. On a Repository object you bind only exceptions; a repository-authoritative .github/agent-factory.yaml lists only the policies it wants to override. Every resolved policy must be bounded by allowedFiles or diffShape (Unbounded otherwise).

Export a repository’s bindings to .github/agent-factory.yaml

Before cutting a repository over to classAuthority: repository, .github/agent-factory.yaml should match what the factory serves so divergence reads 0. export writes the repository’s bindings as the file’s mergePolicies, and check verifies equivalence:

maku policy export --config factory.yaml --manifests resources.yaml --repository Smana/cloud-native-ref > .github/agent-factory.yaml
maku policy check  --config factory.yaml --manifests resources.yaml --repository Smana/cloud-native-ref .github/agent-factory.yaml
# equivalent

A repository whose classes are still the config file’s is refused (the repository's classes are the config file's, and the file binds central policies: migrate the repository first): convert it first with maku config migrate --from.

Documentation with approval-gated architecture paths

apiVersion: maku.ogenki.io/v1alpha1
kind: MergePolicy
metadata: {name: docs-broad, namespace: agent-system}
spec:
  description: Prose changes to the documentation, within a size bound.
  maxPatchFiles: 10
  maxModifiedLines: 200
  maxPerDay: 2
  monitor: {followUpWindow: 168h}
factory: aws-0
mergePolicies:
  - {name: docs-links, mode: live, holdoutChecks: ['Check the documentation links 🔗']}
  - name: docs-broad
    mode: shadow
    allowedFiles: ['^docs/.+\.md$', '^README\.md$']
    holdoutChecks: ['Check the documentation links 🔗']
    protectedFiles: ['^docs/superpowers/', '^docs/specs/', '^docs/security/']
    requiresApproval: [{changedFiles: ['^docs/architecture/']}]

Because docs-broad has no diffShape and no oracle, the gate also requires an approving reviewer verdict (reviewer_verdict_missing otherwise, MR12).

Dependency updates

An adopted policy: Renovate’s pull requests, with no agent run (none workflow).

apiVersion: maku.ogenki.io/v1alpha1
kind: MergePolicy
metadata: {name: deps-patch, namespace: agent-system}
spec:
  description: Renovate's patch bumps, once the release has aged.
  author: {adopt: {logins: ['renovate[bot]'], branches: ['^renovate/']}}
  modifyOnly: true
  maxPatchFiles: 3
  maxModifiedLines: 10
  diffShape: semver-patch
  releaseAgeCheck: renovate/stability-days
  maxPerDay: 2
  evidence: low
  monitor:
    followUpWindow: 168h
    flux: {within: 1h}    # the source is the Repository's merge.fluxSource
factory: aws-0
mergePolicies:
  - {name: docs-links, mode: live, holdoutChecks: ['Check the documentation links 🔗']}
  - name: deps-patch
    mode: shadow
    allowedFiles: ['^(apps|flux|infrastructure)/.+\.ya?ml$']
    protectedFiles: ['^infrastructure/base/crossplane/configuration-core/']

Minor updates get a policy of their own, deps-minor: the same author, diffShape: semver-minor, modifyOnly, the same caps and release age, no daily cap of its own. It is shadow only: a binding in mode: live is refused (semver-minor is shadow only), so it collects evidence and never merges.

factory: aws-0
mergePolicies:
  - {name: docs-links, mode: disabled}
  - {name: deps-minor, mode: shadow, allowedFiles: ['^(apps|flux|infrastructure)/.+\.ya?ml$']}

See adopted classes for how adoption reads commits and pushes.

Generated files

apiVersion: maku.ogenki.io/v1alpha1
kind: MergePolicy
metadata: {name: generated-files, namespace: agent-system}
spec:
  description: Regenerated files, compared byte for byte by a holdout.
  modifyOnly: true
factory: aws-0
mergePolicies:
  - {name: docs-links, mode: live, holdoutChecks: ['Check the documentation links 🔗']}
  - name: generated-files
    mode: shadow
    allowedFiles: ['^gen/.+$']
    holdoutChecks: ['Regenerate and compare']

The holdout is a gate-path GitHub Actions workflow that regenerates gen/ from the head and fails on any byte of difference; Maku reads its result and never runs repository code.

Two documentation scopes as separate policies

Two shapes of documentation change are two policies, each bound on its own, with its own evidence, promotion and daily cap:

apiVersion: maku.ogenki.io/v1alpha1
kind: MergePolicy
metadata: {name: docs-small, namespace: agent-system}
spec:
  modifyOnly: true
  maxModifiedLines: 40
  protectedFiles: ['^docs/(superpowers|specs)/']
  maxPerDay: 2
---
apiVersion: maku.ogenki.io/v1alpha1
kind: MergePolicy
metadata: {name: website-small, namespace: agent-system}
spec:
  modifyOnly: true
  maxModifiedLines: 20
  protectedFiles: ['^docs/(superpowers|specs)/']
  maxPerDay: 2
factory: aws-0
mergePolicies:
  - {name: docs-links, mode: live, holdoutChecks: ['Check the documentation links 🔗']}
  - {name: docs-small,    mode: shadow, allowedFiles: ['^docs/.+\.md$']}
  - {name: website-small, mode: shadow, allowedFiles: ['^website/content/.+\.md$']}

When a pull request touches only website/content/guide.md within 20 lines and both policies are live, website-small wins selection because its maxModifiedLines (20) is stricter than docs-small’s (40).

Tightening and relaxing

maku policy diff proves a change structural, policy by policy (mergepolicy.Structural), on the resolved classes. A tightening is bounded on every row by the old policy: fewer allowed paths, more denied ones, a wider approval subset, lower caps, more evidence, a lower mode. Anything else, including a rewritten pattern, is a relaxation.

Change to the docs-broad binding aboveVerdictWhy, as printed
maxModifiedLines: 100, protectedFiles adds '^docs/runbooks/'tightening
allowedFiles gains '^docs/.+\.svg$'relaxationallowedFiles broadened or rewritten
A new bindingrelaxationthe class is new (a new binding in mode: disabled is a tightening)
A removed bindingtightening

On a cut-over repository, a relaxation of a policy that is live in the new file runs that policy in shadow and logs repository merge policy relaxed: the class runs in shadow with the why. The demotion lives in the factory’s memory: a restart lifts it.

Moving a repository to its own file (classAuthority: repository)

  1. policyManagement.stage at simulate or manage, the exported .github/agent-factory.yaml merged, divergence 0, and a week without unexplained dual evaluations.
  2. One central pull request switching the repository to classAuthority: repository and removing its central bindings:
policyManagement: {stage: manage}
repositories:
  - name: Smana/cloud-native-ref
    maintainers: [Smana]
    triggerLabel: factory/ready
    classAuthority: repository
    # merge, checks and schedules stay as they were; classes is removed

A repository served from a Repository object sets classAuthority: repository there instead, and drops its mergePolicies: the file then holds the bindings (classAuthority repository: the repository's file holds the bindings (MP15)).

  1. Reverting that pull request is the rollback. No tool writes a repository file back to central objects, so a binding changed in .github/agent-factory.yaml after cutover is carried back by hand.

Workflows

Validate a binding file: maku policy diff

To validate a new or changed .github/agent-factory.yaml, use diff, never check. diff parses both files strictly, resolves each binding against the policies --manifests serves and the central guardrails, and names each policy’s structural change. Pass the same file twice to validate one file alone. It requires policyManagement.stage at simulate or manage.

maku policy diff --config factory.yaml --manifests resources.yaml --repository owner/name old.yaml new.yaml

It prints CLASS CHANGE WHY per policy: unchanged, tightening, or relaxation with why.

Migration only: maku policy check

maku policy check --config factory.yaml --manifests resources.yaml --repository owner/name .github/agent-factory.yaml

check means equivalent to the central policies, not “valid”. It parses and validates as diff does, then prints equivalent or each difference (docs-broad: only in the repository). Use it for the export before a cutover, and in a repository’s CI while the central config still decides.

Fixture replay: maku policy simulate

maku policy simulate --config factory.yaml --repository owner/name new.yaml \
  internal/factory/reconciler/testdata/conformance/*.json

A fixture replay, not an impact preview: it replays Maku’s conformance fixtures (version 2) under the central policies and under the file’s policies with the gate’s own evaluator, and prints CENTRAL, REPOSITORY and the change (unchanged, newly_auto_merged, newly_blocked, newly_approval_required, changed). It requires policyManagement.stage at simulate or manage.

The fixtures are recorded under the test config in internal/factory/reconciler/simulate_test.go, for dead-links and docs. Under any other config a row prints (the fixture recorded another central decision): read a replay as proof that the evaluator is the gate’s, not as a preview of your repository’s pull requests.

Recorded-diff backtest

maku policy backtest new.yaml --repository owner/name --since 30d replays the newest recorded per-policy decisions under an edited file, with the same evaluator the gate uses. The policy and binding editors offer the same replay against the last 30 days. Each row links to a real pull request and shows its before and after. Only changed and unknown rows print; the counts include unchanged decisions too. A warning names a rule that matched none.

A backtest reconstructs the diff from the merge commit’s first parent and the judged head, and reuses the recorded checks and fixed-base evidence. If those immutable references or the diff are unavailable, the row is unknown, never unchanged. Oracle decisions are also unknown because their original finding snapshots are not in the decision record. The replay writes nothing.

The settings pages

With policyManagement.stage: manage (factory and broker), /settings/merge-policies/<owner>/<name> shows a repository’s policies and evidence, and /settings/merge-policies/policies/<name> shows one policy; see the web UI for permissions. Editors write nothing: each answers with the manifest or file edit to commit. Promotion is the one exception, below, and opens a pull request without merging it.

RepositoryWhere its bindings are editedCheck answers
Bound, central authorityThe Bindings editor: each binding’s mode and parameters, the policy’s meaning read-onlyThe Repository manifest, repository-<name>.yaml, each binding resolved or refused with its reason: commit it where the platform’s GitOps applies it
repository authority.github/agent-factory.yaml, by pull request: the page shows each policy’s file binding and no editorNothing on the page: maku policy diff checks the file. It touches .github/, so a human merges it
Not migrated (its classes are the config file’s)Nowhere: the page says “Not migrated yet: maku config migrate prints its Repository.”—

A policy’s page shows its definition and its consumers. Its editor checks a changed spec (POST /api/policy/policies/<name>/preview): the mergepolicy-<name>.yaml to commit and each consumer’s change, live consumers first.

Promotion: shadow to live

    sequenceDiagram
  participant M as Maintainer
  participant UI as /settings or maku
  participant B as Broker
  participant F as Factory
  participant GH as GitHub
  M->>UI: Promote to live
  UI->>B: POST /api/policy/promotions
  B->>F: GET /v1/policy/evidence (caller's token)
  F->>GH: 180 days of the policy's pull requests
  F-->>B: clean, bad, drill, proposal
  B->>B: eligible? record in policy_promotions
  B->>F: POST /v1/policy/promote
  F->>GH: open factory/promote-<repository>-<policy>, one mode line
  F-->>UI: pull request URL
  M->>GH: review and merge it
  B->>F: read served mode and PR state
  F-->>B: close merged when live, abandoned when closed unmerged
  

A policy is eligible when all three hold (evidence.Evaluate):

BlockerClears when
below_minimumAt least the policy’s minimum shadow decisions a maintainer merged unchanged at the head the decision judged: 5 at evidence: low, 20 at standard (the default)
bad_outcomeNo mature, conclusive merge of the policy was reverted (other than a drill), followed up or regressed
no_drillA factory/drill revert of one of the repository’s pull requests merged: the drill is per repository, so one clears it for every policy

Shadow evidence is keyed by class=<policy> in the gate’s decision marker, so agreed decisions recorded under earlier label-chosen decisions and under diff-chosen decisions count together with no migration. Only a served shadow policy is promotable. The factory re-reads the GitOps file and changes only its mode: shadow line to mode: live; the pull request body carries the agreed, wrong-call and drill counts and the supporting pull requests. Factory.spec.gitops names the repository, path and base branch. A requested record resumes after a failed open; a second request is refused once the PR is open. There are no Merged or Abandon buttons: served live closes the record merged, and an unmerged close closes it abandoned, allowing another request.

With gitops unset, the response instead carries the one-line proposal and its gh pr create command; the maintainer opens the PR manually. maku policy promote POLICY --repository owner/name uses the same flow. For the first rollback drill, choose a merged PR of the repository and run maku policy drill owner/name#PR: the merger App opens a revert labelled factory/drill, and a maintainer reviews and merges that too. Any merged pull request of the repository qualifies, whoever merged it.

Below the minimum, a maintainer may request an exception (a lower minimum and a justification of 20 to 2,000 characters); one of policyManagement.operators approves or refuses it once. An approved exception lasts 14 days; bad outcomes and the drill still block.

Approval memory

For a pull request a live policy’s requiresApproval subset sent to a maintainer (approval_required), /settings/approval-memory offers two choices:

ChoiceEffect
Merge onceApprove the head on GitHub: the approved-merge path merges that head only and saves nothing
Merge and create ruleSaves a grant and merges nothing: this pull request stays waiting for a human, and a maintainer still merges it (approve its head with merge.approveToMerge, or merge it by hand), because an approval_required hand-off never returns to the gate by itself. The grant covers later pull requests. Preview rule first shows the exact predicate, the future pull requests it would match, what stays outside it, its expiry and how to revoke it

The form takes the repository, policy, pull request, the record’s policy= or resolved= hash and the caught files (?repository=&class=&pr=&policy=&file=…). Each caught file becomes an exact pattern. A grant matches a later pull request when it is active, of the same repository and policy, bound to the policy in force, unexpired, every caught file matches one of its patterns, and its optional diff shape (links-only, semver-patch, semver-minor) holds. The lowest id wins.

A grant never bypasses the fixed base, the policy’s conditions and deny, the breaker, the caps, a policy in shadow or disabled, a policy change, or its expiry.

    stateDiagram-v2
  [*] --> active: created (maintainer)
  active --> suspended: lookup under another policy hash
  suspended --> active: reconfirm (maintainer)
  active --> expired: past expiry or maxGrantLifetime
  suspended --> expired
  expired --> active: renew (maintainer)
  active --> active: renew, used
  active --> revoked: revoke (maintainer or admin)
  suspended --> revoked
  expired --> revoked
  active --> disabled: a merge it authorized reverted
  suspended --> disabled
  expired --> disabled
  revoked --> [*]
  disabled --> [*]
  
ActionWhoNote
Create, renew, reconfirmA maintainer (GitHub write)Lifetime 1–365 days, 90 by default, cut at each lookup by maxGrantLifetime. Reconfirm rebinds to the hash the suspension was found under
RevokeAny maintainer, or an adminImmediate and final
ExportAny readerGET /api/approval-memory/export?repository= as YAML

The factory reads grants immediately before the decision and again before the merge call, never from a cache; a failed lookup authorizes nothing. The decision record names the grant (grant=<id>:<version>).

Operating it

Metrics

Definitions are in operations; this is what to watch per stage.

stageQueryExpected
read, simulate, managemax by (repository) (maku_factory_policy_central_divergence)0
read, simulate, managesum by (repository, reason) (increase(maku_factory_policy_load_errors_total[1h]))No series
simulate, managesum by (repository, agreement) (increase(maku_factory_policy_dual_decisions_total[1d]))No unexplained; explained only while divergence > 0; no no_policy once the file is read
manage (repository authority)sum by (repository, class, change) (increase(maku_factory_policy_changes_total[1d]))relaxation only with a pull request you meant
manage (grants)maku_factory_approval_grants_active, increase(maku_factory_approval_grant_events_total{event="disabled"}[1d])disabled 0
manage (promotions)increase(maku_rooms_policy_changes_total[7d])Each eligible automatic promotion reaches promotion_pr_opened, then promotion_merged when served live or promotion_abandoned when closed unmerged; a no-GitOps request begins at promotion_requested
Allsum by (class, reason) (increase(maku_factory_merge_decisions_total{reason=~"policy_.*|approval_required"}[1h]))policy_* 0

Maku ships no alert on these series; add the host’s rules for an invalid or unreadable policy and a disabled grant.

Reading a decision

/settings/merge-policies/<owner>/<name>/decisions/<pr> renders each record the factory wrote on the pull request in the gate’s order: fixed base, author mode, policy conditions, requires approval, grant, breaker and caps, verdict. The stage that refused is named; later stages are not reached. The record’s fields are in the factory:

<!-- agent-factory-decision head=<sha> class=docs-broad decision=human:approval_required files=2/10 lines=14/200 … policy=3f2a9c1e0b7d -->
FieldUse
policy=The snapshot decided under (cut over), or compared (dual). Match it against sha256sum .github/agent-factory.yaml at the commit
dual=agree, explained, unread, unexplained, no_policy. With anything but agree the factory logs merge decision under the repository policy with both decisions
grant=The grant and version that let it arm
policygen=The generation of the bound policy’s MergePolicy the decision used, below. Absent for a class the config file declares
repogen=Only for a bound policy: the generation of the Repository that holds the binding (its mode and parameters)
considered=Each candidate policy that did not hold, as <policy>:<reason>, comma-separated. Each shadow policy that held has a record line of its own after the decision’s
resolved=The first 12 hex digits of the resolved policy’s hash: the policy’s definition and this repository’s binding together, mode excluded. It is what an approval grant binds to, so the approval-memory form prefills from it; an edit to another policy leaves it, and its grants, unchanged

The guardrails and workflows in force are the pod’s config, bound by its checksum, not per record. policy_unavailable and policy_invalid decisions map to no stage on the timeline.

Reasons

The gate’s policy-related reasons. Every other reason is in the factory.

ReasonMeansNext step
helda maintainer put this pull request on hold (factory/hold)a maintainer reviews the task and chooses the next step
policy_unavailablethe repository’s merge policy could not be read recently, so auto-merge waitsa maintainer reviews the task and chooses the next step
policy_invalidthe repository’s merge policy is invalid, so auto-merge is pauseda maintainer reviews the task and chooses the next step
approval_requiredit changes a file its class asks a maintainer to approvea maintainer reviews the task and chooses the next step
shadow_would_require_approvala shadow policy would merge, except a path needs a maintainer approvala maintainer approves the current head; this does not count as an agreed decision
shadow_would_armit would auto-merge, and the merge gate is in shadowa maintainer reviews the task and chooses the next step
no_policy_matchedno merge policy of the repository holds on this diff: a maintainer reviews and merges ita maintainer reviews the task and chooses the next step
reviewer_verdict_missingno reviewer read this change, and its policy has no shape to check ita maintainer reviews the task and chooses the next step
file_not_allowedit changes a file outside its class’s allowed filesa maintainer reviews the task and chooses the next step
file_protectedit changes a file its class protectsa maintainer reviews the task and chooses the next step
file_added_or_deletedit changes a file in a way other than editing its content (an add, delete, rename, copy or mode change), which its class does not allowa maintainer reviews the task and chooses the next step
patch_too_largeit changes more files or lines than its class allowsa maintainer reviews the task and chooses the next step
class_mismatchthe diff is not the class the triage predicteda maintainer reviews the task and chooses the next step
holdout_reda holdout check its class requires did not succeed (failed, cancelled, neutral, skipped, or not posted by GitHub Actions), or its checks could not all be reada maintainer reviews the task and chooses the next step
holdout_pendinga holdout check has not passed yetnothing to do: the task goes on when the holdout checks report
release_age_redthe release age check failed, or was not posted by the adopted logina maintainer reviews the task and chooses the next step
release_age_pendingthe release age check has not passed yetnothing to do: the task goes on when the release age check passes
label_missingit does not carry the label its class requiresa maintainer reviews the task and chooses the next step
label_not_adoptedits required label was not applied by a login the class adoptsa maintainer reviews the task and chooses the next step
approval_stalea maintainer’s approval is of an older head: approve the current onea maintainer reviews the task and chooses the next step
head_unreportedthe task’s implementer never reported its current head in the room: no handoff of its runs names that commita maintainer reviews the task and chooses the next step
changes_requesteda reviewer requested changes, and the factory does not merge over themthe agent revises after a Request changes review; to merge as it stands, the reviewer approves
policy_pendingthe merge policy is not readya maintainer approves the merge policy in Settings
policy_absentthe merge policy has not evaluated the pull requesta maintainer reviews the task and chooses the next step
gate_pathit touches a gate path, so an agent can never merge ita maintainer reviews the task and chooses the next step
class_pausedauto-merge of this class is paused after a revert, a follow-up fix or a regression in its recent mergesa maintainer reviews the task and chooses the next step
auto_merge_captoday’s auto-merge cap is reacheda maintainer reviews the task and chooses the next step

Other policy vocabularies:

WhereValues
maku_factory_policy_load_errors_total{reason}invalid, counted at every read; unreadable, stale, counted per gate pass of a cut-over repository. A binding over a guardrail is refused alone (GuardrailMismatch), never the file
policy diffunchanged, tightening, relaxation
Promotion blockersbelow_minimum, bad_outcome, no_drill
Settings API refusalsnot_a_maintainer, not_an_operator, no_such_class, not_promotable, evidence_pending, not_eligible, exception_unusable, minimum_not_below, justification_length, bad_state, records_unavailable
Grant API refusalsbad_predicate, repository_permission, grant_state (status or version moved: reload), grants_unavailable

Rollback

Every rollback is a pull request: to the repository’s Repository (or .github/agent-factory.yaml) for a policy, or to the central Factory / config for a stage.

A policy

ToDoTakes effect
Hold one pull request immediatelyApply the factory/hold label on GitHub (MR10), or request changes on itNext gate pass (at once)
Demote a live policy to shadowSet its binding’s mode: shadow (or mode: disabled to turn it off) in the Repository or .github/agent-factory.yamlOnce Flux applies the Repository, or on the next fence read within 5 minutes
Undo a promotionRevert the promotion’s pull requestAs above
Stop one saved grantRevoke it on /settings/approval-memoryAt once, for good
Undo a bad file on a cut-over repositoryRevert it on the default branch. Meanwhile an invalid file already pauses auto-merge (policy_invalid); human merges continueOn the next read

A relaxation needs no rollback to be safe: a cut-over repository runs a relaxed live policy in shadow until the factory restarts.

A stage

To roll backSetEffect
Repository authority (classAuthority: repository)Revert the cutover pull request (restore Repository.spec.mergePolicies and drop classAuthority: repository), before lowering stage below manageCentral Repository bindings decide again
Settings pages, promotions and grant lookupspolicyManagement.stage: simulate on the factory and broker (and human.approvalMemory: false on the broker)/settings/* and /v1/policy/* return 404; grants stay in the database unused
Simulation and dual evaluationpolicyManagement.stage: readmaku policy diff and simulate refuse; decision records omit policy= and dual=

Troubleshooting

maku policy check says not equivalent for a file I just wrote. check means “equivalent to central”, not “valid”: a new policy is only in the repository. Validate it with maku policy diff (the same file twice is fine).

the classes shape was removed in this release. The file uses the removed classes: map: write mergePolicies bindings instead, with maku policy export once the factory serves the repository from a Repository (upgrading).

A policy has unknown field harness, requires or mode "off". v0.52.0 removed workflow fields and requires from MergePolicy, replaced binding mode: "off" with mode: disabled (or deleting the binding), and replaced the six policyManagement switches with stage. Run maku config migrate or consult merge policies removals.

A policy I bound is missing. Its binding did not resolve and dropped that policy alone. maku policy check prints <policy>: refused, <reason>: …, and a Repository’s BindingsValid condition names it; the reasons are in policies and bindings.

maxPatchFiles 30 is over the guardrail's 20. A binding may only lower a guardrail cap (GuardrailMismatch). Leave the key out to inherit it.

allowedFiles "docs/.+" must start with ^ and end with $. Anchor allow lists. Protected and approval patterns are unanchored on purpose: '^docs/specs/' covers the directory.

key "Mode" is not a field (did you mean "mode"?). Keys are case-exact. The message starts with where the key is (mergePolicies[2]:) and lists every key valid there.

considered=docs:reviewer_verdict_missing. docs has no diffShape and no oracle, so MR12 requires a reviewer’s approve, and the task ran a workflow without a reviewer (such as quick). Run with standard or careful, or merge by hand.

The divergence gauge stays at 1 after I fixed the file. It updates on the next valid read, up to five minutes later. After a failed read or a removed file it keeps the last compared value until the factory restarts; read it with the load-error counter.

dual=unread. The repository’s decision needed the diff and the central decision did not read it. Expected on a pull request the central policy never diff-checks; it is not a disagreement.

A cut-over repository stopped auto-merging. policy_unavailable (reads failing) or policy_invalid (the file) in the decision; maku_factory_policy_load_errors_total names which. Human merges still work.

A live policy went to shadow on its own. A merged change was a relaxation; the log line repository merge policy relaxed says why. It stays in shadow until the factory restarts; promote it again with evidence if the relaxation was intended.

My grant stopped matching. suspended: the policy changed, reconfirm it. expired: renew it. disabled: its merge was reverted, create a new one if still right. Otherwise the pull request caught a file the grant’s patterns do not cover, or the policy is not live.

The settings pages are a 404. policyManagement.stage is below manage on the broker or the factory, or factoryURL is unset on the broker. Approval memory’s page also needs human.approvalMemory: true.

Promote to live answers not_promotable. The policy is not bound/served from a Repository or not in shadow.

Factory resources

The chart ships three kinds in maku.ogenki.io/v1alpha1: Factory, Repository and MergePolicy. The factory reads them on every replica, together with the config file, and a change applies without a restart. How is in architecture.

  • Live: the catalogue and repositories, including each repository’s policies and merge rules and adding or removing a repository. Needs a rollout: the startup switches, among them policyManagement, coordination, hardening and api. The table lists both.
  • A refused change keeps the last accepted version while the factory runs. After a restart an invalid object is not served, and a factory with nothing to serve waits, unready, until its resources are applied.
  • Deleting the only Repository leaves nothing servable: the factory logs config not servable, keeping the current one and keeps serving the last config until it restarts. A restart then waits, not Ready, until a Repository is applied again.
  • A repository defined in both the file and a resource is refused, never merged.
  • Tasks record status.configGenerations for the Factory, Repository and MergePolicy they started under. It is a record, not a pin.

Policies and bindings

A MergePolicy is one policy definition: its metadata.name is the policy name, and its spec declares what changes it admits. A Repository evaluates every non-disabled catalog policy in shadow and binds its exceptions under spec.mergePolicies, each with its mode (live, shadow or disabled) and repository-specific parameters, while holding its merge settings under spec.merge. One definition serves every repository that uses it, so a shared edit is reviewed once.

apiVersion: maku.ogenki.io/v1alpha1
kind: MergePolicy
metadata: {name: dead-links, namespace: agent-system}
spec:
  description: Retargets dead external links a detector found, and nothing else.
  modifyOnly: true
  maxModifiedLines: 20
  diffShape: links-only
  protectedFiles: ['^docs/(superpowers|specs)/']
  oracle: {probe: dead-links, maxFindings: 10}               # the workflow file is the repository's
  monitor: {oracleRuns: 2, followUpWindow: 168h}
  maxPerDay: 1
  evidence: low
---
apiVersion: maku.ogenki.io/v1alpha1
kind: Repository
metadata: {name: ai-native-ref, namespace: agent-system}
spec:
  factoryRef: aws-0
  repository: Smana/ai-native-ref
  maintainers: [Smana]
  merge:
    requiredChecks: [validate, lint]
    verifyChecks: [validate, lint]
    leakScanCheck: lint
    mergerLogin: ogenki-agent-merger[bot]
    approveToMerge: true
    breaker: {window: 10, maxReverts: 1}
  mergePolicies:
    - {name: docs-links, mode: shadow, holdoutChecks: [validate]}
    - {name: docs,       mode: disabled}
    - name: dead-links
      mode: shadow
      allowedFiles: ['^(docs|website/content)/.+\.md$']
      holdoutChecks: ['External links 🔗']
      oracleWorkflow: dead-links.yaml

Every field has one combination rule:

KindFieldsOn the policyOn the bindingResolved as
Meaningdescription, author.adopt, diffShape, modifyOnly, oracle.probe, oracle.maxFindings, releaseAgeCheck, monitor, evidenceyesrefusedthe policy’s
Modemode: live, shadow, disabledrefusedrequiredthe binding’s
NarrowingallowedFilesoptionaloptionalthe one that is set; on both, a path must match the policy’s list and the binding’s (narrowedFiles on the resolved class)
Fill oncecompanionFiles, requiredLabel, oracleWorkflowoptionaloptionalset in one place; both is ParameterTwice
AdditiveholdoutChecks, protectedFiles, requiresApprovaloptionaloptionalthe union
CapsmaxPatchFiles, maxModifiedLines, maxPerDayoptionaloptional, at most the policy’sthe lower; above the policy is OverPolicy
Repository factthe Flux source a monitor watches——Repository.spec.merge.fluxSource

A binding tightens or fills; it never widens what the policy says. The guardrails cap every binding: their paths and checks are added, an unset cap inherits theirs, a policy cap above theirs is clamped, and an explicit binding cap above theirs is GuardrailMismatch. docs-links carries diffShape: links-only built in; review is not a policy and is refused on both MergePolicy and bindings.

Factory.spec.mergeDefaults holds the merge settings most repositories share. A Repository overrides them key by key: a key it sets wins whole (a breaker it sets replaces the default’s), and a key it omits is the default’s. Repository.status.merge shows the result, and status.mergeDefaulted names the keys the Factory filled. Set merge.autoRevert: true to let the merger merge a green revert at the exact head GitHub created; the default is off and no revert policy is needed.

Each binding resolves and fails on its own. A policy is accepted when it is valid alone. A binding that does not resolve drops that policy only: the Repository and its other policies keep serving. While the factory runs, a refused edit can restore the last resolved policy only at the lower of its old mode and the binding’s written mode. disabled and MissingRef restore nothing; after a restart no refused binding serves a last resolved policy. A repository’s own file in mergePolicies (above) resolves the same way.

ReasonOnMeansFix
MissingRefa bindingNo served policy has its name, or the policy was refused with none served beforeApply or fix the policy
MissingParametera bindingoracle without oracleWorkflow, or monitor.flux without merge.fluxSourceSet it
ParameterTwicea bindingA fill-once parameter (companionFiles, requiredLabel, oracleWorkflow) set on the policy and the bindingRemove one
OverPolicya bindingA cap above the policy’sLower it
GuardrailMismatcha bindingA cap above mergeGuardrailsLower it
Unboundeda bindingBound live or shadow, the policy resolved with it has neither allowedFiles nor a diffShape (docs-links has its shape built in)Set allowedFiles on the policy or the binding, or a diffShape
AmbiguousAdoptiona bindingTwo adopted bindings of one shape share a login and an overlapping branch prefix; the later in the list is refused and keeps no last policyNarrow or unbind one
Invalida binding, a policyThe resolved policy, or the policy alone, fails the class rulesThe message names the rule
DefinedTwicea RepositoryThe config file also defines the repositoryRemove it from one of the two

The per-repository shape (spec.repositoryRef, classes and merge on one MergePolicy per repository) is removed: a forgotten object reads as an empty policy with CONSUMERS 0, and maku config validate refuses one (upgrading).

Offline commands prepare the move. migrate splits a config file into the Factory, each Repository with its bindings, and one MergePolicy per non-catalog policy (rewriting any removed workflow or mode fields into their new homes); validate lays manifests over a config file and refuses what the factory would refuse, one line each:

maku config migrate --from config.yaml --residual residual.yaml > manifests.yaml
maku config validate --config residual.yaml --base-ref origin/main manifests.yaml   # each changed policy's consumers

The residual is the file to deploy. A catalogue key left in the file next to a Factory is ignored, with a warning at every start. When the file comes from a Helm values file, remove the migrated keys from the values rather than overriding them with key: null. The flags are in the CLI.

Status

The leader writes each object’s status; the other replicas never do. It runs every 30 seconds and after every config sync, lists the three kinds without the cache (a kind whose CRD is not installed counts as empty) and writes an object only when its status changed. With no object it reads nothing else, and with none of the three CRDs installed it runs every 5 minutes, and after every sync.

kubectl get factory,repository,mergepolicy -n agent-system

An example output, with plausible values:

NAME                                   ACCEPTED   READY   REPOS   STOPPED   AGE
factory.maku.ogenki.io/aws-0           True       True    2       false     12d

NAME                                     REPO                  FACTORY   POLICIES   LIVE   ACCEPTED   CONNECTED   AGE
repository.maku.ogenki.io/ai-native-ref  Smana/ai-native-ref   aws-0     4          0      True       True        12d

NAME                                   CONSUMERS   CURRENT   LIVE   DESCRIPTION                              AGE
mergepolicy.maku.ogenki.io/dead-links  2           1         0      Retargets dead external links             3d

The status and each of its conditions carry one observedGeneration: the generation the factory last looked at, which trails the object’s own until it reads the newer one. A condition’s lastTransitionTime moves only when its status does. A refused object keeps the last accepted version in service, and its message says which generation that is. The factory logs one WARN line, generation refused, with the kind, name, generation, serving generation and the first error, the first time it refuses a generation, and one binding refused line per refused binding.

ConditionOnStatus and reason
Acceptedall threeTrue Served; Unknown Pending (not looked at yet); False with the refusal: NotThisFactory, DefinedTwice, MissingRef, Invalid. A MergePolicy refused with a generation still serving reads serving generation 3; generation 4 refused: …
BindingsValida Repository with bindingsTrue BindingsValid; False BindingsRefused, the message naming each refused binding: refused: dead-links (MissingParameter)
ReadyRepositoryTrue Ready; False when a generation or any binding is refused, even when a last good class still serves; Unknown Pending before the first read
PausedRepositoryTrue OperatorPaused while spec.merge.paused is set, with the operator’s reason; False NotPaused
ConnectedRepositoryTrue Healthy; False Unhealthy (the GitHub connection), WiringFailed (the message is the error), NotServed; Unknown NotChecked (no GitHub call yet)
RepositoryFileValidRepositoryTrue Valid, or FenceOnly (the file gives only factory: and the repository is under central authority, so the central policies decide); False Invalid (the file does not parse, is in the removed classes: shape, or, under repository authority, binds no policy); Unknown PolicyReadOff, NotServed, NotRead
InSyncRepositoryTrue InSync, or FenceOnly; False FileInvalid, or Diverges (the message lists up to five differences from the repository’s file); Unknown, same reasons as above
PrivateCodeRepositoryTrue Public, Acknowledged; False Unacknowledged (private, internal or unread code without spec.privateCode.acknowledged: private code); Unknown NotChecked, NotServed
ReadyFactoryTrue Ready; True ServingLastGood (a newer generation was refused and the last accepted one keeps serving: the message reads serving generation 3; generation 4 refused, and Accepted carries the error); False NotAccepted (nothing is served), GitHubDown (a served repository is unhealthy; one not checked yet is not counted), SyncFailing (the last sync failed, or none in 15 minutes)

A Repository reports its authority (central or repository), its resolved merge and mergeDefaulted, and one entry per binding in classes[]: the written mode, the servedMode actually in force, the policyGeneration it serves, accepted with reason and message, and the last decision as verdict:reason with its time. A MergePolicy reports its consumers[] (each binding Repository, its mode, the generation it serves, whether it resolved and why not), consumerCount, currentCount (consumers serving its current generation) and liveCount. The last decision is kept in memory and is best-effort: it is empty after a restart or a leader change, until the next decision. Every decision marker of a bound policy carries policygen=<n>, the generation of its policy, and repogen=, so a decision can be matched to the objects that made it.

The settings pages follow the split. A bound repository’s page offers its repository-<name>.yaml from the bindings editor, and each policy has its own page with its consumers and the mergepolicy-<name>.yaml its editor checks. A change is a GitOps pull request on the manifest, which Flux applies, and the factory builds the manifest from the version it serves: a change it refused is not in it.

Counts and spend are not in the status yet.

How this page’s examples are checked

Every YAML block marked with <!-- check: central --> or <!-- check: repository --> is parsed and validated by internal/app/maku_policy_docs_test.go, run by task test: each central block is laid over the test config internal/app/testdata/policy-factory.yaml and loaded with config.Parse; each repository file is checked with mergepolicy.Parse and mergepolicy.Validate against that config with this page’s first central block. The test config serves no MergePolicy, so this checks a file’s shape and its required bindings, not what each binding resolves to. The MergePolicy manifests, the worked-example fragments and the .policy.yml block are not checked by that test.