Repository navigation
feat: structured error codes — QRY-0xx query executor codes (#361, 5/6) - #364
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks done
adityamukho
added a commit
that referenced
this pull request
Aug 25, 2026
adityamukho
added a commit
that referenced
this pull request
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tobail_coded!/err_coded!with their realQRY-0xxcodes.QRY-0xxcodes (docs/ERROR_REFERENCE.md) intosrc/query/datalog/executor.rsandsrc/query/datalog/evaluator.rs:QRY-001Invalid entityQRY-002Attribute must be a keywordQRY-003Cannot transact a pseudo-attributeQRY-004Invalid valueQRY-005Transaction failedQRY-006Retraction failedQRY-007Unknown predicateQRY-008Functions lock poisonedQRY-009Rules lock poisonedoptimizer.rs,matcher.rs, andmagic_sets.rshave zerobail!/anyhow!call sites, so they are unchanged.QRY-001/004/005/006'sERROR_REFERENCE.md"Error text" entries are rewritten from a concrete example to the canonical{}-placeholder template form shared withREGISTRY, per the design spec's migration convention (the worked example moves to each entry's "Example" section, unchanged).CHANGELOG.mdupdated 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 intoDatalogExecutor::execute_transact/execute_retract, but that path is not reachable throughMinigraf::execute()today: the public write path routestransact/retractthroughMinigraf::materialize_transaction/materialize_retraction(src/db.rs) instead, for WAL-first-ordering reasons, and never calls thoseDatalogExecutormethods.db.rs's own near-duplicate messages there are already earmarked asAPI-003/API-004inERROR_REFERENCE.mdfor the API+INT category PR (#277 step 6, out of scope here);QRY-001/004/005/006currently have nodb.rs-side equivalent at all.Given that, regression tests for
QRY-001..006and theQRY-008/009lock-poisoning paths constructDatalogExecutor/RecursiveEvaluator/StratifiedEvaluatordirectly — the same convention this file already uses ("Stream 3: branc 8000 hes unreachable via the parser") for exactly this situation.QRY-007and the rules-path variants ofQRY-008/009are additionally covered by public-API integration tests in the newtests/error_codes_qry_test.rs.That file also locks in current
INT-000behavior (with a documented rationale) for two error families that live in this issue's in-scope files but have no documented QRY code:evaluator.rs("Max iterations exceeded", etc.) — a real, live, public-API-reachable path with no matching QRY code today.sumover a string attribute) — which actually originates insrc/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 buildcargo test— 732 unit tests + all integration/doc tests green, 0 failurescargo clippy --all-features -- -D warnings— cleancargo fmt --check— cleanQRY-00Ncode viaMinigrafError::code()for all 9 codes🤖 Generated with Claude Code
https://claude.ai/code/session_01P7e4uTBWtM8fMZiPZc4bCw