[Draft] Concept upload history + rollback (P2-1) - #715
Closed
mvkonchits-db wants to merge 5 commits into
Closed
Conversation
Co-authored-by: Isaac
Co-authored-by: Isaac
Extract shared atomic bulk-event wrapper (_run_atomic_bulk_event) reused by both re-upload and rollback. Record-on-upload writes one upload_event row inside the same transaction. Rollback re-applies captured prev-state forward. Co-authored-by: Isaac
GET /semantic-models/uploads and POST /semantic-models/uploads/{event_id}/rollback,
registered above the /concepts/{concept_iri:path} catch-all.
Co-authored-by: Isaac
6 tests: event recorded w/ prev-state; rollback of modified restores prior definition forward (new version); rollback of add deprecates; rollback of remove restores active; rollback itself recorded; mid-rollback atomicity. Fix prev-state capture for file-imported concepts (v1 holds pre-upload snapshot). Co-authored-by: Isaac
Contributor
Author
|
Superseded by the concepts-v2 redesign (#734): the upload_event/rollback approach here was replaced by the upload_preview mechanism on feat/concepts-v2 (p1_upload_preview migration, upload_preview model/repository, orphan-version self-heal). Closing as obsolete. Note: #704 (reference-reconciliation split/merge) stays open — its worklist logic is not yet in #734. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DRAFT — not for review yet. Stacked on the diff engine (#705, which is itself on the versioning engine #703). Merge order: #703 → #705 → this. Held from review-ready until the full stack passes E2E together.
What this is (P2-1)
Records every file re-upload as an auditable event, and lets a steward roll one back. Backend only. Composes the diff engine's machinery — one new table (
upload_event), one migration (m5), single alembic head.Rollback is FORWARD, never a delete
The store is snapshot-per-version and append-only, so "roll back upload #N" does not delete anything — it re-applies each concept's pre-upload state as a NEW bulk versioning event. The rollback is itself recorded (auditable, and itself roll-back-able).
upload_event:{id, context_name, created_at, created_by, summary(JSON diff counts), concept_prev_state(JSON: per-concept {iri, prev_version|null, prev_status|null, bucket})}.apply_upload_as_versioning_eventcaptures prev-state before mutation and writes the event inside the same atomic closure — so an upload that rolls back writes no event.publish_concept_versionre-publishing V's frozen triples; new (was absent) →deprecate_concept(tombstone, never hard-delete); removed (was deprecated) → restore prior status._run_atomic_bulk_event(context, work_fn); both re-upload and rollback call it.commitis restored on both the except and finally paths.Endpoints (above the /concepts/{iri:path} catch-all)
GET /semantic-models/uploads?context=<ctx>(READ_ONLY) → newest-first[{id, created_at, created_by, summary}].POST /semantic-models/uploads/{event_id}/rollback(READ_WRITE + editable gate) →{event_id, rolled_back, summary}.Tests —
test_upload_rollback.py, 6 passed; diff-engine regression 6 passed (wrapper refactor safe)event recorded with correct prev-state · rollback of a modified upload restores the prior definition + mints a new version · rollback of an add deprecates (tombstone, resolvable) · rollback of a remove restores active · rollback recorded as a new event · mid-rollback failure leaves the store unchanged.
Not included
This pull request and its description were written by Isaac.