Audit log

The audit log is one Postgres table, audit_log, that records who did what: the engine’s actions in a session, changes made in the dashboard or through the API, sign-ins, refused requests and refused egress.

This page is for operators and anyone who has to account for what happened: what an entry holds, every action recorded, how the table stays append-only, and how to read and export it.

What an entry holds

Field Meaning
id Unique ID. IDs sort in the order entries were written.
at Timestamp.
actor Who acted: kojo for the engine, a user’s email or token:<name> for the dashboard and the API, a forge login or chat user for a refused request, sandbox:<id> for refused egress.
session_id The session, when the action belongs to one.
action A dotted verb, see below.
target What was acted on.
detail A JSON object with the specifics.

Actions recorded

Written by the engine:

Action Target Detail
session.start Repository surface, kind, actor, trusted, dry_run
session.end Repository status, and cost_usd or error
session.cancel Repository none
session.message Session ID surface, seq, message, chars, and where it was written: number and url, or thread. A message someone sent a session at work, stored for its next model step; the actor is its author. A message refused for its length, its emptiness or the session’s limit of 20 is a request.reject instead. See Talking to a session at work.
sandbox.create Sandbox ID image, skill
sandbox.destroy Sandbox ID none
skill.run Skill name passed, attempts, changed_files
merge.decide Repository action, reason, risk
approval.ask Approval ID kind, deadline
approval.decide Approval ID kind, status. The actor is the person who decided.
approval.expire Approval ID kind, deadline. Nobody decided before the deadline; the actor is kojo.
approval.late Approval ID kind, value, deadline. A click after the deadline, which changed nothing; the actor is the person who clicked.
pr.open repo#number branch, draft, files, url
pr.merge repo#number method
pr.edit repo#number skill, session. Someone other than kōjō pushed commits to a pull request it opened; the actor is that user.
pr.close repo#number outcome (merged or closed), human_edited, skill. The actor is whoever merged or closed it.
comment.post repo#number url, and skill when a skill posted it
memory.save Memory ID scope (team or personal), topic, skill, and person for a personal memory
memory.learn Memory ID pull_request, reviewer, skill, topic, kind, url. A lesson learned from a review.
schedule.propose Schedule name The proposed schedule
skill.proposal.start scope/skill proposal, trigger, evidence (how many items). The actor is who asked, or kojo for the periodic check.
skill.proposal.create scope/skill proposal, draft, evidence, loosens, eval, baseline. The proposal passed the checks and became a draft.
skill.proposal.validate scope/skill proposal, outcome (ready or did_not_hold_up), measured, and when measured pass_rate, baseline_pass_rate, min_eval_pass_rate, eval, baseline, cases
skill.proposal.close scope/skill proposal, status, note, and refused (what it tried to widen) or same_as (a rejected proposal with the same files)
skill.proposal.approve scope/skill proposal, draft, via, revision or pull_request, loosens. The actor is the person who approved it.
skill.proposal.reject scope/skill proposal, reason. The actor is who rejected it.
request.reject Repository, approval, session, or for a production alert <source>:<issue ID> (sentry:5123964221, datadog:<UUID>) reason. The actor is the author of the refused request, or of a refused message to a session; for an alert it is alert:<source>:<project> (the Sentry project or the Datadog service), and the detail adds project, environment and issue. An alert’s reason is a code: alert_unmapped, alert_ambiguous, alert_open, alert_pr_open, alert_round_limit, alert_daily_limit or alert_resolved (see Sentry), or alert_mismatch or alert_unread (see Datadog). For those two the detail adds error, in fixed words: the issue is not the one the alert named, or issue could not be read, alone or followed by the HTTP status (: HTTP 403) or : the API answered about another issue. What the source’s API answered stays in the server’s log, since it can hold anything.
proxy.deny Host, with :port when the port is not 443 or 80 none. The actor is sandbox:<id>.
campaign.pause Campaign ID reason (pilot, cost or bound), spent_usd, and for bound the problem and stopped, the queued sessions it cancelled. A campaign paused after its pilot, at its cost bound, or because settings/models no longer bounds what a session costs; the actor is kojo.
campaign.done Campaign ID spent_usd. Every repository of the campaign is over; the actor is kojo.

Written by the dashboard and the API:

Action Target Detail
auth.login none none. The actor is the email that signed in.
session.create Session ID repo, skill, dry_run
session.cancel Session ID none
config.activate scope/object revision, parent, message
config.rollback scope/object revision, parent
config.propose scope/object scope, object, pull_request, updated, message. An edit of a repository’s setting kept in .factory/ opened a pull request (updated false) or added a commit to kōjō’s open one.
config.move repo:<forge/owner/name> pull_request, created, left_alone. A move to the repository opened its pull request.
skill.draft.create, skill.draft.update scope/name draft, and on an update version and proposal (empty unless the draft is a proposal kōjō made)
skill.draft.delete Draft ID none
skill.draft.test, skill.draft.eval scope/name draft, and session or run
skill.activate Skill draft, via (git or dashboard), pull_request or revision, and proposal when the draft was a proposal
skill.delete scope/name revision
eval.start Skill name run
memory.save Memory ID repo, topic, scope, and person for a personal memory
memory.delete Memory ID scope, repo, topic, source, and for a personal memory person, with by_admin when an admin deleted someone else’s
memory.read Person An admin listed another person’s memories
memory.erase Person deleted (how many), by_admin. Every memory of one person was deleted.
report.link Session ID expires_at. A person made a link to the session’s shareable report; the link itself is not recorded. Links kōjō puts in pull request descriptions are not audited.
report.revoke Session ID none. An admin revoked every link to the session’s report made so far. The number of these entries is the revocation count every link carries.
report.export Session ID none. An operator saved the session’s report page as a file.
campaign.create Campaign ID repos, skipped (how many), skill, max_cost_usd (the estimate). Nothing runs yet.
campaign.confirm Campaign ID max_cost_usd: the bound the person confirmed.
campaign.continue Campaign ID after (pilot or cost), max_cost_usd
campaign.cancel Campaign ID sessions: the IDs of the open sessions asked to stop; failed: how many could not be asked; again: the campaign was cancelled already.
campaign.retry Campaign ID repos: the repositories that run again.

A session is marked over last. When it ends, its sandboxes are destroyed (sandbox.destroy) and session.end is written before the terminal status is stored. Once a session shows succeeded or failed, its session.end entry exists and nothing of it is still running.

Two limits to keep in mind:

  • Individual sandbox commands are not audit entries. They are exec steps of the session, see session replay.
  • proxy.deny is written by the embedded proxy only. A standalone kojo proxy has no database connection and writes no audit entries.

An audit write that fails is logged at error level (msg="audit write failed") and does not stop the work.

Append-only

The first database migration creates a trigger on the table:

CREATE FUNCTION kojo_audit_append_only() RETURNS trigger AS $$
BEGIN
    RAISE EXCEPTION 'audit_log is append-only';
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER audit_log_append_only BEFORE UPDATE OR DELETE ON audit_log
    FOR EACH ROW EXECUTE FUNCTION kojo_audit_append_only();
CREATE TRIGGER audit_log_no_truncate BEFORE TRUNCATE ON audit_log
    FOR EACH STATEMENT EXECUTE FUNCTION kojo_audit_append_only();

Any UPDATE or DELETE of a row, and any TRUNCATE of the table, fails with audit_log is append-only, whoever sends it, kōjō included. The source is migrations.go.

A database role that owns the table can still drop the triggers. Give kōjō’s database role no more than it needs, and archive exports outside the database if the log must survive a database administrator. kōjō never prunes the table, so it grows for the life of the deployment.

Reading and exporting

In the dashboard, the log is under Records, Audit log (/audit). The page lists entries newest first, with filters for actor, action, session and a time range, and paging to older entries. Selecting an actor or an action in a row filters by it. Users with the operator role also get a button that downloads the filtered time range as kojo-audit.ndjson.

The Audit log page of the dashboard: filters for actor, action, session and a time range, and a table of entries with time, actor, action, target, session and detail.
The newest entries first: a config activation by a person, then the skill.run and session.start entries of kōjō's sessions.

From the API:

Endpoint Role Returns
GET /api/v1/audit viewer {"entries": [...]}, newest first.
GET /api/v1/audit/export operator The log as newline-delimited JSON, one entry per line, newest first, as a download named kojo-audit.ndjson.

Query parameters of GET /api/v1/audit:

Parameter Meaning
actor Exact actor.
session A session ID.
action Exact action, or a prefix when it ends with a dot: skill. matches every skill action.
since, until RFC 3339 timestamps.
before An entry ID: entries older than it, for paging.
limit Default 100, at most 500.

GET /api/v1/audit/export takes since and until only and streams the whole range.

curl -H "Authorization: Bearer $KOJO_TOKEN" \
  "$KOJO_SERVER/api/v1/audit?session=ses_01jexample"
curl -H "Authorization: Bearer $KOJO_TOKEN" \
  "$KOJO_SERVER/api/v1/audit/export?since=2026-01-01T00:00:00Z&until=2026-02-01T00:00:00Z" \
  -o kojo-audit-2026-01.ndjson

The token is one of server.auth.tokens in kojo.yaml. There is no CLI command that exports the audit log: use the endpoint. If the database fails during an export the stream ends early without an error status, so check that the last line of the file is the oldest entry you expect.

Scroll to move. + - zoom, 0 fit, Esc close.100%