Invocation, options and results
Linktopaz compiler compare
topaz compiler compare <left> <right>
Input
Use topaz compiler compare <left> <right> with exactly two operands. The only option is -, -, - or -. The default is semantic.
For the first three layers both operands are observation bundle directories and each must validate before comparison. For native- 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
| Option | Default | Contract | Conflicts |
|---|---|---|---|
--layer semantic|generated-source|provenance|native-binary | semantic | 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
LinkChoose the comparison layer that represents the property being investigated. Native-binary comparison reads existing files.
Option conditions
Link- applies to compiler compare only
Behavior contract
LinkCommand behavior
Arguments and rejection
Use topaz compiler compare <left> <right> with exactly two operands. The only option is -, -, - or -. The default is semantic.
For the first three layers both operands are observation bundle directories and each must validate before comparison. For native- 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. to standard output. This is the fixed comparison artifact and there is no human renderer or - selector. Both - and - are rejected.
The receipt contains schema, string layer, boolean equal, nullable string first, nonnegative integer mismatch, array mismatches and boolean truncated.
Each mismatch identifies phase, path, kind and nullable stable, 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
- compiler/crates/topaz_cli/src/command/flags.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/dispatch.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/validation.rs at
b48527d0a174
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
LinkExample contract
The invocation topaz compiler compare main. 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
- compiler/crates/topaz_cli/src/command/flags.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/dispatch.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/validation.rs at
b48527d0a174
Example
LinkArgument-rejection example
Linkfunction identity<T>(value: T) -> T {value}
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
- compiler/crates/topaz_cli/src/command/flags.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/dispatch.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/validation.rs at
b48527d0a174
Verification scope
LinkObserved 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.