compactbench 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 (90) hide show
  1. compactbench-0.1.0/.gitignore +98 -0
  2. compactbench-0.1.0/CHANGELOG.md +136 -0
  3. compactbench-0.1.0/LICENSE +201 -0
  4. compactbench-0.1.0/PKG-INFO +161 -0
  5. compactbench-0.1.0/README.md +111 -0
  6. compactbench-0.1.0/benchmarks/public/elite_practice/buried_constraint_v1_1.yaml +66 -0
  7. compactbench-0.1.0/benchmarks/public/elite_practice/buried_constraint_v1_2.yaml +61 -0
  8. compactbench-0.1.0/benchmarks/public/elite_practice/buried_constraint_v1_3.yaml +71 -0
  9. compactbench-0.1.0/benchmarks/public/elite_practice/buried_constraint_v1_4.yaml +61 -0
  10. compactbench-0.1.0/benchmarks/public/elite_practice/buried_constraint_v1_5.yaml +67 -0
  11. compactbench-0.1.0/benchmarks/public/elite_practice/decision_override_v1_1.yaml +63 -0
  12. compactbench-0.1.0/benchmarks/public/elite_practice/decision_override_v1_2.yaml +76 -0
  13. compactbench-0.1.0/benchmarks/public/elite_practice/decision_override_v1_3.yaml +72 -0
  14. compactbench-0.1.0/benchmarks/public/elite_practice/decision_override_v1_4.yaml +71 -0
  15. compactbench-0.1.0/benchmarks/public/elite_practice/decision_override_v1_5.yaml +63 -0
  16. compactbench-0.1.0/benchmarks/public/elite_practice/entity_confusion_v1_1.yaml +64 -0
  17. compactbench-0.1.0/benchmarks/public/elite_practice/entity_confusion_v1_2.yaml +69 -0
  18. compactbench-0.1.0/benchmarks/public/elite_practice/entity_confusion_v1_3.yaml +61 -0
  19. compactbench-0.1.0/benchmarks/public/elite_practice/entity_confusion_v1_4.yaml +66 -0
  20. compactbench-0.1.0/benchmarks/public/elite_practice/entity_confusion_v1_5.yaml +71 -0
  21. compactbench-0.1.0/benchmarks/public/hard/.gitkeep +0 -0
  22. compactbench-0.1.0/benchmarks/public/starter/buried_constraint_starter_v1.yaml +68 -0
  23. compactbench-0.1.0/benchmarks/public/starter/decision_override_starter_v1.yaml +63 -0
  24. compactbench-0.1.0/benchmarks/public/starter/entity_confusion_starter_v1.yaml +67 -0
  25. compactbench-0.1.0/benchmarks/schemas/template-v1.json +135 -0
  26. compactbench-0.1.0/docs/architecture/_legacy-saas/README.md +111 -0
  27. compactbench-0.1.0/pyproject.toml +166 -0
  28. compactbench-0.1.0/src/compactbench/__init__.py +10 -0
  29. compactbench-0.1.0/src/compactbench/__main__.py +6 -0
  30. compactbench-0.1.0/src/compactbench/cli.py +343 -0
  31. compactbench-0.1.0/src/compactbench/compactors/__init__.py +47 -0
  32. compactbench-0.1.0/src/compactbench/compactors/_state_parser.py +118 -0
  33. compactbench-0.1.0/src/compactbench/compactors/_utils.py +37 -0
  34. compactbench-0.1.0/src/compactbench/compactors/base.py +38 -0
  35. compactbench-0.1.0/src/compactbench/compactors/errors.py +11 -0
  36. compactbench-0.1.0/src/compactbench/compactors/hierarchical_summary.py +113 -0
  37. compactbench-0.1.0/src/compactbench/compactors/hybrid_ledger.py +115 -0
  38. compactbench-0.1.0/src/compactbench/compactors/naive_summary.py +54 -0
  39. compactbench-0.1.0/src/compactbench/compactors/structured_state.py +64 -0
  40. compactbench-0.1.0/src/compactbench/config.py +36 -0
  41. compactbench-0.1.0/src/compactbench/contracts/__init__.py +41 -0
  42. compactbench-0.1.0/src/compactbench/contracts/artifact.py +49 -0
  43. compactbench-0.1.0/src/compactbench/contracts/case.py +81 -0
  44. compactbench-0.1.0/src/compactbench/contracts/result.py +79 -0
  45. compactbench-0.1.0/src/compactbench/dsl/__init__.py +66 -0
  46. compactbench-0.1.0/src/compactbench/dsl/errors.py +23 -0
  47. compactbench-0.1.0/src/compactbench/dsl/generators.py +243 -0
  48. compactbench-0.1.0/src/compactbench/dsl/models.py +107 -0
  49. compactbench-0.1.0/src/compactbench/dsl/parser.py +55 -0
  50. compactbench-0.1.0/src/compactbench/dsl/substitution.py +32 -0
  51. compactbench-0.1.0/src/compactbench/dsl/validator.py +97 -0
  52. compactbench-0.1.0/src/compactbench/engine/__init__.py +29 -0
  53. compactbench-0.1.0/src/compactbench/engine/difficulty.py +54 -0
  54. compactbench-0.1.0/src/compactbench/engine/distractors.py +69 -0
  55. compactbench-0.1.0/src/compactbench/engine/errors.py +11 -0
  56. compactbench-0.1.0/src/compactbench/engine/generation.py +96 -0
  57. compactbench-0.1.0/src/compactbench/engine/seeds.py +31 -0
  58. compactbench-0.1.0/src/compactbench/engine/transcript.py +84 -0
  59. compactbench-0.1.0/src/compactbench/leaderboard/__init__.py +38 -0
  60. compactbench-0.1.0/src/compactbench/leaderboard/errors.py +11 -0
  61. compactbench-0.1.0/src/compactbench/leaderboard/projection.py +103 -0
  62. compactbench-0.1.0/src/compactbench/leaderboard/qualification.py +90 -0
  63. compactbench-0.1.0/src/compactbench/leaderboard/ranking.py +71 -0
  64. compactbench-0.1.0/src/compactbench/providers/__init__.py +52 -0
  65. compactbench-0.1.0/src/compactbench/providers/_retry.py +48 -0
  66. compactbench-0.1.0/src/compactbench/providers/base.py +44 -0
  67. compactbench-0.1.0/src/compactbench/providers/errors.py +15 -0
  68. compactbench-0.1.0/src/compactbench/providers/google_ai_studio.py +112 -0
  69. compactbench-0.1.0/src/compactbench/providers/groq.py +95 -0
  70. compactbench-0.1.0/src/compactbench/providers/mock.py +53 -0
  71. compactbench-0.1.0/src/compactbench/providers/ollama.py +100 -0
  72. compactbench-0.1.0/src/compactbench/py.typed +0 -0
  73. compactbench-0.1.0/src/compactbench/runner/__init__.py +53 -0
  74. compactbench-0.1.0/src/compactbench/runner/_resolver.py +57 -0
  75. compactbench-0.1.0/src/compactbench/runner/continuation.py +78 -0
  76. compactbench-0.1.0/src/compactbench/runner/cycle.py +67 -0
  77. compactbench-0.1.0/src/compactbench/runner/errors.py +15 -0
  78. compactbench-0.1.0/src/compactbench/runner/evaluation.py +71 -0
  79. compactbench-0.1.0/src/compactbench/runner/persistence.py +227 -0
  80. compactbench-0.1.0/src/compactbench/runner/run.py +257 -0
  81. compactbench-0.1.0/src/compactbench/scoring/__init__.py +48 -0
  82. compactbench-0.1.0/src/compactbench/scoring/checks.py +92 -0
  83. compactbench-0.1.0/src/compactbench/scoring/compression.py +66 -0
  84. compactbench-0.1.0/src/compactbench/scoring/contradictions.py +70 -0
  85. compactbench-0.1.0/src/compactbench/scoring/drift.py +30 -0
  86. compactbench-0.1.0/src/compactbench/scoring/errors.py +7 -0
  87. compactbench-0.1.0/src/compactbench/scoring/scorer.py +77 -0
  88. compactbench-0.1.0/src/compactbench/utils/__init__.py +1 -0
  89. compactbench-0.1.0/submissions/README.md +34 -0
  90. compactbench-0.1.0/submissions/_template/README.md +17 -0
@@ -0,0 +1,98 @@
1
+ # Environment
2
+ .env
3
+ .env.local
4
+ .env.*.local
5
+ !.env.example
6
+
7
+ # Secrets
8
+ *.pem
9
+ *.key
10
+ *.crt
11
+ !tests/fixtures/**/*.pem
12
+
13
+ # Python
14
+ __pycache__/
15
+ *.py[cod]
16
+ *$py.class
17
+ *.so
18
+ .Python
19
+ build/
20
+ dist/
21
+ *.egg-info/
22
+ *.egg
23
+ MANIFEST
24
+ .installed.cfg
25
+ pip-log.txt
26
+ pip-delete-this-directory.txt
27
+
28
+ # Virtualenvs
29
+ .venv/
30
+ venv/
31
+ env/
32
+ ENV/
33
+
34
+ # uv
35
+ .uv-cache/
36
+ .uv/
37
+
38
+ # Testing & coverage
39
+ .pytest_cache/
40
+ .hypothesis/
41
+ .coverage
42
+ .coverage.*
43
+ htmlcov/
44
+ coverage.xml
45
+ *.cover
46
+ .tox/
47
+ .nox/
48
+
49
+ # Type checkers
50
+ .mypy_cache/
51
+ .pyre/
52
+ .pytype/
53
+ .pyright-cache/
54
+
55
+ # Linting
56
+ .ruff_cache/
57
+
58
+ # Notebooks
59
+ .ipynb_checkpoints/
60
+
61
+ # Build artifacts
62
+ *.whl
63
+
64
+ # Docs — MkDocs build output
65
+ site/
66
+
67
+ # IDE
68
+ .idea/
69
+ .vscode/*
70
+ !.vscode/extensions.json
71
+ !.vscode/settings.example.json
72
+ *.swp
73
+ *.swo
74
+
75
+ # Claude Code local state
76
+ .claude/
77
+
78
+ # OS
79
+ .DS_Store
80
+ Thumbs.db
81
+ desktop.ini
82
+
83
+ # Local state
84
+ data/
85
+ results/
86
+ runs/
87
+ *.jsonl.gz
88
+
89
+ # Hidden benchmark content — never commit
90
+ benchmarks/hidden/
91
+ benchmarks/**/_private/
92
+
93
+ # Generated
94
+ *.generated.py
95
+
96
+ # Logs
97
+ logs/
98
+ *.log
@@ -0,0 +1,136 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] — 2026-04-17
11
+
12
+ First public release. The full v1 stack: DSL parser, case-generation engine,
13
+ scoring engine, mock + real providers, built-in compactors, end-to-end runner,
14
+ submission pipeline with public leaderboard, and 15 Elite practice templates
15
+ across three launch families.
16
+
17
+ ### Added
18
+ - Initial project scaffold: Python package layout, CLI entrypoint, core ABCs
19
+ - Apache 2.0 license
20
+ - Contributor guide and code of conduct
21
+ - MkDocs documentation skeleton
22
+ - GitHub Actions CI workflow
23
+ - Template DSL (WO-002):
24
+ - YAML + Handlebars-style `{{variable}}` substitution
25
+ - Pydantic models for `TemplateDefinition` and sub-structures
26
+ - Seeded generator registry: `person_name`, `action_phrase`, `project_noun`,
27
+ `org_name`, `date_iso`, `amount_usd`, `product_sku`
28
+ - SHA-256-based sub-seed derivation for reordering-stable determinism
29
+ - Semantic validator for references, generators, and duplicate names
30
+ - JSON Schema at `benchmarks/schemas/template-v1.json`
31
+ - Three starter templates: `buried_constraint_starter_v1`,
32
+ `decision_override_starter_v1`, `entity_confusion_starter_v1`
33
+ - `compactbench suites list` command wired up
34
+ - Elite v1 public practice templates (WO-009):
35
+ - 15 templates in `benchmarks/public/elite_practice/`, 5 variations each for
36
+ the three launch families: `buried_constraint_v1`, `decision_override_v1`,
37
+ `entity_confusion_v1`
38
+ - Variations within each family probe different failure modes (e.g.,
39
+ indirect phrasing, double constraints, negative examples, sandwich
40
+ layouts for `buried_constraint`; simple/three-way/partial/late/meta-reset
41
+ overrides for `decision_override`; 2-person/3-person/same-role/
42
+ observer-vs-owner/shared-project for `entity_confusion`)
43
+ - Difficulty policy scales distractor turns 4 → 8 → 16 → 32 from easy to
44
+ elite, matching the ranked set's expected adversarial load
45
+ - `compactbench suites list` now shows `elite_practice` with 15 templates
46
+ across 3 families
47
+ - `docs/governance/elite-versions.md` — active-version table, version
48
+ policy, retirement policy, anti-gaming reminders, v1 changelog
49
+ - 9 new unit tests verify every template parses, validates, and generates
50
+ at every configured difficulty
51
+ - Hidden ranked set (20 per family in `compactbench/compactbench-hidden`)
52
+ lands in a follow-up so it doesn't commingle public and hidden content
53
+ - Submission pipeline + leaderboard (WO-008):
54
+ - `src/compactbench/leaderboard/` — `elite_score` computation, tie-breakers,
55
+ qualification floors (with rejection reasons), `RunResult` → public
56
+ `LeaderboardRow` projection, best-first rank assignment
57
+ - `.github/workflows/evaluate-submission.yml` — runs on GitHub-hosted
58
+ `ubuntu-latest`, gated on a maintainer-applied `evaluate` label; clones PR
59
+ head, installs submission deps, runs `compactbench run`, posts score
60
+ comment, uploads results artifact
61
+ - `.github/workflows/update-leaderboard.yml` — on push under `submissions/**`
62
+ rebuilds `docs/data/leaderboard.json` via `scripts/rebuild_leaderboard.py`
63
+ and commits; triggers the docs Pages redeploy
64
+ - `docs/leaderboard.md` — live table rendered client-side from
65
+ `data/leaderboard.json`, grouped by `(benchmark_version, target_model)`
66
+ - `submissions/_template/` — copy-paste scaffold (method.py, config.yaml,
67
+ requirements.txt, README.md)
68
+ - `compactbench submit` prints a submission checklist (full PR automation
69
+ stays server-side since hidden-set evaluation requires repo secrets)
70
+ - Runner infra decision updated: v1 uses GitHub-hosted runners, not
71
+ self-hosted; migration path preserved
72
+ - End-to-end runner (WO-007):
73
+ - `compactbench run --method <spec> --suite <key> --provider <k> --model <m>`
74
+ orchestrates: load suite → generate cases → per case iterate drift cycles
75
+ (compact → evaluate → score) → aggregate → persist results.jsonl
76
+ - Event-log JSONL format: `run_start`, one `case_complete` per case
77
+ streamed, final `run_end` with aggregates
78
+ - `--resume` continues from an existing output file; rejects with
79
+ `ResumeError` if run parameters differ
80
+ - `compactbench score --results` now pretty-prints the run summary from the
81
+ persisted events (reads, not re-scores)
82
+ - `--method` supports `built-in:<key>` and `<path.py>:<ClassName>`
83
+ (loads user compactors from file paths, verifies `Compactor` subclass)
84
+ - Drift cycles extend the transcript with seeded continuation turns; the
85
+ model's continuation response uses only the previous artifact as context
86
+ (that is the drift vector measured)
87
+ - Per-case `CaseResult` captures all cycles, case-level score, and
88
+ `drift_resistance`; run-level aggregates cover overall / drift /
89
+ constraint retention / contradiction / compression
90
+ - Real model providers (WO-006):
91
+ - `GroqProvider` — Llama 3.3 70B, Kimi K2, etc. via the `groq` SDK
92
+ - `GoogleAIStudioProvider` — Gemini 2.0 Flash etc. via the `google-genai` SDK
93
+ - `OllamaProvider` — local models via the `ollama` SDK
94
+ - Shared `retry_with_backoff` async helper with exponential + capped delay
95
+ - Per-provider retry predicates: Groq retries `RateLimitError` /
96
+ `APITimeoutError` / `APIConnectionError`; Google retries 429s and 5xxs;
97
+ Ollama retries `httpx.TimeoutException` / `ConnectError` + 429/5xx
98
+ `ResponseError`
99
+ - Config via `COMPACTBENCH_GROQ_API_KEY`,
100
+ `COMPACTBENCH_GOOGLE_AI_STUDIO_API_KEY`, `COMPACTBENCH_OLLAMA_BASE_URL`
101
+ - Cross-provider contract tests ensure identical response shape
102
+ - Real provider SDKs stay optional (`pip install 'compactbench[providers]'`);
103
+ importing a provider without its SDK raises a clean `ProviderError`
104
+ - Built-in compactors + mock provider (WO-005):
105
+ - Four baselines in `compactbench.compactors`: `naive-summary`,
106
+ `structured-state`, `hierarchical-summary`, `hybrid-ledger`
107
+ - All inherit async `Compactor` ABC bound to `(provider, model)` at
108
+ construction
109
+ - Shared JSON → `StructuredState` parser with code-fence stripping and
110
+ lenient field coercion
111
+ - `MockProvider` with scripted-sequence + default-response modes and call
112
+ recording for tests
113
+ - Registries: `list_built_ins()` / `get_built_in()` for compactors and
114
+ `list_providers()` / `get_provider_cls()` for providers
115
+ - `compactbench providers list` wired up
116
+ - Scoring engine (WO-004):
117
+ - Per-item checks: `contains_normalized`, `forbidden_absent`, `exact`, `set_match`
118
+ - Weighted cycle aggregation per decisions.md §B3 item weights
119
+ - Contradiction detection (item-aware: recall items excluded)
120
+ - Compression ratio via `cl100k_base` tokenizer
121
+ - Drift resistance from cross-cycle scores (clamped to `[0, 1]`)
122
+ - `compactbench score --results results.jsonl` wired up (reads JSONL of
123
+ `{case, artifact, responses}` records, prints per-case + aggregate summary)
124
+ - Case generation engine (WO-003):
125
+ - `compactbench.engine.generate_case` — pure function of
126
+ (template, seed, difficulty) → `GeneratedCase`
127
+ - Case-seed derivation from `(suite_version, seed_group, case_slot)` via SHA-256
128
+ - Difficulty policy application (distractor count, paraphrase depth,
129
+ override timing exposed as `difficulty.*` bindings)
130
+ - Distractor-turn generator (seeded, alternating user/assistant)
131
+ - Variable substitution across transcript, ground truth, and evaluation items
132
+ - `compactbench generate --template <key> --seed <int>` command wired up
133
+ - Three regression fixtures pinning the starter templates at seed=42, medium
134
+
135
+ [Unreleased]: https://github.com/compactbench/compactbench/compare/v0.1.0...HEAD
136
+ [0.1.0]: https://github.com/compactbench/compactbench/releases/tag/v0.1.0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 CompactBench contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: compactbench
3
+ Version: 0.1.0
4
+ Summary: Open benchmark for AI conversation compaction methods
5
+ Project-URL: Homepage, https://compactbench.github.io/compactbench
6
+ Project-URL: Repository, https://github.com/compactbench/compactbench
7
+ Project-URL: Documentation, https://compactbench.github.io/compactbench
8
+ Project-URL: Issues, https://github.com/compactbench/compactbench/issues
9
+ Project-URL: Changelog, https://github.com/compactbench/compactbench/blob/main/CHANGELOG.md
10
+ Author: CompactBench contributors
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: ai,benchmark,compaction,context,drift,evaluation,llm,memory,summarization
14
+ Classifier: Development Status :: 2 - Pre-Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: Apache Software License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: httpx>=0.27
27
+ Requires-Dist: jsonschema>=4.22
28
+ Requires-Dist: pydantic-settings>=2.3
29
+ Requires-Dist: pydantic>=2.7
30
+ Requires-Dist: rich>=13.7
31
+ Requires-Dist: ruamel-yaml>=0.18
32
+ Requires-Dist: tiktoken>=0.7
33
+ Requires-Dist: typer>=0.12
34
+ Provides-Extra: dev
35
+ Requires-Dist: hypothesis>=6.100; extra == 'dev'
36
+ Requires-Dist: pre-commit>=3.7; extra == 'dev'
37
+ Requires-Dist: pyright>=1.1.370; extra == 'dev'
38
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
39
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
40
+ Requires-Dist: pytest>=8.2; extra == 'dev'
41
+ Requires-Dist: ruff>=0.5; extra == 'dev'
42
+ Provides-Extra: docs
43
+ Requires-Dist: mkdocs-include-markdown-plugin>=6.2; extra == 'docs'
44
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
45
+ Provides-Extra: providers
46
+ Requires-Dist: google-genai>=0.3; extra == 'providers'
47
+ Requires-Dist: groq>=0.9; extra == 'providers'
48
+ Requires-Dist: ollama>=0.3; extra == 'providers'
49
+ Description-Content-Type: text/markdown
50
+
51
+ # CompactBench
52
+
53
+ > Open benchmark for AI conversation compaction methods.
54
+
55
+ [![PyPI version](https://img.shields.io/pypi/v/compactbench.svg)](https://pypi.org/project/compactbench/)
56
+ [![Python](https://img.shields.io/pypi/pyversions/compactbench.svg)](https://pypi.org/project/compactbench/)
57
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
58
+ [![CI](https://github.com/compactbench/compactbench/actions/workflows/ci.yml/badge.svg)](https://github.com/compactbench/compactbench/actions/workflows/ci.yml)
59
+
60
+ CompactBench measures whether language models still behave correctly after long conversation history is replaced with a compacted representation. It runs adversarial, deterministic, multi-cycle benchmarks and publishes ranked results on a public leaderboard.
61
+
62
+ - **Deterministic generation** — same template + seed + version always yields the same case
63
+ - **Hidden ranked set** — public practice cases for development, hidden templates for ranked scoring
64
+ - **Multi-cycle drift** — methods are evaluated across repeated compact → continue → compact loops
65
+ - **State-fidelity scoring** — correctness of retained decisions, constraints, and entities, not output style
66
+ - **Versioned everywhere** — benchmark suite, template, scorer, model, and method versions are recorded with every result
67
+
68
+ ## Install
69
+
70
+ ```bash
71
+ pip install compactbench
72
+ ```
73
+
74
+ Or with uv (recommended for development):
75
+
76
+ ```bash
77
+ uv pip install compactbench
78
+ ```
79
+
80
+ ## Quickstart
81
+
82
+ Run a built-in compactor against the starter suite using a local Ollama model:
83
+
84
+ ```bash
85
+ compactbench run \
86
+ --method built-in:hybrid-ledger \
87
+ --suite starter \
88
+ --provider ollama \
89
+ --model llama3.2
90
+ ```
91
+
92
+ Generate a single case deterministically for inspection:
93
+
94
+ ```bash
95
+ compactbench generate --template buried_constraint_v1 --seed 42
96
+ ```
97
+
98
+ Score an existing results file:
99
+
100
+ ```bash
101
+ compactbench score --results results.jsonl
102
+ ```
103
+
104
+ ## Writing your own compactor
105
+
106
+ Implement the `Compactor` interface and register it.
107
+
108
+ ```python
109
+ from compactbench.compactors import Compactor
110
+ from compactbench.contracts import CompactionArtifact, Transcript
111
+
112
+ class MyCompactor(Compactor):
113
+ name = "my-method"
114
+ version = "0.1.0"
115
+
116
+ def compact(self, transcript: Transcript, config: dict) -> CompactionArtifact:
117
+ ...
118
+ ```
119
+
120
+ Then run:
121
+
122
+ ```bash
123
+ compactbench run --method path/to/my_compactor.py:MyCompactor --suite elite_practice
124
+ ```
125
+
126
+ See [docs/writing-a-compactor.md](docs/writing-a-compactor.md) for full details.
127
+
128
+ ## Leaderboard
129
+
130
+ The public leaderboard is at **[https://compactbench.github.io/compactbench/leaderboard](https://compactbench.github.io/compactbench/leaderboard/)**.
131
+
132
+ Submissions are evaluated against **hidden** ranked benchmark cases by a maintainer-operated runner. To submit:
133
+
134
+ 1. Write and test your compactor locally against `elite_practice`.
135
+ 2. Open a PR to [`submissions/`](submissions/) with your method source and config.
136
+ 3. A maintainer runs it against the hidden set and merges if it qualifies.
137
+
138
+ See [docs/submitting.md](docs/submitting.md) for the full submission protocol.
139
+
140
+ ## Project status
141
+
142
+ **v0.1.0 launch-ready.** All ten workorders from the implementation roadmap have landed:
143
+
144
+ - Core: DSL parser, case generation, scoring engine, mock + real providers (Groq / Google AI Studio / Ollama)
145
+ - Methods: four built-in compactors (`naive-summary`, `structured-state`, `hierarchical-summary`, `hybrid-ledger`)
146
+ - Runtime: end-to-end `compactbench run` with drift cycles, JSONL event log, `--resume`
147
+ - Leaderboard: PR-based submission workflow on GitHub-hosted runners, static site fed by a qualification + ranking core
148
+ - Content: 15 public Elite practice templates + 15 hidden ranked templates across three launch families
149
+ - Release: PyPI trusted-publishing workflow wired up; tag `v0.1.0` to ship
150
+
151
+ See [CHANGELOG.md](CHANGELOG.md) for the full breakdown. Post-launch work (hidden-set content expansion, additional template families, shadow evaluation automation, custom domain) is tracked via GitHub issues.
152
+
153
+ ## Contributing
154
+
155
+ Bug reports, template proposals, and new compactors are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
156
+
157
+ Please also read our [Code of Conduct](CODE_OF_CONDUCT.md).
158
+
159
+ ## License
160
+
161
+ Apache License 2.0 — see [LICENSE](LICENSE).