Skip to content

fix(spawn): resource_status reports the spawn memory floor - #24588

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/resource-status-spawn-floor-14592
Oct 29, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/resource-status-spawn-floor-14592

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: resource_status says when no subagent can start, instead of reading AMPLE while the spawn gate holds every start.

The tool's posture reads the reclaimable memory sum against resource_pressure_gb. The spawn gate reads its own, stricter figure against agent.spawn_min_memory_gb plus the start's price. Nothing in resource_status.py or the tool reads the floor, so the tool can print Posture: AMPLE and "ample headroom" while every spawn_run waits in the queue.

Why it matters

Agents call resource_status before a sub-agent wave. In the reported case the agent read AMPLE and told the user subagents were fine to launch, while every spawn sat queued.

Intended?

No. The tool's description is "check headroom and the cap actually in force before heavy work / a wide subagent wave", and #23884 (merged) left "the spawn floor" to this issue on purpose. On main, src/kiro_crew/mcp_tools/spawn.py:742 (resource_status) prints only ResourceStatus.summary_lines() and the adaptive cap; src/kiro_crew/resource_status.py:796 (probe) reads only resource_pressure_gb / resource_critical_gb. The gate prices the start at src/kiro_crew/subagent_manager/admission/gate.py:866-898.

Repro

Read on current main (a3ee04f57), no local test run:

  1. Set agent.spawn_min_memory_gb to 4.0 (the pre-0.8 default the report hit), or use a loaded Mac at the 2.0 default: docs/system-specs/modules/subagent.md records that the gate's macOS figure runs about 3.5 GiB below the posture's figure on a loaded host.
  2. Gate figure 3.3 GB, posture figure above 4 GB.
  3. spawn_run defers (Subagent spawn deferred: only 3.30 GB available, need ...) and stays queued.
  4. resource_status prints Posture: AMPLE and Guidance: ample headroom right now ..., with no word about the floor.

Not a goal

  • No change to the gate, the floor default, the reserve or the posture thresholds.
  • No [RESOURCES] context-line change; the floor is read only by the pull tool.
  • Gap 2 of the issue (the queued reason) is already on main: the receipt and the dashboard show the gate's sentence.

What changed (motivation → approach → change)

Approach: read the floor with the gate's own helpers and figure, and let it override AMPLE guidance when unmet.

  • src/kiro_crew/resource_status.py: new SpawnFloorReading and spawn_floor_reading(). They use _spawn_memory_floor_and_cost, _shared_start_price_gb and _dedicated_start_price_gb, and read check_memory_available (the gate's figure). One bar: the floor plus the cheapest top-level start (a shared start at subagent_cost_gb). It is a lower bound, because the warming reserve and learned prices live in the gateway's manager. 0 floor takes no reading; an unmeasurable figure fails open as the gate does; an unreadable cgroup usage reads as blocked with its cause. A session bound to a remote workspace takes no reading and is never reported blocked, because the gate prices its children without the floor (remote_child).
  • src/kiro_crew/mcp_tools/spawn.py: the tool adds a Subagent spawn floor: line. When the bar is unmet, the guidance says new top-level subagents cannot start and wait in the queue. The tool reads the caller's placement with session_attached_remotely (in place of AMPLE or the kernel-pressure guidance; after critical/tight guidance as a Spawning: line).
  • docs/system-specs/modules/subagent.md: one paragraph on the new reading.

Example (floor 4.0, gate figure 3.3):

  Subagent spawn floor: 4 GB must stay free after a start; the gate reads 3.3 GB, a top-level start needs at least 4.15 GB (more for a dedicated one or while other starts are warming) — BLOCKED: new top-level subagents wait in the queue

Guidance: new top-level subagents cannot start now — the gate reads 3.3 GB and one needs at least 4.15 GB; they wait in the queue until memory frees.

Backwards compatibility

Compatible: the tool prints one more line, and its guidance changes only when the floor is unmet. Posture, thresholds and every gate stay the same.

Removes nothing.

Tests

  • test/test_resource_status.py: pricing matches the gate helpers; blocked, disabled, unmeasurable and unreadable-cgroup cases; an end-to-end tool case where AMPLE plus an unmet floor must not say "ample headroom". The autouse fixture pins the gate figure so no case reads the CI host's memory.
  • test/test_mcp_core_more_coverage.py::TestResourceStatusTool: the helper pins the reading; new cases for blocked over AMPLE, critical/tight plus blocked, blocked over kernel pressure, and a met floor keeping the AMPLE text.

Proof: not provable -- other: tests run only in CI on this host by its owner's rule

Static gates run locally: black, isort, flake8 on the changed files. Tests run in CI.

Manual verification

Called spawn_floor_reading() with floor 4.0 and a pinned gate figure of 3.3 GB; output is the example above.

Related Issues

Fixes #14592

Sibling sweep

Swept: git grep -n "ample headroom" -- src/ docs/ test/
Siblings: none -- the tool in mcp_tools/spawn.py is the only place that prints the AMPLE guidance.

Pattern harvest

Not generalizable: one advisory tool read a looser figure than the gate it advises about; the fix reads the gate's own figure.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 26, 2026 21:18
@CrysisDeu
CrysisDeu requested a review from buluoray October 26, 2026 21:18
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 26, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from fbe1c7a to 97a6f1d Compare October 26, 2026 21:39
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b53d4d654bd2152297078902c0508a6c94b6a914 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The tool only adds one line and changes its guidance when the floor is unmet. It reads the gate's own figure and prices, and it leaves the remote-child exemption alone.

Notes

  • The description says the bar is "a shared start at subagent_cost_gb", but the code and the spec paragraph price it from the cheapest learned or unlearned dedicated bucket. The code and spec agree with each other; only the description is out of date.

[DESIGN-REVIEWED] b53d4d6

Description read

[DESCRIPTION-READ] 5ae480947b1cd83a76e95a9e566cab97fd441f3602ae8b7c02dd2210118d2db1

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on b53d4d654bd2152297078902c0508a6c94b6a914; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- src/kiro_crew/resource_status.py:1104 -- Fresh log prices can falsely report all starts blocked

return min([unlearned] + [_dedicated_start_price_gb(cost_gb, settled, b) for b in local])
Trigger: A cached 0.5 GB local bucket crosses its seven-day expiry before the manager’s hourly refresh. With a 4 GB floor, 0.5 GB configured cost, 4.4 GB available and nothing warming, resource_status → spawn_floor_reading → _read_learned_settled drops that bucket and substitutes the unlearned price.
Outcome: The tool reports a 4.65 GB minimum and tells the caller to wait for memory, although admission still reads _learned_settled_gb and permits an eligible shared top-level start at 4.15 GB. Repeated tool calls retain this false blocking guidance until the manager refreshes.
Anchor: defect
Fix: Use the manager’s current price map for categorical blocking; when unavailable, use the shared configured-cost price as the guaranteed lower bound.
Sites: src/kiro_crew/resource_status.py:1017, src/kiro_crew/resource_status.py:1039, src/kiro_crew/resource_status.py:1052, src/kiro_crew/mcp_tools/spawn.py:797, src/kiro_crew/mcp_tools/spawn.py:817

[BLOCK-MERGE-DOWNGRADED] b53d4d6
[GPT-REVIEWED] b53d4d6

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 — LOW. The failure needs three things at once: a learned bucket aging out of the cost log at seven days (subagent_cost.py:44, read in resource_status.py:1073-1076), the manager's map still holding that bucket because it only re-reads every hour (monitoring.py:41, monitoring.py:1163-1168), and free memory sitting in the narrow band between the two prices. When that happens, the tool's text wrongly says starts are blocked. That text is advice only (spawn.py:797-808), and admission still decides on _learned_settled_gb (gate.py:840), so real spawns still go through. The wrong text is visible and fixes itself at the next hourly re-read, at the latest. No data or security is at stake.
The real fix costs more than that. Either the status tool gets a new link to the gateway manager's in-memory price map, or it falls back to the bare configured cost, which would understate the bar on the ordinary path. Neither is worth it for a guidance line that is wrong for up to an hour.

[ADJUDICATION] b53d4d654bd2152297078902c0508a6c94b6a914 total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/resource_status.py:1104 reason=disproportionate-remedy
[GPT-ADJUDICATED] b53d4d654bd2152297078902c0508a6c94b6a914

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b53d4d654bd2152297078902c0508a6c94b6a914 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of b53d4d654bd2152297078902c0508a6c94b6a914 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Every item reuses the gate's own pricing helpers (subagent_parts/start_pricing.py) and figure, has one consumer (the tool), and stays inside the frozen Goal.

What this change ships

Inventory (7 items) — 7 justified

Intent: when an agent checks resource_status before a subagent wave, it learns that no subagent can start, instead of reading AMPLE (#14592). This is a FIX.

  1. resource_status now prints a Subagent spawn floor: line stating the floor, the gate's own memory figure and the lowest bar a top-level start must clear — justified
  2. With an AMPLE posture and the floor unmet, the guidance now says new top-level subagents cannot start and wait in the queue, replacing "ample headroom" — justified
  3. With the floor unmet, the blocked guidance replaces the macOS kernel-pressure guidance — justified
  4. With a critical or tight posture and the floor unmet, a trailing Spawning: line is added — justified
  5. A session bound to a remote workspace takes no reading and is never reported blocked, matching the gate's remote_child rule — justified
  6. An unreadable cgroup usage reads as BLOCKED and states its cause, and an unmeasurable figure fails open, both as the gate does — justified
  7. The bar is priced from the learned cost log (the cheapest local bucket), falling back to subagent_cost_gb when the log is unreadable or only partly read — justified

[FIRST-PRINCIPLES-REVIEWED] b53d4d6

Description read

[DESCRIPTION-READ] fc7eab1f10d13c38c7e2aa27e1dffd80fe5fe2a1eb2769acbadf5f88429bb6b1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b53d4d654bd2152297078902c0508a6c94b6a914 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b53d4d654bd2152297078902c0508a6c94b6a914 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b53d4d6

Verdict parsed from the review's SHA-scoped output markers for commit b53d4d654bd2152297078902c0508a6c94b6a914.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b53d4d654bd2152297078902c0508a6c94b6a914 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 26, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from 97a6f1d to ee220ed Compare October 26, 2026 22:11
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 26, 2026
@CrysisDeu

CrysisDeu commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

GPT F1 (ee220ed): fixed in 214778e. The blocked line and guidance now say new top-level subagents cannot start, and that a running subagent's own shared starts need only the floor, since the gate admits those at the floor itself. Test pins both phrases.

@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from ee220ed to 214778e Compare October 26, 2026 22:42
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 26, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from 214778e to 9e9c665 Compare October 26, 2026 23:18
@CrysisDeu

CrysisDeu commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

GPT F1 and Opus BLOCKING (214778e): fixed in 9e9c665. A caller bound to a remote workspace (session_attached_remotely) takes no floor reading and is never reported blocked, matching the gate's remote_child pricing. The nested-start clause is gone; the blocked text is scoped to local top-level starts only. Tests: test_a_remote_caller_takes_no_reading_and_is_never_blocked, test_the_caller_placement_reaches_the_floor_reading.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 26, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from 9e9c665 to 3b314c7 Compare October 27, 2026 01:47
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 27, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from 3b314c7 to a4bc6a8 Compare October 27, 2026 02:20
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Opus BLOCKING (3b314c7): fixed in a4bc6a8. The bar now prices the cheapest start the way the gate does: _shared_start_price_gb of the lowest _dedicated_start_price_gb over an unlearned bucket (at least _UNLEARNED_DEDICATED_START_GB) and each local learned bucket, read with the manager's own read_learned_costs_checked call. @remote buckets are left out. If the cost log is unreadable it falls back to subagent_cost_gb. Tests: test_a_fresh_install_is_blocked_between_the_cost_bar_and_the_gate_bar, test_a_learned_lighter_bucket_lowers_the_bar_to_its_price, test_a_remote_bucket_never_sets_the_local_bar, test_an_unreadable_cost_log_falls_back_to_the_configured_cost.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 27, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from a4bc6a8 to 30a4a92 Compare October 27, 2026 02:51
@CrysisDeu

CrysisDeu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

GPT F1 (a4bc6a8): fixed in 30a4a92. _read_learned_settled now returns None on an incomplete read, so the bar falls back to subagent_cost_gb instead of the unlearned price. Test: test_an_incomplete_cost_log_read_falls_back_to_the_configured_cost.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from 30a4a92 to 2f61314 Compare October 27, 2026 03:22
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

GPT F1 and Semgrep test-bare-monkeypatch-undo (30a4a92): fixed in 2f61314. The bare monkeypatch.undo() is gone. The real reader is captured at import as _REAL_LEARNED_SETTLED, like _REAL_SLICE_PROBE, and only that one patch is put back for this case.

@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from 2f61314 to 186bc4e Compare October 27, 2026 03:53
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Maintainer call needed on the GPT 6.1 block (186bc4e). Every other check and lane is green.

The finding is real. The tool reads memory in its own process, which sits inside the caller runtime's cgroup. The gateway reads its own figure. The tool's figure is never higher than the gateway's, so it can only err toward a false BLOCKED, never a false OK.

Options:

  • (A) The gateway exposes its own memory reading via a new /api/spawn route, and the tool reads it.
  • (B) Ship as-is, with the tool line labelled as the caller-process view.
  • (C) Drop the floor line from resource_status.

Which one do you want? This PR is on hold until then: no more pushes, no reruns, no override.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 28, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/resource-status-spawn-floor-14592 branch from 186bc4e to b53d4d6 Compare October 29, 2026 11:27
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (decision) at b53d4d6.

On the earlier head 186bc4e the author asked the maintainers for a ruling and put the PR on hold. The question is whether resource_status may read memory in the tool's own process, which can only err toward a false BLOCKED, or must read the gateway's figure. The options were (A) a gateway route, (B) ship it labelled as the caller-process view, or (C) drop the floor line. Nobody has answered on the PR. The current head is a rebase of that commit, and the reading is still taken locally (resource_status.py#L1063). A maintainer's choice clears this. With (B), the guidance text should say it is the caller-process view.

The rest is sound, CI is green, and all lanes pass.

AI findings judged non-blocking:

  • GPT 6.1 F1 (downgraded): an aged-out cost-log bucket can show a false BLOCKED for up to an hour. The text is advisory and admission is unchanged (resource_status.py#L1063).
  • Design note: the description's pricing wording is out of date. This is description only.

— crew-pr-reviewer (r135)

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head (or skipped / author override), UX skipped or pass, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 5268e02 into main Oct 29, 2026
94 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/resource-status-spawn-floor-14592 branch October 29, 2026 19:58
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resource_status ignores spawn memory floor; subagents queue silently

3 participants