Whole file
hongdangmoo49/Trinity
The author described this change as “fix: make rotation/warning thresholds configurable instead of hardcoded”. It counts as a record because the checks below fail on the code as it stood at 1cd2216ac and pass on 03640174c, with nothing else changed between the two runs.
Projecthongdangmoo49/Trinity
Fix saved2026-06-03
Sharing licenceMIT · LICENSE
Change size+6 −6
What the code was meant to do, written into the code itself as a save note
fix: make rotation/warning thresholds configurable instead of hardcoded
The change
| 208 | 208 | def ratio(self) -> float: | |
| 209 | 209 | return self.used / self.total if self.total > 0 else 0.0 | |
| 210 | 210 | ||
| 211 | - | @property | |
| 212 | - | def should_rotate(self) -> bool: | |
| 213 | - | return self.ratio >= 0.60 | |
| 211 | + | def should_rotate(self, threshold: float = 0.60) -> bool: | |
| 212 | + | """Check if context usage exceeds rotation threshold.""" | |
| 213 | + | return self.ratio >= threshold | |
| 214 | 214 | ||
| 215 | 215 | @property | |
| 216 | 216 | def remaining(self) -> int: | |
| ⋯ | |||
| 278 | 278 | last_activity: float = 0.0 | |
| 279 | 279 | status: str = "unknown" # "idle", "working", "error", "unknown" | |
| 280 | 280 | ||
| 281 | - | @property | |
| 282 | - | def context_warning(self) -> bool: | |
| 283 | - | return self.context_ratio >= 0.60 | |
| 281 | + | def context_warning(self, threshold: float = 0.60) -> bool: | |
| 282 | + | """Check if context usage exceeds warning threshold.""" | |
| 283 | + | return self.context_ratio >= threshold | |
| 284 | 284 | ||
The check that tells the two apart
fail→pass·tests/test_models.py::TestAgentHealth::test_context_warning
fail→pass·tests/test_models.py::TestAgentHealth::test_healthy_agent
fail→pass·tests/test_models.py::TestContextUsage::test_above_threshold
fail→pass·tests/test_models.py::TestContextUsage::test_at_threshold
fail→pass·tests/test_models.py::TestContextUsage::test_below_threshold
fail→pass·tests/test_models.py::TestContextUsage::test_zero_usage
Check file tests/test_models.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it1cd2216ace692f413052038c275491bcfb108fd7
Broken version dated2026-06-03
Moduletrinity.models
Units changedAgentHealth, ContextUsage
Fingerprintef8a1cf9f533e994
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in hongdangmoo49/Trinity
- 2026-06-17fix: avoid missing workflow events traceback
- 2026-06-06fix: reuse target workspace for workflow followups
- 2026-06-05fix(tui): address code quality review for SacredGeometryAnimator
- 2026-06-03fix(security): prevent path traversal in ManagedHome read/write_config
- 2026-06-02fix: sanitize surrogate characters in SharedContextEngine.write()