Skip to content

fix(streams): preserve declared system tag fields in rows (ITL-1543) - #606

Closed
eywalker wants to merge 14 commits into
mainfrom
eywalker/itl-1543-part-b
Closed

eywalker wants to merge 14 commits into
mainfrom
eywalker/itl-1543-part-b

Conversation

@eywalker

@eywalker eywalker commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Mentions ITL-1543
Mentions ITL-1557
Mentions ITL-1561

Rows carry their stream's declared system-tag Arrow types, flags, and field metadata. Copies, standalone async Join, typed empty tables, and record-batch reads carry those fields too. The raw nullable Join case left open in #605 is covered by a regression that compares sync and async rows in every order of three tied inputs.

Before and after

Comparison Result
Source and stream paths, both layouts, and all 22 exported operators on sync and async paths Ordinary rows kept their entry, instance, and record IDs. The raw Rejoin fixture kept its declared nullable fields and changed those three IDs as expected.
Plain and cached function pods, including downstream of Join IDs and stored result paths, types, flags, and values matched.
60 sync and async job comparisons with saved/load and as_source() Entry, instance, and record IDs, operator record hashes, stored paths, column types, and flags matched.
Hand-built unusual system tags Preserving int8 or a nullable text field holding text changes the entry ID and its dependent IDs. Ordinary field metadata alone changed the row field but left the measured IDs equal. A raw Arrow Null system tag keeps its type until entry hashing, where the error names the column and asks for a supported nullable type.
Goldens All 2,504 matched.

The source-info declaration remains in arrow_utils.add_source_info. It still declares generated source token columns non-nullable, and the row token API still uses nullable fields. The cache read regression verifies that an older stored token column retains its original flag on readback. ITL-1557 tracks the token decision. The existing PR 494 guard stays for the PR 601 follow-up.

Review regressions

Finding Regression coverage
Source-built custom system tags with Arrow extension metadata changed entry, instance, and record IDs The source now refuses any Arrow field metadata on a nominated system tag. test_refuses_field_metadata_on_custom_system_tags covers ordinary and extension keys for all nine constructors that accept system_tag_columns, plus a SpiralDB tag copied with tags_as_data and then nominated. A metadata-free source matches all three row IDs at 969ed093.
Standalone async Join kept metadata from the destination operand on system tags sorted across tied inputs test_standalone_async_join_rows_keep_declared_system_tag_fields compares the predicted types and flags, empty and populated Arrow schemas, and sync and async rows across all orders of three tied inputs with matching or different metadata. The sorted source and record fields carry no operand metadata.
The field property covered async for function pods alone, and the raw Null error offered no remedy Field comparisons exercise sync and async for each concrete stream and all 22 exported operators across several tag orders and column layouts. The test names the excluded abstract bases, rowless view and unavailable-source proxy. test_entry_id_explains_how_to_replace_a_raw_null_system_tag covers top-level and nested raw Null.

The job and transport regressions now assert the declared field for narrow and nullable raw system tags. A former source fixture using an integer custom tag now asserts the existing construction error.

The source refusal is a stopgap pending ITL-1561, which will re-evaluate which Arrow field metadata a custom system tag may carry. Remove the metadata before building the source. A raw ArrowTableStream still preserves its declared fields and passes them to rows.

Rechecking this revision against the previous PR head with the same main changes applied produced identical results for 238 ordinary cases, including source and stream fixtures, standalone operators, cached function pods and physical source caching. The tied Join matched standalone in both modes, and 60 sync and async saved-job comparisons matched through as_source(). Its stored schemas (including field metadata), values and record hashes matched apart from the recording timestamp.

Second review regressions

Finding Regression coverage
A legacy source cache could return a system tag with extension field metadata and change row IDs test_reopened_cache_refuses_legacy_system_tag_metadata checks table, sync row, async row, and stored-record reads after reopening a persisted cache without its original source. The error names the field and asks for a rebuild. test_bound_proxy_refuses_delegated_system_tag_metadata checks the same source rule for a live delegate's table, preview, and both row paths.
Polars conversion erased metadata on Arrow inputs to DataFrameSource test_dataframe_source_validates_arrow_inputs_before_polars covers Table and RecordBatch inputs, both with and without a separate schema.
Standalone async Join moved custom system-tag values and flags between tied operands test_tied_join_keeps_custom_system_tags_with_their_operand compares prediction, table, and both row paths across all six orders and two layouts. Both execution paths now call the same sorter.
The row-field property omitted bound SourceProxy test_stream_and_rows_agree_on_tag_and_primary_data_fields[bound_source_proxy] checks the public bound proxy through table, sync row, and async row access.

The common source validator checks system tags on cached, delegated, and directly wrapped tables. The plain derived route discards its origin's system tags, the tag-copy form rebuilds provenance, and the unbound proxy exposes no rows. Raw Arrow streams retain their declared fields.

The second-round before-and-after comparison matched all 240 ordinary cases and 60 saved and loaded jobs, including as_source(). The tied Join's stored schemas, record hashes, paths, and values matched apart from the recording time. All 2,504 goldens matched.

Third review regression

Arrow readers and C exporters could lose nominated system-tag metadata before validation. test_dataframe_source_validates_arrow_inputs_before_polars covers Tables, RecordBatches, RecordBatchReaders, Arrow C stream exporters, Arrow C array exporters, and exporters supporting both protocols. It tests populated and empty inputs with and without a declared schema, and checks that exporters are called once.

DataFrameSource materializes Arrow input once, validates the nominated fields, and passes the checked table to Polars. It preserves Polars' array-first choice for dual exporters and its chunk-handling behavior. Metadata-free inputs in the before-and-after comparison kept their Arrow fields, values, and source, pipeline, entry, instance, and record IDs.

Merge verification

Part A landed in #605. The merge from main retains exactly the Part B patch. After accounting for main commits that the original branch had already merged and normalizing diff headers, the old and new patches match across all 29 files.

Posted by a Codex agent on behalf of @eywalker.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.08029% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/orcapod/core/operators/join.py 95.45% 1 Missing ⚠️
src/orcapod/core/record_batch_channels.py 85.71% 1 Missing ⚠️
src/orcapod/core/row_ids.py 90.00% 1 Missing ⚠️
src/orcapod/core/streams/base.py 85.71% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/orcapod/core/datagrams/datagram.py 93.24% <100.00%> (+0.01%) ⬆️
src/orcapod/core/datagrams/tag_data.py 98.88% <100.00%> (+0.04%) ⬆️
src/orcapod/core/operators/static_output_pod.py 95.74% <100.00%> (+0.06%) ⬆️
src/orcapod/core/sources/cached_source.py 96.95% <100.00%> (ø)
src/orcapod/core/sources/data_frame_source.py 93.54% <100.00%> (+1.24%) ⬆️
src/orcapod/core/sources/db_table_source.py 96.96% <100.00%> (ø)
src/orcapod/core/sources/derived_source.py 97.70% <ø> (-0.01%) ⬇️
src/orcapod/core/sources/polling_source.py 97.37% <100.00%> (-0.02%) ⬇️
src/orcapod/core/sources/source_proxy.py 87.15% <100.00%> (+2.15%) ⬆️
src/orcapod/core/sources/stream_builder.py 99.03% <100.00%> (+0.03%) ⬆️
... and 5 more

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

# Conflicts:
#	.zed/rules
#	CLAUDE.md
#	changelog.d/ITL-1543.md
#	docs/dev/design_issues/ITL-1543-AS2.md
#	src/orcapod/core/operators/join.py
#	src/orcapod/core/sources/cached_source.py
#	src/orcapod/core/sources/data_frame_source.py
#	src/orcapod/core/sources/derived_source.py
#	src/orcapod/core/sources/polling_source.py
#	src/orcapod/core/sources/stream_builder.py
#	src/orcapod/utils/arrow_utils.py
#	tests/test_core/sources/test_source_arrow_validation.py
@eywalker

eywalker commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Closing without merging, by the developer's decision. Changes that landed on main on purpose cover or withdraw this PR's aim:

ITL-1543 stays open for anything of its aim that is still missing.

Posted by a Claude Code agent on behalf of @eywalker.

@eywalker eywalker closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant