Skip to content

docs: design crash-safe ownership checkpointing - #79

Merged
Aliferous3 merged 9 commits into
mainfrom
design/ownership-checkpoint-architecture
Oct 19, 2026
Merged

Aliferous3 merged 9 commits into
mainfrom
design/ownership-checkpoint-architecture

Conversation

@Aliferous3

Copy link
Copy Markdown
Owner

Summary

Phase 1C-B0 design tranche — resolves the ownership spec §9.1 persistence-handoff blocker at the design level only. No code, schema, runtime wiring, or production changes.

Fundamental finding: the four-table 012 model is provably insufficient for exact crash-safe accumulation — exact Top-25/human_contributor_count requires the complete per-contributor scope set, multi-invocation walks lose in-memory state, and none of the four tables can hold provisional counters without violating the privacy contract. Minimum amendment: one ephemeral work table (ownership_history_work) + one CAS checkpoint function (prospective migration 013, not created).

Recommended architecture: per-scope accumulate → resolve → commit lifecycle; page delta + cursor advance in ONE Postgres transaction (exactly-once under retry, proven for both forbidden crash windows and lost-response replays); deterministic contributor_key as the work key (preserves Top-25 tie semantics exactly); two-pass identity resolution so overflow contributors' github_node_id/login are never persisted; pinned-revision walks via object(oid:) — flagged as requiring a non-persisting Phase 1C-B0.5 spike (unmeasured query shape).

Contains: full option evaluation (A–D), impossibility analysis, work-table shape/bounds/TTL, versioning/promotion, 19-case failure matrix, concurrency/rate-limit design, backup classification (EPHEMERAL), differential-equivalence test design, and the proposed spec amendment (recorded in §27 as PROPOSED — not live).

Test plan

  • npm test — 613 pass / 0 fail (docs-only diff; contract-scan tests green)
  • No lib/, api/, src/, migrations/, config, or test changes
  • Production untouched; ownership tables remain empty

Generated with Devin

Resolves the spec §9.1 persistence-handoff blocker at the design level:
proves the four-table model cannot carry exact crash-safe accumulation,
and specifies the minimal amendment — one EPHEMERAL pseudonymous work
table, a single-transaction CAS page checkpoint, per-scope two-pass
identity resolution, and a pinned-revision walk (pending a B0.5
non-persisting spike). Records the proposed spec amendment in §27.

Docs only — no code, schema, or config changes.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dev-ledger Ready Ready Preview Oct 19, 2026 5:52am UTC

…dentity

Revision 2: move all durable contributor writes into the single scope-COMMIT
transaction (no identity rows during page-by-page resolve), split ephemeral
state into accumulation counters plus a represented-key-only identity
staging relation, remove the unimplementable resolve-drift fold (a null
author.user carries no node id to map back), reclassify work_key as a
linkable pseudonymous identifier, and make TTL/cursor bounds concrete.

Docs only.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…semantics

Revision 3: is_bot is frozen pass-1 attribution — resolve verifies rather
than re-derives it and a classification flip fails the scope closed; the
staging relation drops is_bot entirely. Adds the explicit pre-flip abandon
transaction (versioned snapshot/ephemeral deletes plus anti-join pruning
of contributor rows unreferenced in ANY version, preserving active-version
references). first_seen_at/last_seen_at now accumulate only across
finalized scopes where the contributor was individually represented —
recorded in the spec so the field names don't overclaim.

Docs only.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Revision 3: ownership_contributors is shared across calculation versions
but the dashboard RPCs version-filter only snapshots — mid-build mutation
of shared contributor metadata would leak into active-version responses
and could not be restored on abort. Identity/metadata staging moves to a
build-grain ephemeral relation (ownership_contributor_build_work);
retained rows are never mutated while a building version is incomplete;
promotion applies staged metadata and flips active_version in one
transaction; abort deletes building artifacts and anti-join prunes
unreferenced contributor rows. is_bot is frozen once per build — drift
between passes or across scopes fails closed. Docs only.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Revision 4: build-level contributor staging accumulates across
already-finalized scopes, so losing any required ephemeral state
invalidates the entire building version — piecemeal resume is impossible.
Adds the canonical own_abandon_build operation reused by the stale sweep,
restore reconciliation, operator abort, and invalid-state recovery;
defines build-state validity invariants; forbids overlapping building
versions; keeps both relations EPHEMERAL (loss = discarded build, never
active data). Docs only.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
ownership_scopes is shared across calculation versions and the deployed
dash_ownership_scopes enumerates base scope rows unversioned, so a
building version could leak new scopes or mutate active exclusion state.
Design adds retained ownership_scope_versions (CORE), moves
excluded/exclusion_reason to per-version membership, routes abandon/GC
and the scopes RPC through membership, and keeps base scope identity
immutable.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
A snapshot must be impossible without version membership: prospective
013 adds a composite (scope, repo, tenant, version) FK from
ownership_snapshots to ownership_scope_versions with NO ACTION/RESTRICT
semantics so cleanup can never cascade-destroy snapshots. Also separates
the hard 500-directory enumeration cap (overflow paths never persisted)
from the cardinality_cap analysis-omission marker, and states per-version
bounds honestly.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Revision 7 state-integrity pass. The snapshot→scope-version FK protected
membership, but 012's snapshots→scopes CASCADE and a cascading
scope_versions→scopes FK would still let a direct base-scope delete
destroy active membership and snapshots — prospective 013 sets both
retained child→scope FKs to ON DELETE NO ACTION (repo/account teardown
still cascades via the direct repository/user FKs; NO ACTION is named
exactly because it checks after the statement's referential actions,
unlike RESTRICT). Adds the retired-version lifecycle gate: at most one
active plus one building version, fresh-build preflight GCs retired
versions in legal order before initializing, making the ≤~1000 base
identity bound real. Defines committed-V-provenance staging cleanup on
scope restart (build-level staging has no scope provenance and the
represented set can drift), and strengthens promotion to require the
staged linked key set to exactly equal the represented V key set. Docs
only — no migration, no production change.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Aliferous3
Aliferous3 merged commit 12f160c into main Oct 19, 2026
5 checks passed

This branch was successfully deployed

1 active deployment
Preview — faa83cf6 Deployed Oct 19, 2026 by vercel[bot]
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