feat(projection): add complete observation day gate (issue #94)
This commit is contained in:
@@ -117,6 +117,33 @@ def _open_period(conn, start="2026-09-01T00:00:00+00:00"):
|
||||
ensure_period_open(conn, datetime.fromisoformat(start))
|
||||
|
||||
|
||||
def _insert_local_day(conn, local_date, tz_name="UTC", tz_offset="+00:00",
|
||||
utc_start=None, utc_end=None, bw=1024*1024*100,
|
||||
br=0, coverage=0.95, samples=24, complete=True):
|
||||
"""Insert a local_days row (issue #94 gate prerequisite)."""
|
||||
if utc_start is None:
|
||||
utc_start = local_date + "T00:00:00+00:00"
|
||||
if utc_end is None:
|
||||
dt = datetime.strptime(local_date, "%Y-%m-%d") + timedelta(days=1)
|
||||
utc_end = dt.strftime("%Y-%m-%dT00:00:00+00:00")
|
||||
conn.execute(
|
||||
"INSERT INTO local_days "
|
||||
"(local_date, tz_name, tz_offset, utc_start, utc_end, "
|
||||
" bytes_written, bytes_read, coverage, sample_count, complete) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
(local_date, tz_name, tz_offset, utc_start, utc_end,
|
||||
bw, br, coverage, samples, complete),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
|
||||
def _insert_complete_local_days(conn, start_date, count, bw=1024*1024*100):
|
||||
"""Insert multiple complete local days to satisfy the issue #94 gate."""
|
||||
for i in range(count):
|
||||
d = (datetime.strptime(start_date, "%Y-%m-%d") + timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
_insert_local_day(conn, d, bw=bw)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Unit tests for helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -184,6 +211,7 @@ class TestStateMatrix:
|
||||
d = (datetime(2026, 9, 20) + timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
_insert_day(conn, d, bw=1024*1024*100)
|
||||
_insert_sample(conn, "2026-09-30T10:00:00+00:00")
|
||||
_insert_complete_local_days(conn, "2026-09-29", 1)
|
||||
proj = compute_projection(conn, _clock())
|
||||
assert proj.confidence_state == ConfidenceState.LIMITED
|
||||
assert proj.headline_remaining_seconds is not None
|
||||
@@ -199,6 +227,7 @@ class TestStateMatrix:
|
||||
d = (datetime(2026, 9, 1) + timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
_insert_day(conn, d, bw=1024*1024*100, coverage=0.95, samples=24)
|
||||
_insert_sample(conn, "2026-09-30T10:00:00+00:00")
|
||||
_insert_complete_local_days(conn, "2026-09-29", 1)
|
||||
proj = compute_projection(conn, _clock())
|
||||
assert proj.confidence_state == ConfidenceState.SUPPORTED
|
||||
assert proj.headline_remaining_seconds is not None
|
||||
|
||||
Reference in New Issue
Block a user