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.evaluate

    Evaluate one canonical input and preserve completed failures as outcomes.

    evaluate(rule: PreparedLispexRule, input: LispexValue, limits: LispexLimits) -> Result<LispexEvaluation, LispexAttemptError>
    Receiver
    Not applicable
    Minimum arity
    3
    Maximum arity
    3

    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

    Parameter constraints

    evaluate(rule, input, limits) returns Result<LispexEvaluation, LispexAttemptError>. It submits the immutable prepared program, one canonical input value, and the complete declared evaluation limits. It snapshots caller owned data before entry and performs no external action on behalf of the guest.

    Ok contains a completed evaluation even when the rule fails. LispexEvaluation.request records the verified semantic request and its identity. LispexEvaluation.settlement records the completed canonical outcome of that request. The result carries no successful value when its settlement is a failure.

    LispexSettlement.Complete(value) contains exactly one canonical LispexValue. A false Boolean or an application value named deny or review remains a successful language result. The adapter neither interprets that value as a host command nor performs an external action.

    LispexSettlement.SemanticFailure(condition) records an uncaught deterministic language or domain failure. The condition retains its stable phase, stable code, typed canonical parameters, and canonical failure site. Returning a procedure or multiple values across the single Datum result boundary cannot produce Complete.

    LispexSettlement.LimitExhaustion(condition) records a deterministic stop under the selected evaluation resource model and limits. Its condition identifies the first exhausted resource axis and canonical failure site. It preserves the first cause and returns no successful result prefix.

    A LispexCondition identifies a failure through its phase and stable code together. Its parameters retain their canonical types and values. Its site follows the selected canonical site contract. A resource condition also carries the exhausted axis required by that contract.

    Translated messages, source coordinates, host paths, and displayed stacks are diagnostic presentation. They do not replace condition parameters or alter the canonical settlement. A code or human message alone is insufficient to compare failures.

    LispexAttemptError.Admission(report) reports a refused submission. The report records the submitted request data and identities verified before refusal. Admission refusal produces neither a canonical evaluation outcome nor an evaluation receipt.

    LispexAttemptError.Interrupted(fault) reports a host interruption that prevented evaluation completion. Cancellation, a host deadline, or loss of host resources cannot be relabeled as a deterministic Lispex limit stop. The attempt supplies no canonical evaluation outcome or evaluation receipt.

    LispexAttemptError.EngineDefect(report) identifies an evaluator defect that prevented a conforming completed evaluation. It remains distinct from an admitted program's language failure. The attempt supplies no canonical evaluation outcome or evaluation receipt.

    A boundary report states its stage and stable reason with named presentation fields. It cites only identities already verified at that stage. It does not synthesize a canonical input, program identity, evaluation request identity, or failure site that validation has not established.

    A preparation read or normalization failure before canonical code exists produces a report bound to the exact submitted source. It stops before entry evaluation. Source locations in that report describe the supplied source and do not claim a canonical evaluation location.

    Canonical input decoding and canonical result or failure encoding remain evaluation work. A deterministic resource stop during those evaluation events is LimitExhaustion. Whether the guest entry was called does not by itself determine the outcome class.

    A lexical guest guard can recover from ordinary runtime and domain conditions under the Lispex condition contract. Preparation, admission, resource, operational, and internal failures remain outside guest recovery. Resource exhaustion runs no guest recovery or cleanup and preserves its first cause.

    Every call starts a fresh evaluation account. Reusing a prepared rule preserves its program while supplying an independent input and declared budget. An earlier value, failure, or host cache state cannot become hidden input to a later evaluation.

    A conforming execution of the same admitted semantic request produces the same Complete value or the same complete failure condition. The comparison includes the phase, code, typed parameters, canonical site, and resource axis when present. It excludes host execution observations.

    Deterministic language failures and evaluation resource stops remain eligible for portable receipts and exact replay. An outer attempt error does not become a receipt eligible settlement merely because its report is structured or reproducible.

    SemanticFailure carries resource as None(). LimitExhaustion carries Some of the first exhausted axis. Channel names identify the input, result or diagnostics channel declared by the selected versioned model. They are not locale dependent messages.

    Each evaluation performs the required guest and module initialization under its evaluation budget before the selected entry runs. A reused prepared handle contains no guest state from an earlier call. Preparation performs no guest computation.

    Validate the evaluation limit record and supported contract before entry. A canonical input whose codec or contract differs from the prepared rule produces Admission. A valid handle does not permit a caller to reinterpret its bytes under another codec.

    Result

    The declared result type is Result<LispexEvaluation, LispexAttemptError>.

    Effects

    Failures

    Result and effects

    Link

    Evaluate one canonical input and preserve completed failures as outcomes.

    Why

    Link

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

    Resolved contracts

    Link

    Related entries

    Link

    std.lispex

    Read a completed evaluation and preserve its failure class

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

    Read a completed evaluation and preserve its failure class

    evaluate(rule, input, limits) returns Result<LispexEvaluation, LispexAttemptError>. It submits the immutable prepared program, one canonical input value, and the complete declared evaluation limits. It snapshots caller owned data before entry and performs no external action on behalf of the guest.

    Ok contains a completed evaluation even when the rule fails. LispexEvaluation.request records the verified semantic request and its identity. LispexEvaluation.settlement records the completed canonical outcome of that request. The result carries no successful value when its settlement is a failure.

    LispexSettlement.Complete(value) contains exactly one canonical LispexValue. A false Boolean or an application value named deny or review remains a successful language result. The adapter neither interprets that value as a host command nor performs an external action.

    LispexSettlement.SemanticFailure(condition) records an uncaught deterministic language or domain failure. The condition retains its stable phase, stable code, typed canonical parameters, and canonical failure site. Returning a procedure or multiple values across the single Datum result boundary cannot produce Complete.

    LispexSettlement.LimitExhaustion(condition) records a deterministic stop under the selected evaluation resource model and limits. Its condition identifies the first exhausted resource axis and canonical failure site. It preserves the first cause and returns no successful result prefix.

    A LispexCondition identifies a failure through its phase and stable code together. Its parameters retain their canonical types and values. Its site follows the selected canonical site contract. A resource condition also carries the exhausted axis required by that contract.

    Translated messages, source coordinates, host paths, and displayed stacks are diagnostic presentation. They do not replace condition parameters or alter the canonical settlement. A code or human message alone is insufficient to compare failures.

    LispexAttemptError.Admission(report) reports a refused submission. The report records the submitted request data and identities verified before refusal. Admission refusal produces neither a canonical evaluation outcome nor an evaluation receipt.

    LispexAttemptError.Interrupted(fault) reports a host interruption that prevented evaluation completion. Cancellation, a host deadline, or loss of host resources cannot be relabeled as a deterministic Lispex limit stop. The attempt supplies no canonical evaluation outcome or evaluation receipt.

    LispexAttemptError.EngineDefect(report) identifies an evaluator defect that prevented a conforming completed evaluation. It remains distinct from an admitted program's language failure. The attempt supplies no canonical evaluation outcome or evaluation receipt.

    A boundary report states its stage and stable reason with named presentation fields. It cites only identities already verified at that stage. It does not synthesize a canonical input, program identity, evaluation request identity, or failure site that validation has not established.

    A preparation read or normalization failure before canonical code exists produces a report bound to the exact submitted source. It stops before entry evaluation. Source locations in that report describe the supplied source and do not claim a canonical evaluation location.

    Canonical input decoding and canonical result or failure encoding remain evaluation work. A deterministic resource stop during those evaluation events is LimitExhaustion. Whether the guest entry was called does not by itself determine the outcome class.

    A lexical guest guard can recover from ordinary runtime and domain conditions under the Lispex condition contract. Preparation, admission, resource, operational, and internal failures remain outside guest recovery. Resource exhaustion runs no guest recovery or cleanup and preserves its first cause.

    Every call starts a fresh evaluation account. Reusing a prepared rule preserves its program while supplying an independent input and declared budget. An earlier value, failure, or host cache state cannot become hidden input to a later evaluation.

    A conforming execution of the same admitted semantic request produces the same Complete value or the same complete failure condition. The comparison includes the phase, code, typed parameters, canonical site, and resource axis when present. It excludes host execution observations.

    Deterministic language failures and evaluation resource stops remain eligible for portable receipts and exact replay. An outer attempt error does not become a receipt eligible settlement merely because its report is structured or reproducible.

    SemanticFailure carries resource as None(). LimitExhaustion carries Some of the first exhausted axis. Channel names identify the input, result or diagnostics channel declared by the selected versioned model. They are not locale dependent messages.

    Each evaluation performs the required guest and module initialization under its evaluation budget before the selected entry runs. A reused prepared handle contains no guest state from an earlier call. Preparation performs no guest computation.

    Validate the evaluation limit record and supported contract before entry. A canonical input whose codec or contract differs from the prepared rule produces Admission. A valid handle does not permit a caller to reinterpret its bytes under another codec.

    Why

    A caller must distinguish a completed rule decision from a request that never produced a canonical evaluation outcome. Typed conditions preserve the same meaning across products and presentation settings. Keeping admission and operational attempts outside LispexSettlement prevents a report from masquerading as a replayable rule result.

    Source evidence

    Return a language failure as an outcome

    Link
    main.tpzReturn a language failure as an outcomeOpen 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) (+ input 1)))\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 attempt: Result<LispexEvaluation, LispexAttemptError> = evaluate(rule, input, preset.evaluation)
    44. let evaluation: LispexEvaluation = test.assertOk(attempt)
    45. match (evaluation.settlement) {
    46. case SemanticFailure(_) => io.writeLine("language failure")
    47. case _ => io.writeLine("unexpected outcome")
    48. }
    49. return Ok(0)
    50. }
    Expected outputexit 0
    language failure
    
    $ topaz run main.tpz --locked · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. language 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

    Distinguish interrupted attempts from completed failures

    Link
    main.tpzDistinguish interrupted attempts from completed failuresOpen in Playground
    1. import std.lispex { LispexAttemptError, LispexOperationalFault, LispexSettlement, LispexResourceAxis }
    2. function attemptReason(error: LispexAttemptError) -> string {
    3. return match (error) {
    4. case Admission(report) => report.code
    5. case Interrupted(fault) => match (fault) {
    6. case Cancelled() => "cancelled"
    7. case DeadlineExceeded() => "deadline"
    8. case SafetyPreemption() => "physical safety"
    9. }
    10. case EngineDefect(report) => report.code
    11. }
    12. }
    13. function resource(outcome: LispexSettlement) -> Option<LispexResourceAxis> {
    14. return match (outcome) {
    15. case Complete(value) => None()
    16. case SemanticFailure(condition) => condition.resource
    17. case LimitExhaustion(condition) => condition.resource
    18. }
    19. }
    20. export function main(args: Array<string>, stdin: string) -> Result<int, string> {
    21. return Ok(0)
    22. }
    Expected outputexit 0
    No stdout.
    $ topaz check main.tpz --locked --format json · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Check this source in the verified application fixture. Host interruption has no canonical settlement. A completed deterministic failure remains inside LispexEvaluation.

    Source evidence

    Menu

    Download