Repository navigation
feat(claude): keep work-only permission rules across settings merges - #253
Conversation
The settings merge replaced permissions.allow and deny with the tracked lists, so rules added by hand on one machine were lost on the next run. Both lists are now a union: the tracked rules, then an optional machine-local fragment's, then the live file's own, each once in a stable order. The fragment may carry only those two lists and is refused otherwise. Work machines render that fragment from the claude_permissions_allow field of the 1Password item op-work-item names, so work-specific rules stay out of the tracked settings. A host without op-work-item skips the render, and a new or changed fragment is applied in the same run by a handler.
PR Reviewer Guide 🔍(Review updated until commit 4f4cdf5)Here are some key observations to aid the review process:
|
|
PR-Agent run 44250475662.1 on 4f4cdf5: success |
|
@cubic-dev-ai review this PR |
@inkatze cubic can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 40,041 of the 40,000 allowed lines of code this month. Reviews resume on 2 December 2026 (in 20 days). Paid plans include much higher monthly review limits. Upgrade now to resume reviews. To help optimise your usage, you can tune cubic to get the most out of your usage limits:
|
…he add-only union The merge validated and then re-read the fragment, treated a blank file as invalid, and accepted whitespace-only rules. It now reads once, treats a blank fragment as empty and refuses blank rules (the renderer checks the same). Docs name the op-work-item consumers, the add-only revocation path and the need to add the field before the next run; tests cover each shape. Planwright-Sign-Off: PS-1
… docs A fragment holding several JSON documents passed the shape check on its last document alone and then aborted the merge with a raw jq error. The check now slurps and requires exactly one document. Docs name every permission list the fragment may carry and reconcile the rendered-files intro. Planwright-Sign-Off: PS-2
The header listed only a missing, empty or blank fragment as adding nothing, while a dangling symlink is refused. The header now says so. Planwright-Sign-Off: PS-3
A fragment with permissions null or false passed both validators through the // default and was silently treated as empty; both now require an object when the key is present. The merge passed the fragment to jq on the command line, where other users could read it from the process list; it now arrives as a file descriptor. CLAUDE.md names the work fragment in its permission layers, the op-work-item doc no longer calls the fragment a second-item consumer, and tests pin exit 4 for each refusal. Planwright-Sign-Off: PS-4
Passing the fragment through process substitution failed open if the writer failed, so the merge now writes a private temp file it checks and removes. The op-render tests assert which violation fired, the empty-union test fails on a non-OK rerun, and the CLAUDE.md and machine-local-files wrapping returns to its prior shape. Planwright-Sign-Off: PS-5
The merge now creates a temp file on every run, so a failure to create or write one exits with a FAILED line instead of a bare shell error, and the single exit trap removes the live-file temp file too. Tests cover a bad deny list and that a rerun after expanding home paths reports OK. Planwright-Sign-Off: PS-6
The multi-document case carried an unrelated violation, so it now uses two valid documents and top-level null and scalar fragments are covered; a refused fragment leaves the live file alone and a refused render leaves the previous fragment alone. One trap is installed before any temp file exists, and the merge comment names what the home path is passed in for. Planwright-Sign-Off: PS-7
The merge checked only that the live and tracked settings parsed, so an array, a scalar or several documents crashed the merge with a raw jq error (and null or false was reported as invalid JSON through jq -e). Both now must be a single object and fail with the usual status and message. docs/claude-config.md says plainly that a removed rule stays in a live file until deleted by hand. Planwright-Sign-Off: PS-8
|
Persistent review updated to latest commit 4f4cdf5 |
|
Checked: an empty |
Keep machine-specific Claude permission rules across settings merges, and render work-only rules from 1Password instead of committing them.
The settings merge used jq's
*, so every run replacedpermissions.allowandpermissions.denyin the live~/.claude/settings.jsonwith the tracked lists, and any rule added by hand on one machine was lost.scripts/claude-settings-merge.shnow merges both lists as a union: the tracked rules, then an optional machine-local fragment (third argument), then rules only the live file carries. Each rule appears once and the order stays stable. A fragment holding anything except those two string lists is refused. The hook-ownership merge is unchanged.roles/claude/files/claude-settings-work.json.tplrenders~/.config/dotfiles/claude-settings-work.jsonfrom theclaude_permissions_allowfield of the itemop-work-itemnames, throughop-render.sh --work-account, which gains asettings-fragmentrule. A host withoutop-work-itemskips the render. A handler re-applies the merge when the fragment changes.CLAUDE.md,docs/machine-local-files.md,docs/claude-config.md) cover the fragment and the new removal cost.Testing: new cases in
scripts/claude-settings-merge-test.sh(union, idempotent rerun, missing fragment is a no-op, bad fragment refused) andscripts/op-render-test.sh(fragment rule). The full pre-commit hook set passes locally.Known limitations: removing a rule from the tracked file or the 1Password field no longer removes it from a live settings file. Delete it there by hand as well.
Review record
Both convergence steps ran as Agent-tool subagents, hand-recorded per step with
step-record.sh write(start and end stamped from the clock when each step began and finished), because the headless session primitives take only spec and task units.Steps at
pre-implementation(run000001)Ended on
704baf3dc19a.Steps at
pre-ci(run000001)Ended on
7e6cc502add6.Steps at
convergence(run000001)Ended on
02fde99b71f4.Steps at
pre-pr(run000001)Ended on
02fde99b71f4.Steps at
post-pr(run000001)Ended on
02fde99b71f4.Steps at
post-pr(run000002)Ended on
02fde99b71f4.Steps at
pre-implementation(after the merge of main, run000002)Ended on
58095348a07d.Steps at
pre-ci(after the merge of main, run000002)Ended on
58095348a07d.Steps at
convergence(after the merge of main, run000002)Ended on
4f4cdf51a98b.Steps at
pre-pr(after the merge of main, run000002)Ended on
4f4cdf51a98b.Steps at
post-pr(after the merge of main, run000002)Ended on
4f4cdf51a98b.Steps at
post-pr(final round, run000003, which carries every point of the second round and supersedes the halted record above)Ended on
4f4cdf51a98b.Merge with main: main was merged into this branch (a merge commit; no history rewritten). Two conflicts: the
CLAUDE.mdrow ofroles/claude/files/scripts/instruction-budget.sh(main's row kept for the bot-review surface, this branch'sCLAUDE.mdrow re-derived with--countand the formula) andscripts/op-render-test.sh(main's new section kept as 30, this branch's fragment section renumbered 31). Review rounds after the merge (polish and a gemini panel-review) added fixes: the fragment is read once, a blank fragment counts as empty, multi-document, null and whitespace-only values are refused, the fragment reaches jq as a private temp file rather than on the command line, and a live or tracked settings file must be a single JSON object; each has a test.Bot review: cubic refused its review on 2026-11-12 (workspace limit, reviews resume 2 December 2026), so PR-Agent is the bot review. It reviewed the final head with one finding (an empty
claude_permissions_allowwould break the render). That finding was declined with proof (op-render-test.shsection 31, "an empty field renders an empty fragment", passes), the decline was settled by the hub, and the reply is posted: #253 (comment). It is a description-level finding, so there is no thread to resolve; the decision ledger records it as rejected.Not covered: roles/claude/files/scripts/instruction-budget.sh — only the repo-root
CLAUDE.mdrow was re-derived by the budget formula after this change; the guard's counting, thresholds rule and surfaces list that the word-budget requirement states are unchanged.Not covered: CLAUDE.md — adds one row to the machine-local files table and one parenthetical in the permissions section; the file stays at its 200-line ceiling and under its re-derived word budget, so the requirements on this file's size, table completeness and content rules still hold.
Not covered: roles/claude/tasks/main.yml — adds one argument (the fragment path) to the settings-merge task; the skill link task and the commands-path removal that the requirement describes are untouched.
Not covered: docs/claude-config.md — rewords the settings-merge paragraph and adds a row to the permission-layers table; the sentence on ignoring
.claude/that the requirement covers is untouched.Not covered: scripts/op-render.sh — adds an independent
settings-fragmentvalidation rule beside the existing ones; the standing-rules render and its validator that the requirement describes are untouched.Not covered: roles/claude/tasks/op-render.yml — adds one render task for the settings fragment and lists it in the failure and skip reporting; the standing-rules render task that the requirement describes is untouched.
Not covered: docs/machine-local-files.md — documents a new machine-local file and the
op-work-itemconsumers; the standing-rules file documentation that the requirement describes is untouched.