feat: XHR-hook captures + calibrate command - #16
Merged
Conversation
ADR-0024 v1.8.0 P2 + P3.
P2 — px-camoufox::capture_sensor:
- Spawns a fresh session, navigates to about:blank, injects a small
monkey-patch that wraps `JSON.stringify` (logging `[{t,d},…]` event
batches) and `XMLHttpRequest.prototype.send` (logging URL + body
for /b/s targets).
- Navigates to the target URL, waits, extracts captures back to Rust
as a `CaptureResult` (plaintext_events, xhr_sends, cookies, ua).
- Live test gated by `CAPTURE_PX=1` writes JSON to
`px-research/captures/eT15wiaE/<unix-ts>.json`.
P3 — px-native::events::calibrate + `px-cli calibrate`:
- `calibrate(observed, synthesised)` returns a `CalibrationReport`:
missing_tags, extra_tags, per_tag observed/synth/missing keys.
- New CLI subcommand: `px-cli calibrate <capture.json> [--json]`
prints a human-readable diff for operators.
- `SensorEvent` + `EventField` derive `Deserialize` so captures
round-trip back into the calibrator.
Operator workflow:
CAPTURE_PX=1 PX_PROXIES=... cargo test -p pxsolver-camoufox \
--test capture_sensor -- --ignored --nocapture
px-cli calibrate px-research/captures/eT15wiaE/<ts>.json
132 workspace tests pass; clippy clean; all files ≤200 LOC.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merged
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.
Summary
v1.8.0 P2 + P3 (ADR-0024). Gives the operator the tools to capture ground-truth sensor payloads from a real browser session and compare them against what
px-native::events::default_batchsynthesises today.What's new
P2 —
pxsolver-camoufox::capture_sensorcapture_sensor(config, proxy, url, wait_ms) -> CaptureResult:about:blankand injects a monkey-patch that hooksJSON.stringify(records[{t, d}, …]shapes) +XMLHttpRequest.prototype.send(records URL + body for/b/s).Live test:
Writes to
px-research/captures/eT15wiaE/<unix-ts>.json.P3 —
px-native::events::calibrate+px-cli calibratecalibrate(observed, synthesised) -> CalibrationReport(missing_tags, extra_tags, per_tag observed/synth/missing keys).px-cli calibrate <capture.json>prints the diff:--jsonflag for machine consumption.Tests
calibrateunit tests, smoke test ofpx-cli calibrateagainst a synthetic fixture.cargo clippy --workspace --all-targets --all-features -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::panicclean.What this still doesn't prove
P4 is the live throughput test against a real PX-fronted target. That requires the operator to:
CAPTURE_PX=1test through a working AR residential proxy.px-cli calibrateagainst the resulting JSON to see whichdefault_batchfields lie.default_batchuntil missing/extra tags converge.PX_NATIVE_PROFILES(added in feat(server): wire SensorNativeSolver into solve dispatcher #15) and measure/v1/solvethroughput.🤖 Generated with Claude Code