sessionpipe-core 0.13.0 → 0.13.1

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.
@@ -26,9 +26,30 @@ export declare class Outbox {
26
26
  events: Event[];
27
27
  offset: number;
28
28
  };
29
- /** Files older than `days` are pruned; the cursor files with them. */
29
+ /** Files older than `days` are pruned, and each sink's cursor into them. The seq
30
+ * counter stays: a session resumed after the window counts on from where it was,
31
+ * so a receiver's (harness, session, seq) dedup doesn't take its new events for
32
+ * ones it already has, and the sinks read the new file from its start.
33
+ * It all happens under the drain's `flush` lock, since a drain holds the whole
34
+ * cursor map and writes it back: a file and its cursor keys go together, so a
35
+ * session resumed in between can't keep a key past its new file's end. While a
36
+ * drain runs, nothing is pruned (0); the next prune does it. It never throws: it
37
+ * is a cleanup, and a hook's drain comes after it. */
30
38
  prune(days: number, now?: number): number;
39
+ /** A sink's cursor into a session file about to be pruned (`gone`), or one already
40
+ * missing (an earlier prune, an older release, by hand) is removed. The caller
41
+ * holds the `flush` lock. */
42
+ private dropStaleCursors;
31
43
  delete(ref: OutboxRef): void;
44
+ /** The key every sink's cursor holds for a session is removed with the session's
45
+ * file: the key alone pointed into the old file, and a session that went on (still
46
+ * running, or resumed later) had its new file's first events unsent until it grew
47
+ * past that offset. Every file under <state>/cursors is taken (a sink since taken
48
+ * out of the config still has one; one that doesn't parse reads as empty and is
49
+ * left), by the key a drain writes (the file's own name, `safeId`) and by the ref
50
+ * as given. The caller holds the drain's `flush` lock: a drain holds the whole
51
+ * cursor map and writes it back, so a key dropped under it would come back. */
52
+ private dropCursors;
32
53
  }
33
54
  /** Per-sink cursor: byte offset per session file, moved only on a 2xx. */
34
55
  export declare class Cursors {
@@ -36,6 +57,8 @@ export declare class Cursors {
36
57
  readonly sink: string;
37
58
  constructor(root: string, sink: string);
38
59
  private file;
60
+ /** The map; empty when the file is missing, cut off mid-write, or holds anything
61
+ * but an object (`null`, a list), so a drain never indexes into those. */
39
62
  read(): Record<string, number>;
40
63
  write(c: Record<string, number>): void;
41
64
  key(ref: OutboxRef): string;
@@ -44,8 +67,18 @@ export declare class Cursors {
44
67
  * took it is gone (its 15 s deadline ends it without a release), or after 5 min. */
45
68
  export declare function takeLock(root: string, ref: OutboxRef, staleMs?: number): (() => void) | null;
46
69
  /** A named lock under <root>/locks, held by one process at a time: the file names
47
- * its pid. Stale once that process is gone, or after `staleMs`. */
70
+ * its pid and a nonce. Stale once that process is gone, or after `staleMs`. A stale
71
+ * lock is taken over by renaming it aside first: of two workers that both judged it
72
+ * stale, one rename wins, and one that moved a fresh lock instead (another worker's,
73
+ * made in between) puts it back and stands down. The release deletes the file only
74
+ * while it is still this taker's, so a lock taken over can't be wiped by its old
75
+ * holder. Two holders at once used to mean two drains reading the same cursors and
76
+ * sending the same batch (issue #208's one-request-a-second pace rests on one). */
48
77
  export declare function takeNamedLock(root: string, name: string, staleMs?: number): (() => void) | null;
78
+ /** `takeNamedLock`, tried again every `everyMs` until `forMs` have passed: for a
79
+ * command whose work goes under a lock a worker holds for seconds (a drain). null
80
+ * once the time is up. */
81
+ export declare function waitNamedLock(root: string, name: string, forMs: number, everyMs?: number): Promise<(() => void) | null>;
49
82
  /** Whether the process a lock or a claimed job names is still running. A pid that
50
83
  * can't be read counts as running: the age rule decides then. */
51
84
  export declare function processAlive(pid: number): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../src/outbox.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD,qBAAa,MAAM;IACL,QAAQ,CAAC,IAAI,EAAE,MAAM;IAAjC,YAAqB,IAAI,EAAE,MAAM,EAAI;IAErC,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3B;IACD,IAAI,CAA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C,EAAE,MAAM,GAAG,MAAM,CAS7D;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CASvD"}
1
+ {"version":3,"file":"pii.d.ts","sourceRoot":"","sources":["../../../src/privacy/pii.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,UAAU,CAAC;AA2BnC,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAS7D;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CASvD"}
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- // sessionpipe-core 0.13.0 · Apache-2.0 · https://sessionpipe.org
1
+ // sessionpipe-core 0.13.1 · Apache-2.0 · https://sessionpipe.org
2
2
 
3
3
  // src/version.ts
4
4
  import { spawn } from "node:child_process";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sessionpipe-core",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "sessionpipe core: protocol types, harness adapters, privacy filter and redaction rulesets, outbox and sinks. Zero runtime dependencies. (published unscoped until the @sessionpipe npm org exists; the code is the same)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",