Add history-based state changes and recompute pipeline

This commit is contained in:
2026-02-22 19:52:07 +03:00
parent c84102d2f1
commit ec54d3249e
22 changed files with 4973 additions and 32 deletions

View File

@@ -18,6 +18,7 @@
Registry invariants:
- Assets do not carry `project_id` in request/response contracts.
- Registry `PUT` mutations are history-backed (event + snapshot + projection update), not direct projection writes.
## Ingest
@@ -34,6 +35,29 @@ Manual CSV ingest contract:
- `GET /assets/{id}/timeline`
- `GET /components/{id}/timeline`
Legacy flat timeline routes remain available for compatibility during UI migration.
## History API
- `GET /api/history/jobs/{id}`
- `GET /api/history/components/{id}/events`
- `GET /api/history/assets/{id}/events`
- `POST /api/history/components/{id}/apply`
- `POST /api/history/assets/{id}/apply`
- `GET /api/history/components/{id}/timeline`
- `GET /api/history/assets/{id}/timeline`
- `DELETE /api/history/components/{id}/events/{event_id}`
- `DELETE /api/history/assets/{id}/events/{event_id}`
- `POST /api/history/components/{id}/rollback`
- `POST /api/history/assets/{id}/rollback`
History API invariants:
- `POST /api/history/*/apply` uses semantic dedupe (no-op changes do not create events/snapshots/timeline rows).
- Delete/rollback/hard-restore are asynchronous and return `202 Accepted` with `job_id`.
- Timeline endpoints are grouped by day by default (`UTC`, optional `tz` override).
- `DELETE .../events/{event_id}` is soft-delete + recompute enqueue (not physical delete).
- `POST .../rollback` supports `compensating` and `hard_restore` modes.
## Failures
- `GET /failures`
@@ -42,6 +66,7 @@ Manual CSV ingest contract:
## UI Routes
- `GET /ui`
- `GET /ui/search`
- `GET /ui/assets`
- `GET /ui/assets/{id}`
- `GET /ui/components`
@@ -81,3 +106,4 @@ Rules:
- API router is registered in `internal/api/server.go`.
- Registry, ingest, failures, asset/component pages, and UI routes are attached to `http.ServeMux`.
- History API routes and background history worker are also wired from `internal/api/server.go`.