@indigoai-us/hq-cloud 6.15.6 → 6.15.7

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.
@@ -11,6 +11,37 @@ export interface StateStoreOptions<T> {
11
11
  reduce: (state: T, record: StateStoreRecord) => T;
12
12
  /** Compact after this many WAL records. Defaults to 256. */
13
13
  maxRecordsBeforeCompaction?: number;
14
+ /** Compact once the current WAL reaches this many bytes. Defaults to 16 MiB. */
15
+ maxWalBytesBeforeCompaction?: number;
16
+ }
17
+ export interface StateStoreRecoveryStats {
18
+ /** Bytes in the selected generation's WAL, including its header. */
19
+ walBytes: number;
20
+ /** Largest single snapshot payload or WAL frame buffered during recovery. */
21
+ maxReadBytes: number;
22
+ }
23
+ export interface StateStoreRepairResult {
24
+ recoveredGeneration: number;
25
+ recoveredWalBytes: number;
26
+ firstCompactGeneration: number;
27
+ currentGeneration: number;
28
+ }
29
+ export interface StateStoreRecoveryProgress {
30
+ /** Bytes consumed from the snapshot plus WAL selected for recovery. */
31
+ bytesRead: number;
32
+ /** Total bytes in that snapshot/WAL generation. */
33
+ totalBytes: number;
34
+ }
35
+ export type StateStoreMaintenanceResult = {
36
+ status: "missing" | "not-needed";
37
+ } | ({
38
+ status: "repaired";
39
+ } & StateStoreRepairResult);
40
+ export interface StateStoreMaintenanceOptions {
41
+ /** Rewrite even when the generation is already under its byte budget. */
42
+ force?: boolean;
43
+ /** Synchronous recovery progress, suitable for a process heartbeat. */
44
+ onProgress?: (event: StateStoreRecoveryProgress) => void;
14
45
  }
15
46
  export declare class StateStoreCorruptionError extends Error {
16
47
  constructor(message: string, options?: ErrorOptions);
@@ -25,16 +56,37 @@ export declare class StateStore<T> {
25
56
  private state;
26
57
  private lastRecordSequence;
27
58
  private recordCount;
59
+ private walBytes;
60
+ private maxRecoveryReadBytes;
28
61
  private constructor();
29
62
  static exists(rootDir: string, scopeId: string): boolean;
30
63
  static open<T>(options: StateStoreOptions<T>): StateStore<T>;
64
+ /**
65
+ * Repair an over-budget generation without opening it once and refreshing it
66
+ * a second time. The entire recovery and two-copy publication happens under
67
+ * the scope lock, so an appender cannot race the migration.
68
+ */
69
+ static repairIfNeeded<T>(options: StateStoreOptions<T>, maintenance?: StateStoreMaintenanceOptions): StateStoreMaintenanceResult;
31
70
  getState(): T;
32
71
  getGeneration(): number;
33
72
  getLastRecordSequence(): number;
73
+ getRecoveryStats(): StateStoreRecoveryStats;
34
74
  append(type: number, payload: unknown, flags?: number): StateStoreRecord;
75
+ /**
76
+ * Atomically replace the current state with a compact snapshot generation.
77
+ *
78
+ * This is the rollback-compatible write path for domains whose previous
79
+ * reducer cannot understand a new WAL record type. If the recovered
80
+ * generation contains records, publish two compact copies so every retained
81
+ * WAL is header-only before pruning it. Later replacements need one new copy
82
+ * and retain the prior compact copy.
83
+ */
84
+ replaceState(nextState: T): void;
35
85
  /** Create G+1 without ever merging two generations during recovery. */
36
86
  compact(): void;
37
87
  private refreshFromDisk;
38
88
  private compactUnlocked;
89
+ private compactGeneration;
90
+ private installGeneration;
39
91
  }
40
92
  //# sourceMappingURL=state-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../../src/sync/state-store.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,CAAC,CAAC;IAChB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,KAAK,CAAC,CAAC;IAClD,4DAA4D;IAC5D,0BAA0B,CAAC,EAAE,MAAM,CAAC;C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