approval-gate
v1.1.2Policy and decision surface for human-held function calls — pre_call gate, pending inbox, per-session permission settings, and two notification event functions.
Install
iii call compose::add worker=approval-gate@1.1.2Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.
Full markdown
/registry/workers/approval-gate.md?version=1.1.2. Paste it into an LLM prompt or pipe it through curl from a worker.Install
iii call compose::add worker=approval-gate@1.1.2Dependencies
Readme
approval-gate
The policy and decision surface for human-held function calls (spec). Four surfaces, one worker:
- The gate —
approval::gate, apre_callhook. At startup the worker observes the harness'sharness::hook::on-pre-callwith it. It evaluates per-session mode, allow-lists, and inline configrules, and answerscontinue,deny, orhold. - The filesystem-access watch —
approval::filesystem-access-watch, apost_callhook: the worker observesharness::hook::on-post-callwith it forshell::*/coder::*. It watches for a jail-scopefilesystem_access_requeston a dispatch failure and converts it into afilesystem_accesshold, so the raw rejection does not reach the model. See Folder-access grant watch below. - The decision plane —
approval::resolveplus the per-session settings RPCs (set_mode,add_always_allow,approve_always, …). Human/console only. - The pending inbox — an ephemeral index of held calls
(
approval::list-pending/approval::get-pending) plus two event functions (approval::on-pending-created/approval::on-pending-resolved) that notification workers and UIs observe.PendingApprovalRecord.kind("function"|"filesystem_access") tells a console which prompt to render.
The worker keeps no resolved-approval history: a record exists only while
a call is held; every record has an explicit deletion path (resolve, turn
abort, session delete). The transcript's function_result and the calls of
approval::on-pending-resolved are the audit trail. Holds do not expire:
they wait until a human resolves or the turn/session is purged.
Standalone caveat
This worker codes against the harness contracts
(harness::hook::on-pre-call, harness::hook::on-post-call,
harness::function::resolve, harness::on-turn-completed,
harness::filesystem::grant/grants — see harness.md § Hooks / § API
Reference) and session-manager's session::on-deleted. Its observers of the
harness and session-manager functions stay pending while a sibling is not
running and become active when the sibling registers its function, so start
order does not matter: the worker boots and serves its RPCs either way.
Lacking harness::filesystem::grant/grants specifically degrades
approval::filesystem-access-watch alone (see
Folder-access grant watch) — it never holds,
the rest of the worker is unaffected. The configuration worker is the one
hard dependency — it is enabled by default in the engine, and a failed
register/fetch aborts boot. The integration suite exercises the harness
surface against in-process fakes and, when the harness binary is available,
the real harness worker.
Install
iii call compose::add worker=approval-gateQuickstart
cargo build
./target/debug/approval-gate --url ws://127.0.0.1:49134The authoritative config lives in the engine's configuration worker (no
committed config.yaml); pass --config <file>.yaml only to seed the entry on
its very first registration.
Hold → decide → release, from any client:
# A held call shows up in the inbox…
iii call approval::list-pending
# …a human allows it (the harness runs the released call)…
iii call approval::resolve session_id=s_1 function_call_id=c_1 decision=allow
# …or denies it with a reason the model can adapt to.
iii call approval::resolve session_id=s_1 function_call_id=c_1 decision=deny reason="not on prod"Permission model
Per-session mode plus two allow-lists, evaluated in this order (ported unchanged from the proven implementation):
approval::*/configuration::*target → deny (human_only_function, even underfull— self-escalation defense)- mode
full→ allow approved_alwayshit → allow (every mode — remembered human decisions)- mode
autoandalways_allowhit → allow (dormant undermanual) - fall through to configuration
rules(first match wins):allow→ allow ·deny→ deny · no match → hold
When the configuration entry omits rules, the gate denies only this
worker's own approval::* surface; every other call holds. On startup the
worker seeds/backfills the stored entry so rules are editable in the console.
Event functions
Both are private functions: only this worker calls them, anyone may observe
them, and each handler returns the event it is called with. Neither takes
args; observers select events with filters on the event's fields. The worker
calls each function only while something observes it. iii delivers each call
to every observer whose filters match: fire-and-forget, at-most-once (drops
are counted per function and reason) and unordered. Reconcile with one
approval::list-pending call after a restart or a gap.
| Function | Args | Called when | Event (input and output) |
|---|---|---|---|
approval::on-pending-created |
none; filter on input.session_id, input.session_metadata.<key> |
a call was held and its inbox record written (async, off the hook's hot path) | PendingApprovalRecord & { status: "pending" } — redacted args, session context: self-sufficient for notification copy |
approval::on-pending-resolved |
none; filter on input.session_id, input.session_metadata.<key> |
a pending call left the inbox (exactly once per record) | PendingResolvedEvent { session_id, turn_id, function_call_id, function_id, outcome: "allow" | "deny" | "aborted", reason?, session_metadata?, resolved_at } — reason is the operator's, on deny |
A multi-tenant notification worker observes only its own sessions by
filtering on the record's denormalized session_metadata, and reads the
event from the envelope's output with capture: ['output']:
iii.observe(
{
function_id: 'approval::on-pending-created',
filters: { 'input.session_metadata.owner': { $eq: 'u_1' } },
capture: ['output'], // the target reads the event as payload.output
},
'notify::approval-requested',
)iii.observe(
Source::function("approval::on-pending-resolved")
.filters(json!({ "input.session_id": { "$eq": session_id } }))
.capture([Capture::Output]),
"notify::approval-cleared",
);The worker calls each function only while something observes it.
Folder-access grant watch
When a shell::* / coder::* call fails with a jail-scope error (S215,
S220, C215, C220) whose message carries a filesystem_access_request=<json> tail,
approval::filesystem-access-watch (a post_call hook, observed with
on_error: "fail_open" so a crashed/absent watch never turns an
already-decided result into a stuck call) converts the failure into a
kind: "filesystem_access" pending record instead of letting the raw denial
reach the model. The record's
access_request: { requested_root, attempted_path, error_code } is what the console
shows: "allow access to requested_root?".
Before holding, the watch stands down (delivers the original error, no prompt) whenever:
- the offending dir is the session's own workspace (
metadata.working_dir) or under it — that is a harness stamp hole, not something a grant fixes; - the harness already reports a durable grant covering the dir
(
harness::filesystem::grants) — shell rejecting anyway is a store/stamp skew, not something a re-ask resolves; - the user already denied this dir earlier in the session
(
approval_filesystem_access_denied/<session_id>); - the call has already been re-asked
grant_reask_limittimes (default3, configurable — see below); - the harness doesn't implement the workspace-grant control plane at all
(
harness::filesystem::grantsfails) — the watch stands down entirely rather than looping.
Resolving a filesystem_access record's allow decision takes an additional
grant_scope (once | session | always, default once):
| Scope | Effect |
|---|---|
once |
The release carries extra_roots: [dir] — trusted for just this one call. |
session |
harness::filesystem::grant first (durable for the rest of the session), THEN release with no extra_roots — the harness stamps the grant on every subsequent call itself. Falls back to once-style extra_roots if the grant call fails, so the user's click still works. |
always |
Same as session, PLUS a best-effort append of dir to the shell deployment configuration's fs.host_roots (configuration::get/configuration::set {id: "shell"}). A persist failure is logged and never blocks the release. |
deny records the dir in approval_filesystem_access_denied/<session_id> (so the same
session won't be re-asked about it again) before delivering a denial whose
default reason mentions folder access specifically ("user denied folder access to <dir>" unless the operator supplies their own).
Degraded modes — the watch is entirely additive and fails toward "do nothing, deliver the original error":
- No shell
filesystem_access_requestsupport (older shell/coder): the ladder never finds a hint, sofilesystem-access-watchnever holds — behaves as if it did not observe the hook at all. - No harness workspace-grant control plane (older harness): the "already granted?" check fails, so every candidate stands down — no holds, no prompts, just the original error.
- Harness/console down when the hook fires:
on_error: "fail_open"delivers the original error unchanged; nothing is stuck.
Configuration
The whole config — runtime wiring and deployment approval defaults — lives
in the single engine configuration entry approval-gate (operator-edited
through its explicit form in the Console's global Settings modal; reactive reload, no polling). There is
no committed config.yaml. On first boot the worker seeds the entry with
the built-in defaults (including rules) so the editor is pre-filled; existing
stored values are never overwritten except to add a missing rules field.
{
"default_mode": "manual", // manual | auto | full — sessions with no stored settings
"rules": [ // first match wins; no match → hold
"!approval::*",
{ "function": "state::get", "action": "allow", "modes": ["auto"] }
],
"grant_reask_limit": 3 // approval::filesystem-access-watch re-asks per held call before standing down
}configuration is a required boot dependency: the worker registers the
schema and fetches the authoritative value at startup, and a failed
register/fetch aborts boot (the gate must run on a known, authoritative policy
surface, never a guessed one). When no value is stored yet the built-in
defaults above are seeded and used. Every field hot-reloads on
configuration::set — nothing requires a restart.
Agent exposure
Deny all approval::* and configuration::* functions to in-run agents:
resolve would let an agent approve its own held calls, and the settings
RPCs are self-escalation (the gate's human_only_function rule is the
in-depth backstop). list_pending / get_pending are read-only and
redacted, but they enumerate held calls across sessions — keep them off
agent allow-lists too.
Local development & testing
cargo test # lib suites: pure unit + engine-backed handlers
cargo test --test integration # engine-backed; self-skips without the engine and state binaries
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
./target/debug/approval-gate --manifest # registry-publish manifestThe engine-backed suites spawn a real engine (III_ENGINE_BIN or iii on
PATH) with its configuration worker, run this repo's standalone state
worker beside it (III_STATE_BIN, built with cargo build in state/),
register the production surface in-process, and fake sibling RPCs where noted
(session::get). With CARGO_BIN_EXE_harness pointing at a built harness
binary, tests/harness_integration.rs additionally boots the real harness
worker for cross-worker hold / sweep / resolve checks.
III_ENGINE_BIN=$(command -v iii) III_STATE_BIN=../state/target/debug/state cargo testArchitecture documentation
Deep documentation lives in architecture/: internals.md for maintainers (evaluation order, the emit-gate deletion mechanics, lazy seeding, engine facts the code depends on) and integration.md for consumers (the full function and event contract, the harness handoff, deployment notes, what not to do).
API reference (JSON)
{
"functions": [
{
"description": "Returns this approval-gate instance's configuration entry ID, without its value.",
"metadata": {
"internal": true
},
"name": "approval-gate::configuration-id",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ConfigurationIdentityRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"id": {
"type": "string"
}
},
"required": [
"id"
],
"title": "ConfigurationIdentityResponse",
"type": "object"
}
},
{
"description": "Add a function to the session's auto-mode trust list (idempotent). Human/console-only.",
"metadata": {},
"name": "approval::add-always-allow",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"function_id": {
"type": "string"
},
"session_id": {
"type": "string"
}
},
"required": [
"function_id",
"session_id"
],
"title": "AlwaysAllowMutationRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AlwaysAllowEntry": {
"properties": {
"function_id": {
"type": "string"
},
"granted_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"granted_by": {
"$ref": "#/definitions/GrantedBy"
}
},
"required": [
"function_id",
"granted_at",
"granted_by"
],
"type": "object"
},
"ApprovalSettings": {
"description": "The stored per-session record (scope `approval_settings`). Reads compute the effective settings from configuration defaults when no record exists — see settings.rs.",
"properties": {
"always_allow": {
"default": [],
"description": "Consulted only in auto mode.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"approved_always": {
"default": [],
"description": "Consulted in every mode — remembered human decisions.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"mode": {
"allOf": [
{
"$ref": "#/definitions/PermissionMode"
}
],
"default": "manual"
},
"mode_set_at": {
"default": 0,
"description": "ms epoch",
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"GrantedBy": {
"oneOf": [
{
"enum": [
"user_click"
],
"type": "string"
},
{
"description": "Copied from deployment auto-scoped allow rules on first mutation.",
"enum": [
"seed"
],
"type": "string"
}
]
},
"PermissionMode": {
"enum": [
"manual",
"auto",
"full"
],
"type": "string"
}
},
"description": "Shared by every settings mutation RPC: the post-mutation record.",
"properties": {
"settings": {
"$ref": "#/definitions/ApprovalSettings"
}
},
"required": [
"settings"
],
"title": "SettingsResponse",
"type": "object"
}
},
{
"description": "Record a per-session 'approve always' grant (honoured in every mode). Human/console-only.",
"metadata": {},
"name": "approval::approve-always",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"function_id": {
"type": "string"
},
"session_id": {
"type": "string"
}
},
"required": [
"function_id",
"session_id"
],
"title": "ApproveAlwaysRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AlwaysAllowEntry": {
"properties": {
"function_id": {
"type": "string"
},
"granted_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"granted_by": {
"$ref": "#/definitions/GrantedBy"
}
},
"required": [
"function_id",
"granted_at",
"granted_by"
],
"type": "object"
},
"ApprovalSettings": {
"description": "The stored per-session record (scope `approval_settings`). Reads compute the effective settings from configuration defaults when no record exists — see settings.rs.",
"properties": {
"always_allow": {
"default": [],
"description": "Consulted only in auto mode.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"approved_always": {
"default": [],
"description": "Consulted in every mode — remembered human decisions.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"mode": {
"allOf": [
{
"$ref": "#/definitions/PermissionMode"
}
],
"default": "manual"
},
"mode_set_at": {
"default": 0,
"description": "ms epoch",
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"GrantedBy": {
"oneOf": [
{
"enum": [
"user_click"
],
"type": "string"
},
{
"description": "Copied from deployment auto-scoped allow rules on first mutation.",
"enum": [
"seed"
],
"type": "string"
}
]
},
"PermissionMode": {
"enum": [
"manual",
"auto",
"full"
],
"type": "string"
}
},
"description": "Shared by every settings mutation RPC: the post-mutation record.",
"properties": {
"settings": {
"$ref": "#/definitions/ApprovalSettings"
}
},
"required": [
"settings"
],
"title": "SettingsResponse",
"type": "object"
}
},
{
"description": "Drop the session's stored settings record (revert to configuration defaults).",
"metadata": {},
"name": "approval::clear-settings",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"session_id": {
"type": "string"
}
},
"required": [
"session_id"
],
"title": "ClearSettingsRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"cleared": {
"type": "boolean"
}
},
"required": [
"cleared"
],
"title": "ClearSettingsResponse",
"type": "object"
}
},
{
"description": "Report what approval::gate WOULD decide for a function id (allow / deny / needs_approval) without deciding it: no pending record, no writes. Called by the harness before an agent observes a function with an ordinary function as the target, since an observer's target runs outside any turn and cannot ask a human.",
"metadata": {},
"name": "approval::evaluate",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"arguments": {
"default": null,
"description": "Call arguments, for deployments whose rules carry argument constraints. Defaults to `{}`."
},
"function_id": {
"description": "The function id to evaluate.",
"type": "string"
},
"session_id": {
"description": "Session whose effective settings apply (mode + always-allow list).",
"type": "string"
}
},
"required": [
"function_id",
"session_id"
],
"title": "EvaluateRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"EvaluateVerdict": {
"description": "What [`crate::functions::gate`] WOULD answer for this call.",
"oneOf": [
{
"description": "Dispatches with no human in the loop.",
"enum": [
"allow"
],
"type": "string"
},
{
"description": "Refused outright.",
"enum": [
"deny"
],
"type": "string"
},
{
"description": "Would hold for human approval — which an observer's target, running outside any turn, has no way to obtain.",
"enum": [
"needs_approval"
],
"type": "string"
}
]
}
},
"properties": {
"reason": {
"description": "Why, for the non-allow verdicts.",
"type": [
"string",
"null"
]
},
"verdict": {
"$ref": "#/definitions/EvaluateVerdict"
}
},
"required": [
"verdict"
],
"title": "EvaluateResponse",
"type": "object"
}
},
{
"description": "post_call hook (observer of harness::hook::on-post-call): watch shell::*/coder::* dispatch failures for a jail-scope filesystem_access_request and hold a filesystem_access pending approval for it. Called by the harness only.",
"metadata": {},
"name": "approval::filesystem-access-watch",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"HookCall": {
"properties": {
"arguments": {
"default": null
},
"function_id": {
"type": "string"
},
"id": {
"type": "string"
}
},
"required": [
"function_id",
"id"
],
"type": "object"
},
"HookResult": {
"description": "`post_call` payload: the function_result the harness is about to deliver to the model.",
"properties": {
"content": {
"default": [],
"items": {
"$ref": "#/definitions/TextBlock"
},
"type": "array"
},
"details": {
"$ref": "#/definitions/HookResultDetails"
},
"function_call_id": {
"default": "",
"type": "string"
},
"function_id": {
"default": "",
"type": "string"
},
"is_error": {
"default": false,
"type": "boolean"
}
},
"type": "object"
},
"HookResultDetails": {
"properties": {
"error": {
"anyOf": [
{
"$ref": "#/definitions/HookResultError"
},
{
"type": "null"
}
]
}
},
"type": "object"
},
"HookResultError": {
"description": "`result.details.error` on a dispatch failure. New harness versions fill `code`; older/plain remote errors can arrive without one, so consumers may recover it from the `filesystem_access_request` tail (contracts.md, the post-call hook's HOLD).",
"properties": {
"code": {
"default": null,
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
}
},
"required": [
"message"
],
"type": "object"
},
"TextBlock": {
"properties": {
"text": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"text",
"type"
],
"type": "object"
}
},
"properties": {
"call": {
"anyOf": [
{
"$ref": "#/definitions/HookCall"
},
{
"type": "null"
}
],
"description": "pre_call payload."
},
"depth": {
"default": 0,
"description": "Sub-agent depth (hooks run for child turns too).",
"format": "int64",
"type": "integer"
},
"metadata": {
"additionalProperties": true,
"default": null,
"description": "The per-send tracing metadata (`metadata.fs_scope.root` is the user-picked session workspace, absolute + canonical).",
"type": [
"object",
"null"
]
},
"point": {
"default": null,
"type": [
"string",
"null"
]
},
"result": {
"anyOf": [
{
"$ref": "#/definitions/HookResult"
},
{
"type": "null"
}
],
"description": "post_call payload: the function_result about to be delivered."
},
"session_id": {
"type": "string"
},
"step": {
"default": null,
"format": "int64",
"type": [
"integer",
"null"
]
},
"turn_id": {
"type": "string"
}
},
"required": [
"session_id",
"turn_id"
],
"title": "HookInput",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"oneOf": [
{
"properties": {
"decision": {
"enum": [
"continue"
],
"type": "string"
}
},
"required": [
"decision"
],
"type": "object"
},
{
"properties": {
"decision": {
"enum": [
"deny"
],
"type": "string"
},
"reason": {
"type": "string"
}
},
"required": [
"decision",
"reason"
],
"type": "object"
},
{
"properties": {
"decision": {
"enum": [
"hold"
],
"type": "string"
}
},
"required": [
"decision"
],
"type": "object"
}
],
"title": "HookOutput"
}
},
{
"description": "pre_call hook (observer of harness::hook::on-pre-call): evaluate the permission model and answer continue / deny / hold; writes the pending inbox record on hold. Called by the harness only.",
"metadata": {},
"name": "approval::gate",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"HookCall": {
"properties": {
"arguments": {
"default": null
},
"function_id": {
"type": "string"
},
"id": {
"type": "string"
}
},
"required": [
"function_id",
"id"
],
"type": "object"
},
"HookResult": {
"description": "`post_call` payload: the function_result the harness is about to deliver to the model.",
"properties": {
"content": {
"default": [],
"items": {
"$ref": "#/definitions/TextBlock"
},
"type": "array"
},
"details": {
"$ref": "#/definitions/HookResultDetails"
},
"function_call_id": {
"default": "",
"type": "string"
},
"function_id": {
"default": "",
"type": "string"
},
"is_error": {
"default": false,
"type": "boolean"
}
},
"type": "object"
},
"HookResultDetails": {
"properties": {
"error": {
"anyOf": [
{
"$ref": "#/definitions/HookResultError"
},
{
"type": "null"
}
]
}
},
"type": "object"
},
"HookResultError": {
"description": "`result.details.error` on a dispatch failure. New harness versions fill `code`; older/plain remote errors can arrive without one, so consumers may recover it from the `filesystem_access_request` tail (contracts.md, the post-call hook's HOLD).",
"properties": {
"code": {
"default": null,
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
}
},
"required": [
"message"
],
"type": "object"
},
"TextBlock": {
"properties": {
"text": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"text",
"type"
],
"type": "object"
}
},
"properties": {
"call": {
"anyOf": [
{
"$ref": "#/definitions/HookCall"
},
{
"type": "null"
}
],
"description": "pre_call payload."
},
"depth": {
"default": 0,
"description": "Sub-agent depth (hooks run for child turns too).",
"format": "int64",
"type": "integer"
},
"metadata": {
"additionalProperties": true,
"default": null,
"description": "The per-send tracing metadata (`metadata.fs_scope.root` is the user-picked session workspace, absolute + canonical).",
"type": [
"object",
"null"
]
},
"point": {
"default": null,
"type": [
"string",
"null"
]
},
"result": {
"anyOf": [
{
"$ref": "#/definitions/HookResult"
},
{
"type": "null"
}
],
"description": "post_call payload: the function_result about to be delivered."
},
"session_id": {
"type": "string"
},
"step": {
"default": null,
"format": "int64",
"type": [
"integer",
"null"
]
},
"turn_id": {
"type": "string"
}
},
"required": [
"session_id",
"turn_id"
],
"title": "HookInput",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"oneOf": [
{
"properties": {
"decision": {
"enum": [
"continue"
],
"type": "string"
}
},
"required": [
"decision"
],
"type": "object"
},
{
"properties": {
"decision": {
"enum": [
"deny"
],
"type": "string"
},
"reason": {
"type": "string"
}
},
"required": [
"decision",
"reason"
],
"type": "object"
},
{
"properties": {
"decision": {
"enum": [
"hold"
],
"type": "string"
}
},
"required": [
"decision"
],
"type": "object"
}
],
"title": "HookOutput"
}
},
{
"description": "Read one pending record; null when resolved or unknown.",
"metadata": {},
"name": "approval::get-pending",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"function_call_id": {
"description": "The function call id of the held call.",
"type": "string"
},
"session_id": {
"description": "The session the pending record belongs to.",
"type": "string"
}
},
"required": [
"function_call_id",
"session_id"
],
"title": "GetPendingRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/GetPendingResponse"
},
{
"type": "null"
}
],
"definitions": {
"AccessRequest": {
"description": "The filesystem access ask parsed from the shell/coder `filesystem_access_request` tail. Only present on `kind: \"filesystem_access\"` records.",
"properties": {
"attempted_path": {
"description": "The raw offending path from the request, as sent by the caller.",
"type": "string"
},
"error_code": {
"description": "The jail-scope rejection code that produced this hint (`S215`, `S220`, `C215`, `C220`).",
"type": "string"
},
"requested_root": {
"description": "Canonical root a grant should target (existing directory, or nearest existing ancestor directory of the offending path).",
"type": "string"
}
},
"required": [
"attempted_path",
"error_code",
"requested_root"
],
"type": "object"
},
"GetPendingResponse": {
"description": "`null` (handler returns `Option<GetPendingResponse>`) when resolved or unknown.",
"properties": {
"pending": {
"$ref": "#/definitions/PendingApprovalRecord"
}
},
"required": [
"pending"
],
"type": "object"
},
"PendingApprovalRecord": {
"description": "The inbox payload — shared by both event functions, `list_pending`, and `get_pending`. Self-describing (all ids inside the value) and notification-safe (arguments pass through redaction).",
"properties": {
"access_request": {
"anyOf": [
{
"$ref": "#/definitions/AccessRequest"
},
{
"type": "null"
}
],
"description": "Present only when `kind == \"filesystem_access\"`."
},
"arguments_excerpt": {
"default": null,
"description": "Redacted — safe to forward to notification channels."
},
"assistant_excerpt": {
"description": "First text block of the assistant message that contained this function_call. Best-effort; not derivable from the `pre_call` `HookInput` in v1, so always omitted today.",
"type": [
"string",
"null"
]
},
"depth": {
"default": 0,
"description": "Sub-agent depth (0 = top-level), from `HookInput`.",
"format": "int64",
"type": "integer"
},
"function_call_id": {
"type": "string"
},
"function_id": {
"type": "string"
},
"kind": {
"allOf": [
{
"$ref": "#/definitions/PendingKind"
}
],
"description": "`\"function\"` or `\"filesystem_access\"`."
},
"pending_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"session_description": {
"type": [
"string",
"null"
]
},
"session_id": {
"type": "string"
},
"session_metadata": {
"additionalProperties": true,
"description": "Tenancy + routing (what observers filter on as `input.session_metadata.<key>`).",
"type": [
"object",
"null"
]
},
"session_title": {
"type": [
"string",
"null"
]
},
"turn_id": {
"type": "string"
}
},
"required": [
"function_call_id",
"function_id",
"kind",
"pending_at",
"session_id",
"turn_id"
],
"type": "object"
},
"PendingKind": {
"description": "What a pending record represents.",
"oneOf": [
{
"description": "A function call held by `approval::gate` (the normal case).",
"enum": [
"function"
],
"type": "string"
},
{
"description": "A function call held by `approval::filesystem-access-watch` after a jail-scope rejection carrying a `filesystem_access_request` — the console should ask \"allow access to `requested_root`?\" instead of a generic approve/deny prompt.",
"enum": [
"filesystem_access"
],
"type": "string"
}
]
}
},
"title": "Nullable_GetPendingResponse"
}
},
{
"description": "Read the session's effective settings (stored record or configuration defaults); never writes.",
"metadata": {},
"name": "approval::get-settings",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"session_id": {
"type": "string"
}
},
"required": [
"session_id"
],
"title": "GetSettingsRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AlwaysAllowEntry": {
"properties": {
"function_id": {
"type": "string"
},
"granted_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"granted_by": {
"$ref": "#/definitions/GrantedBy"
}
},
"required": [
"function_id",
"granted_at",
"granted_by"
],
"type": "object"
},
"ApprovalSettings": {
"description": "The stored per-session record (scope `approval_settings`). Reads compute the effective settings from configuration defaults when no record exists — see settings.rs.",
"properties": {
"always_allow": {
"default": [],
"description": "Consulted only in auto mode.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"approved_always": {
"default": [],
"description": "Consulted in every mode — remembered human decisions.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"mode": {
"allOf": [
{
"$ref": "#/definitions/PermissionMode"
}
],
"default": "manual"
},
"mode_set_at": {
"default": 0,
"description": "ms epoch",
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"GrantedBy": {
"oneOf": [
{
"enum": [
"user_click"
],
"type": "string"
},
{
"description": "Copied from deployment auto-scoped allow rules on first mutation.",
"enum": [
"seed"
],
"type": "string"
}
]
},
"PermissionMode": {
"enum": [
"manual",
"auto",
"full"
],
"type": "string"
},
"SettingsSource": {
"enum": [
"stored",
"defaults"
],
"type": "string"
}
},
"properties": {
"settings": {
"$ref": "#/definitions/ApprovalSettings"
},
"source": {
"allOf": [
{
"$ref": "#/definitions/SettingsSource"
}
],
"description": "Whether a per-session record exists."
}
},
"required": [
"settings",
"source"
],
"title": "GetSettingsResponse",
"type": "object"
}
},
{
"description": "The pending inbox across sessions, with tenancy filters; the catch-up path for notification workers after a restart.",
"metadata": {},
"name": "approval::list-pending",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"cursor": {
"default": null,
"description": "Opaque.",
"type": [
"string",
"null"
]
},
"limit": {
"default": null,
"description": "Default 50.",
"format": "uint",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"metadata": {
"additionalProperties": true,
"default": null,
"description": "Equality match against `session_metadata` (tenancy).",
"type": [
"object",
"null"
]
},
"session_id": {
"default": null,
"type": [
"string",
"null"
]
}
},
"title": "ListPendingRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AccessRequest": {
"description": "The filesystem access ask parsed from the shell/coder `filesystem_access_request` tail. Only present on `kind: \"filesystem_access\"` records.",
"properties": {
"attempted_path": {
"description": "The raw offending path from the request, as sent by the caller.",
"type": "string"
},
"error_code": {
"description": "The jail-scope rejection code that produced this hint (`S215`, `S220`, `C215`, `C220`).",
"type": "string"
},
"requested_root": {
"description": "Canonical root a grant should target (existing directory, or nearest existing ancestor directory of the offending path).",
"type": "string"
}
},
"required": [
"attempted_path",
"error_code",
"requested_root"
],
"type": "object"
},
"PendingApprovalRecord": {
"description": "The inbox payload — shared by both event functions, `list_pending`, and `get_pending`. Self-describing (all ids inside the value) and notification-safe (arguments pass through redaction).",
"properties": {
"access_request": {
"anyOf": [
{
"$ref": "#/definitions/AccessRequest"
},
{
"type": "null"
}
],
"description": "Present only when `kind == \"filesystem_access\"`."
},
"arguments_excerpt": {
"default": null,
"description": "Redacted — safe to forward to notification channels."
},
"assistant_excerpt": {
"description": "First text block of the assistant message that contained this function_call. Best-effort; not derivable from the `pre_call` `HookInput` in v1, so always omitted today.",
"type": [
"string",
"null"
]
},
"depth": {
"default": 0,
"description": "Sub-agent depth (0 = top-level), from `HookInput`.",
"format": "int64",
"type": "integer"
},
"function_call_id": {
"type": "string"
},
"function_id": {
"type": "string"
},
"kind": {
"allOf": [
{
"$ref": "#/definitions/PendingKind"
}
],
"description": "`\"function\"` or `\"filesystem_access\"`."
},
"pending_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"session_description": {
"type": [
"string",
"null"
]
},
"session_id": {
"type": "string"
},
"session_metadata": {
"additionalProperties": true,
"description": "Tenancy + routing (what observers filter on as `input.session_metadata.<key>`).",
"type": [
"object",
"null"
]
},
"session_title": {
"type": [
"string",
"null"
]
},
"turn_id": {
"type": "string"
}
},
"required": [
"function_call_id",
"function_id",
"kind",
"pending_at",
"session_id",
"turn_id"
],
"type": "object"
},
"PendingKind": {
"description": "What a pending record represents.",
"oneOf": [
{
"description": "A function call held by `approval::gate` (the normal case).",
"enum": [
"function"
],
"type": "string"
},
{
"description": "A function call held by `approval::filesystem-access-watch` after a jail-scope rejection carrying a `filesystem_access_request` — the console should ask \"allow access to `requested_root`?\" instead of a generic approve/deny prompt.",
"enum": [
"filesystem_access"
],
"type": "string"
}
]
}
},
"properties": {
"next_cursor": {
"type": [
"string",
"null"
]
},
"pending": {
"description": "Ordered by pending_at ascending.",
"items": {
"$ref": "#/definitions/PendingApprovalRecord"
},
"type": "array"
}
},
"required": [
"pending"
],
"title": "ListPendingResponse",
"type": "object"
}
},
{
"description": "Internal: hot-reload approval-gate from the authoritative configuration when it changes — swaps the per-call snapshot (default_mode, rules, grant_reask_limit).",
"metadata": {
"internal": true
},
"name": "approval::on-config-change",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "The `configuration::on-updated` event, delivered as output to the internal `approval::on-config-change`. The handler re-fetches the authoritative configuration, so only the (advisory) configuration id is read; a struct (not `Value`) keeps the request schema concrete and unknown fields are ignored.",
"properties": {
"id": {
"default": null,
"description": "Configuration id that changed (advisory; the handler re-fetches the value).",
"type": [
"string",
"null"
]
}
},
"title": "OnConfigChangeEvent",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Ack returned by the internal `approval::on-config-change` handler.",
"properties": {
"ok": {
"type": "boolean"
}
},
"required": [
"ok"
],
"title": "OnConfigChangeResponse",
"type": "object"
}
},
{
"description": "Called when a function call was held for human approval and its inbox record written. Event: PendingApprovalRecord with status \"pending\" (redacted args, session context). No args; filter on input.session_id or input.session_metadata.<key>. Observe it from notification workers.",
"metadata": {},
"name": "approval::on-pending-created",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AccessRequest": {
"description": "The filesystem access ask parsed from the shell/coder `filesystem_access_request` tail. Only present on `kind: \"filesystem_access\"` records.",
"properties": {
"attempted_path": {
"description": "The raw offending path from the request, as sent by the caller.",
"type": "string"
},
"error_code": {
"description": "The jail-scope rejection code that produced this hint (`S215`, `S220`, `C215`, `C220`).",
"type": "string"
},
"requested_root": {
"description": "Canonical root a grant should target (existing directory, or nearest existing ancestor directory of the offending path).",
"type": "string"
}
},
"required": [
"attempted_path",
"error_code",
"requested_root"
],
"type": "object"
},
"PendingKind": {
"description": "What a pending record represents.",
"oneOf": [
{
"description": "A function call held by `approval::gate` (the normal case).",
"enum": [
"function"
],
"type": "string"
},
{
"description": "A function call held by `approval::filesystem-access-watch` after a jail-scope rejection carrying a `filesystem_access_request` — the console should ask \"allow access to `requested_root`?\" instead of a generic approve/deny prompt.",
"enum": [
"filesystem_access"
],
"type": "string"
}
]
},
"PendingStatus": {
"description": "A record in the inbox is pending until it is resolved.",
"enum": [
"pending"
],
"type": "string"
}
},
"description": "Event of `approval::on-pending-created` — the inbox record just written, with `status: \"pending\"`.",
"properties": {
"access_request": {
"anyOf": [
{
"$ref": "#/definitions/AccessRequest"
},
{
"type": "null"
}
],
"description": "Present only when `kind == \"filesystem_access\"`."
},
"arguments_excerpt": {
"default": null,
"description": "Redacted — safe to forward to notification channels."
},
"assistant_excerpt": {
"description": "First text block of the assistant message that contained this function_call. Best-effort; not derivable from the `pre_call` `HookInput` in v1, so always omitted today.",
"type": [
"string",
"null"
]
},
"depth": {
"default": 0,
"description": "Sub-agent depth (0 = top-level), from `HookInput`.",
"format": "int64",
"type": "integer"
},
"function_call_id": {
"type": "string"
},
"function_id": {
"type": "string"
},
"kind": {
"allOf": [
{
"$ref": "#/definitions/PendingKind"
}
],
"description": "`\"function\"` or `\"filesystem_access\"`."
},
"pending_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"session_description": {
"type": [
"string",
"null"
]
},
"session_id": {
"type": "string"
},
"session_metadata": {
"additionalProperties": true,
"description": "Tenancy + routing (what observers filter on as `input.session_metadata.<key>`).",
"type": [
"object",
"null"
]
},
"session_title": {
"type": [
"string",
"null"
]
},
"status": {
"$ref": "#/definitions/PendingStatus"
},
"turn_id": {
"type": "string"
}
},
"required": [
"function_call_id",
"function_id",
"kind",
"pending_at",
"session_id",
"status",
"turn_id"
],
"title": "PendingCreatedEvent",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AccessRequest": {
"description": "The filesystem access ask parsed from the shell/coder `filesystem_access_request` tail. Only present on `kind: \"filesystem_access\"` records.",
"properties": {
"attempted_path": {
"description": "The raw offending path from the request, as sent by the caller.",
"type": "string"
},
"error_code": {
"description": "The jail-scope rejection code that produced this hint (`S215`, `S220`, `C215`, `C220`).",
"type": "string"
},
"requested_root": {
"description": "Canonical root a grant should target (existing directory, or nearest existing ancestor directory of the offending path).",
"type": "string"
}
},
"required": [
"attempted_path",
"error_code",
"requested_root"
],
"type": "object"
},
"PendingKind": {
"description": "What a pending record represents.",
"oneOf": [
{
"description": "A function call held by `approval::gate` (the normal case).",
"enum": [
"function"
],
"type": "string"
},
{
"description": "A function call held by `approval::filesystem-access-watch` after a jail-scope rejection carrying a `filesystem_access_request` — the console should ask \"allow access to `requested_root`?\" instead of a generic approve/deny prompt.",
"enum": [
"filesystem_access"
],
"type": "string"
}
]
},
"PendingStatus": {
"description": "A record in the inbox is pending until it is resolved.",
"enum": [
"pending"
],
"type": "string"
}
},
"description": "Event of `approval::on-pending-created` — the inbox record just written, with `status: \"pending\"`.",
"properties": {
"access_request": {
"anyOf": [
{
"$ref": "#/definitions/AccessRequest"
},
{
"type": "null"
}
],
"description": "Present only when `kind == \"filesystem_access\"`."
},
"arguments_excerpt": {
"default": null,
"description": "Redacted — safe to forward to notification channels."
},
"assistant_excerpt": {
"description": "First text block of the assistant message that contained this function_call. Best-effort; not derivable from the `pre_call` `HookInput` in v1, so always omitted today.",
"type": [
"string",
"null"
]
},
"depth": {
"default": 0,
"description": "Sub-agent depth (0 = top-level), from `HookInput`.",
"format": "int64",
"type": "integer"
},
"function_call_id": {
"type": "string"
},
"function_id": {
"type": "string"
},
"kind": {
"allOf": [
{
"$ref": "#/definitions/PendingKind"
}
],
"description": "`\"function\"` or `\"filesystem_access\"`."
},
"pending_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"session_description": {
"type": [
"string",
"null"
]
},
"session_id": {
"type": "string"
},
"session_metadata": {
"additionalProperties": true,
"description": "Tenancy + routing (what observers filter on as `input.session_metadata.<key>`).",
"type": [
"object",
"null"
]
},
"session_title": {
"type": [
"string",
"null"
]
},
"status": {
"$ref": "#/definitions/PendingStatus"
},
"turn_id": {
"type": "string"
}
},
"required": [
"function_call_id",
"function_id",
"kind",
"pending_at",
"session_id",
"status",
"turn_id"
],
"title": "PendingCreatedEvent",
"type": "object"
}
},
{
"description": "Called when a pending approval left the inbox (outcome: allow | deny | aborted). Called exactly once per record; lets UIs clear badges. No args; filter on input.session_id or input.session_metadata.<key>.",
"metadata": {},
"name": "approval::on-pending-resolved",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ResolvedOutcome": {
"enum": [
"allow",
"deny",
"aborted"
],
"type": "string"
}
},
"description": "Event of `approval::on-pending-resolved` — a pending call left the inbox. Called exactly once per record (gated on the record delete).",
"properties": {
"function_call_id": {
"type": "string"
},
"function_id": {
"type": "string"
},
"outcome": {
"$ref": "#/definitions/ResolvedOutcome"
},
"reason": {
"description": "Operator-supplied on deny.",
"type": [
"string",
"null"
]
},
"resolved_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"session_id": {
"type": "string"
},
"session_metadata": {
"additionalProperties": true,
"description": "Tenancy routing, from the record.",
"type": [
"object",
"null"
]
},
"turn_id": {
"type": "string"
}
},
"required": [
"function_call_id",
"function_id",
"outcome",
"resolved_at",
"session_id",
"turn_id"
],
"title": "PendingResolvedEvent",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ResolvedOutcome": {
"enum": [
"allow",
"deny",
"aborted"
],
"type": "string"
}
},
"description": "Event of `approval::on-pending-resolved` — a pending call left the inbox. Called exactly once per record (gated on the record delete).",
"properties": {
"function_call_id": {
"type": "string"
},
"function_id": {
"type": "string"
},
"outcome": {
"$ref": "#/definitions/ResolvedOutcome"
},
"reason": {
"description": "Operator-supplied on deny.",
"type": [
"string",
"null"
]
},
"resolved_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"session_id": {
"type": "string"
},
"session_metadata": {
"additionalProperties": true,
"description": "Tenancy routing, from the record.",
"type": [
"object",
"null"
]
},
"turn_id": {
"type": "string"
}
},
"required": [
"function_call_id",
"function_id",
"outcome",
"resolved_at",
"session_id",
"turn_id"
],
"title": "PendingResolvedEvent",
"type": "object"
}
},
{
"description": "Internal: observer of session::on-deleted (purge the session's settings and pending records).",
"metadata": {},
"name": "approval::on-session-deleted",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Caller": {
"description": "Who made an invocation. `worker_id` / `worker_name` are stamped by the engine from the calling connection; `function_id`, `invocation_id` and `parent` are asserted by the calling SDK.",
"properties": {
"function_id": {
"description": "The handler the call was made from; absent for a top-level call.",
"type": [
"string",
"null"
]
},
"invocation_id": {
"type": [
"string",
"null"
]
},
"parent": {
"anyOf": [
{
"$ref": "#/definitions/ParentCaller"
},
{
"type": "null"
}
],
"description": "The caller of that handler, one level only."
},
"worker_id": {
"type": [
"string",
"null"
]
},
"worker_name": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"InvocationStatus": {
"enum": [
"success",
"error"
],
"type": "string"
},
"ObservedError": {
"description": "What a call failed with: [`Observed::error`], [`Call::error`](crate::Call::error).",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object"
},
"ParentCaller": {
"description": "[`Caller::parent`]: a caller without a parent of its own.",
"properties": {
"function_id": {
"type": [
"string",
"null"
]
},
"invocation_id": {
"type": [
"string",
"null"
]
},
"worker_id": {
"type": [
"string",
"null"
]
},
"worker_name": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"SessionDeletedEvent": {
"description": "`session::on-deleted` event (only the field we read).",
"properties": {
"session_id": {
"type": "string"
}
},
"required": [
"session_id"
],
"type": "object"
}
},
"description": "What an observer's target receives with the default `deliver: envelope`: the observed call, per the observer's `capture`.\n\n```rust,no_run # use iii_sdk::{Error, IIIClient, Observed, RegisterFunction}; # use serde_json::Value; # fn demo(iii: &IIIClient) { iii.register_function( \"alerts::payment-failed\", RegisterFunction::new(|event: Observed<Value>| { println!(\"{} failed: {:?}\", event.function_id, event.error); Ok::<_, Error>(()) }), ); # } ```",
"properties": {
"activation_id": {
"type": "string"
},
"caller": {
"anyOf": [
{
"$ref": "#/definitions/Caller"
},
{
"type": "null"
}
]
},
"duration_ms": {
"format": "double",
"type": "number"
},
"error": {
"anyOf": [
{
"$ref": "#/definitions/ObservedError"
},
{
"type": "null"
}
]
},
"function_id": {
"type": "string"
},
"input": true,
"invocation_id": {
"type": "string"
},
"metadata": true,
"namespace": {
"type": [
"string",
"null"
]
},
"observer_id": {
"type": "string"
},
"output": {
"anyOf": [
{
"$ref": "#/definitions/SessionDeletedEvent"
},
{
"type": "null"
}
]
},
"started_at_ms": {
"format": "uint64",
"minimum": 0,
"type": "integer"
},
"status": {
"$ref": "#/definitions/InvocationStatus"
}
},
"required": [
"activation_id",
"duration_ms",
"function_id",
"invocation_id",
"observer_id",
"started_at_ms",
"status"
],
"title": "Observed_for_AnyValue_and_SessionDeletedEvent",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Acknowledgement returned by the internal observer targets (`on-config-change`, `on-session-deleted`, `on-turn-completed`) whose result is not consumed by callers — kept typed so the response schema is concrete rather than the permissive `AnyValue` (\"unknown\") schema a `Value` return would emit.",
"properties": {
"ok": {
"type": "boolean"
}
},
"required": [
"ok"
],
"title": "EventAck",
"type": "object"
}
},
{
"description": "Internal: observer of harness::on-turn-completed (purge the turn's pending records).",
"metadata": {},
"name": "approval::on-turn-completed",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Caller": {
"description": "Who made an invocation. `worker_id` / `worker_name` are stamped by the engine from the calling connection; `function_id`, `invocation_id` and `parent` are asserted by the calling SDK.",
"properties": {
"function_id": {
"description": "The handler the call was made from; absent for a top-level call.",
"type": [
"string",
"null"
]
},
"invocation_id": {
"type": [
"string",
"null"
]
},
"parent": {
"anyOf": [
{
"$ref": "#/definitions/ParentCaller"
},
{
"type": "null"
}
],
"description": "The caller of that handler, one level only."
},
"worker_id": {
"type": [
"string",
"null"
]
},
"worker_name": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"InvocationStatus": {
"enum": [
"success",
"error"
],
"type": "string"
},
"ObservedError": {
"description": "What a call failed with: [`Observed::error`], [`Call::error`](crate::Call::error).",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object"
},
"ParentCaller": {
"description": "[`Caller::parent`]: a caller without a parent of its own.",
"properties": {
"function_id": {
"type": [
"string",
"null"
]
},
"invocation_id": {
"type": [
"string",
"null"
]
},
"worker_id": {
"type": [
"string",
"null"
]
},
"worker_name": {
"type": [
"string",
"null"
]
}
},
"type": "object"
},
"TurnCompletedEvent": {
"description": "`harness::on-turn-completed` event (only the field we read).",
"properties": {
"turn_id": {
"type": "string"
}
},
"required": [
"turn_id"
],
"type": "object"
}
},
"description": "What an observer's target receives with the default `deliver: envelope`: the observed call, per the observer's `capture`.\n\n```rust,no_run # use iii_sdk::{Error, IIIClient, Observed, RegisterFunction}; # use serde_json::Value; # fn demo(iii: &IIIClient) { iii.register_function( \"alerts::payment-failed\", RegisterFunction::new(|event: Observed<Value>| { println!(\"{} failed: {:?}\", event.function_id, event.error); Ok::<_, Error>(()) }), ); # } ```",
"properties": {
"activation_id": {
"type": "string"
},
"caller": {
"anyOf": [
{
"$ref": "#/definitions/Caller"
},
{
"type": "null"
}
]
},
"duration_ms": {
"format": "double",
"type": "number"
},
"error": {
"anyOf": [
{
"$ref": "#/definitions/ObservedError"
},
{
"type": "null"
}
]
},
"function_id": {
"type": "string"
},
"input": true,
"invocation_id": {
"type": "string"
},
"metadata": true,
"namespace": {
"type": [
"string",
"null"
]
},
"observer_id": {
"type": "string"
},
"output": {
"anyOf": [
{
"$ref": "#/definitions/TurnCompletedEvent"
},
{
"type": "null"
}
]
},
"started_at_ms": {
"format": "uint64",
"minimum": 0,
"type": "integer"
},
"status": {
"$ref": "#/definitions/InvocationStatus"
}
},
"required": [
"activation_id",
"duration_ms",
"function_id",
"invocation_id",
"observer_id",
"started_at_ms",
"status"
],
"title": "Observed_for_AnyValue_and_TurnCompletedEvent",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Acknowledgement returned by the internal observer targets (`on-config-change`, `on-session-deleted`, `on-turn-completed`) whose result is not consumed by callers — kept typed so the response schema is concrete rather than the permissive `AnyValue` (\"unknown\") schema a `Value` return would emit.",
"properties": {
"ok": {
"type": "boolean"
}
},
"required": [
"ok"
],
"title": "EventAck",
"type": "object"
}
},
{
"description": "Remove a function from the session's auto-mode trust list (no-op when absent). Human/console-only.",
"metadata": {},
"name": "approval::remove-always-allow",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"function_id": {
"type": "string"
},
"session_id": {
"type": "string"
}
},
"required": [
"function_id",
"session_id"
],
"title": "AlwaysAllowMutationRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AlwaysAllowEntry": {
"properties": {
"function_id": {
"type": "string"
},
"granted_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"granted_by": {
"$ref": "#/definitions/GrantedBy"
}
},
"required": [
"function_id",
"granted_at",
"granted_by"
],
"type": "object"
},
"ApprovalSettings": {
"description": "The stored per-session record (scope `approval_settings`). Reads compute the effective settings from configuration defaults when no record exists — see settings.rs.",
"properties": {
"always_allow": {
"default": [],
"description": "Consulted only in auto mode.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"approved_always": {
"default": [],
"description": "Consulted in every mode — remembered human decisions.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"mode": {
"allOf": [
{
"$ref": "#/definitions/PermissionMode"
}
],
"default": "manual"
},
"mode_set_at": {
"default": 0,
"description": "ms epoch",
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"GrantedBy": {
"oneOf": [
{
"enum": [
"user_click"
],
"type": "string"
},
{
"description": "Copied from deployment auto-scoped allow rules on first mutation.",
"enum": [
"seed"
],
"type": "string"
}
]
},
"PermissionMode": {
"enum": [
"manual",
"auto",
"full"
],
"type": "string"
}
},
"description": "Shared by every settings mutation RPC: the post-mutation record.",
"properties": {
"settings": {
"$ref": "#/definitions/ApprovalSettings"
}
},
"required": [
"settings"
],
"title": "SettingsResponse",
"type": "object"
}
},
{
"description": "Apply a human decision to a held call: release it for execution (allow) or deliver a denial (deny). Human/console-only.",
"metadata": {},
"name": "approval::resolve",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AccessDuration": {
"description": "How far an `allow` on a `filesystem_access` pending record should apply. Ignored (logged) when the target record's `kind` is not `\"filesystem_access\"`. Defaults to `once` when omitted.",
"oneOf": [
{
"description": "One-shot: trust the directory for just the released call.",
"enum": [
"once"
],
"type": "string"
},
{
"description": "Durable for the rest of the session (`harness::filesystem::grant`).",
"enum": [
"session"
],
"type": "string"
},
{
"description": "Durable for the session AND persisted to the `shell` deployment configuration (`fs.host_roots`), best-effort.",
"enum": [
"always"
],
"type": "string"
}
]
},
"ResolveDecision": {
"enum": [
"allow",
"deny"
],
"type": "string"
}
},
"properties": {
"access_duration": {
"anyOf": [
{
"$ref": "#/definitions/AccessDuration"
},
{
"type": "null"
}
],
"default": null,
"description": "Only meaningful when the target record is `kind: \"filesystem_access\"` and `decision: \"allow\"`. Defaults to `once`."
},
"decision": {
"$ref": "#/definitions/ResolveDecision"
},
"function_call_id": {
"type": "string"
},
"reason": {
"default": null,
"description": "Surfaced to the model on deny.",
"type": [
"string",
"null"
]
},
"session_id": {
"type": "string"
}
},
"required": [
"decision",
"function_call_id",
"session_id"
],
"title": "ResolveRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"resolved": {
"description": "false: unknown/already-resolved pending call.",
"type": "boolean"
},
"turn_resumed": {
"description": "Passthrough from harness::function::resolve.",
"type": [
"boolean",
"null"
]
}
},
"required": [
"resolved"
],
"title": "ResolveResponse",
"type": "object"
}
},
{
"description": "Set the session's permission mode (manual / auto / full). Human/console-only.",
"metadata": {},
"name": "approval::set-mode",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"PermissionMode": {
"enum": [
"manual",
"auto",
"full"
],
"type": "string"
}
},
"properties": {
"mode": {
"$ref": "#/definitions/PermissionMode"
},
"session_id": {
"type": "string"
}
},
"required": [
"mode",
"session_id"
],
"title": "SetModeRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AlwaysAllowEntry": {
"properties": {
"function_id": {
"type": "string"
},
"granted_at": {
"description": "ms epoch",
"format": "int64",
"type": "integer"
},
"granted_by": {
"$ref": "#/definitions/GrantedBy"
}
},
"required": [
"function_id",
"granted_at",
"granted_by"
],
"type": "object"
},
"ApprovalSettings": {
"description": "The stored per-session record (scope `approval_settings`). Reads compute the effective settings from configuration defaults when no record exists — see settings.rs.",
"properties": {
"always_allow": {
"default": [],
"description": "Consulted only in auto mode.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"approved_always": {
"default": [],
"description": "Consulted in every mode — remembered human decisions.",
"items": {
"$ref": "#/definitions/AlwaysAllowEntry"
},
"type": "array"
},
"mode": {
"allOf": [
{
"$ref": "#/definitions/PermissionMode"
}
],
"default": "manual"
},
"mode_set_at": {
"default": 0,
"description": "ms epoch",
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"GrantedBy": {
"oneOf": [
{
"enum": [
"user_click"
],
"type": "string"
},
{
"description": "Copied from deployment auto-scoped allow rules on first mutation.",
"enum": [
"seed"
],
"type": "string"
}
]
},
"PermissionMode": {
"enum": [
"manual",
"auto",
"full"
],
"type": "string"
}
},
"description": "Shared by every settings mutation RPC: the post-mutation record.",
"properties": {
"settings": {
"$ref": "#/definitions/ApprovalSettings"
}
},
"required": [
"settings"
],
"title": "SettingsResponse",
"type": "object"
}
}
]
}