Skip to content

fix(protocol): structured per-statement status - #154

Merged
jsam merged 4 commits into
mainfrom
fix/structured-statement-status
Oct 3, 2026
Merged

jsam merged 4 commits into
mainfrom
fix/structured-statement-status

Conversation

@jsam

@jsam jsam commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Failed statements were returned as OK message rows, so clients had to match message text to find failed writes.

  • QueryJob records each failed statement as {index, code, message} in errors. Later statements still run.
  • A one-statement program that fails gets an error frame with a code. A longer program gets a result with errors[].
  • Rule, session-rule, storage and query failures go through this path, including session-bound /ws rules and facts.
  • Index and .kg use errors are classified by cause.
  • Ontology remove and upgrade tolerate rules that are already gone.
  • is_error_message phrase matching is removed.
  • ontology-client soft_errors reads errors[] and falls back to exact-shape matching, with table-driven tests.
  • JS/Python SDK and GUI frame types model errors and code.

Tests: tests/statement_status_tests.rs (in-process and /ws) covers an oversized insert, a 2nd-statement failure, an invalid rule mid-program where the 3rd statement still applies, not_found and conflict codes, and ontology remove/upgrade with a missing rule.

Gates: fmt, clippy -D warnings (rustc 1.99), workspace tests (3420 passed), snapshot tests (1149 passed).

@jsam
jsam force-pushed the fix/remove-legacy-session-ws branch from 71ccfd0 to 9aecb06 Compare October 2, 2026 13:38
Base automatically changed from fix/remove-legacy-session-ws to main October 3, 2026 09:45
@jsam
jsam force-pushed the fix/structured-statement-status branch 2 times, most recently from 44ed835 to 1bd28b5 Compare October 3, 2026 10:53
jsam and others added 4 commits October 3, 2026 12:56
QueryJob records each failed statement as {index, code, message} in
QueryResult.errors instead of only a message row. A one-statement
program that fails is a WS error frame with a code; a longer program
returns a result whose errors[] names each failed statement, including
when the program ends in a query. Removes is_error_message phrase
matching; ontology commands and .kg drop cleanup read errors.
soft_errors returns the engine's errors[] when present. For engines
without it, message rows must match an exact success shape: the old
prefix allowlist accepted "Relation 'x' not found." and
"Rule 'x' not found." as success. Adds table-driven tests over every
engine message.
Rule, session-rule, storage and query failures no longer abort the
program: each is recorded in errors[] with a code and later statements
still run. Session-bound /ws rules and facts get code=validation, index
and .kg use errors are classified by cause, and ontology remove/upgrade
tolerate rules that are already gone. SDK and GUI frame types model
errors and code.
Rebased onto #152: map StorageError::InvalidName to Validation, and expect
invalid-name statements as structured statement errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jsam
jsam force-pushed the fix/structured-statement-status branch from 1bd28b5 to 2d998d0 Compare October 3, 2026 11:00
@jsam
jsam merged commit f1bc286 into main Oct 3, 2026
9 of 12 checks passed
@jsam
jsam deleted the fix/structured-statement-status branch October 3, 2026 11:00
jsam added a commit that referenced this pull request Oct 3, 2026
#156's rejection test predates #154, which reports statement failures in
QueryResult.errors instead of an Err.

Co-authored-by: Claude Opus 5.5 <[email protected]>
jsam added a commit that referenced this pull request Oct 3, 2026
* fix(protocol): report per-statement failures structurally

QueryJob records each failed statement as {index, code, message} in
QueryResult.errors instead of only a message row. A one-statement
program that fails is a WS error frame with a code; a longer program
returns a result whose errors[] names each failed statement, including
when the program ends in a query. Removes is_error_message phrase
matching; ontology commands and .kg drop cleanup read errors.

* fix(ontology-client): read structured statement errors in soft_errors

soft_errors returns the engine's errors[] when present. For engines
without it, message rows must match an exact success shape: the old
prefix allowlist accepted "Relation 'x' not found." and
"Rule 'x' not found." as success. Adds table-driven tests over every
engine message.

* fix(protocol): route every statement failure through statement status

Rule, session-rule, storage and query failures no longer abort the
program: each is recorded in errors[] with a code and later statements
still run. Session-bound /ws rules and facts get code=validation, index
and .kg use errors are classified by cause, and ontology remove/upgrade
tolerate rules that are already gone. SDK and GUI frame types model
errors and code.

* fix(protocol): adapt to the InvalidName storage error from #152

Rebased onto #152: map StorageError::InvalidName to Validation, and expect
invalid-name statements as structured statement errors.
jsam added a commit that referenced this pull request Oct 3, 2026
#156's rejection test predates #154, which reports statement failures in
QueryResult.errors instead of an Err.
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