Skip to content

fix(crew-log): carry the lineage scan's fault bit to the dispatch refusal - #12534

Merged
iamwhatever merged 1 commit into
mainfrom
fix/dispatch-view-lineage-fault
Sep 21, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/dispatch-view-lineage-fault

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

crew_log.read.dispatch_view folded the dispatch scope view from
SessionTree.records(). That accessor says in its own docstring that it "Drops
whether the scan faulted", and names reading() as the accessor that keeps it. Both
consumers of the view DECIDE on a lineage edge:

  • the per-unit read door, dashboard/handlers/crew_log.py::_read_scope_refusal;
  • the unit listing, read.list_session_units, which drops a row whose
    dispatched_by answers False.

dispatched_by answers False for a missing node whatever put it there, so an edge
the scan never read and a genuine absence of lineage were the same answer, and
nothing anywhere recorded which one had happened. A conductor refused its own child's
log got the same account as a stranger, and an operator investigating had nothing to
read.

Three reachable causes set the dropped bit:

  1. a unit whose oldest segment stat or read_head raises
    (session_tree.SessionTree._read, its return None, True arms);
  2. a unit whose announce record is PRESENT and unreadable as an entry, cached as
    _Head(..., faulted=True). A log is append-only, so those bytes cannot become
    readable: that verdict is re-served on every later scan for the life of the file.
    This one never clears.
  3. a session-unit population past TREE_UNIT_CAP (over_cap).

Why it matters

_read_scope_refusal is the only door a dispatched session has to the crew logs of
the sessions it created (#12141). Refusing is the safe direction and nothing is
over-granted -- but in cause 2 the refusal is permanent, and with no record of why,
the failure is indistinguishable from a correct scope denial to everyone including
the operator.

The listing has the same shape one level out. A row dropped for a lost edge is dropped
BEFORE it is counted, so scanned never sees it, and truncated reported only the cut
the function itself made: a caller was handed a short list labelled complete.

The sibling module already does this correctly, which is the precedent this change
follows rather than a new judgement.
crew_log/holders.py::ReferenceScanner.holders reads lineage through
self._tree.reading(preferred_ids) and ORs lineage.incomplete into its answer, and
its docstring states the reason in the same terms: "A lineage read that faulted drops
one unit's creator record silently, so a conductor stops being recognised as its
worker's ancestor, the ancestor rule stops dropping it, and the conductor ... is
reported as the holder. That is a confident WRONG owner, not a missing one, and
without the tree's flag the answer would call itself complete."

How our fix solves it

  • dispatch_view reads through SessionTree.reading(), the accessor
    ReferenceScanner already uses, so the fault bit travels WITH the scan that produced
    it -- one locked scan serving the nodes, the flag and the records, instead of a second
    unlocked call whose answer could disagree with the first. (This is a claim about the
    fault bit's path, not about how many accessors the class exposes; an earlier wording
    said "ONE mechanism rather than two spellings of it", which reads as the latter and is
    corrected here.) Its except arm now reports
    incomplete=True: a scan that failed outright is the strongest incompleteness there
    is, and it previously read as a store holding no lineage.
  • TreeReading carries the scan's own records. A consumer that places a UNIT needs
    the sid -> slot map, which fold_tree drops -- it is keyed by slot and a unit id
    appears nowhere in its output. Asking records() for that map separately would be a
    SECOND scan under a second take of the tree's lock, so its population could differ
    from the nodes and the flag, and the ancestor rule would be applied across two
    moments. The field defaults to (), so nothing that constructs a TreeReading
    without it changes.
  • DispatchView carries incomplete.
  • The fault is surfaced to the OPERATOR, never to the caller. Both cases return the
    same _OUT_OF_SCOPE_REFUSAL, and the refusal site logs a warning naming the
    incomplete scan. A caller-visible distinction would be an existence oracle: this door
    passes the requested unit as the scan's preferred (crew_log.py:1132), a named unit
    is admitted first (session_tree.py:400), and its own read fault accumulates into the
    scan's flag (session_tree.py:422) -- so a guessed id that exists and cannot be read
    would be worded differently from one that does not exist, on exactly the boundary
    _OUT_OF_SCOPE_REFUSAL documents itself as protecting. See the review disposition
    below; this is the shape the first revision got wrong.
  • The listing sets truncated and gets no field of its own. Every caller already
    reads truncated as "this is not the whole set", which is the safety property; a
    separate lineage_incomplete key would be a response contract with no consumer in
    the product (grepped: written only, read by nothing in src/, website/src/, test/
    or docs/). The cause is recorded for an operator at the PRODUCER, below, which is
    what covers this path: a caller that only lists reaches no refusal door.
  • The permanent fault is recorded once, at the arm that judges it.
    SessionTree._read warns when an announce record is present and unreadable, naming
    the unit. That is the one layer that knows both the cause and which unit carries it,
    and because every later scan is served by the head cache without reaching that line,
    the operator gets one record per damaged unit rather than one per scan. Being at the
    producer, it covers both consumers of the fault bit -- the per-unit door and the
    listing -- where a record at either call site covers only that one. The other fault
    arms stay silent on purpose: each is transient or re-judged on the next scan, so
    logging them would be per-scan noise.

Deliberately unchanged: the post-read re-check (_unit_recheck_refusal). It re-folds
the target's CLASS and never re-runs dispatched_by, so it holds no lineage verdict to
word. Its own _OUT_OF_SCOPE_REFUSAL use is about the scope tuple moving during the
read, which is a different fact.

What tests we did

Four new tests in test/test_crew_log_routes.py::TestTheDispatchFence, three driving the
REAL route (routes.api_crew_log_unit_page) and the fourth the real listing, not a
helper:

  • test_an_unreadable_middle_log_refuses_as_unknown_lineage_not_out_of_scope -- the
    regression. A conductor -> child -> grandchild tree where the CHILD's announce record
    is replaced on disk with a well-formed JSON object that is not an entry, so the scan
    drops that unit's record and the walk finds no node for its slot. The grandchild's own
    log is intact and the conductor really did dispatch it transitively. It asserts the
    wire carries the ordinary refusal AND that the refusal site logged the incomplete
    scan. The damage is planted as BYTES rather than monkeypatched, because cause 2 above
    is the non-transient one and a patched read would exercise only the transient case.
  • test_an_intact_store_logs_no_incomplete_scan_when_it_refuses -- the allow-direction
    control. Without it, a site that logged on every denial would satisfy the assertion
    above while saying nothing true.
  • test_the_refusal_text_is_identical_whether_the_scan_was_short -- the no-oracle pin.
    It compares the two response bodies for EQUALITY rather than asserting a phrase, so
    re-introducing any caller-visible difference reddens it however it is spelled.
  • test_a_listing_only_lineage_fault_is_recorded_by_the_producer_once -- the listing
    consumer, which reaches no refusal door. It drives the SCOPED listing, because
    list_session_units builds its dispatch view only when a slot is in scope and an
    unscoped owner listing never consults lineage at all. It asserts the listing still
    reports truncated, and that the producer's record appears exactly ONCE across two
    scans naming the unit.

Mutation-verified on this head, in both directions. Reverting dispatch_view to
_TREE.records(preferred) with incomplete=False reddens the regression test on its
caplog assertion (assert False -- nothing was logged), 333 of 334 green. For the
producer record, deleting the warning reddens the listing test at assert 0 == 1 while
its two truncated assertions still pass, so the fixture reached the faulted state and
only the record was missing; moving that same warning to the arm where the head cache is
READ reddens it at assert 2 == 1. Two mutations failing in opposite directions is what
says the once-per-unit claim is measured rather than decorative. Both controls hold.

Scoped local run on the pushed tree, serially (-n0): 334 passed across
test_crew_log_routes.py, test_crew_log_session_tree.py and
test_crew_log_holders.py -- the last because it consumes TreeReading. The two
existing pins on the listing's truncated field (one is False, one is True) both
still pass, which is what says the fold into that field did not invert an existing
contract. Gates on the final tree, each exit status read on its own: black, isort,
flake8, mypy, comment-history, sync-IO-in-async, loop-bound locks, brand, testpaths
coverage and feature map.

Review disposition

  • GPT 5.6 F1 (fenced, upheld): accepted and fixed, not overridden. The first
    revision returned a distinct refusal when the scan was short, and my code comment
    argued incomplete was a property of the scan rather than the target. That was wrong:
    I had not traced preferred. The three call sites above establish it, and the fix is
    the uniform refusal plus the operator log.
  • First Principles item 2 (undeclared): accepted. This description previously
    promised the caller-visible _LINEAGE_UNREADABLE_REFUSAL and quoted a mutation
    transcript asserting 'could not be established' on the wire, neither of which exists
    in the tree. That was a stale body after the security fix, and it is corrected here.
  • First Principles item 4 (zero consumers): accepted, subtracted. The
    lineage_incomplete response key is deleted. I verified the claim rather than taking
    it on the reviewer's grep: the field had no reader anywhere in the product.
  • Design Review Watch (listing-only fault): accepted and fixed. Design found that
    this description and the listing's own comment both claimed "the cause is available to
    an operator in the log the refusal door writes", and that the door's log fires only in
    _read_scope_refusal. That was false for a caller that only lists: it would see
    truncated latched by a fault that never clears, with nothing anywhere recording why.
    I verified the chain before acting rather than treating a restated point as settled.
    Fixed at the producer rather than at the second call site, so one record covers both
    consumers; the false comment is corrected rather than left beside its correction.
  • Design Review Suggestion (SessionTree.records() at zero product callers) and
    First Principles item 5: the count is right, the duplication premise is not.

    Re-measured uncapped: zero callers in src/, 26 in one test file. But records() is
    a one-line projection of the same private locked scan reading() uses, so there is no
    second implementation to drift; snapshot() is the same shape and does have a product
    caller, which is what says the three-projection trio is intended. The docstring
    sentence that named a caller it no longer has IS corrected here. Deleting or
    privatizing a member of that trio is a change to the module's shape and is not this
    change's to make.
  • GPT 5.6 advisory FINDING (read.py:264 and :599): accepted and fixed. Two more
    comments in this file still described reporting paths this change had already altered --
    one said the caller is told "the lineage could not be established", which is the second
    refusal text the security fix DELETED, and the other credited the per-unit refusal door
    with the listing's record. The first was the worse of the two: a comment describing the
    existence oracle as current behaviour is how a later maintainer reinstates it. Both are
    rewritten. I also swept the whole diff for every phrasing of that claim rather than only
    the two lines named, because this is the third site of one claim and the first fix
    addressed only one of them; the remaining occurrences of "refusal door" in crew_log/
    are the corrected text saying this path reaches none.
  • CodeQL: neutral on this diff.

Pattern harvest

Rule candidate: semgrep
Pattern: a decider bound to the fault-DROPPING half of a two-accessor pair over one
scan.

This defect class is not the specific bug. SessionTree deliberately exposes two
accessors over the same scan -- records() drops whether the scan faulted,
reading() keeps it -- and the class is any caller that DECIDES on the result while
bound to the first. holders.py was bound correctly and read.py was not, with no
mechanical difference between the two call sites for a reviewer to see: both read
plausibly, and the wrong one's consequence surfaces only on a store that could not be
fully read, which no test exercised.

The checkable form is narrow and exact: forbid \.records\( on
kiro_crew.crew_log.session_tree.SessionTree outside SessionTree.reading itself,
since reading is the only legitimate caller left. That is one semgrep rule with no
false-positive surface, and it retires the class for this pair rather than for this
one call site.

The generalization worth carrying beyond it is a review-prompt line, because the
shape recurs wherever a scan's completeness travels beside its data: when a module
offers a lossy and a lossless reader of one measurement, a caller that acts on the
result takes the lossless one, and the lossy one exists for display. The
TreeReading docstring already states that rule in prose; nothing enforced it.

A second, smaller pattern this round paid for: a fault-specific REFUSAL TEXT on a door
whose scan admits a caller-named target first is an existence oracle. Worth a
review-prompt line of its own, since the tell is not in the refusal site but in whether
the scan's input is caller-controlled.

Any other suggestions on the work

Found by an audit of the crew log stack, whose remaining findings are advisory and
latent and are not filed: the usage fold's context_by_source is the one retained map
in the projection registry with neither a count budget nor the label coercion its
siblings carry (bounded today only by the producer's closed label vocabulary),
approvals' by_decision has no count budget, and there is no declared entry-type
vocabulary for KIND_CREW at all, so validate_data returns silently for every
crew-kind entry -- harmless while nothing writes a crew log, and worth knowing before
the first writer does.

Refs #12141.

no linked issue: this came out of a read-only audit of the crew log stack rather than a
filed report, so there is no issue to close. #12141 is the merged PR that introduced the
cross-session read door this defect lived on, referenced for context only -- it must not be
reopened or closed by this merge.

@chenmingwei23
chenmingwei23 requested review from a team and iamwhatever September 21, 2026 14:27
@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: checking Automated validation is still running labels Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Verify the refusal-site WARNING's per-request cadence is acceptable: cause 2 never clears, so a polling conductor logs one warning per refused read forever.

[DESIGN-REVIEWED] 6ff6a74

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6ff6a74

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

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 6ff6a74c911d3d400bb1f76e4e1b48354f8dbdf4 — 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.

First-Principles-Verdict: CONCERNS

TreeReading.records leaves SessionTree.records() a second spelling with zero product consumers, under a docstring claiming "ONE mechanism rather than two spellings."

Not justified as shipped

  • Item 6 — duplicate of src/kiro_crew/crew_log/session_tree.py::SessionTree.records: the new field is justifiably atomic (one lock take), but it strands the old accessor — grepped \.records\( across src/: 0 product callers remain (only ~27 sites in test/test_crew_log_session_tree.py, not consumers), while the new read.py docstring still ships "the fault bit reaches a decider through ONE mechanism rather than two spellings of it" with both spellings exposed.
    Subtraction: delete SessionTree.records(); its tests read reading(...).records instead.
    Clears when: the deletion is made, or a product consumer of records() is counted.

What this change ships

Inventory (7 items) — 6 justified

Intent: FIX — a lineage scan that couldn't read part of the store refused a conductor its own child's log with no record anywhere of why; provenance is the added regression test that reddens on base.

  1. A refusal during an incomplete lineage scan now logs an operator warning; wire text unchanged — justified
  2. A permanently unreadable announce record logs one warning per damaged unit at the producer — justified
  3. Scoped unit listing reports truncated: true when the lineage scan was short — justified
  4. A failed dispatch scan reports itself incomplete instead of as an empty store — justified
  5. DispatchView.incomplete field — justified
  6. TreeReading.records field — duplicate of session_tree.py::SessionTree.records (0 product consumers remain on the old spelling)
  7. Four tests pin the fault path, the no-oracle equality, and once-per-unit logging — justified

[FIRST-PRINCIPLES-REVIEWED] 6ff6a74

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

The change is purely additive and well-guarded: reading.nodes equals the prior fold_tree(records) over the same locked scan, the fault warning sits at the one cached permanent-fault arm so it fires once per damaged unit, view.incomplete is None-guarded in list_session_units, and the refusal wire text stays identical to avoid an existence oracle. I confirmed each of these against the code and found no groundable defect.

No findings.

[OPUS-REVIEWED] 6ff6a74

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

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

@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 Sep 21, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dispatch-view-lineage-fault branch from 1dd419e to 143f24d Compare September 21, 2026 15:00
@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 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

F1 (GPT 5.6, fenced, crew_log.py:1151) -- accepted and fixed, not overridden. The
finding is correct and my own rebuttal in the code was wrong in a specific way I had
not traced.

I verified the mechanism independently before acting rather than taking the finding on
its word. The chain holds:

  • crew_log.py:1132 -- this door calls dispatch_view((unit,)), so the requested
    unit is the scan's preferred.
  • session_tree.py:400 -- a named preferred unit is admitted first,
    for unit_id in islice(preferred, TREE_UNIT_CAP).
  • session_tree.py:422 -- faulted = faulted or read_faulted, so that unit's own read
    fault accumulates into the scan's flag.

So incomplete is not purely a property of the scan at this call site, which is
what my comment claimed: a caller can steer it with the id it names. A guessed id that
exists and cannot be read would have been worded differently from one that does not
exist, which is an existence oracle on exactly the boundary _OUT_OF_SCOPE_REFUSAL
documents itself as protecting.

The fix, on 143f24d560f6430989006ea6cd2841321a50ca87: the caller-visible
distinction is gone. _LINEAGE_UNREADABLE_REFUSAL is deleted and both cases return
_OUT_OF_SCOPE_REFUSAL; the incompleteness is recorded in a logger.warning at the
refusal site, which is where it was needed -- an operator asking why a conductor cannot
read its own child now gets an answer, and no caller learns anything about a unit it
named. That is the reviewer's prescribed remedy.

The rest of the change stands, and the distinction that motivated it is not lost -- it
simply stops being something the caller can read:

  • dispatch_view still reads through SessionTree.reading() rather than
    records(). That is the structural half: the fault bit now EXISTS in the view, which
    is what any consumer needs to tell a lost edge from a real absence.
  • The listing keeps lineage_incomplete, and that half is not the same shape.
    read.py:636 calls dispatch_view() with no preferred, so the flag cannot be
    steered at a unit the caller names, and the field names no unit -- it reports the
    scan's own state and folds into truncated so a caller reading only that field is
    never told a short list is complete. If a reviewer disagrees that the two cases are
    distinguishable, that is the argument to make and I will take the field out too.

Tests were retargeted onto what the change now guarantees, rather than left asserting
a wording that no longer exists:

  • the regression test asserts the wire carries the ordinary refusal and that the
    refusal site logged the incomplete scan;
  • test_an_intact_store_logs_no_incomplete_scan_when_it_refuses is its
    allow-direction control, so a site that logged on every denial would not pass;
  • test_the_refusal_text_is_identical_whether_the_scan_was_short compares the two
    response bodies for equality, so re-introducing any caller-visible difference
    reddens it however it is spelled -- that is the pin against this finding returning.

Mutation-verified on this head: reverting dispatch_view to _TREE.records(preferred)
reddens exactly the regression test (assert False on the caplog assertion -- nothing
logged) with 332 of 333 still green, so the three tests are not vacuous and the two
controls hold. Gates re-run on the amended tree, each exit status read on its own:
black, isort, flake8, mypy, comment-history, sync-IO-in-async, loop-bound locks, brand,
testpaths coverage, feature map.

@chenmingwei23
chenmingwei23 force-pushed the fix/dispatch-view-lineage-fault branch from 143f24d to 363f6c1 Compare September 21, 2026 15:11
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Watch item answered: accepted and deferred. I checked all three of its claims against the code at this head rather than reading the finding's shape, and all three hold.

  • The operator record never names the damaged unit, and exists only if a per-unit refusal happens -- correct on every claim. (1) The judged fault is cached as _Head(..., faulted=True) at session_tree.py:494 and logs nothing; the file's only logger.warning is at :533, which is the whole-scan exception arm and a different case. (2) The refusal-door warning names the requested unit, not the unreadable one. (3) The listing path logs nothing for a short scan -- read.py:346 is again the exception arm -- and the quoted truncated or lineage_incomplete is verbatim the live expression at read.py:691, so the reference is not stale even though the response key of that name was subtracted on First Principles item 4: the local variable survives at :686.

    Deferred rather than fixed, on severity and on risk. On severity: the consequence is that an operator bisects the store to find the damaged log. That is a diagnosability cost, it is recoverable, and no caller is given a wrong answer, so it is an improvement rather than a defect this change ships. The claim in the PR body is that the operator learns the scan was short while the caller cannot, and that claim is still true as written -- it does not promise the unit's identity. On risk: the two blocking lanes are clean on this head, and a new head re-rolls the non-deterministic review lanes, which this PR has already paid for over three rounds.

    One nuance for whoever takes it, recorded because it is the part a careless fix gets wrong. The arm that must log is the one that JUDGES the fault, not the one that reads the cache. A log is append-only, so faulted=True at :494 is cached and then re-served by every later scan for the life of that log; a warning placed where the cached verdict is read fires on every scan instead of once. Log where the entry is created, and pin it with a test that scans twice and asserts a single record.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Item 5 answered: the consumer count is right and the duplication premise is not. Rebutted, with the measurement.

  • Moving dispatch_view onto reading() strands SessionTree.records() at zero src consumers -- the count is correct, and I re-measured it rather than relying on the grep quoted in the finding: \.records( appears in three files repo-wide, all under test/, and zero times in src/. Uncapped and untruncated, because a bounded search is not an absence.

    What does not hold is "a second spelling of reading().records left to maintain". There is no second implementation to maintain. records() at session_tree.py:359 is one line, return self._records_with_fault(preferred)[0] at :365, and reading() calls that same private locked scan at :526. The two cannot drift, because there is nothing separate to drift: both are projections of one scan, and the scan is _records_with_fault at :367.

    The sibling settles the shape. snapshot() is the same kind of one-line projection, return self.reading(preferred).nodes at :549, and it has a live src consumer at dashboard/session_memory.py:219. The module deliberately exposes three projections over one private scan, and each docstring routes a reader to the right one: records for the raw records, snapshot for lineage as decoration, reading for a reader that DECIDES on an edge. This change moves one caller from the fault-dropping projection to the fault-keeping one, which is the whole of the fix. Deleting a member of that trio because the current src population happens not to call it is a change to the module's shape, and it is not this change's to make.

    They are also not interchangeable at the call sites the subtraction would port. reading().records folds the entire tree through fold_tree and builds a tuple; records() does neither. Moving 26 test call sites onto it makes every one of them pay a fold it does not exercise, which is a worse test, not a tidier one.

    Accepted from the item, and stated rather than quietly dropped: the docstring sentence "this one stays for callers that only want the records" no longer names a src caller, and that is prose this diff falsified. It stays for now for the same reason the Design item is deferred -- the blocking lanes are clean on this head, and a one-sentence docstring is not worth re-rolling the non-deterministic review lanes. It is the one part of item 5 I would take.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 21, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dispatch-view-lineage-fault branch from 363f6c1 to 0f32459 Compare September 21, 2026 16:22
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Sep 21, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision labels Sep 21, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dispatch-view-lineage-fault branch from 0afb94b to 04ece28 Compare September 21, 2026 17:30
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Item 7 answered for this head. The deletion is declined for the same measured reasons as on 0afb94b7bb15babe11e8a3e13595ee16e7379e72 (comment 5764316795, which stands and is not restated here). One part of this round's framing is new, and it is a fair hit that I accept.

  • "The fix's own ONE mechanism claim leaves SessionTree.records() a second spelling" -- the count is right, again, and re-measured: zero src/ consumers, 26 in test/test_crew_log_session_tree.py. The deletion is still declined on scope: records() is pre-existing API this diff only stops calling, _records_with_fault is one private locked scan with three one-line projections over it, and snapshot() is the identical shape with a live product caller at dashboard/session_memory.py:219, which is what says the trio is intended. The full argument, including why a static rule retires the class better than deleting one of two names, is in 5764316795.

    Accepted: the description's wording earns this reading, and that is my error, not the reviewer's. "Through ONE mechanism rather than two spellings of it" was meant about the FAULT BIT's path -- one scan under one lock serving the nodes, the flag and the records, instead of a second unlocked call that could disagree with the first. It was not a claim about how many accessors the class exposes. Read as the latter, which is a reasonable reading of those words, it does contradict keeping records(), and the sentence should say what it means: the fault bit travels with the scan that produced it.

    Not corrected by editing the description right now, and the reason is mechanical rather than a disagreement: an edit fires edited, which re-dispatches this review round and cancels the two lanes currently in flight on this head. The correction is recorded here instead, which is the durable record for this sha, and it rides the next push if one happens for another reason. If the maintainer would rather have the reword than the in-flight round, say so and I will take the re-roll.

    The deletion itself is with the maintainer as a scope decision and is not being rebutted a fifth time. The lane is advisory, so it does not gate readiness either way.

@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 21, 2026
…usal site

The dispatch scope view was folded from SessionTree.records(), which drops
whether the scan faulted, while both of its consumers DECIDE on an edge: the
per-unit read door and the unit listing. dispatched_by() answers False for a
missing node whatever put it there, so an edge the scan never read and a real
absence of lineage were the same answer, and nothing anywhere recorded which
one had happened.

Three reachable causes set that bit: a unit whose segment stat or head read
raises, a unit whose announce record is present and unreadable (cached as a
judged fault, and permanent because the log is append-only), and a population
past TREE_UNIT_CAP.

dispatch_view now reads through SessionTree.reading(), the same accessor
ReferenceScanner already uses for this reason, so the fault reaches a decider
through one mechanism rather than two spellings of it. TreeReading carries the
scan's own records so the sid->slot map, the nodes and the flag all come from
one scan under one take of the tree's lock; asking records() separately would be
a second scan whose population could differ. DispatchView carries incomplete.

The fault is surfaced to the OPERATOR, never to the caller. A caller-visible
refusal text would be an existence oracle: the door passes the requested unit as
the scan's preferred, a named unit is admitted first, and its own read fault
feeds the scan's flag -- so a guessed id that exists and cannot be read would be
told apart from one that does not exist, on exactly the boundary
_OUT_OF_SCOPE_REFUSAL exists to keep closed. One refusal text for both cases,
with a warning at the refusal site naming the incomplete scan.

The listing gets no field of its own either. It sets truncated, which every
caller already reads as "this is not the whole set" -- the safety property -- and
a separate lineage_incomplete key would be a response contract with no consumer
in the product. The cause is available to an operator in the refusal door's log.

The per-unit re-check is deliberately untouched: it re-folds the target's class
and never re-runs dispatched_by, so it has no lineage verdict to word.
@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 04ece284a3c39196194bdd674676d631eed0aabf; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

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

@chenmingwei23
chenmingwei23 force-pushed the fix/dispatch-view-lineage-fault branch from 04ece28 to 6ff6a74 Compare September 21, 2026 18:22
@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 6ff6a74c911d3d400bb1f76e4e1b48354f8dbdf4; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

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

@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 21, 2026
@chenmingwei23

chenmingwei23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Item 6, TreeReading.records leaves SessionTree.records() a second spelling with zero product consumers -- the subtraction is declined on scope, and the docstring wording it quotes is conceded. One item, one rationale, in two parts.

On the subtraction, the position is unchanged and this is its fifth raise. The full argument stands at #12534 (comment) and is not re-argued here. Its shape, once: records() is a pre-existing public accessor that this diff only stops CALLING, its body is one private locked scan behind three one-line projections, and snapshot() is the identical shape WITH a live caller at dashboard/session_memory.py:219. Deleting it rewrites about 27 call sites in test/test_crew_log_session_tree.py for zero behaviour change, a wider diff than the fault this PR fixes. A maintainer can take the subtraction as its own change, and a static rule retires the whole class better than one hand deletion does.

On the wording, the review is right and I am not disputing it. The sentence at src/kiro_crew/crew_log/read.py:337 is scoped to how the fault bit reaches a DECIDER: dispatch_view and ReferenceScanner both reach it through reading, so there is one path to a decider rather than two. It does not claim the codebase exposes a single accessor. But this review read it the other way, and a sentence that can leave a reader believing records() was already removed is the same class of over-claim this PR has corrected three times already, at read.py:264, at read.py:599, and in the PR body. The reword is owed.

What I am not doing is spending a new head on it this minute. A push re-rolls every review lane, and GPT and Opus are both clean on this head with Design at PASS. This PR's rule is that an advisory finding is answered in a comment while the blocking lanes are clean, and this verdict is advisory by its own statement. The reword rides the next head this PR takes for any other reason; if none arrives it is a one-clause follow-up, recorded here rather than left for the next reader to trip over.

Items 1 through 5 and item 7 are marked justified and are not contested.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 21, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified at head 6ff6a74c. Approving.

A fault bit carried from a scan to a dispatcher has one classic failure -- carried but never acted on -- so I checked what the bit means and what changes when it is set, and the honest answer is split.

The bit means the scan could not READ part of the store, not that the scan found a fault. Three setters accumulate into _records_with_fault: an announce record present but unreadable as an entry (session_tree.py:484-511, the permanent case on an append-only log), a faulted directory listing (:414-416), and over_cap where rows past TREE_UNIT_CAP were never walked. Combined at :545-546 as incomplete = faulted or over_cap, with the outer except at :549 also returning incomplete=True.

At the per-unit refusal door this is observability, not correctness, and the PR says so. On not view.dispatched_by(...) the handler logs a warning (handlers/crew_log.py:1131,1150) and the 403 plus its wire text are byte-identical either way -- deliberate, to avoid an existence oracle. Worth naming plainly: the operator gets the distinction, the caller deliberately does not.

The correctness half is elsewhere and it is real. read.py:697-702 folds lineage_incomplete into "truncated", and read.py:351 makes a failed scan return incomplete=True instead of an empty view that read as "this store holds no lineage." Before the diff, dispatch_view used _TREE.records(), which drops the bit -- so a conductor asking about its own transitively-dispatched grandchild got "out of scope" whether the edge was truly absent or merely unread, and the listing reported truncated: false while the tree was missing an edge. A confident wrong answer worded as a real absence, with nothing logged to explain it. That is a genuine fix, not a nit.

Propagation is fail-closed: every exception arm sets incomplete=True, and the bit is derived at scan time from faulted or over_cap rather than read off a persisted per-record field -- so a legacy on-disk log missing any such field cannot make the scan read clean, which is the concrete "older record shape" case.

Mutations are right, and the non-vacuity one is the one that matters: inverting the bit's meaning (incomplete = not (faulted or over_cap)) still reddens three tests, including the intact-store control. So the tests check what the bit MEANS, not that a field travels. Dropping the propagation reddens test_crew_log_routes.py:1494 and :1586. 40 passed in TestTheDispatchFence.

First Principles' CONCERNS holds and you have already conceded the half worth conceding: SessionTree.records() now has zero product consumers while read.py:337 claims "ONE mechanism rather than two spellings." Declining the deletion on scope is reasonable (~27 test sites for zero behaviour change), and rewording the docstring at the next head closes the part that would mislead a reader.

Both blocking lanes have real verdicts at this head -- [GPT-REVIEWED] 6ff6a74c at 18:46 and [OPUS-REVIEWED] 6ff6a74c at 18:55. There is a stale "review incomplete" straggler for the same SHA from 18:24 that the primary comment's later update supersedes; noting it so nobody reads it as outstanding.

@iamwhatever
iamwhatever enabled auto-merge (squash) September 21, 2026 21:31
@iamwhatever
iamwhatever merged commit 819022d into main Sep 21, 2026
100 of 153 checks passed
@iamwhatever
iamwhatever deleted the fix/dispatch-view-lineage-fault branch September 21, 2026 21:31
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 21, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…usal site (kirodotdev#12534)

The dispatch scope view was folded from SessionTree.records(), which drops
whether the scan faulted, while both of its consumers DECIDE on an edge: the
per-unit read door and the unit listing. dispatched_by() answers False for a
missing node whatever put it there, so an edge the scan never read and a real
absence of lineage were the same answer, and nothing anywhere recorded which
one had happened.

Three reachable causes set that bit: a unit whose segment stat or head read
raises, a unit whose announce record is present and unreadable (cached as a
judged fault, and permanent because the log is append-only), and a population
past TREE_UNIT_CAP.

dispatch_view now reads through SessionTree.reading(), the same accessor
ReferenceScanner already uses for this reason, so the fault reaches a decider
through one mechanism rather than two spellings of it. TreeReading carries the
scan's own records so the sid->slot map, the nodes and the flag all come from
one scan under one take of the tree's lock; asking records() separately would be
a second scan whose population could differ. DispatchView carries incomplete.

The fault is surfaced to the OPERATOR, never to the caller. A caller-visible
refusal text would be an existence oracle: the door passes the requested unit as
the scan's preferred, a named unit is admitted first, and its own read fault
feeds the scan's flag -- so a guessed id that exists and cannot be read would be
told apart from one that does not exist, on exactly the boundary
_OUT_OF_SCOPE_REFUSAL exists to keep closed. One refusal text for both cases,
with a warning at the refusal site naming the incomplete scan.

The listing gets no field of its own either. It sets truncated, which every
caller already reads as "this is not the whole set" -- the safety property -- and
a separate lineage_incomplete key would be a response contract with no consumer
in the product. The cause is available to an operator in the refusal door's log.

The per-unit re-check is deliberately untouched: it re-folds the target's class
and never re-runs dispatched_by, so it has no lineage verdict to word.
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
…usal site (kirodotdev#12534)

The dispatch scope view was folded from SessionTree.records(), which drops
whether the scan faulted, while both of its consumers DECIDE on an edge: the
per-unit read door and the unit listing. dispatched_by() answers False for a
missing node whatever put it there, so an edge the scan never read and a real
absence of lineage were the same answer, and nothing anywhere recorded which
one had happened.

Three reachable causes set that bit: a unit whose segment stat or head read
raises, a unit whose announce record is present and unreadable (cached as a
judged fault, and permanent because the log is append-only), and a population
past TREE_UNIT_CAP.

dispatch_view now reads through SessionTree.reading(), the same accessor
ReferenceScanner already uses for this reason, so the fault reaches a decider
through one mechanism rather than two spellings of it. TreeReading carries the
scan's own records so the sid->slot map, the nodes and the flag all come from
one scan under one take of the tree's lock; asking records() separately would be
a second scan whose population could differ. DispatchView carries incomplete.

The fault is surfaced to the OPERATOR, never to the caller. A caller-visible
refusal text would be an existence oracle: the door passes the requested unit as
the scan's preferred, a named unit is admitted first, and its own read fault
feeds the scan's flag -- so a guessed id that exists and cannot be read would be
told apart from one that does not exist, on exactly the boundary
_OUT_OF_SCOPE_REFUSAL exists to keep closed. One refusal text for both cases,
with a warning at the refusal site naming the incomplete scan.

The listing gets no field of its own either. It sets truncated, which every
caller already reads as "this is not the whole set" -- the safety property -- and
a separate lineage_incomplete key would be a response contract with no consumer
in the product. The cause is available to an operator in the refusal door's log.

The per-unit re-check is deliberately untouched: it re-folds the target's class
and never re-runs dispatched_by, so it has no lineage verdict to word.
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.

3 participants