8000 Full error UX: structured errors, --explain flag, recovery hints · Issue #148 · Mnehmos/mnehmos.nls.lang · GitHub
[go: up one dir, main page]

Skip to content

Full error UX: structured errors, --explain flag, recovery hints #148

Closed

Description

@Mnehmos

Problem

v0.1 delivers baseline file+line errors. v1.0 requires production-grade error UX: structured machine-readable output, extended explanations, and recovery suggestions.

Acceptance Criteria

  • --json flag on all commands outputs structured error objects (code, file, line, col, message)
  • nlsc explain E001 (or --explain flag) gives extended documentation for each error code
  • Every error class has a documented error code
  • Recovery hints are context-aware (e.g. suggests correct @use path, correct type name)
  • Editor/LSP integration can consume structured errors

Why This Blocks v1.0

Production tools have production error handling. This is a trust signal for engineering teams.

Activity

  1. added this to the v1.0 milestone on Mar 17, 2026
  2. Mnehmos commented on Apr 2, 2026

    @Mnehmos
    OwnerAuthor

    Delivered the first structured-error slice in / PR #168.

    This slice adds:

    • shared CLI diagnostics with stable JSON fields: , , , , , optional
    • support for , plus matching and support while the implementation stayed compact
    • first covered categories: missing file (), parse errors (), stdlib resolution errors (), and dependency resolution errors ()
    • targeted regression coverage for JSON error output without breaking existing human-readable stderr flows

    Still remaining for #148:

    • richer explain/recovery UX beyond inline hints ( / )
    • broader structured coverage for other commands and validation categories
    • any deeper formatting/contract guarantees we want for success payloads and multi-diagnostic cases
  3. Mnehmos commented on Apr 2, 2026

    @Mnehmos
    OwnerAuthor

    Delivered the first structured-error slice in 1ba3324 / PR #168.

    This slice adds:

    • shared CLI diagnostics with stable JSON fields: code, file, line, col, message, optional hint
    • --json support for nlsc verify, plus matching compile and run support while the implementation stayed compact
    • first covered categories: missing file (EFILE001), parse errors (EPARSE001), stdlib @use resolution errors (EUSE001), and dependency resolution errors (E_RESOLUTION)
    • targeted regression coverage for JSON error output without breaking existing human-readable stderr flows

    Still remaining for #148:

    • richer explain/recovery UX beyond inline hints (--explain / nlsc explain)
    • broader structured coverage for other commands and validation categories
    • any deeper formatting/contract guarantees we want for success payloads and multi-diagnostic cases
  4. added 2 commits that reference this issue on Apr 2, 2026
  5. Mnehmos commented on Apr 2, 2026

    @Mnehmos
    OwnerAuthor

    Delivered the next Gitflow slice in PR #169.\n\nThis slice adds a centralized catalog for the currently emitted compile/verify/run CLI error codes, adds , and updates for the active codes.\n\nStill remaining on #148 after this slice: any broader error taxonomy expansion beyond the currently emitted compile/verify/run codes, any additional UX/formatting work around explanations, and any other acceptance points not covered by the explain/catalog/docs slice.

  6. Mnehmos commented on Apr 2, 2026

    @Mnehmos
    OwnerAuthor

    Delivered the next Gitflow slice in PR #169.

    This slice adds a centralized catalog for the currently emitted compile/verify/run CLI error codes, adds nlsc explain <ERROR_CODE>, and updates docs/error-reference.md for the active codes.

    Still remaining on #148 after this slice: any broader error taxonomy expansion beyond the currently emitted compile/verify/run codes, any additional UX or formatting work around explanations, and any other acceptance points not covered by the explain/catalog/docs slice.

  7. Mnehmos commented on Apr 2, 2026

    @Mnehmos
    OwnerAuthor

    Delivered this slice in via PR #170.

    This slice adds structured error output to and , reusing the shared diagnostic contract already used by compile/verify/run. It reuses and , and adds the minimum new graph-only codes for lookup and unsupported ANLU graph formats (, ). Tests and were updated for the new behavior.

    Still remaining on #148 after this slice:

    • add -driven recovery UX across the rest of the CLI surface
    • finish structured error coverage for commands outside compile/verify/run/graph/diff
    • add any remaining recovery hints / catalog entries needed for other command-specific failures
  8. Mnehmos commented on Apr 2, 2026

    @Mnehmos
    OwnerAuthor

    Delivered this slice in fd46815 via PR #170.

    This slice adds --json structured error output to nlsc graph and nlsc diff, reusing the shared diagnostic contract already used by compile/verify/run. It reuses EFILE001 and EPARSE001, and adds the minimum new graph-only codes for --anlu lookup and unsupported ANLU graph formats (EGRAPH001, EGRAPH002). Tests and docs/error-reference.md were updated for the new behavior.

    Still remaining on #148 after this slice:

    • add --explain-driven recovery UX across the rest of the CLI surface
    • finish structured error coverage for commands outside compile/verify/run/graph/diff
    • add any remaining recovery hints and catalog entries needed for other command-specific failures
  9. 37 remaining items

  10. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Follow-up from PR #170 is fixed in #184. {
    "ok": false,
    "command": "graph",
    "diagnostics": [
    {
    "code": "ECLI001",
    "file": "",
    "line": null,
    "col": null,
    "message": "the following arguments are required: file",
    "hint": "Rerun the command with --help to inspect the required arguments and valid options."
    }
    ],
    "usage": "usage: nlsc graph [-h] [-f {mermaid,dot,ascii}] [-a ANLU] [--dataflow]\n [-o OUTPUT] [--json]\n file",
    "error_type": "ECLI001"
    } and {
    "ok": false,
    "command": "diff",
    "diagnostics": [
    {
    "code": "ECLI001",
    "file": "",
    "line": null,
    "col": null,
    "message": "the following arguments are required: file",
    "hint": "Rerun the command with --help to inspect the required arguments and valid options."
    }
    ],
    "usage": "usage: nlsc diff [-h] [--stat] [--full] [--json] file",
    "error_type": "ECLI001"
    } now return structured JSON payloads on successful runs, including graph metadata/rendered output and diff summaries/serialized changes so the JSON contract is coherent on both success and failure paths.

  11. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Follow-up from PR #173 is in PR #185. This fixes {
    "ok": false,
    "command": "atomize",
    "diagnostics": [
    {
    "code": "EATOM002",
    "file": ".",
    "line": null,
    "col": null,
    "message": "Atomize failed for .: WindowsPath('.') has an empty name",
    "hint": "Check the output path and local filesystem permissions, then rerun nlsc atomize."
    }
    ],
    "file": "."
    } so default output-path derivation no longer raises an uncaught before diagnostics are emitted. The command now keeps that failure inside the handled atomize flow and returns a structured payload instead of a traceback, with focused regression coverage for both JSON and direct command error handling.

  12. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Superseding the previous shell-mangled comment.

    Follow-up from PR #173 is in PR #185. This fixes nlsc atomize . --json so default output-path derivation no longer raises an uncaught ValueError before diagnostics are emitted. The command now keeps that failure inside the handled atomize flow and returns a structured EATOM002 payload instead of a traceback, with focused regression coverage for both JSON and direct command error handling.

  13. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Implemented the parser-bootstrap JSON follow-up in 6def1e9 via #186. Added failing coverage for treesitter and , updated the bootstrap allowlist, and extended EPARSE002 explain coverage.

  14. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Follow-up note: this is specifically the parser-bootstrap JSON gap for treesitter init --json and assoc --json.

  15. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Implemented the remaining atomize parser-bootstrap JSON gap in commit ec49b36 and opened PR #187.\n\nCovered by CLI JSON/explain tests for plus emitted_by metadata alignment.

  16. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Implemented the remaining atomize parser-bootstrap JSON gap in commit ec49b36 and opened PR #187.

    Covered by CLI JSON/explain tests for --parser treesitter atomize --json plus EPARSE002 emitted_by metadata alignment.

  17. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Completed the compile/lock:update JSON and file-I/O slice in #188.

    • added stable EARTIFACT001 and ELOCK003 diagnost 8BD0 ics for compile/lock:update artifact and lockfile I/O failures
    • pinned exact --json success payloads for compile and lock:update
    • updated docs/error-reference.md and docs/cli-reference.md
    • ran targeted CLI JSON tests plus adjacent compile/lockfile regressions

    Commit: 97aabf7

  18. Mnehmos commented on Apr 3, 2026

    @Mnehmos
    OwnerAuthor

    Implemented the graph JSON artifact-write slice in commit adf9996.

    PR: #189

    Validation:

    • python -m pytest tests/test_cli_error_json.py -k "graph_json" -v
    • python -m pytest tests/test_cli_explain.py -k "artifact_io_failure_details or known_error_details" -v
    • python -m pytest tests/test_cli_error_json.py -k "artifact_write_failure or compiled_artifact_read_failure" -v
    • python -m pytest tests/test_cli_error_json.py tests/test_cli_explain.py -v
  19. Mnehmos commented on Sep 10, 2026

    @Mnehmos
    OwnerAuthor

    Audited against current master — all acceptance criteria are delivered:

    • --json on all commands emits structured diagnostics (code, file, line, col, message, hint) — including the new nlsc ir command and warnings-vs-failure separation (ok, diagnostics, warnings, scaffold fields from bug(semantics): reject executable prose and implicit placeholder returns #190/feat(semantics): resolve operation signatures and type-check calls, bindings, and returns #195).
    • nlsc explain <code> prints extended documentation (title, summary, emitted-by, common causes, next steps) and --json returns it structured; unknown codes get EEXPLAIN001.
    • Every error class is cataloged in nlsc/error_catalog.py — ECLI/EFILE/EPARSE/EUSE/E_RESOLUTION/ETEST/ECONTRACT/ETARGET/EVALIDATE/E_RUN/EEXEC/EGRAPH/ELOCK/ELSP/EASSOC/EWATCH plus the EIR001–004 and ESEM001–012 families, each with causes and next steps.
    • Context-aware recovery hints: dependency errors suggest the exact missing ANLU, field errors list available fields, stdlib errors suggest roots/--stdlib-path, strict-mode hints show the ELSE migration pattern.
    • Editor/LSP integration: nlsc lsp publishes structured LSP diagnostics (line, severity, source) on open/change.

    Closing as delivered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCommand line interfacedeveloper-experienceImproves developer workflowpriority-highImportant, address soon

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0