Repository navigation
Constrain immutable edge tables to one index and one direction - #440
Merged
Merged
Conversation
An immutable edge append writes one index row per index, and those index rows are the whole persisted record (no State row, no count). Eviction (scan-and-delete) scans a single index and deletes only its rows, so a second index's rows would be orphaned: unreachable to trim via the scanned index, yet still returned by scans on the other index. Enforce `indexes.size <= 1` in `ModelSchema.ImmutableEdge.init`, so "the index rows are the record" holds by construction. This keeps immutable-edge eviction a complete delete and is a prerequisite for scan-and-delete. Surfaced while implementing delete. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
em3s
force-pushed
the
fix/immutable-edge-single-index
branch
2 times, most recently
from
July 21, 2026 12:50
bcd8fb5 to
27add0a
Compare
A BOTH-direction immutable edge writes both an OUT and an IN index row per append. Eviction (scan-and-delete) scans one direction and deletes only those rows, so the opposite-direction rows would be orphaned — the same complete-delete violation as multiple indexes. Extend the ImmutableEdge invariant to also require `direction != BOTH`, so an immutable edge is one index in one direction: its persisted rows are exactly the set a single scan can reach and delete. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
em3s
force-pushed
the
fix/immutable-edge-single-index
branch
from
July 21, 2026 12:50
27add0a to
a0d4e3f
Compare
Contributor
Author
|
Merge |
1 task done
1 task done
1 task done
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.
Summary
Establish the constraints for an immutable edge table: exactly one index in one direction (OUT or IN, not BOTH).
Surfaced while implementing scan-and-delete. An immutable edge persists only index rows (no State row, no count), so the index rows are the record — and an append writes one row per
(index x direction). Eviction scans a single index in a single direction and deletes only those rows. Any row keyed by another index, or by the opposite direction, would be orphaned: unreachable to trim via the scanned path, yet still returned by scans that reach it.Constraining an immutable edge to one index and one direction keeps "the index rows are the record" true by construction, so eviction stays a complete delete. This is a prerequisite for the immutable-edge scan-delete work.
Changes
ModelSchema.ImmutableEdge—initblock enforces two invariants:indexes.size <= 1(message names the offending indexes)direction != BOTHEnforced at the model boundary, so it holds for every entry point (table create/update, deserialization, direct construction) and yields a 400 on the create/update path.
Compatibility
The check runs on every construction, including reads (
toV3ModelSchemaImmutableEdgereconstructs the schema from stored metadata). Immutable edge is a new table type and queue/v1 (singleseq_ascindex, OUT) is compliant, so no existing table is affected; a pre-existing table that violated the rule would now fail to read back.How to Test
./gradlew :core:test --tests "*EdgeSchemaSerializationTest"— includes cases asserting a two-index and a BOTH-directionImmutableEdgeconstruction each throw../gradlew :server:test --tests "*ImmutableEdgeE2ETest"— includes E2Es: creating an immutable table with two indexes, or with BOTH direction, returns 400../gradlew :core:spotlessCheck :server:spotlessCheck.AI Assistance