Repository navigation
feat: name program and target tokens in self-kill refusal - #15055
SaRedfiche wants to merge 1 commit into
Conversation
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Mirrored copy of Watch
[DESIGN-REVIEWED] 49c9558 Description read[DESCRIPTION-READ] 5f37ab90880dd1996ddd103a639e6f7697fd4136021c4e70272234b460314db7 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 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- src/kiro_crew/security/init.py:1443 -- length-expanding Unicode in |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (8 items) — 7 justifiedIntent: let a reader of a self-kill refusal see which two tokens tripped the floor, distinguishing real kills from false positives (#14827). ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 49c9558 Description read[DESCRIPTION-READ] d834592009f8f51499182631352340d7d3bdc9c395fe0751dcc5835bf0b794cc That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo blocking findings — the new FINDING — src/kiro_crew/security/argv_floor.py:1052 — FINDING — src/kiro_crew/security/init.py:1444 — [OPUS-REVIEWED] 49c9558 |
Security Scope Review (fork) — ✅ PASSWhich legitimate operations does adjudicated, zero confirmed regressions Scope-Verdict: PASS TIGHTENING: The ADJUDICATED: 15 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix (10 rows), windows (3 rows), any (2 rows). The diff's only platform-shaped assumption is [SCOPE-REVIEWED] 49c9558Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. |
f9d5476 to
58b337b
Compare
The self-protection-kill refusal diagnostic now carries additive program and target offset fields with the same char-class census, so a reader can tell a real by-name kill from a glob-argument false positive without running the classifier. A new raw-word-span splitter aligns the resolved frame tokens to their real source offsets by index, so even a shell-variable-resolved glob token is bracketed at its true position. The span field and the first two refusal lines are byte-identical when the fields are omitted, and no field carries a byte of the command.
58b337b to
49c9558
Compare
|
Thanks for this, @SaRedfiche! This PR had readiness: passed but fell into conflict with |
Problem / Motivation
Goal: Make the self-kill refusal say which token it read as the kill program and which as the target, so a reader can tell a real kill from a false positive without running the classifier.
When the self-protection floor blocks a command, its refusal diagnostic reports only a whole-command
span=0..N. That is enough to see the floor fired, but not why — a reader cannot tell whether the block was a genuinepkill kirocrewor a false positive where an innocent argument (a glob path whose basename is*, next to a path carrying the product name) happened to look like a by-name kill of this gateway.Why it matters
The self-protection floor is meant to stop the agent killing its own supervisor, but a false positive silently blocks ordinary work with no way to diagnose it short of reading the classifier source. Naming the two token offsets turns "this was refused, and here is exactly which two words tripped it" into something a reader can act on.
Not a goal
self-protection-killonly.What changed (motivation → approach → change)
The self-kill refusal reported only a whole-command span, so a false positive gave a reader no way to see which two words the floor keyed on. The fix adds two optional fields to the refusal diagnostic —
program=<a>..<b>andtarget=<c>..<d>— each with the same char-class census the existingspan=already carries.Locating those offsets is the work. A new
_raw_word_spans()splitter walks the shared quote/escape state machine to break the command into shell words at their real source offsets, keeping quoted separators inside their word and an abutting operator as its own span._self_kill_token_spans()then aligns those raw spans to the resolved frame's tokens by index — sound because both derive from the same word split, before per-word variable and tilde resolution — so a variable-resolved token like"$C"/gateway/*is bracketed at its true position even though the product name entered it by$Cexpansion.argv_floor._raw_word_spansargv_floor._self_kill_token_spansNoneto fall backdiagnostics.RefusalTokenSpan+refusal_diagnostic()span=and the first two refusal lines are byte-identical when they are omittedsecurity/__init__.pyself-protection-killonly and threads them throughA leg with no single-token target (bare
kill $(...)) returnsNoneand keeps the whole-command span.docs/system-specs/modules/security.mddocuments the token-level exception in the same change.Backwards compatibility
Compatible: the fields are additive and omitted for every floor except
self-protection-kill; thespan=field and the first two refusal lines are byte-identical when they are absent, which the tests pin.Tests
A new
TestSelfProtectionKillDiagnosticSpansclass (10 tests) covers all shapes:pkill -f kirocrewandkillall kirocrewbracket the program and target tokens; the variable-resolved glob command brackets its real source offsets; a quoted ERE pattern brackets its raw region;kill $(pgrep -f kirocrew)and a non-self-kill fall back with no fields; every other floor's line stays byte-identical; and_refusal_diagnostic_idstill reads the rule id. The denied-command count pin and the keystonetest_sandbox_governance_maskcontinue to hold.Manual verification
N/A — unit coverage is sufficient; the change is a diagnostic string and its offset computation, both fully exercised by the new tests against real
is_deniedoutput.Related Issues
Fixes #14827
Pattern harvest
Not generalizable: this is a targeted diagnostic enrichment for one floor whose decision is already token-level; the offset-alignment approach is specific to the self-kill by-name leg and does not describe a defect class worth a lint or review rule.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)