Skip to content

Add scan-and-delete for immutable edge tables - #438

Merged
em3s merged 3 commits into
mainfrom
feat/immutable-edge-scan-delete
Jul 21, 2026
Merged

em3s merged 3 commits into
mainfrom
feat/immutable-edge-scan-delete

Conversation

@em3s

@em3s em3s commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add a scan-and-delete primitive for immutable edge tables and expose it end-to-end — the building block queue/v1 uses to bound its log. Both a consumer commit (poll → process → commit, #439) and plain retention reduce to the same thing: delete a processed prefix by scanning an index range and deleting the matched rows.

An immutable edge table persists only index rows (no State row, no count), so deleting the scanned index keys is a complete delete. HBase has no native range delete, so this scans the matching index rows and issues per-row point deletes (bounded by limit; callers loop to trim a larger range).

Builds on the immutable-edge constraint from #440 (already merged to main): one index in one direction is exactly what makes "deleting the scanned index keys is a complete delete" true by construction.

Changes

Engine primitive:

  • IndexedLabelMixin.scanAndDeleteIndexedEdges(scanFilter) — scans one page of a range and deletes the matched index rows via the existing deleteIndexedEdges, returning the count deleted.
  • TableBinding.scanDelete(index, start, direction, limit, ranges) — new binding op; V2BackedTableBinding implements it gated to immutable edges (require(isImmutable)), NilTableBinding is a no-op.
  • MutationService.scanDelete(...) exposes it on the write path and caps limit at MAX_SCAN_DELETE_LIMIT (1000) so one call cannot scan-and-delete an unbounded range in a single RPC batch; callers loop to drain a larger range. Enforced at the engine, so every caller is bounded.

User-facing surface:

  • EdgeMutationController: DELETE /graph/v3/databases/{database}/tables/{table}/edges/scan/{index} (start, direction, limit, ranges) → EdgeScanDeleteResponse{database, table, index, deleted}. limit is required (destructive op — force explicit intent). Blocked in read-only mode by the existing ReadOnlyRequestFilter (non-GET).

Deliberately immutable-only: for a mutable indexed edge, deleting only index rows would leave the State row and count dangling.

How to Test

  • ./gradlew :engine:test --tests "*ImmutableEdgeSpec" — includes a case: append 3 rows, scanDelete seq <= 1001, assert 2 deleted and only the newer row remains.
  • ./gradlew :server:test --tests "*ImmutableEdgeE2ETest" — includes E2Es: append then scanDelete deletes the matched page and leaves the rest; an over-cap limit is rejected with 400.
  • ./gradlew :engine:spotlessCheck :server:spotlessCheck.

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: claude code (opus 4.8)

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 21, 2026
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from 830506b to 80f85ec Compare July 21, 2026 08:55
em3s added a commit that referenced this pull request Jul 21, 2026
Make #438 self-contained: a user-facing endpoint and E2E for the engine
scan-and-delete primitive, plus a bound on how much one call can delete.

- EdgeMutationController: DELETE /graph/v3/databases/{db}/tables/{table}/edges/scan/{index}
  (start, direction, limit, ranges) -> EdgeScanDeleteResponse{database, table, index, deleted}.
  `limit` is required (destructive op, force explicit intent).
- MutationService.scanDelete caps `limit` at MAX_SCAN_DELETE_LIMIT (1000) so one call
  cannot scan-and-delete an unbounded range in a single RPC batch; callers loop to
  drain a larger range. Enforced at the engine so every caller is bounded.
- E2E in ImmutableEdgeE2ETest: append then scanDelete `seq <= X` deletes the matched
  page and leaves the rest; over-cap limit is rejected with 400.

DELETE is blocked in read-only mode by the existing ReadOnlyRequestFilter (non-GET).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from 80f85ec to ae2cb22 Compare July 21, 2026 12:57
@em3s
em3s changed the base branch from main to fix/immutable-edge-single-index July 21, 2026 12:57
em3s added a commit that referenced this pull request Jul 21, 2026
Make #438 self-contained: a user-facing endpoint and E2E for the engine
scan-and-delete primitive, plus a bound on how much one call can delete.

- EdgeMutationController: DELETE /graph/v3/databases/{db}/tables/{table}/edges/scan/{index}
  (start, direction, limit, ranges) -> EdgeScanDeleteResponse{database, table, index, deleted}.
  `limit` is required (destructive op, force explicit intent).
- MutationService.scanDelete caps `limit` at MAX_SCAN_DELETE_LIMIT (1000) so one call
  cannot scan-and-delete an unbounded range in a single RPC batch; callers loop to
  drain a larger range. Enforced at the engine so every caller is bounded.
- E2E in ImmutableEdgeE2ETest: append then scanDelete `seq <= X` deletes the matched
  page and leaves the rest; over-cap limit is rejected with 400.

DELETE is blocked in read-only mode by the existing ReadOnlyRequestFilter (non-GET).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from ae2cb22 to 78bfc14 Compare July 21, 2026 13:02
Base automatically changed from fix/immutable-edge-single-index to main July 21, 2026 13:03
em3s added a commit that referenced this pull request Jul 21, 2026
Make #438 self-contained: a user-facing endpoint and E2E for the engine
scan-and-delete primitive, plus a bound on how much one call can delete.

- EdgeMutationController: DELETE /graph/v3/databases/{db}/tables/{table}/edges/scan/{index}
  (start, direction, limit, ranges) -> EdgeScanDeleteResponse{database, table, index, deleted}.
  `limit` is required (destructive op, force explicit intent).
- MutationService.scanDelete caps `limit` at MAX_SCAN_DELETE_LIMIT (1000) so one call
  cannot scan-and-delete an unbounded range in a single RPC batch; callers loop to
  drain a larger range. Enforced at the engine so every caller is bounded.
- E2E in ImmutableEdgeE2ETest: append then scanDelete `seq <= X` deletes the matched
  page and leaves the rest; over-cap limit is rejected with 400.

DELETE is blocked in read-only mode by the existing ReadOnlyRequestFilter (non-GET).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from 78bfc14 to 28c795c Compare July 21, 2026 13:44
em3s added a commit that referenced this pull request Jul 21, 2026
Make #438 self-contained: a user-facing endpoint and E2E for the engine
scan-and-delete primitive, plus a bound on how much one call can delete.

- EdgeMutationController: DELETE /graph/v3/databases/{db}/tables/{table}/edges/scan/{index}
  (start, direction, limit, ranges) -> EdgeScanDeleteResponse{database, table, index, deleted}.
  `limit` is required (destructive op, force explicit intent).
- MutationService.scanDelete caps `limit` at MAX_SCAN_DELETE_LIMIT (1000) so one call
  cannot scan-and-delete an unbounded range in a single RPC batch; callers loop to
  drain a larger range. Enforced at the engine so every caller is bounded.
- E2E in ImmutableEdgeE2ETest: append then scanDelete `seq <= X` deletes the matched
  page and leaves the rest; over-cap limit is rejected with 400.

DELETE is blocked in read-only mode by the existing ReadOnlyRequestFilter (non-GET).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch 2 times, most recently from fc9987b to 945a7ec Compare July 21, 2026 13:58
em3s added a commit that referenced this pull request Jul 21, 2026
Make #438 self-contained: a user-facing endpoint and E2E for the engine
scan-and-delete primitive, plus a bound on how much one call can delete.

- EdgeMutationController: DELETE /graph/v3/databases/{db}/tables/{table}/edges/scan/{index}
  (start, direction, limit, ranges) -> EdgeScanDeleteResponse{database, table, index, deleted}.
  `limit` is required (destructive op, force explicit intent).
- MutationService.scanDelete caps `limit` at MAX_SCAN_DELETE_LIMIT (1000) so one call
  cannot scan-and-delete an unbounded range in a single RPC batch; callers loop to
  drain a larger range. Enforced at the engine so every caller is bounded.
- E2E in ImmutableEdgeE2ETest: append then scanDelete `seq <= X` deletes the matched
  page and leaves the rest; over-cap limit is rejected with 400.

DELETE is blocked in read-only mode by the existing ReadOnlyRequestFilter (non-GET).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@em3s em3s mentioned this pull request Jul 21, 2026
1 task done
em3s and others added 3 commits July 21, 2026 23:47
Immutable edge tables persist only index rows, so deleting the scanned index
keys is a complete delete — the building block queue retention/eviction needs.

- IndexedLabelMixin.scanAndDeleteIndexedEdges: scan one page of a range and
  delete the matched index rows via the existing deleteIndexedEdges, returning
  the count deleted.
- TableBinding.scanDelete + V2BackedTableBinding (gated to immutable edges) +
  NilTableBinding (no-op).
- MutationService.scanDelete exposes it on the write path.

HBase has no native range delete, so this issues per-row point deletes after a
scan (bounded by limit; callers loop to trim a larger range).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- require the label is IMMUTABLE_INDEXED inside scanAndDeleteIndexedEdges, so it
  cannot corrupt a mutable table (deleting index rows there would leave its State
  row and count records dangling).
- document the group-aggregate semantics: scan-and-delete is eviction, not a
  logical un-append, so group aggregates (lifetime append counts) are
  intentionally not decremented.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Make #438 self-contained: a user-facing endpoint and E2E for the engine
scan-and-delete primitive, plus a bound on how much one call can delete.

- EdgeMutationController: DELETE /graph/v3/databases/{db}/tables/{table}/edges/scan/{index}
  (start, direction, limit, ranges) -> EdgeScanDeleteResponse{database, table, index, deleted}.
  `limit` is required (destructive op, force explicit intent).
- MutationService.scanDelete caps `limit` at MAX_SCAN_DELETE_LIMIT (1000) so one call
  cannot scan-and-delete an unbounded range in a single RPC batch; callers loop to
  drain a larger range. Enforced at the engine so every caller is bounded.
- E2E in ImmutableEdgeE2ETest: append then scanDelete `seq <= X` deletes the matched
  page and leaves the rest; over-cap limit is rejected with 400.

DELETE is blocked in read-only mode by the existing ReadOnlyRequestFilter (non-GET).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from 945a7ec to 704c41b Compare July 21, 2026 14:48
@em3s

em3s commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Optimistic

@em3s
em3s merged commit b6b8e88 into main Jul 21, 2026
2 checks passed
@em3s
em3s deleted the feat/immutable-edge-scan-delete branch July 21, 2026 14:57
@em3s em3s self-assigned this Jul 21, 2026
@em3s em3s mentioned this pull request Jul 21, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant