Skip to content

Simplify window decisions and relational query execution - #152

Merged
KidkArolis merged 2 commits into
masterfrom
codex/query-execution-refactor
Sep 30, 2026
Merged

KidkArolis merged 2 commits into
masterfrom
codex/query-execution-refactor

Conversation

@KidkArolis

@KidkArolis KidkArolis commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Window merging, relation synchronization, and query inspection previously mixed decisions with cache updates, recursively synchronized ready relation levels, and repeated classification work. This refactor separates the window decision function, drains relation work through an explicit loop, and reuses compiled classification reasons for inspection.

  • Extract maintainWindow(state, change, context), returning noop, update, or refetch. The store still applies adapter metadata and commits the resulting rows.
  • Queue ready relation levels and process them until no work remains. Reentrant warm subscriptions use the latest queued parent rows; backing store queries, chunk retention, partial results, and request sharing remain in place.
  • Compile classification, projection detection, and diagnostic reasons together. Freeze the reasons once and reuse them in inspect(), with readonly diagnostic types. Remove the unused classification wrappers.
  • Restore the window safety argument and relation-kind documentation beside the extracted functions. Shorten AGENTS.md and remove restrictions on adding tests.

Validation:

  • npm run tsc, npm run lint, npm run ava, and npm run test pass with 453 tests. Lint reports the two existing render-time Date warnings in schema tests.
  • The 1,024-combination policy test compares compiled classification reasons against explainQueryNode. Twelve direct maintainWindow cases cover visible patches, underfilled inserts/removals, boundary ties, full-window removals, offset shifts, metadata-only updates, unknown membership, and missing ordering. Inspection checks verify frozen reasons and reference reuse.
  • npm run package:check verifies packed ESM, CommonJS, declarations, and public/private exports.
  • A one-off comparison of 129,600 window decisions against the original implementation matched decisions and preservation of row-array identity across offsets, requested/served page sizes, ordering, event kinds, known/unknown membership, and visible/invisible rows.
  • Rechecked shared-root fetching, array-field realtime membership, fetch-policy isolation, and query hashing with the comparison probes. Three queries over the same root still issue one root request.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium. Approved: Cursor Bugbot completed with no findings, Cursor Security Agent was not running, and no approval policy requires human review. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver - Risk Based

@KidkArolis
KidkArolis merged commit 9e5d8fb into master Sep 30, 2026
5 checks passed
@KidkArolis
KidkArolis deleted the codex/query-execution-refactor branch September 30, 2026 15:18
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