docs(cache): ADR 0007 — selection-set-aware cache reads (PR-009a) - #1003
Merged
AnthonyMDev merged 1 commit intoMay 29, 2026
Conversation
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: bcfdcd0a695d6e2dd8d7ae93 ✅ AI Style Review — No Changes DetectedNo MDX files were changed in this pull request. Review Log: View detailed log
|
Captures the architectural shift to per-field column projection for the row-per-field SQLite schema. The whole-record `selectRecords` shape that PR-009 initially drafted is the wrong public contract — shipping it under semver locks out the schema's central optimization permanently. The fix is to thread per-field projection info, including each field's storage-shape type, from the executor down to the cache. Decision principles fixed by this ADR: - The NormalizedCache protocol changes its read shape — breaking change accepted under ADR 0001. - The executor declares field reads upfront, not lazily. - SQL-level column projection is the implementation target for ApolloSQLiteDatabase. - InMemoryNormalizedCache filters fields client-side. - Custom scalars expose their storage column statically; mechanism fixed in PR-009b. Implementation sequence: eight new sub-phase 1A.5 PRs (009a–009h) between the slimmed PR-009 and SQLiteNormalizedCache's switchover. Phase 1A grows from 10 to ~16 PRs, adding 4–6 weeks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AnthonyMDev
force-pushed
the
cache-rewrite/phase-0-adr-007-selection-aware-reads
branch
from
May 29, 2026 16:54
115922d to
0c1d2a2
Compare
7 tasks
AnthonyMDev
deleted the
cache-rewrite/phase-0-adr-007-selection-aware-reads
branch
May 29, 2026 17:49
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Goal
Lock the architectural decision behind the projection-aware sub-phase 1A.5 (PR-009a through PR-009h): cache reads under 3.0 carry per-field projection info, including each field's storage-shape type and the scalar-vs-list discriminator from ADR 0006, end-to-end from executor to SQL. The whole-record
selectRecords(forKeys:)shape that PR-009 initially drafted is removed from the public protocol (already done in PR #1001's slim) and replaced with a projection-aware read API.Why this is needed
PR-008 + the ADR-0006 amendment (PR-008b in the §8 list) produce a row-per-element schema with six type-specific columns and a
positiondiscriminator. Each scalar field is one row atposition = -1; each list element is one row atposition = 0..N-1. Five of the six value columns areNULLon every row, and list reads pull N rows where N is the list length. The schema's design property is that each field (and each list element) has its storage column determined by its GraphQL type, known at codegen time — but the current executor never communicates that type info to the cache.Closing the loop requires changes to
NormalizedCache,ApolloStore.load,CacheDataExecutionSource, andSQLiteNormalizedCache. That's a breaking-protocol-shape change to the publicNormalizedCachecontract — well within scope for the 3.0 major version bump per ADR 0001, but a one-way ratchet under semver. Doing it later means waiting for 4.0.What this ADR commits to
Seven principles (full text in the file). Of particular note after ADR 0006's row-per-element decision:
Intfield projectsint_valuefiltered toposition = -1; a[String]field projectsstring_valuefiltered toposition >= 0ordered byposition.positionpredicates per field.CacheDataExecutionSourceis the highest-risk PR in the sub-phase; may split if the executor's lazy resolution pattern can't migrate in one shot.Non-goals captured:
positiondiscriminator and synthetic sub-record indirection for nested lists.NormalizedCachecontract.Alternatives rejected
Implementation sequence (post-ADR-0006 §8)
Phase 1A grows from the post-ADR-0006 count of 11 PRs to ~17 PRs, adding 4–6 weeks.
Acceptance criteria
Stacks on
cache-rewrite/phase-1-planat4dfb34e4d(the §8 amendment commit). Doc-only — no code dependencies on PR #1001 or future PR-008b.Followup
After this merges:
FieldProjectiontypes.