guarddiff 0.1.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.
Files changed (68) hide show
  1. guarddiff-0.1.0/.env.example +4 -0
  2. guarddiff-0.1.0/.github/ISSUE_TEMPLATE/bug.yml +22 -0
  3. guarddiff-0.1.0/.github/ISSUE_TEMPLATE/question.yml +11 -0
  4. guarddiff-0.1.0/.github/workflows/ci.yml +21 -0
  5. guarddiff-0.1.0/.gitignore +44 -0
  6. guarddiff-0.1.0/CHANGELOG.md +20 -0
  7. guarddiff-0.1.0/LICENSE +21 -0
  8. guarddiff-0.1.0/PKG-INFO +627 -0
  9. guarddiff-0.1.0/README.md +602 -0
  10. guarddiff-0.1.0/SECURITY.md +7 -0
  11. guarddiff-0.1.0/docs/images/01-demo-table.png +0 -0
  12. guarddiff-0.1.0/docs/images/02-report-summary.png +0 -0
  13. guarddiff-0.1.0/docs/images/03-report-items.png +0 -0
  14. guarddiff-0.1.0/docs/images/04-gate.png +0 -0
  15. guarddiff-0.1.0/docs/images/05-qwen3guard-recorded.png +0 -0
  16. guarddiff-0.1.0/docs/images/06-live-config.png +0 -0
  17. guarddiff-0.1.0/examples/ollama-qwen3guard/guarddiff.toml +46 -0
  18. guarddiff-0.1.0/pyproject.toml +50 -0
  19. guarddiff-0.1.0/src/guarddiff/__init__.py +16 -0
  20. guarddiff-0.1.0/src/guarddiff/__main__.py +7 -0
  21. guarddiff-0.1.0/src/guarddiff/cli.py +192 -0
  22. guarddiff-0.1.0/src/guarddiff/config.py +101 -0
  23. guarddiff-0.1.0/src/guarddiff/errors.py +23 -0
  24. guarddiff-0.1.0/src/guarddiff/examples/offline/guarddiff.toml +48 -0
  25. guarddiff-0.1.0/src/guarddiff/examples/offline/items.jsonl +18 -0
  26. guarddiff-0.1.0/src/guarddiff/examples/qwen3guard-recorded/guarddiff.toml +34 -0
  27. guarddiff-0.1.0/src/guarddiff/examples/qwen3guard-recorded/items.jsonl +18 -0
  28. guarddiff-0.1.0/src/guarddiff/examples/qwen3guard-recorded/qwen3guard_recorded.jsonl +18 -0
  29. guarddiff-0.1.0/src/guarddiff/gate.py +81 -0
  30. guarddiff-0.1.0/src/guarddiff/guards/__init__.py +59 -0
  31. guarddiff-0.1.0/src/guarddiff/guards/base.py +33 -0
  32. guarddiff-0.1.0/src/guarddiff/guards/python_fn.py +79 -0
  33. guarddiff-0.1.0/src/guarddiff/guards/qwen3guard.py +115 -0
  34. guarddiff-0.1.0/src/guarddiff/guards/regex.py +29 -0
  35. guarddiff-0.1.0/src/guarddiff/guards/replay.py +64 -0
  36. guarddiff-0.1.0/src/guarddiff/items.py +52 -0
  37. guarddiff-0.1.0/src/guarddiff/judges/__init__.py +5 -0
  38. guarddiff-0.1.0/src/guarddiff/judges/rules.py +41 -0
  39. guarddiff-0.1.0/src/guarddiff/latency.py +16 -0
  40. guarddiff-0.1.0/src/guarddiff/metrics.py +125 -0
  41. guarddiff-0.1.0/src/guarddiff/outcomes.py +54 -0
  42. guarddiff-0.1.0/src/guarddiff/packs/LICENSE +5 -0
  43. guarddiff-0.1.0/src/guarddiff/packs/starter-en-ko.jsonl +18 -0
  44. guarddiff-0.1.0/src/guarddiff/report/__init__.py +1 -0
  45. guarddiff-0.1.0/src/guarddiff/report/html.py +107 -0
  46. guarddiff-0.1.0/src/guarddiff/report/markdown.py +66 -0
  47. guarddiff-0.1.0/src/guarddiff/runner.py +304 -0
  48. guarddiff-0.1.0/src/guarddiff/targets/__init__.py +40 -0
  49. guarddiff-0.1.0/src/guarddiff/targets/base.py +31 -0
  50. guarddiff-0.1.0/src/guarddiff/targets/mock.py +35 -0
  51. guarddiff-0.1.0/src/guarddiff/targets/openai_http.py +58 -0
  52. guarddiff-0.1.0/src/guarddiff/targets/python_fn.py +18 -0
  53. guarddiff-0.1.0/tests/conftest.py +46 -0
  54. guarddiff-0.1.0/tests/fixtures/expected.json +461 -0
  55. guarddiff-0.1.0/tests/fixtures/items.jsonl +18 -0
  56. guarddiff-0.1.0/tests/fixtures/qwen3guard_metrics.json +44 -0
  57. guarddiff-0.1.0/tests/fixtures/qwen3guard_out.jsonl +18 -0
  58. guarddiff-0.1.0/tests/gd_testhelpers.py +70 -0
  59. guarddiff-0.1.0/tests/test_cli.py +179 -0
  60. guarddiff-0.1.0/tests/test_indeterminate.py +182 -0
  61. guarddiff-0.1.0/tests/test_metrics_rules.py +55 -0
  62. guarddiff-0.1.0/tests/test_offline_fixture.py +134 -0
  63. guarddiff-0.1.0/tests/test_openai_target.py +123 -0
  64. guarddiff-0.1.0/tests/test_packaging.py +62 -0
  65. guarddiff-0.1.0/tests/test_qwen3guard.py +120 -0
  66. guarddiff-0.1.0/tests/test_report.py +63 -0
  67. guarddiff-0.1.0/tests/test_resume.py +241 -0
  68. guarddiff-0.1.0/uv.lock +1461 -0
@@ -0,0 +1,4 @@
1
+ # Only needed for the `openai` target (any OpenAI-compatible endpoint, see README).
2
+ # Copy to .env, fill in, and export it: set -a; . ./.env; set +a
3
+ # The config names this variable in `api_key_env`; guarddiff never reads a key from a file.
4
+ OPENAI_API_KEY=
@@ -0,0 +1,22 @@
1
+ name: 버그 / Bug
2
+ description: README대로 했는데 다르게 동작해요 / Something does not work as the README says
3
+ labels: [bug]
4
+ body:
5
+ - type: textarea
6
+ id: what
7
+ attributes:
8
+ label: 무엇이 일어났나요? / What happened?
9
+ description: 실행한 명령과 나온 메시지를 그대로 붙여 주세요. / Paste the command and the output.
10
+ validations:
11
+ required: true
12
+ - type: textarea
13
+ id: expected
14
+ attributes:
15
+ label: 기대한 결과 / Expected
16
+ - type: input
17
+ id: env
18
+ attributes:
19
+ label: 환경 / Environment
20
+ placeholder: "macOS 15 (M3) · Ubuntu 24.04 · Windows 11 / uv 0.x / mock or real mode"
21
+ validations:
22
+ required: true
@@ -0,0 +1,11 @@
1
+ name: 질문 / Question
2
+ description: 이해가 안 되는 부분이나 더 알고 싶은 점 / Something unclear or worth explaining
3
+ labels: [question]
4
+ body:
5
+ - type: textarea
6
+ id: question
7
+ attributes:
8
+ label: 질문 / Question
9
+ description: README의 어느 부분(절 제목)에 대한 질문인지 알려 주세요. / Which README section is this about?
10
+ validations:
11
+ required: true
@@ -0,0 +1,21 @@
1
+ # Offline tests only: the mock target and recorded guard answers need no keys, models or network.
2
+ name: ci
3
+ on:
4
+ push:
5
+ pull_request:
6
+ schedule:
7
+ - cron: "17 3 * * 1" # weekly, to catch breakage from runtime or dependency changes
8
+ workflow_dispatch:
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.11", "3.12", "3.13"]
16
+ steps:
17
+ - uses: actions/checkout@v4.4.0
18
+ - uses: astral-sh/setup-uv@v10.3.3
19
+ - run: uv python install ${{ matrix.python-version }}
20
+ - run: uv sync --locked --python ${{ matrix.python-version }}
21
+ - run: uv run --python ${{ matrix.python-version }} pytest -q
@@ -0,0 +1,44 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ .venv/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ .mypy_cache/
8
+ *.egg-info/
9
+
10
+ # Node
11
+ node_modules/
12
+ dist/
13
+ .next/
14
+
15
+ # 실행 산출물·모델·데이터 캐시
16
+ runs/
17
+ outputs/
18
+ .cache/
19
+ *.safetensors
20
+ *.gguf
21
+ *.bin
22
+
23
+ # 환경·비밀
24
+ .env
25
+ .env.*
26
+ !.env.example
27
+
28
+ # OS·에디터
29
+ .DS_Store
30
+ .vscode/
31
+ .idea/
32
+
33
+ # Flutter·Dart
34
+ .dart_tool/
35
+ build/
36
+ .flutter-plugins
37
+ .flutter-plugins-dependencies
38
+ coverage/
39
+
40
+ # guarddiff output folders created by the README commands
41
+ guarddiff-demo/
42
+ guarddiff-out/
43
+ out/
44
+ myeval/
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses semantic versioning.
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.1.0] - 2026-11-11
9
+
10
+ ### Added
11
+ - `guarddiff run | report | gate | demo | init` commands.
12
+ - Seven outcomes that separate guard blocks from the model's own refusals, plus `indeterminate`.
13
+ - Metrics: ASR, over-block rate, Wilson 95% intervals, exact McNemar test, latency p50/p95, guard cost.
14
+ - Guards: `regex`, `python`, `replay`, `hf-qwen3guard` (optional extra). Targets: `mock`, `python`, `openai`.
15
+ - `gate` fails by default when any item is indeterminate (`--allow-indeterminate` to opt out); the `run` table marks such variants with `!`.
16
+ - Resume re-runs only variants whose guard, target, judge or latency-mode config changed. Pairs that ended `indeterminate` are always re-run (`retry N indeterminate pairs`), so fixing the cause and running again is enough.
17
+ - `run --only` keeps the stored results of the variants it did not run (`kept N pairs …`).
18
+ - `gate` exits 2 when `--allow-indeterminate` and `--max-indeterminate` are combined; allowing indeterminate items prints a note. `report --format md` and `report.html` mark variants with indeterminate items with `!` and a warning line.
19
+ - Resumable `results.jsonl`, `summary.json`, single-file `report.html`, Markdown summary.
20
+ - Bundled 18-prompt English/Korean set (CC0-1.0) and offline, recorded-replay and live examples.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LeeGyeongPil
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.