8000 feat: structured error codes — QRY-0xx query executor codes (#361, 5/6) by adityamukho · Pull Request #364 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

feat: structured error codes — QRY-0xx query executor codes (#361, 5/6) - #364

Merged
adityamukho merged 3 commits into
mainfrom
error-codes-277-qry
Aug 25, 2026
Merged

adityamukho merged 3 commits into
mainfrom
error-codes-277-qry

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Summary

Part of #277 (structured runtime error codes, umbrella issue). This is step 5 of the 6-PR rollout, covering issue #361: migrate the query executor's bail!/anyhow! call sites to bail_coded!/err_coded! with their real QRY-0xx codes.

  • Migrates all 9 documented QRY-0xx codes (docs/ERROR_REFERENCE.md) into src/query/datalog/executor.rs and src/query/datalog/evaluator.rs:
    • QRY-001 Invalid entity
    • QRY-002 Attribute must be a keyword
    • QRY-003 Cannot transact a pseudo-attribute
    • QRY-004 Invalid value
    • QRY-005 Transaction failed
    • QRY-006 Retraction failed
    • QRY-007 Unknown predicate
    • QRY-008 Functions lock poisoned
    • QRY-009 Rules lock poisoned
  • optimizer.rs, matcher.rs, and magic_sets.rs have zero bail!/anyhow! call sites, so they are unchanged.
  • QRY-001/004/005/006's ERROR_REFERENCE.md "Error text" entries are rewritten from a concrete example to the canonical {}-placeholder template form shared with REGISTRY, per the design spec's migration convention (the worked example moves to each entry's "Example" section, unchanged).
  • CHANGELOG.md updated with a QRY-specific breaking-ish-change bullet under the existing post-1.0: add structured error codes to runtime output #277 foundation entry.

Important finding (documented in code + CHANGELOG)

QRY-001..006 (transact/retract validation) are wired into DatalogExecutor::execute_transact/execute_retract, but that path is not reachable through Minigraf::execute() today: the public write path routes transact/retract through Minigraf::materialize_transaction/materialize_retraction (src/db.rs) instead, for WAL-first-ordering reasons, and never calls those DatalogExecutor methods. db.rs's own near-duplicate messages there are already earmarked as API-003/API-004 in ERROR_REFERENCE.md for the API+INT category PR (#277 step 6, out of scope here); QRY-001/004/005/006 currently have no db.rs-side equivalent at all.

Given that, regression tests for QRY-001..006 and the QRY-008/009 lock-poisoning paths construct DatalogExecutor/RecursiveEvaluator/StratifiedEvaluator directly — the same convention this file already uses ("Stream 3: branc 8000 hes unreachable via the parser") for exactly this situation. QRY-007 and the rules-path variants of QRY-008/009 are additionally covered by public-API integration tests in the new tests/error_codes_qry_test.rs.

That file also locks in current INT-000 behavior (with a documented rationale) for two error families that live in this issue's in-scope files but have no documented QRY code:

  • The recursive-rule iteration/derived-facts/results limit family in evaluator.rs ("Max iterations exceeded", etc.) — a real, live, public-API-reachable path with no matching QRY code today.
  • The runtime aggregate type-mismatch family (e.g. sum over a string attribute) — which actually originates in src/query/datalog/functions.rs, not one of this issue's five in-scope files, so intentionally left unmigrated here.

Both are flagged as candidate follow-up work for the API+INT category PR (#277 step 6), which audits every leftover uncoded call site crate-wide.

Test plan

  • cargo build
  • cargo test — 732 unit tests + all integration/doc tests green, 0 failures
  • cargo clippy --all-features -- -D warnings — clean
  • cargo fmt --check — clean
  • New/extended regression tests assert the exact QRY-00N code via MinigrafError::code() for all 9 codes
  • Pre-push hook (fmt + clippy + test) passed on push

🤖 Generated with Claude Code

https://claude.ai/code/session_01P7e4uTBWtM8fMZiPZc4bCw

Migrates all 9 documented QRY-0xx codes (part of #277) into
src/query/datalog/executor.rs and evaluator.rs's bail!/anyhow! call sites via
bail_coded!/err_coded!: QRY-001 invalid entity, QRY-002 attribute must be a
keyword, QRY-003 cannot transact a pseudo-attribute, QRY-004 invalid value,
QRY-005 transaction failed, QRY-006 retraction failed, QRY-007 unknown
predicate, QRY-008 functions lock poisoned, QRY-009 rules lock poisoned.
optimizer.rs/matcher.rs/magic_sets.rs have no bail!/anyhow! call sites, so
they are unchanged.

QRY-001/004/005/006's ERROR_REFERENCE.md "Error text" entries are rewritten
from a concrete example to the canonical {}-placeholder template form shared
with REGISTRY, per the design spec's migration convention.

QRY-001..006 (transact/retract validation) are wired into
DatalogExecutor::execute_transact/execute_retract, but that path is not
reachable through Minigraf::execute() today: the public write path routes
transact/retract through Minigraf::materialize_transaction/
materialize_retraction (src/db.rs) instead, which is out of this issue's
scope (already earmarked as API-003/API-004 for the API+INT category PR,
#277 step 6). Regression tests for QRY-001..006 and the QRY-008/QRY-009
lock-poisoning paths therefore construct DatalogExecutor/RecursiveEvaluator/
StratifiedEvaluator directly, matching this file's existing convention for
branches unreachable via the public API. QRY-007 and the rules-path variants
of QRY-008/009 are additionally covered by public-API integration tests.

Also adds regression tests locking in current INT-000 behavior for two
error families that live in-scope but have no documented QRY code: the
recursive-rule iteration/derived-facts/results limit family in evaluator.rs,
and the runtime aggregate type-mismatch family (which actually originates in
src/query/datalog/functions.rs, not one of this issue's five in-scope
files, so left unmigrated here).

Part of #277 (umbrella; not closed by this commit). Closes #361.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P7e4uTBWtM8fMZiPZc4bCw
@codecov
codecov Bot commented Aug 25, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 2c7f670 into main Aug 25, 2026
16 checks passed
@adityamukho
adityamukho deleted the error-codes-277-qry branch August 25, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0