Skip to content

fix(audit): use semantic database object names - #653

Draft
seonghobae wants to merge 14 commits into
developfrom
fix/audit-log-semantic-database-names
Draft

fix(audit): use semantic database object names#653
seonghobae wants to merge 14 commits into
developfrom
fix/audit-log-semantic-database-names

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Purpose

Repair the ScopeWeave Audit Trail persistence vocabulary so organization-owned SQLite identifiers are semantically specific while preserving the established /api/orgs/:id/audit, audit CSV, and workspace-export wire contracts.

TDD evidence

The branch was cut from protected develop@2c328875e00e86537df3e965170be80532571cad. A regression was introduced before production repair to require semantic Audit Trail storage, preserve seeded legacy audit data through migration, and replace the generic audit index. Final tests now cover fresh storage, realistic legacy migration, idempotent reopen, semantic index creation, and wire compatibility. Predecessor/base results are not used as final evidence.

Persistence repair

The authoritative durable relation is now audit_events with audit_event_id, audit_action, and audit_metadata_json, plus audit_events_org_event_idx(org_id, audit_event_id). Production audit writes and durable reads use those names directly.

A historical audit_log is handled only as a startup migration source. Migration validates an unambiguous legacy/intermediate shape, refuses dual populated authorities, copies and removes the legacy table/indexes inside BEGIN IMMEDIATE, and rolls back on failure. Existing foreign-key semantics, one-event-per-row 3NF shape, append-only/no-UPSERT behavior, tenant hot read path, and runtime read/write topology remain unchanged.

Compatibility boundary

Historical public fields id, action, and meta remain unchanged for JSON, CSV, and workspace export. They are produced by explicit SQL aliases in the web adapter; no durable or temporary audit_log compatibility object remains.

Documentation

ARCHITECTURE.md, CHANGELOG.md, docs/doctoring/audit-persistence-semantic-naming.md, and docs/product-technical-gap-baseline.md record old→new terminology, bounded-context rationale, migration/rollback behavior, compatibility ownership, and exact source evidence.

Merge discipline

Fresh required GitHub verification and qualifying independent current approval are required on the unchanged final head before merge. No force push, bypass, self-approval, stale status transfer, or weakened test/security gate is acceptable.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae seonghobae added bug Something isn't working priority: medium Normal-priority or P2 work status: draft Draft pull request type: bug Defect or incorrect behavior labels Sep 2, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: medium Normal-priority or P2 work status: draft Draft pull request type: bug Defect or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant