Repository navigation
Conversation
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of All evidence gathered. The fix itself is cause-level within First-Principles-Verdict: CONCERNS Point patch: the identical two-resolve containment shape survives in What this change shipsIntent: stop a Windows CI flake that refuses benign work-ledger keys as "path traversal" when two containment resolves straddle the directory's creation — a FIX.
Watch
[FIRST-PRINCIPLES-REVIEWED] 3960622 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of All key questions are answered. The fix is root-cause (removes the racing second resolve), keeps the guard's strength via a race-free Design-Verdict: CONCERNS Sound root-cause fix, but the identical two-resolve race survives in Watch
[DESIGN-REVIEWED] 3960622 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- src/kiro_crew/work_ledger.py:511 -- |
384e12e to
d0934b6
Compare
binding_path and conductor_dir resolved the child and then the parent as two separate filesystem walks. On a host whose temp path carries a short (8.3) component, the Windows CI runner's tmp_path does, the two walks can disagree about the parent's prefix form once the directory appears between them, and a benign key is refused as path traversal -- the intermittent Windows-shard failure of the binding-race test. The child is now composed from the resolved parent and containment is checked lexically, so the guard keeps its traversal guarantee without a second resolve to race.
d0934b6 to
3960622
Compare
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:
When you've addressed these, the pipeline will re-assess on its next cycle. |
|
@NicholasRBowers Going with road (a). I read |
|
target=design — The Watch item is fair: my "not generalizable" claim was contradicted by the sibling count, and the scope statement was written before the full extent was known. Disposition: main's #9614/#9673 fix ( |
|
target=first-principles — All four items were marked justified at review time and stand as analysis; the disposition is supersession. #9614/#9673 landed the same containment shape upstream ( |
Problem / Motivation
test_two_conductors_binding_one_worker_at_once_yield_exactly_one_bindingfails intermittently on the Windows CI shard with a refusal that names a perfectly innocent key:chat-2-workercontains no separators and no dot segments; nothing about it traverses anything. The two path constructors behind it,binding_path()andconductor_dir()insrc/kiro_crew/work_ledger.py, guarded themselves by resolving the child path and then the parent as two separate filesystem walks:On a host whose temp path carries a short (8.3) component — the GitHub Windows runners hand pytest a
RUNNER~1-style prefix — those two walks can disagree.Path.resolve()finalizes everything that already exists on disk, so a resolve that runs afterbindings/was created returns the long form; a resolve whose final component does not exist yet falls back to the lexical form and keeps the short prefix. When the two sides of one containment check straddle the directory's creation,is_relative_tocomparesRUNNER~1againstrunneradminand refuses the key.Why it matters
The failure is intermittent in exactly the way that wastes the most time. The binding race starts four threads at once; the first write creates
bindings/, so whichever threads resolve after that moment see the expanded prefix and whichever resolve ran before it kept the short one. One thread gets refused with a "path traversal" error that accuses a benign key, the shard goes red, and a re-run burns half an hour of CI to pass or fail on thread timing. The same shape sits inconductor_dir()for any concurrent first access to a conductor's ledger.It also misleads diagnosis. The refusal says "path traversal blocked", so the natural reaction is to audit the key for separators — and there are none. The real defect is that the guard's two inputs were taken from the filesystem at two different moments.
What changed (motivation → approach → change)
Symptom: a benign key refused as traversal. Root cause: containment decided by comparing two filesystem resolves that are not atomic with respect to each other. Fix: resolve the parent once and compose the child from it, then check containment lexically.
The guard keeps its full strength, including the part the composed form alone cannot see. The child's name comes from
_store_name(), which sanitizes every unsafe character and appends a digest, so a composed child can never escape the parent — the lexical check still refuses anything that would, and the null-byte and shape checks upstream of it stay untouched. What is removed is the second walk, which was the only thing that could race. What the second walk could catch is restored separately: a symlink or junction planted at the composed child is rejected viaos.lstat(a link or reparse point at the final component), which looks at one entry instead of walking the tree, so it carries none of the race back. Writes and reads through the returned path land in the same directory as before:Path.resolve()finalizes junctions and symlinks for existing prefixes either way, and every caller derives paths through these constructors, so no caller ever mixes the two forms.One behavior note for reviewers: the returned path is now the composed
resolved-parent / namerather than the fully-finalized path. On hosts without aliased prefixes the two are byte-identical, and on aliased hosts the composed form is actually the more stable choice — it does not flip between boots depending on whether the directory happened to exist at resolve time.The change is two files:
src/kiro_crew/work_ledger.py— both constructors resolve the parent once and compose the child lexicallytest/test_work_ledger.py— two regression tests plus a shared_racing_resolve()helperTests
I wrote the regression tests first and watched them fail with the exact CI error —
WorkLedgerError: path traversal blocked for worker key: 'chat-2-worker'— reproduced deterministically on a machine where the real race cannot trigger, then watched them pass after the fix. That is the part that matters most: the old code's misfire no longer depends on runner luck to demonstrate.The helper
_racing_resolve()models the runner deterministically. It flips the second resolve under the data home onto a sibling prefix, which is precisely the divergence the 8.3 form produces when the directory appears between the two walks; on hosts without aliased prefixes the same flip is the only way to observe the two-resolve disagreement at all.Two more tests pin the link guard: they plant a link at the composed child name, point it outside the ledger, and assert both constructors refuse it, watched to fail with "DID NOT RAISE" before the guard existed.
The flaky binding-race test itself ran three times back to back, clean each time, and the full file covers the lock-ordering, cap, and torn-file criteria unchanged.
python -m mypy src/kiro_crewis clean, and the repo'scheck_black_formatting.py/check_subprocess_encoding.pygates plus flake8, isort, and black pass on the touched files.Manual verification
There is nothing to eyeball in the app: the observable behavior change is that a refusal stops happening. The honest reproduction of the original failure needs the runner's short-form temp path, which is why it only surfaced on the Windows shard; the deterministic flip test is the reviewer-accessible stand-in, and the binding-race test is the end-to-end check that the shard gate exercises on every run.
Pattern harvest
Not generalizable: the defect is a two-resolve ordering inside one path constructor, not a recurring API misuse — a static rule cannot tell a containment check that must survive directory creation from an ordinary resolve. The durable guard is the regression test, which flips the prefix between the two resolves deterministically.
Related Issues
No dedicated issue. The failing shard is visible directly on
main's own CI runs, so this PR also unsticks the Windows lane for every open PR that inherited the flake.Checklist