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

    Obtain an immutable rule selected by a verified application lock.

    APIs in this module

    1 APIs

    NameModule
    Generated rule factorystd.lispex.rules

    Module

    Link

    A generated factory selects a rule declared by the verified application package and prepares or validates it under explicit finite limits. Every factory returns the same PreparedLispexRule used by std.lispex.evaluate.

    Why

    Link

    A generated name selects a deployment decision already recorded in the package lock. Preparing a supplied source bundle expresses a separate intent and remains an explicit operation.

    Availability

    Link

    Import std.lispex.rules 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.

    Public API

    Link

    Generated rule factory

    Pending contracts

    Link

    Pass values through a bounded guest boundary

    Link
    Ruletopaz.stdlib.contract.lispex-host-boundary.rule

    Pass values through a bounded guest boundary

    The Lispex 2.0 embedding contract governs both modules. Topaz is the host. Lispex is the guest. A guest invocation cannot invoke Topaz code or acquire host authority.

    The host supplies a closed source bundle or an admitted prepared rule. Evaluation accepts one canonical Datum and returns one canonical Datum on success. Host closures and object references cannot cross the boundary.

    Preparation and evaluation each receive a complete finite limit record. Missing fields, unknown fields, negative values and values outside the declared integer range are rejected before entry. No implicit default replaces an invalid record.

    Guest code cannot obtain files, sockets, clocks, randomness, process state, environment variables or host callbacks. The host reads external facts before the call and passes their values explicitly.

    The same canonical request under the same semantic and resource contracts produces the same canonical outcome. Host interruption and engine defects remain separate from deterministic language and resource failures.

    Topaz decides what to do with a returned value after the guest invocation ends. A guest result does not itself grant permission to write files, send messages or perform another host action.

    Why

    Explicit immutable values preserve the direction of authority. Preparation and evaluation have different inputs and costs, so separate bounded operations preserve distinct intentions. A shortcut must perform those same phases without granting an alternate capability path.

    Source evidence

    Pass captured host text as a value

    Link
    main.tpzPass captured host text as a valueOpen 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))\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.Text(stdin), 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 Complete(output) => {
    47. let captured: Bytes = canonicalBytes(input)
    48. let returned: Bytes = canonicalBytes(output)
    49. io.writeLine("{returned.toHex() == captured.toHex()}")
    50. }
    51. case _ => io.writeLine("unexpected outcome")
    52. }
    53. return Ok(0)
    54. }
    Expected outputexit 0
    true
    
    $ topaz run main.tpz --locked · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. true

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

    Source evidence

    Resolve generated factories through the admitted lock

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

    Resolve generated factories through the admitted lock

    std.lispex.rules exports one factory for each rule binding declared by the admitted application lock. The spelling is the exact Topaz identifier in that row. The placeholder ruleName is descriptive and is not a literal universal export.

    Reject missing, duplicate, invalid or colliding exported identifiers during package admission. Generated names do not depend on directory enumeration, source discovery, a network request or a mutable global registry.

    Each factory accepts one complete LispexPreparationLimits record and returns Result of PreparedLispexRule or LispexPreparationError. Validate limits before preparing source or validating transported bytes. The factory has no zero argument or unlimited path.

    The lock row fixes the source closure, selected entry, prepared artifact policy, evaluator and standard library identities, ABI, codec, language and Unicode contracts, profile and resource model. An installed mismatch refuses admission. Never silently replace a locked component.

    A row containing closed source follows prepare. A row containing a transported prepared representation follows admitPrepared. Both paths must yield the same verified program and selected entry promised by the row and preserve the supplied preparation limits.

    Repeated calls may share an immutable rule handle. Sharing and caching preserve the verified canonical program identity and evaluation charges. Preparation reuse may change preparation work and acceptance under its supplied budget. Each later evaluate call starts with its own explicit evaluation limits.

    Factory failure preserves the same Source, Admission, Interrupted or EngineDefect case as the underlying operation. It creates no canonical evaluation outcome and no evaluation receipt. An unrelated unreached factory cannot alter a reached rule result.

    A returned rule is evaluated through std.lispex.evaluate or evaluateWithEvidence. The factory does not evaluate a hidden input, return a business decision or grant a second host callback path.

    A package example supplies a real verified lock through the product test fixture. Concrete generated names are package data. Their inventory is determined by that lock and is not an unresolved language behavior.

    Why

    A generated factory expresses the intention to select a deployment choice already fixed in a verified lock. prepare expresses the intention to submit a new closed bundle. Their shared result and execution contract preserve both intentions without two evaluator semantics.

    Source evidence

    Use a factory name supplied by a verified lock

    Link
    main.tpzUse a factory name supplied by a verified lockOpen in Playground
    1. import std.lispex { PreparedLispexRule, LispexPreparationError, LispexPreparationLimits }
    2. import std.lispex.rules { identity }
    3. function lockedRule(limits: LispexPreparationLimits) -> Result<PreparedLispexRule, LispexPreparationError> {
    4. return identity(limits)
    5. }
    6. export function main(args: Array<string>, stdin: string) -> Result<int, string> {
    7. return Ok(0)
    8. }
    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.

    Use a verified Lispex application package supplied through TOPAZ_LISPEX_APPLICATION. This example specifies the Lispex 2.0 behavior. The product scope remains the public 5.21.3 observation scope. The supplied fixture lock must declare identity as the exported name of its closed identity rule. That name is fixture data rather than a universal module export.

    Source evidence

    Menu

    Download