error-system #13

Merged
navicore merged 2 commits from error-system into main 2026-05-21 18:53:40 +00:00
Owner
No description provided.
● All 11 tasks complete. Summary of what shipped:

  Error System Implementation — Complete

  Tests: 320 total (147 unit + 173 integration), up from 290. All green.

  What's New

  ISO error vocabulary (crates/patch-prolog-core/src/error.rs):
  - PrologError enum with all 9 ISO formal-error constructors
  - ThrownError propagation type with uncatchable flag
  - format_term public helper for rendering ISO error terms as strings

  Catch/throw:
  - throw/1 — raises a term that propagates through the solver
  - catch/3 — pushes a catch-barrier choice point; dispatch_or_return walks the choice stack on errors, unwinds to
   a matching catcher, runs recovery
  - Cut is opaque to catch — ! inside catch's goal can't destroy the catch frame

  Dynamic predicate directive:
  - :- dynamic(F/A). (single or comma-list) parsed into ProgramDirectives
  - CompiledDatabase carries the dynamic set, serialized via bincode
  - Undefined non-dynamic predicates throw existence_error(procedure, F/A); dynamic ones fail silently (linter
  contract preserved)

  Architectural cleanup:
  - SolveResult::Error(String) → Error(Term)
  - try_solve_once / try_solve_collecting now return Result<bool, ThrownError>
  - try_exec_misc returns Result<Option<bool>, ThrownError>
  - steps_exceeded side-channel flag eliminated — step limit flows through ThrownError { uncatchable: true }
  - All ~60 built-in error sites in solver.rs and builtins.rs migrated from String to structured PrologError

  Safety:
  - Step limit (resource_error(steps)) is uncatchable
  - CLI renders error terms via format_term for both JSON and text output

  Files Changed

  - New: crates/patch-prolog-core/src/error.rs
  - Updated: parser.rs (directive parsing), database.rs (dynamic set + indexing helper), solver.rs (Result
  refactor, catch/throw), builtins.rs (PrologError-typed errors, throw/catch dispatch), lib.rs (exports)
  - CLI template (src/compiler.rs): error rendering via format_term
  - knowledge/rules.pl: added :- dynamic(field/1).
  - Docs: ARCHITECTURE.md, ROADMAP.md, README.md, docs/design/{SOLVER,SAFETY,ISO_COMPLIANCE,ERROR_SYSTEM}.md
  - Tests: 16 new throw/catch/error-shape tests in tests/integration.rs, plus updates to existing tests for the
  new undefined-predicate semantics
● CI setup complete. Summary:
All checks were successful
CI - Linux / CI - Linux x86_64 (pull_request) Successful in 22s
41ebaa0695
CI Setup — Done

  Files added:
  - justfile — single source of truth for build/test/lint
  - rust-toolchain.toml — pins local toolchain to 1.95.0 (matches CI)
  - .forgejo/workflows/ci-linux.yml — Forgejo workflow that calls just ci

  just recipes:
  - fmt, fmt-check, lint (-D warnings), test, build (all --locked)
  - install — cargo install --path . --locked --force
  - clean, stats (scc + cargo-modules with graceful fallback)
  - ci — chains fmt-check lint test build, prints a success banner

  Forgejo workflow (modeled on ../patch-seq/.forgejo/workflows/ci-linux.yml):
  - Triggers on PR to main and workflow_dispatch
  - Runs on navicore-rust (your custom runner with Rust 1.95.0 + just pre-installed)
  - Caches ~/.cargo/registry and ~/.cargo/git; does not cache target/
  - Single step: just ci
  - No SARIF/CodeQL upload (Forgejo-incompatible)

  Toolchain invariant: rust-toolchain.toml channel 1.95.0 matches the runner image. They agree.

  Cleanup done (since -D warnings surfaced ~11 pre-existing clippy issues):
  - 4× len() >= 1 → !is_empty() (builtins.rs, solver.rs tests)
  - 4× 3.14 test literals → 2.5 (no PI approx warning)
  - 1× or_insert_with(Vec::new) → or_default() (index.rs)
  - 1× doc list indentation (solver.rs)
  - 1× #[allow(clippy::should_implement_trait)] on Solver::next with a one-line comment explaining the naming
  choice

  Verified: just ci runs locally end-to-end — fmt-check ✓, clippy (warnings as errors) ✓, all 320 tests ✓, release
   build ✓.
Sign in to join this conversation.
No description provided.