orderkey_snapshot

    Download zip
    Author
    Version
    0.2.0
    License
    MIT
    Last updated
    28 minutes ago
    Downloads
    159

    #OrderKey snapshot reader

    Native MoonBit reader for verified, portable OrderKey candidates. The full repository includes docs/QUERIES.md with query and SDK examples. Package using python scripts/package_snapshot.py from the repository root: the parent module excludes snapshot/ from the core package, so SDK packaging uses an isolated stage.

    Import WeiR-h/orderkey_snapshot and WeiR-h/orderkey. Reader::open(directory) validates and loads once. Reader::query(QuerySpec, limit~, cursor~) performs typed pagination with no further filesystem access. Page exposes rows, scanned and optional cursor. Data stays frozen for the session; new readers validate files again.

    Use Reader::open_selected(directory, expected_selection_sha256=...) to verify a selected training delivery. A bounded delivery carries its original v2 selection.json and measured rank ranges. The reader checks the selection digest, scan mode, budgets and ranges against the delivery.

    A cross-batch rebuild carries assessment.json. The reader checks the copy against the assessment digest in the job receipt. A holdout receipt from gate-batch carries the approved assessment and holdout key-set digests and can be read through the existing approved reader.

    Use ApprovedReader::open(directory, receipt, expected_sha256) for a snapshot approved by gate-batch. Supply the receipt digest from trusted release configuration. Call reader.query(id, predicate, cursor~) with the approved query ID and typed predicate. The receipt supplies the scan mode and page size. The example in examples/approved reads an approved USGS snapshot after the original exports have been removed.

    This module depends on MoonFST (MIT), async and sha256 (Apache-2.0). It does not open MoonLSM. The core module remains standard-library-only. MIT license; reference and dependency notices are in the repository THIRD_PARTY.md. No independent user adoption is claimed.

    SnapshotError

    pub suberror SnapshotError {
    InvalidSnapshot(String)
    }

    ApprovedQuery

    type ApprovedQuery

    ApprovedReader

    pub struct ApprovedReader {
    // private fields
    }

    Opens and reads a portable snapshot under a trusted batch receipt.

    ApprovedReader::open

    async fn ApprovedReader::open(snapshot : String, receipt : String, expected_sha256 : String) -> ApprovedReader

    Obtain expected_sha256 independently of the delivered receipt and snapshot.

    ApprovedReader::query

    fn ApprovedReader::query(self : ApprovedReader, id : String, query :
    QuerySpec
    , cursor? : Bytes?) -> Page raise

    Uses the receipt's scan mode and page size for this exact typed predicate.

    BoundedQuery

    pub struct BoundedQuery {
    // private fields
    }

    A rank plan prepared against one immutable snapshot.

    BoundedQuery::windows

    Page

    pub(all) struct Page {
    rows : Array[Record]
    cursor : Bytes?
    scanned : Int
    }

    Reader

    pub struct Reader {
    // private fields
    }

    Immutable in-memory session. No filesystem access after open returns.

    Reader::contract

    Reader::loaded_bytes

    fn Reader::loaded_bytes(self : Reader) -> Int64

    Reader::open

    async fn Reader::open(dir : String) -> Reader

    Opens a portable candidate without requiring original input paths.

    Reader::open_selected

    async fn Reader::open_selected(dir : String, expected_selection_sha256? : String) -> Reader

    Opens a selected snapshot only after verifying its workload receipt. An expected digest pins the caller's intended selection.json.

    Reader::plan_bounded

    fn Reader::plan_bounded(self : Reader, query :
    QuerySpec
    , max_windows : Int) -> BoundedQuery raise

    Reader::plan_segmented

    fn Reader::plan_segmented(self : Reader, query :
    QuerySpec
    ) -> SegmentedQuery raise

    Reader::query

    fn Reader::query(self : Reader, query :
    QuerySpec
    , limit? : Int, cursor? : Bytes?) -> Page raise

    Reader::query_bounded

    fn Reader::query_bounded(self : Reader, query : BoundedQuery, limit? : Int, cursor? : Bytes?) -> Page raise

    Reader::query_segmented

    fn Reader::query_segmented(self : Reader, plan : SegmentedQuery, limit? : Int, cursor? : Bytes?) -> Page raise

    Reader::row_count

    fn Reader::row_count(self : Reader) -> Int

    Record

    pub(all) struct Record {
    key : Bytes
    value : Bytes
    }

    SegmentedQuery

    pub struct SegmentedQuery {
    // private fields
    }

    Prepared ranges bound to the immutable snapshot and original query.