//! Pin the canonical identity of the parsed prelude as a literal
//! hex hash. Updates intentionally on prelude-content changes
//! (record the why in the commit body); accidental drift trips
//! immediately.

use ailang_core::workspace::module_hash;
use ailang_surface::parse_prelude;

#[test]
fn prelude_parse_yields_canonical_hash() {
    let m = parse_prelude();
    let h = module_hash(&m);
    // The expected hex updates intentionally on prelude-content
    // changes; record the why in the commit body.
    // 2026-05-21 operator-routing-eq-ord re-pinned (prior:
    // 3abe0d3fa3c11c99): Eq Int/Bool/Str bodies flip to placeholder
    // `false`; Eq Unit added; six float_* fns added; class-Eq doc
    // rewritten away from the "P2 follow-up" comment.
    // 2026-05-21 schema-camelcase-fix re-pinned (prior:
    // 6d0577ff0d4e50ac): `Term::Lam`'s JSON tags renamed from
    // `paramTypes`/`retType` to `param-types`/`ret-type`. The
    // prelude contains 11 `(lam ...)` forms, so each lambda's
    // canonical-JSON bytes change and the module hash drifts.
    // Form-A surface unchanged — only the canonical-JSON byte
    // stream differs, which is what the rename targets.
    // 2026-05-28 prep.3 (kernel-extension-mechanics) re-pinned
    // (prior: 562a03fc57e7e017): prelude becomes kernel-tier —
    // `examples/prelude.ail` gains the `(kernel)` module-header
    // attribute, which serialises as `"kernel": true` in the
    // canonical JSON. This changes the prelude's content hash
    // deterministically; the behaviour `prelude_free_fns.rs`
    // protects (12 free fns callable bare in every consumer) is
    // unchanged — only the code path migrates from the hardcoded
    // `&["prelude"]` literal to the kernel-flag filter.
    // 2026-05-29 intrinsic-bodies.2 re-pinned (prior:
    // af372f28c726f29f): the 13 authored prelude dummy bodies
    // (7 Eq/Ord instance methods + 6 float_* fns) migrate from
    // placeholder terms ((body false)/(body true)/
    // (body (term-ctor Ordering EQ))) to Term::Intrinsic. The
    // canonical-JSON byte stream changes; behaviour is unchanged
    // (codegen intercepts by name before the body is inspected).
    // 2026-05-29 intrinsic-bodies audit-tidy re-pinned (prior:
    // 2ea61ef21ebc1913): the same 13 defs' doc strings were
    // rewritten from the stale "placeholder / try_emit_primitive_instance_body"
    // wording to honest "compiler-supplied (intrinsic)" wording.
    // doc is part of the canonical JSON, so the module hash moves;
    // the synthesised mono def-hashes do NOT (synthesise_mono_fn
    // sets doc: None).
    assert_eq!(
        h, "62764e07c1bc9bbb",
        "prelude module hash drifted; if intentional, capture the new \
         hex below + record the why in the commit body."
    );
}
