Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Library · std.lispex

    LispexLimits.logicalAllocation

    Bound cumulative logical allocation without refunds.

    LispexLimits.logicalAllocation: int
    Receiver
    LispexLimits
    Minimum arity
    0
    Maximum arity
    0

    Declaration and parameters

    Link

    Availability

    Included by default: no

    Import std.lispex from an application package with a verified lock. Packages with [lispex] require --locked. Application profile topaz/lispex-decision-application/1 uses evaluator profile lispex/r7rs-rule-embedded-core/1. Application profile topaz/lispex-decision-application/2 uses evaluator profile lispex/r7rs-rule-current-profile-bounded/1.

    The generated-module resolver gate starts at language mode 5.18. Compatibility of this API with earlier released editions remains Pending. Target deployment conditions are native (native-only), web (web-isolated-workers), web-worker (web-isolated-workers). Runtime payload follows checker-reached rules. An empty reached-rule set includes no runtime payload. Application quotas are required. Lock-only packages do not receive these application modules.

    Source evidence

    Receiver

    LispexLimits

    Parameter constraints

    LispexLimits contains the six named int fields work, logicalAllocation, semanticFrames, input, result, and diagnostics. LispexPreparationLimits and LispexHostLimits contain the same six named fields in their independent accounting domains. Every field is required and has no implicit unlimited form.

    Each limit is a nonnegative Topaz int within the selected contract's supported representation bounds. Zero is an explicit finite bound and is never replaced by a default. Negative values, overflow, missing required fields, and unknown fields are refused before the affected operation begins.

    The work field bounds cumulative normative computation. Native arithmetic, traversal, source processing, decoding, and encoding retain the charges assigned by their selected phase and contract. Host elapsed time and machine instruction counts do not replace work accounting.

    The logicalAllocation field bounds cumulative logical allocation, including intermediate values. Sharing, garbage collection, and returning from a call do not refund committed charges. Physical allocation behavior does not change a logical charge.

    The semanticFrames field bounds active semantic control state under the selected contract. A guest tail call replaces its current call frame. Nontail calls and active guard control consume their declared frames. Host stack layout does not redefine this budget.

    The input, result, and diagnostics fields bound their respective channels in units defined by the selected versioned contract. The field names do not promise byte units. Preparation and host operations apply the channel meanings declared by their own contracts.

    defaultLimits() returns LispexLimitPreset with preparation, evaluation, and host records. The preparation and evaluation records use the published common finite preset shared with Lispex 2.0 products. The host record uses the declared finite host work preset. The call returns complete values and performs no guest evaluation or discovery.

    A preset selection is resolved before admission and execution. The request records the effective declared evaluation limits. Copying a preset and changing one field creates an explicit new selection. No invalid field is repaired from a preset and no host silently reduces the selection.

    Preparation uses its own finite account for the closed source bundle. Evaluation starts a new account for the immutable prepared program and supplied input. Warm caches and reused preparation cannot move work into the evaluation account, increase its allowance, or change its normative charges.

    Package admission, value conversion, artifact inspection, replay validation, authentication and additional profile checks use the separate finite host account assigned to each operation. Transported prepared rule validation uses the explicit preparation account. Their host limits cannot serve as an unlimited fallback for guest work.

    Canonical input decoding and canonical result or failure encoding remain evaluation work. Additional profile schema and evidence checks remain host work. A host helper that validates or retains data in advance does not remove the evaluation's declared logical events or charges.

    At each atomic resource event, check work first, logicalAllocation next, semanticFrames next, and the applicable channel last. Skip axes the event does not require. An event reserves at most its declared semantic channel and work across several channels follows the contract's event sequence.

    Commit an event's charges and effect only after every required reservation succeeds. If one reservation fails, perform none of that event's effect or charges. Retain charges committed by earlier events. Releasing an active frame does not refund cumulative work or allocation.

    A reservation accepts a resulting charge equal to its limit. It rejects a resulting charge above the limit before the effect. Accounting uses checked exact arithmetic and cannot wrap or vary with host word size.

    Checks and reservations follow semantic event order. A later charge cannot hide an earlier domain failure. Work needed to reach or perform an earlier check can itself exhaust a budget before that check completes.

    Optimizations, inlining, native fast paths, and constant sharing preserve normative events and their first observable failure. They preserve the exhausted axis and canonical site for the same admitted semantic request. Equal aggregate usage totals alone do not establish this requirement.

    A result channel failure returns no successful result prefix. Diagnostic production obeys its finite channel budget, and terminal reporting uses the reserved emergency representation defined by the selected contract. Optional tracing cannot change the canonical outcome when its own capacity is exhausted.

    The host admits a request only when its physical envelope can support the selected logical limits. It refuses unsupported envelopes without lowering the request budget or choosing another engine. A later physical failure remains operational or defective execution and cannot be relabeled as deterministic guest exhaustion.

    A deterministic evaluation limit stop returns LimitExhaustion with the first exhausted axis and canonical site. A preparation resource stop remains a preparation failure report. An additional profile host budget refusal remains an admission or profile work report according to its stage.

    Host work after a completed evaluation preserves that evaluation when its own budget is exhausted. It can refuse qualification, evidence creation, validation, or authentication without replacing the guest settlement or changing the original evaluation request identity.

    Replaying a request uses the same resource model and complete evaluation limit record. A different declared limit record is a request mismatch even when the observed value would be unchanged. Host verification and comparison budgets remain separately identified.

    Tariff coefficients, logical allocation units, detailed frame charges, channel units, finite default numbers, emergency capacities, and physical envelope requirements come from their versioned Lispex 2.0 contracts. This binding does not infer them from Lispex 1.x counters or current public product observations.

    Missing and unknown named record fields are Topaz checking errors before a call is formed. A negative field or an unsupported representable value in a complete record causes the typed preflight refusal of the called operation. Neither path repairs the record or begins its phase.

    Result

    The declared result type is int.

    Effects

    Failures

    Result and effects

    Link

    Select this field from a value of its named type without call parentheses.

    Bound cumulative logical allocation without refunds.

    Why

    Link

    The limits contract gives this operation one explicit input boundary and preserves the distinct result and failure cases.

    Resolved contracts

    Link

    Related entries

    Link

    std.lispex

    Apply finite budgets in the declared resource order

    Link
    Ruletopaz.stdlib.contract.lispex-limits.rule

    Apply finite budgets in the declared resource order

    LispexLimits contains the six named int fields work, logicalAllocation, semanticFrames, input, result, and diagnostics. LispexPreparationLimits and LispexHostLimits contain the same six named fields in their independent accounting domains. Every field is required and has no implicit unlimited form.

    Each limit is a nonnegative Topaz int within the selected contract's supported representation bounds. Zero is an explicit finite bound and is never replaced by a default. Negative values, overflow, missing required fields, and unknown fields are refused before the affected operation begins.

    The work field bounds cumulative normative computation. Native arithmetic, traversal, source processing, decoding, and encoding retain the charges assigned by their selected phase and contract. Host elapsed time and machine instruction counts do not replace work accounting.

    The logicalAllocation field bounds cumulative logical allocation, including intermediate values. Sharing, garbage collection, and returning from a call do not refund committed charges. Physical allocation behavior does not change a logical charge.

    The semanticFrames field bounds active semantic control state under the selected contract. A guest tail call replaces its current call frame. Nontail calls and active guard control consume their declared frames. Host stack layout does not redefine this budget.

    The input, result, and diagnostics fields bound their respective channels in units defined by the selected versioned contract. The field names do not promise byte units. Preparation and host operations apply the channel meanings declared by their own contracts.

    defaultLimits() returns LispexLimitPreset with preparation, evaluation, and host records. The preparation and evaluation records use the published common finite preset shared with Lispex 2.0 products. The host record uses the declared finite host work preset. The call returns complete values and performs no guest evaluation or discovery.

    A preset selection is resolved before admission and execution. The request records the effective declared evaluation limits. Copying a preset and changing one field creates an explicit new selection. No invalid field is repaired from a preset and no host silently reduces the selection.

    Preparation uses its own finite account for the closed source bundle. Evaluation starts a new account for the immutable prepared program and supplied input. Warm caches and reused preparation cannot move work into the evaluation account, increase its allowance, or change its normative charges.

    Package admission, value conversion, artifact inspection, replay validation, authentication and additional profile checks use the separate finite host account assigned to each operation. Transported prepared rule validation uses the explicit preparation account. Their host limits cannot serve as an unlimited fallback for guest work.

    Canonical input decoding and canonical result or failure encoding remain evaluation work. Additional profile schema and evidence checks remain host work. A host helper that validates or retains data in advance does not remove the evaluation's declared logical events or charges.

    At each atomic resource event, check work first, logicalAllocation next, semanticFrames next, and the applicable channel last. Skip axes the event does not require. An event reserves at most its declared semantic channel and work across several channels follows the contract's event sequence.

    Commit an event's charges and effect only after every required reservation succeeds. If one reservation fails, perform none of that event's effect or charges. Retain charges committed by earlier events. Releasing an active frame does not refund cumulative work or allocation.

    A reservation accepts a resulting charge equal to its limit. It rejects a resulting charge above the limit before the effect. Accounting uses checked exact arithmetic and cannot wrap or vary with host word size.

    Checks and reservations follow semantic event order. A later charge cannot hide an earlier domain failure. Work needed to reach or perform an earlier check can itself exhaust a budget before that check completes.

    Optimizations, inlining, native fast paths, and constant sharing preserve normative events and their first observable failure. They preserve the exhausted axis and canonical site for the same admitted semantic request. Equal aggregate usage totals alone do not establish this requirement.

    A result channel failure returns no successful result prefix. Diagnostic production obeys its finite channel budget, and terminal reporting uses the reserved emergency representation defined by the selected contract. Optional tracing cannot change the canonical outcome when its own capacity is exhausted.

    The host admits a request only when its physical envelope can support the selected logical limits. It refuses unsupported envelopes without lowering the request budget or choosing another engine. A later physical failure remains operational or defective execution and cannot be relabeled as deterministic guest exhaustion.

    A deterministic evaluation limit stop returns LimitExhaustion with the first exhausted axis and canonical site. A preparation resource stop remains a preparation failure report. An additional profile host budget refusal remains an admission or profile work report according to its stage.

    Host work after a completed evaluation preserves that evaluation when its own budget is exhausted. It can refuse qualification, evidence creation, validation, or authentication without replacing the guest settlement or changing the original evaluation request identity.

    Replaying a request uses the same resource model and complete evaluation limit record. A different declared limit record is a request mismatch even when the observed value would be unchanged. Host verification and comparison budgets remain separately identified.

    Tariff coefficients, logical allocation units, detailed frame charges, channel units, finite default numbers, emergency capacities, and physical envelope requirements come from their versioned Lispex 2.0 contracts. This binding does not infer them from Lispex 1.x counters or current public product observations.

    Missing and unknown named record fields are Topaz checking errors before a call is formed. A negative field or an unsupported representable value in a complete record causes the typed preflight refusal of the called operation. Neither path repairs the record or begins its phase.

    Why

    Complete named records make a resource request explicit and reproducible. Separate preparation, evaluation, and host budgets prevent cache behavior or extra profile checks from changing guest meaning. Ordered reservations and atomic effects ensure that every conforming product reports the same first semantic stop.

    Source evidence

    Complete with a resource failure at zero work

    Link
    main.tpzComplete with a resource failure at zero workOpen in Playground
    1. import std.bytes { Bytes }
    2. import std.io
    3. import std.test
    4. import std.lispex {
    5. LispexPackage,
    6. LispexBoundaryReport,
    7. LispexLimitPreset,
    8. LispexLimits,
    9. LispexSource,
    10. LispexSourceBundle,
    11. PreparedLispexRule,
    12. LispexPreparationError,
    13. LispexDatumView,
    14. LispexValue,
    15. LispexValueError,
    16. LispexEvaluation,
    17. LispexAttemptError,
    18. LispexSettlement,
    19. applicationPackage,
    20. defaultLimits,
    21. prepare,
    22. valueFromDatum,
    23. canonicalBytes,
    24. evaluate,
    25. }
    26. export function main(args: Array<string>, stdin: string) -> Result<int, string> {
    27. let packageResult: Result<LispexPackage, LispexBoundaryReport> = applicationPackage()
    28. let application: LispexPackage = test.assertOk(packageResult)
    29. let preset: LispexLimitPreset = defaultLimits()
    30. let source: LispexSource = LispexSource {
    31. name: "source.scm",
    32. bytes: "(define rule (lambda (input) (let loop () (loop))))\n".encodeUtf8(),
    33. }
    34. let bundle: LispexSourceBundle = LispexSourceBundle {
    35. entryModule: "source.scm",
    36. entryBinding: "rule",
    37. sources: [source],
    38. }
    39. let prepared: Result<PreparedLispexRule, LispexPreparationError> = prepare(application, bundle, preset.preparation)
    40. let rule: PreparedLispexRule = test.assertOk(prepared)
    41. let converted: Result<LispexValue, LispexValueError> = valueFromDatum(application, LispexDatumView.Boolean(true), preset.host)
    42. let input: LispexValue = test.assertOk(converted)
    43. let zeroWork: LispexLimits = LispexLimits {
    44. work: 0,
    45. logicalAllocation: preset.evaluation.logicalAllocation,
    46. semanticFrames: preset.evaluation.semanticFrames,
    47. input: preset.evaluation.input,
    48. result: preset.evaluation.result,
    49. diagnostics: preset.evaluation.diagnostics,
    50. }
    51. let attempt: Result<LispexEvaluation, LispexAttemptError> = evaluate(rule, input, zeroWork)
    52. let evaluation: LispexEvaluation = test.assertOk(attempt)
    53. match (evaluation.settlement) {
    54. case LimitExhaustion(_) => io.writeLine("resource failure")
    55. case _ => io.writeLine("unexpected outcome")
    56. }
    57. return Ok(0)
    58. }
    Expected outputexit 0
    resource failure
    
    $ topaz run main.tpz --locked · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. resource failure

    Run this source inside the verified Lispex application supplied through TOPAZ_LISPEX_APPLICATION. The example expects the Lispex 2.0 host contract.

    Source evidence

    Menu

    Download