Repository navigation
refactor(apps): report a dropped installed record from apps.manager - #12223
Conversation
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] f740878 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsThe refactor preserves behavior exactly: No findings. [OPUS-REVIEWED] f740878 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The drift the description names has one counted sibling left: Not justified as shipped
What this change shipsInventory (4 items) — 3 justifiedIntent: FIX — stop the ownership rebuild pruning an app's MCP grant over an apps directory it couldn't actually read, by letting
[FIRST-PRINCIPLES-REVIEWED] f740878 |
e9c4919 to
1b4aa28
Compare
Disposition of the advisory findingsBoth advisory lanes on It is filed as #12248. An apps root that exists and is not a directory is reported Design Review (Fable 5): PASS, no blocking findings. Handled, see above. The one required fix in this headThe Comment History Gate blocked the previous head on a real finding of mine: The test class docstring described where the walk had sat rather than stating Local on this head: 459 tests pass in the two affected files, and every gate is |
Disposition of the advisory findings on
|
The one red on this head is not from this change
Each asserts a POSIX signal returncode in the kill summary and reads Why it is not this change:
Nothing available here moves it. Re-running replays the merge ref resolved when Everything else on this head is green: 90 lanes, 78 success, 11 skipped, nothing This PR is complete on its own terms and waits on the main-side fix for #12247 |
1b4aa28 to
435b547
Compare
435b547 to
95585e1
Compare
The blocking finding on
|
95585e1 to
fc54b09
Compare
Disposition on
|
The agent config rebuild re-derived apps.manager's skip rules to tell an unclaimed MCP server name from one whose owner went unread. list_apps drops an app whose installed record does not read, silently rather than raising, so a caller that needs the two apart had to walk the apps directory itself and reconstruct the record filename, the occupied-entry test and the junction probe. That mirror had no test in the owner's suite, and its failure prunes a mount ref nothing re-adds. list_apps_with_skips returns the same rows plus whether the listing dropped an app that is on disk. The walk moves into apps.manager beside _absence_is_genuine, so there is no copy left to go stale, and the owner's suite now pins the skip report.
fc54b09 to
f740878
Compare
Disposition of the CONCERNS on
|
The fact checks out. What this change did to that disagreement is nothing. On current main, Why it is not fixed here. The item names the reason itself: serving that caller needs a read that names the dropped app, and Issue #12306 records the divergence, both sites, and both ways to retire it: have the dashboard walk consume a manager-owned read that names the dropped entry, or pin its different answer with a test stating why a dangling link is a definite absence there. |
iamwhatever
left a comment
There was a problem hiding this comment.
Approved on the current head: CI green, readiness passed, no security-sensitive path in the diff.
…irodotdev#12223) The agent config rebuild re-derived apps.manager's skip rules to tell an unclaimed MCP server name from one whose owner went unread. list_apps drops an app whose installed record does not read, silently rather than raising, so a caller that needs the two apart had to walk the apps directory itself and reconstruct the record filename, the occupied-entry test and the junction probe. That mirror had no test in the owner's suite, and its failure prunes a mount ref nothing re-adds. list_apps_with_skips returns the same rows plus whether the listing dropped an app that is on disk. The walk moves into apps.manager beside _absence_is_genuine, so there is no copy left to go stale, and the owner's suite now pins the skip report.
Problem / Motivation
_app_owned_mcp_keysinsrc/kiro_crew/agent.pyworks out which{app}:{server}names installed apps claim, and whether that read saw every claim, by walking the
apps directory itself. To do that it had to reconstruct four rules that
apps.managerowns: the installed-record filename, the occupied-entry test, thejunction probe, and which root entries
list_appsskips.It reconstructed them because
list_appsreachesif not meta: continuefor arecord that does not read and drops the app silently rather than raising, so its
return value cannot separate "no app is installed under that name" from "that
app's record went unread". A caller that needs the two apart had no way to ask.
A second defect sits in the same read, and this PR closes it too. When the apps
root is not a directory, nothing under it can be enumerated, so every installed
app's record is unreachable at once -- and the read answers COMPLETE anyway. An
app missing from a complete listing means "not installed", so the rebuild treats
every claimed name as unclaimed on exactly the input where it knows least. Main's
agent.pyalready answers this way (_root.is_dir() and any(...)yieldsskipped=False), so this is behaviour inherited rather than introduced here.Why it matters
The reconstruction was a mirror of another module's rules with no test in the
owner's suite.
apps.managercould change its record layout or its skipbehaviour and nothing in
test/test_app_manager.pywould fail; the copy inagent.pywould simply start answering the old question.Its failure lands on the unrecoverable side. The completeness flag would read as
fully-read when it was not, so a name no live claim mentions is treated as
genuinely unowned and its
mcpServersentry is pruned. A pruned entry is notre-added: the rendered config is the merge base for the next rebuild, so the
server stops being offered until someone re-declares it by hand. The tri-state
read exists precisely to hold the grant on a read fault, and a stale mirror
defeats it silently.
The asymmetry is sharp today:
_absence_is_genuine-- the rule the agent-sidecopy cites by name in its own comment -- is covered at
test_app_manager.pywhere it is defined, and was covered nowhere where it was mirrored.
What changed (motivation -> approach -> change)
The issue named two remedies and they are not equivalent. Widening
list_apps'sreturn shape would reach 29 call sites in
src/and 40 references intest/,every one of which consumes a plain
list[dict]today, to serve one caller. Sothis adds a purpose-built read instead and leaves
list_appsuntouched.apps.managergainslist_apps_with_skips() -> AppsListing, a NamedTuple of thesame rows
list_appsreturns pluscomplete, which is False when an entry in theapps root stood for an app the listing dropped. The walk and its two predicates
move out of
agent.pyand sit beside_absence_is_genuine, whose fail-to-unknowndirection they follow.
agent.pyconsumes that answer. The split follows the module boundary: the rulesabout the apps directory belong to
apps.manager, and the MCP alias minting andenablement composition stay in
agent.py, which owns those. The agent-side copyis deleted rather than kept in agreement with a ratchet, so there is no second
implementation left that could drift.
What the read decides is unchanged in every case but one. The deliberate residue
it keeps: a plain file beside the app directories is not a dropped app, because it
cannot be told apart from an ordinary non-app file and counting every one would
hold the listing permanently incomplete.
The one case that changes is the non-directory apps root (#12248). It now reports
incomplete when something OCCUPIES the root, and still reports complete when the
root is simply ABSENT. Presence is judged without resolving, by the same
_path_is_occupiedpredicate the record-level check uses, so a dangling link and aWindows junction are seen rather than read as absence.
A plain file counts at the root while it does not count one level down, and the
position carries that argument rather than the shape: a file beside the app
directories is an ordinary member of a healthy apps root, whereas a file standing
where the root belongs has replaced the whole directory and no healthy
installation looks like that.
Backwards compatibility
Compatible:
list_appskeeps its signature, its return type and its behaviour,so none of its callers are touched;
list_apps_with_skipsandAppsListingareadditions.
One behaviour change, which is the #12248 fix:
_app_owned_mcp_keysnow reports anincomplete ownership read when the apps root is occupied by a non-directory, where
it reported a complete one. Every other input returns the same
_AppOwnershipvalues, which is what the unchanged agent-side tests pin.
What that changes downstream is asymmetric, and deliberately so in
agent.py: anincomplete read keeps a mount reference, because dropping one can unmount a server
for good, while an auto-approve grant still requires a positive answer and is not
kept on doubt. So the fix stops a server being unmounted over a root nobody could
read, without leaving an auto-approval on a name.
The only reachable state it newly refuses to be certain about is an apps root that
exists and is not a directory, which no healthy installation has.
Tests
New in the owner's suite,
test/test_app_manager.py::TestListingReportsWhatItDropped(14 cases), so the skip report cannot go stale without failing where the rules
live:
list_appsreturnsa junction-shaped record are each reported as a skip
skips a non-directory
are each NOT a skip -- the boundary that keeps the listing from being
permanently incomplete
file, by a dangling link, or by a junction shape is reported incomplete -- the
apps listing reports COMPLETE when the apps root is not a directory #12248 fix, pinned against that absent-root boundary
already read
Unchanged and passing: the 13 agent-side cases in
test/test_agent.py::TestToolBloatFixesthat pin the mount and grant behaviourunder a partial ownership read. This is a move of the read, so they were not
edited.
Mutation-verified, each red an
AssertionErrorabout the value:droppedforced False)exists()only)For the #12248 fix, mutated separately against the four root cases, restoring from
a file copy and asserting each marker matched. Baseline unmutated: 4 passed.
exists()only)The third is the both-directions check: it fails only the absent-root case, which
shows the fix is conditional on the root being occupied rather than a blanket flip
of every non-directory root.
The first is the check the issue asked for: removing the skip report fails the
agent-side completeness tests, so the new API is load-bearing. The third isolates
the consumption. The three kill different, non-identical sets, so the tests are
independent rather than one assertion firing three times. The unwalkable-root case
also asserts its own precondition (that the completeness walk ran), which is what
caught the short-circuit under mutation one.
Local:
test/test_app_manager.py+test/test_agent.py459 passed with-n0.Gates: flake8, isort, mypy,
check_black_formatting.py,check_comment_history.py,check_loop_bound_locks.py,check_brand_name.py,check_subprocess_encoding.pyall clean.Manual verification
N/A -- unit coverage sufficient. The change has no user-visible surface, and the
paths it decides are filesystem shapes (dangling links, unparseable records,
junctions) that the tests construct directly.
Related Issues
Closes #12169
Closes #12248
Pattern harvest
Rule candidate: review-prompt
Pattern: a module reconstructs another module's skip or occupancy rules because
the owner drops a record silently, so the copy has no test in the owner's suite
and goes stale without a failure.
Any other suggestions on the work
The residue this description previously deferred is fixed here instead, as
#12248: an occupied non-directory apps root now reports an incomplete listing. The
absent-root case keeps reporting complete, since nothing being installed is a real
answer rather than a doubt.
One residue genuinely remains and is not worth closing: a plain file standing where
a single app's directory belongs is still not counted as a dropped app. Unlike the
root, that position has an ordinary innocent occupant, so counting it would hold
every normal listing incomplete and cost every caller that reads completeness as
doubt. It is documented at the predicate.