Skip to content

fix(preprocess): start the first preprocess run instead of crashing on 404 - #71

Merged
SimoneBottoni merged 2 commits into
mainfrom
fix/preprocess-first-run
Jul 9, 2026
Merged

fix(preprocess): start the first preprocess run instead of crashing on 404#71
SimoneBottoni merged 2 commits into
mainfrom
fix/preprocess-first-run

Conversation

@aural-psynapse

@aural-psynapse aural-psynapse commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Why

run_preprocess() turns a freshly-ingested intercept table into the preprocessed form its collection needs before any query can run or be proven. It checks the current preprocess status first and only then starts a run.

The problem: a table that has never been preprocessed has no status record yet, so the status endpoint returns 404. That 404 raised straight out of the initial status check and crashed run_preprocess() before it ever called start_preprocess() — so the very first preprocess never happened.

Consequence: the collection stayed is_valid: false (invalid_reason: table_not_preprocessed), and every proof query against it failed — evaluate_handoff() returned ERROR with an empty per_claim. On a fresh setup, verification could never succeed.

Changes

  • In run_preprocess(), treat a 404 from the initial status check as "not started" and proceed to start the first preprocess run. Any non-404 error still propagates unchanged.

Verification

Reproduced against the live backend: on a never-preprocessed table, row-returning queries returned 500 while COUNT(*) succeeded, and the collection reported table_not_preprocessed. Running start_preprocess first flipped the collection to is_valid: true and the same row query resolved. With the fix, a full end-to-end run reaches PASS on an honest claim and CAUGHT on a tampered one.

…hen the table has no status record yet (404)
Comment thread src/sourcerykit/handoff/_preprocess.py Outdated
@SimoneBottoni
SimoneBottoni self-requested a review July 9, 2026 16:12
@SimoneBottoni
SimoneBottoni merged commit d4ecb83 into main Jul 9, 2026
3 checks passed
@SimoneBottoni
SimoneBottoni deleted the fix/preprocess-first-run branch July 13, 2026 09:53
aural-psynapse added a commit that referenced this pull request Jul 17, 2026
## Changes

**Docs**
- **AGENTS.md** — note it is the canonical agent entry point (mirrored
as the provably.ai machine view), and make explicit that claims must
come from the agent's own `SourceryKitAgentResponse` output, not be
hand-assembled.
- **docs/handoff.md** — add a `SourceryKitAgentResponse` section
describing the typed output and its `ClaimedValue` fields (`path`,
`value`, `sourcerykit_ref`), ordered type → component. Correct the
`claimed_value` payload row from `Any` to `list[ClaimedValue]`.
- **cookbooks/openai_agents** — accept `OPENROUTER_API_KEY` as well as
`MODEL_API_KEY`, so a verbatim copy authenticates against an
OpenAI-compatible gateway (OpenRouter).

**Code**
- **evaluate_handoff / build_handoff_payload** — when a claim can't be
resolved it was dropped with only a log line, so a payload that ended up
with zero claims surfaced as `ERROR` with an empty `errors` list. The
drop reason now travels on the payload (`build_errors`) and
`evaluate_handoff` returns it in `errors`, so a zero-claim result
explains itself.

## Why

These changes come out of a discoverability loop that runs a fresh agent
from provably.ai to a working SourceryKit integration and turns each
observed failure into one fix. Runs kept failing at the same points:
agents couldn't find the entry doc, hand-assembled claims instead of
binding `SourceryKitAgentResponse`, couldn't authenticate the cookbook
with the key they had, and hit an `ERROR` with no reason when claims
failed to resolve. Each item above addresses one of those. (The separate
preprocess bug that blocked verification end-to-end is fixed in #71.)

---------

Co-authored-by: SimoneBottoni <simone.bottoni94@gmail.com>
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