| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Singular.Registry.FoldSelection
Description
Pull request 1 of #518 judges every pending request alone and settles one per fold. This module is the pure selection: it takes the pending requests, the live facts, the clock and a capacity bound as arguments and returns, for every pending request, exactly one of settled or excluded-with-reason. It reads no file, no clock and no provider, and imports no command-line module and no application module, so both the command line and the conformance suite can use it.
The seven checks run in the spec's order; the first one a request fails names its reason:
- it decodes as a request, otherwise
undecodable - its edge is one the model admits, otherwise
edge-inadmissible - its processing window is open beyond the fold margin, otherwise
window-closed - the model's approval check accepts it, otherwise
no-approvalorapproval-mismatch - the model's leaf check accepts it from the live state, otherwise
key-exists,token-missing,key-unknown,not-bookedorterminal-immutable - the application step's verdict carried on the request is ready, otherwise
application-datum-unreadableorapplication-required - no earlier included request names the same key, otherwise
key-in-batch
Requests that pass all seven keep ledger input order; the first ones up to
the capacity bound are settled and each remaining one is named capacity.
The window rule mirrors the command line's processing-window rule: open
only while the time left is beyond the margin. The approval and leaf checks
follow the model's refusal order: excluded edges first, then approval, then
the leaf from the live state.
Synopsis
- data EdgeKind
- = EdgeInsertActive
- | EdgeUpdateTerminal
- | EdgeOther Text
- data Leaf
- data ApprovalCheck
- data AppVerdict
- = AppReady
- | AppDatumUnreadable
- | AppRequired Text
- data PendingRequest = PendingRequest {
- prRef :: Int
- prKey :: Int
- prOwner :: Text
- prEdge :: EdgeKind
- prDeadline :: Integer
- prDecodeOk :: Bool
- prApproval :: ApprovalCheck
- prApp :: AppVerdict
- data SelectedRequest = SelectedRequest {}
- data Reason
- data Exclusion = Exclusion {}
- data Selection = Selection {
- selectionSettled :: [SelectedRequest]
- selectionExcluded :: [(PendingRequest, Exclusion)]
- selectionBound :: Int
- selectionProvenance :: Text
- type LiveFacts = Map Int (Leaf, Bool)
- selectFold :: Int -> Integer -> Integer -> LiveFacts -> [PendingRequest] -> Selection
- judgeAlone :: Integer -> Integer -> LiveFacts -> PendingRequest -> Either Exclusion SelectedRequest
- foldCapacity :: Int
- foldCapacityProvenance :: Text
- exclusionName :: Exclusion -> Text
- exclusionSource :: Exclusion -> Text
Documentation
The edge a pending request names. Only the two edges the model admits
settle; any other edge is refused edge-inadmissible.
Constructors
| EdgeInsertActive | |
| EdgeUpdateTerminal | |
| EdgeOther Text |
Instances
| Show EdgeKind Source # | |
Defined in Singular.Registry.FoldSelection | |
| Eq EdgeKind Source # | |
Defined in Singular.Registry.FoldSelection | |
The live leaf for a key, read from the registry state before the decision.
Constructors
| LeafUnknown | |
| LeafAbsent | |
| LeafActive | |
| LeafTerminal |
Instances
| Show Leaf Source # | |
Defined in Singular.Registry.FoldSelection | |
| Eq Leaf Source # | |
Defined in Singular.Registry.FoldSelection | |
data ApprovalCheck Source #
The model's approval check, decided by the caller from the live state:
a missing approval, an approval under another policy (both no-approval),
an approval whose tuple does not match (approval-mismatch), or a match.
Instances
| Show ApprovalCheck Source # | |
Defined in Singular.Registry.FoldSelection Methods showsPrec :: Int -> ApprovalCheck -> ShowS Source # show :: ApprovalCheck -> String Source # showList :: [ApprovalCheck] -> ShowS Source # | |
| Eq ApprovalCheck Source # | |
Defined in Singular.Registry.FoldSelection Methods (==) :: ApprovalCheck -> ApprovalCheck -> Bool Source # (/=) :: ApprovalCheck -> ApprovalCheck -> Bool Source # | |
data AppVerdict Source #
The application step's verdict, asked through the application value and carried on the pending request: the settlement inputs are ready, the carried datum does not read, or the value carries no holding rules for a termination, naming the application's executable.
Constructors
| AppReady | |
| AppDatumUnreadable | |
| AppRequired Text |
Instances
| Show AppVerdict Source # | |
Defined in Singular.Registry.FoldSelection Methods showsPrec :: Int -> AppVerdict -> ShowS Source # show :: AppVerdict -> String Source # showList :: [AppVerdict] -> ShowS Source # | |
| Eq AppVerdict Source # | |
Defined in Singular.Registry.FoldSelection Methods (==) :: AppVerdict -> AppVerdict -> Bool Source # (/=) :: AppVerdict -> AppVerdict -> Bool Source # | |
data PendingRequest Source #
One pending request with everything the seven checks need. The application verdict arrives as a field, like the decode verdict does: the selection never calls the application value.
Constructors
| PendingRequest | |
Fields
| |
Instances
| Show PendingRequest Source # | |
Defined in Singular.Registry.FoldSelection Methods showsPrec :: Int -> PendingRequest -> ShowS Source # show :: PendingRequest -> String Source # showList :: [PendingRequest] -> ShowS Source # | |
| Eq PendingRequest Source # | |
Defined in Singular.Registry.FoldSelection Methods (==) :: PendingRequest -> PendingRequest -> Bool Source # (/=) :: PendingRequest -> PendingRequest -> Bool Source # | |
data SelectedRequest Source #
A request that passed all seven checks.
Constructors
| SelectedRequest | |
Instances
| Show SelectedRequest Source # | |
Defined in Singular.Registry.FoldSelection Methods showsPrec :: Int -> SelectedRequest -> ShowS Source # show :: SelectedRequest -> String Source # showList :: [SelectedRequest] -> ShowS Source # | |
| Eq SelectedRequest Source # | |
Defined in Singular.Registry.FoldSelection Methods (==) :: SelectedRequest -> SelectedRequest -> Bool Source # (/=) :: SelectedRequest -> SelectedRequest -> Bool Source # | |
Every exclusion reason: eight model refusals in the model's own words, six selection-policy reasons of the processor.
Constructors
Instances
| Bounded Reason Source # | |
Defined in Singular.Registry.FoldSelection | |
| Enum Reason Source # | |
Defined in Singular.Registry.FoldSelection Methods succ :: Reason -> Reason Source # pred :: Reason -> Reason Source # toEnum :: Int -> Reason Source # fromEnum :: Reason -> Int Source # enumFrom :: Reason -> [Reason] Source # enumFromThen :: Reason -> Reason -> [Reason] Source # enumFromTo :: Reason -> Reason -> [Reason] Source # enumFromThenTo :: Reason -> Reason -> Reason -> [Reason] Source # | |
| Show Reason Source # | |
Defined in Singular.Registry.FoldSelection | |
| Eq Reason Source # | |
Defined in Singular.Registry.FoldSelection | |
Why a pending request is left out: its reason and a detail text. The
detail of application-required names the application's executable.
Instances
| Show Exclusion Source # | |
Defined in Singular.Registry.FoldSelection | |
| Eq Exclusion Source # | |
Defined in Singular.Registry.FoldSelection | |
The selection: the settled requests and the excluded requests, each in ledger input order, with the capacity bound used and its provenance.
Constructors
| Selection | |
Fields
| |
Instances
| Show Selection Source # | |
Defined in Singular.Registry.FoldSelection | |
| Eq Selection Source # | |
Defined in Singular.Registry.FoldSelection | |
type LiveFacts = Map Int (Leaf, Bool) Source #
The live facts: per key, the leaf and whether a live output holds the key's one active token.
selectFold :: Int -> Integer -> Integer -> LiveFacts -> [PendingRequest] -> Selection Source #
Judge every pending request alone, keep ledger input order, and settle the first included requests up to the capacity bound. The only cross-request rule is the seventh check, which reads earlier included requests of the same key; the capacity cut runs after every request has its own verdict. Both lists keep ledger input order.
judgeAlone :: Integer -> Integer -> LiveFacts -> PendingRequest -> Either Exclusion SelectedRequest Source #
Judge one request alone against the live facts: the six per-request
checks in the spec's order. No argument names any other pending request, so
a request's verdict never depends on requests on other keys. The seventh
check, ReasonKeyInBatch, needs the earlier verdicts and runs in
selectFold.
foldCapacity :: Int Source #
The capacity bound of a fold: nine requests per fold, an estimate under preprod's execution budget of 14 million memory units, bound by trie-proof verification. The number is not measured under preprod parameters.
foldCapacityProvenance :: Text Source #
an estimate, not a measurement: about nine requests fit in a fold under preprod's execution budget of 14 million memory units, bound by trie-proof verification
exclusionName :: Exclusion -> Text Source #
The reason's name in the receipt's vocabulary.
exclusionSource :: Exclusion -> Text Source #
Which vocabulary the reason belongs to: a refusal of the model or the processor's own selection policy.