Skip to content

feat(VAN-16): broader action taxonomy and per-triager activity log views#23

Merged
fr4nc1stein merged 3 commits into
mainfrom
fr4nc1stein/van-16-fill-gaps-in-activity-logs-module
May 29, 2026
Merged

feat(VAN-16): broader action taxonomy and per-triager activity log views#23
fr4nc1stein merged 3 commits into
mainfrom
fr4nc1stein/van-16-fill-gaps-in-activity-logs-module

Conversation

@fr4nc1stein

Copy link
Copy Markdown
Owner

Closes #22

Summary

Fills two of the three gaps in the Activity Logs module (/admin/activity-logs).


Item 1 — Broader action taxonomy

Added 5 new AuditAction types and wired them into the relevant routes:

Action Where it fires
comment_posted POST /api/reports/[id]/comments
template_used POST /api/reports/[id]/comments (when templateId is provided)
scope_created POST /api/admin/scopes
scope_updated PATCH /api/admin/scopes/[id]
scope_archived DELETE /api/admin/scopes/[id]

The page (/admin/activity-logs) now has icons and colour badges for all 15 known action types, including the 3 that were already in lib/audit.ts but missing from the UI (role_changed, user_suspended, user_unsuspended).

Item 2 — Per-triager scoped audit views

  • Activity logs API gate dropped from ADMIN to TRIAGER
  • When a TRIAGER calls the endpoint, actor_id is automatically forced to their own user ID — they only see their own actions
  • ADMINs continue to see all logs with full filter access
  • Export endpoint gets the same treatment
  • UI shows a blue info banner when the view is scoped: *"Showing your own actions only. Admins can view all platform activity."

Item 3 — Deferred

Retention policy controls depend on the Program Settings module — skipped for now.


Files changed

  • lib/audit.ts — +5 action types
  • app/api/reports/[id]/comments/route.ts — log comment_posted + template_used
  • app/api/admin/scopes/route.ts — log scope_created
  • app/api/admin/scopes/[id]/route.ts — log scope_updated, scope_archived
  • app/api/admin/activity-logs/route.ts — TRIAGER access + auto-scope
  • app/api/admin/activity-logs/export/route.ts — TRIAGER access + auto-scope
  • app/admin/activity-logs/page.tsx — full action type sync + scoped banner

🤖 Generated with Claude Code

fr4nc1stein and others added 3 commits May 25, 2026 23:37
- CLAUDE.md: added '5. Learn From Corrections' and '6. Autonomous Execution'
  sections based on Boris Cherny's CLAUDE.md patterns
- tasks/lessons.md: initial 23 lessons extracted from ISSUES.md, CHANGELOG.md,
  docs/agent.md, docs/SCHEMA_REFACTOR.md, docs/MIGRATION_ORDER.md, and AGENTS.md
  covering Cloudflare edge runtime, Next.js 16, auth/middleware, DB migrations,
  API design, security, and dev workflow patterns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Item 1 - Broader action taxonomy:
- lib/audit.ts: add 5 new AuditAction types (comment_posted, scope_created,
  scope_updated, scope_archived, template_used)
- app/api/reports/[id]/comments/route.ts: log comment_posted on POST
- app/api/admin/scopes/route.ts: log scope_created on POST
- app/api/admin/scopes/[id]/route.ts: log scope_updated on PATCH,
  scope_archived on DELETE; capture userId from requireRole
- app/admin/activity-logs/page.tsx: sync ACTION_TYPES/ICONS/COLORS with all
  known action types (added role_changed, user_suspended, user_unsuspended,
  comment_posted, scope_created, scope_updated, scope_archived, template_used)

Item 2 - Per-triager scoped audit views:
- app/api/admin/activity-logs/route.ts: drop gate to requireRole('TRIAGER');
  TRIAGERs are auto-scoped to their own actor_id; response includes scoped flag
- app/api/admin/activity-logs/export/route.ts: same TRIAGER access + auto-scope
- app/admin/activity-logs/page.tsx: show info banner when scoped=true

Retention policy (item 3) deferred -- depends on VAN-11 (Program Settings)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fr4nc1stein fr4nc1stein merged commit 6aff1ae into main May 29, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fill gaps in Activity Logs module

1 participant