176821c2e7
The 3020-line docs/DESIGN.md is replaced by the design/ ledger:
design/INDEX.md (sole addressable spine, typed Contracts+Models tables,
polymorphic links — prose file OR authoritative source //!), 14
design/contracts/*.md test-linked invariants + 3 source-link-only
contracts (mangling/env-construction/qualified-xref, no prose file —
code is SoT), 5 design/models/*.md whitepapers, and
docs/journals/2026-05-19-design-decision-records.md (the
relitigation-guard archive — every why/rejected/does-not-do/rollback/
empirical ### moved out at ###-granularity). Clean cut: git rm
docs/DESIGN.md, no stub.
RED-first crates/ailang-core/tests/design_index_pin.rs — the 4-clause
anti-regrowth spine (DESIGN.md-gone / every-INDEX-link-resolves /
every-contract-names-a-resolvable-ratifier /
contracts-carry-no-decision-record-prose) — demonstrably RED before,
GREEN after. Build-atomic by task ordering: design_schema_drift.rs's
include_str! (the only compile-time consumer) retargeted to
design/contracts/data-model.md BEFORE the deletion; its
## Data model/## Pipeline slicer dropped (a simplification the split
enables). 2 NoInstance diagnostics + 2 lockstep E2Es retargeted to
design/contracts/{float-semantics,typeclasses}.md. ~12 agent reading
lists + 5 SKILL bodies + CLAUDE.md + skills/README.md + ~25
code/C/.ail/spec comment xrefs retargeted; OQ7 dangling 'Iter 13b'
cite deleted (no forward target — a pointer would be fiction).
honesty-rule.md rewritten so the rule names the new home
(rationale->journals), resolving the recon-found internal
contradiction; the two docs_honesty_pin.rs:70,72 pinned phrases kept
verbatim+contiguous.
Boss-verified independently: cargo test --workspace 646 passed /
0 failed; design_index_pin 4/4; acceptance grep CLEAN of live
DESIGN.md refs (residuals = only the spec-mandated clause-4
deletion-enforcer). 2 DONE_WITH_CONCERNS routed to the mandatory
milestone-close audit: (a) str-abi.md:23 '(iter str-concat,
2026-05-13)' provenance stamp trips advisory architect_sweeps Sweep-1
— Boss-confirmed byte-identical to DESIGN.md@deeffb1:2062-2065, a
faithfully-migrated PRE-EXISTING anchor (regexes verbatim, only path
retargeted), NOT split-introduced — RATIFY-or-tidy at audit; (b) a
now stale-direction intra-prose 'see Str ABI below' cross-ref in
float-semantics.md — audit-adjudication candidate. Plan defect noted:
Task 9 Step 4's verbatim acceptance grep used a ^./ anchor not
matching the system's grep -rIn output; substance re-verified CLEAN.
Spec grounding-check PASS x2. Journals INDEX + decision-records
pointer appended (Boss-only).
72 lines
3.1 KiB
Rust
72 lines
3.1 KiB
Rust
//! Pin for the iter-24.3 FreeFnCall constraint-residual-push
|
|
//! invariant (design/contracts/typeclasses.md, "Cross-module
|
|
//! references in synthesised bodies" invariant 3).
|
|
//!
|
|
//! Property protected: bare-name references to polymorphic free fns
|
|
//! that resolve through the auto-injected-prelude path AT THE
|
|
//! DOT-QUALIFIED SYNTH BRANCH push residuals for the fn's declared
|
|
//! constraints. The discharge loop then fires `NoInstance` at
|
|
//! typecheck if no instance ships for the unified concrete type.
|
|
//!
|
|
//! Failure mode this pin catches: a future refactor changes the
|
|
//! prelude auto-injection resolution path so that bare-name `print`
|
|
//! reaches synth via a different branch (e.g. locals, env.module_globals
|
|
//! direct hit) that does NOT push residuals. Without this pin, the
|
|
//! regression surfaces as `unknown variable: show` from codegen for
|
|
//! the negative case — confusing diagnostic, hard to bisect.
|
|
|
|
use ailang_check::check_workspace;
|
|
use ailang_surface::load_workspace;
|
|
use std::path::PathBuf;
|
|
|
|
fn fixture_path() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../examples")
|
|
.join("show_no_instance.ail")
|
|
}
|
|
|
|
#[test]
|
|
fn bare_name_polyfn_fires_typecheck_no_instance_not_codegen_unknown_var() {
|
|
// The fixture calls `print f` bare-name (no `prelude.` qualifier)
|
|
// where `f : Int -> Int`. The auto-injected-prelude resolution
|
|
// must route this through the dot-qualified synth branch so that
|
|
// the `Show a` declared constraint of `print` produces a residual,
|
|
// and the discharge loop fires `no-instance`.
|
|
let ws = load_workspace(&fixture_path()).expect("workspace loads");
|
|
let diags = check_workspace(&ws);
|
|
|
|
// Exactly one `no-instance` diagnostic — proves:
|
|
// (a) the bare-name `print` resolved (was not "unknown variable")
|
|
// (b) the resolution reached the dot-qualified synth branch
|
|
// which pushes the declared-constraint residual
|
|
// (c) the discharge loop ran with the residual and fired the
|
|
// NoInstance because no `Show (Int -> Int)` instance exists.
|
|
let no_inst: Vec<_> = diags.iter().filter(|d| d.code == "no-instance").collect();
|
|
assert_eq!(
|
|
no_inst.len(),
|
|
1,
|
|
"expected exactly one 'no-instance' diagnostic — got {} (all diags: {diags:?})",
|
|
no_inst.len()
|
|
);
|
|
|
|
// No "unknown variable" or other codegen-grade errors at typecheck:
|
|
// if the residual push did NOT fire, the typecheck would pass
|
|
// silently and the error would only surface at codegen.
|
|
let unknown_vars: Vec<_> = diags
|
|
.iter()
|
|
.filter(|d| {
|
|
d.code == "unknown-variable"
|
|
|| d.message.contains("unknown variable")
|
|
|| d.code == "internal"
|
|
})
|
|
.collect();
|
|
assert!(
|
|
unknown_vars.is_empty(),
|
|
"expected zero 'unknown variable' or 'internal' diagnostics at typecheck — \
|
|
got {} (all diags: {diags:?}). If this fires, the bare-name `print` \
|
|
resolution bypassed the dot-qualified synth branch and the constraint \
|
|
residual was never pushed.",
|
|
unknown_vars.len()
|
|
);
|
|
}
|