Skip to main content

krabka_verified/
lib.rs

1//! Formally verified pure kernels shared by Krabka crates.
2//!
3//! These synchronous kernels have Creusot contracts proved under their stated
4//! preconditions. Host state, concurrency, and I/O remain outside that boundary.
5//! See `docs/verification.md` and `docs/proof-contract-audit.md`.
6#![doc(html_root_url = "https://docs.rs/krabka-verified/1.0.8")]
7// Rust's backend does not see names used only in Creusot contracts, and treats
8// the grouping parentheses in Pearlite expressions as redundant Rust syntax.
9#![cfg_attr(creusot, allow(unused_imports, unused_parens))]
10
11macro_rules! creusot_open_spec {
12    ($item:item) => {
13        #[cfg(creusot)]
14        // cargo-mutants: #[cfg(creusot)] spec function; not compiled outside Creusot, so no test can tell.
15        #[cfg_attr(test, mutants::skip)]
16        #[logic(open)]
17        $item
18    };
19}
20pub(crate) use creusot_open_spec;
21
22pub mod audit;
23pub mod authz;
24pub mod barrier;
25pub mod break_glass;
26pub mod break_glass_persistence;
27pub mod broker;
28pub mod chain;
29pub mod checkpoint;
30pub mod compaction;
31#[cfg(any(creusot, test))]
32mod composition;
33pub mod consensus;
34pub mod delegation_token;
35pub mod delivery;
36pub mod directory;
37pub mod diskless;
38pub mod epoch;
39pub mod features;
40pub mod freeze;
41pub mod group_migration;
42pub mod isr;
43pub mod jwks;
44pub mod leader_epoch;
45pub mod list_offsets;
46pub mod local_recovery;
47pub mod log_index;
48pub mod oauth;
49pub mod offset_allocator;
50pub mod opa;
51pub mod produce;
52pub mod producer;
53pub mod producer_id;
54pub mod producer_snapshot;
55pub mod quorum_state;
56pub mod quota;
57pub mod raft;
58pub mod reassignment;
59pub mod reconfiguration;
60pub mod recovery;
61pub mod registration;
62pub mod remote_metadata;
63pub mod remote_read;
64pub mod remote_txn;
65pub mod restore;
66pub mod restore_sidecar;
67pub mod retention;
68pub mod schema;
69pub mod scram;
70#[cfg(creusot)]
71mod sequence;
72pub mod share;
73pub mod snapshot;
74pub mod stamp;
75pub mod storage;
76pub mod stretch;
77pub mod throttle;
78pub mod timestamp;
79pub mod transaction;
80pub mod uniform_assignor;
81pub mod vote;
82pub mod voter_set;
83pub mod wal;
84pub mod worm;
85
86pub use {
87    audit::{
88        AuditCheckpointAdmission, AuditLossMarkerAdmission, SpoolAppendDecision,
89        audit_checkpoint_admission, audit_loss_marker_admission, spool_append_decision,
90    },
91    authz::{
92        AclDecision, AclOperationKind, AclPatternKind, acl_decision, acl_identity_match,
93        acl_operation_match, acl_resource_match,
94    },
95    barrier::{
96        BarrierCutClassification, BarrierMarkerFenceDecision, BarrierMarkerFenceFacts,
97        BarrierPlacementDecision, BarrierTargetCountDecision, barrier_cut_classification,
98        barrier_marker_fence_decision, barrier_placement_decision, barrier_target_count_decision,
99    },
100    break_glass::{BreakGlassAdmission, break_glass_admission, select_break_glass_candidate},
101    break_glass_persistence::{
102        BreakGlassConsumptionDecision, BreakGlassConsumptionFacts, BreakGlassLocalActionDecision,
103        BreakGlassLocalActionFacts, BreakGlassLocalSpendState, BreakGlassProposalState,
104        break_glass_consumption_decision, break_glass_local_action_decision,
105    },
106    broker::{
107        DeleteRecordsTrimApplication, DeleteRecordsTrimDecision, DeleteRecordsTrimFacts,
108        FetchVisibility, FetchWatermarks, ReplicaFetchMutation, delete_records_trim_application,
109        delete_records_trim_decision, effective_share_backlog, fetch_visibility,
110        preferred_rebalance_admission, replica_fetch_mutation, unclean_recovery_commit_admission,
111    },
112    chain::{ChainStep, chain_step, select_chain_tip},
113    checkpoint::{checkpoint_id_newer, checkpoint_id_retained, latest_checkpoint_index},
114    compaction::{
115        BatchMeta, RecordMeta, RetainDecision, TxnDataState, compute_horizon, retain_decision,
116    },
117    consensus::{
118        election_has_quorum, election_jitter_ms, log_is_up_to_date, majority_size,
119        recompute_high_watermark,
120    },
121    delegation_token::{
122        TokenCreateDecision, TokenDeadlines, TokenExpireDecision, TokenMutationDecision,
123        TokenMutationFacts, TokenMutationKind, TokenMutationState, TokenRenewDecision,
124        create_token_deadlines, expire_token_deadline, renew_token_expiry, token_mutation_decision,
125    },
126    delivery::{coalesce_delivery_range, delivery_watermark_advance, scheduled_delivery_visible},
127    directory::{
128        DirectoryAssignmentDecision, DirectoryResponseDecision, directory_assignment_decision,
129        directory_response_decision,
130    },
131    diskless::{
132        DisklessBatchStep, DisklessTrimDecision, diskless_batch_step, diskless_logical_range,
133        diskless_object_reclaimable, diskless_retention_prefix, diskless_span_extension,
134        diskless_trim_decision,
135    },
136    epoch::exact_epoch_successor,
137    features::{FeatureUpdateDecision, feature_update_decision},
138    freeze::{
139        FreezeIdentityState, FreezeMutationDecision, FreezeMutationKind, FreezeReplacementDecision,
140        FreezeReplacementFacts, FreezeScopeDecision, FreezeScopeRank, FreezeSignatureDecision,
141        FreezeSignatureFacts, FreezeStoredState, freeze_mutation_decision, freeze_refuses,
142        freeze_replacement_decision, freeze_scope_decision, freeze_signature_decision,
143        freeze_timestamp_in_window,
144    },
145    group_migration::{
146        GroupMigrationDirection, GroupMigrationRecordAction, GroupMigrationRecordPlan,
147        classic_upgrade_epoch, consumer_downgrade_epoch, group_migration_record_plan,
148    },
149    jwks::{
150        JwksCacheDecision, JwksCacheFacts, JwksOnDemandDecision, jwks_cache_admission,
151        jwks_on_demand_refresh_decision, jwks_publication_generations,
152    },
153    leader_epoch::{EpochEntry, epoch_and_offset_for_entries},
154    list_offsets::{
155        ListOffsetsBoundDecision, ListOffsetsBoundFacts, ListOffsetsEarliestFacts,
156        ListOffsetsEpochDecision, ListOffsetsKind, ListOffsetsSelectionDecision,
157        ListOffsetsSelectionFacts, list_offsets_bound_decision, list_offsets_earliest,
158        list_offsets_epoch_decision, list_offsets_kind, list_offsets_selection_decision,
159    },
160    local_recovery::{
161        LocalRecoveryStep, LocalRecoverySwapAction, local_recovery_batch_step,
162        local_recovery_index_frontier, local_recovery_sealed_last, local_recovery_segment_chain,
163        local_recovery_swap_action,
164    },
165    log_index::{offset_index_lookup, offset_index_position_at_or_after, time_index_lookup},
166    oauth::{
167        OAuthAuthenticationKind, OAuthExpiryPresence, OAuthPrincipalMatch, OAuthSessionCap,
168        OAuthSessionDecision, OAuthSessionFacts, oauth_session_admission,
169    },
170    offset_allocator::{
171        reserve_offsets, wal_reservation_epoch_ready, wal_reservation_frontier,
172        wal_reservation_response,
173    },
174    opa::{
175        OpaAuthorizationDecision, OpaCacheAdmission, OpaCacheExpiry, opa_cache_admission,
176        opa_cache_expiry, opa_error_decision,
177    },
178    produce::{ProduceBatchAdmission, produce_batch_admission, produce_durability_frontier},
179    producer::{
180        ProducerDecision, ProducerEntryFacts, RetainedSequenceRange, decrement_sequence,
181        increment_sequence, producer_decision,
182    },
183    producer_id::{
184        ProducerIdBlockAllocationDecision, ProducerIdBlockPlan, producer_id_block_allocation,
185    },
186    producer_snapshot::{
187        ProducerReloadRange, producer_snapshot_entry_valid, producer_snapshot_latest_index,
188        producer_snapshot_reload_keeps, producer_snapshot_reload_log_start,
189        producer_snapshot_replay_start, producer_snapshot_stray,
190    },
191    quorum_state::{
192        QuorumStateLoadDecision, QuorumStateWriteDecision, quorum_state_load_decision,
193        quorum_state_write_decision,
194    },
195    quota::{
196        IpQuotaPrecedence, QuotaCandidatePresence, UserClientQuotaFacts, UserClientQuotaPrecedence,
197        ip_quota_precedence, user_client_quota_precedence,
198    },
199    raft::{FetchResponseMutation, fetch_response_mutation, metadata_record_offset_deltas},
200    reassignment::{
201        ReassignmentAction, ReassignmentSetMembership, reassignment_action,
202        reassignment_plan_admission, reassignment_set_membership,
203    },
204    reconfiguration::{
205        VoterChangeKind, VoterReconfigurationDecision, VoterReconfigurationPlan,
206        voter_reconfiguration_decision,
207    },
208    recovery::{
209        BarrierRecoveryFinalizeDecision, BarrierRecoveryFoldAction, BarrierRecoveryRecordKind,
210        ReplayCursorDecision, ReplayRecordDecision, barrier_recovery_finalize_decision,
211        barrier_recovery_fold_action, replay_batch_cursor_decision, replay_cursor_decision,
212        replay_record_decision, should_capture_first_downgrade,
213    },
214    registration::{BrokerHeartbeatDecision, broker_heartbeat_decision},
215    remote_metadata::{remote_metadata_partition, remote_metadata_resume_cursor},
216    remote_read::{
217        remote_read_relative_offset, remote_time_index_candidate_count,
218        tiered_earliest_finished_index, tiered_latest_finished_index, tiered_owning_epoch_index,
219    },
220    remote_txn::{RemoteTxnOverlapDecision, remote_txn_overlap_decision},
221    restore::{
222        RestoreBatchFrame, RestoreContentExclusions, RestoreExclusions, RestoreFilterDecision,
223        RestoreLayout, RestoreProducer, RestoreReconcileDecision, RestoreRecordDeltas,
224        RestoreSnapshotState, RestoreTimestampType, restore_archive_reconcile,
225        restore_batch_filter_decision, restore_batch_past_offset_bound, restore_batch_step,
226        restore_record_coordinates, restore_record_selected, restore_rewritten_batch_header,
227        restore_rewritten_record,
228    },
229    restore_sidecar::{
230        RestoreAbortedTxn, RestoreSegmentExtent, restore_index_frontier,
231        restore_leader_epoch_entry_valid, restore_offset_index_entry_valid,
232        restore_producer_ids_strict, restore_time_index_entry_valid, restore_txn_index_entry_valid,
233    },
234    retention::{barrier_cut_expired, local_retention_prefix, retention_delete_target},
235    schema::{
236        SchemaBatchAdmission, SchemaFailureDecision, SchemaFailureKind, SchemaFieldAction,
237        SchemaFieldRole, schema_batch_admission, schema_failure_decision, schema_field_action,
238        schema_frame_id,
239    },
240    scram::{
241        ScramAlterationDecision, ScramAlterationFacts, ScramAlterationKind, ScramPriorState,
242        scram_alteration_decision,
243    },
244    share::{
245        ShareOffsetMutationDecision, ShareOffsetMutationGate, share_offset_mutation_decision,
246        share_prune_frontier,
247    },
248    snapshot::{
249        SnapshotChunkDecision, SnapshotInstallDecision, snapshot_chunk_admission,
250        snapshot_install_decision, snapshot_prune_admission,
251    },
252    stamp::{
253        covering_stamp_range_index, exact_stamp_range_index, stamp_range_insertion_index,
254        stamp_ranges_valid,
255    },
256    storage::{
257        LocalTruncationPlan, RemoteCacheAction, future_log_swap_admission,
258        local_append_coordinates, local_truncation_plan, remote_cache_action,
259        remote_partition_delete_transition, remote_segment_transition, truncation_batch_retained,
260        truncation_frontier, truncation_relative_offset,
261    },
262    stretch::{
263        min_insync_is_site_loss_safe, quorum_survives_any_single_site_loss, site_loss_survivors,
264    },
265    timestamp::{
266        earliest_max_timestamp_index, first_timestamp_index, timestamp_record_coordinates,
267        timestamp_scan_next, timestamp_scan_window,
268    },
269    transaction::{
270        IdleTransactionState, NO_TRANSACTION_TIMEOUT_MS, TransactionCompletionDecision,
271        TransactionIdentity, TransactionMarkerMaterializationDecision,
272        TransactionReaperCompletionDecision, TransactionSnapshot, aborted_transaction_interval,
273        aborted_transaction_overlaps, first_unstable_offset, should_abort_idle_transaction,
274        transaction_completion_decision, transaction_marker_closes,
275        transaction_marker_materialization_decision, transaction_reaper_completion_decision,
276    },
277    vote::{
278        VoteAdmissionDecision, VoteEncodeDecision, VoteWireDecision, vote_admission_decision,
279        vote_encode_decision, vote_wire_decision,
280    },
281    voter_set::{
282        VoterSetWireDecision, VoterWireDecision, voter_set_wire_decision, voter_wire_decision,
283    },
284    wal::{WalFetchAdmission, exact_wal_batch_range, select_wal_voter_index, wal_fetch_admission},
285    worm::{
286        WormDigestFacts, WormObjectAvailabilityFacts, WormObjectIdentityFacts,
287        WormObjectSetDecision, WormObjectSetFacts, WormSignatureDecision, worm_object_set_decision,
288        worm_signature_decision,
289    },
290};