Clutter T7: bound upper-bound classification by the terminal branch threshold
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
Research direction
Start in src/devostasis/vitals/clutter.py at _complete, where the reachable set is built for UNCLASSIFIED retention, and compare the loop bound with CLUTTER["heavy_stale_branches"]. Apply the terminal bound from the issue, then run the existing T7 vectors and the proposed regression test, using its call-budget monkeypatch to confirm the classification loop stays at threshold+1 or fewer calls. Done when large counts return DEGRADED/HEAVY with all four possible_bands and existing T7 outcomes are unchanged.
Written by the indexing model from the issue text.
Description
Evidence and impact
At readiness PR #57 head b849923511ffef24b3b53d0ed01937ae706f60f8, src/devostasis/vitals/clutter.py blob 08b75d21cbe76d15ca35da100d2e2879cf4765bf contains this T7 path in _complete, for a positive stale count with UNCLASSIFIED retention:
reachable = {classify(stale_work, tracked_open, residue) for residue in range(0, stale_branches + 1)}
The same blob is present on current master and the inspected #81 head a4761daa9fa87026ea106a3d722e7299b3de3b8b. The saved-observation/evaluator boundary admits non-negative Python integers without a numerical upper limit. The loop therefore performs N+1 classifications for a count N, even though there are only four bands and the terminal branch threshold is 20. A large legitimate integer can make offline evaluation effectively nonterminating. This is independent of #38's malformed count/coherence repairs; a nonnegative integer is precisely the value admitted by that proposed guard. #22 and #26 address the accepted semantics, not computational complexity. Searches of open and closed issue/PR titles/bodies and relevant existing discussions did not find this specific repair.
Minimal implementation-only repair
- reachable = {classify(stale_work, tracked_open, residue) for residue in range(0, stale_branches + 1)}
+ terminal = min(stale_branches, CLUTTER["heavy_stale_branches"])
+ reachable = {classify(stale_work, tracked_open, residue) for residue in range(0, terminal + 1)}
Proof: for every residue >= CLUTTER["heavy_stale_branches"], the existing classifier returns HEAVY regardless of the other two counts, by its first predicate. The omitted suffix contains only HEAVY, already present at the inclusive terminal point. If the observed count is below the terminal threshold, no values are omitted. possible_bands, their canonical ordering, exact/degraded selection, original observed count, diagnostics and explanation remain unchanged. No rule, policy, threshold, contract, case identifier or gauge adjustment. Existing T7 acceptance (#22, docs/spec/vitals.md and docs/spec/PROVENANCE.md) remains authoritative.
Executed evidence
Python 3.13.5, isolated transcription of the actual classify function and policy values from #57 (policy blob ae3b002f5d910947773b914a7aa4815f991b2003), not an imported repository package:
- 190,991 exact ordered reachable-set comparisons (stale work 0..30, tracked open 0..60, stale branches 0..100): all equal.
- Six large-count (
10**100) cases spanning work-only CLEAN/LIGHT/CLUTTERED/HEAVY and ratio boundaries: all expected sets, 21 classifier calls each. - With 1,000,000 observed branches: 1,000,001 vs 21 reachability classifications, same four bands. The ordinary full-count classification outside the loop is an additional call in either version.
Proposed full-package regression (NOT_RUN)
from devostasis.observations import Observation, ObservationSet
from devostasis.vitals import clutter
from devostasis.policy import CLUTTER
def test_t7_large_unclassified_count_has_bounded_classification(monkeypatch):
obs = ObservationSet({}, "2026-10-01T00:00:00Z")
n = 10**100
for key in clutter.IDS:
obs.add(Observation(key, "AVAILABLE", "count", n if key == clutter.BRANCHES_STALE else 0))
obs.add(Observation(clutter.BRANCHES_RETENTION, "AVAILABLE", "enum", "UNCLASSIFIED"))
original = clutter.classify
calls = 0
def bounded(*args):
nonlocal calls
calls += 1
assert calls <= CLUTTER["heavy_stale_branches"] + 2
return original(*args)
monkeypatch.setattr(clutter, "classify", bounded)
result = clutter.evaluate(obs).to_dict()
assert result["evaluation_status"] == "DEGRADED"
assert result["band"] == "HEAVY"
assert result["band_semantics"] == "CONSERVATIVE_UPPER_BOUND"
assert result["possible_bands"] == ["CLEAN", "LIGHT", "CLUTTERED", "HEAVY"]
assert result["derived"]["stale_branch_count"] == n
assert "CLUTTER_BRANCH_PURPOSE_UNCLASSIFIED" in result["diagnostics"]
The call budget makes this test fail quickly on the original code rather than waiting for an enormous loop. Add ordinary boundary/ratio controls and retain all existing T7 vectors. Integrate into earliest unpublished release readiness and propagate forward per the branch policy. Check actual pytest, vectors, sample/historical verification and exact-head CI before accepting. These are NOT_RUN here; git clone/ls-remote fails DNS, and #57 workflow run 39592128628 is completed/failure. Authenticated andy-zen-dev has pull=true, push/triage/maintain/admin=false. This issue is the prepared implementation handoff, not a committed patch or release approval.
- Dominant language
- Python
- Stars
- 6
- Forks
- 1
- Avg merge
- 6m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from drevendev/Devostasis
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
drevendev/Devostasis#148 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
drevendev/Devostasis#25 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
drevendev/Devostasis#157 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
drevendev/Devostasis#156 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
drevendev/Devostasis#155 · 9 comments ·
All issues in drevendev/Devostasis
Similar issues
-
bug bugfix
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
simplify
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Elko Super TR: temperature stops updating once the thermostat reports its active sensorPossibly taken @zigpy-review-bot claimed this today. Openbot: code audit
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
zigpy/zha-device-handlers#5790 ·
Maintainers usually reply within 1 day
-
source defect
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
mampfes/hacs_waste_collection_schedule#8269 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day