contextpress 0.5.4__tar.gz → 0.5.5__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 (61) hide show
  1. contextpress-0.5.5/AGENTS.md +45 -0
  2. contextpress-0.5.5/AUDIT.md +89 -0
  3. {contextpress-0.5.4 → contextpress-0.5.5}/CHANGELOG.md +5 -0
  4. {contextpress-0.5.4 → contextpress-0.5.5}/PKG-INFO +2 -1
  5. {contextpress-0.5.4 → contextpress-0.5.5}/README.md +1 -0
  6. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/__init__.py +1 -1
  7. {contextpress-0.5.4 → contextpress-0.5.5}/pyproject.toml +2 -2
  8. {contextpress-0.5.4 → contextpress-0.5.5}/.gitignore +0 -0
  9. {contextpress-0.5.4 → contextpress-0.5.5}/CITATION.cff +0 -0
  10. {contextpress-0.5.4 → contextpress-0.5.5}/CONTRIBUTING.md +0 -0
  11. {contextpress-0.5.4 → contextpress-0.5.5}/LICENSE +0 -0
  12. {contextpress-0.5.4 → contextpress-0.5.5}/NOTICE +0 -0
  13. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/_bootstrap.py +0 -0
  14. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/compression.py +0 -0
  15. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/core.py +0 -0
  16. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/llm/__init__.py +0 -0
  17. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/llm/_helpers.py +0 -0
  18. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/llm/adapters.py +0 -0
  19. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/llm/base.py +0 -0
  20. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/models.py +0 -0
  21. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/normalizer.py +0 -0
  22. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/pipeline.py +0 -0
  23. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/profiles.py +0 -0
  24. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/py.typed +0 -0
  25. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/registry.py +0 -0
  26. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/stats.py +0 -0
  27. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/strategies/__init__.py +0 -0
  28. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/strategies/base.py +0 -0
  29. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/strategies/budget.py +0 -0
  30. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/strategies/filler.py +0 -0
  31. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/strategies/recency.py +0 -0
  32. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/strategies/repetition.py +0 -0
  33. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/strategies/resolution.py +0 -0
  34. {contextpress-0.5.4 → contextpress-0.5.5}/contextpress/warnings_capture.py +0 -0
  35. {contextpress-0.5.4 → contextpress-0.5.5}/examples/agent_pipeline.py +0 -0
  36. {contextpress-0.5.4 → contextpress-0.5.5}/examples/benchmark_presets.py +0 -0
  37. {contextpress-0.5.4 → contextpress-0.5.5}/examples/dry_run_preview.py +0 -0
  38. {contextpress-0.5.4 → contextpress-0.5.5}/examples/estimate_and_stats.py +0 -0
  39. {contextpress-0.5.4 → contextpress-0.5.5}/examples/llm_tier_claude.py +0 -0
  40. {contextpress-0.5.4 → contextpress-0.5.5}/examples/llm_tier_gemini.py +0 -0
  41. {contextpress-0.5.4 → contextpress-0.5.5}/examples/llm_tier_ollama.py +0 -0
  42. {contextpress-0.5.4 → contextpress-0.5.5}/examples/llm_tier_openai.py +0 -0
  43. {contextpress-0.5.4 → contextpress-0.5.5}/examples/pick_preset.py +0 -0
  44. {contextpress-0.5.4 → contextpress-0.5.5}/tests/__init__.py +0 -0
  45. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_budget.py +0 -0
  46. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_filler.py +0 -0
  47. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_llm_helpers.py +0 -0
  48. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_models.py +0 -0
  49. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_normalizer.py +0 -0
  50. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_pipeline.py +0 -0
  51. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_recency.py +0 -0
  52. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_repetition.py +0 -0
  53. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_resolution.py +0 -0
  54. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_stats.py +0 -0
  55. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_v03.py +0 -0
  56. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_v04.py +0 -0
  57. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_v05.py +0 -0
  58. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_v051.py +0 -0
  59. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_v052.py +0 -0
  60. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_v053.py +0 -0
  61. {contextpress-0.5.4 → contextpress-0.5.5}/tests/test_v054.py +0 -0
@@ -0,0 +1,45 @@
1
+ # Notes for agents and contributors
2
+
3
+ ## Branches
4
+
5
+ - **`dev`** — default working branch; all feature work and fixes land here first.
6
+ - **`main`** — release branch; merge from `dev` when cutting a PyPI release.
7
+
8
+ Always `git checkout dev` before making changes in this repo.
9
+
10
+ ## Where things live
11
+
12
+ | Area | Path |
13
+ |------|------|
14
+ | Public API | `contextpress/core.py` → `ContextManager` |
15
+ | I/O formats | `contextpress/normalizer.py` |
16
+ | Stage presets | `contextpress/compression.py` (`STAGE_ORDER`, `VALID_STAGES`) |
17
+ | Tier 1 stages | `contextpress/strategies/*.py` |
18
+ | Tier 2 | `contextpress/llm/` (`LLMBackend`, `adapters.py`) |
19
+ | Custom stages | `contextpress/registry.py` + `ContextManager.register_stage()` |
20
+ | Orchestration | `contextpress/pipeline.py` (behavior contract at top of file) |
21
+ | Profiles | `contextpress/profiles.py` |
22
+
23
+ `contextpress/__init__.py` lazy-loads `ContextManager` so `from contextpress.models import Turn` avoids pulling optional Tier-2 / sumy import chains when possible.
24
+
25
+ ## Commands
26
+
27
+ ```bash
28
+ pip install -e ".[dev]"
29
+ pytest tests -q
30
+ ```
31
+
32
+ ## Invariants (non-negotiable)
33
+
34
+ See the numbered block at the top of `contextpress/pipeline.py`. Tests assume Tier 1 is deterministic (no live LLM calls in `tests/`).
35
+
36
+ ## Stabilization backlog
37
+
38
+ See [`AUDIT.md`](AUDIT.md) for pre-0.6.0 findings (contract gaps, refactors, fixture gaps). Prefer low-risk items from that backlog before adding stages or new dependencies.
39
+
40
+ ## Adding a stage
41
+
42
+ 1. Subclass `BaseStrategy`, implement `process`.
43
+ 2. Register it in `Pipeline._build_strategy`.
44
+ 3. Add the name to `compression.STAGE_ORDER` and presets if it should be user-selectable.
45
+ 4. Extend `profiles.Profile` / `PROFILES` if it needs per-type defaults.
@@ -0,0 +1,89 @@
1
+ # Pre-0.6.0 stabilization audit (0.5.5)
2
+
3
+ Recorded after the 0.5.x ergonomics arc. This is the Phase 1 deliverable:
4
+ findings + backlog for Phases 2–4. Behavior changes are deferred unless marked
5
+ **fix now**.
6
+
7
+ ## Architecture (summary)
8
+
9
+ ```
10
+ ContextManager (core.py)
11
+ → normalize_messages (normalizer.py)
12
+ → apply_stage_selection (compression.py)
13
+ → Pipeline.run (pipeline.py)
14
+ → filler → repetition → resolution → recency → budget
15
+ → optional Tier 2 LLM
16
+ → denormalize_output
17
+ ```
18
+
19
+ Profiles: `chat`, `rag_doc`, `agent`. Tier 1 deps: nltk, scikit-learn, sumy, tiktoken.
20
+
21
+ ## Findings
22
+
23
+ ### Contract / correctness
24
+
25
+ | ID | Severity | Finding | Action |
26
+ |----|----------|---------|--------|
27
+ | C1 | Medium | Invariant 1 says system turns are untouched; `BudgetStrategy` truncates system as last resort (`budget.py`) | Document in contract (Phase 2) or change behavior later |
28
+ | C2 | Medium | LLM dedup failures in `Pipeline._run_llm_tier` fall back silently (no warning); summarize path warns | Add warning (Phase 2) |
29
+ | C3 | Medium | Filler drops ack phrases like `"sounds good"` before resolution can use them (`filler.py` / `resolution.py`) | Document + fixture test (Phases 3–4) |
30
+ | C4 | Low | `Turn.importance` / `Turn.resolved` set by resolution but unused by pipeline | Leave; optional cleanup later |
31
+
32
+ ### Duplication / maintainability (Phase 2)
33
+
34
+ | ID | Finding | Action |
35
+ |----|---------|--------|
36
+ | R1 | TF-IDF + cosine similarity copied in `repetition.py`, `recency.py`, `resolution.py` | Extract shared helper |
37
+ | R2 | Token counting duplicated in `stats.py` and `budget.py` | Budget uses `stats` helpers |
38
+ | R3 | `_bootstrap.py` downloads unused `stopwords`; warning mentions recency (doesn't use NLTK) | Trim packages; fix message |
39
+ | R4 | Strategies use ad hoc `deepcopy` vs `clone_turn` | Prefer `clone_turn` where safe |
40
+
41
+ ### Test / fixture gaps (Phases 3–4)
42
+
43
+ | ID | Gap |
44
+ |----|-----|
45
+ | T1 | No assert that input `messages` are immutable after `compress()` |
46
+ | T2 | No end-to-end `rag_doc` / richer `agent` pipeline tests |
47
+ | T3 | Normalizer edge cases: `None`, bad types, tuple skip, LangChain turn-count mismatch |
48
+ | T4 | No offline real-chat fixtures under `tests/fixtures/` |
49
+ | T5 | Cross-stage filler → resolution interaction untested |
50
+
51
+ ### Normalizer fragility (document; fix only if fixtures break)
52
+
53
+ | ID | Area |
54
+ |----|------|
55
+ | N1 | LangChain detection heuristic on first list element |
56
+ | N2 | Dict/tuple skips change turn count vs input |
57
+ | N3 | New turns (RESOLVED / LLM summary) lose `_original_dict` keys |
58
+ | N4 | `apply_text_to_turn` only replaces the first text block |
59
+
60
+ ### Deferred (not in 0.5.x stabilization)
61
+
62
+ - Resolution / normalizer rewrites
63
+ - New pipeline stages
64
+ - New LLM backends
65
+ - New hard dependencies
66
+ - Changing stage order without a proven bug
67
+
68
+ ## Phase plan
69
+
70
+ | Phase | Version | Scope |
71
+ |-------|---------|--------|
72
+ | 1 Analysis | **0.5.5** | This document + backlog |
73
+ | 2 Refactor | **0.5.6** | R1–R3, C1 doc, C2 warning (no semantic stage changes) |
74
+ | 3 Fixtures | **0.5.7** | Offline chat samples + smoke/invariant tests |
75
+ | 4 Fixes | **0.5.8** | Bugs proven by fixtures + T1–T5 regression tests |
76
+
77
+ ## Invariants checklist (from `pipeline.py`)
78
+
79
+ 1. System turns pass through stages untouched — **except** budget last-resort truncation (C1).
80
+ 2. Input never mutated — enforced by clones; **needs T1**.
81
+ 3. Output format mirrors input — denormalize; weaker after turn collapse.
82
+ 4. Last 3 non-system not compressed by recency — unit tested.
83
+ 5. Last 2 non-system not removed by budget — unit tested.
84
+ 6. Resolution (chat) needs both sides — unit tested; C3 may weaken signals.
85
+ 7. Repetition: more recent wins — unit tested.
86
+ 8. Tier 1 deterministic — assumed; sumy/NLTK have fallbacks.
87
+ 9. LLM failure → Tier 1 + warning — summarize yes; dedup **C2**.
88
+ 10. `token_budget=None` skips budget enforcement — OK.
89
+ 11–12. Presets + Tier 2 modes — covered by existing tests.
@@ -4,6 +4,11 @@ All notable changes to `contextpress` are recorded here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.5.5] - 2026-07-26
8
+
9
+ - **Stabilization Phase 1** — codebase audit and prioritized backlog in [`AUDIT.md`](AUDIT.md).
10
+ - No runtime API changes; prep for low-risk refactors (0.5.6) and fixture-driven fixes (0.5.7–0.5.8).
11
+
7
12
  ## [0.5.4] - 2026-07-25
8
13
 
9
14
  - **`compress_many()`** — batch ``compress()`` over a list of conversations.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: contextpress
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Deterministic context compression for LLM chat, RAG, and agent pipelines
5
5
  Project-URL: Homepage, https://github.com/Taha-azizi/contextpress
6
6
  Project-URL: Documentation, https://github.com/Taha-azizi/contextpress#readme
@@ -561,6 +561,7 @@ For academic use, cite this package in your paper’s software or methods sectio
561
561
 
562
562
  ## Extension and growth
563
563
 
564
+ - **Stabilization audit** — See [`AUDIT.md`](AUDIT.md) for known contract gaps and the 0.5.5–0.5.8 backlog (refactors, fixtures, fixes).
564
565
  - **Custom stages** — Subclass `contextpress.strategies.base.BaseStrategy` and plug in via a custom `Pipeline` subclass or future registry hooks.
565
566
  - **Tier 2** — Implement `LLMBackend` (`summarize`, `deduplicate`) for provider-specific semantic compression; failures fall back to Tier 1.
566
567
  - **Presets API** — `from contextpress.compression import VALID_STAGES, STAGE_ORDER` for tooling and experiments.
@@ -320,6 +320,7 @@ For academic use, cite this package in your paper’s software or methods sectio
320
320
 
321
321
  ## Extension and growth
322
322
 
323
+ - **Stabilization audit** — See [`AUDIT.md`](AUDIT.md) for known contract gaps and the 0.5.5–0.5.8 backlog (refactors, fixtures, fixes).
323
324
  - **Custom stages** — Subclass `contextpress.strategies.base.BaseStrategy` and plug in via a custom `Pipeline` subclass or future registry hooks.
324
325
  - **Tier 2** — Implement `LLMBackend` (`summarize`, `deduplicate`) for provider-specific semantic compression; failures fall back to Tier 1.
325
326
  - **Presets API** — `from contextpress.compression import VALID_STAGES, STAGE_ORDER` for tooling and experiments.
@@ -16,7 +16,7 @@ __all__ = [
16
16
  "CompressionResult",
17
17
  "CompressionStats",
18
18
  ]
19
- __version__ = "0.5.4"
19
+ __version__ = "0.5.5"
20
20
 
21
21
 
22
22
  def __getattr__(name: str) -> Any:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "contextpress"
7
- version = "0.5.4"
7
+ version = "0.5.5"
8
8
  description = "Deterministic context compression for LLM chat, RAG, and agent pipelines"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -59,7 +59,7 @@ packages = ["contextpress"]
59
59
  "contextpress/py.typed" = "contextpress/py.typed"
60
60
 
61
61
  [tool.hatch.build.targets.sdist]
62
- include = ["/contextpress", "/tests", "/examples", "/README.md", "/LICENSE", "/NOTICE", "/CHANGELOG.md", "/CITATION.cff", "/CONTRIBUTING.md"]
62
+ include = ["/contextpress", "/tests", "/examples", "/README.md", "/LICENSE", "/NOTICE", "/CHANGELOG.md", "/CITATION.cff", "/CONTRIBUTING.md", "/AUDIT.md", "/AGENTS.md"]
63
63
 
64
64
  [tool.black]
65
65
  line-length = 100
File without changes
File without changes
File without changes
File without changes