Expand description
C ABI for AgentStateGraph — opaque handle-based API.
All functions use opaque pointers and C strings. The caller is responsible for freeing returned strings with agentstategraph_free_string.
This crate produces a shared library (.so/.dylib/.dll) and static library (.a) that any language with C FFI can call.
Every extern "C" function in this crate takes raw pointers by design —
they form the C ABI contract. Marking them unsafe fn would change that
ABI and make every bindgen-generated header noisier. We validate pointer
inputs inside each function instead (is_null checks, bounded CStr
reads). The blanket allow below silences clippy on this pattern
crate-wide.
Structs§
- SgPolicy
Store - Opaque handle to a PolicyStore.
- SgRepo
- Opaque handle to a Repository.
- SgTask
Store - Opaque handle to a TaskStore.
Functions§
- agentstategraph_
blame - Blame — returns JSON string with blame entry.
- agentstategraph_
branch - Create a branch. Returns commit ID string.
- agentstategraph_
check_ taint - Check the taint status for
pathgivenagent_id+confidence. - agentstategraph_
delete - Delete a value at a path. Returns commit ID string.
- agentstategraph_
delete_ branch - Delete a branch by name. Returns
{"deleted": true|false}or{"error": "..."}.deleted=falsemeans the ref didn’t exist. - agentstategraph_
diff - Diff two refs. Returns JSON string of DiffOps.
- agentstategraph_
fork_ namespace - Create another repository handle over the same storage, scoped to
namespace. The returned handle has independent active session/epoch state and must be released withagentstategraph_free. - agentstategraph_
free - Free a repository handle.
- agentstategraph_
free_ string - Free a string returned by AgentStateGraph functions.
- agentstategraph_
get - Get a JSON value at a path. Returns a JSON string (caller must free).
- agentstategraph_
list_ branches - List branches, optionally filtered by prefix.
prefixmay be NULL or an empty string for no filter. Returns a JSON array of{"name": String, "target": String}objects (target = commit id hex), or{"error": "..."}on failure. - agentstategraph_
list_ taints - List active taints / quarantines / watches.
kind_or_nullaccepts “taint” | “quarantine” | “watch” or NULL to list all. - agentstategraph_
log - Get commit log as JSON. Returns JSON array string.
- agentstategraph_
merge - Merge source into target. Returns commit ID or error JSON.
- agentstategraph_
migrate_ check - Check the migration status of a repository. Returns a JSON report:
{"status":"up_to_date","version":"0.4.0"},"upgrade_available","downgrade","unversioned","corrupt".targetmay be null to use the binary’s currentSCHEMA_VERSION. - agentstategraph_
migrate_ run - Run migrations.
modeis"apply"or"dry-run". Returns a JSON report describing each step. - agentstategraph_
new_ memory - Create a new in-memory AgentStateGraph repository.
- agentstategraph_
new_ postgres - Create a new Postgres-backed AgentStateGraph repository.
- agentstategraph_
new_ sqlite - Create a new SQLite-backed AgentStateGraph repository.
- agentstategraph_
policy_ active - List currently-active (ratified and
active_from <= now) policies.prefix_or_nullfilters by path prefix (NULL/empty = all). Returns JSON array. - agentstategraph_
policy_ check_ tokens - List active policies whose
triggersintersecttokens_json(a JSON array of strings). Binding-level helper mirroring the internal filter used byevaluate_change. Returns JSON array of policies. - agentstategraph_
policy_ evaluate - Authorization evaluation (POLICY_V1.md §5).
situation_jsonis a flat{string: string}JSON object, or{"facts": {...}}wrapper. Returns JSONDecision. - agentstategraph_
policy_ evaluate_ change - Change-proposal evaluation (POLICY_V1.md §22.2).
proposal_jsonis a JSONChangeProposal. Returns JSONDecision. - agentstategraph_
policy_ evaluate_ change_ scoped - Scoped change-proposal evaluator (0.7.5 §3b). See
agentstategraph_policy_evaluate_scopedfortenant_filtersemantics. - agentstategraph_
policy_ evaluate_ scoped - Scoped evaluator (0.7.5 §3b). Variant of
agentstategraph_policy_evaluatethat accepts an optionaltenant_filter. PassNULLfor no filter (equivalent to the non-scoped variant). Returns JSONDecision. - agentstategraph_
policy_ get - Fetch the active policy at
path. Returns JSON policy object. - agentstategraph_
policy_ history - Walk the supersedes chain for
path. Returns JSON array, oldest first through the current active version. - agentstategraph_
policy_ list - List policies whose path starts with
prefix_or_null(NULL or empty = no filter). Returns JSON array of policies. - agentstategraph_
policy_ propose - Propose a new (unratified) policy.
policy_jsonis a JSON object matching thePolicyschema. Returns a JSON string"path@version"handle on success, or{"error": ...}JSON on failure. - agentstategraph_
policy_ ratify - Ratify an unratified proposal at
path. Returns{"ok":true}on success,{"error": ...}on failure. - agentstategraph_
policy_ set_ external_ evaluator - Configure an external policy evaluator on the store (0.7.5 §4c).
- agentstategraph_
policy_ sign - Sign the active policy at
path. §2c of the 0.7.5-beta.1 plan. - agentstategraph_
policy_ store_ free - Free a PolicyStore handle.
- agentstategraph_
policy_ store_ new - Create a new PolicyStore handle bound to the given repository, path
prefix, and agent id. The returned pointer must be freed with
agentstategraph_policy_store_free. The underlying repository is shared (refcounted); freeing the PolicyStore does NOT free the repository. - agentstategraph_
policy_ supersede - Replace the active policy at
pathwithnew_policy_json. Returns JSON"path@new_version"handle on success. - agentstategraph_
policy_ verify - Verify the signature on the active policy at
path. §2c of the 0.7.5-beta.1 plan. - agentstategraph_
quarantine_ apply - Apply a quarantine.
params_json:{"name","reason","severity","authorized_agents":[...],"expires","propagate","agent_id"}. - agentstategraph_
quarantine_ release - Release a quarantine.
params_jsonshape matches taint_remove. - agentstategraph_
repository_ call - Invoke an advanced repository operation through the stable JSON ABI.
- agentstategraph_
repository_ capabilities - Return the advanced repository API contract implemented by
agentstategraph_repository_call. Keeping this contract data-driven gives native bindings one stable ABI entry point while still allowing their public APIs to remain strongly typed and idiomatic. - agentstategraph_
set - Set a JSON value at a path. Returns commit ID string (caller must free).
- agentstategraph_
taint_ apply - Apply a taint.
params_jsonshape:{"name":"...","effect":"warn|block|review|isolate","reason":"...", "severity":"medium","expires":null,"propagate":true,"agent_id":"..."}. Returns JSON{"ok":true,"id":"<uuid>"}or{"error":"..."}. - agentstategraph_
taint_ remove - Remove a taint.
params_json:{"name":"...","reason":"...","proof":null,"agent_id":"..."}. - agentstategraph_
taskstore_ abandon_ task - agentstategraph_
taskstore_ add_ task - Add a task. Arguments:
- agentstategraph_
taskstore_ add_ task_ ex - Extended add_task that also threads the 0.6.0 Task extension fields
through the FFI:
payload_json(an arbitrary JSON value or NULL),parent_change(opaque string or NULL),on_complete_json(a JSON OnCompleteHook value or NULL — see agentstategraph-tasks::OnCompleteHook for the variant tags). Returns the Task as JSON or{"error": "..."}. - agentstategraph_
taskstore_ archive_ plan - agentstategraph_
taskstore_ assign_ task - agentstategraph_
taskstore_ complete_ task - Complete a task.
proof_kindis “commit” | “file” | “test” | “text”. - agentstategraph_
taskstore_ create_ plan - Create a plan. Returns the Plan as JSON, or
{"error": ...}on failure. - agentstategraph_
taskstore_ delete_ plan - agentstategraph_
taskstore_ derived_ status - Compute the derived (rollup) status of a parent task. Returns
"pending"|"in_progress"|"done"|"abandoned"JSON-wrapped. - agentstategraph_
taskstore_ free - Free a TaskStore handle.
- agentstategraph_
taskstore_ get_ plan - Get a plan by name.
- agentstategraph_
taskstore_ get_ task - agentstategraph_
taskstore_ list_ plans - List plans. Returns JSON array.
- agentstategraph_
taskstore_ list_ plans_ by_ status - List plans filtered by status.
statusis “active”, “completed”, “archived”, or null/empty for all. Returns JSON array. - agentstategraph_
taskstore_ list_ tasks - agentstategraph_
taskstore_ new - Create a new TaskStore handle bound to the given repository, path
prefix, and agent id. The returned pointer must be freed with
agentstategraph_taskstore_free. The underlying repository is shared (refcounted); freeing the TaskStore does NOT free the repository. - agentstategraph_
taskstore_ next_ task - Returns the next unblocked task as JSON,
nullif none, or error JSON. - agentstategraph_
taskstore_ next_ task_ for - Next task filtered by assignment.
agentnull for any;include_unassignedcontrols fallback to unassigned when an agent is specified. - agentstategraph_
taskstore_ set_ blockers - Set blockers.
blockers_jsonis a JSON string array (may be null or “[]”). - agentstategraph_
taskstore_ set_ priority - agentstategraph_
taskstore_ set_ title - Replace a task’s title; a blank title is refused.
- agentstategraph_
taskstore_ start_ task - agentstategraph_
taskstore_ task_ ids - agentstategraph_
taskstore_ unassign_ task - agentstategraph_
watch_ apply - Apply a watch.
params_json:{"name","reason","metric","threshold","direction":"above|below", "check_interval_secs","expires","severity","propagate","agent_id"}. - agentstategraph_
watch_ remove - Remove a watch.