Skip to content

feat(history): unified change history API - #456

Merged
stakach merged 2 commits into
masterfrom
feat/unified-history
Oct 19, 2026
Merged

stakach merged 2 commits into
masterfrom
feat/unified-history

Conversation

@stakach

@stakach stakach commented Oct 19, 2026

Copy link
Copy Markdown
Member

Part of PlaceOS/models#336

Exposes the unified change history from models (PlaceOS/models#337, #338), and attributes every change to the request that made it.

Changes

  • Request metadata: an Application around filter wraps each request in History.with_metadata.
    • history_metadata(request, current_user) records the user, the API key, X-App-Id/Name/Date/Build, the user agent, the client IP and the request id. Header values are capped at 256 characters.
    • The metadata is only built when a change is recorded, after authorize! has run.
    • authorize! now keeps the api_key it authenticated with.
  • GET /api/engine/v2/history (admin), newest first, paginated. It filters on:
    • resource_types and exclude_resource_types (table names)
    • resource_id
    • correlation_id
    • user_id
    • actions
    • period_start and period_end
  • GET /api/engine/v2/history/:id (admin): returns one entry.
  • POST /api/engine/v2/history/undelete?resource_type=&resource_id= (admin): restores the latest deleted version, keeping its id. It returns:
    • 201 with the restored record
    • 404 when there is nothing to restore
    • 409 when the record can't be saved, e.g. it already exists
  • /group_history: now returns History entries correlated to the group, with the same permissions as before. Breaking: the response shape changes from GroupHistory to History.
  • Groups: the acting_user assignments are removed, since changes are now attributed by the around filter.
  • Dependencies: placeos-models 9.122. OpenAPI docs are regenerated.

Review

  • New specs: spec/controllers/history_spec.cr
    • metadata from headers and API keys
    • each filter and pagination
    • show
    • undelete: restore, 404, 409, admin only
  • Updated: spec/controllers/groups/history_spec.cr also checks correlation, attribution and show.
  • Local results: both history spec files pass, 10 examples. ./test compiles out of memory in the local Docker VM, so I ran them with crystal spec on the host against the compose database. The full suite runs in CI.
  • Lint: ameba reports no new findings (the same 178 as master with the current ameba).
  • Not done: ts-client types follow in a separate PR.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the type: enhancement new feature or request label Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added type: enhancement new feature or request and removed type: enhancement new feature or request labels Oct 19, 2026
@stakach
stakach merged commit fbc585e into master Oct 19, 2026
11 checks passed
@stakach
stakach deleted the feat/unified-history branch October 19, 2026 23:37
@stakach stakach mentioned this pull request Oct 19, 2026
18 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement new feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant