Repository navigation
fix(host): a workflow token widened outside every agent job is not counted as what the agent may do (#1011) - #1138
Merged
pengfei-threemoonslab merged 4 commits intoNov 14, 2026
Conversation
…unted as what the agent may do (#1011) A workflow whose agent job (`analyze`, claude-code-action, `contents: read`, `issues: read`) gained a sibling job that runs no agent (`publish`, `issues: write`) printed `1 change(s), 1 widening what the agent may do (⚠).`, and the Stop hook listed the row under "These rows widen what the agent can do", while the agent job's token was byte-for-byte unchanged. Fix the claim, not the gate. One engine predicate, `workflow_widening_outside_agent_jobs` in core/host_grants.py, computed beside the workflow branch of host_grant_expansion_signals (now the shared `_workflow_expansion_signals` / `_gained_workflow_writes` helpers), places a widened workflow change outside every agent job. It fails closed: `None` (the agent's) unless both sides publish job contexts, the only expansion signal is `workflow_write_*`, no job holds write-all, no step reference moved between jobs, every gained write scope is in a job with no agent launch (read or unread), reusable workflow call or unreadable steps on either side, and every such job is on both sides, explicit, and kept the same declaration, effective writes and reusable call. A workflow with none of those anywhere is placed the same way. The row reads it: its `why` names the gained scopes and the agent jobs that kept their tokens and holds the `; ` clause `widens a workflow job's token outside any agent job` (capability_diff_rows.OUTSIDE_AGENT_JOBS), as DIRECTION_UNKNOWN is a clause (#820). `diff`'s summary counts such a change apart (`1 widening a workflow job's token outside any agent job (⚠)`), the counts adding up to review.summary.widenings, and the generated Stop hook, which renders the clause at install time, names those rows under their own heading. `expands`, direction, severity, cells, drift signals, check decisions, verify gates, baselines, grant ids and every JSON shape are unchanged. Docs: CHANGELOG (Host comparison), a STABILITY migration note, the capability_diff registry row and its parity-test note, docs/integrations.md and docs/quickstart.md on the marker. New test file measured into tests/shard_seconds.json as a supplemental increment.
CHANGELOG (Unreleased, Host comparison) and a STABILITY migration note state what moved: the row's why clause, diff's split summary and the Stop hook heading, and what did not (expands, direction, severity, signals, gates, JSON shape). The capability_diff registry row and its parity-test note name the predicate and its test; docs/integrations.md and docs/quickstart.md say a workflow-job widening outside any agent job is still marked and counted apart.
pengfei-threemoonslab
added a commit
that referenced
this pull request
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1011
What was wrong
A workflow whose agent job (
analyze,anthropics/claude-code-action,contents: read,issues: read) gains a sibling job that runs no agent (publish,issues: write,run: echo) printed:The Claude Code Stop hook put the same row under "These rows widen what the agent can do". The job cells and the #823 note were right, and the token declaration did widen. But the agent job's token was byte-for-byte unchanged, so the summary claimed more than the job-level facts showed.
What changes (Option A: fix the claim, not the gate)
On the issue's reproduction this branch prints:
Compared with main's
diff --jsonon the same repro, only the row'swhyand the review change'swhydiffer.review.summaryis still{changes: 1, rows: 1, widenings: 1}.Engine, one predicate.
workflow_widening_outside_agent_jobs(before, after)lives incore/host_grants.py, beside the workflow branch ofhost_grant_expansion_signals. That branch is now the shared helpers_workflow_expansion_signalsand_gained_workflow_writes, so the signal and the predicate read one computation. The predicate fails closed. It returnsNone, which counts the change as the agent's, unless all of these hold:permission_contexts. A legacy grant counts as the agent's.workflow_write_*. Sopull_request_target,secrets: inheritandworkflow_agent_widened_*each keep the change the agent's.write-allon either side.unread_agent_runs), a reusable workflow call, or unreadable steps.permissions, an agent job on repository defaults, and an agent job new in the change each keep it the agent's.A workflow where the audit finds none of those in any job gets the same label.
Rows (
core/capability_diff_rows.py). An expanding workflow row reads the predicate and appends to itswhy:OUTSIDE_AGENT_JOBS = "widens a workflow job's token outside any agent job".This reuses the Hook, MCP server, plugin, permission-mode and sandbox edits are labelled widenings even when they narrow or disable #820
DIRECTION_UNKNOWNmechanism: a defined whole;clause, whichwidens_outside_agent_jobs(expands, why)reads. The renderer derives nothing itself.diffsummary (cli/diff.py). Such changes are counted apart, e.g.2 change(s), 1 widening what the agent may do, 1 widening a workflow job's token outside any agent job (⚠).The two counts add up toreview.summary.widenings.Stop hook (
cli/install_hooks.py). The generated script rendersOUTSIDE_AGENT_JOBSat install time and lists those rows underThese rows widen a workflow job's token outside any agent job:. It still announces them, and the announcement digest is unchanged.Unchanged:
expands,direction, severity, cells, driftexpansion_signals,checkdecisions and violations,verifygates and control state, baselines, grant ids and every JSON shape. No field or schema is added. The PR comment renderer andreview_questionalready said "declared capability change"; I confirmed that and did not touch them.Surface discipline
No new surface: no command, schema version, JSON field or summary block. This edits the wording of the existing
capability_diffsurface and of the Stop hook. Thecapability_diffrow indocs/distribution-surfaces.mdand its note intests/test_distribution_surface_parity.pyare updated. The metric it moves is noise rate: a non-agent publisher job no longer reads as an agent widening.Tests
tests/test_workflow_job_scoped_widening.py(new, 32 cases, measured intotests/shard_seconds.jsonas a supplemental increment):diff --json, thedifftext, drift signals,checkagent-boundary-json, theverifyverifier.jsonrow and summary, and the Stop hook.clauderun gains;write-all;pull_request_target;secrets: inherit;bypassPermissionsrule;difftext and the hook.diffsummary adds up toreview.summary.widenings. The Stop hook gives each kind its own heading, and a look-alike clause in parentheses does not match. The rendered hook holds the engine's constant.tests/test_actions_token_scope.py::test_control_an_ordinary_job_write_grant_still_widenspinned the exactwhyof an agent-less workflow. Its expectation now includes the new clauses. It still widens.Coordination notes
Rendered hook script. The rendered hook script's bytes change: a new rendered constant and the split in
_route_host_diff. No render-hash or prior-hash list pins the hook script, so nothing needs recomputing. The new constant sits afterDIRECTION_UNKNOWN, clear of fix(trust): check and the Claude Code hook protect a declared policy pack (#1128) #1130's hunks.Expected conflicts with fix(host): a tightened deny or ask rule is not a widening; lifted denials rate by what they restricted (#1036) #1136 (checked with
git merge-tree):## Unreleased→### Host comparisonheading inCHANGELOG.md;capability_diffrow indocs/distribution-surfaces.md.host_grants.py,capability_diff_rows.py,docs/quickstart.mdand the parity test merge cleanly. Against fix(trust): check and the Claude Code hook protect a declared policy pack (#1128) #1130, onlyCHANGELOG.mdandSTABILITY.mdconflict, both at the insertion point;install_hooks.pyandtests/shard_seconds.jsonmerge cleanly. Whichever PR merges second keeps both sides.Local gate:
pytest -m "not perf" -n auto -rfEswith the lock venv (pydantic 2.14.3) gave 2 failed, 24097 passed, 16 skipped, 120 xfailed. Both failures aretests/test_check_unmodelled_host_config_keys.py[local_settings_enabled_plugins-worktree|git_range], the known local XDG git-ignore failure: the fixture's basegit commitexits 1.ruff check .is clean, andscripts/generate_schemas.py --checkis clean under the lock venv.Protected paths: none touched (
.github/,pyproject.toml,constraints/,AGENTS.md,CLAUDE.md, frozen schemas).Written by Claude Code (Opus 5.5). The main session reviews the diff.
🤖 Generated with Claude Code