OverviewFilesCommitsIssuesDocsReleasesPeers

atproto-store commits / 975f5da

OverlayRepoStore.put: stamp a per-write TID rev for atproto-native merge
Records carry no rev at put time (the commit rev comes at sign), so a monotonic per-write TID is minted as the overlay change-feed version — cross-device conflicts resolve rev-wins (later write wins) instead of falling back to feed seq. Only touches the change feed, never the canonical record file, so the byte-identical determinism proofs still hold. Tracks hyper-social #8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
975f5da06e5793d5c2dec3e5a9e5c7536cf8b5a4
by plankatron <fleeky@gmail.com> · 2026-07-19T18:09:44.000Z

Changed files (2) +6 -2

lib/overlay-repo-store.js +5 -1
……@@ -19,6 +19,7 @@ import * as dagCbor from '@ipld/dag-cbor'
1919import b4a from 'b4a'
2020import fs from '#node:fs' // dual-runtime: bare-fs under Bare (the daemon), builtin fs under Node (tests)
2121import { join } from '#node:path'
22import { tidNow } from './tid.js'
2223
2324const EXT = '.dagcbor'
2425const byteOrder = (a, b) => b4a.compare(b4a.from(a), b4a.from(b)) // match Hyperbee's key comparison exactly
……@@ -55,7 +56,10 @@ export class OverlayRepoStore {
5556 const p = this._pathFor(collection, rkey)
5657 fs.mkdirSync(join(this._recordsDir, collection), { recursive: true })
5758 fs.writeFileSync(p, bytes)
58 if (this._overlay) { try { await this._overlay.registerFile(this._overlayPath(collection, rkey), p, { size: bytes.length }) } catch {} }
59 // Stamp a monotonic per-write version (TID) so cross-device conflict resolution is atproto-native
60 // (rev-wins: the later write wins). Records carry no rev at put time — the commit rev comes at sign.
61 // Only affects the overlay change feed, never the canonical record file → determinism is preserved.
62 if (this._overlay) { try { await this._overlay.registerFile(this._overlayPath(collection, rkey), p, { size: bytes.length, rev: tidNow() }) } catch {} }
5963 }
6064
6165 async get (collection, rkey) {
package.json +1 -1
……@@ -1,6 +1,6 @@
11{
22 "name": "atproto-store",
3 "version": "0.0.4",
3 "version": "0.0.5",
44 "description": "Holepunch-native atproto repo store \u2014 records in a classic Hyperbee (collection/rkey -> DAG-CBOR). The P2P home; the atproto-repo module is the bridge serializer over it.",
55 "type": "module",
66 "main": "lib/repo-store.js",