iter ext-cli.1: CLI accepts .ail (Form A) sources alongside .ail.json
Closes the loop opened by this morning's .ailx → .ail rename. Every
path-taking ail subcommand (check, build, run, manifest, render,
prose, merge-prose, describe, emit-ir, diff, workspace, deps) now
accepts a .ail (Form A) input as well as .ail.json (Form B). For
.ail paths the subcommand parses through ailang_surface::parse
in-line and proceeds with the same loaded Module value .ail.json
would have produced; binary semantics are extension-agnostic.
Architecture: a new ailang_surface::{load_module, load_workspace}
pair dispatches on file extension. A new injection point
ailang_core::workspace::load_workspace_with<F> lets the surface
crate plug in an extension-aware loader without core having to
import surface (which would close a crate cycle). Import resolution
in workspace::visit now prefers a .ail sibling over a .ail.json
sibling. The CLI binary's 18 callsites switched to the surface
loaders. Surface parse failures route through
workspace_error_to_diagnostic as a new SurfaceParse variant of
WorkspaceLoadError, so `ail check --json foo.ail` on a malformed
.ail returns a parseable JSON diagnostic with code
surface-parse-error instead of the misleading
`json: expected value at line 1 column 1` fall-through.
Boss pre-commit correction: the implementer followed the plan
verbatim and used snake_case `surface_parse_error`, but every
existing diagnostic code in the codebase is kebab-case (verified
via `git grep` over crates/ailang-check/src and crates/ail/src);
realigned to `surface-parse-error` at three sites (the diagnostic
arm + two ct1 test strings). Journal Concerns section records
the correction.
Tests: cargo test --workspace 487 green (+7 from this iter:
1 core unit, 4 surface integration, 1 ail E2E pair, 1 ct1 CLI
diagnostic-shape). bench/check.py, compile_check.py, cross_lang.py
clean on re-run; the latency.{explicit,implicit}_at_rc tail
cluster occasionally flagged on first runs is the same
nondeterministic cluster the previous two audits documented;
baseline left pristine for the third consecutive iter.
Roadmap follow-up "ail check/build/run accept .ail extension" (P2)
removed.
DESIGN.md §Decision 6 / "CLI" bullet gained the symmetric upward
sentence: both .ail and .ail.json are first-class CLI inputs.
This commit is contained in:
+32
-18
@@ -336,7 +336,7 @@ fn main() -> Result<()> {
|
||||
if workspace {
|
||||
// Workspace mode: load all modules and emit their defs
|
||||
// together, alphabetically by (module, name).
|
||||
let ws = ailang_core::load_workspace(&path)?;
|
||||
let ws = ailang_surface::load_workspace(&path)?;
|
||||
let mut entries: Vec<(String, &ailang_core::Def)> = Vec::new();
|
||||
for (mod_name, m) in &ws.modules {
|
||||
for d in &m.defs {
|
||||
@@ -394,7 +394,7 @@ fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let m = ailang_core::load_module(&path)?;
|
||||
let m = ailang_surface::load_module(&path)?;
|
||||
if json {
|
||||
let entries: Vec<_> = m
|
||||
.defs
|
||||
@@ -422,14 +422,14 @@ fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
Cmd::Render { path } => {
|
||||
let m = ailang_core::load_module(&path)?;
|
||||
let m = ailang_surface::load_module(&path)?;
|
||||
print!("{}", ailang_surface::print(&m));
|
||||
}
|
||||
Cmd::Prose { path } => {
|
||||
// Iter 20a: load via `load_module` (single-module mode,
|
||||
// matching how `render` / `parse` work). Workspace-wide
|
||||
// prose is not in scope for 20a.
|
||||
let m = ailang_core::load_module(&path)?;
|
||||
let m = ailang_surface::load_module(&path)?;
|
||||
print!("{}", ailang_prose::module_to_prose(&m));
|
||||
}
|
||||
Cmd::MergeProse { original, edited } => {
|
||||
@@ -439,7 +439,7 @@ fn main() -> Result<()> {
|
||||
// Form-A is the form an LLM should produce; JSON is the
|
||||
// hashable artefact, not the writing surface. The prose
|
||||
// file is embedded byte-for-byte.
|
||||
let module = ailang_core::load_module(&original)
|
||||
let module = ailang_surface::load_module(&original)
|
||||
.with_context(|| format!("loading {}", original.display()))?;
|
||||
let original_form_a = ailang_surface::print(&module);
|
||||
let prose = std::fs::read_to_string(&edited)
|
||||
@@ -527,7 +527,7 @@ fn main() -> Result<()> {
|
||||
}
|
||||
Cmd::Describe { path, name, json, workspace } => {
|
||||
if workspace {
|
||||
let ws = ailang_core::load_workspace(&path)?;
|
||||
let ws = ailang_surface::load_workspace(&path)?;
|
||||
let (mod_name, def) = resolve_describe_name(&ws, &name)?;
|
||||
if json {
|
||||
// We pass the def itself through and add the
|
||||
@@ -558,7 +558,7 @@ fn main() -> Result<()> {
|
||||
print!("{}", ailang_surface::print(&one));
|
||||
}
|
||||
} else {
|
||||
let m = ailang_core::load_module(&path)?;
|
||||
let m = ailang_surface::load_module(&path)?;
|
||||
let def = m
|
||||
.defs
|
||||
.iter()
|
||||
@@ -593,7 +593,7 @@ fn main() -> Result<()> {
|
||||
// diagnostics (codes `module-not-found`,
|
||||
// `module-cycle`, `module-name-mismatch`, `schema-mismatch`).
|
||||
// Real I/O errors on the entry file remain fatal.
|
||||
let diags = match ailang_core::load_workspace(&path) {
|
||||
let diags = match ailang_surface::load_workspace(&path) {
|
||||
Ok(ws) => ailang_check::check_workspace(&ws),
|
||||
Err(e) => match workspace_error_to_diagnostic(&e) {
|
||||
Some(d) => vec![d],
|
||||
@@ -608,7 +608,7 @@ fn main() -> Result<()> {
|
||||
std::process::exit(1);
|
||||
}
|
||||
} else {
|
||||
let ws = ailang_core::load_workspace(&path)?;
|
||||
let ws = ailang_surface::load_workspace(&path)?;
|
||||
let diags = ailang_check::check_workspace(&ws);
|
||||
if !diags.is_empty() {
|
||||
for d in &diags {
|
||||
@@ -648,7 +648,7 @@ fn main() -> Result<()> {
|
||||
Cmd::EmitIr { path, out } => {
|
||||
// Iter 5c: workspace lowering. For single-module programs the
|
||||
// workspace is effectively a trivial workspace with one module.
|
||||
let ws = ailang_core::load_workspace(&path)?;
|
||||
let ws = ailang_surface::load_workspace(&path)?;
|
||||
let diags = ailang_check::check_workspace(&ws);
|
||||
if !diags.is_empty() {
|
||||
for d in &diags {
|
||||
@@ -743,8 +743,8 @@ fn main() -> Result<()> {
|
||||
}
|
||||
Cmd::Diff { a, b, json, workspace } => {
|
||||
if workspace {
|
||||
let ws_a = ailang_core::load_workspace(&a)?;
|
||||
let ws_b = ailang_core::load_workspace(&b)?;
|
||||
let ws_a = ailang_surface::load_workspace(&a)?;
|
||||
let ws_b = ailang_surface::load_workspace(&b)?;
|
||||
let report = build_workspace_diff(&ws_a, &ws_b);
|
||||
if json {
|
||||
let v = workspace_diff_report_to_json(&report);
|
||||
@@ -756,8 +756,8 @@ fn main() -> Result<()> {
|
||||
std::process::exit(1);
|
||||
}
|
||||
} else {
|
||||
let ma = ailang_core::load_module(&a)?;
|
||||
let mb = ailang_core::load_module(&b)?;
|
||||
let ma = ailang_surface::load_module(&a)?;
|
||||
let mb = ailang_surface::load_module(&b)?;
|
||||
let report = build_diff(&ma, &mb);
|
||||
if json {
|
||||
let v = diff_report_to_json(&report);
|
||||
@@ -771,7 +771,7 @@ fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
Cmd::Workspace { entry, json } => {
|
||||
let ws = ailang_core::load_workspace(&entry)?;
|
||||
let ws = ailang_surface::load_workspace(&entry)?;
|
||||
// Iterate alphabetically over module names (BTreeMap order
|
||||
// is already sorted; assert it explicitly).
|
||||
let mut entries: Vec<(String, String, usize)> = ws
|
||||
@@ -852,7 +852,7 @@ fn main() -> Result<()> {
|
||||
}
|
||||
Cmd::Deps { path, of, json, workspace } => {
|
||||
if workspace {
|
||||
let ws = ailang_core::load_workspace(&path)?;
|
||||
let ws = ailang_surface::load_workspace(&path)?;
|
||||
|
||||
// `--of NAME`: optional, accepts dot notation
|
||||
// (`<module>.<def>`) or a bare name (matches in all
|
||||
@@ -978,7 +978,7 @@ fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let m = ailang_core::load_module(&path)?;
|
||||
let m = ailang_surface::load_module(&path)?;
|
||||
let mut entries = Vec::new();
|
||||
for d in &m.defs {
|
||||
if let Some(filter) = &of {
|
||||
@@ -1316,6 +1316,20 @@ fn workspace_error_to_diagnostic(
|
||||
"field": field,
|
||||
})),
|
||||
),
|
||||
// ext-cli.1: surface-side parse failure on a `.ail` (Form A)
|
||||
// source file. Routed through the same `Diagnostic` channel as
|
||||
// schema/coherence errors so `ail check --json foo.ail` on a
|
||||
// broken `.ail` returns a parseable JSON array instead of the
|
||||
// misleading JSON-parse fall-through.
|
||||
W::SurfaceParse { path, message } => Some(
|
||||
ailang_check::Diagnostic::error(
|
||||
"surface-parse-error",
|
||||
message.clone(),
|
||||
)
|
||||
.with_ctx(serde_json::json!({
|
||||
"path": path.display().to_string(),
|
||||
})),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2190,7 +2204,7 @@ fn build_to(
|
||||
opt: &str,
|
||||
alloc: ailang_codegen::AllocStrategy,
|
||||
) -> Result<PathBuf> {
|
||||
let ws = ailang_core::load_workspace(path)?;
|
||||
let ws = ailang_surface::load_workspace(path)?;
|
||||
let diags = ailang_check::check_workspace(&ws);
|
||||
if !diags.is_empty() {
|
||||
for d in &diags {
|
||||
|
||||
Reference in New Issue
Block a user