Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
canonical `{}`-placeholder template form so the registry↔doc sync test can
compare them byte-for-byte; the concrete example now lives in each entry's
prose instead.
- **Query executor errors now carry real `QRY-00N` codes** (#361, part of
#277) instead of the generic `INT-000` fallback: `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 — the full QRY
category (9 of 9 documented codes; see `docs/ERROR_REFERENCE.md`). Anything
that was matching on `MinigrafError::code() == "INT-000"` for one of these
conditions now sees the specific code instead. `QRY-001`/`004`/`005`/`006`'s
`ERROR_REFERENCE.md` "Error text" entries were also rewritten from a
concrete example (e.g. `` `Invalid entity: "not-a-uuid"` ``) to the
canonical `{}`-placeholder template form (`` `Invalid entity: {}` ``) they
share with `REGISTRY`, per the design spec's migration convention; the
worked example moved to each entry's "Example" section, unchanged.
`QRY-001`..`006` (the transact/retract validation codes) are wired into
`DatalogExecutor::execute_transact`/`execute_retract`, but that code 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 raise their own
uncoded (still `INT-000`) errors, two of which — "attribute must be a
keyword" and "cannot transact a pseudo-attribute" — are already earmarked
as `API-003`/`API-004` for the API+INT category PR (#277 step 6).
- **The core binary size budget is raised from 1MB to ~1.2MB** (`binary-size.yml`'s
`SIZE_LIMIT_BYTES`, and PHILOSOPHY.md §4's stated target), toward #277.
The project was already at the 1MB wire before #277 started (measured
Expand Down
10 changes: 5 additions & 5 deletions docs/ERROR_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ predicate evaluation, or fact transacting.

### QRY-001 Invalid entity

**Error text**: `Invalid entity: "not-a-uuid"`
**Error text**: `Invalid entity: {}`

**Cause**: An entity ID in a `transact` fact could not be resolved. Entity IDs must be UUIDs (as `#uuid "..."` tagged literals), existing entity symbols, or values that can be resolved to a UUID at execution time.

Expand Down Expand Up @@ -1525,7 +1525,7 @@ predicate evaluation, or fact transacting.

### QRY-004 Invalid value

**Error text**: `Invalid value: [1, 2, 3]`
**Error text**: `Invalid value: {}`

**Cause**: A value in a fact is of a type that Minigraf cannot store. Supported value types are: string, integer (i64), float (f64), boolean, UUID ref (`Value::Ref`), and keyword.

Expand All @@ -1541,7 +1541,7 @@ predicate evaluation, or fact transacting.

### QRY-005 Transaction failed

**Error text**: `Transaction failed: write lock is poisoned`
**Error text**: `Transaction failed: {}`

**Cause**: The batch of facts could not be committed. This is a wrapper error — the nested reason message identifies the root cause, which is typically a storage error, lock poisoning, or WAL write failure.

Expand All @@ -1554,7 +1554,7 @@ predicate evaluation, or fact transacting.

### QRY-006 Retraction failed

**Error text**: `Retraction failed: fact not found`
**Error text**: `Retraction failed: {}`

**Cause**: A retraction could not be applied. The nested reason message identifies the specific cause — the fact may not exist at the given transaction time, or a storage error occurred.

Expand All @@ -1567,7 +1567,7 @@ predicate evaluation, or fact transacting.

### QRY-007 Unknown predicate

**Error text**: `unknown predicate: 'between?'`
**Error text**: `unknown predicate: '{}'`

**Cause**: A `:where` clause invoked a predicate (expression function) that is not built-in and has not been registered via `db.register_predicate()`.

Expand Down
72 changes: 72 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ pub enum ErrorCategory {
/// downstream `match`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum ErrorCode {
Qry001,
Qry002,
Qry003,
Qry004,
Qry005,
Qry006,
Qry007,
Qry008,
Qry009,
Int000,
Wal001,
Wal002,
Expand All @@ -50,6 +59,60 @@ pub(crate) enum ErrorCode {
/// "Error text" lines by the sync test in this module (added once real
/// codes exist in a follow-up category PR — see the design spec).
pub(crate) const REGISTRY: &[(ErrorCode, &str, &str, ErrorCategory)] = &[
(
ErrorCode::Qry001,
"QRY-001",
"Invalid entity: {}",
ErrorCategory::Query,
),
(
ErrorCode::Qry002,
"QRY-002",
"Attribute must be a keyword",
ErrorCategory::Query,
),
(
ErrorCode::Qry003,
"QRY-003",
"Cannot transact a pseudo-attribute",
ErrorCategory::Query,
),
(
ErrorCode::Qry004,
"QRY-004",
"Invalid value: {}",
ErrorCategory::Query,
),
(
ErrorCode::Qry005,
"QRY-005",
"Transaction failed: {}",
ErrorCategory::Query,
),
(
ErrorCode::Qry006,
"QRY-006",
"Retraction failed: {}",
ErrorCategory::Query,
),
(
ErrorCode::Qry007,
"QRY-007",
"unknown predicate: '{}'",
ErrorCategory::Query,
),
(
ErrorCode::Qry008,
"QRY-008",
"functions lock poisoned",
ErrorCategory::Query,
),
(
ErrorCode::Qry009,
"QRY-009",
"rules lock poisoned",
ErrorCategory::Query,
),
(
ErrorCode::Int000,
"INT-000",
Expand Down Expand Up @@ -336,6 +399,15 @@ mod tests {
}

match ErrorCode::Int000 {
ErrorCode::Qry001 => assert_has_registry_entry(ErrorCode::Qry001),
ErrorCode::Qry002 => assert_has_registry_entry(ErrorCode::Qry002),
ErrorCode::Qry003 => assert_has_registry_entry(ErrorCode::Qry003),
ErrorCode::Qry004 => assert_has_registry_entry(ErrorCode::Qry004),
ErrorCode::Qry005 => assert_has_registry_entry(ErrorCode::Qry005),
ErrorCode::Qry006 => assert_has_registry_entry(ErrorCode::Qry006),
ErrorCode::Qry007 => assert_has_registry_entry(ErrorCode::Qry007),
ErrorCode::Qry008 => assert_has_registry_entry(ErrorCode::Qry008),
ErrorCode::Qry009 => assert_has_registry_entry(ErrorCode::Qry009),
ErrorCode::Int000 => assert_has_registry_entry(ErrorCode::Int000),
ErrorCode::Wal001 => assert_has_registry_entry(ErrorCode::Wal001),
ErrorCode::Wal002 => assert_has_registry_entry(ErrorCode::Wal002),
Expand Down
Loading
Loading