Repository navigation
refactor(subagent): unchain the memory-deferral detail ternary - #17916
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (1 items) — 1 justifiedIntent: let the next reader of
[FIRST-PRINCIPLES-REVIEWED] af0e309 Description read[DESCRIPTION-READ] 5c0b3081de3160d9cfc7bc51d374459f720b6c62e840c0bbdc85c17ce87ca38e That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
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: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] af0e309 Description read[DESCRIPTION-READ] 0dfc93b93f079c0512539c7edf8da4f20ccfff9751f7df4aaecc353627fac6d7 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 |
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: |
|
CI attribution — all six reds on
Each shard has exactly that one failure (e.g. shard 6: |
8a95c63 to
98f8ac2
Compare
|
Rebased onto |
98f8ac2 to
36d07d9
Compare
|
Rebased: main moved in |
The memory floor's deferral detail picked one of three strings through a ternary nested inside another ternary's else arm. Spell it as if/elif/else with the same branch order: a lane-share hold names only its note, an unknown headroom adds the GB it needs, and a measured shortfall reports the figures. Every string, and the order its conditions are tested in, is unchanged.
36d07d9 to
af0e309
Compare
|
Rebased: main moved in import-graph overlap files since this head went green (6c15ee7 -> aee834c); CI re-running. The one red on the prior head, |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved on maintainer request after review: refactor (1 file). The nested conditional expression for memory_detail becomes an if/elif/else with the same three branches in the same order (lane held, unknown usage, low memory) and the same strings, so behaviour is unchanged.
Problem / Motivation
Goal: Make the subagent memory-deferral detail read top to bottom, so a reader sees at a glance which of the three messages a held spawn gets.
spawn_implinsubagent_manager/admission/gate.pybuiltmemory_detailthrough a ternary nested inside another ternary'selsearm:unknown_note if lane_held else (… if unknown_usage else …). The second condition sits mid-expression between two f-strings, so a reader has to unpack precedence to learn which text a lane-share hold, an unknown headroom and a measured shortfall each produce. It is one of two chained ternaries the module-simplification detector still reports as actionable in the backend.Why it matters
Nothing is broken today. The trap is for the next reader of a user-facing line. This string is the reason a spawn waits: it reaches the
spawn_runtool result, the Slack "Queued subagent" reply, the spawn API'sreason_detail, and the refusal text when the task store cannot record the wait.Not a goal
subagent_manager. One module per PR, and this one stays at one site.What changed (motivation → approach → change)
Readability only; nothing behaves differently. The nested ternary is now an
if lane_held:/elif unknown_usage:/else:block. Each arm assignsmemory_detailthe same f-string it produced before.The block stays where the ternary was: after the deferral's audit emit and before the pressure-hold cleanup. It adds no call,
await,tryor new name.memory_detailis already bound to""earlier in the function, so mypy keeps inferringstr.Backwards compatibility
Compatible: every combination of
lane_held,unknown_usageand the figures yields the same string as before.Removes nothing: one expression is rewritten as one
ifstatement; no field, function or name goes away.Tests
No new tests: the change preserves behaviour, and existing tests drive all three arms. A serial coverage run of 11 admission and spawn test files (736 tests) executes every new line and all four branch arcs, with
gate.pyat 83% (the file is not baselined; the floor is 80%).Local gates (Python 3.12): flake8, isort, mypy,
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 --test,verify_vendor_manifest.pyandtest_flake_pattern_ratchet.pyall exit 0. Eight admission and spawn test files, including the ones that assert these detail strings, pass: 567 tests.scripts/scrub-lint.shis not in the checkout; that scan runs as CI'sinternal-content-scanjob. Backend-only diff, so CI reportsonly_backend=trueand the frontend suites cannot newly fail.Pre-PR review: seven read-only reviewers (AUTOSDE rules, behaviour preservation, import semantics, security keystone and boot path, comment accuracy, and mirrors of the Opus and GPT CI contracts) found no code defect. The GPT mirror ran on a fallback model, so it is weaker evidence than the CI lane. Independent verifiers checked the three notes raised:
spawn_runresult, the Slack reply and the spawn API all show that exact note with no figures.Manual verification
N/A — unit coverage sufficient: the change is one expression inside a function existing tests drive through all three arms. Evaluating the old and new forms over 756 input combinations (non-bool truthy and falsy
lane_held,Noneand0.0prices,-1.0readings) gave identical results; a reviewer's independent harness over 23,040 combinations also matched name-read order and raised exceptions.Screenshots / video
Why no screenshot: backend-only refactor of one Python module; nothing renders differently.
Related Issues
Part of #16523
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)