Skip to content

Commit 65654a2

Browse files
rustyconoverclaude
andcommitted
table_buffering: FrameworkNS prefix + drop wire flag + rename from TableSinkSource
Three coupled landings: * FrameworkNS enum (vgi.function_storage) reserves the b"_vgi/" prefix for framework-owned storage namespaces. BoundStorage.state_* rejects raw bytes with that prefix and accepts FrameworkNS members verbatim; framework callsites in worker.py and table_in_out_function.py migrated off bare bytes literals (b"agg" / b"win" / b"buf_init" / b"streaming_finalize" / b"sd"). User-owned fixture namespaces keep their freely-chosen names. * Rename TableSinkSourceFunction -> TableBufferingFunction throughout: module, params, finalize-state, RPC method names, phase strings, FrameworkNS members. The Sink+Source name exposed the C++ operator shape rather than what users think they're doing ("buffer all input, emit at end"). * Drop the redundant table_buffering bool on the catalog wire. CatalogFunctionType and FunctionType gain TABLE_BUFFERING values; the class hierarchy resolves there directly via _CLASS_NAME_TO_FUNCTION_TYPE, the auto-set + Meta.table_buffering attribute go away, and downstream consumers derive routing from function_type alone. Single source of truth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 591b132 commit 65654a2

14 files changed

Lines changed: 1489 additions & 1080 deletions

‎.beads/issues.jsonl‎

Lines changed: 84 additions & 0 deletions
Large diffs are not rendered by default.

‎tests/test_function_storage.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,44 @@ def test_facade_state_put_get_roundtrip(self, storage: FunctionStorageSqlite) ->
233233
assert bs.state_get(b"agg", b"k1") == b"v1"
234234
assert bs.state_get(b"agg", b"missing") is None
235235

236+
def test_facade_rejects_reserved_ns_prefix(self, storage: FunctionStorageSqlite) -> None:
237+
"""User-supplied bytes starting with b"_vgi/" are rejected at every state_* entry."""
238+
import pytest
239+
240+
from vgi.function_storage import BoundStorage
241+
242+
bs = BoundStorage(storage, b"exec1", attach_opaque_data=b"a")
243+
reserved = b"_vgi/anything"
244+
with pytest.raises(ValueError, match="reserved prefix"):
245+
bs.state_get(reserved, b"k")
246+
with pytest.raises(ValueError, match="reserved prefix"):
247+
bs.state_put(reserved, b"k", b"v")
248+
with pytest.raises(ValueError, match="reserved prefix"):
249+
bs.state_get_many(reserved, [b"k"])
250+
with pytest.raises(ValueError, match="reserved prefix"):
251+
bs.state_put_many(reserved, [(b"k", b"v")])
252+
with pytest.raises(ValueError, match="reserved prefix"):
253+
bs.state_scan(reserved)
254+
with pytest.raises(ValueError, match="reserved prefix"):
255+
bs.state_drain(reserved)
256+
with pytest.raises(ValueError, match="reserved prefix"):
257+
bs.state_delete(reserved)
258+
with pytest.raises(ValueError, match="reserved prefix"):
259+
bs.state_append(reserved, b"k", b"v")
260+
with pytest.raises(ValueError, match="reserved prefix"):
261+
bs.state_log_scan(reserved, b"k")
262+
263+
def test_facade_framework_ns_member_passes_through(self, storage: FunctionStorageSqlite) -> None:
264+
"""FrameworkNS members bypass the reserved-prefix check and resolve to their bytes value."""
265+
from vgi.function_storage import BoundStorage, FrameworkNS
266+
267+
bs = BoundStorage(storage, b"exec1", attach_opaque_data=b"a")
268+
bs.state_put(FrameworkNS.AGGREGATE_STATE, b"k1", b"v1")
269+
assert bs.state_get(FrameworkNS.AGGREGATE_STATE, b"k1") == b"v1"
270+
# Same key under a raw user namespace must NOT see the framework
271+
# write — they live in different ns rows.
272+
assert bs.state_get(b"agg", b"k1") is None
273+
236274
def test_facade_pack_int_key(self) -> None:
237275
"""pack_int_key is little-endian, signed, 8 bytes — round-trips to int.from_bytes."""
238276
from vgi.function_storage import BoundStorage

0 commit comments

Comments
 (0)