feat(audit): record project assignments in the workspace audit log #428

Merged
sharang merged 1 commits from feat/projects-audit into main 2026-09-29 14:34:35 +00:00
Owner

Why

From the user's test of #427: assigning a Prüfobjekt to a project, or removing it from one, did not appear in the workspace audit log.

What

  • PATCH /api/v1/targets/{id} with project_ids that actually change writes to POST /v1/audit. The payload follows the contract agreed with the portal session:
    • action: target.projects_changed, product: pruefwerk;
    • actor_type: user, or staff under support access; actor_id is the sub, actor_name the name or "BreakPilot-Support (Name)";
    • target_type: target, target_id (24-hex), target_name;
    • metadata: {added: [{id, name}], removed: [{id, name}]}. Names come from the cached registry list; a deleted project has name: "".
  • A no-op PATCH writes nothing. The write is background and best-effort, and a registry outage never fails the PATCH.
  • AuditEntry gains product, actor_type and target_*; the support-access audit (#425) now carries product and actor_type too.

Tests

  • change audited with names, including a deleted project
  • staff actor type; no-op → no entry
  • core/agent suites; clippy (CI flags); fmt

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

## Why From the user's test of #427: assigning a Prüfobjekt to a project, or removing it from one, did not appear in the workspace audit log. ## What - `PATCH /api/v1/targets/{id}` with `project_ids` that actually change writes to `POST /v1/audit`. The payload follows the contract agreed with the portal session: - `action: target.projects_changed`, `product: pruefwerk`; - `actor_type`: `user`, or `staff` under support access; `actor_id` is the sub, `actor_name` the name or "BreakPilot-Support (Name)"; - `target_type: target`, `target_id` (24-hex), `target_name`; - `metadata: {added: [{id, name}], removed: [{id, name}]}`. Names come from the cached registry list; a deleted project has `name: ""`. - A no-op PATCH writes nothing. The write is background and best-effort, and a registry outage never fails the PATCH. - `AuditEntry` gains `product`, `actor_type` and `target_*`; the support-access audit (#425) now carries `product` and `actor_type` too. ## Tests - change audited with names, including a deleted project - staff actor type; no-op → no entry - core/agent suites; clippy (CI flags); fmt 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-09-29 14:27:10 +00:00
feat(audit): record project assignments in the workspace audit log
CI / Check (push) Skipped
CI / Check (pull_request) Successful in 7m20s
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
b3eba1521c
A change of a target's projects (PATCH with a real difference) writes
target.projects_changed to the registry's audit log: who (user, or staff
under support access), which target, and the projects added and removed
by name (a deleted project with an empty name). Background and
best-effort; a no-op writes nothing. Audit entries now carry product,
actor_type and the target they concern.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 001ab17b47 into main 2026-09-29 14:34:35 +00:00
Sign in to join this conversation.