@adhd/backlog 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhd/backlog",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "bin": {
5
5
  "backlog": "index.js"
6
6
  },
@@ -16,7 +16,7 @@
16
16
  "@adhd/environment": "^0.1.5",
17
17
  "@adhd/environment-base-spec": "^0.1.0",
18
18
  "@adhd/sox-graph-store": "^0.8.4",
19
- "@adhd/sox-store-adapter": "^0.5.8",
19
+ "@adhd/sox-store-adapter": "^0.7.0",
20
20
  "@adhd/sox-telemetry": "^0.2.0",
21
21
  "pino": "10.3.1",
22
22
  "pino-pretty": "13.1.3",
@@ -0,0 +1,42 @@
1
+ /** Thrown when another live process already holds the serve lock for this
2
+ * store. Carries the holder's pid and the lock file path so callers can
3
+ * surface both — refusing SILENTLY (a bare non-zero exit with no reason)
4
+ * is exactly the failure mode that let this incident go undetected. */
5
+ export declare class ServeLockHeldError extends Error {
6
+ readonly holderPid: number;
7
+ readonly lockPath: string;
8
+ constructor(holderPid: number, lockPath: string);
9
+ }
10
+ export interface ServeLockHandle {
11
+ /** Idempotent. Removes the lock file ONLY if it still names this process
12
+ * as holder (never deletes a lock a later process legitimately took over
13
+ * after detecting this one as stale — that would delete a live peer's
14
+ * lock out from under it). */
15
+ release: () => void;
16
+ }
17
+ /** `:memory:` has no filesystem identity — no cross-process concern, no lock. */
18
+ export declare function isLockableDbPath(dbPath: string): boolean;
19
+ /** Canonicalizes to the realpath when the file (or its parent dir) exists,
20
+ * so two spellings of the same store collapse to one lock identity; falls
21
+ * back to a plain absolute resolve when nothing on disk exists yet (a
22
+ * not-yet-created db is still a valid lock anchor — mirrors sox-ecosystem's
23
+ * `singleton.ts` `canonicalizePath`, reimplemented here for the same reason
24
+ * noted in this file's header). */
25
+ export declare function canonicalDbPath(dbPath: string): string;
26
+ export declare function serveLockPath(dbPath: string): string;
27
+ /**
28
+ * Acquire the `backlog serve` writer lock for `dbPath`. Fails LOUD and
29
+ * IMMEDIATELY (no spin-wait/retry-until-timeout — a refused `serve` should
30
+ * say why right now, not silently poll and eventually give up) when a live
31
+ * holder is found: throws {@link ServeLockHeldError} naming the holder's
32
+ * pid. A lock file whose recorded pid is no longer alive (crash, SIGKILL,
33
+ * native panic — the same "can't run cleanup code" cases
34
+ * `signal-cleanup.ts`'s own doc comment is honest about) is detected via a
35
+ * liveness probe on READ, not relied on to have been cleaned up by the dead
36
+ * process, and is reclaimed automatically.
37
+ *
38
+ * Call this BEFORE opening the store; release the returned handle only
39
+ * AFTER the store is fully closed (see this file's header re: the
40
+ * shutdown-window).
41
+ */
42
+ export declare function acquireServeLock(dbPath: string): ServeLockHandle;