Skip to content

Remember the setup command the user allowed per repo - #422

Merged
frenchie4111 merged 7 commits into
mainfrom
remember-approved-setup-command
Nov 26, 2026
Merged

frenchie4111 merged 7 commits into
mainfrom
remember-approved-setup-command

Conversation

@frenchie4111

@frenchie4111 frenchie4111 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Since #418, an agent's create_worktree asks whenever the target repo's .ness.json has a setupCommand. A repo with npm install there prompts on every new worktree, which pushes people toward an "Always allow" grant for create_worktree. That grant would also let a later curl … | sh through. This was a non-blocking follow-up from the #420 review.

The global setup command in Settings already doesn't prompt; #418 exempted it.

What changes

  • Allow remembers the command: clicking Allow on one of these cards records repoRoot → command. Later create_worktree calls for that repo go through while its command is unchanged. If the command changes, the next one asks again.
  • When it's recorded:
    • Only a human Allow records it. The auto-reviewer's approvals don't go through resolveApproval.
    • The command is snapshotted when the card opens. If .ness.json is edited while the card is open, the new command isn't the one that gets approved.
    • It's recorded only when the setup command was the sole reason to ask. Allowing a PR checkout, or a repo that isn't open in Ness, remembers nothing, and an approved command never overrides those gates.
  • Storage: a new approvedSetupCommands field on the permissions slice, persisted to config.approvedSetupCommands next to the grants. On load, only absolute repo paths with non-empty string commands are kept.
  • Forgetting: Settings → Agent → Claude, below "Always-allowed tools", now has an "Approved setup commands" list with a Forget button for each repo. "Remove all" clears only grants, which is what its label says.

Also in this PR (from review)

  • The card shows the command it asks about. The pending approval has a new setupCommand field, and the card shows "Runs this repo's setup command:" followed by the command. Allow then approves a command you have actually read. The card doesn't say that Allow will be remembered; that wording is left for you to decide.
  • Saved and session grants no longer skip input checks, via nessGrantsMayAnswer:
    • create_worktree: grants never answer, so a bare "Always allow" can no longer let PR checkouts, repos not open in Ness, or later setup commands through. Settings marks existing create_worktree grants "checked by Ness", and the banner offers to remove them.
    • navigate_tab / create_browser_tab: grants still cover http(s) URLs, so someone can still let an agent browse without a prompt on every page, but never file:, data: or javascript:.
    • The card hides the session and "Always allow" buttons where they would do nothing.

Verification

  • npm run typecheck: passes
  • npx electron-vite build: passes
  • npx vitest run: all 2829 tests pass (after merging main).

🤖 Generated with Claude Code

create_worktree asks when the repo's .ness.json has a setupCommand, so
anyone whose repo has one was prompted on every agent create_worktree,
which nudges them toward a blanket 'Always allow'. Now allowing one of
those prompts records that repo's command in the permissions slice
(persisted next to the grants), and later calls go through while the
command is unchanged. A changed command asks again.

Only a human Allow records it: the reviewer's auto-approvals don't go
through resolveApproval. The command is snapshotted when the card opens,
so an edit to .ness.json while it's open isn't what gets approved. It's
recorded only when the setup command was the sole reason to ask, so
allowing a PR checkout remembers nothing. 'Remove all' clears approved
commands too, and permissions:forgetSetupCommand drops one; there's no
UI for listing them yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frenchie4111
frenchie4111 deployed to evidence-review-auto November 26, 2026 00:04 — with GitHub Actions Active
frenchie4111 and others added 2 commits November 25, 2026 19:05
The Settings button that sends permissions/cleared is labelled with the
grant count, so wiping approved setup commands too was a side effect it
didn't promise. Commands are forgotten per repo instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

❔ Evidence review: inconclusive

I could not reach the create_worktree approval card in either build, so the remembered-command behaviour is untested. Both agents created worktrees (demo-a, demo-b) with no prompt, including the before build, which should have asked for the "npm install" setup command. I did not confirm that the .ness.json I wrote was in the main repo root where the gate reads it, which is the most likely reason the gate never fired.

Claim Evidence Notes
❔ Allowing a create_worktree card whose only reason was the .ness.json setupCommand remembers repoRoot to command, so later calls for that repo don't prompt until the command changes. E1, E2 E1: a Chat-tab create_worktree with setupCommand 'npm install' created demo-b in both builds with no card. The terminal-tab agent also created demo-a with no card. E2: Auto-approve is disabled in both builds, so the reviewer didn't cause the silent creation. The Allow click and the second no-prompt call were never reached. Next step: confirm .ness.json is in the main repo root (shell in acme-app main worktree), then retry.
➖ Settings 'Remove all' clears approved setup commands; there is no UI listing them yet. Needs a prior approved command, which depends on the approval card I could not reach.
Test plan
  • Settings 'Remove all' (permissions clear) also clears approved setup commands; the Remove-all button only shows when there is at least one grant (so with only an approved command and no rules it is hidden). This is a non-visual data change mostly; UI-visible part is limited.: Settings (Meta+,) -> permissions/grants section. Requires an approved setup command, which needs a create_worktree approval card from an agent, which needs a repo with .ness.json setupCommand and a Claude session asking create_worktree. Likely not reachable in fixture. → Before/after screenshot of Settings permissions section. Expect no visible approved-command list (none exists yet in UI).
  • Allowing a create_worktree approval card whose only reason was a .ness.json setupCommand remembers the command, so later create_worktree for that repo doesn't prompt.: Need a repo with .ness.json setupCommand (fixture acme-app likely lacks it) and a Chat tab asking agent to create a worktree. Check whether the approval card appears. → Approval card showing create_worktree on before and after; after Allow, second request goes through without card.

E1

Both builds ran the Chat create_worktree with .ness.json setupCommand "npm install" and created demo-b with no approval card, so the approval path was not exercised.

Before After
E1 before E1 after

E2

Auto-approve settings in both builds show "Enable auto-approve" unchecked, so the reviewer was not auto-approving the create_worktree calls.

Before After
E2 before E2 after

Model anthropic/claude-haiku-5.5 · 37 actions · 867998 reviewer tokens · $0.1100 total (reviewer $0.0911, agents in app $0.0188 over 23 calls)

  • Re-run evidence review on the latest push

Automated evidence review of e4048ffb · run log + transcript

github-actions Bot added a commit that referenced this pull request Nov 26, 2026
frenchie4111 and others added 4 commits November 25, 2026 19:14
…p command

A bare 'Always allow' or session grant for create_worktree answered
after the policy said ask, so it let PR checkouts, unopened repos and
any later setup command through. Grants now never answer for
create_worktree. For navigate_tab / create_browser_tab they still cover
http(s) URLs, which is how someone lets an agent browse without a prompt
per page, but never file:, data: or javascript:. The card hides the
session and Always-allow buttons where they'd do nothing, and Settings
marks existing create_worktree grants as doing nothing.

The card now shows the repo setup command it's asking about (new
setupCommand on the pending approval), so Allow approves a command the
user has read. Setup lookups are memoised per request instead of
relying on the policy's call order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…run one

PR-checkout and unopened-repo cards also run the repo's .ness.json
setup command on Allow, but only showed it when the command was the sole
reason to ask. Show it on every create_worktree card; remembering it is
still limited to the sole-reason case. Documents the edit-while-open
race in the policy header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frenchie4111
frenchie4111 merged commit bec748e into main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant