Skip to content

Organizations export audit logs to their own systems and choose how long transcripts are kept #623

Open

Description

@fctl-sh

Organizations keep their audit trail in their own systems (Splunk, Datadog, a bucket their SIEM reads) and have rules for how long their tools keep what they hold. fctl's audit logs can be read only by a signed-in admin, or an access token of theirs without limits, 100 entries at a time, and are deleted after a year whatever the organization's rules say. Transcripts, which hold code, command output and anything an agent printed, stay until their project is deleted: removing one session's means deleting the whole project.

How it works now

  • The log. One D1 table, audit_log (id, ts, actor_id, action, target, data, ip, workspace_id; crates/fctl-control/migrations/0001_init.sql, 0013_workspaces.sql); the instance's entries have no workspace. Most are written after the response by Ctx::audit_in (crates/fctl-control/src/ctx.rs); seven other files in crates/fctl-control/src insert their own (autopilots.rs, delegations.rs, do_hooks.rs, housekeeping.rs, schedules.rs, reviews.rs, and api/memories.rs for memory.stale_deleted).
  • Reading it. GET /api/v1/workspaces/{id}/audit (its admins) and GET /api/v1/admin/audit (instance admins), both api::admin::audit_page: 100 entries, newest first, and next_before, a timestamp. The next page takes entries strictly before it, so entries sharing the last one's millisecond are skipped. A workspace's admins see the IP address of their own entries alone. fctl workspaces audit and fctl admin audit take --before MS and --json; the web app puts each entry in a sentence (web/src/lib/audit.ts).
  • Who can. Limited access tokens and service accounts don't reach it (fctl_domain::limits::allows, fctl_domain::service_accounts::allows), nor do admin tokens, which reach the people endpoints alone (fctl_domain::admin_tokens::allows) and only where FCTL_ADMIN_TOKENS is on.
  • How long. The hourly job (run in crates/fctl-control/src/housekeeping.rs) deletes entries older than AUDIT_RETENTION_MS, 365 days, on every instance. docs/organizations.md#oversight and fctl.sh's privacy policy say a year.
  • Webhooks (docs/automation.md#webhooks, ADR 0084 and 0088, crates/fctl-control/src/hooks.rs and do_hooks.rs): 19 events in four groups, signed as Standard Webhooks, 8 attempts over about 21 hours, each webhook's newest 1,000 deliveries kept 30 days, events past 1,000 waiting dropped. Every post names a workspace (HookEnvelope.workspace), so the instance's log has nowhere to go, and a webhook that chose no events gets every event, later ones included.
  • Transcripts. A session's event log, diffs and the images its agent read are in its SessionObject, its messages' files in its project's FilesObject, its documents in the workspace's search index (ADR 0056), its task in D1 (sessions.prompt). They stay until the project is deleted (docs/security.md#retention), which queues session_purges and file_purges for the hourly job, 200 a run (purge_sessions; a SessionObject's /purge leaves search, then empties its storage). FilesObject deletes a project's files, never one session's, and no endpoint deletes a session: archiving hides it (api::sessions::update).
  • Around a session. Retrospectives go with its row (ON DELETE CASCADE); memory notes stay, their session link cleared (ON DELETE SET NULL, crates/fctl-control/migrations/0021_memories_and_retrospectives.sql). Projects already choose how long stale notes stay, which the hourly job deletes and audits as fctl's doing (ADR 0092).

What should happen

  • The audit log reads from a cursor, in the order entries were written, without gaps.
  • A token that reads audit logs and nothing else.
  • Workspace webhooks post audit entries, when chosen.
  • A self-hosted instance chooses how long audit entries stay.
  • A workspace chooses when its sessions are archived and when their transcripts are deleted; its admins hold sessions or projects out of it.
  • Web app, CLI, docs/, docs/llms.txt and fctl-site's privacy policy.

A cursor. GET …/audit?after=CURSOR&limit=500, oldest first, answers {entries, next}. The cursor follows the order rows were written (a new seq, or SQLite's rowid), not ts: audit_in writes after the response with the request's time, so an entry can land after a later one was read. before keeps working. fctl workspaces audit --after CURSOR --json prints JSON Lines, and --follow keeps printing, for a forwarder (Vector, Fluent Bit, a job that writes to S3).

A token. fctl token "Splunk" --access audit -w acme reaches the audit endpoints alone (a new TokenAccess in tokens.scope). It acts as its person, so it reads the logs they admin, and stops reading one when they stop being its admin.

Webhooks. A fifth group, Audit log, with one event, audit.entry: the entry as the API reads it, with its seq. Only a workspace's own webhooks take it, and only by name: "Every event" leaves it out, so existing webhooks don't start posting people's actions. One writer (crate::audit, which the eight places call) hands each entry to hooks::emit, with IP addresses only where the API shows them to workspace admins. Since webhooks drop and give up, receivers catch up with the cursor from the last seq they got.

Instance retention. InstanceSettings.audit_retention_days (Admin → Settings, fctl admin set --audit-retention 3y), a year unless set, which the hourly job reads.

Workspace retention. Archive sessions N days after their last activity (sessions.last_activity_at), and delete their transcripts M days after it, for sessions that ended. The hourly job archives, as people do, and deletes: the SessionObject (/purge), the session's files (FilesObject needs a per-session delete) and its task in D1, oldest first, 200 a run. The row stays (number, title, who started it, when, status, pull requests, retrospectives), so links, the audit log, notes and pull requests still name it; it takes no more messages. The audit log records session.transcripts_deleted per project and run, as fctl's doing. A hold (PUT/DELETE /api/v1/sessions/{id}/hold or /projects/{id}/hold, with a reason), by the workspace's admins and audited, keeps a session, or a project's sessions, out of both.

Design and UX

An admin should send Acme's audit log to their SIEM and set how long transcripts stay in a few minutes, seeing before they save what will leave fctl and what will be deleted and when, with nothing deleted that they didn't see counted first.

  • Audit log tab. Above the log, for admins: "Acme's audit log in your own systems", a lead from facts ("Acme's log recorded 2,341 entries in the last 30 days. fctl keeps them a year; your systems keep them as long as your rules say.") and two ways side by side, buttons lined up: "Post each entry as it happens" ("A webhook posts every entry to an address of yours within seconds, signed, and tries again for about 21 hours.") [Add a webhook for the audit log], which opens the webhook form with Audit log chosen; "Let your SIEM pull them" ("A token that only reads audit logs reads the entries after the last one it read, so a pull never misses one.") [Make an audit token]. The preview: POST splunk.acme.dev/services/collector, a green 200, fctl-event: audit.entry, and JSON with "action": "workspace.member_removed", "actor": {"name": "Ada"}, "seq": 18342. Once set up, it shrinks to a line: "Posting to Splunk HEC · read by the token Datadog 2m ago".
  • A new token shows its secret once, as access tokens do, then complete commands: curl -H "Authorization: Bearer fctl_pat_…" "https://app.fctl.sh/api/v1/workspaces/acme/audit?after=0" and fctl workspaces audit -w acme --after 0 --follow --json, ending "Its first page starts at Acme's oldest entry, from Nov 23, 2025."
  • Settings → Retention, after Policies: "How long Acme keeps sessions", and a lead from facts: "Acme keeps every session's transcript, diffs and files until its project is deleted: 4,812 sessions in 9 projects, the oldest from March." Then "Archive sessions [30 days ▾] after their last activity." and "Delete their transcripts, diffs and files [1 year ▾] after their last activity." Beside them, one session's life on a line (last activity, archived at day 30, transcript gone at day 365) with "What stays: web#12, its title, who started it and when, its pull requests and retrospectives". Under them (aria-live): "Saving archives 1,204 sessions and deletes the transcripts of 312 at the next hourly runs, oldest first. 3 sessions and 1 project on hold stay." Members read it as a sentence, with who sets it.
  • Saving a deletion asks, in red as it can't be undone: "Delete the transcripts of 312 sessions?", "Their transcripts, diffs, files and search entries go within a few hours and can't be brought back. Their numbers, titles, starters, pull requests and retrospectives stay." [Delete them] beside [Only archive them]. Toast: "Saved: 312 transcripts go over the next 2 hours".
  • Holds. "Hold…" in a session's ⋯ menu and a project's Settings, for admins, asks a reason. A held session shows a blue banner: "On hold since Nov 12 (Ada): Contract review, LEGAL-7. Acme's retention leaves it." Settings → Retention lists holds, newest first, folding past five.
  • A deleted transcript's session says, in place of it: "Its transcript was deleted on Nov 30, a year after its last activity, as Acme keeps sessions.", then what stays.
  • States. Loading: skeletons, never the intro before the counts. Failed: "Couldn't count Acme's sessions: … Try again", and Save waits. Waiting: "312 transcripts go at the next hourly runs, 200 an hour: 112 are left." Nothing due: "Nothing goes yet: Acme's oldest session was active 41 days ago."
  • CLI. A deletion without --dry-run asks for the workspace's name, or takes --yes.
$ fctl workspaces retention -w acme
Sessions are archived 30 days after their last activity, and their transcripts deleted after a year.
3 sessions and 1 project are on hold: fctl workspaces retention -w acme --holds
$ fctl workspaces retention -w acme --delete-after 1y --dry-run
Saving deletes the transcripts of 312 sessions at the next hourly runs. Nothing changed.
$ fctl sessions hold web#12 --reason "Contract review, LEGAL-7"
$ fctl token "Splunk" --access audit -w acme --days 365
$ fctl webhooks add https://splunk.acme.dev/services/collector -w acme --events audit.entry

Building it:

  • Follow hyperstructure/design's docs: docs/principles.md; docs/web-app/explaining.md for pages that set something up (a headline that names the outcome, a lead built from this place's facts, a preview of the result, one primary action, and who can act); docs/web-app/kit.md for controls.
  • Design every state before building it: the first visit, loading, errors and refusals, waiting, partial setups and long lists.
  • Say what happens, plainly, and never leave someone at a disabled control without saying who can act.
  • Prototype the main screens with realistic data (cargo xtask demo's world) and review them before building the rest.
  • Check both themes, a phone's width, the keyboard, screen readers and reduced motion, and show screenshots in each pull request.
  • Give the CLI the same care: readable output, --json, and errors that say what to do next.
  • Add or update the pages of hyperstructure/design's docs for each new component, with the reasons behind its choices.

Compatibility

  • D1 migrations: the audit log's sequence and its index, the workspace's retention, holds, and when a transcript was deleted. A token with the new access, read by a control plane rolled back before it, reaches nothing (Limits::parse).
  • Protocol: optional fields (AuditEntry.seq, AuditList.next, Workspace.retention, Session.hold, Session.transcript_deleted_at, InstanceSettings.audit_retention_days) and a webhook group and event, then cargo xtask gen. Hosts and agents need nothing: retention takes only sessions that ended, and fctl resumes none whose transcript went.
  • A retention under 30 days leaves what webhooks' logs carry of a session (its title, the start of its agent's replies) until they age out; the docs say so.
  • Docs: docs/security.md#retention, docs/organizations.md (Oversight, Credentials at a glance), docs/automation.md#webhook-events, docs/api.md, docs/cli.md, docs/self-hosting.md, docs/architecture.md and docs/llms.txt, and an ADR for deleting transcripts on a schedule. The CLI's flags ship with the next release.
  • fctl-site's legal/privacy.md: sessions are kept as their workspace chooses, not until the project goes; audit entries go to addresses workspace admins choose; a self-hosted instance chooses how long audit logs stay, app.fctl.sh a year.

Decisions for a person

  • Which credential reads audit logs: an access token limited to them, ending with its admin, as here, or a credential of the workspace's own that outlives one admin, like a service account.
  • Whether self-hosted instances get a way to post the instance's own log, which no workspace webhook can.
  • The bounds: the shortest and longest audit retention, the shortest transcript retention, and whether app.fctl.sh's workspaces may keep audit entries longer than a year.
  • What stays once a transcript goes (the title, retrospectives, pull requests), and whether a session waits while its pull requests are open or an autopilot or schedule still follows it.
  • Whether a hold stops its project and workspace from being deleted, and whether instance admins set and lift holds too.

Related: #622, #616, #619

Session: https://app.fctl.sh/s/ses_01M8450BECFP8DN88R0ZP0N0MS

Activity

  1. added
    enhancement
    control-plane
    web
    cli
    integrations
    security
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clicontrol-planeenhancementintegrationssecurityweb

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions