Approvals & safety
From ask to card
Section titled “From ask to card”When an engine wants to do something your permission mode does not cover, it raises an ask and blocks. Ka’s asks have no timeout: an unanswered ask would wedge the session forever. ka agent owns expiry instead:
- Every ask becomes an approval card with an id, the exact subject, and a TTL (
approval_ttl_secs, default 900s). - On Telegram the card renders as a message with Allow / Deny inline buttons; on Matrix as text commands plus a ✅/❌ reaction on the card message; on Slack and Discord as native buttons; in the terminal as a card the one-letter answers settle (
yallows,ndenies,sallows for the session); on the web control panel as the approvals inbox. Every surface calls the same runtime decision path, so an ask appears in each, and none can settle an ask the engine no longer holds. Cards route by policy (D9, see roles): a self-scope ask (inside the acting user’s own grants and remaining quota, noescalatehit) delivers to that user’s surfaces and their/y//nsettle it; shared-resource, over-quota andescalateasks go to the admin queue, where a foreign decision is refused and audited and the escalation reason is on the card. - Every approved intent re-resolves the actor at execute time: a user disabled since the approval, a removed role or a withdrawn grant denies it, notifies the admin, and writes an
approval.staleaudit row, so a stale card can never execute. - If the TTL lapses with no decision, ka agent answers deny, records the expiry in the audit log, and the turn continues.
Fail closed is the rule: silence can never authorize. abort during an ask is always allowed and cancels the cycle.
Fewer, better prompts
Section titled “Fewer, better prompts”Approval fatigue is a security bug, not just friction. Two opt-in reductions, both scoped:
approvals.auto_review = truemaps to the engine’s auto-review: a fast model may auto-allow unmistakably safe exec calls, never deny.- “Allow for this session” exists on the local surfaces only, never from a phone:
y-style session answers in the terminal (y <id> session, orson the card) and the equivalent on the web. Scoped to one tool with exact arguments, and cleared on/new. A different argument still asks.
Durable allow-rules
Section titled “Durable allow-rules”A repeat ask can become a rule instead of a ritual. /y <id> always (terminal and web only; a phone is refused, exactly like session) settles the card Allow and persists a rule: the absence of a future card for matching asks, never a grant. The engine’s permission gate, path grants and role ceilings all still apply upstream of it.
- Shapes, narrowest first.
command: a provably plain bash prefix (cargo testalso answerscargo test --color never; nevercargo test && …).call_key: the byte-identical bash command (the landing shape for compound commands, because the engine decorates permission questions with volatile context).tool: one tool hand name, and atoolrule can never match a bash ask.ask_key: the exact question and detail pair, when nothing narrower is derivable. A compound command can therefore only ever landcall_key: there is no path from one compound approval to “always allow bash”. - Fail-closed creation. Every shape must pass validation and its own tested cases before anything is stored; a failing rule is refused with nothing written.
- Ordering and scope. Rules are consulted after D9 routing, and only for non-escalated self-scope asks: exactly the asks the acting user decides themselves. Escalated, shared-resource and over-quota asks never see a rule; orphan asks keep their deny.
- Mode scope. A rule fires in its creation mode and more permissive ones only: an
ask-born rule is silent inreadonlyand fires inaccept_edits. Role ceilings compose through the session’s effective mode, so a rule can never lift a member above their role. - Surfaces and audit.
/rules [rm <id>]lists and removes (the admin sees and removes all; a member only their own); the terminal’s bareaon an armed card is the/y <id> alwaysshortcut;ka-agent grant rule check '<command>'dry-runs a command against the operator’s rules and grants nothing. Audit rows:rule.add,rule.rm, and each settle asapproval.decidelabeledAllow (rule <id>).
Every allow-class settle (operator /y, a session allow, a rule) routes through one runtime path that also takes the checkpoint snapshot before the engine hears Allow, so the safety net has no gaps in it.
Grants: reach without cards
Section titled “Grants: reach without cards”Out of the box the engine works inside its workspace behind cards (ask); /mode allow drops the cards for the session, and under allow ka agent composes no OS sandbox at all (the pinned engine would otherwise still ask for sandbox grants outside the workspace, so nothing is jailed and nothing asks). Wider or narrower reach is a [grants] block in ka-agent.toml:
[grants]install = true # sudo apt / npm -g / pip / cargo / go installs run unasked
[[grants.path]]dir = "/srv/data" # absoluteaccess = "allow" # allow | ask | denyOr from the shell: ka-agent grant path add /srv/data --access allow|ask|deny writes the same rows format-preserving and applies live; grant path list shows them.
Three levers, enforced between the engine layer and the __guard hook:
- Path grants.
allowdirs are writable without asking (they join the sandbox allowlist, and__guardpre-approves writes inside them);askis the engine’s normal flow;denydirs are blocked in every mode, for bash and the file tools. Any number of granted dirs behaves identically. - The install gate.
grants.install = false(the default) denies install-class commands, with the error naming the key to set;truepre-approves them. - Full access.
grants.full = trueturns the sandbox off, grants installs, ignores deny paths and pre-approves bash and file writes;/statusshows⚠ full accessanddoctorwarns untilgrants.advisory = falsesilences the reminder.
Two invariants hold everywhere. Self-protection: ka agent’s own files (the enumerated config, store, secrets and memory always; the whole data root minus the workspace and attachments/ plus the binary once no operator gate remains, i.e. allow mode or full) are denied for bash and the file tools in every mode. And an operator’s engine-layer deny rule outranks every grant: a pre-approve may only downgrade an ask, never bypass a deny. The engine’s own catastrophic hardstops (fork bomb, rm -rf /, raw devices, curl | sh) still ask under every setting.
These operator grants are separate from the scope-string grants that gate connector tools; see connectors & grants. The full key reference is in configuration.
The approval profile
Section titled “The approval profile”Every built-in tool carries an effect class, and the profile decides what skips the card:
| Effect | Tools | In ask mode |
|---|---|---|
| Read | notes_search, notes_read, history_search, history_show, http_get, calendar_events, cron_list |
auto-allowed (grants still gate http_get) |
| Propose | memory_propose, skill_propose |
auto-allowed: nothing lands until you accept |
| LocalWrite | notes_append, remind, send_file |
auto-allowed: writes inside ka agent’s own data root, or a file to you |
| Schedule | cron_manage |
asks |
| Spawn | scout |
asks, and is never in the auto-allow profile: starting a child spends a model turn and a worker slot. The child’s own asks are denied fail-closed (see scout) |
| ExternalWrite | github_issue_comment, github_pull_review |
asks, and logs an intent first |
External MCP servers and plugins keep asking per call unless a rule says otherwise.
What is never offered
Section titled “What is never offered”- “Always allow” from a phone. Durable always lives in ka agent’s own rules layer (
/y <id> always, above), where you can list and revoke it; the engine’s own coarse per-tool always, which would write the project.ka/ka.toml, is never sent at all: every settle answers plain Allow, so no engine-side always file can appear. Phone surfaces settle one card at a time and tighten modes; durable decisions are terminal and web. - Local-only commands from channels.
shell,set_feature,set_sandbox,save_api_key,save_settingscannot be reached from a channel at all; the port has no operation that maps to them.
The engine also carries a self-protection guard (ka-agent __guard, wired as its pre-tool-use hook for bash, write, edit, read and grep): every write is normalized (~, ., .., symlinks resolved) and refused when it lands inside ka agent’s own data root, config or secrets, and bash commands are scanned against the same rules, so the assistant cannot edit the policy that bounds it. The guard is also where [grants] decisions are enforced (see above).
The audit chain
Section titled “The audit chain”Every decision (allow, deny, expiry) and every notable event lands in an append-only audit chain in the state store. Unauthorized channel traffic is audited too, and gets no reply. External writes through connector tools additionally leave intent rows (tool, status, timestamps), surfaced on the web UI’s intents page; see connectors & grants.
Budgets
Section titled “Budgets”Two daily caps, configured in ka-agent.toml:
[budgets]daily_usd = 5.0 # ka usage accounting, enforced via the engine spend guarddaily_tokens = 2_000_000 # the only cap that binds for unpriced modelsSpend is reported per turn (the console prints turn done · $0.0137 · 6,205 tokens), and the spend guard raises an ask that becomes an approval card like any other.
Kill semantics
Section titled “Kill semantics”/stop aborts the running cycle and waits the grace period (default 10s). If the worker does not settle, ka agent SIGTERMs the worker’s process group (so tool children die too; the engine layer forces bash jobs to never detach), then SIGKILLs after a further 5s. The turn is marked aborted or killed, and never replayed automatically.