fix: extract --json always carries the extraction inline - #190
Open
yzld2002 wants to merge 1 commit into
Open
Conversation
The documented contract is that `ade extract --json` puts the whole result on stdout: the payload's `extraction` key is the schema-shaped result itself, not a pointer to `<store_dir>/extract.json`. Reported (#189) as a fresh-vs-cached shape divergence, with downstream tooling breaking one step later on a payload with no `extraction` key. Both paths already go through one `emit_summary`, and the payload's keys are identical on a fresh completion and a cached hit — checked across every input form (parse item, `extract -d` reuse, `extract -d` parse-first, `--markdown`, `--markdown-url`) and a forced re-extract. The new parity tests pin that, so no refactor can split the two paths again; the only key that legitimately differs is the parse provenance of the invocation (`parsed_first` on a fresh `extract -d` that had to parse, `reused_parse` on its re-run). The one way a successful run could still reach stdout with no result in it was a completed body whose `result` carried no `extraction`: the summary read it with `.get`, so the run reported `status: extracted`, billed, wrote an `extract.json` with no result in it, and printed `extraction: null`. That now fails whole in the consume-before-write block, the same posture as any other unreadable completion — the ticket is marked unreadable with the reason and no artifact is written. `ade help extract --json` now says outright that `extraction` is inline on every successful run, cached hits included. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #189
What I found
The two paths are not separate code: fresh completions and cached hits both
render through the single
emit_summaryinextract.py, andextractionisbuilt unconditionally from the same dict on both — the response
resulton afresh run, the byte-identical
extract.jsonon a cached one. Driving bothpaths through the CLI seam across every input form (parse item,
extract -dreuse,
extract -dparse-first,--markdown,--markdown-url) and a forcedre-extract, the payloads come out key-for-key and value-for-value identical
apart from
cached, withextractioninline in each. The reported summaryshape does not reproduce, and no version of this repo can produce it: the key
has been unconditional since the first commit, on every branch and every tag,
so there is no maintainer evidence of an intentional summary shape to
document — the contract stands as written.
What was actually broken
There was one way a successful run could reach stdout with no result in it: a
completed body whose
resultcarried noextraction. The summary read itwith
.get, so the run reportedstatus: extracted, billed, wrote anextract.jsonwith no result in it, and printedextraction: null— silentlyhanding a consumer a payload it cannot read, which is the failure the issue
describes from the consumer's side.
That now fails whole in the consume-before-write block, next to the existing
extraction_metadataand markdown-echo guards:unsupported_result_schema,the ticket marked
unreadablewith the reason, no artifact written, and are-run that re-polls the same job instead of re-billing.
Changes
extract.py: a completed result with no usableextraction(key missing,or not an object/array) is rejected before any write, instead of reporting
a billed success with
extraction: null.tests/test_extract.py: parity tests pinning fresh ≡ cached payload shapeacross the input forms and a forced re-extract, plus the regression test
for the guard (fails on
main, both parametrisations).help.py+docs/reference/help.json:ade help extract --jsonnow saysoutright that
extractionis inline on every successful run, cached hitsincluded.
Notes
ruffandtyclean.extract.jsonhas noextraction(writtenbefore this guard) still serve
extraction: nullon a cached hit. Nothingcan create one from here, so I left the store read alone rather than have a
cached hit re-bill.
creditsisdocumented as "0 on a cached hit", but both
parseandextractreport theoriginal bill on a cached hit. Left alone here.
🤖 Generated with Claude Code