rhinotape 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rhinotape-0.4.0/.github/ISSUE_TEMPLATE/bug_report.yml +39 -0
- rhinotape-0.4.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
- rhinotape-0.4.0/.github/ISSUE_TEMPLATE/feature_request.yml +26 -0
- rhinotape-0.4.0/.github/PULL_REQUEST_TEMPLATE.md +19 -0
- rhinotape-0.4.0/.github/workflows/ci.yml +100 -0
- rhinotape-0.4.0/.github/workflows/publish.yml +88 -0
- rhinotape-0.4.0/.gitignore +11 -0
- rhinotape-0.4.0/.pre-commit-hooks.yaml +13 -0
- rhinotape-0.4.0/CHANGELOG.md +59 -0
- rhinotape-0.4.0/CONTRIBUTING.md +70 -0
- rhinotape-0.4.0/LICENSE +21 -0
- rhinotape-0.4.0/PKG-INFO +316 -0
- rhinotape-0.4.0/README.md +276 -0
- rhinotape-0.4.0/SECURITY.md +22 -0
- rhinotape-0.4.0/assets/logo.jpg +0 -0
- rhinotape-0.4.0/docs/integrations.md +407 -0
- rhinotape-0.4.0/examples/agent_circuit_breaker.py +106 -0
- rhinotape-0.4.0/examples/basic_openai.py +35 -0
- rhinotape-0.4.0/examples/chaos_and_new_episodes.py +95 -0
- rhinotape-0.4.0/examples/framework_integrations.py +246 -0
- rhinotape-0.4.0/examples/local_replay_server.py +47 -0
- rhinotape-0.4.0/examples/memory_store_and_matchers.py +67 -0
- rhinotape-0.4.0/examples/pytest_agent_example.py +33 -0
- rhinotape-0.4.0/examples/v03_advanced_agent.py +40 -0
- rhinotape-0.4.0/pyproject.toml +82 -0
- rhinotape-0.4.0/src/rhinotape/__init__.py +167 -0
- rhinotape-0.4.0/src/rhinotape/__main__.py +5 -0
- rhinotape-0.4.0/src/rhinotape/_version.py +3 -0
- rhinotape-0.4.0/src/rhinotape/aiohttp_adapter.py +615 -0
- rhinotape-0.4.0/src/rhinotape/cassette.py +482 -0
- rhinotape-0.4.0/src/rhinotape/chaos.py +168 -0
- rhinotape-0.4.0/src/rhinotape/cli.py +3007 -0
- rhinotape-0.4.0/src/rhinotape/html_report.py +278 -0
- rhinotape-0.4.0/src/rhinotape/integrations.py +965 -0
- rhinotape-0.4.0/src/rhinotape/matchers.py +138 -0
- rhinotape-0.4.0/src/rhinotape/models.py +316 -0
- rhinotape-0.4.0/src/rhinotape/parsers.py +1277 -0
- rhinotape-0.4.0/src/rhinotape/pricing.py +333 -0
- rhinotape-0.4.0/src/rhinotape/py.typed +0 -0
- rhinotape-0.4.0/src/rhinotape/pytest_plugin.py +711 -0
- rhinotape-0.4.0/src/rhinotape/requests_adapter.py +455 -0
- rhinotape-0.4.0/src/rhinotape/scrubbing.py +649 -0
- rhinotape-0.4.0/src/rhinotape/server.py +1438 -0
- rhinotape-0.4.0/src/rhinotape/session.py +2127 -0
- rhinotape-0.4.0/src/rhinotape/stores.py +104 -0
- rhinotape-0.4.0/src/rhinotape/transport.py +51 -0
- rhinotape-0.4.0/src/rhinotape/urllib_adapter.py +326 -0
- rhinotape-0.4.0/tests/test_advanced_assertions.py +114 -0
- rhinotape-0.4.0/tests/test_aiohttp_adapter.py +263 -0
- rhinotape-0.4.0/tests/test_cassette_ops.py +118 -0
- rhinotape-0.4.0/tests/test_chaos_replay.py +143 -0
- rhinotape-0.4.0/tests/test_chaos_toolkit.py +171 -0
- rhinotape-0.4.0/tests/test_cli_power_tools.py +141 -0
- rhinotape-0.4.0/tests/test_cli_v03.py +343 -0
- rhinotape-0.4.0/tests/test_concurrency_stress.py +176 -0
- rhinotape-0.4.0/tests/test_concurrency_v04.py +101 -0
- rhinotape-0.4.0/tests/test_coverage_cli_v04.py +77 -0
- rhinotape-0.4.0/tests/test_coverage_hardening_v04.py +1074 -0
- rhinotape-0.4.0/tests/test_coverage_server_html.py +55 -0
- rhinotape-0.4.0/tests/test_coverage_stores_matchers_chaos.py +78 -0
- rhinotape-0.4.0/tests/test_diagnostics.py +108 -0
- rhinotape-0.4.0/tests/test_e2e_agent_loop.py +146 -0
- rhinotape-0.4.0/tests/test_e2e_anthropic_protocol.py +84 -0
- rhinotape-0.4.0/tests/test_e2e_gemini_vertex.py +96 -0
- rhinotape-0.4.0/tests/test_e2e_mixed_transports_server.py +74 -0
- rhinotape-0.4.0/tests/test_e2e_openai_protocol.py +111 -0
- rhinotape-0.4.0/tests/test_edge_cases_and_coverage.py +179 -0
- rhinotape-0.4.0/tests/test_embeddings_and_cohere.py +113 -0
- rhinotape-0.4.0/tests/test_export_and_convert.py +190 -0
- rhinotape-0.4.0/tests/test_framework_integrations.py +737 -0
- rhinotape-0.4.0/tests/test_gzip_and_perf.py +262 -0
- rhinotape-0.4.0/tests/test_hooks_and_breakers.py +115 -0
- rhinotape-0.4.0/tests/test_html_report.py +176 -0
- rhinotape-0.4.0/tests/test_match_headers_and_strict_unused.py +107 -0
- rhinotape-0.4.0/tests/test_matchers.py +186 -0
- rhinotape-0.4.0/tests/test_new_episodes.py +84 -0
- rhinotape-0.4.0/tests/test_parsers_and_pricing.py +132 -0
- rhinotape-0.4.0/tests/test_perf_benchmarks.py +101 -0
- rhinotape-0.4.0/tests/test_pii_and_scrubbing_v04.py +168 -0
- rhinotape-0.4.0/tests/test_plugin_and_cli.py +85 -0
- rhinotape-0.4.0/tests/test_polyglot_proxy_server.py +582 -0
- rhinotape-0.4.0/tests/test_ponytail_review_and_run.py +249 -0
- rhinotape-0.4.0/tests/test_pricing_analytics.py +147 -0
- rhinotape-0.4.0/tests/test_prod_hardening_cli_parsers.py +974 -0
- rhinotape-0.4.0/tests/test_prod_hardening_core.py +1179 -0
- rhinotape-0.4.0/tests/test_production_hardening.py +317 -0
- rhinotape-0.4.0/tests/test_providers_v04.py +106 -0
- rhinotape-0.4.0/tests/test_public_api.py +20 -0
- rhinotape-0.4.0/tests/test_pytest_reporting.py +210 -0
- rhinotape-0.4.0/tests/test_pytester_plugin.py +106 -0
- rhinotape-0.4.0/tests/test_pytester_v04.py +123 -0
- rhinotape-0.4.0/tests/test_reasoning_and_coverage.py +415 -0
- rhinotape-0.4.0/tests/test_replay_server.py +106 -0
- rhinotape-0.4.0/tests/test_requests_adapter.py +358 -0
- rhinotape-0.4.0/tests/test_schema_and_coverage.py +137 -0
- rhinotape-0.4.0/tests/test_scrubbing_and_cassette.py +77 -0
- rhinotape-0.4.0/tests/test_security_and_fuzz.py +96 -0
- rhinotape-0.4.0/tests/test_semantic_assertions.py +79 -0
- rhinotape-0.4.0/tests/test_session_and_transport.py +170 -0
- rhinotape-0.4.0/tests/test_sse_spec.py +35 -0
- rhinotape-0.4.0/tests/test_stats_and_hash.py +164 -0
- rhinotape-0.4.0/tests/test_stores.py +129 -0
- rhinotape-0.4.0/tests/test_streaming.py +484 -0
- rhinotape-0.4.0/tests/test_urllib_adapter.py +192 -0
- rhinotape-0.4.0/tests/test_v03_features.py +909 -0
- rhinotape-0.4.0/uv.lock +2057 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug, crash, scrubbing bypass, or unexpected replay mismatch
|
|
3
|
+
labels: ["bug"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Thanks for reporting an issue! For security vulnerabilities (secret leaks, XSS, path traversal), please follow `SECURITY.md` instead of opening a public issue.
|
|
9
|
+
|
|
10
|
+
- type: textarea
|
|
11
|
+
id: description
|
|
12
|
+
attributes:
|
|
13
|
+
label: What happened?
|
|
14
|
+
description: Clear description of the bug and what you expected instead.
|
|
15
|
+
validations:
|
|
16
|
+
required: true
|
|
17
|
+
|
|
18
|
+
- type: textarea
|
|
19
|
+
id: reproduction
|
|
20
|
+
attributes:
|
|
21
|
+
label: Minimal Reproduction
|
|
22
|
+
description: Minimal offline snippet (e.g. using `httpx.MockTransport` or a sanitized `.tape.json`).
|
|
23
|
+
render: python
|
|
24
|
+
validations:
|
|
25
|
+
required: true
|
|
26
|
+
|
|
27
|
+
- type: input
|
|
28
|
+
id: environment
|
|
29
|
+
attributes:
|
|
30
|
+
label: Environment
|
|
31
|
+
placeholder: "e.g. rhinotape 0.4.0, Python 3.12, Ubuntu 24.04, httpx 0.28, pytest 9.0"
|
|
32
|
+
validations:
|
|
33
|
+
required: true
|
|
34
|
+
|
|
35
|
+
- type: textarea
|
|
36
|
+
id: logs
|
|
37
|
+
attributes:
|
|
38
|
+
label: Error / Traceback Output
|
|
39
|
+
render: shell
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: true
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: Security Vulnerability Report
|
|
4
|
+
url: https://github.com/Hoaiduc195/rhinotape/security/advisories/new
|
|
5
|
+
about: Report secret-scrubbing bypasses, XSS, or path-traversal issues privately.
|
|
6
|
+
- name: Framework Integration Cookbook
|
|
7
|
+
url: https://github.com/Hoaiduc195/rhinotape/blob/master/docs/integrations.md
|
|
8
|
+
about: Guides for FastAPI, Flask, Django, LangChain, LlamaIndex, Node.js, Go, and Rust.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Propose a new provider parser, assertion, framework integration, or CLI tool
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: problem
|
|
7
|
+
attributes:
|
|
8
|
+
label: Problem or Use Case
|
|
9
|
+
description: What workflow or testing challenge are you trying to solve?
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
|
|
13
|
+
- type: textarea
|
|
14
|
+
id: proposal
|
|
15
|
+
attributes:
|
|
16
|
+
label: Proposed Solution
|
|
17
|
+
description: Describe the API, CLI command, or behavior you'd like to see.
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
|
|
21
|
+
- type: checkboxes
|
|
22
|
+
id: contribution
|
|
23
|
+
attributes:
|
|
24
|
+
label: Contribution
|
|
25
|
+
options:
|
|
26
|
+
- label: I would be interested in submitting a PR for this feature.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
<!-- Briefly describe what this PR changes and why. Link any related issue (`Closes #123`). -->
|
|
4
|
+
|
|
5
|
+
## Type of Change
|
|
6
|
+
|
|
7
|
+
- [ ] Bug fix
|
|
8
|
+
- [ ] New feature / provider / integration
|
|
9
|
+
- [ ] Documentation / examples
|
|
10
|
+
- [ ] Refactor / performance / tests
|
|
11
|
+
|
|
12
|
+
## Checklist
|
|
13
|
+
|
|
14
|
+
- [ ] Added or updated offline tests (no live API calls or real secrets)
|
|
15
|
+
- [ ] `uv run ruff check src tests examples` & `uv run ruff format --check src tests examples` pass
|
|
16
|
+
- [ ] `uv run mypy` passes (`strict = true`)
|
|
17
|
+
- [ ] `uv run pytest -v -W error` passes with coverage `>= 93%`
|
|
18
|
+
- [ ] `uv run rhinotape verify . --check-secrets --check-pii` passes
|
|
19
|
+
- [ ] No new hard runtime dependencies added (`httpx` remains the sole core dependency)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master, main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ${{ matrix.os }}
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
15
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
exclude:
|
|
17
|
+
- os: macos-latest
|
|
18
|
+
python-version: "3.11"
|
|
19
|
+
- os: macos-latest
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
- os: windows-latest
|
|
22
|
+
python-version: "3.11"
|
|
23
|
+
- os: windows-latest
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
|
|
29
|
+
- name: Install uv
|
|
30
|
+
uses: astral-sh/setup-uv@v5
|
|
31
|
+
|
|
32
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
33
|
+
run: uv python install ${{ matrix.python-version }}
|
|
34
|
+
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: uv sync --python ${{ matrix.python-version }} --extra dev
|
|
37
|
+
|
|
38
|
+
- name: Lint & format check with ruff
|
|
39
|
+
run: |
|
|
40
|
+
uv run --python ${{ matrix.python-version }} ruff check src tests examples
|
|
41
|
+
uv run --python ${{ matrix.python-version }} ruff format --check src tests examples
|
|
42
|
+
|
|
43
|
+
- name: Type-check with mypy
|
|
44
|
+
run: uv run --python ${{ matrix.python-version }} mypy
|
|
45
|
+
|
|
46
|
+
- name: Run pytest with coverage
|
|
47
|
+
run: |
|
|
48
|
+
uv run --python ${{ matrix.python-version }} coverage run --source=rhinotape -m pytest -v -W error
|
|
49
|
+
uv run --python ${{ matrix.python-version }} coverage report -m --fail-under=93
|
|
50
|
+
|
|
51
|
+
- name: Dogfood rhinotape verify (secrets & PII)
|
|
52
|
+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
|
|
53
|
+
run: uv run --python ${{ matrix.python-version }} rhinotape verify . --check-secrets --check-pii
|
|
54
|
+
|
|
55
|
+
- name: Build package
|
|
56
|
+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
|
|
57
|
+
run: uv build
|
|
58
|
+
|
|
59
|
+
- name: Verify wheel installs cleanly across optional extras
|
|
60
|
+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
|
|
61
|
+
run: |
|
|
62
|
+
uv venv --python ${{ matrix.python-version }} .tmp-no-pytest-venv
|
|
63
|
+
uv pip install --python .tmp-no-pytest-venv/bin/python dist/*.whl
|
|
64
|
+
.tmp-no-pytest-venv/bin/python -c "import rhinotape; print(rhinotape.__version__)"
|
|
65
|
+
.tmp-no-pytest-venv/bin/python - <<'PY'
|
|
66
|
+
import httpx
|
|
67
|
+
from rhinotape import MemoryCassetteStore, TapeMode, TapeSession
|
|
68
|
+
|
|
69
|
+
store = MemoryCassetteStore()
|
|
70
|
+
resp_payload = {
|
|
71
|
+
"model": "gpt-4o-mini",
|
|
72
|
+
"choices": [{"message": {"role": "assistant", "content": "pong"}}],
|
|
73
|
+
"usage": {"prompt_tokens": 10, "completion_tokens": 5},
|
|
74
|
+
}
|
|
75
|
+
transport = httpx.MockTransport(lambda req: httpx.Response(200, json=resp_payload))
|
|
76
|
+
with TapeSession("smoke.tape.json", mode=TapeMode.RECORD, store=store) as rec:
|
|
77
|
+
with httpx.Client(transport=transport) as client:
|
|
78
|
+
r = client.post(
|
|
79
|
+
"https://api.openai.com/v1/chat/completions",
|
|
80
|
+
json={"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "ping"}]},
|
|
81
|
+
)
|
|
82
|
+
assert r.status_code == 200
|
|
83
|
+
rec.assert_call_count(1)
|
|
84
|
+
|
|
85
|
+
with TapeSession("smoke.tape.json", mode=TapeMode.REPLAY, store=store) as rep:
|
|
86
|
+
with httpx.Client(
|
|
87
|
+
transport=httpx.MockTransport(lambda req: httpx.Response(500))
|
|
88
|
+
) as client:
|
|
89
|
+
r = client.post(
|
|
90
|
+
"https://api.openai.com/v1/chat/completions",
|
|
91
|
+
json={"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "ping"}]},
|
|
92
|
+
)
|
|
93
|
+
assert r.status_code == 200
|
|
94
|
+
assert r.json()["choices"][0]["message"]["content"] == "pong"
|
|
95
|
+
rep.assert_call_count(1)
|
|
96
|
+
rep.assert_tokens_under(50)
|
|
97
|
+
print("Offline wheel smoke test OK")
|
|
98
|
+
PY
|
|
99
|
+
.tmp-no-pytest-venv/bin/rhinotape --help
|
|
100
|
+
rm -rf .tmp-no-pytest-venv
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
uses: astral-sh/setup-uv@v5
|
|
19
|
+
|
|
20
|
+
- name: Set up Python and install dev dependencies
|
|
21
|
+
run: uv sync --extra dev
|
|
22
|
+
|
|
23
|
+
- name: Verify release tag matches package version
|
|
24
|
+
if: github.event_name == 'release'
|
|
25
|
+
env:
|
|
26
|
+
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
27
|
+
run: |
|
|
28
|
+
uv run python - <<'PY'
|
|
29
|
+
import os
|
|
30
|
+
import re
|
|
31
|
+
from pathlib import Path
|
|
32
|
+
|
|
33
|
+
text = Path("src/rhinotape/_version.py").read_text(encoding="utf-8")
|
|
34
|
+
match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', text, re.MULTILINE)
|
|
35
|
+
assert match is not None, "Could not parse __version__ from src/rhinotape/_version.py"
|
|
36
|
+
pkg_version = match.group(1)
|
|
37
|
+
tag = os.environ["RELEASE_TAG"]
|
|
38
|
+
normalized_tag = tag[1:] if tag.startswith("v") else tag
|
|
39
|
+
if normalized_tag != pkg_version:
|
|
40
|
+
raise SystemExit(
|
|
41
|
+
f"Release tag {tag!r} does not match src/rhinotape/_version.py __version__ ({pkg_version!r})."
|
|
42
|
+
)
|
|
43
|
+
print(f"Verified release tag {tag} matches __version__ == {pkg_version}")
|
|
44
|
+
PY
|
|
45
|
+
|
|
46
|
+
- name: Run test suite
|
|
47
|
+
run: uv run pytest -q -W error
|
|
48
|
+
|
|
49
|
+
- name: Build wheel and sdist
|
|
50
|
+
run: uv build
|
|
51
|
+
|
|
52
|
+
- name: Validate distributions with twine
|
|
53
|
+
run: uvx twine check dist/*
|
|
54
|
+
|
|
55
|
+
- uses: actions/upload-artifact@v4
|
|
56
|
+
with:
|
|
57
|
+
name: dist
|
|
58
|
+
path: dist/
|
|
59
|
+
|
|
60
|
+
publish-testpypi:
|
|
61
|
+
needs: build
|
|
62
|
+
if: github.event_name == 'workflow_dispatch'
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
environment: testpypi
|
|
65
|
+
permissions:
|
|
66
|
+
id-token: write
|
|
67
|
+
steps:
|
|
68
|
+
- uses: actions/download-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
name: dist
|
|
71
|
+
path: dist/
|
|
72
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
73
|
+
with:
|
|
74
|
+
repository-url: https://test.pypi.org/legacy/
|
|
75
|
+
|
|
76
|
+
publish-pypi:
|
|
77
|
+
needs: build
|
|
78
|
+
if: github.event_name == 'release'
|
|
79
|
+
runs-on: ubuntu-latest
|
|
80
|
+
environment: pypi
|
|
81
|
+
permissions:
|
|
82
|
+
id-token: write
|
|
83
|
+
steps:
|
|
84
|
+
- uses: actions/download-artifact@v4
|
|
85
|
+
with:
|
|
86
|
+
name: dist
|
|
87
|
+
path: dist/
|
|
88
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
- id: rhinotape-verify-secrets
|
|
2
|
+
name: Verify rhinotape cassettes (schema + secrets)
|
|
3
|
+
description: Validate .tape.json(.gz) cassettes and block leaked API keys or tokens.
|
|
4
|
+
entry: rhinotape verify --check-secrets
|
|
5
|
+
language: python
|
|
6
|
+
files: \.tape\.json(\.gz)?$
|
|
7
|
+
|
|
8
|
+
- id: rhinotape-verify-pii
|
|
9
|
+
name: Verify rhinotape cassettes (schema + secrets + PII)
|
|
10
|
+
description: Validate .tape.json(.gz) cassettes and block leaked secrets or PII.
|
|
11
|
+
entry: rhinotape verify --check-secrets --check-pii
|
|
12
|
+
language: python
|
|
13
|
+
files: \.tape\.json(\.gz)?$
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.0 - 2026-11-26
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- **Renamed package to `rhinotape`** (`pip install rhinotape`, `import rhinotape`, `rhinotape` CLI, `rhinotape` / `rhinotape_dir` pytest fixtures, `RHINOTAPE_*` env vars) with new rhinoceros brand logo and redesigned docs.
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- **Zero-code CLI wrapper (`rhinotape run`) & `python -m rhinotape`:** Wrap any test runner or app (`npm test`, `vitest`, `go test`, `cargo test`, `pytest`) against an ephemeral local reverse proxy with automatic provider base-URL injection and `--max-cost` / `--max-tokens` / `--strict-unused` CI gates.
|
|
10
|
+
- **Universal Python framework integration layer (`rhinotape.integrations`):** Pure ASGI 3.0 `TapeASGIMiddleware` (FastAPI, Starlette, Litestar, Django ASGI), pure PEP 3333 `TapeWSGIMiddleware` (Flask, Django WSGI, Bottle, Falcon), `TapeConfig.from_env()`, `current_session()` / `require_session()`, `make_httpx_client()` / `make_async_httpx_client()`, `TapeTestCaseMixin`, `activate_tape()` / `activate_from_env()`, and `handle_generic_request()` bridge.
|
|
11
|
+
- **Polyglot reverse-proxy & HTTP control plane (`TapeReplayServer`):** Record/replay proxy modes (`once`, `record`, `new_episodes`), CORS support, PII redaction, and `/__tape__/{health,stats,interactions,reset,load,save,assert}` endpoints.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Production & security hardening:** Bounded request/response sizes (`max_request_bytes` → HTTP 413, upstream `MAX_CASSETTE_BYTES` cap), bounded chunked decoding, request timeouts, thread-safe concurrent saves & `max_interactions` accounting, strict `NaN`/`Infinity`/`bool` validation across cassettes/models/pricing/assertions, expanded secret & base64 verification in `rhinotape verify`, and Python 3.10–3.13 + Windows cross-platform CLI/signal fixes.
|
|
15
|
+
|
|
16
|
+
## 0.3.0 - 2026-11-25
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- **Single-source dynamic versioning** via `src/rhinotape/_version.py` (`hatch` dynamic version).
|
|
20
|
+
- **Cached input & reasoning token tracking + external pricing files:** `Usage.cached_input_tokens`, `Usage.reasoning_tokens` (OpenAI Chat Completions/Responses & Gemini `thoughtsTokenCount`), `o3`/`o4-mini` pricing, `ModelPrice.cached_input_per_million`, `load_pricing_file()`, and `RHINOTAPE_PRICING_FILE` env var override.
|
|
21
|
+
- **Deterministic gzip-compressed cassettes (`.tape.json.gz`):** Transparent load/save with `mtime=0` deterministic headers, bounded decompression safety (`MAX_CASSETTE_BYTES`), and `--tape-compress` / `tape_compress` / `@pytest.mark.tape(compress=...)`.
|
|
22
|
+
- **Chaos & fault-injection replay (`on_replay` + `replace_response`):** Inject 429/503 errors, mutated LLM responses, or custom latency on replay across all HTTP adapters without modifying cassettes.
|
|
23
|
+
- **`TapeMode.NEW_EPISODES`:** VCR-classic mode that replays existing matches offline while recording and appending only newly added requests (preserving existing `cassette.metadata`).
|
|
24
|
+
- **Optional `requests`, `aiohttp`, and stdlib `urllib.request` adapters:** Thread-safe, `contextvars`-isolated interception for `requests` (`rhinotape[requests]`), async `aiohttp` (`rhinotape[aiohttp]`), and opt-in stdlib `urllib.request` (`patch_urllib=True`) with zero new hard runtime dependencies.
|
|
25
|
+
- **Extended thinking, OpenAI Embeddings, Cohere v1/v2 & WHATWG SSE hardening:** `LLMCallSummary.thinking` extraction (Anthropic, DeepSeek-R1, Gemini), OpenAI embeddings & Cohere JSON/SSE parsers + pricing, and WHATWG SSE spec compliance (UTF-8 BOM, CRLF, single-space strip, bare fields).
|
|
26
|
+
- **Hot-path performance optimizations:** Pre-compiled `redact_patterns`, single-pass pattern-only `redact_body`, mtime/size-cached `RHINOTAPE_PRICING_FILE`, and zero-copy `DEFAULT_PRICING` lookup.
|
|
27
|
+
- **Selective header matching & strict unused checks:** `match_headers` whitelist in `fingerprint_request`/`TapeSession` and `--tape-strict-unused` / `tape_strict_unused` pytest enforcement.
|
|
28
|
+
- **Expanded assertions & session telemetry:** `assert_text_contains()`, `assert_text_matches()`, `assert_no_tool_called()`, `assert_thinking_present()`, `assert_reasoning_tokens_under()`, `assert_cached_tokens_at_least()`, `assert_model()`, `assert_provider()`, `assert_no_errors()`, `export_summary()`, `last_text`, `last_thinking`, and `all_texts`.
|
|
29
|
+
- **Full CI/CD CLI suite & pre-commit hooks:** `rhinotape stats` (per-provider/model cache hit %, cache savings USD, avg/p95 latency), `rhinotape inspect --show-bodies --show-thinking --interaction` + `Cassette.content_hash()`, `rhinotape schema` (Draft 2020-12 JSON Schema), `rhinotape export` (Markdown/CSV/HAR 1.2/HTML/JUnit XML), `rhinotape convert` (gzip ↔ json with `--force`), `rhinotape verify --check-secrets --check-pii`, `.pre-commit-hooks.yaml`, `rhinotape diff` directory comparison, `--show-text-diff` & CI gates, `rhinotape prune`, `rhinotape redact --pii`, `rhinotape summary --group-by dir --max-cost --max-tokens`, `rhinotape search`, `rhinotape list`, `rhinotape pricing`, `rhinotape replay-check`, `rhinotape reparse`, `rhinotape merge`, `rhinotape split`, and `rhinotape serve`.
|
|
30
|
+
- **Cassette operations & in-memory / pluggable persistence:** `Cassette.merge()`, `filter()`, `slice()`, `deduplicate()`, `clone()`, `stats()`, `sort_interactions()`, `validate()`, `add_interaction()`, `to_json()`/`from_json()`, `to_bytes()`/`from_bytes()`, `CassetteStore` Protocol, thread-safe `MemoryCassetteStore`, path-traversal-guarded `FileCassetteStore`, and `TapeSession(..., store=...)`.
|
|
31
|
+
- **Local HTTP Replay Server & Interactive HTML Trace Viewer:** Stdlib `TapeReplayServer` (`/__tape__/health`, `/__tape__/stats`, SSE streaming, latency pacing, query-param scrubbing on 404s) and zero-CDN, XSS-safe `render_html_report()` wired into `rhinotape export --format html` and `pytest --tape-html-report`.
|
|
32
|
+
- **PII Presets, Wildcard Header Scrubbing & URL Path Redaction:** Built-in `PII_EMAIL`, `PII_PHONE`, `PII_SSN`, `PII_CREDIT_CARD`, `PII_IPV4`, `PII_JWT`, `PII_PRESETS`, `resolve_pii_patterns()`, `redact_pii`, `fnmatch` wildcards in `scrub_headers()`, and `redact_url_patterns`.
|
|
33
|
+
- **More Providers & Cache-Write Billing:** Mistral FIM (`codestral`/`ministral-*`), xAI Grok (`grok-2`/`grok-3`/`grok-3-mini`), Perplexity (`sonar*`), OpenAI Audio/Image endpoints, Hugging Face router, `ModelPrice.cache_write_per_million` (Anthropic 1.25x), `Usage.cache_creation_tokens`, and `estimate_cache_savings_usd()`.
|
|
34
|
+
- **Composable Request Matchers & Chaos Toolkit:** `MATCH_STRICT`, `MATCH_RELAXED`, `MATCH_PATH_AND_BODY`, `ignore_json_array_order`, `match_all`/`match_any`/`match_method`/`match_path`/`match_json_subset`/`match_json_regex`/`match_header_equals`, plus `fail_nth`, `fail_first`, `inject_latency`, `corrupt_json_body`, `truncate_stream`, and `chain_replay_hooks`.
|
|
35
|
+
- **Recording Hooks, Live Circuit Breakers & Advanced Assertions:** `on_record`, custom cassette `metadata`, `TapeSession.save()`, `max_interactions`, `max_cost_usd`, `assert_json_output`, `assert_max_cost_per_call`, `assert_max_tokens_per_call`, `assert_streamed`/`assert_not_streamed`, `assert_status_codes`, `assert_tool_call_count`, and `assert_cache_hit_rate_at_least`.
|
|
36
|
+
- **Pytest Plugin & Diagnostics UX:** `tape_max_cost`, `tape_max_tokens`, `tape_redact_pii` ini options, `RHINOTAPE_*` env-var fallbacks, `rhinotape_dir` fixture, `--tape-update-stale <days>`, semantic JSON key-path diff summaries in `format_request_diff()`, and structured `UnmatchedRequestError` (`.incoming`, `.closest`, `.diff_text`).
|
|
37
|
+
- **Performance & Security Hardening:** Direct dict literals in `to_dict()`, pre-computed `_detect_provider()` lookup tables, cached `compile_sensitive_headers()`, lazy UTF-8 SSE replay encoding, and pre-read `MAX_CASSETTE_BYTES` stat guard in `Cassette.load()`.
|
|
38
|
+
- **Trusted Publishing workflow & Community Docs:** `.github/workflows/publish.yml`, `CONTRIBUTING.md`, `SECURITY.md`, and runnable examples in `examples/`.
|
|
39
|
+
|
|
40
|
+
## 0.2.0 - 2026-11-25
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
- **True SSE Streaming support** (sync & async `httpx` streaming record/replay + token/tool-call parsing) for OpenAI Chat Completions, OpenAI Responses API, Anthropic Messages, and Google Gemini (`:streamGenerateContent`).
|
|
44
|
+
- **`contextvars`-based `httpx` dispatcher** with reference-counted thread-safe patching for nested sessions and concurrent `asyncio.gather` tasks.
|
|
45
|
+
- **Request filtering & flexible matching:** `ignore_hosts`, `ignore_localhost`, `ignore_request`, `ignore_fields` (dot-path + `*` wildcards), `ignore_query_params`, and `allow_playback_repeats`.
|
|
46
|
+
- **Actionable `UnmatchedRequestError` diagnostics:** distinguishes exhausted replay queues from unmatched requests and prints a unified diff against the closest recorded request.
|
|
47
|
+
- **Atomic cassette writes** (`NamedTemporaryFile` + `os.fsync` + `os.replace`) and safe default `save_on_error=False` so failing tests never overwrite cassettes with partial data.
|
|
48
|
+
- **PEP 561 `py.typed` marker**, strict `mypy` verification, `pytester` end-to-end plugin tests, and GitHub Actions CI matrix (Python 3.10–3.13).
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
- Binary payloads (`base64`) and JSON primitives (`null`, strings) now round-trip faithfully via explicit `body_encoding`.
|
|
52
|
+
- Anthropic cache tokens (`cache_creation_input_tokens`, `cache_read_input_tokens`) and Gemini `thoughtsTokenCount` are now included in usage and cost calculations.
|
|
53
|
+
- Boundary-safe model pricing prefix matching prevents short prefixes like `gpt-4` from matching `gpt-4o`.
|
|
54
|
+
- Parametrized pytest tests with `@pytest.mark.tape(name=...)` no longer collide on cassette filenames.
|
|
55
|
+
- `Cassette.load()` wraps malformed JSON and unsupported schema versions in `CorruptCassetteError`.
|
|
56
|
+
|
|
57
|
+
## 0.1.0 - 2026-11-25
|
|
58
|
+
|
|
59
|
+
- Initial release with sync/async `httpx` record & replay, secret scrubbing, OpenAI/Anthropic/Gemini JSON parsers, assertions, pytest plugin, and CLI.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Contributing to `rhinotape`
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to `rhinotape`! We welcome bug fixes, new provider parsers, framework integration guides, CLI improvements, and tests.
|
|
4
|
+
|
|
5
|
+
Looking for a place to start? Check out our open [**good first issues**](https://github.com/Hoaiduc195/rhinotape/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) and [**help wanted**](https://github.com/Hoaiduc195/rhinotape/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) issues.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Architecture Overview
|
|
10
|
+
|
|
11
|
+
| Module | Responsibility |
|
|
12
|
+
| :--- | :--- |
|
|
13
|
+
| `src/rhinotape/models.py` | Core immutable data models (`Interaction`, `RecordedRequest`, `RecordedResponse`, `Usage`, `ToolCall`, `LLMCallSummary`, `TapeMode`, exceptions) |
|
|
14
|
+
| `src/rhinotape/cassette.py` | Schema v2 `.tape.json(.gz)` serialization, atomic writes, bounded decompression, validation, merge/filter/slice |
|
|
15
|
+
| `src/rhinotape/scrubbing.py` | Secret/header/URL/PII redaction, field stripping, request fingerprinting, semantic JSON diffs |
|
|
16
|
+
| `src/rhinotape/parsers.py` | Provider-aware JSON, SSE, and NDJSON parsers + stream chunk redaction |
|
|
17
|
+
| `src/rhinotape/pricing.py` | Built-in USD per-1M-token pricing table, cache read/write billing, `RHINOTAPE_PRICING_FILE` loader |
|
|
18
|
+
| `src/rhinotape/session.py` | `TapeSession` lifecycle, `contextvars` dispatcher, streaming wrappers, guardrails, and assertions |
|
|
19
|
+
| `src/rhinotape/transport.py` | Explicit `httpx` `TapeTransport` / `AsyncTapeTransport` wrappers |
|
|
20
|
+
| `src/rhinotape/*_adapter.py` | Optional `requests`, `aiohttp`, and stdlib `urllib.request` adapters |
|
|
21
|
+
| `src/rhinotape/integrations.py` | Zero-dependency ASGI/WSGI middleware, `TapeConfig`, `unittest` mixin, SDK factories, generic HTTP bridge |
|
|
22
|
+
| `src/rhinotape/server.py` | Local reverse-proxy record/replay server & `/__tape__/*` polyglot HTTP control plane |
|
|
23
|
+
| `src/rhinotape/matchers.py` | Composable request matchers (`match_all`, `match_json_subset`, etc.) |
|
|
24
|
+
| `src/rhinotape/chaos.py` | Composable fault-injection `on_replay` hooks (`fail_nth`, `truncate_stream`, etc.) |
|
|
25
|
+
| `src/rhinotape/stores.py` | `CassetteStore` protocol, `MemoryCassetteStore`, `FileCassetteStore` |
|
|
26
|
+
| `src/rhinotape/html_report.py` | Self-contained, XSS-safe, zero-CDN HTML trace viewer |
|
|
27
|
+
| `src/rhinotape/pytest_plugin.py` | Auto-discovered `pytest11` plugin, fixtures, budgets, and xdist aggregation |
|
|
28
|
+
| `src/rhinotape/cli.py` | `rhinotape` CLI subcommands (`inspect`, `verify`, `diff`, `serve`, `run`, `export`, etc.) |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Development Setup
|
|
33
|
+
|
|
34
|
+
`rhinotape` uses [`uv`](https://docs.astral.sh/uv/) for dependency management and targets Python `>=3.10`.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/Hoaiduc195/rhinotape.git
|
|
38
|
+
cd rhinotape
|
|
39
|
+
uv sync --extra dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Running Checks Locally
|
|
43
|
+
|
|
44
|
+
Every pull request must pass linting, formatting, strict typing, zero-warning tests, coverage (`>=93%`), and secret/PII verification:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
uv run ruff check src tests examples
|
|
48
|
+
uv run ruff format --check src tests examples
|
|
49
|
+
uv run mypy
|
|
50
|
+
uv run coverage run --source=rhinotape -m pytest -v -W error
|
|
51
|
+
uv run coverage report -m --fail-under=93
|
|
52
|
+
uv run rhinotape verify . --check-secrets --check-pii
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Design Principles
|
|
58
|
+
|
|
59
|
+
- **Minimal runtime dependencies:** `httpx>=0.27.0` is the sole hard runtime dependency. Optional integrations (`pytest`, `requests`, `aiohttp`) must remain optional extras and never break `import rhinotape` when absent.
|
|
60
|
+
- **Deterministic & offline-first:** All tests must run completely offline (`httpx.MockTransport` or local loopback sockets) with zero real API keys or external network calls.
|
|
61
|
+
- **Zero secret leaks:** Never commit real API keys, tokens, or PII in cassettes or tests.
|
|
62
|
+
- **Strict typing:** All public APIs must be fully annotated and pass `mypy --strict` (`py.typed` is shipped).
|
|
63
|
+
- **Lean & backwards-compatible:** Prefer small, focused changes that preserve existing public APIs and cassette schema v2 compatibility.
|
|
64
|
+
|
|
65
|
+
## Adding a New LLM Provider
|
|
66
|
+
|
|
67
|
+
1. Add provider detection and JSON/SSE parsing in `src/rhinotape/parsers.py`.
|
|
68
|
+
2. Add reference model rates (if public) in `src/rhinotape/pricing.py`.
|
|
69
|
+
3. Add offline E2E record/replay/streaming tests in `tests/`.
|
|
70
|
+
4. Update the Supported Providers table in `README.md`.
|
rhinotape-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 llm-tape contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|