You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow SamplerEngine.query_temporal to return sequences and aggregates from tables that have foreign keys but no primary key, using the native node IDs that DiskGraph already assigns to those rows.
For example, events(user_id FK → users.id, time, value) needs no event PK to be ingested or sampled through users → events. Today, a temporal query over that same relation fails with table "events" has no primary key metadata. This PR removes that extra requirement from temporal frame materialization.
Where support is missing today
query_temporal calls temporal_query::execute, which builds a shared frame for its sequence and aggregate consumers. In materialize_frame, relation traversal has already found the destination node IDs, and distinct has already removed repeated visits by node ID. The function then unconditionally requires table.primary_key_map() and raises the missing-PK error above.
It subsequently adds the PK column to the row projection and reads its values as the secondary ordering key for rows with equal timestamps. That ordering/projection assumption blocks every materialized frame over an FK-only destination, including count-only queries that need no event attributes. Both sequences and aggregates fail at this shared step.
The separate query_temporal_lengths / count_frame path already traverses and counts native node IDs without requiring destination PK metadata.
How this follows the existing engine
DiskGraph distinguishes a stored row's native identity from its optional external primary key:
The graph sampler's TemporalMostRecent path reads destination node IDs from the stored adjacency and filters using edge timestamps. It does not require the destination's PK column.
This PR uses that same native identity in the temporal materializer. It does not introduce another row-ID scheme or generate a source PK.
Changes
Make destination PK metadata optional. Project and decode the declared PK only when present; preserve the existing PK-based tie ordering for keyed tables.
For an FK-only destination, use the native node ID already returned by traversal as the secondary ordering key. Keep the existing temporal sort, window filtering, sequence limits, reducers, and node_ids output. This follows the graph engine's identity convention; it does not change the graph sampler's ordering algorithm.
Preserve each source occurrence as its own node, including identical event rows. Existing distinct behavior continues to remove repeated visits to one node, rather than collapsing different rows with equal values. IDs remain local to the index.
Preserve Arrow row counts in table_rows and take_batch when the projection is empty. Previously the mandatory PK guaranteed at least one projected column. With an optional PK, a static count-only frame can legitimately have zero columns and still contain rows. These frames decode no rowpack values and report zero rows decoded.
PK lookup and FK validation retain their existing requirements. RDL entity selection still requires a declared PK; an FK-only table can supply related events without becoming an entity table. The companion rdl-platform#139 enables that distinction in RDL and depends on this native change.
Testing Done
354 native temporal tests passed, including 16 new FK-only cases across one/three shards and both output formats. Coverage includes identical rows, cutoff boundaries, windows, bounded sequences, empty histories and anchors, length queries, deferred columns, and zero-column counts.
The duplicate-event fixture has times 9, 9, 10, 11 and values 2, 2, 3, 100: cutoff 10 returns three distinct native nodes, count 3, and sum 7. An empty history returns zero. The missing-PK failure was reproduced with the previous native binary.
17 sampling regression tests passed; the unrelated Rust benchmark test was deselected. Python lint/format, whitespace checks, and local binding-crate Clippy passed. Full-workspace CI Clippy passed.
Quick CPU benchmark of the full native dependency update (567f6cab → 232aec03): 65,536 events, 256 roots, one thread, fixed CPU core, three alternating runs per revision. Keyed output hashes matched. Median bounded-sequence time was 7.96 → 7.96 ms (+0.04%); shared sequence/aggregate time was 22.19 → 22.33 ms (+0.63%). This measured query execution; ingestion, training, and GPU execution were not timed.
No actionable comments were generated in the recent review.
Walkthrough
Temporal queries now support destination tables without primary-key metadata. Frame sorting uses the primary-key value when available and otherwise uses the native node ID. Zero-column Arrow batches preserve row counts, while empty projections do not increase the decoded-row count. The README documents keyless-table node ID behavior, and tests cover temporal queries across one- and three-shard graphs.
Merge Risk: Low · previous review 232ae
An invalid root can be counted as a real row in the empty-path count-only case; validate roots before constructing the empty batch.
Pre-merge checks: 2 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Change Map Design Review
The required PR conversation comment is unavailable. The checkout contains only the marker in the template and review guidance, not the PR's marked change-map comment. The description's linked URL and…
Provide the actual author or authorized-bot conversation comment beginning with <!-- kumo-pr-change-map -->, or make it available to this review. It must cover all three changed files and state the observed failure or release requirement,…
Passed checks: 2 passed
Check name
Status
Explanation
Pr Size
The pull request changes 3 files. This does not exceed the 40-file limit.
Public Resource Access
The pull request adds no external resource reference. The README additions describe behavior only, and the new test paths point to local temporary Parquet fixtures, which this check excludes. Existing…
Full details: Public Resource Access
Explanation
The pull request adds no external resource reference. The README additions describe behavior only, and the new test paths point to local temporary Parquet fixtures, which this check excludes. Existing README URLs and repository references are unchanged.
Full details: Change Map Design Review
Explanation
The required PR conversation comment is unavailable. The checkout contains only the marker in the template and review guidance, not the PR's marked change-map comment. The description's linked URL and summary do not provide the same-comment evidence required for the observed failure, existing behavior, smallest sufficient change, focused verification, and stopping condition. The reviewed diff is available and shows a focused three-file change, including optional primary-key handling in materialize_frame, native node-ID ordering, zero-column Arrow row counts, tests, and README text, but that cannot establish whether the proposed design map is necessary and correctly scoped.
Resolution
Provide the actual author or authorized-bot conversation comment beginning with <!-- kumo-pr-change-map -->, or make it available to this review. It must cover all three changed files and state the observed failure or release requirement, existing behavior, smallest sufficient change, focused verification, stopping condition, and any optional refinements.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
Observed failure: query_temporal traverses an FK-only destination successfully, then materialize_frame rejects its missing PK metadata while preparing the row projection and tie key. Native ingestion, graph sampling, and length-only temporal queries already use native node IDs without requiring a destination PK. Make the projection optional and use those same IDs for temporal ties. Completion means sequences and aggregates work for FK-only destinations, preserve distinct source occurrences, and retain existing keyed behavior. Verification: 354 temporal tests (including 16 new cases), 17 sampling tests, and local/full-workspace CI Clippy passed. The README is restored to the base version and is absent from the PR diff.
Optional PK projection and tie key; use the existing native node ID when no PK is declared; retain zero-column Arrow row counts and accurate decode counters.
Remove the materializer's extra PK requirement using DiskGraph's existing row identity, including count-only frames that need no projected attributes.
458-459: Minor · Functional Correctness · Quick win
Validate node IDs before returning an empty projection.
For a keyless root table with path: [], an out-of-range root ID reaches this branch without a traversal. A count-only query then returns 1 for a nonexistent row. The normal path rejects that ID in TableReader::edges_for_node. (raw.githubusercontent.com)
Validate the root IDs without decoding rowpack data before constructing the batch.
Pin the native node-ID order for keyless time ties.
The PR documents that keyless temporal ties use the native node ID. sort_frame_rows applies that tie order through stable_sort_key. No test in the keyless or duplicate-row path asserts the order of node_ids for equal timestamps. A change that reverses or ignores this tie-breaker keeps the current assertions passing. Add an assertion that the two time-9 IDs appear in the documented native-ID order. Confirm the U64 comparison in stable_sort_key before choosing the expected direction.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
## Summary
Allow non-entity tables without primary keys in `kumo.pytorch`,
following DiskGraph's existing row identity. For example, `events(owner
FK → users.id, at, amount)` can supply histories, aggregates and graph
neighbors without an artificial event key. Entity/root and candidate
entity declarations still require a PK.
This ports
[rdl-platform#139](kumo-ai/rdl-platform#139)
into the API's new home at `packages/experimental/kumo-pytorch`,
introduced by #244. The API implementation, tests and agreed examples
are retained under the `kumo.pytorch` namespace. The standalone
dependency-pin changes are omitted: this package already uses the
workspace DiskGraph, including merged native support from #184.
## Where support is missing
The current `TableSpec` constructor rejects `primary_key=None` with
`table name and primary key must be non-empty`, before the table reaches
ingestion. Downstream API paths also assume every table has a PK: native
ingestion configuration always declares one, temporal sequences project
it, graph output reads it for identity, and serving requires it for row
uniqueness and fetching.
DiskGraph already stores and traverses rows without PKs. Ingestion
assigns native node IDs; graph sampling and temporal queries use those
IDs to address individual occurrences. External PK lookup is a separate
requirement for choosing entities. This change carries that existing
distinction through the API.
## Implementation and intended behavior
- Accept `TableSpec(..., primary_key=None)` and `build.Table(...,
key=None)`. A shared declaration check rejects PK-less sample/candidate
entities before binding, type inference or source access.
- Omit absent PK metadata and projections in the DiskGraph adapter. Use
returned native node IDs for temporal and graph identity. Constant-only
sequences project their existing clock to satisfy the native sequence
API.
- Use private source-occurrence ordinals in the in-memory test/serving
paths. Keep separate source occurrences distinct, including equal-valued
rows and aliases of the same input mapping. Repeated visits reuse an
occurrence; `distinct=True` removes repeated visits rather than
collapsing equal values.
- Validate key presence/uniqueness and request PK columns in `rows_spec`
only for keyed tables. Update authored documentation and regenerate the
public API reference.
No source key generation, additional identity column or persistent
identity inventory is introduced. Existing keyed ordering, entity
lookup, source cleanup and unsupported-operation checks retain their
behavior. Native source, workspace packaging and dependencies are
unchanged by this PR.
The new `G-KEYLESS-001` guarantee has two hand-calculated examples:
| Case | Input | Required answer |
| --- | --- | --- |
| C-KEYLESS-001 | Identical amount-2 events at time 9, amount 3 at 10,
and future amount 100 at 11. | Cutoff 9: count 2, sum 4. Cutoff 10:
count 3, sum 7. Recent `(9,10]` count 1. Empty history: count/sum 0. |
| C-KEYLESS-002 | Two links revisit the same two identical eligible
facts. | Distinct count 2 / sum 4; repeated count 4 / sum 8. Future
facts excluded. |
Keyless IDs remain opaque and local to an index or prepared serving
dataset. Reordering, repartitioning or serving subsets can change tied
selections and floating reduction rounding. Occurrence multiplicity and
integer reductions remain exact; stable cross-preparation identity
requires a declared PK.
## Testing Done
- **Full CPU suite: 1,926 passed**, 3 GPU skips and 47 opt-in
end-to-end/notebook checks deselected.
- **Complete conformance: 705 passed**, with no skipped or deselected
obligations, including DiskGraph and the in-memory differential checks.
- **Installed wheels: 41 passed** for keyless/entity behavior and the
README quick start, followed by **all 3 example notebooks passing** with
exact committed-file comparisons.
- Fresh independent adversarial review: 26 focused keyless tests, four
case/engine golden checks, and additional alias, NULL-FK,
repeated-visit, multi-file/shard, graph and serving probes passed.
- Source/wheel builds, Ruff 0.17.3 lint/format, generated
API/limitations freshness, whitespace checks and the repository-wide
SPDX check passed.
Validation uses Python 3.12 on CPU, with DiskGraph built from this
branch's in-tree source. The editable package is `kumo.pytorch`; the old
`rdl-pytorch` editable install was removed. Installed-wheel checks use a
separate environment and staged tests/docs/examples without `src/`; both
API and engine imports were verified to come from the installed wheels.
From `packages/experimental/kumo-pytorch`:
```bash
CUDA_VISIBLE_DEVICES='' python -m pytest -q --require-imports
CUDA_VISIBLE_DEVICES='' python -m conformance --engine all
python -m tests.api_reference
python -m tests.limitations_reference
python -m ruff check .
python -m ruff format --check .
```
Both the source distribution and its wheel build successfully. The
installed-wheel gate also exercises the README, keyless/entity tests and
example notebooks. Ruff uses the CI pin, 0.17.3. Native compilation used
the existing Rust 1.98 compiler; CI uses the repository's pinned
toolchain. No GPU or live-service validation is claimed.
Earlier standalone benchmarks measured roughly 4% additional in-memory
test-engine time and 6.3% retained source heap. Those historical
measurements were not repeated for this monorepo port.
## Migration and review
All 26 existing touched files matched the imported base after namespace
conversion; the four new guarantee/test files had no collisions. This is
the same RDL feature moved into the monorepo, with no additional
behavior or altered golden answers. The new package's existing CPU,
DiskGraph, notebooks and installed-wheel workflows cover the changed
paths.
Independent adversarial review found no actionable issues. It executed
all 26 focused keyless cases and four golden case/engine combinations,
plus multi-file/shard, NULL-FK, aliased-row, repeated-visit, graph and
serving probes. It also checked namespace coexistence and verified that
all 67 Python modules in the built wheel match source byte-for-byte.
## Change map
[File-by-file change
map](#267 (comment)).
Reviewed at: e7a75e6
Co-authored-by: Codex <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow
SamplerEngine.query_temporalto return sequences and aggregates from tables that have foreign keys but no primary key, using the native node IDs that DiskGraph already assigns to those rows.For example,
events(user_id FK → users.id, time, value)needs no event PK to be ingested or sampled throughusers → events. Today, a temporal query over that same relation fails withtable "events" has no primary key metadata. This PR removes that extra requirement from temporal frame materialization.Where support is missing today
query_temporalcallstemporal_query::execute, which builds a shared frame for its sequence and aggregate consumers. Inmaterialize_frame, relation traversal has already found the destination node IDs, anddistincthas already removed repeated visits by node ID. The function then unconditionally requirestable.primary_key_map()and raises the missing-PK error above.It subsequently adds the PK column to the row projection and reads its values as the secondary ordering key for rows with equal timestamps. That ordering/projection assumption blocks every materialized frame over an FK-only destination, including count-only queries that need no event attributes. Both sequences and aggregates fail at this shared step.
The separate
query_temporal_lengths/count_framepath already traverses and counts native node IDs without requiring destination PK metadata.How this follows the existing engine
DiskGraph distinguishes a stored row's native identity from its optional external primary key:
primary_key_mapoptional. The table still has native nodes and FK-derived relations.TemporalMostRecentpath reads destination node IDs from the stored adjacency and filters using edge timestamps. It does not require the destination's PK column.DiskgraphFeatureStore._get_fused_pkeyalready returns sampled global node IDs when there is no PK column.This PR uses that same native identity in the temporal materializer. It does not introduce another row-ID scheme or generate a source PK.
Changes
node_idsoutput. This follows the graph engine's identity convention; it does not change the graph sampler's ordering algorithm.distinctbehavior continues to remove repeated visits to one node, rather than collapsing different rows with equal values. IDs remain local to the index.table_rowsandtake_batchwhen the projection is empty. Previously the mandatory PK guaranteed at least one projected column. With an optional PK, a static count-only frame can legitimately have zero columns and still contain rows. These frames decode no rowpack values and report zero rows decoded.PK lookup and FK validation retain their existing requirements. RDL entity selection still requires a declared PK; an FK-only table can supply related events without becoming an entity table. The companion rdl-platform#139 enables that distinction in RDL and depends on this native change.
Testing Done
9, 9, 10, 11and values2, 2, 3, 100: cutoff 10 returns three distinct native nodes, count 3, and sum 7. An empty history returns zero. The missing-PK failure was reproduced with the previous native binary.567f6cab→232aec03): 65,536 events, 256 roots, one thread, fixed CPU core, three alternating runs per revision. Keyed output hashes matched. Median bounded-sequence time was 7.96 → 7.96 ms (+0.04%); shared sequence/aggregate time was 22.19 → 22.33 ms (+0.63%). This measured query execution; ingestion, training, and GPU execution were not timed.Change map
File-by-file change map.