@ocap/types 1.30.21 → 1.30.23

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.
@@ -158,6 +158,42 @@ export interface IMerkleProof {
158
158
  root: string;
159
159
  }
160
160
 
161
+ // ============================================================================
162
+ // Health Metrics
163
+ // ============================================================================
164
+
165
+ /**
166
+ * Ledger health snapshot used by /ledger-health monitoring endpoint.
167
+ *
168
+ * Designed to surface the "stuck checkpoint" failure mode (see ledger.ts
169
+ * createCheckpointIfNeeded): if any entry in the pending range stays
170
+ * finalized=0, createCheckpoint is permanently skipped and lag grows
171
+ * unbounded.
172
+ */
173
+ export interface ILedgerHealth {
174
+ /** Latest entry sequence in the ledger */
175
+ latestSequence: number;
176
+
177
+ /** Latest checkpoint (null if none created yet) */
178
+ latestCheckpoint: {
179
+ height: number;
180
+ sequence: number;
181
+ timestamp: number;
182
+ } | null;
183
+
184
+ /** latestSequence - latestCheckpoint.sequence (0 if no checkpoint) */
185
+ checkpointLag: number;
186
+
187
+ /** ms since latest checkpoint.timestamp (null if no checkpoint) */
188
+ checkpointAgeMs: number | null;
189
+
190
+ /** Count of entries with finalized=0 in the pending range (after latest checkpoint) */
191
+ unfinalizedCount: number;
192
+
193
+ /** Timestamp (ms) of oldest unfinalized entry in pending range, null if none */
194
+ oldestUnfinalizedTimestamp: number | null;
195
+ }
196
+
161
197
  // ============================================================================
162
198
  // Configuration Types
163
199
  // ============================================================================
@@ -272,6 +308,14 @@ export interface ILedgerStorage {
272
308
  */
273
309
  hasUnfinalizedInRange(fromSeq: number, toSeq: number): Promise<boolean>;
274
310
 
311
+ /**
312
+ * Count unfinalized entries and find oldest timestamp in range.
313
+ * Used by the health endpoint to detect stuck checkpoints.
314
+ *
315
+ * @returns count and oldest timestamp (null if count=0)
316
+ */
317
+ getUnfinalizedStats(fromSeq: number, toSeq: number): Promise<{ count: number; oldestTimestamp: number | null }>;
318
+
275
319
  // Checkpoint operations
276
320
  saveCheckpoint(checkpoint: ICheckpoint): Promise<void>;
277
321
  getCheckpointByHeight(height: number): Promise<ICheckpoint | null>;
@@ -342,6 +386,9 @@ export interface ILedger {
342
386
  getMerkleProof(sequence: number): Promise<IMerkleProof>;
343
387
  verifyMerkleProof(proof: IMerkleProof): boolean;
344
388
 
389
+ // Monitoring
390
+ getHealth(): Promise<ILedgerHealth>;
391
+
345
392
  // Lifecycle
346
393
  initialize(): Promise<void>;
347
394
  close(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocap/types",
3
- "version": "1.30.21",
3
+ "version": "1.30.23",
4
4
  "description": "Typescript definitions generated from protobuf",
5
5
  "keywords": [
6
6
  "ocap",