Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 20 additions & 7 deletions .zed/rules
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,17 @@ Orcapod stores or embeds in a name is pinned in the golden folder of the current
frozen and provisional files; an operator leaving the group has its entries relocated into
a frozen file before the release step. Never put a value that depends on a provisional
operator in a frozen file.
- Provisional sources are outside the freeze too (developer, November 21, 2026, ITL-1314:
"make polling source provisional"): orcapod.sources.PROVISIONAL_SOURCES
(core/sources/provisional.py) is the one list (today PollingSource, its identity
decided by ITL-1316), each listed class sets PROVISIONAL = True (declared on
RootSource, which warns when one is constructed, also through from_config), and building
one issues ProvisionalHashWarning once per source kind per process. The warning and the
use record are one helper, utils/provisional.warn_provisional_use (operators use it
too). Unlike a provisional operator, a provisional source is never pinned, in no golden
file: only operators can be declared by a golden case, so compute_group_kinds refuses a
case that builds one. The mark never enters a hash, an identifier, a config or a stored
path.
- The unit of immutability is the golden file. The manifest's `golden.history`
(`src/orcapod/contexts/data/<version>.json`) lists every file with the sha256 of its bytes;
a release appends a revision with `added: {}`, pinned in
Expand Down Expand Up @@ -830,11 +841,13 @@ element come from a tag value, or from anywhere other than the input's data elem
the step is not an operator: it is a derived source. So a tag's value is offered as data only
by a source, DerivedSource(origin, tags_as_data={tag: data_name}) (ITL-939), never by an
operator. That form is a new root: fresh provenance through SourceStreamBuilder, schema-only
pipeline_hash, and a default source_id of the form
tags_as_data:<algorithm label>:<hex> (the kind names the operation; the config type key stays
derived), the labelled content hash an operator node doing the
derivation would have (DerivedSource._default_source_id, the one place that defines it;
the string is used as-is in system-tag values and source-info tokens). DerivedSource without tags_as_data (a job node's stored records)
pipeline_hash, and a source_id the user must give (developer, November 21, 2026, ITL-1313:
"simply make them throw an error if source id is not provided"): it has no default, and
DerivedSource(..., tags_as_data=...) and node.as_source(tags_as_data=...) raise
ValueError without one, before the origin is read; a saved config without one is refused
too. The given string is used as-is in system-tag values and source-info tokens, and with the
sorted mapping it is the source's identity (the origin enters only through the schema). The
config type key stays derived. DerivedSource without tags_as_data (a job node's stored records)
keeps its old identity; do not change it (ITL-956).

### Two identity chains
Expand Down Expand Up @@ -1189,8 +1202,8 @@ data. The rules:
every source. Every default names its kind first: the class's SOURCE_KIND, which is also
its config type key (arrow_table, dict, list, data_frame, derived, csv,
delta_table, sqlite_table, postgresql_table, db_table, spiraldb_table,
polling_source, cached), or names the operation that derives the source
(tags_as_data). A default built from a hash is <kind>:<algorithm label>:<hex>, built
polling_source, cached). A DerivedSource with tags_as_data has no default: it
requires a source_id (ITL-1313). A default built from a hash is <kind>:<algorithm label>:<hex>, built
only by core/sources/source_ids.hash_source_id (an in-memory source hashes its table as
given; hash_in_key_order=True, refused without key columns or with a source_id, hashes
it sorted by the key columns in key order, arrow_utils.key_row_order, an Arrow sort after
Expand Down
27 changes: 20 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,17 @@ Orcapod stores or embeds in a name is pinned in the golden folder of the current
frozen and provisional files; an operator leaving the group has its entries relocated into
a frozen file before the release step. Never put a value that depends on a provisional
operator in a frozen file.
- Provisional sources are outside the freeze too (developer, November 21, 2026, ITL-1314:
"make polling source provisional"): `orcapod.sources.PROVISIONAL_SOURCES`
(`core/sources/provisional.py`) is the one list (today `PollingSource`, its identity
decided by ITL-1316), each listed class sets `PROVISIONAL = True` (declared on
`RootSource`, which warns when one is constructed, also through `from_config`), and building
one issues `ProvisionalHashWarning` once per source kind per process. The warning and the
use record are one helper, `utils/provisional.warn_provisional_use` (operators use it
too). Unlike a provisional operator, a provisional source is never pinned, in no golden
file: only operators can be declared by a golden case, so `compute_group_kinds` refuses a
case that builds one. The mark never enters a hash, an identifier, a config or a stored
path.
- The unit of immutability is the golden file. The manifest's `golden.history`
(`src/orcapod/contexts/data/<version>.json`) lists every file with the sha256 of its bytes;
a release appends a revision with `added: {}`, pinned in
Expand Down Expand Up @@ -850,11 +861,13 @@ element come from a tag value, or from anywhere other than the input's data elem
the step is not an operator: it is a derived source. So a tag's value is offered as data only
by a source, `DerivedSource(origin, tags_as_data={tag: data_name})` (ITL-939), never by an
operator. That form is a new root: fresh provenance through `SourceStreamBuilder`, schema-only
`pipeline_hash`, and a default `source_id` of the form
`tags_as_data:<algorithm label>:<hex>` (the kind names the operation; the config type key stays
`derived`), the labelled content hash an operator node doing the
derivation would have (`DerivedSource._default_source_id`, the one place that defines it;
the string is used as-is in system-tag values and source-info tokens). `DerivedSource` without `tags_as_data` (a job node's stored records)
`pipeline_hash`, and a `source_id` the user must give (developer, November 21, 2026, ITL-1313:
"simply make them throw an error if source id is not provided"): it has no default, and
`DerivedSource(..., tags_as_data=...)` and `node.as_source(tags_as_data=...)` raise
`ValueError` without one, before the origin is read; a saved config without one is refused
too. The given string is used as-is in system-tag values and source-info tokens, and with the
sorted mapping it is the source's identity (the origin enters only through the schema). The
config type key stays `derived`. `DerivedSource` without `tags_as_data` (a job node's stored records)
keeps its old identity; do not change it (ITL-956).

### Two identity chains
Expand Down Expand Up @@ -1233,8 +1246,8 @@ data. The rules:
every source. Every default names its kind first: the class's `SOURCE_KIND`, which is also
its config type key (`arrow_table`, `dict`, `list`, `data_frame`, `derived`, `csv`,
`delta_table`, `sqlite_table`, `postgresql_table`, `db_table`, `spiraldb_table`,
`polling_source`, `cached`), or names the operation that derives the source
(`tags_as_data`). A default built from a hash is `<kind>:<algorithm label>:<hex>`, built
`polling_source`, `cached`). A `DerivedSource` with `tags_as_data` has no default: it
requires a `source_id` (ITL-1313). A default built from a hash is `<kind>:<algorithm label>:<hex>`, built
only by `core/sources/source_ids.hash_source_id` (an in-memory source hashes its table as
given; `hash_in_key_order=True`, refused without key columns or with a `source_id`, hashes
it sorted by the key columns in key order, `arrow_utils.key_row_order`, an Arrow sort after
Expand Down
20 changes: 20 additions & 0 deletions changelog.d/ITL-1313.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Breaking changes and migration

- `DerivedSource(origin, tags_as_data=...)` and `node.as_source(tags_as_data=...)` need a
`source_id` (ITL-1313): there is no default any more, and building one without it raises
`ValueError` before the origin is read. The default it had, `tags_as_data:<label>:<hex>`
of a hash of the derivation, was of questionable stability (`record_id_columns=None` and
`record_id_columns=()`, one key policy, gave two ids). Pass `source_id="<a name>"`;
`as_source` takes it as a keyword. A saved config already stores the source id; one
without it is refused when loaded. With a given `source_id` the origin enters the source's
identity only through its schema, as for every named source. Plain `DerivedSource(node)`
and `node.as_source()` keep their `derived:<label>:<hex>` default.

### Known limitations

- `PollingSource` is provisional in data context v1 (ITL-1314): its default source id and
its content hash are not frozen and may change in a later release (ITL-1316), and with
them the system tags, stored paths and record ids of its rows and of every step
downstream. Building one issues `ProvisionalHashWarning` once per process
(`orcapod.sources.PROVISIONAL_SOURCES` lists it). It behaves as before otherwise, and no
golden value pins it.
3 changes: 2 additions & 1 deletion docs/api/sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ code. See site/README.md.

Source classes provide the entry point for external data into Orcapod pipelines.
All sources convert their input to a PyArrow Table and use `SourceStreamBuilder` for
enrichment (provenance columns, system tags, hashing).
enrichment (provenance columns, system tags, hashing). `PollingSource` is provisional: its
source id and hashes are not frozen with data context v1 (`PROVISIONAL_SOURCES`).

::: orcapod.core.sources.ArrowTableSource

Expand Down
3 changes: 2 additions & 1 deletion docs/concepts/data-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ the file is checked against the stored tables when a node reads them.

`MapColumns` (`map_columns`) raises "not supported with data-tags yet" when a
data-tag reaches it; rename with `map_tags` and `map_data`.
`PollingSource` keeps its tags plain. Each error names its issue and the way out: build the
`PollingSource` (provisional, see [Provisional sources](sources.md#provisional-sources)) keeps
its tags plain. Each error names its issue and the way out: build the
source with `tag_only_columns=True` to keep every tag plain, as in v0.3. A plain tag is not
data, so a function that reads a tag's value (as `scale` above reads `time`) can no longer
take it from that column: as in v0.3, the value must also be a data column of its own, for
Expand Down
3 changes: 2 additions & 1 deletion docs/concepts/function-pods.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ A node is stale, and runs, when:
- `clear_cache()` was called on it, or on any job node above it;
- a job node above it ran again;
- its source was bound again (`job.bind(sources=...)`), or the bound source's own modified
time moved (a `CachedSource` that read new rows, a `PollingSource` that found new rows).
time moved (a `CachedSource` that read new rows, a `PollingSource` that found new rows;
`PollingSource` is provisional, see [Provisional sources](sources.md#provisional-sources)).

Staleness comes from modified times only, so every run first asks each source feeding it,
once, whether its data changed (`check_for_new_data()`, ITL-1102): `job.run()`,
Expand Down
4 changes: 3 additions & 1 deletion docs/concepts/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ The output schema follows three rules:
```python
from orcapod.sources import DerivedSource

with_probe = DerivedSource(source, tags_as_data={"probe": "probe_name"})
with_probe = DerivedSource(
source, tags_as_data={"probe": "probe_name"}, source_id="spikes_with_probe"
)
by_subject = GroupBy(by=["subject_id"])(with_probe)
print(by_subject.keys())
# (('subject_id',), ('spike_count', 'probe_name'))
Expand Down
37 changes: 30 additions & 7 deletions docs/concepts/sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ hashing) and produces the final immutable stream.

`orcapod.sources` also provides database-backed sources (`SQLiteTableSource`,
`PostgreSQLTableSource`, `SpiralDBTableSource`) and `PollingSource` for data that arrives over
time; see the [API reference](../api/sources.md). Their default `source_id` names the table
time (provisional in this release, see [Provisional sources](#provisional-sources)); see the
[API reference](../api/sources.md). Their default `source_id` names the table
where it lives (`sqlite_table:<db path>:main.<table>`,
`postgresql_table:<host>:<port>/<database>.<schema>.<table>`, with the server the connection
reached; the
Expand Down Expand Up @@ -648,7 +649,9 @@ experiments = DictSource(
)

with_start = DerivedSource(
experiments, tags_as_data={"session_start": "session_start_value"}
experiments,
tags_as_data={"session_start": "session_start_value"},
source_id="experiments_with_start",
)

tag_keys, data_keys = with_start.keys()
Expand Down Expand Up @@ -686,10 +689,11 @@ before. Things to know:
(`job.nodes["bmi"].as_source(tags_as_data=...)`).
- It is a **new source**, not a step in the origin's pipeline: `upstreams` is empty, and it
has provenance columns of its own, like the result of handing the same rows to
`ArrowTableSource`. Use it in place of the origin. Its default `source_id` is
`tags_as_data:` followed by a labelled hash built from the origin's identity and the mapping, so
it changes when either changes; pass `source_id=` to choose a name. The mapping is part of the
source's `content_hash` either way, so two mappings never share one.
`ArrowTableSource`. Use it in place of the origin. It needs a `source_id`: there is no
default, and building one without it raises `ValueError` before the origin is read
(ITL-1313); `as_source(tags_as_data=..., source_id=...)` takes it too. The source is
identified by that name and the mapping, like any named source: the mapping is part of its
`content_hash`, so two mappings never share one.
- A saved job reloads a derived source whenever its origin can be reloaded (a CSV file, a
Delta table, a database table). Over an in-memory source it is saved but not reloaded, like
the in-memory source itself.
Expand All @@ -698,13 +702,32 @@ before. Things to know:
print(with_start.upstreams)
# ()
print(with_start.source_id)
# tags_as_data:...:...
# experiments_with_start
```

Only a source can do this. An operator rearranges rows and columns, and every data value it
emits was already a data value of its input; turning a tag value into a data value creates
new data, which is what a source is for.

### Provisional sources

Data context v1 freezes the hashes of Orcapod at the 0.4.0 release. A provisional source is
outside that freeze: its default `source_id` and its content hash are still being decided
(ITL-1316), so a later release may change them, and with them the system tags, stored paths
and record ids of its rows and of every step downstream of it, which then compute their
results again (nothing stored is lost or wrong). It works as any source does otherwise.

```python
from orcapod.sources import PROVISIONAL_SOURCES

print(sorted(PROVISIONAL_SOURCES))
# ['PollingSource']
```

Building one, directly or from a saved config, issues `orcapod.errors.ProvisionalHashWarning`
once per process; filter its class to silence it, as for
[provisional operators](operators.md#provisional-operators).

## What a source does at a run

A job node that has run holds its rows until it is stale, and staleness comes from modified
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ What `run()` does on each kind of object:
|---|---|
| An in-memory source (`DictSource`, `ArrowTableSource`, ...), a Delta or SQL table source | nothing to compute: a view of the rows it holds |
| A `SpiralDBTableSource` | reads the whole table into memory (`head()` is the bounded read); every call reads again |
| A `PollingSource` | polls, as `as_table()` does |
| A `PollingSource` (provisional, see [Provisional sources](sources.md#provisional-sources)) | polls, as `as_table()` does |
| A `CachedSource` | reads its cache and writes the wrapped source's new rows to it |
| A function pod's or operator's output stream | computes what is not computed yet |
| A job node | runs the node as a job run would, after every job node it depends on that holds no current run (each once), commits, and returns the view of that run's rows; a node that holds a current run (completed in this process and not stale) runs nothing. `run(load_only=True)` loads stored results only. `as_table()` of a job node only reads |
Expand Down
22 changes: 22 additions & 0 deletions docs/dev/design_issues/ITL-1313-S4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## `src/orcapod/core/sources/`

### S4 — Default source ids of questionable stability: `DerivedSource(tags_as_data=...)`
**Status:** resolved
**Severity:** medium
**Issue:** ITL-1313 (related: ITL-1311)

The source identity inventory (ITL-1311) found that `DerivedSource(origin, tags_as_data=...)`
built a default `source_id`, `tags_as_data:<label>:<hex>`, from a hash of the derivation (the
origin's content hash, the sorted mapping and `record_id_columns` when set), whose stability
is questionable: `record_id_columns=None` and `record_id_columns=()`, one key policy, gave two
different ids.

**Fix:** developer decision, November 21, 2026: "Rather than squeezing them in, let's simply
drop the "default" source id feature for all sources where the stability of the auto
computed source id is questionable. Simply make them throw an error if source id is not
provided." `DerivedSource` with `tags_as_data` and `node.as_source(tags_as_data=...)` (which
now takes `source_id`) raise `ValueError` without a `source_id`, before the origin is read;
`from_config` refuses a config without one before rebuilding the origin. `_derivation_hash`
and `DerivedSource._default_source_id` are removed. Plain `DerivedSource(node)` and
`node.as_source()` are unchanged (ITL-956). Tests:
`tests/test_core/sources/test_derived_source_tags_as_data.py`.
19 changes: 19 additions & 0 deletions docs/dev/design_issues/ITL-1314-S5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## `src/orcapod/core/sources/`

### S5 — `PollingSource`'s identity is not settled; provisional in data context v1
**Status:** open
**Severity:** medium
**Issue:** ITL-1316 (related: ITL-1314, ITL-1311)

The source identity inventory (ITL-1311) found that `PollingSource`'s identity is not
settled: its default `source_id` is the semantic hash of the implementer's own `identity()`,
which nothing holds stable, and its content hash, `(impl.identity(), sorted tag columns, key
columns)`, leaves out the `source_id` and the declared schema, so two polling sources with
different names share a content hash.

Developer decision, November 21, 2026 ("make polling source provisional"): it is not repaired
before 0.4.0 and not deleted. It is provisional (ITL-1314): `PROVISIONAL_SOURCES` lists it,
building one issues `ProvisionalHashWarning` once per process, and no golden value pins it
(the three pins it had were removed; a golden case cannot declare a provisional source). Its
identity is decided in ITL-1316, after which it leaves the list and its golden values are
added.
Loading
Loading