Invalidate dependent schemes on event edits + audit events CRUD & pins (#46) #71

Merged
claude-bot merged 1 commit from fix/46-invalidation-audit into main 2026-07-16 07:13:30 +00:00
Contributor

Closes #46. Two spec gaps.

Invalidation (§4.3)

Editing an event's phase_config or date range via PUT /events/{id} now invalidates/stales dependent schemes (new invalidate_for_event_change, sharing an _apply_invalidation helper with the segment path). The dead per-segment affected computation in invalidate_for_segment_change (immediately overwritten by affected = 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 via PUT /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/delete and event_date_override.set/clear now 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/mypy clean; 214 tests pass (only the known Windows-only backup file-lock errors remain, which pass on the Linux CI runner). New tests in test_scheme_generator.py + test_events_api.py.

🤖 Generated with Claude Code

Closes #46. Two spec gaps. ### Invalidation (§4.3) Editing an event's `phase_config` or date range via `PUT /events/{id}` now invalidates/stales dependent schemes (new `invalidate_for_event_change`, sharing an `_apply_invalidation` helper with the segment path). The dead per-segment `affected` computation in `invalidate_for_segment_change` (immediately overwritten by `affected = 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 via `PUT /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/delete` and `event_date_override.set/clear` now 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`/`mypy` clean; 214 tests pass (only the known Windows-only backup file-lock errors remain, which pass on the Linux CI runner). New tests in `test_scheme_generator.py` + `test_events_api.py`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fix #46: invalidate dependent schemes on event edits; audit events CRUD & pins
All checks were successful
CI / Python lint & type-check (pull_request) Successful in 1m9s
CI / Alembic migration check (pull_request) Successful in 42s
CI / Python tests (pull_request) Successful in 2m1s
CI / Frontend lint, test & build (pull_request) Successful in 1m33s
CI / Dependency audit (pull_request) Successful in 1m38s
CI / Docker build, health smoke & E2E (pull_request) Successful in 3m4s
f1b3c01721
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>
claude-bot deleted branch fix/46-invalidation-audit 2026-07-16 07:13:31 +00:00
Sign in to join this conversation.
No description provided.