Invalidate dependent schemes on event edits + audit events CRUD & pins (#46) #71
No reviewers
Labels
No labels
area/ai
area/backend
area/frontend
area/infra
area/scheduler
area/wled
good-first-issue
priority/high
priority/low
priority/medium
type/bug
type/chore
type/ci-cd
type/docs
type/feature
type/qa
v1.0.0
v1.1.0
v1.2.0
v2.0.0
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/Iris-WLED!71
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/46-invalidation-audit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #46. Two spec gaps.
Invalidation (§4.3)
Editing an event's
phase_configor date range viaPUT /events/{id}now invalidates/stales dependent schemes (newinvalidate_for_event_change, sharing an_apply_invalidationhelper with the segment path). The dead per-segmentaffectedcomputation ininvalidate_for_segment_change(immediately overwritten byaffected = True) is simplified away, with a comment on why scoping is unsafe (an added segment is referenced by no existing scheme yet still requires full regen). Auto-regens now write a per-scheme audit row carrying the trigger (segment_change/event_edit).Note: "root scheme" from the spec text is not a field on
Event/EventUpdate, so it isn't reachable viaPUT /events/{id}; the two updatable triggers (phase_config, date range) are covered. Flagging in case a root-scheme field is intended later.Audit (§7.3)
event.create/update/deleteandevent_date_override.set/clearnow write audit rows with before/after snapshots (JSON-safe; dates ISO). The five admin handlers switched their auth dep to capture the actor.Verified:
ruff/format/mypyclean; 214 tests pass (only the known Windows-only backup file-lock errors remain, which pass on the Linux CI runner). New tests intest_scheme_generator.py+test_events_api.py.🤖 Generated with Claude Code
Spec gaps §4.3 (invalidation) and §7.3 (audit coverage). Invalidation: - Add invalidate_for_event_change() so editing an event's phase_config or date range via PUT /events/{id} regenerates its candidate schemes and stales its approved ones, matching segment-change behaviour. - Simplify away the dead per-segment `affected` computation in invalidate_for_segment_change (it was unconditionally forced True); keep the conservative "any segment change affects all schemes" behaviour, which is required to cover the added-segment case that per-segment scoping cannot detect. - Auto-regens now write a per-scheme audit row capturing the trigger (segment change / event edit), per §4.3. Audit coverage (§7.3): - event.create / event.update / event.delete write audit rows with before/after event snapshots. - event_date_override.set / .clear write audit rows with before/after event_id. Tests: event phase_config/date-range edits stale approved schemes; name-only edits do not; events CRUD and pin set/clear each write before/after audit rows; auto-regen writes a per-scheme audit row with the trigger. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>