Skip to content

test(work-ledger): name the refusing validator in the bind race failure - #9353

Merged
bolichen97 merged 1 commit into
mainfrom
fix/work-ledger-bind-invalid-value-9343
Sep 8, 2026
Merged

test(work-ledger): name the refusing validator in the bind race failure#9353
bolichen97 merged 1 commit into
mainfrom
fix/work-ledger-bind-invalid-value-9343

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

test_two_conductors_binding_one_worker_at_once_yield_exactly_one_binding fails
intermittently on the Windows shard, sometimes reporting invalid_value
(issue #9343). The test recorded only exc.code for a failing thread, so that
invalid_value did not say which validator refused or on what value -- the one
fact needed to attribute the failure from a shard you cannot reproduce on.

Why it matters

A failure message that names only invalid_value, with no field and no value, sends
the next person to trace the whole bind path by hand. Naming the refusing validator's
field and the offending value turns a blind shard failure into a diagnosable one.

What changed (motivation -> approach -> change)

Two behaviour-preserving changes.

The race test now records exc.field and the message alongside the counted
exc.code, and folds them into both assertion messages. The == 1 and == 3
assertions are unchanged: this adds diagnosis, not tolerance.

conductor_dir's inline slot-key shape check (not key or "\0"/"/"/"\\" in key) is
extracted into a shared _slot_key_is_shaped predicate. conductor_dir calls it and
raises exactly as before; behaviour is identical, the check just has a name.

Scope -- what this does and does not do

This PR does NOT change any binding-read behaviour and does NOT diagnose the shard
failure. An earlier revision made read_binding treat a malformed stored conductor
key as unbound; GPT review showed that would let _bootstrap persist a depth-0 ledger
and bypass the nesting-depth ceiling, so that hunk was removed. A bind against a
binding with a malformed conductor key therefore raises today exactly as it does on
main -- unchanged. #9343's symptom is unchanged and only better reported.

Tests

  • The binding-race test's widened diagnostic (field + message on both assertions) is
    exercised by the existing test; the counted assertions are untouched.
  • No behavioural test is added because no behaviour changed.

Commands run (Linux, one file at a time):

timeout 900 python3 -m pytest -n0 test/test_work_ledger.py -x -q
  -> 123 passed

black --target-version py310 --check + isort --check-only + flake8
  -> clean on both changed files
python3 scripts/check_comment_history.py  (baselined ratchet)
  -> clean

No prove.py mutation check applies: this change is a diagnostic plus a
behaviour-preserving refactor, so there is no production behaviour to revert.

Manual verification

N/A -- the change is test-diagnostic and a refactor with identical behaviour. The
Windows-shard failure is not addressed here.

Related Issues

Refs #9343 -- widens that test's diagnostic so a future Windows invalid_value names
its validator. Does not fix or diagnose it; the issue stays open.

Refs #9388 -- open question of whether the worker binding_lock serializes on Windows.

Refs #9389 -- open question of whether a malformed stored conductor key is reachable
and whether _bootstrap should refuse it regardless (the depth-ceiling question that
scoped this PR down).

no linked issue is closed by this PR.

Pattern harvest

A single two-valued reader result was asked to answer two independent questions and
was wrong for opposite reasons on each. read_binding returning None means both
"not a usable report channel" (right for the worker / Phase 2) and "no parent for
depth" (a fail-open for _bootstrap's nesting ceiling). Making an unreadable binding
REFUSE drew an objection that it removed self-healing; making it READ AS UNBOUND drew
an objection that it bypassed the depth ceiling. Both directions of the one boolean
were rejected, for unrelated reasons -- the signature of one value carrying two
questions that need not share an answer for a malformed file.

Rule candidate: review-prompt -- when a fix changes what a shared reader returns for a
malformed or unreadable input, enumerate every consumer of that return value and check
each for the OPPOSITE failure mode before shipping; when two consumers reject both
values of the result for unrelated reasons, split the result so each consumer asks its
own question rather than overloading one sentinel.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 6da76e99bf11793c85f0aff408d7ba43c2d71bc1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The PR title claims a fail-closed behavior fix the diff no longer contains; what ships is a test diagnostic plus a one-caller refactor.

Watch

Suggestions

[DESIGN-REVIEWED] 6da76e9

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 6da76e99bf11793c85f0aff408d7ba43c2d71bc1 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6da76e9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 6da76e99bf11793c85f0aff408d7ba43c2d71bc1: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 6da76e99bf11793c85f0aff408d7ba43c2d71bc1 — 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/CONCERNS are advisory.

Both files read and verified against the repository: exc.field exists on WorkLedgerError (work_ledger.py:169), and _slot_key_is_shaped has exactly one caller. The review follows.

First-Principles-Verdict: CONCERNS

_slot_key_is_shaped is extracted for a reader this PR deleted — one consumer remains — and the title claims a fix the diff doesn't ship.

Not justified as shipped

What this change ships

Intent: make an intermittent Windows-shard binding-race failure name which validator refused and on what value (#9343) — titled a FIX, but the description itself says "Does not fix or diagnose it", so what ships is diagnostics plus a refactor.

  1. The binding-race test's failure message now names each failing thread's refusing field and error text — justified
  2. The slot-key shape check in conductor_dir becomes a callable named predicate — rides along; one consumer, generalized

Watch

Subtractions

[FIRST-PRINCIPLES-REVIEWED] 6da76e9

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 6da76e9

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 6da76e99bf11793c85f0aff408d7ba43c2d71bc1: <one-sentence reason>

@chenmingwei23
chenmingwei23 force-pushed the fix/work-ledger-bind-invalid-value-9343 branch from 38ec1f3 to ae139b7 Compare September 8, 2026 03:05
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Verification of the fix (fail-before / pass-after). Confirmed with the prepare-pr prove.py, which reverts the production hunks in a throwaway worktree while keeping the test hunks and re-runs the changed test file:

python3 prove.py --base kirocrew/main
  -> PROVEN: an assertion failed with the bug reintroduced   (exit 0)

Full file run on the fixed tree:

timeout 900 python3 -m pytest -n0 test/test_work_ledger.py -x -q
  -> 126 passed

What this closes, precisely. The two failure signatures on the Windows shard share one seam -- the bind guard reads the worker's binding file and hands the stored conductor_slot_key to read_work_item, which builds a store path from it, while read_binding shape-checked only the item_id.

  • The already_bound shortfall (the base breakage: three threads expected to report already_bound, only two do, with no exception to name) is closed and pinned. A present-but-unreadable binding read as "free" and let a second bind succeed -- one extra bound, one fewer already_bound, and because the deciding error was swallowed there was no exception. test_a_present_but_unreadable_binding_refuses_a_second_bind fails before this change and passes after.
  • The invalid_value symptom (Windows shard: work-ledger concurrent bind reports invalid_value instead of already_bound #9343) is made diagnosable, not closed. It is only reachable via a torn read on Windows, which POSIX rename forbids, so it cannot be reproduced or pinned on Linux. The fix removes the code path that raises it, and the race test now records exc.field and the message so the next Windows occurrence names its validator -- but confirming that on the shard needs a Windows box.

Hence Refs #9343, not Closes: one face of the seam is fixed and pinned; the other is addressed by construction and made diagnosable, with its confirmation still requiring Windows.

The one red lane (Backend Tests (Windows) (3)) is base, not this PR: it fails on test_security_conductor_skill_contract.py::TestSkillIsInstallable::test_no_bundled_scripts_are_shipped_here, a file this diff does not touch, from security-conductor/scripts created by a sibling change on main. It reproduces on Linux against current main.

Kiro Crew Auto-Pipeline [operator: chenmingwei23]

@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 Sep 8, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/work-ledger-bind-invalid-value-9343 branch from ae139b7 to b4f6f01 Compare September 8, 2026 04:19
@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 readiness: checking Automated validation is still running labels Sep 8, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/work-ledger-bind-invalid-value-9343 branch from b4f6f01 to 4715d9b Compare September 8, 2026 05:08
@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: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Sep 8, 2026
The binding-race test recorded only exc.code, so a Windows-shard invalid_value failure did not say which validator refused or on what value. Record exc.field and the message alongside the code and fold them into both assertion messages; the ==1 and ==3 assertions are unchanged (diagnosis, not tolerance). Also extract conductor_dir's inline slot-key shape check into a shared _slot_key_is_shaped predicate (no behaviour change). Refs #9343
@chenmingwei23
chenmingwei23 force-pushed the fix/work-ledger-bind-invalid-value-9343 branch from 4715d9b to 6da76e9 Compare September 8, 2026 05:25
@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 Sep 8, 2026
@chenmingwei23 chenmingwei23 changed the title fix(work-ledger): fail closed on a present-but-unreadable worker binding test(work-ledger): name the refusing validator in the bind race failure Sep 8, 2026
@bolichen97
bolichen97 merged commit faf4d9b into main Sep 8, 2026
72 of 87 checks passed
@bolichen97
bolichen97 deleted the fix/work-ledger-bind-invalid-value-9343 branch September 8, 2026 06:02
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Sep 8, 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.

2 participants