DAO layer for task_instances and append-only completion_events #21

Member

Adds dao_instances.py: TaskInstancesDao (upsert idempotent on (definition_id, due_date) via ON CONFLICT, get/get_by_id, list by child+date, list by closed date range, delete_future_uncompleted with NOT EXISTS completion_events guard inside a transaction) and CompletionEventsDao (append with full actor-pair validation, list_by_instance, list_by_child_and_date_range with due-date or occurred-at scope, get_latest_for_instance). NO update/delete methods on the completion-events DAO; package-wide mutation-SQL guard test. 28 new tests; suite 449 passed.

Adds dao_instances.py: TaskInstancesDao (upsert idempotent on (definition_id, due_date) via ON CONFLICT, get/get_by_id, list by child+date, list by closed date range, delete_future_uncompleted with NOT EXISTS completion_events guard inside a transaction) and CompletionEventsDao (append with full actor-pair validation, list_by_instance, list_by_child_and_date_range with due-date or occurred-at scope, get_latest_for_instance). NO update/delete methods on the completion-events DAO; package-wide mutation-SQL guard test. 28 new tests; suite 449 passed.
orchestrator-agent added 1 commit 2026-09-14 08:10:43 -04:00
overseer added 1 commit 2026-09-14 08:17:52 -04:00
- upsert refuses due_dates before today (never generate in the past)
  and refuses regeneration of any instance carrying a completion event
  (immutability); the ON CONFLICT refresh only ever touches open
  instances
- delete_future_uncompleted clamps the cutoff to today so backdating
  cannot rewrite past open instances
- occurred_at enforces ONE strict UTC shape (YYYY-MM-DDTHH:MM:SS+00:00)
  at append; occurred-at range scope uses exact half-open bounds
- was_on_time: bool | None with type(was_on_time) is bool validation -
  0.5 silently coercing to False is rejected
- append-only guards hardened: package-wide mutation regex covers
  UPDATE OR IGNORE/qualified names/quotes, DAO INSERT exempted
  narrowly; behavioral call-interception test proves only INSERT/SELECT
  ever reach the DB for completion_events; compensating self-scan for
  the instances test file's rules-table exemption
overseer added 1 commit 2026-09-14 08:24:19 -04:00
- upsert re-checks 'today' after acquiring the connection lock (call
  date can go stale while queued across midnight); delete cutoff
  clamps to the lock-time date too
- mutation regex now matches INSERT [OR x] INTO completion_events;
  test_schema.py's raw-SQL CHECK-constraint helper exempted narrowly
  via INSERT-strip, guard file self-scanned
- NOW replaced by _now_stamp() (today 08:00 UTC, computed at call
  time); occurred-at test derives its query date from the stamp so it
  is midnight-safe
- new rollover-contention test: a lock holder delays A's upsert across
  a shifted clock; the in-lock re-check rejects the now-past date
overseer added 1 commit 2026-09-14 08:27:00 -04:00
Both comparisons now use the recorded value, never a fresh clock read,
so a midnight boundary mid-test cannot flake them.
orchestrator-agent merged commit 12bb4d58b4 into feature/8940567d-7b50-41ef-a510-8b234fe7290e-sqlite-data-layer 2026-09-14 08:28:01 -04:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Maniacs_Mansion/NestQuest#21