pub struct Store { /* private fields */ }Expand description
The reference Part B store. All methods are safe for concurrent use; every operation runs under one mutex, which makes the claim and the stream-sequence advance one atomic step, and terminal commit and outbox sequence assignment another. TEST/REFERENCE ONLY.
Implementations§
Source§impl Store
impl Store
Sourcepub fn corrupt_sealed_state_test_only(&self, claim_id: &str)
pub fn corrupt_sealed_state_test_only(&self, claim_id: &str)
Go CorruptSealedStateTestOnly: flip one byte of a committed claim’s
sealed terminal result, modelling corrupted primary storage.
Source§impl Store
impl Store
Sourcepub fn new(
now: i64,
lease_seconds: i64,
log_id: &str,
verifier_key: &HybridPrivateKey,
) -> V2Result<Store>
pub fn new( now: i64, lease_seconds: i64, log_id: &str, verifier_key: &HybridPrivateKey, ) -> V2Result<Store>
Go NewStore: a reference store whose authoritative clock starts at
now, whose evaluator leases last lease_seconds, and whose receipt
log log_id is signed by verifier_key.
Sourcepub fn clone_store(&self) -> Store
pub fn clone_store(&self) -> Store
Go Clone: an independent copy of the complete state, modelling a
restore that exactly equals the anchored state. The anchor is not
copied.
Sourcepub fn set_time(&self, now: i64)
pub fn set_time(&self, now: i64)
Go SetTime: set the authoritative clock. Tests may move it
backward to exercise clock-regression handling.
Sourcepub fn set_signer_failure(&self, failing: bool)
pub fn set_signer_failure(&self, failing: bool)
Go SetSignerFailure: make the reference receipt signer fail (or
recover). A failed publication appends nothing.
Sourcepub fn set_acknowledgement_withheld(&self, withheld: bool)
pub fn set_acknowledgement_withheld(&self, withheld: bool)
Go SetAcknowledgementWithheld: stop (or resume) submitting appended
entries to the checkpoint. Resuming acknowledges every pending entry
in log order at the current clock.
Sourcepub fn log_length(&self) -> usize
pub fn log_length(&self) -> usize
Go LogLength: the number of appended (signed) receipts.
Sourcepub fn plant_release_test_only(&self, claim_id: &str, ack_timestamp: i64)
pub fn plant_release_test_only(&self, claim_id: &str, ack_timestamp: i64)
Go PlantReleaseTestOnly: write a release record for claim_id
directly, bypassing release and anchoring (models an attacker who can
write the primary’s storage).
Sourcepub fn abandon_pending_receipts(&self) -> Vec<String>
pub fn abandon_pending_receipts(&self) -> Vec<String>
Go AbandonPendingReceipts: freeze the receipt log and mark every
claim whose committed outbox entry was not yet appended as
receipt_abandoned. Returns the abandoned claim IDs in log order.
Sourcepub fn with_rate_at_finalization(
self: &Arc<Self>,
) -> Arc<RateAtFinalizationStore> ⓘ
pub fn with_rate_at_finalization( self: &Arc<Self>, ) -> Arc<RateAtFinalizationStore> ⓘ
Go WithRateAtFinalization: enable rate admission at finalization and
return the view that advertises it. Use the view as both the claim
store and the rate store.
Trait Implementations§
Source§impl ClaimStoreV2 for Store
impl ClaimStoreV2 for Store
Source§fn claim_v2(
&self,
_ctx: &V2Context,
claim: V2ChallengeClaim,
) -> Result<V2ClaimResult, V2StoreError>
fn claim_v2( &self, _ctx: &V2Context, claim: V2ChallengeClaim, ) -> Result<V2ClaimResult, V2StoreError>
The atomic claim: a claim ID not derived from its replay key is
configuration_invalid and creates nothing; then the authoritative
clock reading (a regressed clock
creates nothing and fails with claim_store_unavailable), replay key
check, authoritative freshness recheck, stream-sequence advance, and
insertion, all under one lock.
Source§fn finalize_v2_claim(
&self,
_ctx: &V2Context,
claim_id: &str,
owner_token: &[u8],
terminal_result: &[u8],
receipt_body: &[u8],
allow_valid_until: i64,
) -> Result<bool, V2StoreError>
fn finalize_v2_claim( &self, _ctx: &V2Context, claim_id: &str, owner_token: &[u8], terminal_result: &[u8], receipt_body: &[u8], allow_valid_until: i64, ) -> Result<bool, V2StoreError>
Commit the evaluator’s terminal result while its lease is live,
reading T_final inside the same critical section. The receipt body
must bind the sealed claim (validate_v2_finalization_payload:
malformed or configuration_invalid otherwise, committing
nothing). A regressed clock
fails with clock_regressed; an allow is rejected at or beyond its
horizon or the challenge expiry. With rate admission at finalization,
an allow is admitted against the sealed rate batch here and fails
with the exact V2StoreError::RateLimitExceeded, committing
nothing, when a counter is exhausted. An identical repeat returns
Ok(false).
Source§fn record_v2_evaluation_progress(
&self,
_ctx: &V2Context,
claim_id: &str,
owner_token: &[u8],
progress: V2EvaluationProgress,
) -> Result<(), V2StoreError>
fn record_v2_evaluation_progress( &self, _ctx: &V2Context, claim_id: &str, owner_token: &[u8], progress: V2EvaluationProgress, ) -> Result<(), V2StoreError>
The owner’s progress is stored only while the claim is evaluating and its lease is live.
Source§fn load_v2_interrupted_claim(
&self,
_ctx: &V2Context,
claim_id: &str,
) -> Result<V2InterruptedClaim, V2StoreError>
fn load_v2_interrupted_claim( &self, _ctx: &V2Context, claim_id: &str, ) -> Result<V2InterruptedClaim, V2StoreError>
Refuses while the lease is live, so the returned progress is final. A terminal claim is returned too (idempotent recovery).
Source§fn recover_interrupted_v2_claim(
&self,
_ctx: &V2Context,
claim_id: &str,
terminal_result: &[u8],
receipt_body: &[u8],
) -> Result<bool, V2StoreError>
fn recover_interrupted_v2_claim( &self, _ctx: &V2Context, claim_id: &str, terminal_result: &[u8], receipt_body: &[u8], ) -> Result<bool, V2StoreError>
Commit the canonical interrupted result after the lease expired. The
result and receipt body are validated exactly as finalization
validates them (validate_v2_finalization_payload: malformed or
configuration_invalid), and the decision and reason must be
indeterminate / evaluation_interrupted (configuration_invalid
otherwise); a refused recovery commits nothing (SPEC-v2 §7.5).
Source§fn rate_at_finalization_view(&self) -> Option<&dyn V2RateAtFinalizationStore>
fn rate_at_finalization_view(&self) -> Option<&dyn V2RateAtFinalizationStore>
store.(V2RateAtFinalizationStore) type assertion: a store that
implements V2RateAtFinalizationStore returns Some(self).Source§impl V2AuthoritativeClock for Store
impl V2AuthoritativeClock for Store
A regressed clock fails with clock_regressed.
Source§impl V2CommittedClaimStore for Store
Returns a terminal claim exactly as its terminal commit persisted it, for
resumption after the handoff was lost (SPEC-v2 §7.11). A claim still
evaluating is claim_lease_live while its lease is live and
claim_lease_lost after, when lease-expiry recovery must run first.
impl V2CommittedClaimStore for Store
Returns a terminal claim exactly as its terminal commit persisted it, for
resumption after the handoff was lost (SPEC-v2 §7.11). A claim still
evaluating is claim_lease_live while its lease is live and
claim_lease_lost after, when lease-expiry recovery must run first.
fn load_v2_committed_claim( &self, _ctx: &V2Context, claim_id: &str, ) -> Result<V2CommittedClaim, V2StoreError>
Source§impl V2ReceiptCheckpoint for Store
impl V2ReceiptCheckpoint for Store
Source§fn acknowledge_v2_receipt(
&self,
_ctx: &V2Context,
log_id: &str,
sequence: i64,
previous_entry_hash: &[u8],
entry_hash: &[u8],
) -> Result<V2CheckpointAcknowledgement, V2StoreError>
fn acknowledge_v2_receipt( &self, _ctx: &V2Context, log_id: &str, sequence: i64, previous_entry_hash: &[u8], entry_hash: &[u8], ) -> Result<V2CheckpointAcknowledgement, V2StoreError>
Accept only the next appended entry of the log, linked by
previous_entry_hash, and return the original acknowledgement for an
identical retry. A different entry hash at an acknowledged sequence is
a fork (SPEC-v2 §7.8): it is refused and freezes the log, after which
the checkpoint acknowledges nothing further for it, neither here nor
from the publisher’s submissions. Identical retries of
acknowledgements made before the fork still return the original
acknowledgement.
fn get_v2_acknowledgement( &self, _ctx: &V2Context, log_id: &str, sequence: i64, ) -> Result<V2CheckpointAcknowledgement, V2StoreError>
Source§impl V2ReceiptPublisher for Store
impl V2ReceiptPublisher for Store
Source§fn publish_v2_receipt(
&self,
_ctx: &V2Context,
claim_id: &str,
receipt_body: &[u8],
) -> Result<Vec<u8>, V2StoreError>
fn publish_v2_receipt( &self, _ctx: &V2Context, claim_id: &str, receipt_body: &[u8], ) -> Result<Vec<u8>, V2StoreError>
Sign and append the committed outbox body for claim_id at the log
position assigned at terminal commit, or return the receipt already
appended. A different body is refused, an earlier unpublished entry
blocks it, and a failing signer or frozen log appends nothing.
Source§impl V2ReleaseClaimStore for Store
impl V2ReleaseClaimStore for Store
Source§fn record_v2_release(
&self,
_ctx: &V2Context,
release: V2ReleaseRecord,
) -> Result<(), V2StoreError>
fn record_v2_release( &self, _ctx: &V2Context, release: V2ReleaseRecord, ) -> Result<(), V2StoreError>
Records a release or a withheld result (SPEC-v2 §6.9): the first
record for a claim wins, an identical repeat is a no-op, and any
different record is V2StoreError::ReleaseStateMismatch. A new
record is a durable security-state change, anchored like any other.