docs(selfhost): verify + document the shared backend's concurrency model - #8071
docs(selfhost): verify + document the shared backend's concurrency model#8071davion-knight wants to merge 1 commit into
Conversation
The AMS local-store concurrency guarantees were designed for two local processes sharing one SQLite file. JSONbored#7175 migrated that layer onto the shared SelfHostD1Database seam (SQLite + Postgres adapters), so the guarantees the hosted service now relies on need to be verified against the real seam and stated explicitly rather than inherited implicitly from the old local-file design. Adds src/selfhost/backend-concurrency-model.md documenting what each adapter guarantees (batch() atomicity, no-lost-update for atomic writes) and what it does not (non-atomic read-modify-write, cross-process SQLite sharing), with the guarantees pinned by a deterministic in-process test of the SQLite seam (test/unit/selfhost-d1-concurrency.test.ts) and cross-referencing the existing PG_TEST_URL-gated integration suite for the Postgres side. The SQLite backend's real topology is single-process/synchronous, so its guarantees are verified in-process with no external dependency and no flakiness; real multi-connection Postgres concurrency stays behind the existing gated integration test rather than a scripted mock that cannot exhibit real races. Closes JSONbored#4942
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Caution 🛑 LoopOver review result - fixes requiredReview updated: 2026-07-22 18:49:35 UTC
Review summary Nits — 5 non-blocking
CI checks failing
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-tests (3), validate-tests (2), validate-tests (1))). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
What & why
The AMS local-store concurrency guarantees were originally designed for two local processes sharing one SQLite file. #7175 migrated that layer onto the shared
SelfHostD1Databaseseam (src/selfhost/backend-contracts.ts, #4010), which now has two interchangeable adapters — SQLite (d1-adapter.ts) and Postgres (pg-adapter.ts). This PR verifies and documents what concurrency those adapters actually guarantee, so the hosted service's assumptions are stated explicitly instead of inherited implicitly from the old local-file design.Deliverables
1. Documented concurrency model —
src/selfhost/backend-concurrency-model.md. Records, per adapter, what is guaranteed (batch()all-or-nothing atomicity; no lost updates for atomic single-statement writes; committed batches apply in order; reads never see an uncommitted intermediate) and what is not (non-atomic read-modify-write across awaits; cross-process SQLite sharing — out of scope for the single-process-per-deployment topology the admission system already assumes). Every claim cites the exact code it describes.2. A deterministic verification test —
test/unit/selfhost-d1-concurrency.test.ts. Exercises concurrent read/write against the realcreateD1Adapter(nodeSqliteDriver(...))seam (opened with the production PRAGMAs) and asserts: N concurrent atomic increments lose no updates;batch()rolls back fully on a failing statement; a committed batch applies in order; a read concurrent with a batch never observes a rolled-back intermediate; and — as the documented hazard — a non-atomic read-modify-write does lose updates.Why this test shape
The SQLite backend's real topology is single-process with a synchronous driver, so its guarantees are verified deterministically in-process — no external dependency, no flakiness. Real multi-connection Postgres concurrency needs a live server, so it stays behind the existing
PG_TEST_URL-gatedtest/integration/selfhost-pg.test.tsrather than a scripted mock that cannot exhibit real races. No production source changes.Closes #4942