fix(handoff): handle "proof already exists" 400 + expose preprocess_ms timing#40
Merged
Merged
Conversation
create_query_record_for_intercept always POSTs generate_proof and let a 400 raise. For a deterministic query (same SQL over the same rows) the backend hashes to an existing query record whose proof was already generated and returns 400 "proof already exists. Use verify endpoint instead." That aborted the call and dropped the query record, so the claim reached the evaluator with no query_record_id and verification failed — even though a valid proof existed. Use the non-raising post_raw and treat a 400 "already exists" as success: skip straight to wait_for_proof_completed (the proof is already there). All other failures still raise.
aural-psynapse
commented
Jun 11, 2026
aural-psynapse
commented
Jun 11, 2026
…ts + hard-error paths
…ng time to the SDK Times preprocess_after_intercept_write per intercept_context and exposes the cumulative ms via provably.preprocess_ms(), so a caller can separate SDK indexing time from the wrapped tool/HTTP call instead of lumping them together.
SimoneBottoni
approved these changes
Jun 12, 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.
Two SDK changes (bundled):
1. Treat "proof already exists" 400 as success. Asking the same question twice 400s with "proof already exists" — we treated that as an error and dropped the query record, so verification failed even though the proof was right there. Fix: on that 400, skip to waiting for the existing proof instead of failing.
2. Expose
provably.preprocess_ms(). Preprocess runs synchronously inside the intercepted call, so callers cannot tell SDK indexing time apart from the wrapped tool/HTTP time. This records preprocess duration perintercept_contextand exposes the cumulative ms, so a caller (e.g. a trace UI) can attribute indexing to the SDK rather than lumping it into the tool call.