Repository navigation
fix(qsearch): Python lifecycle client parity with wire contract v1 (26 → 0 discrepancies) - #102
Merged
Merged
Conversation
LifecycleClient now parses success and error bodies with the section 2.1 rules of protocol/qsearch-lifecycle/v1: bytes are decoded strictly as UTF-8 before json.loads (a BOM, UTF-16 or UTF-32 body and encoded surrogates are refused), every number must have magnitude <= 2^53-1 and nesting is limited to 64 containers with the top-level value counted as 1. Refusals are INVALID_RESPONSE / MANUAL_RECONCILIATION with http_status set, including for non-2xx bodies. Injected text and decoded mappings pass the same rules. Flips six recorded xfails (encoding_utf8_bom, encoding_utf16_le, encoding_utf32_be, unsafe_integer, error_body_unsafe_integer, error_body_depth_exceeds_64); fixtures and SHA256SUMS regenerated and CONTRACT.md section 4 updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lient After the existing schema-id, digest-binding and next_action checks, every 2xx lifecycle body (status, cancel, refresh, replace) must now satisfy protocol/qsearch-lifecycle/v1/job-state.v1.schema.json in full: closed objects with exact member sets, member types, enums, patterns (fullmatch, so no trailing newline), nullability, amounts as finite non-bool numbers in 0..2^53-1, booleans strictly bool, and invariants I1-I8. The validator is a private stdlib module (nano_qsearch/_job_state_v1.py); the runtime stays free of jsonschema. Tests: a differential test compares client accept/reject with jsonschema over every single-member mutation of the 15 golden histories and I1-I8 cross-products (~47k distinct payloads); a seeded fuzz drives lifecycle.job_state over 4000 random records/receipts/clocks and asserts the client accepts every projected envelope. Flips the remaining 20 recorded xfails; fixtures and SHA256SUMS regenerated, CONTRACT.md section 4 now lists no Python discrepancies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Independent review (no CRITICAL/HIGH) follow-ups, each reproduced by a failing test first: - A decoded mapping from an injected transport is canonicalised and parsed on the strict byte path, so nested Mapping types are normalised instead of refused (regression vs the documented 'decoded mapping' transport). - A str body is capped by its UTF-8 byte length, not characters. - The job-state validator no longer raises OverflowError on huge ints. - Client errors are re-raised with no __context__/__cause__ chain and a fresh traceback: 'raise ... from None' only hid the chain, while __context__ (a JSONDecodeError whose .doc is the full body) and frame locals stayed reachable from the public error. - Validator refuses a trailing newline in all six patterned fields. - CONTRACT section 4 wording and the documented jsonschema exclusions. Refs #86 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
The Python
LifecycleClientaccepted responses that wire contract v1 (#86) requires clients to refuse. The gaps were recorded as 26 strict-xfail compatibility tests, and this closes all of them, so Python and the TypeScript client (#93) now accept and reject the same bytes. The change only makes the client refuse more. Fuzzing and a differential test show it still accepts every envelope the real server can produce. Follow-up to #86.Key Changes
job-state.v1.schema.json(members, types, enums, patterns, nullability, invariants I1–I8) on every 2xx.__context__and no frame locals that could expose the response body, URL or transport error.Verification
aether_atlas).job_state()outputs were all accepted.regen.py --checkpasses.Risk / Follow-ups
INVALID_RESPONSE. The default HTTP transport is unaffected for any real server output.🤖 Generated with Claude Code