Repository navigation
refactor(subagent): drop the uncalled _read_samples cost-log reader - #16843
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (2 items) — 2 justifiedIntent: delete a private whole-log cost reader that nothing calls, so only the readers that actually run remain. This is a FIX (subtraction).
[FIRST-PRINCIPLES-REVIEWED] c6f0d86 Description read[DESCRIPTION-READ] e461e91db1a6eb267bc20c74ea90d1b98205a146ce510245cd88f1020e9d66e8 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] c6f0d86 Description read[DESCRIPTION-READ] a051bd8e85e2b788fb1402e34e805e474048cb4ae97b0633438a24c1b19c4bc6 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
d9355d3 to
24bbf6a
Compare
|
Rebased: main moved in files Neither base commit (#16279, #16786) references |
subagent_cost._read_samples() materialised the whole cost log and had no caller: its last one was replaced when the readers switched to streaming through _iter_samples. The surviving materialising reader, _read_samples_checked, which a test uses, now carries the note that materialising is for tests and small utilities only.
24bbf6a to
c6f0d86
Compare
|
Rebased: main moved in files The base commit (#16846) adds no reference to |
iamwhatever
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: refactor (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: removes the uncalled _read_samples() cost-log reader from subagent_cost.py and folds its docstring note into _read_samples_checked(); dead-code removal with no behaviour change. (Semgrep's single annotation is GitHub's ubuntu-latest migration notice, not a finding.)
Problem / Motivation
Goal: Remove a cost-log reader in
subagent_cost.pythat nothing calls, so the module shows only the readers that actually run.src/kiro_crew/subagent_cost.pydefines_read_samples(), which loads every record of the sub-agent cost log into one list. Nothing calls it. Every production reader streams the log through_iter_samples()into bounded per-bucket windows, and the one materialising reader a test uses is_read_samples_checked().Why it matters
The cost log is agent-writable, and this module is careful never to hold it whole in production. A second whole-log reader that runs nowhere invites the next caller to pick it up, and makes a reviewer auditing the bounded reads check a function that does not matter.
Not a goal
toplevelsweep).§4.2/§4.3pointers name sectionsdynamic-subagent-sizing.mdno longer numbers, and the same pointers sit insubagent.pyandsubagent_manager/monitoring.py, so they belong in one docs-pointer pass across all three files.What changed (motivation → approach → change)
Part of the module-simplification campaign. The detector's two mechanical classes (shadow imports, chained ternaries) are at 0 tree-wide, so this is a judgment-class pass: an AST scan for module-level private names nothing references.
subagent_cost._read_sampleswas the one hit with no open PR touching its file. Its last caller was replaced when the readers switched to streaming, and a word-boundary grep acrosssrc/,test/,scripts/,docs/,.github/andwebsite/finds only the definition. The diff deletes the function. Its docstring carried the rule "materialising is for tests and small utilities only; production readers stream through_iter_samples", which applies just as much to_read_samples_checked, so that rule moves onto_read_samples_checked's docstring instead of being lost. No import changes.Before opening, seven read-only review subagents checked the diff from separate angles: AUTOSDE blocking rules, behaviour preservation, import semantics, security keystone and boot path, comment accuracy, and local mirrors of the Codex and Claude review contracts. The behaviour lens compared both versions' syntax trees with docstrings stripped: the removed function is the only difference. None of the seven found a code defect. The one finding, the Codex mirror saying the intent did not match the diff, came from the brief tool reading merged #16100's body off the reused branch name; an independent verifier refuted it. The comment lens also noted, out of scope, that the untouched module docstring says the log is trimmed "per agent" where compaction keeps one window per
(agent, shared)pair.Backwards compatibility
Compatible: the removed function is private and has no caller, string reference or patch target anywhere in the repo.
Removes nothing: the deleted reader was never invoked on any path, so no reader of it exists;
take_away_check.pyreports no take-away shape for a privatedef.Tests
No test change: no test referenced the function.
test_subagent_cost.py,test_adaptive_startup_memory.py,test_subagent_sizing.py,test_admission_gate.py,test_spawn_memory_cause.py,test_spawn_floor_defaults.py,test_queue_depth_after_deferred_start.pyandtest_subagent_queued_visibility.pypass (369 passed) on the Python 3.12 CI-parity venv. That is a superset ofrun_scoped_tests.py's related set for this diff.Gates run locally, all exit 0: the backend
gates[]floor from the prepare-pr profile, includingflake8,isort --check-only,mypy src/kiro_crew,check_black_formatting.py,check_subprocess_encoding.py,check_comment_history.py,check_brand_name.py,check_harness_parity.py,docs_lint.py --test,docs-lint.sh,check_per_file_coverage.py --testandverify_vendor_manifest.py. Backend-only diff, so CI reportsonly_backend=trueand the frontend suites are not affected.Manual verification
N/A — unit coverage sufficient: the change deletes uncalled code, and every live reader of the cost log is exercised by
test_subagent_cost.pyandtest_adaptive_startup_memory.py.Screenshots / video
Why no screenshot: backend-only deletion of an uncalled Python helper; nothing renders differently.
Related Issues
Part of #16523
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)