mirror of
https://github.com/turnstonelabs/turnstone.git
synced 2026-08-12 23:12:23 -06:00
8513016503
Operator context moved to first-class system turns, leaving _reminders written by nothing and read by nothing. Nulling it (the prior 060 step) left a writable dead column — a foot-gun inviting accidental reuse. Drop it outright and remove every reference in one shot so there is no half-alive state: - migration 060: replace the wholesale null with batch_alter_table drop_column (per migration 027); downgrade re-adds the empty column to match the 059 schema (the envelope un-wrap stays irreversible). - _schema.py: remove the column. - _sqlite / _postgresql: drop the reminders save param, the INSERT/bulk values, and both SELECT columns. - reconstruct_messages: the row tuple is now 8/9-tuple (event_id shifts from index 9 to 8); _utils + the _row test helper updated. - _protocol / memory save_message: drop the reminders param + docstrings. - tests: replace the reminders-roundtrip tests with a _source-only file and a 060 drop-column assertion; remove the obsolete legacy-reminders wire test. No production caller passed reminders=, and the SELECT no longer reads the column, so an un-migrated DB simply ignores any residual values.
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
"""Tests for the ``_source`` storage column round-tripping through both backends.
|
|
|
|
``_source`` mirrors the in-memory side channel — which producer synthesised the
|
|
row (a wake ``system_nudge`` or an operator-context kind on a ``system`` turn).
|
|
(The sibling ``_reminders`` column was dropped in migration 060; operator
|
|
context lives in first-class ``system`` turns now.)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
class TestSourceRoundtrip:
|
|
def test_source_roundtrip(self, backend):
|
|
backend.register_workstream("s1")
|
|
backend.save_message("s1", "user", "", source="system_nudge")
|
|
msgs = backend.load_messages("s1")
|
|
assert len(msgs) == 1
|
|
assert msgs[0]["role"] == "user"
|
|
assert msgs[0]["content"] == ""
|
|
assert msgs[0].get("_source") == "system_nudge"
|
|
|
|
def test_source_absent_when_not_set(self, backend):
|
|
backend.register_workstream("s1")
|
|
backend.save_message("s1", "user", "hello")
|
|
msgs = backend.load_messages("s1")
|
|
assert "_source" not in msgs[0]
|
|
|
|
def test_nul_bytes_stripped_from_source(self, backend):
|
|
"""NUL bytes must be stripped from ``_source`` at the storage layer.
|
|
|
|
Producers strip NUL today, but the layer is the tripwire if a future
|
|
producer forgets — and PostgreSQL TEXT columns reject NUL outright.
|
|
"""
|
|
backend.register_workstream("s1")
|
|
backend.save_message("s1", "user", "", source="system_nudge\x00")
|
|
msgs = backend.load_messages("s1")
|
|
assert msgs[0].get("_source") == "system_nudge"
|