@secondlayer/shared 7.9.0 → 7.10.0

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.
@@ -1,5 +1,23 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { ColumnType, Generated, Selectable } from "kysely";
3
+ /**
4
+ * Coverage-kernel constraints. SQL CHECKs in migration 0116 must stay
5
+ * identical — property tests treat this file as the spec.
6
+ */
7
+ declare const STAGE_KINDS: readonly ["raw", "decode", "subgraph", "queue"];
8
+ type StageKind = (typeof STAGE_KINDS)[number];
9
+ declare const NATIVE_CLOCKS: readonly ["block", "cursor", "queue"];
10
+ type NativeClock = (typeof NATIVE_CLOCKS)[number];
11
+ declare const REPAIR_MODES: readonly ["range_safe", "full_reindex", "archive_replay", "none"];
12
+ type RepairMode = (typeof REPAIR_MODES)[number];
13
+ declare const RUN_STATUSES: readonly ["pending", "running", "complete", "syncing", "lagging", "gap", "stale", "failed", "unverified_import", "unanchored", "source_unavailable", "out_of_scope", "disabled", "halted"];
14
+ type RunStatus = (typeof RUN_STATUSES)[number];
15
+ declare const FAILURE_UNITS: readonly ["block", "range", "cursor", "queue"];
16
+ type FailureUnit = (typeof FAILURE_UNITS)[number];
17
+ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch", "crash", "reorg", "source_gap", "handler", "timeout", "unknown"];
18
+ type FailureClass = (typeof FAILURE_CLASSES)[number];
19
+ declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
20
+ type RetryState = (typeof RETRY_STATES)[number];
3
21
  interface BlocksTable {
4
22
  height: number;
5
23
  hash: string;
@@ -727,6 +745,72 @@ interface ObserverJournalTable {
727
745
  error: string | null;
728
746
  processed_at: Date | null;
729
747
  }
748
+ /** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */
749
+ interface StageRegistryTable {
750
+ id: string;
751
+ kind: StageKind;
752
+ depends_on: string | null;
753
+ native_clock: NativeClock;
754
+ producer_version: string;
755
+ repair_mode: RepairMode;
756
+ enabled: Generated<boolean>;
757
+ created_at: Generated<Date>;
758
+ }
759
+ /** One versioned sweep of a stage. */
760
+ interface StageRunsTable {
761
+ id: Generated<string>;
762
+ stage_id: string;
763
+ code_hash: string;
764
+ config_hash: string;
765
+ handler_hash: string | null;
766
+ target_height: number | null;
767
+ target_cursor: string | null;
768
+ status: RunStatus;
769
+ complete_through: number | null;
770
+ started_at: Generated<Date>;
771
+ finished_at: Date | null;
772
+ }
773
+ /** Per-block acknowledgement. Unique on (stage, height, hash). */
774
+ interface StageBlockReceiptsTable {
775
+ id: Generated<string>;
776
+ stage_id: string;
777
+ run_id: string | null;
778
+ block_height: number;
779
+ block_hash: string;
780
+ input_count: number;
781
+ input_digest: string;
782
+ effect_digest: string;
783
+ finalized: Generated<boolean>;
784
+ compacted_at: Date | null;
785
+ created_at: Generated<Date>;
786
+ }
787
+ /** Compacted finalized range. Only sealed after receipts in the range finalize. */
788
+ interface CoverageSegmentsTable {
789
+ id: Generated<string>;
790
+ stage_id: string;
791
+ from_height: number;
792
+ to_height: number;
793
+ chain_digest: string;
794
+ input_digest: string;
795
+ output_digest: string;
796
+ sealed_at: Generated<Date>;
797
+ }
798
+ /** Exact unit or range that failed, plus retry/retention state. */
799
+ interface StageFailuresTable {
800
+ id: Generated<string>;
801
+ stage_id: string;
802
+ run_id: string | null;
803
+ unit_kind: FailureUnit;
804
+ from_height: number | null;
805
+ to_height: number | null;
806
+ class: FailureClass;
807
+ retry_state: RetryState;
808
+ retry_count: Generated<number>;
809
+ last_error: string | null;
810
+ created_at: Generated<Date>;
811
+ resolved_at: Date | null;
812
+ retain_until: Generated<Date>;
813
+ }
730
814
  interface Database {
731
815
  blocks: BlocksTable;
732
816
  transactions: TransactionsTable;
@@ -792,6 +876,11 @@ interface Database {
792
876
  chain_read_cache: ChainReadCacheTable;
793
877
  pending_fork_blocks: PendingForkBlocksTable;
794
878
  observer_journal: ObserverJournalTable;
879
+ stage_registry: StageRegistryTable;
880
+ stage_runs: StageRunsTable;
881
+ stage_block_receipts: StageBlockReceiptsTable;
882
+ coverage_segments: CoverageSegmentsTable;
883
+ stage_failures: StageFailuresTable;
795
884
  }
796
885
  /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
797
886
  interface X402BalancesTable {
@@ -1,5 +1,23 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { ColumnType, Generated } from "kysely";
3
+ /**
4
+ * Coverage-kernel constraints. SQL CHECKs in migration 0116 must stay
5
+ * identical — property tests treat this file as the spec.
6
+ */
7
+ declare const STAGE_KINDS: readonly ["raw", "decode", "subgraph", "queue"];
8
+ type StageKind = (typeof STAGE_KINDS)[number];
9
+ declare const NATIVE_CLOCKS: readonly ["block", "cursor", "queue"];
10
+ type NativeClock = (typeof NATIVE_CLOCKS)[number];
11
+ declare const REPAIR_MODES: readonly ["range_safe", "full_reindex", "archive_replay", "none"];
12
+ type RepairMode = (typeof REPAIR_MODES)[number];
13
+ declare const RUN_STATUSES: readonly ["pending", "running", "complete", "syncing", "lagging", "gap", "stale", "failed", "unverified_import", "unanchored", "source_unavailable", "out_of_scope", "disabled", "halted"];
14
+ type RunStatus = (typeof RUN_STATUSES)[number];
15
+ declare const FAILURE_UNITS: readonly ["block", "range", "cursor", "queue"];
16
+ type FailureUnit = (typeof FAILURE_UNITS)[number];
17
+ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch", "crash", "reorg", "source_gap", "handler", "timeout", "unknown"];
18
+ type FailureClass = (typeof FAILURE_CLASSES)[number];
19
+ declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
20
+ type RetryState = (typeof RETRY_STATES)[number];
3
21
  interface BlocksTable {
4
22
  height: number;
5
23
  hash: string;
@@ -727,6 +745,72 @@ interface ObserverJournalTable {
727
745
  error: string | null;
728
746
  processed_at: Date | null;
729
747
  }
748
+ /** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */
749
+ interface StageRegistryTable {
750
+ id: string;
751
+ kind: StageKind;
752
+ depends_on: string | null;
753
+ native_clock: NativeClock;
754
+ producer_version: string;
755
+ repair_mode: RepairMode;
756
+ enabled: Generated<boolean>;
757
+ created_at: Generated<Date>;
758
+ }
759
+ /** One versioned sweep of a stage. */
760
+ interface StageRunsTable {
761
+ id: Generated<string>;
762
+ stage_id: string;
763
+ code_hash: string;
764
+ config_hash: string;
765
+ handler_hash: string | null;
766
+ target_height: number | null;
767
+ target_cursor: string | null;
768
+ status: RunStatus;
769
+ complete_through: number | null;
770
+ started_at: Generated<Date>;
771
+ finished_at: Date | null;
772
+ }
773
+ /** Per-block acknowledgement. Unique on (stage, height, hash). */
774
+ interface StageBlockReceiptsTable {
775
+ id: Generated<string>;
776
+ stage_id: string;
777
+ run_id: string | null;
778
+ block_height: number;
779
+ block_hash: string;
780
+ input_count: number;
781
+ input_digest: string;
782
+ effect_digest: string;
783
+ finalized: Generated<boolean>;
784
+ compacted_at: Date | null;
785
+ created_at: Generated<Date>;
786
+ }
787
+ /** Compacted finalized range. Only sealed after receipts in the range finalize. */
788
+ interface CoverageSegmentsTable {
789
+ id: Generated<string>;
790
+ stage_id: string;
791
+ from_height: number;
792
+ to_height: number;
793
+ chain_digest: string;
794
+ input_digest: string;
795
+ output_digest: string;
796
+ sealed_at: Generated<Date>;
797
+ }
798
+ /** Exact unit or range that failed, plus retry/retention state. */
799
+ interface StageFailuresTable {
800
+ id: Generated<string>;
801
+ stage_id: string;
802
+ run_id: string | null;
803
+ unit_kind: FailureUnit;
804
+ from_height: number | null;
805
+ to_height: number | null;
806
+ class: FailureClass;
807
+ retry_state: RetryState;
808
+ retry_count: Generated<number>;
809
+ last_error: string | null;
810
+ created_at: Generated<Date>;
811
+ resolved_at: Date | null;
812
+ retain_until: Generated<Date>;
813
+ }
730
814
  interface Database {
731
815
  blocks: BlocksTable;
732
816
  transactions: TransactionsTable;
@@ -792,6 +876,11 @@ interface Database {
792
876
  chain_read_cache: ChainReadCacheTable;
793
877
  pending_fork_blocks: PendingForkBlocksTable;
794
878
  observer_journal: ObserverJournalTable;
879
+ stage_registry: StageRegistryTable;
880
+ stage_runs: StageRunsTable;
881
+ stage_block_receipts: StageBlockReceiptsTable;
882
+ coverage_segments: CoverageSegmentsTable;
883
+ stage_failures: StageFailuresTable;
795
884
  }
796
885
  /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
797
886
  interface X402BalancesTable {
@@ -1,5 +1,23 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { ColumnType, Generated } from "kysely";
3
+ /**
4
+ * Coverage-kernel constraints. SQL CHECKs in migration 0116 must stay
5
+ * identical — property tests treat this file as the spec.
6
+ */
7
+ declare const STAGE_KINDS: readonly ["raw", "decode", "subgraph", "queue"];
8
+ type StageKind = (typeof STAGE_KINDS)[number];
9
+ declare const NATIVE_CLOCKS: readonly ["block", "cursor", "queue"];
10
+ type NativeClock = (typeof NATIVE_CLOCKS)[number];
11
+ declare const REPAIR_MODES: readonly ["range_safe", "full_reindex", "archive_replay", "none"];
12
+ type RepairMode = (typeof REPAIR_MODES)[number];
13
+ declare const RUN_STATUSES: readonly ["pending", "running", "complete", "syncing", "lagging", "gap", "stale", "failed", "unverified_import", "unanchored", "source_unavailable", "out_of_scope", "disabled", "halted"];
14
+ type RunStatus = (typeof RUN_STATUSES)[number];
15
+ declare const FAILURE_UNITS: readonly ["block", "range", "cursor", "queue"];
16
+ type FailureUnit = (typeof FAILURE_UNITS)[number];
17
+ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch", "crash", "reorg", "source_gap", "handler", "timeout", "unknown"];
18
+ type FailureClass = (typeof FAILURE_CLASSES)[number];
19
+ declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
20
+ type RetryState = (typeof RETRY_STATES)[number];
3
21
  interface BlocksTable {
4
22
  height: number;
5
23
  hash: string;
@@ -727,6 +745,72 @@ interface ObserverJournalTable {
727
745
  error: string | null;
728
746
  processed_at: Date | null;
729
747
  }
748
+ /** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */
749
+ interface StageRegistryTable {
750
+ id: string;
751
+ kind: StageKind;
752
+ depends_on: string | null;
753
+ native_clock: NativeClock;
754
+ producer_version: string;
755
+ repair_mode: RepairMode;
756
+ enabled: Generated<boolean>;
757
+ created_at: Generated<Date>;
758
+ }
759
+ /** One versioned sweep of a stage. */
760
+ interface StageRunsTable {
761
+ id: Generated<string>;
762
+ stage_id: string;
763
+ code_hash: string;
764
+ config_hash: string;
765
+ handler_hash: string | null;
766
+ target_height: number | null;
767
+ target_cursor: string | null;
768
+ status: RunStatus;
769
+ complete_through: number | null;
770
+ started_at: Generated<Date>;
771
+ finished_at: Date | null;
772
+ }
773
+ /** Per-block acknowledgement. Unique on (stage, height, hash). */
774
+ interface StageBlockReceiptsTable {
775
+ id: Generated<string>;
776
+ stage_id: string;
777
+ run_id: string | null;
778
+ block_height: number;
779
+ block_hash: string;
780
+ input_count: number;
781
+ input_digest: string;
782
+ effect_digest: string;
783
+ finalized: Generated<boolean>;
784
+ compacted_at: Date | null;
785
+ created_at: Generated<Date>;
786
+ }
787
+ /** Compacted finalized range. Only sealed after receipts in the range finalize. */
788
+ interface CoverageSegmentsTable {
789
+ id: Generated<string>;
790
+ stage_id: string;
791
+ from_height: number;
792
+ to_height: number;
793
+ chain_digest: string;
794
+ input_digest: string;
795
+ output_digest: string;
796
+ sealed_at: Generated<Date>;
797
+ }
798
+ /** Exact unit or range that failed, plus retry/retention state. */
799
+ interface StageFailuresTable {
800
+ id: Generated<string>;
801
+ stage_id: string;
802
+ run_id: string | null;
803
+ unit_kind: FailureUnit;
804
+ from_height: number | null;
805
+ to_height: number | null;
806
+ class: FailureClass;
807
+ retry_state: RetryState;
808
+ retry_count: Generated<number>;
809
+ last_error: string | null;
810
+ created_at: Generated<Date>;
811
+ resolved_at: Date | null;
812
+ retain_until: Generated<Date>;
813
+ }
730
814
  interface Database {
731
815
  blocks: BlocksTable;
732
816
  transactions: TransactionsTable;
@@ -792,6 +876,11 @@ interface Database {
792
876
  chain_read_cache: ChainReadCacheTable;
793
877
  pending_fork_blocks: PendingForkBlocksTable;
794
878
  observer_journal: ObserverJournalTable;
879
+ stage_registry: StageRegistryTable;
880
+ stage_runs: StageRunsTable;
881
+ stage_block_receipts: StageBlockReceiptsTable;
882
+ coverage_segments: CoverageSegmentsTable;
883
+ stage_failures: StageFailuresTable;
795
884
  }
796
885
  /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
797
886
  interface X402BalancesTable {
@@ -1,5 +1,23 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { ColumnType, Generated } from "kysely";
3
+ /**
4
+ * Coverage-kernel constraints. SQL CHECKs in migration 0116 must stay
5
+ * identical — property tests treat this file as the spec.
6
+ */
7
+ declare const STAGE_KINDS: readonly ["raw", "decode", "subgraph", "queue"];
8
+ type StageKind = (typeof STAGE_KINDS)[number];
9
+ declare const NATIVE_CLOCKS: readonly ["block", "cursor", "queue"];
10
+ type NativeClock = (typeof NATIVE_CLOCKS)[number];
11
+ declare const REPAIR_MODES: readonly ["range_safe", "full_reindex", "archive_replay", "none"];
12
+ type RepairMode = (typeof REPAIR_MODES)[number];
13
+ declare const RUN_STATUSES: readonly ["pending", "running", "complete", "syncing", "lagging", "gap", "stale", "failed", "unverified_import", "unanchored", "source_unavailable", "out_of_scope", "disabled", "halted"];
14
+ type RunStatus = (typeof RUN_STATUSES)[number];
15
+ declare const FAILURE_UNITS: readonly ["block", "range", "cursor", "queue"];
16
+ type FailureUnit = (typeof FAILURE_UNITS)[number];
17
+ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch", "crash", "reorg", "source_gap", "handler", "timeout", "unknown"];
18
+ type FailureClass = (typeof FAILURE_CLASSES)[number];
19
+ declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
20
+ type RetryState = (typeof RETRY_STATES)[number];
3
21
  interface BlocksTable {
4
22
  height: number;
5
23
  hash: string;
@@ -727,6 +745,72 @@ interface ObserverJournalTable {
727
745
  error: string | null;
728
746
  processed_at: Date | null;
729
747
  }
748
+ /** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */
749
+ interface StageRegistryTable {
750
+ id: string;
751
+ kind: StageKind;
752
+ depends_on: string | null;
753
+ native_clock: NativeClock;
754
+ producer_version: string;
755
+ repair_mode: RepairMode;
756
+ enabled: Generated<boolean>;
757
+ created_at: Generated<Date>;
758
+ }
759
+ /** One versioned sweep of a stage. */
760
+ interface StageRunsTable {
761
+ id: Generated<string>;
762
+ stage_id: string;
763
+ code_hash: string;
764
+ config_hash: string;
765
+ handler_hash: string | null;
766
+ target_height: number | null;
767
+ target_cursor: string | null;
768
+ status: RunStatus;
769
+ complete_through: number | null;
770
+ started_at: Generated<Date>;
771
+ finished_at: Date | null;
772
+ }
773
+ /** Per-block acknowledgement. Unique on (stage, height, hash). */
774
+ interface StageBlockReceiptsTable {
775
+ id: Generated<string>;
776
+ stage_id: string;
777
+ run_id: string | null;
778
+ block_height: number;
779
+ block_hash: string;
780
+ input_count: number;
781
+ input_digest: string;
782
+ effect_digest: string;
783
+ finalized: Generated<boolean>;
784
+ compacted_at: Date | null;
785
+ created_at: Generated<Date>;
786
+ }
787
+ /** Compacted finalized range. Only sealed after receipts in the range finalize. */
788
+ interface CoverageSegmentsTable {
789
+ id: Generated<string>;
790
+ stage_id: string;
791
+ from_height: number;
792
+ to_height: number;
793
+ chain_digest: string;
794
+ input_digest: string;
795
+ output_digest: string;
796
+ sealed_at: Generated<Date>;
797
+ }
798
+ /** Exact unit or range that failed, plus retry/retention state. */
799
+ interface StageFailuresTable {
800
+ id: Generated<string>;
801
+ stage_id: string;
802
+ run_id: string | null;
803
+ unit_kind: FailureUnit;
804
+ from_height: number | null;
805
+ to_height: number | null;
806
+ class: FailureClass;
807
+ retry_state: RetryState;
808
+ retry_count: Generated<number>;
809
+ last_error: string | null;
810
+ created_at: Generated<Date>;
811
+ resolved_at: Date | null;
812
+ retain_until: Generated<Date>;
813
+ }
730
814
  interface Database {
731
815
  blocks: BlocksTable;
732
816
  transactions: TransactionsTable;
@@ -792,6 +876,11 @@ interface Database {
792
876
  chain_read_cache: ChainReadCacheTable;
793
877
  pending_fork_blocks: PendingForkBlocksTable;
794
878
  observer_journal: ObserverJournalTable;
879
+ stage_registry: StageRegistryTable;
880
+ stage_runs: StageRunsTable;
881
+ stage_block_receipts: StageBlockReceiptsTable;
882
+ coverage_segments: CoverageSegmentsTable;
883
+ stage_failures: StageFailuresTable;
795
884
  }
796
885
  /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
797
886
  interface X402BalancesTable {
@@ -1,5 +1,23 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { ColumnType, Generated, Selectable } from "kysely";
3
+ /**
4
+ * Coverage-kernel constraints. SQL CHECKs in migration 0116 must stay
5
+ * identical — property tests treat this file as the spec.
6
+ */
7
+ declare const STAGE_KINDS: readonly ["raw", "decode", "subgraph", "queue"];
8
+ type StageKind = (typeof STAGE_KINDS)[number];
9
+ declare const NATIVE_CLOCKS: readonly ["block", "cursor", "queue"];
10
+ type NativeClock = (typeof NATIVE_CLOCKS)[number];
11
+ declare const REPAIR_MODES: readonly ["range_safe", "full_reindex", "archive_replay", "none"];
12
+ type RepairMode = (typeof REPAIR_MODES)[number];
13
+ declare const RUN_STATUSES: readonly ["pending", "running", "complete", "syncing", "lagging", "gap", "stale", "failed", "unverified_import", "unanchored", "source_unavailable", "out_of_scope", "disabled", "halted"];
14
+ type RunStatus = (typeof RUN_STATUSES)[number];
15
+ declare const FAILURE_UNITS: readonly ["block", "range", "cursor", "queue"];
16
+ type FailureUnit = (typeof FAILURE_UNITS)[number];
17
+ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch", "crash", "reorg", "source_gap", "handler", "timeout", "unknown"];
18
+ type FailureClass = (typeof FAILURE_CLASSES)[number];
19
+ declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
20
+ type RetryState = (typeof RETRY_STATES)[number];
3
21
  interface BlocksTable {
4
22
  height: number;
5
23
  hash: string;
@@ -727,6 +745,72 @@ interface ObserverJournalTable {
727
745
  error: string | null;
728
746
  processed_at: Date | null;
729
747
  }
748
+ /** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */
749
+ interface StageRegistryTable {
750
+ id: string;
751
+ kind: StageKind;
752
+ depends_on: string | null;
753
+ native_clock: NativeClock;
754
+ producer_version: string;
755
+ repair_mode: RepairMode;
756
+ enabled: Generated<boolean>;
757
+ created_at: Generated<Date>;
758
+ }
759
+ /** One versioned sweep of a stage. */
760
+ interface StageRunsTable {
761
+ id: Generated<string>;
762
+ stage_id: string;
763
+ code_hash: string;
764
+ config_hash: string;
765
+ handler_hash: string | null;
766
+ target_height: number | null;
767
+ target_cursor: string | null;
768
+ status: RunStatus;
769
+ complete_through: number | null;
770
+ started_at: Generated<Date>;
771
+ finished_at: Date | null;
772
+ }
773
+ /** Per-block acknowledgement. Unique on (stage, height, hash). */
774
+ interface StageBlockReceiptsTable {
775
+ id: Generated<string>;
776
+ stage_id: string;
777
+ run_id: string | null;
778
+ block_height: number;
779
+ block_hash: string;
780
+ input_count: number;
781
+ input_digest: string;
782
+ effect_digest: string;
783
+ finalized: Generated<boolean>;
784
+ compacted_at: Date | null;
785
+ created_at: Generated<Date>;
786
+ }
787
+ /** Compacted finalized range. Only sealed after receipts in the range finalize. */
788
+ interface CoverageSegmentsTable {
789
+ id: Generated<string>;
790
+ stage_id: string;
791
+ from_height: number;
792
+ to_height: number;
793
+ chain_digest: string;
794
+ input_digest: string;
795
+ output_digest: string;
796
+ sealed_at: Generated<Date>;
797
+ }
798
+ /** Exact unit or range that failed, plus retry/retention state. */
799
+ interface StageFailuresTable {
800
+ id: Generated<string>;
801
+ stage_id: string;
802
+ run_id: string | null;
803
+ unit_kind: FailureUnit;
804
+ from_height: number | null;
805
+ to_height: number | null;
806
+ class: FailureClass;
807
+ retry_state: RetryState;
808
+ retry_count: Generated<number>;
809
+ last_error: string | null;
810
+ created_at: Generated<Date>;
811
+ resolved_at: Date | null;
812
+ retain_until: Generated<Date>;
813
+ }
730
814
  interface Database {
731
815
  blocks: BlocksTable;
732
816
  transactions: TransactionsTable;
@@ -792,6 +876,11 @@ interface Database {
792
876
  chain_read_cache: ChainReadCacheTable;
793
877
  pending_fork_blocks: PendingForkBlocksTable;
794
878
  observer_journal: ObserverJournalTable;
879
+ stage_registry: StageRegistryTable;
880
+ stage_runs: StageRunsTable;
881
+ stage_block_receipts: StageBlockReceiptsTable;
882
+ coverage_segments: CoverageSegmentsTable;
883
+ stage_failures: StageFailuresTable;
795
884
  }
796
885
  /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
797
886
  interface X402BalancesTable {
@@ -1,6 +1,24 @@
1
1
  import { Kysely } from "kysely";
2
2
  import postgres from "postgres";
3
3
  import { ColumnType, Generated, Selectable } from "kysely";
4
+ /**
5
+ * Coverage-kernel constraints. SQL CHECKs in migration 0116 must stay
6
+ * identical — property tests treat this file as the spec.
7
+ */
8
+ declare const STAGE_KINDS: readonly ["raw", "decode", "subgraph", "queue"];
9
+ type StageKind = (typeof STAGE_KINDS)[number];
10
+ declare const NATIVE_CLOCKS: readonly ["block", "cursor", "queue"];
11
+ type NativeClock = (typeof NATIVE_CLOCKS)[number];
12
+ declare const REPAIR_MODES: readonly ["range_safe", "full_reindex", "archive_replay", "none"];
13
+ type RepairMode = (typeof REPAIR_MODES)[number];
14
+ declare const RUN_STATUSES: readonly ["pending", "running", "complete", "syncing", "lagging", "gap", "stale", "failed", "unverified_import", "unanchored", "source_unavailable", "out_of_scope", "disabled", "halted"];
15
+ type RunStatus = (typeof RUN_STATUSES)[number];
16
+ declare const FAILURE_UNITS: readonly ["block", "range", "cursor", "queue"];
17
+ type FailureUnit = (typeof FAILURE_UNITS)[number];
18
+ declare const FAILURE_CLASSES: readonly ["omission", "version", "digest_mismatch", "crash", "reorg", "source_gap", "handler", "timeout", "unknown"];
19
+ type FailureClass = (typeof FAILURE_CLASSES)[number];
20
+ declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
21
+ type RetryState = (typeof RETRY_STATES)[number];
4
22
  interface BlocksTable {
5
23
  height: number;
6
24
  hash: string;
@@ -728,6 +746,72 @@ interface ObserverJournalTable {
728
746
  error: string | null;
729
747
  processed_at: Date | null;
730
748
  }
749
+ /** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */
750
+ interface StageRegistryTable {
751
+ id: string;
752
+ kind: StageKind;
753
+ depends_on: string | null;
754
+ native_clock: NativeClock;
755
+ producer_version: string;
756
+ repair_mode: RepairMode;
757
+ enabled: Generated<boolean>;
758
+ created_at: Generated<Date>;
759
+ }
760
+ /** One versioned sweep of a stage. */
761
+ interface StageRunsTable {
762
+ id: Generated<string>;
763
+ stage_id: string;
764
+ code_hash: string;
765
+ config_hash: string;
766
+ handler_hash: string | null;
767
+ target_height: number | null;
768
+ target_cursor: string | null;
769
+ status: RunStatus;
770
+ complete_through: number | null;
771
+ started_at: Generated<Date>;
772
+ finished_at: Date | null;
773
+ }
774
+ /** Per-block acknowledgement. Unique on (stage, height, hash). */
775
+ interface StageBlockReceiptsTable {
776
+ id: Generated<string>;
777
+ stage_id: string;
778
+ run_id: string | null;
779
+ block_height: number;
780
+ block_hash: string;
781
+ input_count: number;
782
+ input_digest: string;
783
+ effect_digest: string;
784
+ finalized: Generated<boolean>;
785
+ compacted_at: Date | null;
786
+ created_at: Generated<Date>;
787
+ }
788
+ /** Compacted finalized range. Only sealed after receipts in the range finalize. */
789
+ interface CoverageSegmentsTable {
790
+ id: Generated<string>;
791
+ stage_id: string;
792
+ from_height: number;
793
+ to_height: number;
794
+ chain_digest: string;
795
+ input_digest: string;
796
+ output_digest: string;
797
+ sealed_at: Generated<Date>;
798
+ }
799
+ /** Exact unit or range that failed, plus retry/retention state. */
800
+ interface StageFailuresTable {
801
+ id: Generated<string>;
802
+ stage_id: string;
803
+ run_id: string | null;
804
+ unit_kind: FailureUnit;
805
+ from_height: number | null;
806
+ to_height: number | null;
807
+ class: FailureClass;
808
+ retry_state: RetryState;
809
+ retry_count: Generated<number>;
810
+ last_error: string | null;
811
+ created_at: Generated<Date>;
812
+ resolved_at: Date | null;
813
+ retain_until: Generated<Date>;
814
+ }
731
815
  interface Database {
732
816
  blocks: BlocksTable;
733
817
  transactions: TransactionsTable;
@@ -793,6 +877,11 @@ interface Database {
793
877
  chain_read_cache: ChainReadCacheTable;
794
878
  pending_fork_blocks: PendingForkBlocksTable;
795
879
  observer_journal: ObserverJournalTable;
880
+ stage_registry: StageRegistryTable;
881
+ stage_runs: StageRunsTable;
882
+ stage_block_receipts: StageBlockReceiptsTable;
883
+ coverage_segments: CoverageSegmentsTable;
884
+ stage_failures: StageFailuresTable;
796
885
  }
797
886
  /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
798
887
  interface X402BalancesTable {
@@ -722,6 +722,11 @@ var TABLE_TO_DB = {
722
722
  chain_read_cache: "source",
723
723
  pending_fork_blocks: "source",
724
724
  observer_journal: "source",
725
+ stage_registry: "source",
726
+ stage_runs: "source",
727
+ stage_block_receipts: "source",
728
+ coverage_segments: "source",
729
+ stage_failures: "source",
725
730
  decoded_events: "source",
726
731
  decoder_checkpoints: "source",
727
732
  pox4_calls: "source",
@@ -1256,5 +1261,5 @@ export {
1256
1261
  deleteSubgraph
1257
1262
  };
1258
1263
 
1259
- //# debugId=BD59655AE696BBAF64756E2164756E21
1264
+ //# debugId=9656EAE5754BCCD264756E2164756E21
1260
1265
  //# sourceMappingURL=subgraphs.js.map