Skip to content

feat(work-ledger): a host_pressure level change releases a person-wait hold once - #36657

Closed
iamwhatever wants to merge 2 commits into
mainfrom
feat/pressure-releases-person-wait-hold
Closed

iamwhatever wants to merge 2 commits into
mainfrom
feat/pressure-releases-person-wait-hold

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Lands after #36481. This branch is stacked on it: the first commit (db6c4413e2) is #36481 itself; this PR's own change is the second commit only. It rebases onto main once #36481 merges.

Files carried from #36481 (reviewed there, not here)

docs/request-for-change/README.md, docs/request-for-change/rfc-work-ledger-resource-pressure.md, src/kiro_crew/agent_parts/spec_prompts.py, src/kiro_crew/builtin_skills/goal-conductor/SKILL.md, src/kiro_crew/conductor_wake.py, src/kiro_crew/crewmate_prompts.json, src/kiro_crew/dashboard/handlers/work_ledger.py, src/kiro_crew/dashboard/handlers/work_ledger_read.py, src/kiro_crew/dashboard/handlers/work_ledger_refusals.py, src/kiro_crew/docs/work-ledger.md, src/kiro_crew/host_pressure.py, src/kiro_crew/notifications/resource_pressure.py, src/kiro_crew/probes/work_ledger.py, src/kiro_crew/work_ledger.py, src/kiro_crew/work_ledger_records.py, src/kiro_crew/work_ledger_store.py, src/kiro_crew/work_ledger_writes.py, test/conftest.py, test/conftest_resets.py, test/fixtures/crewmate_prompts/ledger.golden.txt, test/test_agent_refactor_contracts.py, test/test_agent_refactor_spec_bytes.py, test/test_work_ledger_host_pressure.py, test/test_work_ledger_tools.py

Problem / Motivation

Goal: A conductor whose board waits only on people still gets its pause and resume turn when host memory pressure changes level, so queued work resumes after clear.

The owner asked: "然后conductor/worker协调的时候,如果注意到资源非常紧张,应该记录到ledger,然后wake up conductor,让它能够根据当前资源消耗,主动暂停工作". #36481 records host pressure and wakes the conductor. But the person-wait hold runs before the probe. When every open item waits on a person (approval or needs_human), person_wait_fingerprint does not move, so the clear wake is held too. Queued work is not on the ledger, so it never resumes.

Why it matters

A conductor that paused at tight can stay paused for days after memory frees, as long as its open items wait on a person.

Not a goal

What changed (motivation → approach → change)

The accepted RFC amendment rfc-work-ledger-resource-pressure.md §12 (merged in #36589) decides that a pressure level change is a new fact the patrol must see. person_wait_fingerprint now appends |pressure:<episode>:<level> when host_pressure.read_record() returns a fresh record. A level change moves the fingerprint, so _holds_for_person_wait releases once; the delivered turn records the new fingerprint, so the next tick at the same level holds again. A 30 s refresh or the critical re-alert keeps the same episode and level and releases nothing. The fingerprint docstring and monitor-architecture.md name the new release case.

Backwards compatibility

Compatible: the fingerprint string is compared only with a copy the same code took; a loop with an old stored fingerprint releases at most once.

Removes nothing: the hold gains one release case and keeps every other rule.

Tests

test/test_work_ledger_host_pressure.py::test_a_pressure_level_change_releases_a_person_wait_hold_once replaces RFC §5 test 7's "stays held" test: a board waiting on an approval is held under tight, a tight refresh stays held, tight -> clear moves the fingerprint once, and a repeat clear tick holds again. It fails with the fold reverted (checked locally).

Determinism: the file passed 3 repeats in a row, and the 557 tests in every file that names person_wait_fingerprint or _holds_for_person_wait passed under -n 2 (xdist order).

Manual verification

N/A — unit coverage sufficient; the fold is one string join read by the existing hold.

Related Issues

Closes #36588

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 13, 2026 14:26
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of d0da21d7a18b0401375dd4ecddabb7dfcc4cd840 — 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: the fingerprint change is the cause-level fix, and the base already records the decision for it in the accepted RFC's §12 amendment.

What this change ships

Inventory (4 items) — 4 justified

Intent: a conductor paused by host memory pressure still gets its resume turn when memory frees, even when every open item is waiting on a person. FIX.

  1. A board whose items all wait on a person is released once when the pressure level changes (tight → clear, for example), and held again at the same level — justified
  2. A 30 s refresh or a critical re-alert at the same episode and level still keeps the hold — justified
  3. monitor-architecture.md and the person_wait_fingerprint docstring name the new release case — justified
  4. RFC §5 test 7 ("stays held") is replaced by a once-per-level-change release test — justified

[FIRST-PRINCIPLES-REVIEWED] d0da21d

Description read

[DESCRIPTION-READ] 57e2d8e1188e239a6b644da6b9304090448def1aa8485ea215ee8ecb14b38b62

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The fold aims at the hold's real blind spot: queued work is off-ledger, so the fingerprint moves once per level change. The replaced "stays held" pin was reversed by an RFC §12 amendment, not reframed as a gap.

Notes

  • When read_record() expires (90 s without a refresh), it returns None, which drops the |pressure: suffix and moves the fingerprint once more. A notifier outage then produces one extra released turn. That cost is bounded, but the docstring should name it.

[DESIGN-REVIEWED] d0da21d

Description read

[DESCRIPTION-READ] 2f60cad2f2c71bb9085dafc840e064012de2d5f0e0c1c72a3d4ef7aa79143830

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of d0da21d7a18b0401375dd4ecddabb7dfcc4cd840 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d0da21d

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

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

Notes:

  • After a clear turn is delivered, the clear record expires 900 s later and the person-wait fingerprint changes again. This releases the hold one more time. The cost is one quiet-floor model turn per episode, and the hold then comes back.

[OPUS-REVIEWED] d0da21d

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

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

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 13, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Backend red is not this PR's diff. test/test_mate_conductor_parity.py::test_every_shared_rule_has_an_ultra_counterpart_or_a_named_gap fails with ['goal_plan', 'host_pressure']:

@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 Nov 13, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Request changes

Why: the decider found 2 problems and estimates an 80% chance that this change introduces a defect, at or above the 80% level where it asks for changes.

The PR's own change works as described: it folds pressure:<episode>:<level> into person_wait_fingerprint. _holds_for_person_wait compares the fingerprint with ledger_seen_fp, and a delivered turn records the tick's fingerprint, so a level change releases the hold once and a refresh at the same level keeps it. The new test exercises tight → refresh → clear → repeat and would fail if the fold were reverted. Even so, the head can't be merged. It is stacked on #36481, which hasn't merged, and carries all of that PR's code. It conflicts with main. On the merge ref, CI fails the parity test because the host_pressure shared rule (and goal_plan) have no Ultra counterpart. The RFC on this branch still says held boards stay held, which contradicts the code. It needs a rebase onto main after #36481 merges, a fix for the parity test, and a green CI run.

Problems found:

  • This head adds a shared host_pressure conductor rule. On the merge ref, main's parity test fails because that rule has no named Ultra counterpart or gap, and the branch also conflicts with main. Merging this head as it stands would break main's backend test suite. The PR has to be rebased onto mai (src/kiro_crew/agent_parts/spec_prompts.py, high)
  • The PR rests on an RFC §12 amendment it says merged in docs(rfc): a host_pressure level change releases a person-wait hold once #36589, but this branch doesn't contain that amendment. The spec carried on this head therefore contradicts the code change. This clears up only after the rebase that the PR itself says is still pending. (docs/request-for-change/rfc-work-ledger-resource-pressure.md, medium)

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit d0da21d7a1 · 1106 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Closing per the owner's ruling: scope shrinks to a prompt rule (check resource_status before each dispatch wave, #36298) plus the existing resource_status tool. The host_pressure ledger record, conductor wake and person-wait release are more code than the need justifies. Reopen if that changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Work ledger: a host_pressure level change should release a person-wait patrol hold once

2 participants