Files
co-lite/openspec/changes/archive/2026-11-30-add-admin-audit-log/tasks.md
T

4.8 KiB

Tasks

Design: design.md. All tasks run serially: each builds on the one before.

1. Data and contract

  • 1.1 SQL and Pub/Sub topic.
    • Files:
      • sql/01-audit-event.sql: CREATE TABLE IF NOT EXISTS service-log.audit_event (design decision 2).
      • sql/02-audit-log-module.sql: the module row (design decision 10).
      • sql/99-rollback.sql.
    • Mirror 01 and 02 in local/seed/03-colite.sql, and add audit-event-topic audit-event-subscription to local/pubsub/topics.txt.
    • Apply them to the local database and emulator. This is local only.
    • Scope: local/**, openspec/changes/add-admin-audit-log/sql/**
    • Verify: select shows the table and the module row.
  • 1.2 core-libs AuditEvent (design decision 1).
    • Tests first: JSON round trip through the same PubSubUtil used for ResponseTime.
    • Scope: solvway-core-libs/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-core-libs verify

2. services-log

  • 2.1 Storage, listener, purge and read endpoints (design decision 7).
    • Tests first:
      • the listener saves an event with every field;
      • search filters by actor, module, action, outcome and dates, returns newest first, caps the size at 100, and rejects a bad date with 400;
      • detail answers 404 for an unknown id;
      • the purge deletes only rows older than the retention and reads the env setting.
    • Scope: solvway-services-log/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-services-log -am verify

3. mobile-api

  • 3.1 Recording in AppAccessAspect, with Audited and AuditChanges (design decisions 3, 4 and 6).
    • Add annotations on the lead export, the event-lead export, the email detail (sensitive) and event-lead match (skip).
    • Tests first:
      • a write records every field: actor, module, action, method, template, target, outcome and IP;
      • the derived and the explicit action codes;
      • a non-2xx response and a thrown status exception record FAILURE with the status;
      • a 403 refusal for a valid user is recorded;
      • plain GETs, skipped POSTs and the auth endpoints (except first-login) are not recorded;
      • a call without a user is not recorded;
      • a publish failure does not change the response;
      • AuditChanges content lands in changes and is cleared between requests.
    • Scope: solvway-mobile-api/src/**
    • Verify: mvn -T 1C -B -q -pl solvway-mobile-api -am verify
  • 3.2 Allow-listed changes from the services (design decision 5).
    • Tests first, one per service:
      • user role names and enabled flag before and after;
      • role modules added and removed;
      • lead and event-lead edits record field names only, and no value appears anywhere in changes;
      • login-security config and rules before and after.
    • Scope: solvway-mobile-api/src/main/java/**/service/** plus their tests
    • Verify: mvn -T 1C -B -q -pl solvway-mobile-api -am verify
  • 3.3 AdminAuditLogController and the read service (design decision 8).
    • Tests first:
      • the class-level module;
      • parameter mapping;
      • a 404 for an unknown id;
      • only the given filters are forwarded.
    • Scope: solvway-mobile-api/src/** (new audit-log files, constants, tests)
    • Verify: mvn -T 1C -B -q -pl solvway-mobile-api -am verify
    • Live check through the stack:
      • edit a user and see the event with its changes;
      • noevents creating an event is recorded as FAILURE;
      • opening an email is recorded.

4. Portal

  • 4.1 /audit-log list and /audit-log/[id] detail, with a proxy, a service and i18n keys (design decision 9).
    • Tests first:
      • rows and filters go into the query;
      • the detail shows a before/after table and a field-name list;
      • RequireModule gates the page;
      • the proxy is GET only and refuses dot segments.
    • Scope: solvway-admin-portal/app/audit-log/**, solvway-admin-portal/app/api/audit-log/**, solvway-admin-portal/app/lib/**
    • Verify: cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build

5. Check and docs

  • 5.1 Browser check and handover.
    • Playwright on the local stack:
      • as admin, change a user's roles, change a role's grants, edit a lead, open an email and export leads, then see each in Audit log with its changes;
      • as noevents, try a forbidden action and see it as FAILURE;
      • noevents has no Audit log menu entry and sees Not authorized at /audit-log;
      • the list fits at 1280 px, and the pages work at 360 px.
    • Docs, in docs/deployment.md:
      • section 3: the new SQL;
      • section 5: the new topic and subscription;
      • section 6: AUDIT_RETENTION_DAYS.
    • Scope: docs/deployment.md
    • Verify: screenshots, and the steps above observed.

Workflow follow-up

  • Whole-branch review, push, PR to main and merge, then archive on its own branch.