Skip to content

M6e: recursive tuple-stream detection (focus/index under sort/predicate)#22

Merged
flearc merged 2 commits into
mainfrom
feature/m6e-nested-tuple-detection
Jun 25, 2026
Merged

M6e: recursive tuple-stream detection (focus/index under sort/predicate)#22
flearc merged 2 commits into
mainfrom
feature/m6e-nested-tuple-detection

Conversation

@flearc

@flearc flearc commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Root-cause fix (via systematic debugging) for the last sort-on-focus joins failures. The tuple-mode detection was non-recursive: a ^(sort) or [predicate] nests a @$v/#$v step into a sub-path, so no top-level step carried .tuple and the whole path skipped eval_path_tuple entirely → tuple bindings lost → null.

  • Fix (fe18f86), mirroring the already-recursive path_keeps_array:
    • path_is_tuple now recurses into nested path steps.
    • the path dispatch uses path_is_tuple(node) instead of a one-level scan.
    • the self-contained-step-1 seeding routes a nested tuple sub-path through eval_path_tuple(…, true) so its bindings survive (the gap M6c left in seeding; the main loop already did this).
  • Baseline (038f860): regen, additions-only.

Results

  • Official suite 1246 → 1249 (+3); joins 36 → 38/43employee-map-reduce/7,8 (sort-on-focus) plus a bonus sorting/case020 (a general correctness fix, not a 2-case patch).
  • 491 unit tests green; zero-regression guard green (baseline diff additions-only; %-parent / sorting / transform unaffected).
  • Oracle-faithful: case 7 byte-identical to jsonata-js v2.2.1; cases 7/8/case020 asserted against the official expected results; no-perturbation spot-checked.

Remaining joins gaps (deferred)

The reorder cases ($[[1..4]]#$pos[$pos>=2], $^($)#$pos[$pos<3] — filter/sort before #) still need jsonata's ordered-stages machinery.

Test plan

  • busted spec/ — 491/0
  • busted spec/jsonata_suite_spec.lua — zero-regression guard green
  • bash scripts/run-suite.sh — 1249/1682, joins 38/43
  • TDD: regression test fails without the fix, passes with it
  • Oracle parity (jsonata@2.2.1) on the fixed cases

🤖 Generated with Claude Code

flearc and others added 2 commits June 25, 2026 09:56
…redicate

The tuple-mode scan and path_is_tuple only checked top-level steps, so a focus
(@$v) or index (#$v) step nested inside a sub-path — as a ^(sort) or a [predicate]
wraps it — was missed, and the path skipped eval_path_tuple entirely (bindings
lost, result null). Make path_is_tuple recurse into nested path steps (mirroring
path_keeps_array), use it for the dispatch decision, and route a self-contained
nested tuple sub-path through eval_path_tuple(...,true) in the seeding so its
bindings survive (the gap M6c left in seeding; the main loop already did this).

Fixes joins/employee-map-reduce 7,8 (sort-on-focus) + sorting/case020.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ro regressions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@flearc flearc merged commit ebc463a into main Jun 25, 2026
1 check passed
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