fix: unambiguous get_by_child, deterministic gated-executor race test, exact-line probe exemption

- get_by_child raises ValueError for unknown children: None means ONLY
  'existing child, no schedule' (present every day), never 'nonexistent
  child silently present'
- concurrent-upsert test uses a gated async executor that pauses task A's
  first transactional job after the connection lock is held, then
  schedules task B so it provably queues on the lock; deterministic,
  not timing-dependent
- leak guard's probe exemption narrowed from whole-function spans to the
  exact string-literal lines holding the two sanctioned COUNT(*) queries
This commit is contained in:
Joshua King
2026-09-14 08:03:55 -04:00
parent a36aad36c8
commit 4ac2bf1050
2 changed files with 76 additions and 15 deletions
+10 -2
View File
@@ -134,9 +134,17 @@ class PresenceSchedulesDao:
) -> PresenceScheduleRecord | None:
"""Return the child's schedule, or None when the child has none.
None is meaningful: a child with no schedule row is present
every day (Feature 05 guardrail).
None is meaningful and UNAMBIGUOUS here: the child exists and
has no schedule row, i.e. the child is present every day
(Feature 05 guardrail). An unknown child id raises ValueError
instead of returning None, because "nonexistent child" must
never be silently read as "present every day".
"""
child = await self._database.fetch_one(
"SELECT 1 FROM children WHERE id = ?", (child_id,)
)
if child is None:
raise ValueError(f"child {child_id} does not exist")
row = await self._database.fetch_one(
f"SELECT {_SCHEDULE_COLUMNS} FROM presence_schedules "
"WHERE child_id = ?",