Skip to content

The audit log table is never written to #194

Open

Description

@imshashank

audit_log exists in packages/db/src/schema/comms.ts with a well designed set of columns: actor type, actor id, actor name, action, entity type, entity id, a before and after JSONB pair, and an IP address, indexed on organisation and time.

Nothing writes to it. Not one row, ever.

This matters more than the other dormant tables because of what people assume when they see it. An admin evaluating Orbit for a team, reading the schema, will conclude there is an audit trail. There is not. If somebody removes a member, changes a role, deletes a project or rotates an integration token, there is no record of it anywhere.

issue_activity covers changes to issues and is a different thing. It is a product feature for showing history on an issue, scoped to issues, and it does not record administrative actions at all.

What to build

Write the log. Every administrative and destructive action produces a row:

  • Member invited, role changed, removed
  • Team created, renamed, deleted, membership changed
  • Workspace settings changed, including the allowed email domains
  • Integration connected, disconnected, token rotated
  • Project or doc deleted, archived, or its visibility changed
  • Doc share link created or revoked
  • API key created or revoked, once those exist
  • Sign-in method changes, and session revocation

The before and after columns mean the log can answer what a setting used to be, which is usually the actual question. Use them. Never put a secret, a token or a password hash in either one.

Read the log. An admin only view under settings, filterable by actor, action, entity and date, with the newest first. The index audit_log_org_idx on organisation and time already supports that ordering.

Retain the log. Decide and document a retention policy. Unbounded growth on a busy workspace is a real problem, and a self hoster needs to know whether this table will grow forever. Whatever you pick, put it in docs/self-hosting.md.

Things to get right

  • The log is append only. No update path, no delete path, no API that can rewrite history. If retention deletes old rows, that is a scheduled job and not a user action.
  • actor_type defaults to user and the column exists for a reason. MCP agents and automation rules act too, and an audit entry that attributes an agent's action to the human who authorised its token is misleading. Record both: the agent as actor, the granting user as the principal behind it. The mcp_grant row already binds a client and user to a workspace, so the information is available.
  • The IP address column is personal data. Say in the docs that it is collected, and consider making it optional for self hosters who would rather not.
  • Failures to write must not fail the action. If the audit insert throws, the role change should still happen and the failure should be loud in the logs. An audit system that can take down the app is worse than no audit system. Reasonable people disagree about this for compliance reasons, so say what you chose.

Files

  • packages/db/src/schema/comms.ts
  • packages/core/src/org/ and packages/core/src/auth/ for the actions to instrument
  • A new settings route under apps/web/src/app/(app)/settings/
  • packages/shared/src/policy for the admin gate
  • docs/self-hosting.md

Scope note

Writing the log and viewing the log can be two pull requests. Writing it first is more valuable, because a log with no viewer can still be queried in Postgres, while a viewer with no log shows an empty table.

Activity

  1. added
    enhancement
    help wanted
    security
    p1 high
    area: database
    dead code
    on Aug 8, 2026
  2. moved this to Backlog in Orbit roadmapon Aug 8, 2026
  3. added
    size: large
    points: 8
    on Aug 8, 2026
  4. imshashank commented on Aug 8, 2026

    @imshashank
    ContributorAuthor

    Shares its hardest question with #215.

    audit_log.actor_type already exists and already defaults to user, which anticipated that agents and automation act too. #215 makes agents a first class actor with their own identity. The two issues have to agree on how an action is attributed when an agent does it on behalf of a human who authorised it, and the answer should be the same in the activity feed and in the audit log.

    Whichever lands first should decide it, and say so on the other thread. #193 has the same question for rule driven changes.

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

    area: databasedead codeenhancementhelp wantedp1 highpoints: 8securitysize: large

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions