Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f30ed2f
fix(sources)!: refuse reserved column names instead of dropping them …
eywalker Nov 28, 2026
afb14bc
test(semijoin): use a legal column name in the warning test
eywalker Nov 28, 2026
f385fb1
chore: merge main for the API reference fix
eywalker Nov 28, 2026
a54db1e
fix(sources): validate raw fields before source inference and projection
eywalker Nov 28, 2026
f48740e
chore: merge main for the updated PR test matrix
eywalker Nov 28, 2026
151737f
test(pods): verify the custom function fixture implements the protocol
eywalker Nov 28, 2026
76f1864
fix(sources): reject unsafe Python frame row layouts
eywalker Nov 28, 2026
79d90d1
fix(sources): validate Pydantic row fields and raw CSV headers
eywalker Nov 28, 2026
e11236a
chore: merge main for SemiJoin async support
eywalker Nov 28, 2026
8800e42
chore: merge main and verify output validation order
eywalker Nov 28, 2026
4905e19
fix(validation): close reserved column review gaps
eywalker Nov 28, 2026
6ff1f79
fix(validation): refuse reserved keys on pod cache hits and close rev…
eywalker Nov 28, 2026
2ed7126
Merge remote-tracking branch 'origin/main' into eywalker/itl-1165-res…
eywalker Nov 28, 2026
4f5bf1f
fix(validation): refuse reserved names on stored result reads
eywalker Nov 28, 2026
9d6b760
Merge remote-tracking branch 'origin/main' into eywalker/itl-1165-res…
eywalker Nov 28, 2026
62f7e4f
fix(validation): check raw frame and callback tag names before conver…
eywalker Nov 28, 2026
8021d6a
fix(sources): preserve compatible Polars row layouts
eywalker Nov 28, 2026
5498fb0
Merge remote-tracking branch 'origin/main' into eywalker/itl-1165-res…
eywalker Nov 28, 2026
a3d295a
fix(sources): preserve lossless mixed frame rows
eywalker Nov 28, 2026
fbac66e
fix(sources): restore DataFrameSource row conversion
eywalker Nov 28, 2026
a941f55
fix(sources): validate reserved names on the pinned SpiralDB snapshot
eywalker Nov 28, 2026
71aaf21
chore: merge origin/main into PR 616
eywalker Nov 28, 2026
6305579
chore: merge origin/main into PR 616
eywalker Nov 28, 2026
af0547b
test(sources): cover both mixed row layouts
eywalker Nov 28, 2026
9a578a6
chore(merge): bring main into the reserved column names branch
eywalker Nov 28, 2026
1c7f1e3
chore(merge): bring main into the reserved column names branch
eywalker Nov 28, 2026
67ca6ab
chore(merge): bring main into the reserved column names branch
eywalker Nov 29, 2026
e6f2e3f
fix(validation): close reserved column review gaps
eywalker Nov 29, 2026
7807c50
Merge remote-tracking branch 'origin/main' into eywalker/itl-1165-res…
eywalker Nov 29, 2026
57fb2f7
chore(merge): bring main into the reserved column names branch
eywalker Nov 29, 2026
b3565b9
chore(merge): bring main into the reserved column names branch
eywalker Nov 29, 2026
15ed2fe
chore(merge): bring main into the reserved column names branch
eywalker Nov 30, 2026
fff89bb
fix(schema)!: reserve leading underscores at user column boundaries
eywalker Nov 30, 2026
7368dbc
chore(merge): reconcile user column validation with main
eywalker Nov 30, 2026
9b89eab
test(datagrams): use the internal route for metadata fixtures
eywalker Nov 30, 2026
e244d8d
fix(schema): keep the reserved column diagnostic internal
eywalker Nov 30, 2026
d324066
Merge remote-tracking branch 'origin/main' into eywalker/itl-1165-res…
eywalker Nov 30, 2026
aaaabba
fix(sources): preserve source reads under reserved name validation
eywalker Nov 30, 2026
cc6c528
chore: merge main into reserved column validation
eywalker Nov 30, 2026
2455fc9
fix(spiraldb): reject key-only historical snapshots
eywalker Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .zed/rules
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,11 @@ of its identity (GroupBy's member_order), never the input's column order.

### Column naming conventions

All column names beginning with `_` are reserved for Orcapod (ITL-1165). Sources refuse
raw input with these names and tell callers to rename the columns or drop them first.
Sources, raw Arrow streams, operators and function pods validate user column names
with `schema_utils.require_names_not_system`.

__ prefix — System metadata (ColumnConfig meta)
_source_ prefix — Source info provenance (ColumnConfig source)
_input_source_ prefix — Source-info provenance of an input data column as stored by a
Expand Down
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,11 @@ of its identity (GroupBy's `member_order`), never the input's column order.

### Column naming conventions

All column names beginning with `_` are reserved for Orcapod (ITL-1165). Sources refuse
raw input with these names and tell callers to rename the columns or drop them first.
Sources, raw Arrow streams, operators and function pods validate user column names
with `schema_utils.require_names_not_system`.

| Prefix | Meaning | Example | Controlled by |
|--------|---------|---------|---------------|
| `__` | System metadata | `__data_id`, `__pod_version` | `ColumnConfig(meta=True)` |
Expand Down
25 changes: 25 additions & 0 deletions changelog.d/ITL-1165.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### Breaking changes and migration

- Names beginning with `_` are reserved for Orcapod. This applies to user tags and
data columns in sources, declared schemas and raw Arrow streams, function pod
outputs, operator outputs and renames, and derived tag copies. Loading a saved
configuration with a reserved user column name raises an error. Rename these
columns and update downstream references before saving a new configuration.
Use `stream.as_table()` to export user-facing columns for a new source.

### Fixed

- `Pick` and `Index` reject reserved `out` names at construction, so their output
columns stay visible in stream tables.
- Manual function result cache writes refuse reserved user output keys. A cache
lookup that finds a stored result with a reserved output key fails the job run.
Replay and provenance reads also refuse to reconstruct such rows.
- Operator caches and cached sources refuse stored user columns in the reserved
namespace before presenting their rows.
- Raw Arrow and polling sources report reserved column names before validating
their Arrow types.
- `DataFrameSource` checks the column names of input frames and of the frame inferred
from Python data. `PollingSource` checks the inferred columns of Python batches.
List sources check user names in each callback result before requesting more tags.
Dictionary sources check declared names before reading and each row from a custom
collection before asking for the next.
9 changes: 3 additions & 6 deletions docs/concepts/provenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,9 @@ columns (`stream.as_table(columns={"source": True})`).
not valid: the missing inner list would have to be a list, `[[], ["a"]]` or
`[[null], ["a"]]`.

Orcapod's sources, operators and functions always keep these rules. They matter when you
build a table with `_source_*` columns by hand and hand it to `ArrowTableStream`: a list
token over a value that is not a list, a list of another kind (a fixed-size list of tokens
needs a fixed-size list of values of the same size), more list levels in the token than in
the value, a token that is not text, or a missing list of tokens at any level is refused with
`InputValidationError`, which names the token column, its data column and both types.
Use the `source_info` argument when supplying your own tokens to `ArrowTableStream`.
Orcapod checks that the token types and nesting match the data columns. An
`InputValidationError` identifies the token column, its data column and both types.

One case reaches ordinary pipelines. A `Batch` of single values and a source that already
holds lists of them have the same values but different tokens: a list of tokens (one per
Expand Down
7 changes: 7 additions & 0 deletions docs/concepts/sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ dependencies -- it sits at the root of the computational graph. Key properties:

### Concrete source types

Names beginning with `_` are reserved for Orcapod. Rename or drop any such columns
before passing data or a schema to a source. If you have the original stream,
`stream.as_table()` gives you the user-facing columns for a new source.

All sources follow the same pattern: convert input data to a PyArrow Table, then pass it
through `SourceStreamBuilder` which handles enrichment (provenance columns, system tags,
hashing) and produces the final immutable stream.
Expand Down Expand Up @@ -379,6 +383,9 @@ categorical column) is not a dictionary column: it is a library value, stored an
(see [Arrays and other library values](arrays.md)), and is accepted. Supporting
dictionary-encoded columns themselves is future work (ITL-1277).

`DataFrameSource` uses Polars to infer the columns of Python inputs and checks the
resulting column names for reserved names.

### A bare list of key/value structs is a dict

A `dict[K, V]` column is stored as a list of structs with the two fields `key` and `value`,
Expand Down
7 changes: 7 additions & 0 deletions docs/concepts/streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ shortcut) to control which column groups are included.
| `content_hash` | Content hash column | `_content_hash` |
| `sort_by_tags` | Sort rows by tag columns | (ordering only) |

Every column name beginning with `_` is reserved for Orcapod. Use another name for
user tags, data columns, operator outputs and function pod output keys. Underscores
after the first character are allowed.

When reading a table back as a source, drop its system columns first. If you still
have the original stream, `stream.as_table()` gives you its user-facing columns.

Pass config as a dict or a `ColumnConfig` object:

```python
Expand Down
19 changes: 18 additions & 1 deletion docs/dev/design_issues/ITL-1165-RN1.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Cross-cutting

### RN1 — Reserved `_` column names: sources silently drop them, `Pick` / `Index` accept them as new names
**Status:** open
**Status:** resolved
**Severity:** medium
**Issue:** ITL-1165

Expand All @@ -25,3 +25,20 @@ November 16, 2026 while fixing ITL-1160, probed on that branch):
To decide: which names are reserved; then a source refuses such a column with an error naming
it instead of dropping it, and `Pick` / `Index` refuse a reserved `out` name through the same
helper as the mappers.

**Fix:** Reserve all leading-underscore column names for Orcapod. Raw source readers
report the offending columns and how to remove or rename them. The same rule covers
new operator names and function pod output keys, including user data returned by custom
functions before caching or emission and user keys read from stored results. Operator
caches and cached sources check user columns before exposing rows, including when an
operator's records feed a derived source.
Manual function result cache writes also check output keys, and an invalid cached
result fails the run as a stored-table read error.
`DataFrameSource` checks the names on incoming frames and on the frame Polars infers
from Python inputs. Polling checks the columns Polars infers from Python batches. List
sources validate callback user tags before asking for further tags. DictSource checks
declared schemas before consuming rows and each row of a custom collection before advancing
it. A saved operator schema
identifies legacy user names even when a mixed table alone cannot distinguish them
from system tags.
SpiralDB validates the pinned snapshot's column names for historical reads.
13 changes: 9 additions & 4 deletions src/orcapod/core/cached_function_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
)
from orcapod.protocols.database_protocols import ArrowDatabaseProtocol
from orcapod.protocols.observability_protocols import DataExecutionLoggerProtocol
from orcapod.utils.schema_utils import require_names_not_system

from orcapod.semantic_types._schema_conversion import arrow_schema_for_types

Expand Down Expand Up @@ -205,6 +206,11 @@ def lookup_cached_data(self, data: DataProtocol) -> DataProtocol | None:
cached = self._cache.lookup(data, data_context_key=self.data_context_key)
if cached is None:
return None
return self._cache_hit_output(cached)

def _cache_hit_output(self, cached: DataProtocol) -> DataProtocol:
"""Validate a stored output before passing it to the caller."""
require_names_not_system(cached.keys())
return cached.with_meta_columns(**{self.RESULT_COMPUTED_FLAG: False})

def process_data(
Expand Down Expand Up @@ -234,10 +240,9 @@ def process_data(
A ``(tag, output_data)`` tuple; output_data is ``None``
if the inner function filters the data out.
"""
cached = self._cache.lookup(data, data_context_key=self.data_context_key)
cached = self.lookup_cached_data(data)
if cached is not None:
module_logger.info("Pod-level cache hit")
cached = cached.with_meta_columns(**{self.RESULT_COMPUTED_FLAG: False})
return tag, cached

tag, output = self._function_pod.process_data(
Expand Down Expand Up @@ -267,7 +272,7 @@ def process_data(
module_logger.info(
"A result for this input was stored meanwhile; using it"
)
output = stored.with_meta_columns(**{self.RESULT_COMPUTED_FLAG: False})
output = self._cache_hit_output(stored)
else:
output = output.with_meta_columns(**{self.RESULT_COMPUTED_FLAG: True})
return tag, output
Expand Down Expand Up @@ -338,7 +343,7 @@ async def _async_compute_and_store(
module_logger.info(
"A result for this input was stored meanwhile; using it"
)
output = stored.with_meta_columns(**{self.RESULT_COMPUTED_FLAG: False})
output = self._cache_hit_output(stored)
else:
output = output.with_meta_columns(**{self.RESULT_COMPUTED_FLAG: True})
return tag, output
Expand Down
26 changes: 22 additions & 4 deletions src/orcapod/core/data_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,9 @@ def __init__(
output_keys = [output_keys]
# A copy taken once: a later change to the caller's list changes nothing.
output_keys = tuple(output_keys)
# Refuse reserved names at definition time, before inspecting the return
# annotation or executing the function.
schema_utils.require_names_not_system(output_keys)
self._output_keys = output_keys
if function_name is None:
if hasattr(self._function, "__name__"):
Expand Down Expand Up @@ -1441,11 +1444,17 @@ def from_config(cls, config: dict[str, Any]) -> "PythonDataFunction":
import importlib

inner = config.get("config", config)
keys = inner.get("output_keys") or ()
if isinstance(keys, str):
keys = (keys,)
schema_utils.require_names_not_system(
(*keys, *inner.get("output_data_schema", {}))
)
module = importlib.import_module(inner["module_path"])
func = getattr(module, inner["callable_name"])
return cls(
function=func,
output_keys=inner.get("output_keys"),
output_keys=keys,
version=inner.get("version", "v0.0"),
)

Expand Down Expand Up @@ -1693,7 +1702,8 @@ def call(
Raises:
InputValidationError: If ``data`` is of another data context than this
function's; the wrapped function has not been called then, whatever
``skip_cache_lookup`` and ``skip_cache_insert`` are.
``skip_cache_lookup`` and ``skip_cache_insert`` are. Also raised if
the wrapped function returns a data column with a reserved name.
"""
# Checked before anything else: with ``skip_cache_lookup`` the lookup, which
# checks it too, does not run, and the function must not be called.
Expand All @@ -1711,6 +1721,7 @@ def call(
self._cache.check_before_side_effect(self.data_context_key)
output_data = self._data_function.call(data, logger=logger, **kwargs)
if output_data is not None:
schema_utils.require_names_not_system(output_data.keys())
if not skip_cache_insert:
var_dg, exec_dg = self._build_metadata_datagrams()
self._cache.store(
Expand Down Expand Up @@ -1738,7 +1749,8 @@ async def async_call(

Raises:
InputValidationError: If ``data`` is of another data context than this
function's; the wrapped function has not been called then.
function's; the wrapped function has not been called then. Also raised
if the wrapped function returns a data column with a reserved name.
"""
# Checked before anything else: with ``skip_cache_lookup`` the lookup, which
# checks it too, does not run, and the function must not be called.
Expand All @@ -1758,6 +1770,7 @@ async def async_call(
data, logger=logger, **kwargs
)
if output_data is not None:
schema_utils.require_names_not_system(output_data.keys())
if not skip_cache_insert:
var_dg, exec_dg = self._build_metadata_datagrams()
self._cache.store(
Expand Down Expand Up @@ -1790,7 +1803,12 @@ def record_data(
output_data: DataProtocol,
skip_duplicates: bool = False,
) -> DataProtocol:
"""Record the output data against the input data in the result store."""
"""Record the output data against the input data in the result store.

Raises:
InputValidationError: If an output column has a reserved name.
"""
schema_utils.require_names_not_system(output_data.keys())
var_dg, exec_dg = self._build_metadata_datagrams()
self._cache.store(
input_data,
Expand Down
26 changes: 17 additions & 9 deletions src/orcapod/core/function_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,8 @@ def __init__(
config: OrcapodConfig | None = None,
ctx_arg_name: str | None = None,
) -> None:
output_names = data_function.output_data_schema.keys()
try:
schema_utils.require_names_not_meta(output_names)
schema_utils.require_names_not_system(output_names)
except InputValidationError as exc:
raise InputValidationError(f"Invalid function output: {exc}") from exc
output_schema = data_function.output_data_schema
schema_utils.require_names_not_system(output_schema.keys())

super().__init__(
label=label,
Expand All @@ -165,7 +161,7 @@ def __init__(
# Register types for schema validation, excluding ctx (not a data column).
self.data_context.type_converter.ensure_types_registered_for_schemas(
self.input_data_schema,
data_function.output_data_schema,
output_schema,
)
if self._ctx_arg_name is not None:
warn_provisional_pod(CONTEXT_FUNCTION_POD)
Expand Down Expand Up @@ -408,13 +404,19 @@ def process_data(
Returns:
A ``(tag, output_data)`` tuple; ``output_data`` is ``None`` if
the function filters the data out.

Raises:
InputValidationError: If a returned data column uses a reserved name.
"""
extra: dict[str, Any] = {}
if self._ctx_arg_name is not None:
extra[self._ctx_arg_name] = self._build_invocation_context(
tag, data, run_id=run_id
)
return tag, self.data_function.call(data, logger=logger, **extra)
output = self.data_function.call(data, logger=logger, **extra)
if output is not None:
schema_utils.require_names_not_system(output.keys())
return tag, output

async def async_process_data(
self,
Expand All @@ -439,13 +441,19 @@ async def async_process_data(
Returns:
A ``(tag, output_data)`` tuple; ``output_data`` is ``None`` if
the function filters the data out.

Raises:
InputValidationError: If a returned data column uses a reserved name.
"""
extra: dict[str, Any] = {}
if self._ctx_arg_name is not None:
extra[self._ctx_arg_name] = self._build_invocation_context(
tag, data, run_id=run_id
)
return tag, await self.data_function.async_call(data, logger=logger, **extra)
output = await self.data_function.async_call(data, logger=logger, **extra)
if output is not None:
schema_utils.require_names_not_system(output.keys())
return tag, output

def add_post_run_hook(self, hook: PostRunHook) -> None:
"""Register a post-run hook on this pod.
Expand Down
17 changes: 9 additions & 8 deletions src/orcapod/core/nodes/function_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import pyarrow as pa

from orcapod import contexts
from orcapod.core.result_cache import read_stored_result_table
from orcapod.core.output_bindings import (
OutputBindings,
capture_output_bindings,
Expand Down Expand Up @@ -3722,8 +3723,8 @@ def _stored_provenance(
)
for database, path in places:
database.refresh_table(path)
stored = database.get_all_records(
path, record_id_column=constants.DATA_RECORD_ID
stored = read_stored_result_table(
database, path, record_id_column=constants.DATA_RECORD_ID
)
if stored is not None:
if path[-3:-2] == (PYTHON_FUNCTION.type_id,):
Expand Down Expand Up @@ -3828,7 +3829,8 @@ def _fetch_joined_records(
eph_results: pa.Table | None = None
persistent_df = pl.DataFrame()
if persistent_taginfo_df.height > 0:
results = self._cached_function_pod.result_database.get_all_records(
results = read_stored_result_table(
self._cached_function_pod.result_database,
record_path,
record_id_column=constants.DATA_RECORD_ID,
)
Expand Down Expand Up @@ -3859,11 +3861,10 @@ def _fetch_joined_records(
if ephemeral_taginfo_df.height > 0:
eph_frame: pl.DataFrame | None = None
if self._ephemeral_cached_pod is not None:
eph_results = (
self._ephemeral_cached_pod.result_database.get_all_records(
self._ephemeral_cached_pod.record_path,
record_id_column=constants.DATA_RECORD_ID,
)
eph_results = read_stored_result_table(
self._ephemeral_cached_pod.result_database,
self._ephemeral_cached_pod.record_path,
record_id_column=constants.DATA_RECORD_ID,
)
if eph_results is not None:
eph_results = keep_rows_of_data_context(eph_results, context_key).drop(
Expand Down
Loading
Loading