Skip to content

Adds support to fork a graph at any timestamp - #552

Draft
akhileshh wants to merge 11 commits into
meshing-v2-pcgv3from
table-forks
Draft

akhileshh wants to merge 11 commits into
meshing-v2-pcgv3from
table-forks

Conversation

@akhileshh

@akhileshh akhileshh commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Forks of a graph at any timestamp: a fork answers reads as its source did at the fork time, and its edits land in the fork alone, without copying any data.

How a fork reads

  • create_fork makes a new, empty table, plus a marker naming its source and the fork time TF.
  • Each read runs on the fork's table and, in parallel, on its source, with the source's time window ending at TF, inclusive.
    • A window starting after TF skips the source; one ending before TF caps the source there instead.
    • So a source edit stamped after TF never reaches the fork.
  • The two results merge row by row and column by column, cells newest first, as any read returns them.
    • When both tables hold a cell at the same timestamp, the fork's cell wins and the source's is dropped.
  • Meta and version rows are the fork's own and are never read from the source.
  • The merge lives in KVDbClient, whose registered Bigtable client opens forks.
    • ChunkedGraph opens every graph through that registry and names no backend, and a plain table reads as before.
  • The marker is a JSON column in the fork's own meta row, so opening a fork costs no extra read.
  • A fork of a fork carries the whole chain, each hop capped at its own TF, so opening it reads no upstream meta.

How a fork edits

  • Merges and splits on a fork write only the fork's table; every table above it refuses writes.
  • New node and operation ids come from fork-owned counters, seeded above every id the tables above it minted.
  • Locks refuse a root that an operation the fork inherits still holds indefinitely upstream.
  • All of this lives in KVDbClient, so PCG's edit code runs on a fork unchanged.
  • tests/fork/test_edits.py merges and splits on a fork and checks the source's roots never move.

Choosing the fork time

  • create_fork forks at the newest time at or before the request below which no edit still writes, from KVDbClient's safe_time.
  • It reads the source's op logs back only over edits that may still write, since edits finish within 21 minutes of their op timestamp.
  • By default it steps the fork time below each edit still writing; with wait=True it waits for them to finish instead.
  • The edit write deadline is gone: the 21-minute bound is known, and not enforced.

Meshes

  • A fork serves its source's meshes as of the fork point, read from the source's own mesh dirs.
  • Remeshing a fork is refused with 403 until fork mesh writes land, since remeshing writes mesh files outside the table.

Roadmap

  • Here: fork reads at a past TF, fork mesh reads, and fork edits.
  • Next, fork mesh writes: remeshing and stitching write into the fork's own dynamic dir, reading older fragments from the source's.
    • This lifts the remesh refusal above.
  • Later: supervoxel splitting, and fork segmentation in GCS.

Depends on

🤖 Generated with Claude Code

@akhileshh
akhileshh added this pull request to stack #553 November 5, 2026 23:55
@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.20253% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pychunkedgraph/fork/create.py 93.75% 2 Missing and 1 partial ⚠️

Impacted file tree graph

@@                 Coverage Diff                  @@
##           meshing-v2-pcgv3     #552      +/-   ##
====================================================
+ Coverage             69.31%   69.60%   +0.29%     
====================================================
  Files                    92       94       +2     
  Lines                  8933     8993      +60     
  Branches               1182     1192      +10     
====================================================
+ Hits                   6192     6260      +68     
+ Misses                 2545     2537       -8     
  Partials                196      196              
Files with missing lines Coverage Δ
pychunkedgraph/fork/guard.py 100.00% <100.00%> (ø)
pychunkedgraph/graph/chunkedgraph.py 82.27% <ø> (+0.77%) ⬆️
pychunkedgraph/graph/meta.py 98.18% <100.00%> (+0.02%) ⬆️
pychunkedgraph/graph/operation.py 86.69% <100.00%> (+1.66%) ⬆️
pychunkedgraph/fork/create.py 93.75% <93.75%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akhileshh akhileshh changed the title table forks Adds support to fork a graph at any timestamp Nov 6, 2026
akhileshh and others added 11 commits November 27, 2026 19:20
- `GraphEditOperation._raise_failure` clears the cache, records and re-raises by kind, as the four except blocks did.
- Pre-commit's black moves to 26.10.1.

Co-Authored-By: Claude <noreply@anthropic.com>
- An edit with under 30 s left is refused before its indefinite locks, raising `EditDeadlineError`, a 504.
- Graph writes, the supervoxel-split write included, pass the cap on as kvdbclient's write deadline.
- Needs kvdbclient's `write(deadline=)`.

Co-Authored-By: Claude <noreply@anthropic.com>
- `ChunkedGraph` opens a Bigtable graph through kvdbclient's `ForkClient`.
- `pychunkedgraph.fork.create.create_fork` forks at the requested time, stepped back past the edit cap.
- Needs kvdbclient's fork package.

Co-Authored-By: Claude <noreply@anthropic.com>
refuse_on_fork raises Forbidden in remeshing and handle_remesh.
kvdbclient installs from KVDbClient@da067c7 until its PR releases.
tests/fork/test_meshes.py covers fork manifests and the refusal.

Co-Authored-By: Claude <noreply@anthropic.com>
The image has no git, so pip could not clone the git+https pin.
The archive zip of KVDbClient@da067c7 installs with no git.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same code as da067c7, which no branch holds now, plus coverage tests.
Temporary: dropped with the other pin commits before merge.

Co-Authored-By: Claude <noreply@anthropic.com>
- `ChunkedGraph`, `create_fork` and the fork guard name no backend; the registered client opens forks.
- `create_fork` forks at kvdbclient's `safe_time`, stepping back, or with `wait` waiting.
- The edit write deadline is gone, and kvdbclient pins its fork-reads commit `83ba037`.

Co-Authored-By: Claude <noreply@anthropic.com>
- Move the temporary kvdbclient pin to KVDbClient c528caf.
- Fork fixtures move to a conftest the read, mesh and edit tests share.
- Fork edits change only fork roots, minted above every source root.

Co-Authored-By: Claude <noreply@anthropic.com>
- A watershed's populate marker no longer turns OCDBT on for a table
  storing enabled false.
- A table storing no flag still takes the marker's.

Co-Authored-By: Claude <noreply@anthropic.com>
- create_fork stores a copy's mesh block: its own dynamic dir, its
  source's inherited.
- Remeshing refuses only a fork whose dynamic dir is not its own.

Co-Authored-By: Claude <noreply@anthropic.com>
- `POST /table/<table_id>/fork` wraps `create_fork`, admin only, answering the fork time.
- `create_fork` refuses an existing table, an OCDBT-splitting source and a used fork mesh dir, before writing.

Co-Authored-By: Claude <noreply@anthropic.com>
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