Skip to content

Fix native length planning for events without primary keys - #341

Merged
Victsm merged 3 commits into
mainfrom
codex/no-pk-length-planning-20261114
Nov 14, 2026
Merged

Victsm merged 3 commits into
mainfrom
codex/no-pk-length-planning-20261114

Conversation

@Victsm

@Victsm Victsm commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fix a #339 regression where native length planning unconditionally projected an event primary key, rejecting valid keyless tables.

Length-only sequence outputs now carry native row IDs, offsets and row counts without dummy PK or timestamp value columns. Token costs use node-ID metadata; direct validity checks project only their declared input fields. The ordinary compiler also stops adding a placeholder for constant-only events.

This intentionally extends the shared query_temporal / query_temporal_lengths contract to accept empty sequence output projections. Both reuse existing Arrow row-count handling; a length-only bypass would add a second admission rule for the same supported result shape. Frame-level PK/clock reads needed for deterministic ordering and temporal filtering remain unchanged. Existing chronological EventSource clock validation remains unchanged.

Validation: 202 focused Python tests pass with the matching native library, including the complete temporal-query-shapes file (7 passed). The old zero-column refusal test now verifies identities/row counts/lengths for empty and nonempty results through both public methods. Coverage also includes constant-only keyless events, four other row representations, Packed/Padded layouts, 128-anchor parallel pools and epoch-two cache reuse. Direct generic queries cover a real no-PK/no-clock index with zero decoded values. Rust library tests: 288 passed; Rust source is unchanged since that run.

Modified runtime/API/shape-test lint and whitespace checks pass. The aggregate-program test module retains one unchanged baseline PLC0206 diagnostic.

Change map

#341 (comment)

@copy-pr-bot

copy-pr-bot Bot commented Nov 14, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Victsm
Victsm temporarily deployed to gha-kumo-workflow-tests November 14, 2026 01:45 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Sequence plans now accept empty value-column projections while retaining offsets, node IDs, and row counts. The temporal plan compiler keeps empty column lists. Native length planning omits sequence primary keys from its projections. Tests cover identity-only aggregation and ingestion, and compare native batches with ParquetAnchors across six row kinds and two layouts.

Merge Risk: Minimal · up to cf16b

This change lets event tables without primary keys work in native length planning and allows identity-only sequences. Tests cover the changed behavior, and no merge-blocking issue was found.

Security architecture risk: Minimal · up to cf16b

The change permits queries to return row identity and counts without value columns. The inspected selection controls and identity handling remain intact, and no material security, failure-containment, ownership, or rollback regression was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Within the inspected query path, newly accepted identity-only requests expose metadata for the same selected rows that full-column requests already returned. Removing value columns does not expand the selected table, relation path, or temporal window.

Trust Boundaries and Controls

  • inferred — The removed empty-projection rejection was a structural shape restriction, not an authorization control: it examined column-list emptiness, without caller identity or permission inputs. Its removal does not establish an authorization bypass. Upstream authorization remains outside the fully traced scope.

Resilience and Maintainability Implications

  • inferred — Identity-only planning retains the existing task-owned cache lifecycle. The query contract participates in cache identity, shared access is mutex-protected, values are range-checked before each entry is written, and existing cache files are not reopened for recovery. Earlier completed entries can remain reusable after a later calculation fails. No projection-dependent change to publication or cleanup was identified.
Pre-merge checks: Passed 3

Check name Status Explanation
Change Map Design Review Passed The change-map comment (issuecomment-6869616820, marker <!-- kumo-pr-change-map -->, author Victsm) was retrieved from the GitHub API and checked against the PR diff. **Table accuracy and scope (ver…
Pr Size Passed PR size check: the changed-file inventory from git diff --name-status refs/coderabbit/pre-merge-check/base refs/coderabbit/pre-merge-check/head lists 6 modified files. Rename-aware counting also giv…
Public Resource Access Passed The check applies only to external resource references (URLs, repository locations, package sources) that this pull request adds or modifies. I listed the changed files (six files: two Python engine m…
Full details: Change Map Design Review

Explanation

The change-map comment (issuecomment-6869616820, marker &lt;!-- kumo-pr-change-map --&gt;, author Victsm) was retrieved from the GitHub API and checked against the PR diff. Table accuracy and scope (verified): - native_anchors.py edits at lines 536 and 684-686 sit inside NativeAnchors._length_contract (starts at line 452). This matches the table. - diskgraph.py removes the constant-only time-column placeholder (-3 lines). This matches the table row for _TemporalPlanCompiler._sequence. - batch_aggregate.rs removes the "must project at least one column" check and adds the SequencePlan.columns doc comment. This matches the table row. - All six changed files appear in the table. The file-level inventory is covered by the deterministic check. Prior FAIL claims, checked one by one: 1. Stale refusal test and omitted reversal. Refuted. The PR diff does modify test_temporal_query_shapes.py. The refusal test is replaced by test_zero_column_sequence_preserves_identity_and_lengths, parametrized over empty and nonempty anchors and both public methods. The old refusal message no longer appears in packages/. The change map names the reversal explicitly ("deliberately makes empty sequence output projections valid for both public query_temporal and query_temporal_lengths") and has a row for the replaced test. 2. No justification for the global validator change. Partly a design opinion. The table does state a reason: "A length-only bypass would duplicate admission behavior for this same supported shape." This is an uncertain design tradeoff, not a proven defect. A reviewer could prefer a length-scoped check that keeps the public refusal. That is an optional refinement and does not establish a failure. 3. Misleading "without projecting PK" wording. Refuted. The table limits the change to "unnecessary sequence value/output columns" and states that "Frame-level PK and clock reads for ordering/filtering remain unchanged." PreparedFrame::new (batch_aggregate.rs lines 82-88) still adds the PK to frame projections, so the wording is accurate. 4. Verification commands. The table gives the exact focused command for test_temporal_query_shapes.py (7 passed). The 202-case suite is described as "retained in the operational receipt" and its command is not in the comment. This is an optional refinement, not a gap in the focused verification the check requires. Other observations (non-blocking): - The table's prose contains garbled count text ("reproduced2", "all7", "passed288"). These are formatting items, which the check excludes. - The PR objectives say 173 Python tests. The PR description and change map say 202. The description and change map agree, so the objectives appear to be a distillation error. Design verdict: The table gives the observed #339 regression, the inspected behavior (native IDs, existing Arrow row counts), a scoped change set, focused verification and a stopping condition. The code matches it. The remaining question is whether the public API should accept zero-column sequences or only the length path should. The table gives a reasoned answer, so this is not a proven design defect. Prior failure refuted: Claim 1 is factually wrong: the PR diff modifies test_temporal_query_shapes.py, replacing the refusal test with test_zero_column_sequence_preserves_identity_and_lengths; the change map names the public reversal and this test row. Claim 3 is wrong: the table limits the change to sequence output columns and states frame-level PK reads remain; PreparedFrame::new still adds the PK. Claim 2 is a deb...

Full details: Pr Size

Explanation

PR size check: the changed-file inventory from git diff --name-status refs/coderabbit/pre-merge-check/base refs/coderabbit/pre-merge-check/head lists 6 modified files. Rename-aware counting also gives 6. The threshold is more than 40 files, so the check passes. Line counts were ignored as the check requires. Changed files: - packages/diskgraph/diskgraph-pybind/python/tests/test_aggregate_program.py - packages/diskgraph/diskgraph-pybind/python/tests/test_temporal_query_shapes.py - packages/diskgraph/diskgraph-train-table/src/batch_aggregate.rs - packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/diskgraph.py - packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/native_anchors.py - packages/experimental/kumo-pytorch/tests/test_native_length_planning.py

Full details: Public Resource Access

Explanation

The check applies only to external resource references (URLs, repository locations, package sources) that this pull request adds or modifies. I listed the changed files (six files: two Python engine modules, three test modules, and one Rust source file) and searched every added and removed diff line for URLs, git/registry locations, package sources, and dependency declarations. The search found no added or modified external references. The only match was an unrelated code token (api.Tokens()). The pull request description contains a change-map link, but the description is not part of the diff and is not a resource needed to build, test, or use the changed code. No dependency manifests or lock files changed. Because the pull request adds no qualifying external reference, the check passes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 26e2ee6 and cf16bb1.

Files selected for processing: 3

  • packages/diskgraph/diskgraph-pybind/python/tests/test_temporal_query_shapes.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/diskgraph.py
  • packages/experimental/kumo-pytorch/tests/test_native_length_planning.py
Files with no reviewable changes: 1

  • packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/diskgraph.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

@Victsm

Victsm commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Change map

Observed #339 regression: length planning inserted an optional PK into a native sequence output projection, rejecting valid keyless events. The length input already supplies all declared fields, and token metadata uses native node IDs. The initial timestamp fallback was removed.

This deliberately makes empty sequence output projections valid for both public query_temporal and query_temporal_lengths, using the existing zero-column Arrow row-count support. A length-only bypass would duplicate admission behavior for this same supported shape. Frame-level PK and clock reads for ordering/filtering remain unchanged; only unnecessary sequence value/output columns are removed. Chronological EventSource still requires its existing semantic clock.

File Function / scope What changed Why
packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/native_anchors.py NativeAnchors._length_contract Empty outputs for identity/metadata-only lengths; project declared fields only for direct validity costs Remove the accidental PK requirement without a dummy replacement column
packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/diskgraph.py _TemporalPlanCompiler._sequence Remove the constant-only physical-column placeholder Shared zero-column results already retain native identities and row count
packages/diskgraph/diskgraph-train-table/src/batch_aggregate.rs SequencePlan; validate_sequence_plan Accept and document empty sequence output projections Reuse native metadata and existing Arrow row counts through one shared contract
packages/experimental/kumo-pytorch/tests/test_native_length_planning.py test_native_planning_without_event_primary_key Compare real reference/native tensors, coverage, parallel pools and cached lengths for Columns/Composite/fixed/text and constant-only inputs Verify keyed metadata lookup and constant-only compilation on valid keyless events without Python fallback
packages/diskgraph/diskgraph-pybind/python/tests/test_aggregate_program.py identity-only query tests Empty/nonempty timed/untimed query results and a no-PK/no-clock index with zero decoded values Verify metadata and explicit row counts independently of projected values
packages/diskgraph/diskgraph-pybind/python/tests/test_temporal_query_shapes.py test_zero_column_sequence_preserves_identity_and_lengths Replace the former refusal assertion with real output assertions for both public query methods, including empty anchors Align the test with the intentional shared API extension and preserve shape/length correctness coverage

Verification: 202 affected Python tests pass, including all7 tests in test_temporal_query_shapes.py. The old refusal test reproduced2 failures locally and in CI before being updated; it is replaced with stronger result assertions, not deleted. Added constant-only tests also pass. The same Rust source/library passed288 library tests. Modified Python runtime/API/shape tests pass Ruff; native aggregate test lint has one unchanged baseline PLC0206 on unrelated code. Whitespace checks pass.

Exact focused command in the prepared source/matching-native environment: python -m pytest -q packages/diskgraph/diskgraph-pybind/python/tests/test_temporal_query_shapes.py (7 passed). The full 202-case command is retained in the operational receipt and covers native planning, anchor handoff, history limits, materialized batches, padding, DiskGraph backend, aggregate programs and temporal shapes. Stopping condition met; no new bypass flag, result format or planner API was added.

@Victsm
Victsm requested a review from Vedaant-J November 14, 2026 01:45
@Victsm
Victsm temporarily deployed to gha-kumo-workflow-tests November 14, 2026 02:00 — with GitHub Actions Inactive
@Vedaant-J

Copy link
Copy Markdown
Contributor

test_temporal_query_shapes.py:153-162 (test_zero_column_sequence_is_refused) still expects the refusal this PR removes.

@Vedaant-J

Copy link
Copy Markdown
Contributor

engines/diskgraph.py:2276-2278 still adds a placeholder column for constant-only events, with an out-of-date comment and or an event with no key, no clock and no stored field, that placeholder is None;
it is only reachable if such a clockless history isn't refused first, and could be [].

@Victsm
Victsm temporarily deployed to gha-kumo-workflow-tests November 14, 2026 02:24 — with GitHub Actions Inactive
@Victsm
Victsm merged commit 0857714 into main Nov 14, 2026
111 of 112 checks passed
@Victsm
Victsm deleted the codex/no-pk-length-planning-20261114 branch November 14, 2026 06:13

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — cf16bb13 Deployed Nov 14, 2026 by Victsm via import #2381
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.

2 participants