Skip to content

fix(handoff): handle "proof already exists" 400 + expose preprocess_ms timing#40

Merged
SimoneBottoni merged 4 commits into
mainfrom
fix/proof-already-exists-verify
Jun 12, 2026
Merged

fix(handoff): handle "proof already exists" 400 + expose preprocess_ms timing#40
SimoneBottoni merged 4 commits into
mainfrom
fix/proof-already-exists-verify

Conversation

@aural-psynapse

@aural-psynapse aural-psynapse commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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 per intercept_context and 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.

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.
Comment thread src/provably/handoff/_query_records.py Outdated
Comment thread src/provably/handoff/_query_records.py Outdated
…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.
@aural-psynapse aural-psynapse changed the title fix(handoff): treat "proof already exists" 400 as success, not failure fix(handoff): handle "proof already exists" 400 + expose preprocess_ms timing Jun 11, 2026
@SimoneBottoni SimoneBottoni merged commit f9c925c into main Jun 12, 2026
4 checks passed
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.

2 participants