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.

    Tools

    compiler compare

    Compares two compiler observations or selected binary inputs.

    Invocation, options and results

    Link

    topaz compiler compare

    Synopsis
    1. topaz compiler compare <left> <right>

    Input

    Use topaz compiler compare <left> <right> with exactly two operands. The only option is --layer semantic, --layer generated-source, --layer provenance or --layer native-binary. The default is semantic.

    For the first three layers both operands are observation bundle directories and each must validate before comparison. For native-binary the operands are existing regular files whose bytes are read without execution.

    Reject an unknown layer, repeated option, missing value, equals form, missing or extra operand and every unlisted option. In particular no compiler, language, root, output or format selector is accepted.

    Options and conflicts

    OptionDefaultContractConflicts
    --layer semantic|generated-source|provenance|native-binarysemantic

    compiler compare: select one independent comparison layer (default semantic)

    None listed

    Output channels

    stdout

    stderr

    Exit status

    0

    The requested comparison layer is equal.

    1

    The valid comparison receipt records a difference, or arguments, input access, validation or receipt output fails.

    Effects

    Read both inputs without changing them. Do not rebuild sources, run either native input, write a result file, rewrite an observation manifest or follow bundle member symlinks.

    The left and right operand order determines the labels in the receipt. Do not silently swap operands to normalize a disagreement.

    Perform no network access. Missing observations, dependencies or native inputs are errors rather than download requests.

    The same ordered input bytes, selected layer and comparison schema produce identical canonical receipt bytes. Mismatch ordering follows phase order and member path order.

    Equality is scoped to the requested layer. Semantic equality does not claim identical generated source, provenance or native binaries.

    Compare package facts already recorded in an observation. Do not resolve the caller package, consult a live registry, rewrite its lock or materialize its dependencies.

    Native comparison accepts existing product files and does not infer a package build request from their paths.

    Operation

    Link

    Choose the comparison layer that represents the property being investigated. Native-binary comparison reads existing files.

    Option conditions

    Link

    --layer applies to compiler compare only

    Behavior contract

    Link
    Ruletools-commands-compiler-compare.rule.behavior

    Command behavior

    Arguments and rejection

    Use topaz compiler compare <left> <right> with exactly two operands. The only option is --layer semantic, --layer generated-source, --layer provenance or --layer native-binary. The default is semantic.

    For the first three layers both operands are observation bundle directories and each must validate before comparison. For native-binary the operands are existing regular files whose bytes are read without execution.

    Reject an unknown layer, repeated option, missing value, equals form, missing or extra operand and every unlisted option. In particular no compiler, language, root, output or format selector is accepted.

    Output

    Write one canonical JSON comparison receipt using topaz.compiler.comparison/v1 to standard output. This is the fixed comparison artifact and there is no human renderer or --format selector. Both --format human and --format json are rejected.

    The receipt contains schema, string layer, boolean equal, nullable string firstFailingPhase, nonnegative integer mismatchCount, array mismatches and boolean truncated.

    Each mismatch identifies phase, path, kind and nullable stableId, together with nullable left and right byte lengths and SHA-256 digests. Report at most 32 mismatch rows at the first failing phase and set truncated when further mismatches at that phase were omitted.

    Semantic comparison examines source set, tokens, AST, resolved data, typed data, lowered data, diagnostics and recorded outcome in that order. Generated source comparison examines generated source records and source bytes. Provenance comparison examines producer provenance. Native comparison compares the complete supplied file bytes.

    Disagreement produces a valid receipt. A failure to read or validate the inputs writes a human explanation to standard error and does not fabricate a comparison receipt.

    Exit status

    Exit 0 when the requested layer is equal. Exit 1 when the valid comparison receipt reports a difference.

    Exit 1 also covers invalid arguments, unreadable inputs, invalid observation bundles or failure to produce the receipt. Callers distinguish a valid disagreement by its complete stdout receipt.

    Filesystem effects

    Read both inputs without changing them. Do not rebuild sources, run either native input, write a result file, rewrite an observation manifest or follow bundle member symlinks.

    The left and right operand order determines the labels in the receipt. Do not silently swap operands to normalize a disagreement.

    Network access

    Perform no network access. Missing observations, dependencies or native inputs are errors rather than download requests.

    Reproducibility

    The same ordered input bytes, selected layer and comparison schema produce identical canonical receipt bytes. Mismatch ordering follows phase order and member path order.

    Equality is scoped to the requested layer. Semantic equality does not claim identical generated source, provenance or native binaries.

    Packages and locks

    Compare package facts already recorded in an observation. Do not resolve the caller package, consult a live registry, rewrite its lock or materialize its dependencies.

    Native comparison accepts existing product files and does not infer a package build request from their paths.

    Why

    Semantic agreement, generated source agreement, provenance agreement and native byte agreement ask different questions. Equal results in one layer do not make those intentions interchangeable. A fixed comparison receipt lets callers distinguish disagreement from failure to read valid evidence.

    Source evidence

    The linked public CLI recipe checks the exact displayed argument rejection before the requested operation. It does not execute the successful operation or verify its effects.

    The reviewed recipe uses an invalid layer and stops before reading either operand. Successful bundle and native byte comparisons need separate fixture shapes outside the allowlist and no binary is created here.

    Example contract

    Link
    Ruletools-commands-compiler-compare.rule.invocation

    Example contract

    The invocation topaz compiler compare main.tpz main.tpz --language-version 5.21 --layer invalid is expected to exit with 1.

    Reject an unknown comparison layer before reading either operand. Both displayed operands are small fixture paths; no bundle or binary is created.

    Why

    The comparison layer determines which differences count. Rejecting an unknown layer prevents a comparison from silently using different criteria.

    Source evidence

    Example

    Link

    Argument-rejection example

    Link
    main.tpzArgument-rejection exampleOpen in Playground
    1. function identity<T>(value: T) -> T {
    2. value
    3. }
    target product 5.21.3
    Expected result

    Expected result

    Textual rejection details remain Pending in the reference model. The independent Tools example gate expects exit 1.

    Reject an unknown comparison layer before reading either operand. Both displayed operands are small fixture paths; no bundle or binary is created.

    Source evidence

    Verification scope

    Link

    Observed with Topaz 5.21.3 on 2026-11-06T08:36:29.642Z. This invocation passed; exit 1. 3 assertions were evaluated against the independent expected result. Execution record. This result covers the displayed invocation.

    Related references

    Link

    Compiler selection

    Packages, locks and targets

    Menu

    Download