Repository navigation
feat: expose window_days on historical hunts - #332
Conversation
A historical hunt can now be bounded to the last 30, 60, 90 or 180 days. The new optional keyword goes into the POST body as an int; None drops the key, so a bare call sends what it always did and the server applies its own default (the platform maximum). The SDK does not validate the value: the server owns the enum and answers anything else with a 400, which surfaces as the usual typed exception. The sync mirror is regenerated from the async source. Co-Authored-By: Alan Justino <alan.justino@yahoo.com.br>
The server now returns the hunt's time window on the single GET and on the list. It is an additive .get() like the provenance fields: an int for a hunt created with a window, None for one created without (it reaches the platform maximum) or for a server that predates the field. HistoricalHuntList inherits the parse, so both endpoints are covered. Co-Authored-By: Alan Justino <alan.justino@yahoo.com.br>
Pure-unit tests cover the request shape (an int in the body, the key absent for None, no client-side validation) and the parse (int, explicit null, missing key). One respx body per client pair checks what historical_create sends and what the create, get and list responses carry; VCR cannot, because it does not match bodies and the recorded hunts predate the field. The live round trip needs a fresh e2e stack, so it is recorded as an open question rather than faked into the existing cassettes. Co-Authored-By: Alan Justino <alan.justino@yahoo.com.br>
The CLI client adopts `historical_create(window_days=)` in the paired change set and expresses that as `polyswarm_api>=4.8.0`. develop already declares 4.7.0 for a surface that does not include this keyword, so the floor needs the next version up; a floor cannot name a version this repo has not declared, so the bump lands here, in the feature PR (AGENTS.md's standing exception). Minor: one new optional keyword whose default preserves today's request, plus an additive resource field, so no existing call changes behaviour. Bumped with bump-my-version; the emitted string is a clean `4.8.0`. The server already accepts and returns `window_days`, so this repo can release ahead of the CLI. Co-Authored-By: Alan Justino <alan.justino@yahoo.com.br>
|
Code, codegen mirror, specs, and the 4.8.0 bump (clean Test tier: the live VCR lifecycle test is missing, and the reason given doesn't hold up. Action: add the live pair before merge. Create a hunt with |
A live pair, sync and async, creates one hunt with a 30-day window and one without, then reads both back on create, get and list: 30 and None. The cassettes were recorded against the e2e stack, and the pair also passes with VCR off. It replaces the respx stand-in that asserted fabricated envelopes, and closes the open question that tracked the gap. The builder, pass-through and parse tests stay: a cassette cannot see request bodies. Co-Authored-By: Alan Justino <alan.justino@yahoo.com.br>
Their recorded create, get and list responses predated window_days. Re-recorded by deleting each cassette and running its test against the e2e stack, so replay serves the shape the server returns today, the key included. Co-Authored-By: Alan Justino <alan.justino@yahoo.com.br>
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Alan Justino <alan.justino@yahoo.com.br>
|
Reviewed against AGENTS.md and specs/02, 03, 04 and 05. No issues found. It targets |
Findings (round 1)Adds an optional window_days to historical hunt creation and reads it back on get and list. Nothing blocking found. Part of a change across 3 PRs — merge #332 → polyswarm/polyswarm-cli#279 → polyswarm/portal#2577. Reviewed at d5502a7. Fixes are suggestions; nothing was run. |
mjbradford89
left a comment
There was a problem hiding this comment.
Nothing open from this review.
TL;DR
historical_create(..., window_days=None)on both clients: how many days back a historical hunt reaches (30, 60, 90 or 180). Omit it and the request is unchanged.HistoricalHunt.window_daysis parsed on the single GET and the list: an int, orNonefor a hunt created without a window.polyswarm_api>=4.8.0in its paired PR.Semantics
window_daysis a new optional trailing keyword. It rides the JSON body as an int;Noneleaves the key out, so a bare call sends exactly what it always did and the hunt reaches the platform maximum.HistoricalHunt.window_daysis an additive.get(), like the provenance fields.Nonemeans no window was requested, or a server that predates the field.window_days, so the release order (server, then this SDK, then the CLI) is satisfied.aio/api.py(canonical) with the regeneratedapi.pymirror,resources.py, and the endpoint, resource and testing specs.Version
4.7.0 -> 4.8.0, in its own commit, under the standing exception in
AGENTS.md: the CLI's CI installs this SDK from the same-named branch, and itspolyswarm_api>=floor cannot name a version this repo has not declared. It is a minor bump per the versioning table (a new optional keyword whose default preserves the current request, plus a new resource field). It was produced withbump-my-versionand checked:pyproject.toml(versionandcurrent_version) and__init__.pyall read a clean4.8.0, with no.devNor local suffix.Testing
pytest -s -v: 431 passed, which is the 410 ondevelopplus 21 new. Also 431 passed on Python 3.11.test-unasync-mirrorruns):scripts/regenerate_sync.py, thengit diff --exit-code -- src/polyswarm_api/is clean.test/historical_window_test.py:None, an out-of-enum value sent untouched;HistoricalHuntandHistoricalHuntList;ClientTestCase: the bodyhistorical_createsends (a bare call andwindow_days=Noneare byte-identical). This stays respx because VCR does not match request bodies.historical_create(window_days=60)reads back 60 on the create response,historical_getandhistorical_list; the async client'swindow_days=90reads back 90 on create and get.window_days=45is refused by the server with400 Failed schema validation: 45 is not one of [30, 60, 90, 180], raised asRequestException.test_historical_window_days(client_scan_test.py) andtest_async_historical_window_days(async_client_test.py) create one hunt withwindow_days=30and one without, read both back on create, get and list (30 andNone), then delete them. The cassettes were recorded against the e2e stack, and both tests also pass withTESTS_VCR=off.test_historical,test_list_historical,test_historical_resultsand their async twins), whose responses predatedwindow_daysand the provenance fields the SDK already parses. Each hunt in them now carrieswindow_days,rule_id,rule_modifiedandsource_rule_changed, allnullfor these unwindowed inline-rule hunts. They were re-recorded by deleting each cassette and running its test. All eight historical tests pass on replay and live.