Repository navigation
Conversation
The S2 /graph/v1/snippet/search endpoint accepts a fieldsOfStudy filter, but the asta CLI had no way to send it: snippet-search only exposed --fields, --limit, --date and --inserted-before, so a caller could ask for fieldsOfStudy as a returned paper field but could not restrict results by it. Unknown query parameters are ignored server-side, so there was also no error to hint at the gap. Add --fields-of-study to the command and a fields_of_study passthrough on SemanticScholarClient.snippet_search, document the vocabulary and matching behaviour in the semantic-scholar skill, and cover the flag in the papers CLI tests.
…tics
Extend the fieldsOfStudy filter to `asta papers search` so the two S2 search
surfaces the CLI exposes behave the same way. /graph/v1/paper/search honours
the filter server-side (a CS-filtered "protein folding" query drops total from
7.66M to 278k; a bogus value returns zero results), so the gap was the same
silent one snippet-search had.
Also correct a claim about matching: the filter keys on the classifier-derived
s2FieldsOfStudy, not on the externally-sourced fieldsOfStudy returned in
--fields. Probing shows CS-filtered results whose returned fieldsOfStudy is
["Medicine"] with "Computer Science" present only in s2FieldsOfStudy, and
bulk-search results with no external label at all. The previous note said a
paper carrying no field label would not match, which is wrong.
The vocabulary/matching notes now live in one "Filtering by field of study"
section that both commands link to, rather than duplicated per command.
The other S2 endpoints the client wraps (paper/{id}, citations, references,
author/search, author/{id}/papers) do not accept fieldsOfStudy, so there is
nothing to make consistent there. /paper/search/bulk does accept it but is not
wrapped by the client at all.
Suggested-by: @jbragg
🤖 Independent AI code review (Codex)Automated review of the PR by a separately invoked Codex reviewer. Prioritised P0/P1/P2; treat as advisory input for the human reviewer, not a merge gate. P0 (blocking)None. P1 (should fix)
P2 (nits)None. Recommendation: request-changes |
|
Resolved the AI review's sole finding in commit 9de4b01:
Validation: |
Completes the fieldsOfStudy consistency pass. /graph/v1/author/{id}/papers
does honour the filter server-side, contrary to what this PR previously
claimed: a bogus value returns zero rows, and "Medicine" narrows one author's
papers from 500 (the request cap) to 81 and another's from 219 to 12, with the
filtered set a strict subset for the author whose corpus fits under the cap.
The earlier probe that classed this endpoint as "not accepted" tested only
citations/references/author-search, which genuinely do ignore the parameter --
they return a result set identical to the unfiltered one, and identical to what
a made-up parameter name returns.
So add --fields-of-study to `asta papers author papers` and a fields_of_study
passthrough on get_author_papers.
Also correct the matching semantics the skill documents. The filter does not
key on the classifier labels alone. s2FieldsOfStudy carries entries from two
sources, source="s2-fos-model" and source="external", and a paper matches if
the requested field appears under either: every paper returned by a filtered
query carries the field somewhere in s2FieldsOfStudy (81/81 and 100/100 across
the two endpoints), whereas the classifier source alone accounts for only
28/81 and 87/100.
One endpoint-specific gotcha is worth documenting because it looks like a bug
in the filter: /author/{id}/papers omits the external-source entries from
s2FieldsOfStudy unless fieldsOfStudy is requested alongside it, so asking for
s2FieldsOfStudy on its own explains only 28 of the 81 matched papers. The
paper set itself is identical either way. /paper/search returns both sources
regardless.
Tests cover the flag reaching the client and defaulting to None.
Suggested-by: @jbragg
Update — third command added, and a correction to my own earlier claimsPushed 1.
Citations, references and author-search do genuinely ignore it — they return a result set identical to the unfiltered one and identical to what a made-up parameter name returns. The skill now documents that explicitly, so a reader doesn't hand-append the parameter there and assume it applied. 2. The documented match semantics were wrong. The previous revision said the filter "keys on the classifier-derived
Classifier-only would leave a third to seven-eighths of the returned papers unexplained; the union explains all of them. Worth knowing when you sanity-check this yourself: Prior review finding: the single P1 from the earlier Codex pass (snippet-search Validation: One caveat on process: an independent AI review of this latest diff could not be fired from the runtime this turn ran on, so the changes above have not had a second-model pass. Details are in the originating thread. Suggested-by: @jbragg |
Problem
The S2 graph API accepts a
fieldsOfStudyfilter on several endpoints, but theastaCLI had no way to send it.asta papers snippet-searchexposed only--fields,--limit,--dateand--inserted-before;asta papers searchexposed only--fields,--limitand--date;asta papers author papersexposed only--fieldsand--limit. The only mention of the name in the codebase was in the semantic-scholar skill's list of returned paper fields — i.e.fieldsOfStudyas data you can ask for, not as a filter you can apply.The gap was invisible from the outside: the API ignores unknown query parameters rather than rejecting them, so there was no error to hint that the filter wasn't reaching the endpoint.
Endpoint coverage — probed, not assumed
Because unknown parameters are silently ignored, the discriminating test for "does this endpoint support the filter" is a bogus value: an endpoint that parses the parameter must return zero results, while one that ignores it returns the unfiltered set. Comparing a real value against no filter is not sufficient — an ignored parameter and a non-restrictive one look identical.
fieldsOfStudy?search_papers/paper/searchtotal7,658,412 → 278,385 forComputer Science; bogus value →total0snippet_search/snippet/search{"data": []}at HTTP 200get_author_papers/author/{id}/papersMedicine→ 81 rows (of a 500 cap) for one author, 12 of 219 for anotherget_paper_citations/paper/{id}/citationsget_paper_references/paper/{id}/referencessearch_author/author/searchtotalget_paper/paper/{id}/paper/search/bulkdoes acceptfieldsOfStudy(bogus value →total0), but the client doesn't wrap that endpoint at all — exposing it would be a new command, not a consistency fix, so it's out of scope here.Correction to an earlier revision of this PR: its table listed
/author/{id}/papersas "not accepted". That was wrong — it rested on a probe that only covered citations/references/author-search. The endpoint does filter server-side, so the flag is now exposed there too, which is what makes the three search-shaped commands consistent.Change
--fields-of-studyonasta papers search,asta papers snippet-searchandasta papers author papers, passed through asfields_of_studyto the corresponding client method and serialized asfieldsOfStudy. Omitted from the request when unset, so existing behaviour is unchanged.citationsand assume it applied.tests/test_papers_cli.py: for each of the three commands, the flag reaches the client and defaults toNone.What the filter actually matches on
Two claims in earlier revisions of this PR were wrong; both are now corrected in the skill doc.
1. It is not classifier-only. An earlier revision said the filter "keys on the classifier-derived
s2FieldsOfStudy".s2FieldsOfStudyin fact carries entries from two sources —source: "s2-fos-model"(S2's classifier) andsource: "external"(publisher-supplied) — and a paper matches if the requested field appears under either:s2FieldsOfStudys2-fos-modelalone/author/{id}/papers,Medicine/paper/searchprotein folding,Computer ScienceThe union explains every returned paper; the classifier source alone explains a third to seven-eighths of them. The separate
fieldsOfStudyfield is only a narrower projection of the external labels — which is why a paper returned under--fields-of-study "Computer Science"can still come back showingfieldsOfStudy: ["Medicine"], and why a paper with no external label at all can match.2. A paper carrying no field label is still returned. The first revision claimed the opposite. A CS-filtered
/paper/search/bulkquery returns papers whose externalfieldsOfStudyisnull.One gotcha worth knowing
/author/{id}/papersomits thesource: "external"entries froms2FieldsOfStudyunlessfieldsOfStudyis requested alongside it. Ask fors2FieldsOfStudyon its own and only 28 of the 81Medicinematches appear to carry the label, which reads as a broken filter; ask for both and all 81 do. The returned paper set is identical either way — only the label payload changes./paper/searchreturns both sources regardless. The skill tells callers to request both fields on that command.Testing
uv run --extra test pytest tests/test_papers_cli.py— 43 passed.uvx ruff format --check .anduvx ruff check .clean;scripts/validate-skills.pyreports all 25 SKILL.md files valid. Beyond the mocked tests, the new flag was smoke-tested end-to-end through the real CLI against the live API (asta papers author papers 1751762 --fields-of-study "Medicine"returns exactly the 81 rows the raw endpoint probe predicted) — mocks alone can't catch the silently-ignored-parameter failure mode this PR is about.The full suite has 14 pre-existing failures in this sandbox (
tests/test_auth_helper.py,tests/test_auth_status_enhanced.py,tests/test_skills.py,tests/test_workspace_workflow.py) caused bymakeandnpxbeing absent from the environment, not by this change.Suggested-by: @jbragg