Repository navigation
fix(side): withhold the read-only spec's KAS block on a refusing kiro-cli - #16086
Conversation
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/dashboard/side_readonly_spec.py:314 -- function-local False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The documented contract wasn't moved with the behavior: two in-repo descriptions still promise the KAS key is "emptied, not dropped," which the refusing/unknown arms now violate. WatchDoc-behavior drift on the isolation contract. SuggestionsThe description was truncated mid-"Tests" section at the 8000-byte capture limit — confirm the GREEN run line survived intact in the live PR body so the gate record is complete. [DESIGN-REVIEWED] 47b1bba Description read[DESCRIPTION-READ] 8cf60d78c46b91ea69109ced6eb17091cf8d272bcaee9d92b8a7fcc011fa8344 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 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS
What this change shipsInventory (3 items) — 3 justifiedIntent: FIX — stop a below-floor or unknown kiro-cli from refusing the side turn's derived read-only spec whole, by routing its one ungated KAS
Evidence checked: the gate pops an inherited key on refusing/unknown and rewrites on accepting ( [FIRST-PRINCIPLES-REVIEWED] 47b1bba Description read[DESCRIPTION-READ] 9faf45643f8e6bd79d10a22fbf78501405fe5b6a7bbebeaf9fddba8bfc45c7a7 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsThe gated withhold is correct; the prose that documents it — the function's own docstring and the owning spec — still states the old unconditional behaviour. FINDING — src/kiro_crew/dashboard/side_readonly_spec.py:251 — FINDING — docs/system-specs/modules/side.md:291 — the owning spec still describes the derived spec as carrying "an empty KAS [OPUS-REVIEWED] 47b1bba Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
…-cli
`side_readonly_spec` publishes `~/.kiro/agents/<agent>--readonly.json` on
every side turn -- into the registry kiro-cli loads its selectable agents
from -- and rewrites the inherited KAS policy to an empty one:
if "permissions" in spec:
spec["permissions"] = {"rules": []}
It is a generated-spec writer like the five in `agent.py`, but it never
reached the shared version gate #12919 centralized. kiro-cli validates
specs with serde `deny_unknown_fields`, and it is the KEY's presence,
not its value, that a release below SPEC_PERMISSIONS_MIN_VERSION refuses
-- an empty policy is still a policy. So a base spec carrying a
`permissions` block, on a below-floor or unknown release, produced a
derived file that release refuses whole.
What is lost when it is refused is this module's entire reason to exist.
The derived spec is the side turn's read-only isolation: `allowedTools`
emptied, no `autoApprove`, no `toolsSettings` grants, no
`includeMcpJson`, no lifecycle hooks -- so that every call raises a
permission request the READ_ONLY gate judges instead of being approved
by the backend unattended.
Routed through `_write_derived_permissions`, which on an accepting
release derives `{"rules": []}` from the emptied grants -- byte-identical
to what this line wrote -- and on a refusing or unknown one removes the
inherited value. The `if "permissions" in spec` guard stays: the gate
decides whether the field may be CARRIED, not whether to add one, and
its mere presence is what makes KAS load a spec at all.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: iamwhatever <12429733+iamwhatever@users.noreply.github.com>
182993e to
47b1bba
Compare
Problem / Motivation
Goal: Stop a side turn's derived read-only agent spec from being refused whole by a kiro-cli below the spec-permissions floor, by routing its KAS block through the shared version gate.
A side turn does not run under the user's own agent spec.
side_readonly_specderives
<agent>--readonlyfrom it with every backend-side grant emptied —allowedTools: [], noautoApprove, notoolsSettingsallowed*/trusted*,includeMcpJson: false, no lifecyclehooks, and the KAS policy rewritten toan empty one — and publishes it into
~/.kiro/agents/, the only directorykiro-cli loads selectable agents from. That is what makes every tool call raise
a permission request for the
READ_ONLYgate to judge, instead of beingapproved by the backend unattended.
The KAS half of that emptying never reached the shared version gate:
#12919 centralized that gate as
_write_derived_permissions, "the one versiongate every generated spec writer shares", and routed
agent.py's fivegenerated writers through it. This module is a sixth generated-spec writer by
every property that matters — deterministic name, regenerated from the base on
every side turn,
_atomic_json_writeinto the kiro agent registry, neverhand-edited — and it kept its own write.
kiro-cli validates agent specs with serde
deny_unknown_fields, and it is thekey's presence, not its value, that a release below
SPEC_PERMISSIONS_MIN_VERSION(2.23.0) refuses. The repository states thisdirectly: "
{"rules": []}… the key's mere PRESENCE is what makes KAS load thespec at all, so the empty policy is still a policy." So a base spec carrying a
permissionsblock, derived on a below-floor or unknown release, produced aderived file that release refuses whole.
Why it matters
The file that gets refused is the side turn's isolation boundary. Per the
repository's own account of this failure (#12919,
_write_derived_permissions),a release whose schema predates the field "refuses the WHOLE spec and falls
back to broader default grants" — which for this spec means falling back off
the very narrowing the module exists to apply.
handlers/side.pyis explicitthat a spec which cannot be produced fails closed (
ReadOnlySpecError, theturn is refused and "never runs under the base agent"); a spec that is produced
and then refused by the backend is outside that guarantee.
The trigger needs no exotic setup.
installed_kiro_cli_version()answers"unknown" whenever there is no pinned binary, or
--versionis refused, timesout or is unparseable, and its cache is keyed on the binary's path and mtime
so a
kiro-cli updatere-probes. The base spec need only carry apermissionsblock — an author's own KAS policy, or one written while an accepting release
was installed. The development box this was measured on has a real
kiro-cliat2.22.1, one minor below the floor, so the derivation was exercised against a
genuine below-floor binary rather than a stub.
Not a goal
permissionsblock to a base spec that carries none — theif "permissions" in specguard is kept so this change only gates an inherited value, never introduces one.allowedTools: [],includeMcpJson: false, droppedhooks/autoApprove)._write_derived_permissionsitself (fix(agent): gate generated spec permissions by CLI version #12919) or the fiveagent.pywriters already routed through it.What changed (motivation → approach → change)
Symptom → cause → change. The symptom is a derived read-only spec carrying
permissionson a CLI that refuses the file for it. The cause is a write thatpredates the shared gate. The change routes that one write through the gate:
On an accepting release it derives from the already-emptied
allowedTools,which is
{"rules": []}— byte-identical to what the line wrote. On a refusingor unknown one it removes the inherited value, the same withholding the five
sibling writers already do.
The
if "permissions" in specguard is kept deliberately. The gate decideswhether the field may be carried, not whether to add one. Because the key's
presence is what makes KAS load a spec at all, deriving a block for a base that
had none would change what the backend does with that agent — a widening this
change has no reason to make. Pinned by its own test on the accepting release,
where a gate that dropped the guard would write one.
Direction of the change is fail-safe. Withholding a KAS policy can only
remove backend-side auto-approvals from a spec whose whole purpose is to have
none; it cannot add a grant. Every other narrowing in the derivation
(
allowedTools: [],includeMcpJson: false) is unaffected and asserted onevery arm.
No sixth spelling of the version check, and no new layering edge: this
module already imports private names from
kiro_crew.agentfunction-locally onthis path (
_atomic_json_write,kiro_agents_dir_path).scripts/check_agent_sdk_boundary.pypasses with the diff in scope.Backwards compatibility
Compatible. On an accepting release the published file is unchanged:
derived_agent_permissions([], name)is{"rules": []}, exactly the literal theold line assigned, so the content digest — which
publish_readonly_specuses todecide whether to rewrite at all, and which
handlers/side.pybinds a livesession to — does not move. The
[accepts]arm passed before this change aswell as after.
What changes is only the below-floor and unknown cases, where the key is now
withheld instead of written. Nothing is rejected, renamed or removed: no new
required field, no stricter validator, no narrowed type, and no change to any
other derived key.
Tests
test/test_side_readonly_spec.py, asserting on the file as published to theagent registry — the bytes kiro-cli reads — rather than on the derivation in
isolation:
test_the_derived_spec_carries_a_kas_block_only_where_the_cli_accepts_it— parametrized over
accepts/refuses/unknown. A base carrying a KASblock is published through
publish_readonly_spec; the on-disk file mustcarry
{"rules": []}on an accepting release and no key on the other two.allowedTools == []andincludeMcpJson is Falseare asserted on all three,so a regression cannot trade one narrowing for another.
test_a_base_without_a_kas_block_never_gains_one— pins the guard, on theaccepting release where dropping it would show.
_pin_spec_permissions_cli+ an autouseacceptsfixture, the same helper andthe same rationale the five writers' suites already use: two pre-existing
assertions here (
derived["permissions"] == {"rules": []}andset(derived) == set(base) - {"hooks"}) would otherwise be decided by whateverbinary the test host happens to have.
RED on
2fdadc71a, before the production change:The
[accepts]arm and the guard test were green before the change too — theyare the regression guard, not the repro.
GREEN after:
test_side_readonly_spec.py+test_side.py— 40 passed;test_side.py,test_side_context.py,test_side_steer_queue.py— 68 passed.One unrelated failure is present in this module before and after the change
and was reproduced on a pristine checkout of
2fdadc71a:test_publish_never_overwrites_a_foreign_file_at_the_derived_pathraisesOSError: [WinError 1314]creating a symlink, because the Windows box it ran ondoes not hold
SeCreateSymbolicLinkPrivilege. It is environmental andunattributable to this diff.
Static gates on the committed diff:
black --check,isort --check-only,flake8,mypy --platform linux,git diff --check,scripts/check_black_formatting.pyandscripts/check_agent_sdk_boundary.py(both run after committing, so their
origin/main...HEADscope is the real twochanged files and not a vacuous zero).
Manual verification
N/A — unit coverage sufficient: the assertions read the published file itself,
under all three version verdicts the gate distinguishes, which is the artifact a
manual check would inspect.
Screenshots / video
Why no screenshot: this is a pure backend change to
src/kiro_crew/dashboard/side_readonly_spec.py(how the derived read-only agent spec is written to~/.kiro/agents/) and its unit tests. It touches no user-visible frontend surface, so there is no rendered delta to capture.Related Issues
Supersedes #13074 (original author @leonlaiyc). Follow-up to #12919 (the shared
gate and the five
agent.pywriters) and #12844 (the gate itself).Pattern harvest
Rule candidate:
review-promptPattern: a newly centralized runtime-version or capability gate is only central
once every mutation path is enumerated — a sibling writer that predates it
keeps its own write and silently defeats it. When a PR introduces a shared gate
and its own text says "every writer", grep the tree for other assignments to the
same field rather than only the writers that PR touched. A writer that assigns a
CONSTANT (here
{"rules": []}) rather than calling the derivation is the one acall-graph search misses.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement