On this page

Item hashes

tenon hashes <file.tn> [--all] [--requires] [--json] prints stable per-item SHA-256 hashes for the checked package graph rooted at file.tn. It does not write or update tenon.lock, tenon.toml, or any other file.

Package identity

The root source must be in a package directory with a sibling tenon.toml. Its package name supplies the root package identity. The file stem supplies the root module path, and must be a valid importable module name. For example, lib.tn in package geom gives names such as geom::lib.distance, whether lib.tn is the root or is reached as an imported module. A root lib.tn that imports itself is an import cycle (E0221), just as it is when loaded as a dependency.

Canonical item names have the form <package>::<module.path>.<item>. Package versions are not part of identity or the hash: changing only a version keeps the item hashes. Renaming a package changes canonical names and therefore its hashes. See ADR-0075.

The command checks the source and its complete loaded package graph. It reports items from every loaded package in canonical-name byte order. By default it prints public functions, structs, enums, newtypes, interfaces, and impls. An impl is public when its interface and all named types in its identity are public. --all also includes private items.

Hash meanings

Each item has a sig and a body hash, rendered as sha256:<64 lowercase hexadecimal digits>.

The signature hash uses the canonical signature form and the item's reflexive-transitive signature-reference closure. Closure entries are sorted by canonical name; the item's own form is not repeated in the closure. This means a referenced type signature change can change a dependent item's sig. The closure includes private declarations for checking, but public signatures cannot expose private types (E0225), except that a newtype's opaque representation is omitted from its signature. The repr affects only its own body hash; see ADR-0069 and ADR-0076.

The body hash is shallow and covers only that item's own implementation. Function bodies include checkfree. An extern function includes its bound C symbol in its own body hash. Impl bodies include their methods. A newtype's representation affects only that newtype's own body hash. Structs, enums, and interfaces share the (none) body form. In particular, changing a private helper does not change its caller's body hash, and adding an impl does not change a type's signature hash.

Canonical forms serialize the rewritten AST, not formatted source or parse --dump output. Comments and layout do not affect hashes. See ADR-0075 for the canonical forms, exact preimages, and omitted AST details.

Output

Human output has one row per item, sorted by canonical name:

fn geom::lib.distance sig=sha256:<64 lowercase hex> body=sha256:<64 lowercase hex>

--all adds private rows; without it only public rows are emitted. In JSON mode (--json), output is newline-delimited JSON (one object per item), with fields in this order:

{"kind":"fn","name":"geom::lib.distance","public":true,"sig":"sha256:<64 lowercase hex>","body":"sha256:<64 lowercase hex>"}

The kind identifies the item (fn, struct, enum, newtype, interface, or impl); public is a boolean. JSON uses the same filtering, ordering, and hashes as human output.

Impl names are impl <interface> for <type>. Function and type namespaces stay separate: a function and struct with the same name produce two rows, ordered function first on a name tie. Human impl rows start with the impl name without repeating the impl kind.

Plugin requirements

tenon hashes lib.tn --requires prints a tenon.requires sidecar to stdout. Redirect it to a file and check it into the plugin package. This mode cannot be combined with --all or --json.

requires_version = 1
hash_version = 1
plugin = "geom"
items = [
  "sha256:<64 lowercase hex> util::lib.value",
  "sha256:<64 lowercase hex> impl util::lib.Area for util::lib.Square @util::lib",
]

Rows record direct cross-package imports from every loaded module of the root package, using original canonical names even for aliased imports. Dependency packages' imports are not extra rows: signature hashes already cover their transitive signature references. Record each foreign-provider loaded impl whose interface and named target types (including generic arguments) are in that imports' closure; do not record impls provided by the plugin root itself. Impl selection considers only interface and target identity, not method types; the interface signature closure already reaches third types in method signatures. Builtin target types add no named-type requirement. This deliberately over-approximates impl usage. The @package::module suffix identifies the impl's provider, including bridge packages. Moving an impl requires regenerating the sidecar. Rows are sorted by canonical item name; an import-free standalone package has no rows.

Host compatibility

tenon check-compat <tenon.requires> [host-dir] checks the recorded requirements against the host package directory (the current directory when omitted) and its locked package graph. A plugin is a package with a recorded requirements file; a host is a package whose graph provides its requirements. These are not new manifest concepts. The command loads the required modules and their imports, including recorded impl providers, rather than compiling the host root and its imports. It is not run automatically on build.

Each recorded item or impl must be public and present with the same signature hash; body hashes are not compared, so body-only changes are accepted. Additional items do not break compatibility. The check ignores capabilities for now. Function and type names can coincide: the version-1 row omits the namespace, so any public candidate with the recorded signature satisfies it. A present name with no matching signature is E0952. The conservative impl rule above can record an impl the plugin does not use; moving its provider can produce E0951 even if an equivalent impl exists elsewhere. Regenerate the sidecar after reviewing such a change.

All missing or signature-mismatched requirements are reported together, sorted by item name. E0951 identifies a missing item or impl; E0952 identifies a signature mismatch. E0953 reports a malformed or unreadable sidecar; E0954 reports an unsupported requirements or hash version. Neither hashes nor check-compat writes files or updates the lock. Stale locks retain E0935. Diagnostics point at the items key; array elements have no individual spans.

See the language reference for import and interface syntax.

Errors

E0950 is reported when the source has no sibling tenon.toml, or when its file stem is not a valid importable module name. Add a package manifest or use an importable filename. Syntax, import, name, arity, type, coherence, and other package errors are reported using their ordinary compiler diagnostic codes; hashes are not produced for an invalid package graph.

Usage and file/tool errors follow the usual tenon command conventions. Diagnostics are written to stderr; --diagnostics=json selects the compiler's JSON diagnostic format.