Parent: #1438. This is the first atomic unit discovered by Architect/Critic review; it must land before cache consumers are switched to generation validation.
Discovery context
Review of #1438 on base origin/issue-1435-mat-cache (f70897f0) found that replacing nrows checks with generation fields without instrumenting every direct mutation would still permit stale materialization, filtered, sorted, and differential views. Rollback can also accidentally restore an old generation number, and COW/replacement can change storage without changing logical rows.
Scope
- Add internal relation identity plus
view_generation (logical values/order/schema) and storage_generation (backing-buffer/COW/replacement) to col_rel_t.
- Define checked overflow behavior: no generation wrap may create a false cache hit; saturate/force invalidation or rotate identity.
- Instrument append, direct cell/row writes, permutation/sort, compaction, retraction/rollback restoration, schema/type changes, COW unshare, and replacement-buffer publication exactly once at the correct success boundary.
- Define deep-copy, shared-view, and worker-copy semantics; worker-local mutations must diverge without mutating coordinator state.
- Add focused generation-transition tests, including same-row-count mutation, permutation, rollback, COW, replacement, worker copy, and overflow boundaries.
Explicit exclusions
Do not change materialization/filter/sorted/differential cache lookup rules in this unit; that is the next unit under #1438. Do not add public API/ABI, spill, suspended-reader, or K-Fusion retirement work.
Acceptance criteria
- Every in-scope mutation path advances the correct generation once, including same-row-count changes.
- Storage-only changes advance storage generation without falsely claiming a logical view change.
- Rollback/restoration issues a fresh generation rather than reusing a prior value.
- Deep-copy/shared-view/worker-copy tests prove independent generation behavior.
- Overflow handling cannot produce a false equality with an older generation.
- Focused normal and ASan/UBSan tests, clang-tidy, and existing relation/worker regressions pass.
Dependency
Feeds #1438's cache-consumer generation validation, then #1371/#1372/#1382/#1383.
Parent: #1438. This is the first atomic unit discovered by Architect/Critic review; it must land before cache consumers are switched to generation validation.
Discovery context
Review of #1438 on base
origin/issue-1435-mat-cache(f70897f0) found that replacingnrowschecks with generation fields without instrumenting every direct mutation would still permit stale materialization, filtered, sorted, and differential views. Rollback can also accidentally restore an old generation number, and COW/replacement can change storage without changing logical rows.Scope
view_generation(logical values/order/schema) andstorage_generation(backing-buffer/COW/replacement) tocol_rel_t.Explicit exclusions
Do not change materialization/filter/sorted/differential cache lookup rules in this unit; that is the next unit under #1438. Do not add public API/ABI, spill, suspended-reader, or K-Fusion retirement work.
Acceptance criteria
Dependency
Feeds #1438's cache-consumer generation validation, then #1371/#1372/#1382/#1383.