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