Skip to content

fix(pi-004): reserve pending deletion and uncommitted page IDs (draft) - #25

Draft
jamespatrickjackson-lang wants to merge 10 commits into
mainfrom
fix/pi-004-page-id-reservations-20261114
Draft

jamespatrickjackson-lang wants to merge 10 commits into
mainfrom
fix/pi-004-page-id-reservations-20261114

Conversation

@jamespatrickjackson-lang

@jamespatrickjackson-lang jamespatrickjackson-lang commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

PI-004 final source package: permanent page identities (DRAFT, no merge)

Approved owner invariant: presentation page IDs are permanent identities, not recyclable ordinals. This PR extends the original two collision fixes to cover deletion/archive/Save/reload while preserving existing legacy page files, archived records, scientific layer ownership and real project data.

Verified baseline: main a8df8211db350b195c89cedcfc39192c48382cb8. Final head: 122fd0f3a6608d741582cf421a2d360a7f25de9b. The PR remains a separate, draft, unmerged implementation of Issue #23.

Backward-compatible identity decision

  • Existing numeric NN_page IDs and filename layouts are left unchanged.
  • New IDs are created using cryptographic UUIDv4 in a disjoint p_<uuid> namespace; retries reject collisions against live/archived IDs, pending tombstones, same-session issued IDs and the persisted identity ledger.
  • Add optional ProjectManifest.issuedPageIds?: string[] to src/pages/types.ts; every new page/Sub Master creation records its ID in the reducer's project manifest, including if later deleted. Manual Save serializes it with project.json, allowing Save/reopen to reject previously issued IDs. Legacy projects without this field load normally.
  • deletePageById rejects unknown/stale IDs. Failed deleteFile now surfaces as a Save error and preserves pending tombstones. Existing historical archive files are checked before any writes; a differing pages/_archive/{id}.json causes a fail-closed conflict, never an overwrite. Identical archive bytes are left untouched.
  • No authoring fallback-page changes or PI-005 logic are in this PR.

Strict edge: A page ID generated immediately before an unsaved browser crash has no durable ledger entry. Cryptographic UUIDv4 provides practical non-reuse, not a formal zero-probability guarantee across unsaved sessions. A formal guarantee would require an atomic durable issuance journal / asynchronous interface redesign, which was not introduced under this scope.

Exact changed files

src/editor/EditorContext.tsx, src/pages/types.ts, tests/tools/page-id-reservations.test.mjs, tests/tools/permanent-page-identity.test.mjs. No projects/, authored example page, scientific assets, raw data, source files, or provenance files changed.

RED/GREEN receipts

  • Original collision RED test-only commit 3fc194e8e1a3774a2435de433c03d4301a28981f, Actions #43636928052: 679 PASS/2 expected PI-004 FAIL; build PASS.
  • Permanent history RED test-only commit 2e52de5aa7c1911ad8a6a5838ab71572664a1ccc, Actions #43646995108 expected FAIL; implemented afterward.
  • Archive overwrite RED test-only commit a026a55168c2007fd10df448964470d2d81e5006, Actions #43648074660 expected FAIL; source guard implemented afterward.
  • Final GREEN Actions #43648100412 (push) and #43648104291 (PR): 694/694 source tests PASS, 0 fail, build PASS, all configured checks SUCCESS at exact final SHA.

The synthetic scratch-disk test creates an isolated temporary project.json, immutable legacy archive and synthetic data file; reloads JSON and checks an attempted ID collision; verifies protected source/archive bytes unchanged; cleans up its own scratch directory. This is not the real development writer or mounted browser Save/reopen.

Integration and outstanding holds

  • PR #27 is the separate stacked PI-005 zero-page branch, with PR base this PI-004 branch. Do not fold zero-page changes into this PR.
  • PR #22 remains deliberately RED, draft and untouched. The original PI-004 test extractor requires the obsolete single-argument allocator and must be adapted at separately approved integration to exercise new ID/ledger/tombstone semantics; preserve the original negative assertions and TR-02 independence.
  • NOT RUN: actual W4-isolated development writer, browser create/delete/Save/reopen, archive conflicts under live writer, forced deletion faults in browser and real scientific loader/hash invariance. The W4 static isolated preflight does not authorize writer tests. No merge, deployment or real project mutation.

Disposition: source and scratch-serialization candidate for independent owner review; not production-persistence acceptance.

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