policy.yaml
policy.yaml applies to every work item and lives at $KRAFT_HOME/config/policy.yaml.
kraft admin reload rereads this file with the same validation as startup. If the file doesn't validate, Kraft keeps the running policy and reload exits 1 naming why. New loop caps apply to loops that start after the reload.
For how caps, maxima and layers combine, see Caps and budgets.
loops: {}
default: { attempts: 3, wall_clock_s: 3600 }
findings:
loop_severities: [critical, important]
max_concurrent: 3
budget:
work_item_usd: 10
daily_usd: 50
rate_limit_retries: 5
forge_cli_timeout_s: 120
archive:
after_days: 30
The shipped file also holds defaults: and maxima: as comments; see defaults and maxima.
Top-level keys
| Field | Type | Default | Meaning |
|---|---|---|---|
loops.<name> | {attempts, wall_clock_s} | unset | Sets attempts and wall_clock_s for one named loop. See Loop keys. |
default | {attempts, wall_clock_s} | — | Required: without it policy.yaml doesn't load, and Kraft refuses new work. The attempts and wall_clock_s ceiling for every fix loop not named in loops; a max_attempts on the loop itself wins. The seeded file sets {attempts: 3, wall_clock_s: 3600}. |
max_slices | integer | 6 | The most slices a plan's ## Slices section may name. A plan with more isn't sliced, and its plan gate says why. Added in 2.6 |
max_concurrent_slices | integer | unset | How many children of one sliced item may run at once. Unset: only max_concurrent limits them. Added in 2.6 |
max_concurrent | integer | 3 | The concurrency limit: how many work items may be active at once across all repos, however they were started. A start past the limit is queued, not refused. |
auto_escalate_stuck | boolean | true | Whether a stuck stop auto-dispatches an escalation turn on a node that declares no escalation of its own. |
auto_escalate_stuck_cap | integer | 3 | How many times one stuck run is auto-escalated before it is left for you. |
auto_escalate_delay_s | integer | 0 | Seconds to wait after the triggering event before an auto-escalation fires, so a person about to look isn't preempted. |
auto_review_attempts | integer | 1 | How many automated-review attempts one pending gate may spend before it is left for you. |
forge_cli_timeout_s | number | 120 | Seconds one forge CLI call (gh, glab, git) may run before Kraft kills it and reports a forge error. Read at startup and on reload. |
agent_idle_minutes | integer | 30 | Minutes an agent session may write nothing to its log before Kraft kills it and stops the item for you. 0 turns it off. Added in 2.3 |
forge_poll_s | integer | 300 | Seconds between the MR-closed poller's ticks, which ask the forge about every item parked at a merge-request node. Minimum 30. |
attribution.mr | boolean | true | Whether every merge request description ends with a footer that links to Kraft and names the work item. With false, Kraft leaves it off from the next description it writes; it rewrites the description at every sync. Added in 2.5 |
findings.loop_severities | list of critical, important or minor | [critical, important] | Which review-finding severities burn a fix cycle; lower ones are recorded and shown at the human-review gate. |
budget.work_item_usd | number | unset | Dollar cap per work item across all its loops. Unset: no cap. The seeded file sets 10. |
budget.daily_usd | number | unset | The daily dollar cap: what every work item on this instance may spend together since local midnight. Unset: no cap. The seeded file sets 50. |
rate_limit_retries | integer | 5 | How many times Kraft relaunches a work item after a rejected API rate limit before stopping and waiting for you. |
archive.after_days | integer | unset | Completed and abandoned items older than this many days auto-archive, checked hourly and on a publish or reload. The board's Done header shows the number. Unset or 0: no auto-archive and no note. The seeded file sets 30. |
storage.worktrees.limit | size | unset | The most disk worktrees may use. Unset: nothing is measured or held. Over it, a start that needs a new worktree waits. See Storage keys. |
storage.worktrees.quota | size | 80% of limit | Over it, Kraft warns and nothing else. Needs a limit. |
storage.worktrees.auto_cleanup.min_age | age | unset | Unset: no automatic clean-up. An empty auto_cleanup block is 24h. When starts are held, Kraft archives finished items that ended at least this long ago, oldest first, until what archiving can free is under quota. Needs a limit. |
storage.outputs.max_size | size | 64M | The most Kraft keeps of one task's step outputs; a larger capture fails the task. At most 256M. See Step output keys. Added in 2.6 |
triggers | list of {cron, repo, chain, title, description} | unset | Retired: schedules: in intake.yaml replaces it (see Inbound triggers). A file that still has it is read, so schedules keep firing, and kraft admin doctor names the move. |
wait_timeout_minutes | integer | unset | Retired: use total_time_cap_minutes, or maxima.tasks.total_time_cap_minutes. Read with a log warning. In defaults it doesn't load. A chain or override save that sets it is refused, with the name to use. |
defaults | mapping | unset | Starting points that any scope may move within maxima. See defaults and maxima. |
maxima | mapping | unset | Unset: no bound. The ceiling on policy overrides. See defaults and maxima. |
A budget cap refuses to start the next agent task and can't interrupt one that is running. See Caps and budgets.
Storage keys
Added in 2.1
storage.worktrees bounds the disk the worktrees use:
storage:
worktrees:
limit: 10G
quota: 8G
auto_cleanup: # optional; the block being there turns it on
min_age: 24h
- A size is a whole number and a unit,
K,M,GorT, in either case, and binary:1Gis 1024³ bytes. A bare number such as10is refused, because it would be a 10-byte limit. - Without
limitnothing is measured, warned about or held.quotawithout alimit, or at or above it, is invalid. - Kraft counts what a worker can write, under
run/:worktrees/,sandbox-git/, each item's sandbox home (items/<id>/sandbox-home/, or an older item'ssandbox-home/<id>/), each item'sdocs/and its sessions'out/folders, and each item's step outputs (outputs/). Archiving removes the worktree, the sandbox home and the step outputs; abandoning removes the rest. Session logs, earlier versions of a document, attachment copies, the databases and Docker's images and volumes aren't counted. - The figure is measured at startup and every 10 minutes, and matches
du. An archive or abandon takes that item's size off it at once, and a start that creates a worktree adds an estimate (the mean size of the items measured) at once, until the next measurement replaces it. - At or under
quota, nothing happens. Overquota,/api/healthandkraft admin doctorwarn. - Over
limit, a start that would create a new worktree is queued until usage is back under the limit, and its item gets awork_item_storage_heldevent. A resume or retry of an item that already has a worktree isn't held. - The limit holds starts only for what archiving can free: everything counted but the items'
docs/andout/folders. Those count towardquotaand show on the Storage page, but archiving keeps them, so on their own they never hold a start. Step outputs are freed by archiving, so they count toward the limit. - Unless
auto_cleanupis set, Kraft never archives or deletes anything for the limit, step outputs included. With it, they go only with an item it archives, and an in-place item has no worktree to archive that way, so a manual archive is what frees its step outputs.archive.after_daysworks as before. See Limit the disk worktrees use. auto_cleanupturns on automatic clean-up.auto_cleanup: {}ismin_age: 24h, andauto_cleanup:with nothing after it is off. It needs alimit.min_ageis a whole number andhord, in either case:12h,24h,2d. Days are the largest unit, so1wis refused, and so is a bare24.0hmeans no floor.- When starts are held, Kraft archives completed and abandoned items that have a worktree and ended at least
min_ageago, oldest first, until what archiving can free is at or underquota. One archive runs at a time, and one item's failure is logged and skipped. - Archiving removes the worktree and any uncommitted changes in it. A branch with unpushed commits is kept, and the item stays restorable under Archived. Its
work_item_archivedevent carriesby: autoandreason: storage. - When that can't free enough, because every finished item is newer than
min_ageor the rest is live work, starts stay held andkraft admin doctorsays how many finished items were too recent. - A running item can pass the limit between two measurements. The limit stops the next start, not work in flight.
- An in-place item has no worktree. It is never measured, never held and never picked by
auto_cleanup.
kraft admin reload applies a change.
Step output keys
Added in 2.6
storage.outputs.max_size bounds what Kraft keeps of one task's step outputs:
storage:
outputs:
max_size: 64M
- It is a size, written as for
storage.worktrees, and is at most256M, the most one remote machine returns. A larger value is refused when the file loads. - The total apparent size of the files in the task's output folder is checked when the task ends. Over the limit, the task fails and nothing is kept.
- The limit bounds what is kept, not peak use. While a task runs it can write as much as its disk holds, as it can into its worktree,
docs/orout/. - Kraft reads the limit when it launches the task and records it with the session, so a task that ends after a restart is held to the number it started under.
- A change reaches tasks launched after
kraft admin reload.
Loop keys
loops maps a loop key to its own attempts and wall_clock_s. A key that names no live loop is silently unused, so spell it exactly:
| Key | Names |
|---|---|
<node id>.fix_loop | The fix loop of that exec node; see Fix loop. |
<node id>.on_base_changed | The restarts of that node when a rebase moves the base. |
<node id>.on_merge_rejected | The rewinds of that node when a merge train or merge queue drops the merge request. Unset, it is 3 attempts over 7 days, not default. See on_merge_rejected. Added in 2.3 |
<gate id>_reject_loop | The rejections of that gate. |
loops:
verification.fix_loop: { attempts: 5, wall_clock_s: 7200 }
The default caps
These are the caps the shipped chains and library set. The loop default and the two dollar caps are in Top-level keys; the per-level defaults and maxima ship unset and are below.
| Bound | Shipped value | Where it is set |
|---|---|---|
| Fix-loop attempts | 2 for verification, 3 for merge_request_feedback | max_attempts on the loop, in the chain |
implementer task running time | 120 minutes | time_cap_minutes on the task, in library.yaml |
| Wait for CI | 90 minutes | total_time_cap_minutes on the wait task, in library.yaml |
| Wait for the automated review | 30 minutes | the same key |
| Wait for an external approval | 10080 minutes (7 days) | the same key |
| Wait for the post-merge pipeline | 90 minutes | the same key |
Whichever bound runs out first stops the item, and the stop names its scope.
The shipped implementer cap
The implementer task, which both shipped chains run, sets time_cap_minutes: 120. Successful runs finish well inside it, so it binds only a run that has gone wrong, for example a worker stuck on a test run it backgrounded. A turn that ends with a background job still running fails the task: see Result file.
A long plan can need more. Raise the item's own cap, or set a larger one on the task in library.yaml. The task's 120 is above the commented tasks default of 90, which a scope may do. A maxima.tasks.time_cap_minutes (or a broader level's) below 120 makes Kraft refuse both shipped chains at intake, so lower the task's cap to fit.
defaults and maxima
Kraft ships these commented out, because an uncommented value is a real ceiling. This example is illustrative. Uncomment and edit it to use it:
# defaults:
# timeout_minutes: 60
# max_attempts: 3
# allowed_harnesses: [codex, claude]
# escalation_harness: claude
# work_item: { time_cap_minutes: 480, total_time_cap_minutes: 2880, budget_usd: 20 }
# nodes: { time_cap_minutes: 180 }
# steps: { time_cap_minutes: 120 }
# tasks: { time_cap_minutes: 90 }
# maxima:
# timeout_minutes: 180
# allowed_harnesses: [codex, claude]
# work_item: { time_cap_minutes: 1440, token_budget: 2000000, budget_usd: 25 }
# tasks: { time_cap_minutes: 240, total_time_cap_minutes: 10080 }
defaults takes timeout_minutes, max_attempts, allowed_harnesses, escalation_harness, escalation_grants and the per-level caps. maxima takes allowed_tools, allowed_harnesses, timeout_minutes, max_attempts and the per-level caps.
Two rules hold for both sections:
- A narrower level's cap may not exceed a broader one's (
tasks<=steps<=nodes<=work_item), and adefaultsentry may not exceed its level's maximum. Kraft refuses either when it reads the file, naming both. - A cap written flat (
defaults: time_cap_minutes: 30) is refused, with a message naming the level form to use.
| Field | Type | Default | Meaning |
|---|---|---|---|
timeout_minutes, max_attempts, allowed_harnesses | integer, integer, list of harness profile IDs | unset | Operational starting points that any layer may move in either direction, bounded only by maxima. |
escalation_harness | string | claude | The harness profile in harnesses.yaml that an escalation turn runs on, or item. In defaults only: a maxima that names it doesn't load, and Kraft refuses new work. |
escalation_grants | list | [git-commit, git-rebase, git-push] | The grants every escalation turn holds; [] is none. In defaults only, like escalation_harness. |
work_item, nodes, steps, tasks | mapping: time_cap_minutes, total_time_cap_minutes, token_budget, budget_usd | unset | No bound when unset. Per-level values for time_cap_minutes, total_time_cap_minutes, token_budget and budget_usd; a gate is a node. |
maxima.allowed_tools | list of tool names | unset | No bound when unset. A safety field that starts at its maximum and can only be narrowed. |
maxima.allowed_tools unless every harness you use can run under it. A safety field set only in maxima binds every task. See Tool lists for the harnesses that refuse a list.Policy fields
These keys go in a policy: block on a repo (repos.yaml), a chain, a node, a step, a task or a work item's override. Kraft applies the layers from the broadest to the narrowest. The "Rule down the layers" column says how a layer may change what it inherits: the safety fields only narrow, and the operational ones move either way within maxima. Kraft refuses a layer that breaks its row's rule, and names the scope.
| Field | Type | Rule down the layers | Meaning |
|---|---|---|---|
allowed_tools | list | Only narrows. | Tool names the agent may use; the permission gate answers from it. Unset allows every tool, and [] allows none. See Tool lists. |
deny_tools | list | Only accumulates. | Tool names the permission gate denies, on top of allowed_tools. |
grants | list | Only accumulates; an item override can drop one, never add one. | Named git operations a task is guaranteed: git-commit, git-rebase, git-push. See Grants. |
sandbox | mapping | Set once, never changed or removed, its resources included. | Runs every process of the whole work item in docker run, within its resource limits. Two scopes with different sandboxes are refused. See Sandboxed workers. |
token_budget | integer | Within its level's maxima; a child's never above its parent's. | Tokens (input plus output) the scope's launches may spend before the next launch is refused. |
budget_usd | number | As token_budget. | The same cap in dollars, under budget.work_item_usd and budget.daily_usd. |
allowed_harnesses | list | Within maxima. | Harness profiles an agent task may select; Kraft refuses others at intake and again at launch. |
escalation_harness | string | Any value, execution node or broader. | The harness profile an escalation turn runs on; a name harnesses.yaml doesn't define is refused. |
max_attempts, timeout_minutes | integer | Within maxima; execution node or broader. | Bound the node's fix loop; a step, task or gate refuses them. |
time_cap_minutes | integer | As token_budget. | Running time of the scope; a launch past it is refused and a running process is killed at it. |
total_time_cap_minutes | integer | As time_cap_minutes. | Wall-clock time of the scope, including waits and gates, less only a manual pause. For a wait it is the wait's timeout. |
A launch into a sandbox with neither network: nor unrestricted_network: true is refused. Which tool policies a sandbox refuses depends on its network:; see Tool policy.
How the layers combine
A work item freezes its policy when you file it. Kraft layers it from the broadest source to the narrowest:
defaultsandmaximainpolicy.yaml.- The repository's
policy:inrepos.yaml. - The chain's
policy:. - Each node's, step's and task's own
policy:. - Your item's own override, from
kraft item create --policyorkraft item set-policy.
At intake Kraft refuses a layer that relaxes what it inherits, and names the scope, so a bad policy fails when you file the item and not hours into a run. The chain narrowing the same field first never causes a refusal.
Your override is the one layer that can change after filing. On a running or waiting item a change takes effect from the next node entered and the next check of a wait.
A recovery plan inherits the task, step or node that declares it. A fix loop, its judge, a node's escalation task and its conflict handler inherit their node. A gate's auto_review inherits its gate.
What a cap stop says
A time cap stops the item with the reason "<scope> hit its time cap of N minutes". It reads "total time cap" for total_time_cap_minutes, and the scope reads "the work item" for the item itself. A gate's own timeout stops the item the same way, naming the gate, and the gate stays open for you to approve or reject. For the fix per reason, see Caps, budgets and waits.
Tool lists
allowed_tools and deny_tools hold tool names, never permission rules. Use a bare tool (Bash, Read) or one exact MCP tool (mcp__kraft__report_progress). Kraft refuses a scoped rule (Bash(git *)), a glob (mcp__github__*) or a whole server (mcp__github) wherever the list is read, and the message names the field and the name to write instead.
What a harness does under an allowed_tools list:
| Harness | Under a list |
|---|---|
gemini, antigravity | Refuses to launch, because it has no tool-list capability. |
codex | Enforces the list through Kraft's permission hook, but its web tools never reach the hook, so a list that leaves out WebSearch is refused. |
cursor | Enforces the list through the hook, but its web tools never reach it, so a list that leaves out WebFetch and WebSearch is refused. |
Allowing Bash allows its read-only use without a gate ask. Claude runs a read-only shell command (cat, ls, git status) itself, so it can read any file the worktree holds, gitignored ones included.
Related
- Caps and budgets: how caps, maxima and layers combine.
- Permission gate: how tool lists and grants are enforced.
- Chain file keys: where a chain, node, step or task sets its own
policy:.