Skip to content

feat(external-agents): set uses. use .mode once per machine through userConfig - #18621

Open
melodic-automation-lanes[bot] wants to merge 3 commits into
mainfrom
work-resolve-issue/issue-18573-45287328832-1
Open

melodic-automation-lanes[bot] wants to merge 3 commits into
mainfrom
work-resolve-issue/issue-18573-45287328832-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #18573

Summary

Opened by the work-resolve-issue lane. The run's own summary:

external-agents declares four userConfig options (antigravity_uses_task_mode, antigravity_uses_investigate_mode, codex_uses_task_mode, codex_uses_investigate_mode), each limited to read-only and write with defaults.json's value as its default; no review option. The runner now reads them through channel F (a generated copy of the shared lib/plugin-options.mjs: user settings.json located from the cache install's real path, plus managed settings) and passes them as the cascade's userConfig layer, so precedence is plugin default < userConfig < team < personal with no new merge code. Choice and basis: the read sits in runner.mjs setup() rather than loadConfig(), so loadConfig stays a pure resolver for the foundations tests, and tests inject the install and managed-file list through opts.operatorSettings (issue's proposed approach, step 2). A settings source that cannot be read, or holds a non-string value, is a config notice and sets none of the four options (the shared reader's documented fail-closed contract); a value outside the list such as "yes" is dropped per key and the key takes the team value, else the default. defaults.json is unchanged, so write stays an explicit per-user opt-in.

Not verified

  • Verified since: at head 0dc782f (main merged), node --test --test-concurrency=4 over fence, foundations, runner and update tests ran 179 tests: 174 pass, 0 fail, 5 skipped.
  • Verified since: scripts/sync-plugin-options-docs.py reports 0 READMEs changed at 0dc782f, and scripts/sync-shared-copies.sh --check reports all registered copies match.
  • Manual check from a cache install on Windows and in WSL (set the option through /config or claude plugin install --config, then external-agents status <job> for a --use task --mode write run shows mode: write) needs a host run this lane cannot make; it is for a person.
  • Tidy skipped: the change spans four areas (plugins/external-agents, docs/contracts, docs/adr, scripts) against a cutoff of 1, and touches the shared path scripts/.
  • Closed since: commit 6e9111b isolates the CLI-spawning tests from the operator's settings.
  • Behaviour to note: one non-string stored value (e.g. a hand-edited false) makes the shared reader throw for the whole source, so all four options read as unset with one notice, instead of per key. This is lib/plugin-options.mjs's documented fail-closed contract; it falls back to the repository's or…
  • Review lane: no review-venue.txt was in the scratchpad, so the review ran locally in one fresh-context subagent.

Fix

  • plugins/external-agents/.claude-plugin/plugin.json: userConfig with the four mode options (type string, options read-only/write, default from defaults.json; the agy descriptions state agy write mode has no network isolation).
  • plugins/external-agents/lib/plugin-options.mjs: new generated copy of lib/plugin-options.mjs, written by sync-shared-copies.
  • scripts/shared-copies.txt: registers lib/plugin-options.mjs -> plugins/external-agents/lib/plugin-options.mjs.
  • plugins/external-agents/scripts/lib/config.mjs: USER_OPTIONS and operatorUserConfig({install, managedFiles}), which reads the four keys with readOperatorOptions(resolveInstall(realpath of the plugin root), managedSettingsFiles(), keys) and turns an OptionsError into a config notice.
  • plugins/external-agents/scripts/lib/runner.mjs: setup() feeds operatorUserConfig(opts.operatorSettings) as the userConfig layer (a caller-supplied opts.userConfig still wins, for tests) and puts its notices first in config.errors.
  • plugins/external-agents/tests/runner.test.mjs: six tests: a user-settings write with no repository files runs agy task write with no downgrade notice; a team read-only beats it and prints the notice; unset keeps agy task read-only and Codex task write; an invalid "yes" is a notice and falls to the…
  • plugins/external-agents/tests/support/world.mjs: noOperatorSettings (no user settings location, no managed files) injected into every world's opts.
  • plugins/external-agents/tests/update.test.mjs: both worlds inject noOperatorSettings.
  • plugins/external-agents/README.md: a Configuration paragraph on the per-machine options, and the generated options block (written by hand to match scripts/sync-plugin-options-docs.py render(), which this lane cannot run).
  • plugins/external-agents/schemas/external-agents.schema.json: antigravity.uses.task.mode description names the antigravity_uses_task_mode option as the per-machine route.
  • plugins/external-agents/skills/antigravity/SKILL.md and skills/antigravity/reference/run.md: name the per-machine option beside the repository files.
  • docs/contracts/config-cascade/README.md: the external-agents Implementers row lists the userConfig layer and its channel F delivery.
  • docs/contracts/hook-config-delivery/README.md: Adopters row for the external-agents use modes (channel F, shared Node reader).
  • docs/adr/0119-...md: decision 2 names the per-machine option beside the personal or team file (decision 7 already lists userConfig).
  • .changes/external-agents/work-resolve-issue-issue-18573-45287328832-1-d7084772.md: minor changelog fragment (the release PR bumps the version, per ADR 0048).

Verification

The runner ran each check from the base copy against 5a684af:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • read https: //code.claude.com/docs/en/plugins-reference (served as the plugin manifest reference): userConfig fields type/title/description required; options needs Claude Code v2.1.271 or later; set default to one of the options or required: true; non-sensitive values are saved under pluginConfigs…
  • .lane/verify/bin/sync-shared-copies: generated plugins/external-agents/lib/plugin-options.mjs, exit 0.
  • .lane/checks/bin/check-changelog-fragments: all 40 fragments valid.
  • .lane/checks/bin/check-changed-skills: antigravity PASS, 0 errors, 1 warning (description 430 chars over the 419 warn setting; the description was not changed by this PR).
  • .lane/checks/bin/check-affected: first run failed validate-plugins on a contract warning (option titles 'agy task mode' / 'agy investigate mode' not sentence case); retitled to 'Antigravity task mode' / 'Antigravity investigate mode'; rerun: 16 passed, 11 skipped, 0 failed, with validate-plugins…
  • Fresh-context review subagent over the whole diff: no correctness findings; it confirmed by reading that the six new tests' notice regexes match the code's strings, no existing test breaks, the manifest fields are valid, and the README block matches render() character for character.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/45287328832

Left out: the items under Not verified.

Related

#18573

Lane-Activity: work-resolve-issue/resolve-issue
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 5a684af04eda9e756d9288ac8496259d0f3084a9. No person needs to act: a lane clears this reason, and the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@github-actions github-actions Bot 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.

claude-security-review: 1 inline finding(s) on 5a684af04eda9e756d9288ac8496259d0f3084a9; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 0dc782f4416b7aa1d8007933b685db369c0744d0: read 16 of 16 changed file(s); 1 finding(s), 1 as inline comments.

Security review: PR #18621 (external-agents per-machine use-mode options)

This review was blocking only: the prior-findings file says this lane already reviewed an earlier head (5a684af0). I read every hunk of all 16 changed files.

What changed. At the base, the manifest already declares antigravity_uses_task_mode. This head adds three userConfig keys and widens USER_OPTIONS to four keys (config.mjs#L11). It also lets tests inject opts.operatorSettings into operatorUserConfig (runner.mjs#L90).

Trust boundary. I checked it and found nothing exploitable:

  • Where values come from. Values come only from the operator's own user settings and managed settings, through the shared channel-F reader (config.mjs#L18-L25).
  • Precedence. A repository's team and personal files still sit above this layer, so a repository gains nothing it could not already set.
  • Test-only input. opts.operatorSettings and opts.userConfig appear nowhere under plugins/external-agents/bin/. The CLI cannot set them, so only tests can inject them.
  • Test loader hook. The registerHooks hook in tests/support/no-operator-settings.mjs loads only under --import in test spawns. It is not on the shipped load path.
  • Which keys it reads. It reads only the four mode keys, so binary_path still cannot be reached through this layer.

Manifest. The three added keys are guards, because each sets the default and the ceiling of a sandbox mode.

  • codex_uses_task_mode defaults to the permissive write. That matches the bundled defaults.json (line 6: "task": { "mode": "write" }), so nothing widens today. It is flagged inline again, because the prior thread is marked lines changed since posted: yes.
  • The other two keys default to read-only, and their values only choose between read-only and write.

Not findings. The docs, ADR, contract, schema description, skill text and test changes widen no control. The skill still says "never set the key yourself". I found no embedded instructions in the PR context.

critical-findings: 0

Manifest lines (3)
  • manifest userConfig.codex_uses_task_mode: flag, an added guard key (the sandbox ceiling for Codex task runs) whose default is the permissive value write; it matches defaults.json, so nothing widens today
  • manifest userConfig.antigravity_uses_investigate_mode: pass, advisory, picks the read-only or write ceiling for agy investigate runs; read by plugins/external-agents/scripts/lib/config.mjs:11 and :20, applied as the userConfig layer at plugins/external-agents/scripts/lib/runner.mjs:90-91
  • manifest userConfig.codex_uses_investigate_mode: pass, advisory, picks the read-only or write ceiling for Codex investigate runs; read by plugins/external-agents/scripts/lib/config.mjs:11 and :20, applied as the userConfig layer at plugins/external-agents/scripts/lib/runner.mjs:90-91

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 0dc782f4416b7aa1d8007933b685db369c0744d0: read 16 of 16 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #18621, external-agents use modes set once per machine through userConfig

This lane already reviewed an earlier head (5a684af), so this review reports blocking findings only. It found none.

The earlier finding is fixed. Last round's one finding was a closing-issue criterion that was not met: "no test reads the operator's real settings.json or managed settings". Tests that spawned bin/external-agents still read the host's managed settings. This head fixes that:

  • Shared spawner. Every spawned CLI now goes through the shared cli() helper (world.mjs#L30). The helper preloads tests/support/no-operator-settings.mjs with --import. That module uses registerHooks to point lib/plugin-options.mjs at stubs: managedSettingsFiles returns [] and resolveInstall returns userSettings: null.
  • Node version. registerHooks exists in the repository's pinned Node (.node-version is 24.21.0).
  • No other spawn sites. A search of plugins/external-agents/tests finds no other spawn of bin/external-agents.
  • Hook mechanics. The hook does not redirect the stub's own import of the real module (parentURL check). config.mjs imports four names, and the stub exports all four.
  • Probe test. A new test checks the isolation itself, with and without the hook.

Other checks, by reading the code:

  • Signature. operatorUserConfig({ install, managed }) (config.mjs#L18) takes the same shape that noOperatorSettings and the new tests pass.
  • Option list. USER_OPTIONS now lists all four keys.
  • Manifest-default test. It splits each key on _ to get the product and the use, then compares against loadConfig's values and its dotted provenance keys. This matches config-cascade and how foundations.test.mjs uses it.
  • --plugin-dir test. The managed-settings case uses pluginId: null, name: "external-agents". It matches the external-agents@test-market entry through optionsIn's startsWith rule.
  • Error text. The test that reads invalid JSON expects a message that matches optionsIn's text: settings file … is not valid JSON (…) plus ; the userConfig layer is not read.

Not verified by this lane (the author's claims, which I did not run):

  • The node test suites.
  • claude plugin validate.
  • scripts/sync-plugin-options-docs.py --check. The README block was written by hand; CI is the gate.
  • The manual check from a cache install on Windows and in WSL, which needs a person.

Loosened checks would be marked: fail (default; the prompt carried no loosened_check_verdict: or loosened_check_patterns: line); patterns: 0. The prompt also carried no loosened_check_decision_record: line, so I did not check the citation requirement. I found no loosening. The test changes swap userConfig: {} for injected operatorSettings, route spawns through the isolation helper and add tests; no assertion was removed.

Advisory and manifest lines (4)
  • manifest userConfig (new fields antigravity_uses_investigate_mode, codex_uses_task_mode, codex_uses_investigate_mode): pass. config.mjs USER_OPTIONS reads each one, and each default matches defaults.json.
  • manifest userConfig options: pass. The PR and the README name the Claude Code v2.1.271 floor.
  • manifest version (changelog fragment bump: minor): pass. The change adds features.
  • manifest description/keywords: pass. The diff does not change them, and they still describe what ships.

Verifier dropped 0 of 0 candidates.

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 24, 2026
@kyle-sexton

Copy link
Copy Markdown
Member

Held with the do-not-merge label for an owner decision: this adds user settings and managed settings as sources for the agy/Codex task and investigate mode ceilings, so one operator opt-in to write mode covers every repository on the machine, and merge-risk rates Impact HIGH on that (run 45299735532). That is a trust-boundary change with no owner-decisions row or owner quote behind it (#18573 was filed under the shared login). The owner's word releases it. Separately, pr-verify's two fail-notes (CLI tests read the real managed settings) still need a fix.

@kyle-sexton

Copy link
Copy Markdown
Member

Owner decision, 2026-11-24 ~03:08Z, in the PR lane session, verbatim: "go w/ recommenadtions". It accepts option (a): the machine-wide agy/Codex task and investigate mode opt-in from user and managed settings, as designed. The PR lane now fixes the two pr-verify fail-notes (CLI tests must not read the real managed settings) and the claude-security-review thread on the codex_uses_task_mode manifest default. It removes the do-not-merge label once those land.

kyle-sexton and others added 2 commits November 23, 2026 22:13
… settings

Every test that spawns bin/external-agents (runner, update, usage, models
and fence CLI tests) now runs it through world.mjs cli(), which starts node
with --import tests/support/no-operator-settings.mjs. That module registers
a module.registerHooks resolve hook that swaps lib/plugin-options.mjs for
itself: managedSettingsFiles() returns [] and resolveInstall() returns no
user settings location, while readOperatorOptions and OptionsError stay the
real ones. The spawned CLI therefore reads neither the fixed managed
settings path (/etc/claude-code and its Windows and macOS equivalents) nor
any user settings.json, which closes #18573's "no test reads the operator's
real settings.json or managed settings" item.

The isolation lives in the tests, not in an env var the CLI reads:
plugin-options.mjs reads no environment by design, since a repository's
settings env block reaches every process a session starts, so an env var
naming the managed directory would let a repository replace the operator's
managed policy. A new test probes plugin-options.mjs in a child with and
without the hook to show the swap takes effect.

The manifest defaults stay: claude plugin validate rejects a userConfig
field with options and no default ("a field with options needs a default
among them, or required: true"), matching the plugins reference. A new test
pins each of the four manifest defaults to the value the cascade resolves
from defaults.json with the option unset, so a later change to
defaults.json fails CI until the manifest default moves with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/contracts/hook-config-delivery/README.md
#	plugins/external-agents/.claude-plugin/plugin.json
#	plugins/external-agents/README.md
#	plugins/external-agents/scripts/lib/runner.mjs
#	plugins/external-agents/skills/antigravity/SKILL.md
#	plugins/external-agents/skills/antigravity/reference/run.md
#	plugins/external-agents/tests/fence.test.mjs
#	plugins/external-agents/tests/support/world.mjs

@github-actions github-actions Bot 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.

claude-security-review: 1 inline finding(s) on 0dc782f4416b7aa1d8007933b685db369c0744d0; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

Comment on lines +42 to +46
"codex_uses_task_mode": {
"type": "string",
"title": "Codex task mode",
"description": "Default and ceiling for Codex task runs on this machine, in every repository. write (default) or read-only. A repository's team or personal external-agents.yaml overrides it.",
"default": "write",

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.

manifest userConfig.codex_uses_task_mode: flag, an added guard key (the sandbox ceiling for Codex task runs) whose default is the permissive value write

This option sets the default and the ceiling for Codex task runs. USER_OPTIONS in config.mjs (line 11) lists it, and setup() in runner.mjs (lines 90-91) applies it as the cascade's userConfig layer. That makes it a guard, and its manifest default is the permissive value.

It widens nothing today.

  • The default matches the bundled defaults.json (line 6: "task": { "mode": "write" }), so users who never set the option keep the same Codex task mode as before.
  • The reader only takes values the operator actually stored under pluginConfigs in user or managed settings.
  • A repository's team or personal file still overrides it.

Residual risk. If Claude Code writes this default into pluginConfigs when a user configures the plugin, write becomes an explicit userConfig value. A later change of defaults.json to read-only would then not reach those users. Choose this default deliberately, or confirm that only values the user explicitly set are saved.

severity: IMPORTANT

claude-lane: claude-security-review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Accepted under the operator-only userConfig rule (owner-decisions Q261; D16/D22). Exposed surface: none outside the operator. The value is read only from the operator's own user or managed settings (pluginConfigs), the write default equals the bundled defaults.json task.mode today, so it widens nothing, and a repository team or personal file still overrides it. Condition that would make it matter: a change of defaults.json task.mode to read-only. That change must also flip this manifest default, or confirm that Claude Code stores only values the user explicitly set. Resolution goes through the hub on the owner's word.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Hard merge gate: do not merge while applied.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(external-agents): let a user set uses.<use>.mode once per machine via userConfig

1 participant