Repository navigation
feat(external-skills): preview, trust policy, safety lint, and rollback for external skills - #845
Conversation
…ck for external skills Installing an external skill now takes a previewed, user-approved payload: - sumo_qa_preview_external_skill stages the resolved commit through the pinned Skills CLI into a scratch folder and returns its files (size, SHA-256, executable bit), content_digest, source trust tier, detected capabilities, and safety-lint findings. It installs nothing. - sumo_qa_install_external_skill requires approved_digest (the preview's content_digest) and refuses a payload that no longer matches it, so an upstream change after the preview writes nothing. A mutable ref or a source outside the trust policy needs elevated_trust; a denied source is rejected. The trust policy is read from ~/.sumo-qa only. - A deterministic lint with stable rule ids (SQA-EXT-001..013) flags instruction override, concealment, piped remote code, credential files, writes outside the project, and destructive deletes as critical, which block install and handoff with no override; lower severities are disclosed. Findings never carry the matched text. - Execution lints SKILL.md again and marks the body untrusted, framed so it cannot override system, developer, user, or sumo-qa instructions. - A reinstall keeps the superseded record in a bounded per-folder history. sumo_qa_rollback_external_skill restores the previous approved version from its recorded commit and digest, or removes a first install. The suggesting-external-skill skill gains the preview step and a separate payload-approval gate; docs cover the flow and the trust policy file. Refs #520
…keep critical lint to dangerous shapes Trust policy: every spelling of a repository (case, scheme, user, port, www., trailing slash, .git) now maps to one identity on both sides, so denied_sources cannot be bypassed by respelling; entries naming a #ref or @skill fail closed. Rollback: acts only on <root>/<name> lock keys (a repo-shipped lock with a .. or absolute key is refused), needs an agent when several agents' installs match, refuses to delete a first install whose folder no longer holds the recorded digest, re-checks trust for the version it restores (elevated_trust parameter, threaded through the server tool), refuses a history record for another skill, and reinstates the original record. Errors carry rollback-specific hints. Lock: history must be lists of records with the fields rollback reads; a reinstall of the same digest pushes no history. Lint: critical rules match the dangerous instruction itself and skip a negated one; mentions of credential files, shell profiles, and a role reassignment are high (SQA-EXT-014..016), disclosed and non-blocking. SKILL.md: a preview isError offers the next candidate. tools/list snapshot regenerated for the rollback parameters.
…pe rollback to the named skill Critical lint rules no longer exempt a negated command shape: any download-execute, private-key read or send, shell-profile write, or destructive rm anywhere on a line blocks. Only an instruction override directly preceded by "do not", "don't" or "never" is skipped, and every match position is checked. The download-execute, key and profile rules also catch interpreter pipes, sh -c/eval of a download, irm then iex, include/attach/share of a key, and quoted or braced $HOME targets. Rollback acts only on records of the named skill, refuses a folder the user edited or another agent's link points into, keys a restored record to the folder written with the restore's own trust and time, and requires a path on every history record. A restore that fails after the CLI ran and a broken trust policy file get their own error types and accurate hints.
…ollback to its own agent's folders Rollback: a removal no longer counts this install's own links as targets, so agents sharing a canonical copy can each unlink their own link; a restore through a link into a folder recorded for another agent is refused; a restore pops only the history entries it brought back and records the installer CLI that wrote the folder; the restore guard uses the same sanitised-folder test as rollback path selection. Lint: command rules read logical lines (joined at a trailing \, |, && or ||) and instruction rules read markdown paragraphs; each joined line is linted up to 4000 characters, with SQA-EXT-017 disclosing a longer one; verb-led rules start at the first verb so a line stays linear. SQA-EXT-002 gets the directly-negated exemption. One batch of known variants of 003 to 006 now blocks. Docs say plainly the lint is a deterministic known-shape matcher, not a malware detector.
…markdown blocks, and bound every rule
… text and keep rollback reachable Instruction rules (SQA-EXT-001, 002) now match the whole file with each line's markdown markers stripped and every whitespace run collapsed, so no soft wrap in a paragraph, blockquote, list, table, fence or heading splits a phrase; a negation exempts a match only on the verb's own line. The paragraph, block-boundary and fence-state logic is removed. Command rules keep logical lines, physical lines and windows. Rollback restores the newest history record of the rolled-back agent and treats a folder with none as a first install, so an agent switch on a shared folder no longer deadlocks. The circular refusal appears only when the other install is blocked too. SQA-EXT-005 reads each whitespace run once.
…backslash-wrapped instructions Rollback acts on one agent's install of the named skill (the agent given, or the single one recorded) and refuses a shared install before anything changes: a folder whose record or history names another agent, a folder linked with another agent's recorded folder (to, into, or through), or several recorded agents with no agent given. The chain, circle and subfolder link handling, the agent-filtered history pick and the cross-agent history drop are removed. A restore pops the history entry matching its digest, agent and resolved ref. The instruction rules drop a line's trailing continuation backslash before joining, so a backslash-wrapped override or hiding instruction is critical again. The pathological-input timing test runs through lint_skill_file.
…, and recheck under the restore's guard
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbb42f24e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…y write An agent could copy a preview's content_digest into approved_digest and install with no user involved. Install, restore and removal now take an injected approver; the server supplies one that elicits a yes/no from the user showing source, commit, digest, trust tier and reasons, and every finding. A decline or cancel writes nothing, and a host that did not declare elicitation (or whose prompt fails) is refused with the manual npx command; there is no agent-only fallback. Removal re-checks its plan after the user answers instead of holding the lock while asking. Also in this change: - lock records carry the set of agents per folder (legacy agent read as a one-agent set); a reinstall merges it and rollback refuses a shared folder - rollback refuses a folder any unrecorded link under the skill roots reaches - the lock merge refuses a malformed current record before it reaches history, and a restore keeps a replaced record that had no history entry - SQA-EXT-003 iex and SQA-EXT-006 rm patterns no longer backtrack polynomially on whitespace or repeated --rm flags - source identity maps ssh.github.com to github.com and drops port and www. only on GitHub - text lint skips binary assets and reads each payload file once - hints name the preview, approved_digest and the user prompt - the fake Skills CLI writes bytes, so Windows digests match
…capes, and harden the approval prompt - Lint every payload file: decode with replacement, read NUL as whitespace, and disclose bytes past the 1 MiB cap as SQA-EXT-017 instead of skipping a file with a NUL byte or invalid UTF-8. - Drop each scheme's default port from a source's identity, so gitlab.com:443 or :22 no longer escapes a deny or trust entry. - Refuse a rollback when a skill root or its parent is linked onto the folder, when a folder under the roots cannot be listed, or on a link loop (a typed error, not RuntimeError). - Pin the manual fallback command to the reviewed commit: clone, check out the commit, and hand the pinned CLI that checkout. - Escape payload and lock values in the approval prompt, cap the findings list, and name the folders the install may write with what each replaces. - Ask only through form elicitation on a request that can reach the client; an unanswered prompt (300 s) or a cancelled call is a decline, and the SDK gets its cancellation back. - A lock record whose agent is not in its agents is unreadable. - Grant the real-CLI smoke test the user's approval it now needs.
… recheck targets under the write guard, and name every folder the CLI writes - A payload file over the 1 MiB lint cap is the critical finding SQA-EXT-018, which blocks install and handoff; SQA-EXT-017 keeps only the long-line disclosure at its own line. - Lines break at \n only (a CRLF line's \r dropped), so \v, \f, \x85, U+2028 and the like no longer split one shell command. - A link on a rolled-back folder's own path (.claude -> ~/dotfiles/claude) no longer refuses the rollback; any other spelling that reaches the folder still does. - The folders the approval prompt showed are compared again under the write guard; a change made while the prompt was open writes nothing. - A global claude-code install lists $CLAUDE_CONFIG_DIR/skills/<name>, where skills@1.7.0 writes it, as a folder sumo-qa does not track. - The content digest pins each file's executable bit (none on Windows). - A failed update puts back each folder the CLI rewrote, so the folder matches the lock record that stays. - A decline caused by concurrent.futures.CancelledError hands the cancellation back, as for asyncio.CancelledError.
…ead bare carriage returns as line breaks, and back up only this agent's folders The content digest hashes paths and bytes only again, so a lock recorded on any platform or by an earlier release verifies. Each record lists its executable files apart (executable_files); execution, rollback and the install's check of the folders it wrote compare them on POSIX, and the approval prompt always lists every executable-file finding. A bare carriage return now ends a lint line. The install backs up only the folders the CLI writes for this agent, and a backed-up folder link is recreated as a folder link on Windows.
…n Windows, and list higher findings before executable files in the prompt
…y rollback, and state the approval prompt as it is
Finish evidence for head 5e24c81Verdict: merge-ready. All 8 acceptance criteria of #520 are met, CI is green, the mutation gate passed, and 0 review threads are unresolved. Acceptance criteria (#520)
Behaviour ledger (real surface)
Review
Gates
Known limitations (in the PR body)
|
🤖 I have created a release *beep* *boop* --- ## [0.75.0](v0.74.0...v0.75.0) (2026-10-05) ### Features * **external-skills:** preview, trust policy, safety lint, and rollback for external skills ([#845](#845)) ([d1a8f73](d1a8f73)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
Summary
confirmed=truerecorded consent to install an external skill but never showed the exact payload, its source trust or its instruction risks, and an installedSKILL.mdwas handed to the host as executable guidance with no safety boundary or rollback. Now the user previews an exact immutable payload, sources are checked against a trust policy, a deterministic lint flags known dangerous shapes (critical findings block), every write is approved by the user in a prompt the server shows through MCP elicitation, the handoff marks the skill untrusted, and a single-agent install can be rolled back.Related issue
Closes #520
Changes
src/sumo_qa/external_skills.py:preview_external_skill): stages the pinned Skills CLI's output in a scratch folder (removed on every path) and returns commit, per-file size/sha256/executable bit,content_digest, trust tier, capabilities and lint findings; installs nothing. Links out of the checkout or into.gitare refused.approved_digest, re-stages, and refuses before writing if the digest differs or a critical finding exists, then checks every written folder against the approved digest and executable set. A failed install puts each folder back as it was (an update keeps the previous version) or removes a new one.standardonly for a trusted source pinned to a commit SHA; otherwiseelevated(unlisted_source,mutable_ref) and needselevated_trust=true. Allow/deny lists come from~/.sumo-qa/external-skills.policy.jsononly; a broken policy fails closed. Source identity is normalised so a deny entry cannot be bypassed by spelling.SQA-EXT-001..018, findings carry rule/severity/file/line/count/message, never the matched text): a known-shape detector, not a malware detector. Critical rules block with no override, including018for a file over the 1 MiB lint cap. Lines break at\r\n,\rand\nonly. Every payload file is linted whatever its bytes.content_digest(bytes and paths, identical on every platform) andexecutable_files, checked on POSIX at execute and rollback.SKILL.md, verifies files against the record, and returnstrust: "untrusted"with framing that forbids overriding higher-priority instructions.rollback_external_skillrestores the previous approved version of a single-agent install or removes a first install. A skill recorded for more than one agent is refused as shared; every check re-runs under the restore's own guard.src/sumo_qa/server.py,server_schemas.py,tool_registry.py: new toolssumo_qa_preview_external_skillandsumo_qa_rollback_external_skill(both in theexternalgroup), install gainsapproved_digest/elevated_trust, the elicitation approver, strict output models and rollback error hints.skills/sumo-qa-suggesting-external-skill/SKILL.md: preview step, approval flow, untrusted framing, undo step. Docs:docs/TOOLS.md,docs/CONFIGURATION.md,docs/ARCHITECTURE.md,README.md, scenarios.Behaviour change: install now needs
approved_digestfrom a preview and the user's yes in the elicitation prompt;confirmed=truealone no longer installs. The bundled skill is updated in this PR.Drift from the issue text (recorded on #520): #513 already provided digest verification; rollback of a first install stands in for a separate uninstall tool; the bounded per-folder history is the install history; the policy file is read from home only; approval moved from the agent's
[y/N]to server-side elicitation.How it was verified
sumo-qaserver over stdio with an MCP client answering the elicitation prompt (accept, decline, no callback) and the real pinnedskills@1.7.0, on a fresh clone and a temp HOME; the real~/.claude/skills,~/.agents,~/.codexand~/.sumo-qaunchanged before and after. Covered: install gate and prompt contents, elevated trust, lint findings (including an over-cap file, a vertical-tab-split pipe and CR-only line endings), critical block with zero prompts, edited-content and changed-executable refusal at execute, untrusted handoff, rollback restore and remove (including a symlinked~/.claude), lock contents, and a headless haikuclaude -pagent unable to install without the user.using_sumo_qa,check_external_skill_installedandsearch_external_skillsreturn identical output on this branch and on main through the same agent.skill-suggesting-external-skill.yaml1/1 and the conversion config 10/10; no eval input changed since, so the results are reused./code-reviewhigh on the whole diff, then on each fix delta (13 rounds); the last three rounds were limited to regressions against main, writes without a user yes, unmet acceptance criteria and false docs.Known limitations
server/discover). On that protocol the server cannot send an elicitation prompt, so every install through sumo-qa from that host is refused with the manual command. Safe (nothing is written without a yes), but the in-chat approval does not appear there. The 2026InputRequiredResultflow is not supported.CLAUDE_CONFIG_DIRoutside~/.claudefails after the CLI writes, and one pointing at another tracked root is not backed up before an update (both pre-existing on main): [Bug]: global claude-code external skill install fails and leaves an unrecorded folder when CLAUDE_CONFIG_DIR is set #847.SQA-EXT-010in the install prompt, not refused.| fish, a pipe after a bare carriage return (a shell reads\ras an ordinary character, the lint reads it as a line break, as on main), two-step download-then-run and other spellings outside the listed shapes. The preview, the user's approval and the untrusted handoff are the primary controls.SKILL.md, its eval quote andSCENARIOS.mdcarry em-dashes on lines this PR rewrote;scripts/check_no_em_dashes.pydoes not scanskills/.Checklist
pytest) and lint/type checks are green (pre-commit run --all-files,python -m mypy)