--- kind: task slug: audit-instrument-markdown-importer title: Audit-instrument the markdown-backlog importer plan_slug: multitenant-saas-hardening epic_slug: tenant-lifecycle status: draft priority: P2 tenant_id: global owner: unassigned cursor_todo_id: null updated_at: "2026-06-02" --- # Task summary The markdown-backlog importer runs as a file-watcher process (see `packages/database/src/markdown-backlog/`) and writes to `markdown_backlog_items` outside of any tRPC procedure context. Right now those writes leave no audit trail. `recordAudit()` already supports system actors (`actorUserId = null` with a `metadata.system_actor` string), so the importer just needs to call it on its meaningful state changes. ## Subtasks - [ ] Decide which importer events are audit-worthy: - `markdown_backlog.import_run_start` — once per sync sweep, metadata `{ files_changed: N }`. - `markdown_backlog.item_create` / `item_update` / `item_archive` — per row. - The first option is concise; the second is granular. Pick one. - [ ] Wire `recordAudit` calls from the importer. - [ ] Verify the audit-view UI handles `actor_user_id = null` cleanly (it does today; it renders "system: markdown-importer" when `metadata.system_actor` is set). ## Acceptance criteria - [ ] Importer writes at least one audit row per sync sweep. - [ ] The audit view shows those rows with a "system: markdown-importer" actor label. ## Links - Parent: `./Task-workspace-soft-delete-and-audit.md` - Epic: `./Epic-tenant-lifecycle.md`