Repository navigation
feat(api): error envelope + validate-first atomicity (policy R1/R2/R4) - #247
Merged
Merged
Conversation
Implements docs/api-error-policy.md: errors are signal. - ToolError + stable codes; the request handler converts them into visible structured tool errors (isError + JSON envelope) — protocol errors are now reserved for genuine server faults (R1) - validate-first, all-or-nothing batches for create_entities, create_relations, add_observations, sequentialthinking (R2; fixes the mid-loop partial application in add_observations) - silent drops become errors (R4): missing relation endpoints (ENDPOINT_MISSING), all-missing open_nodes, unknown type, unknown get_neighbors/random_walk starts, invalid regex, kb_load file errors, unlinked thoughts - search NL-guard returns the same envelope (NO_MATCHES + suggestion) - tests: 13 protocol-error assertions converted to envelope checks; new policy block (atomicity proofs, envelope shape); fuzz now shows protoErr=0 with every rejection visible as toolErr - full suite 183/183 Co-Authored-By: Claude Code <noreply@anthropic.com>
Contributor
Per-op benchmark — p50 cycles (base vs head)base runs: 5, head runs: 5 (median of mins) · freq-correction ×1.0025 · threshold head−base > max(40 cyc, 5%)
* head frequency-corrected to base via the No regressions beyond threshold. |
Merged
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.
Implements the error half of
docs/api-error-policy.md(adopted 2026-10-08): the server no longer hides failures from the model.What changed
ToolError+ stable codes (ENTITY_NOT_FOUND,ENDPOINT_MISSING,COLLISION,LIMIT_EXCEEDED,INVALID_REGEX,INVALID_FILE,NO_MATCHES,TYPE_NOT_FOUND,VALIDATION_FAILED). The request handler converts them intoisError: truewith a JSON envelope{error: {tool, code, message, details}}. Protocol errors are now reserved for genuine server faults.create_entities(collisions were checked mid-write),create_relations,add_observations(validated inside the write loop → partial batches),sequentialthinking— all validate the whole request before touching state; failures list every offender in one round-trip.open_nodes, unknownget_entities_by_typetypes, unknownget_neighbors/random_walkstarts, invalid regex, kb_load file errors, unlinked thoughts. Duplicates and ensure-absent deletes keep succeeding (their ledgers arrive in the follow-up ledger PR).search_nodes's NL-guard now returns the same envelope shape (NO_MATCHES+suggestedRegexdetail).Evidence
parseToolErrorhelper in test-utils); newAPI error policytest block proves atomicity (failed batches leave nothing behind) and envelope shape.toolErr.🤖 Generated with Claude Code