Skip to content

test(proxy): add property tests for response payload invariants - #1699

Open
iqbalmaulana03 wants to merge 2 commits into
Soju06:mainfrom
iqbalmaulana03:test/hypothesis-pure-functions
Open

test(proxy): add property tests for response payload invariants#1699
iqbalmaulana03 wants to merge 2 commits into
Soju06:mainfrom
iqbalmaulana03:test/hypothesis-pure-functions

Conversation

@iqbalmaulana03

Copy link
Copy Markdown
Contributor

Summary

Add dev-only Hypothesis property tests for Responses payload sanitization and compact trimming, SSE framing, and historical response.create payload slimming. This implements the maintainer-recommended first, pure-function slice of #1595 without adding lifecycle simulation infrastructure or changing production behavior.

Type of change

  • fix: — bug fix (no behavior change beyond the bug)
  • feat: — new user-facing feature or capability
  • refactor: — internal refactor (no behavior change, no API change)
  • docs: — documentation only
  • chore: / ci: / build: — tooling, CI, packaging
  • test: — test-only change
  • Breaking change

Linked issue: Refs #1595

OpenSpec

  • This PR includes / updates an OpenSpec change
  • Not applicable — test-only/dev-tool change exempt under CONTRIBUTING; no observable behavior, requirement, contract, or schema changes
  • This PR touches codex-faithful request/response and SSE paths only through tests and preserves upstream-equivalent behavior

Change directory: N/A

Changes

  • Add bounded reusable Hypothesis strategies for arbitrary JSON values, arrays, and objects.
  • Property-test request input sanitization, unsupported-field stripping, compact token budgets, marker accounting, state anchors, and tool-call pairing.
  • Property-test SSE JSON round trips, CR/LF/CRLF boundaries, Unicode line separators, multiline data, and non-object rejection.
  • Property-test historical response.create slimming while preserving the recent suffix, top-level fields, file references, and caller payload immutability.
  • Keep Hypothesis in the development dependency group only.

Test plan

uv run pytest tests/unit/test_openai_requests.py tests/unit/test_sse.py tests/unit/test_proxy_utils.py -q
# 1188 passed

uv run ty check
# All checks passed

uv run ruff check tests/unit/test_openai_requests.py tests/unit/test_sse.py tests/unit/test_proxy_utils.py tests/unit/hypothesis_strategies.py
# All checks passed

uv run ruff format --check tests/unit/test_openai_requests.py tests/unit/test_sse.py tests/unit/test_proxy_utils.py tests/unit/hypothesis_strategies.py
# 4 files already formatted

make test-unit
# 5766 passed, 70 skipped

npx --yes @fission-ai/openspec@1.8.0 validate --specs
# 49 passed, 0 failed

Screenshots / output

Not applicable; this is a test-only change with no user-visible surface.

Checklist

  • Title is in Conventional Commits format (<type>(<scope>)?: <subject>).
  • Linked the related issue above.
  • Added or updated tests covering the change.
  • Ran the relevant make test-unit target and focused lint/type/test checks locally.
  • OpenSpec is not modified; main specs validate successfully.
  • Simplicity gates reviewed: no setting, default, README section, .env.example entry, or dashboard surface is added.
  • CHANGELOG is not edited by hand.

@iqbalmaulana03
iqbalmaulana03 requested a review from Soju06 as a code owner August 11, 2026 14:52
@Soju06

Soju06 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

@codex review

Thanks — this lands exactly the pure-function slice I suggested in #1595. I've re-run the hung Docker build job (the CI Required failure was infra, not your change). Three small asks while codex runs:

  1. The four @given tests without @settings in tests/unit/test_openai_requests.py inherit Hypothesis's default 200 ms deadline, which can flake on loaded CI runners — please add @settings(deadline=None) like the others.
  2. Add .hypothesis/ to .gitignore so local runs don't leave an untracked example database.
  3. Consider registering a derandomized CI profile (e.g. settings.register_profile("ci", derandomize=True) in a conftest, activated via HYPOTHESIS_PROFILE=ci) so unrelated PRs can't be broken by a freshly generated counterexample — we can loosen this later once the suite has soaked.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47e8955762

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/unit/test_openai_requests.py Outdated
Comment thread tests/unit/test_openai_requests.py
Comment thread pyproject.toml
@iqbalmaulana03

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants