8000 feat(claude): keep work-only permission rules across settings merges by inkatze · Pull Request #253 · inkatze/dotfiles · GitHub
[go: up one dir, main page]

Skip to content

feat(claude): keep work-only permission rules across settings merges - #253

Merged
inkatze merged 11 commits into
mainfrom
planwright/flight/mc-gusto-hub-worker-430fe8eb
Nov 18, 2026
Merged

inkatze merged 11 commits into
mainfrom
planwright/flight/mc-gusto-hub-worker-430fe8eb

Conversation

@inkatze
@inkatze inkatze commented Nov 12, 2026 •
Copy link
Copy Markdown
Owner

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 replaced permissions.allow and permissions.deny in the live ~/.claude/settings.json with the tracked lists, and any rule added by hand on one machine was lost.

  • scripts/claude-settings-merge.sh now 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.tpl renders ~/.config/dotfiles/claude-settings-work.json from the claude_permissions_allow field of the item op-work-item names, through op-render.sh --work-account, which gains a settings-fragment rule. A host without op-work-item skips the render. A handler re-applies the merge when the fragment changes.
  • Docs (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) and scripts/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 (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 704baf3dc19a.

Steps at pre-ci (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 7e6cc502add6.

Steps at convergence (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 polish skill core isolated agent-subagent 7e6cc50 2026-11-12T22:46:54Z 2026-11-12T22:49:56Z passed Converged in 1 iteration over origin/main..7e6cc50: 0 auto, 0 agent-resolvable, 0 needs-sign-off, 0 forks, 0 declined. Merge and op-render suites pass, instruction budget within limits, CLAUDE.md at its 200-line ceiling. Hosted as an Agent-tool subagent, the session-grade headless primitives taking only spec/task units.
2 panel-review skill adopter isolated agent-subagent 7e6cc50 to 02fde99 2026-11-12T22:50:16Z 2026-11-12T23:18:19Z applied codex backend, 2 passes. Applied 1: doc names the op-work-item file as the render's skip condition (02fde99). Rejected after local checks: dedupe claim (jq verified, tests pass), revocation (settled union decision, documented), handler skipped on a failed play (next run's merge applies the fragment), concurrency, null permissions fragment, quadratic dedupe, extra test gates. Deferred: non-array live or tracked lists (already treated as empty). No forks. Hosted as an Agent-tool subagent.

Ended on 02fde99b71f4.

Steps at pre-pr (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 02fde99b71f4.

Steps at post-pr (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 bot-review skill adopter isolated agent-subagent 02fde99 2026-11-12T23:19:42Z 2026-11-12T23:42:20Z limited Vendor quota stop: the default reviewer (cubic) answered its review trigger with its free monthly review limit reached, resuming 2026-12-02. No review, no findings, no replies. Hosted as an Agent-tool subagent.

Ended on 02fde99b71f4.

  • Warning: bot-review limited: reviewer quota reached

Steps at post-pr (run 000002)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 bot-review skill adopter isolated agent-subagent 02fde99 2026-11-12T23:42:57Z 2026-11-12T23:44:20Z halted Retry with --local (cubic CLI through panel-review reviewer:cubic) halted at its egress consent: no recorded consent for reviewer:cubic:inkatze/dotfiles, which only the operator can give. CLI never ran; nothing posted, committed or pushed. Hosted as an Agent-tool subagent.

Ended on 02fde99b71f4.

  • Warning: bot-review halted: cubic local upload consent not recorded

Steps at pre-implementation (after the merge of main, run 000002)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 58095348a07d.

Steps at pre-ci (after the merge of main, run 000002)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 58095348a07d.

Steps at convergence (after the merge of main, run 000002)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 polish skill polish in-session in-session 5809534 to c87f765 2026-11-18T02:15:26Z 2026-11-18T04:37:19Z applied (degraded: launched in the unit session, no isolated session spawned) polish --nested, eight passes, parallel foreground Agent calls. Pass 1: nine single-lens agents, applied f0d7e97. Pass 2: three grouped agents (nine lenses), applied d77dd26. Pass 3: two grouped agents (nine lenses), applied b0188f6 (comment). Pass 4: nine single-lens agents, applied d97da3b. Pass 5: nine single-lens agents, applied 2597b94. Pass 6: nine single-lens agents, applied f2cc484. Pass 7: nine single-lens agents, applied c87f765. Pass 8: nine single-lens agents after c87f765, applied nothing.
2 panel-review skill panel-review in-session in-session c87f765 to 4f4cdf5 2026-11-18T04:38:03Z 2026-11-18T05:55:52Z applied (degraded: launched in the unit session, no isolated session spawned) panel-review --nested, gemini backend (non-Anthropic), two iterations. Iteration 1 (239s): one correctness finding (settings file that is not one JSON object), one docs wording, one test gap applied as 4f4cdf5 (pending sign-off); one cross-file finding declined (template allow-only by design). Iteration 2 (210s), convergence discovery: nothing new to apply, five low findings declined with rationale. Full suites rerun after the commit and pass. The panel commit was not followed by another polish pass.

Ended on 4f4cdf51a98b.

Steps at pre-pr (after the merge of main, run 000002)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 4f4cdf51a98b.

Steps at post-pr (after the merge of main, run 000002)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 bot-review skill bot-review in-session in-session 4f4cdf5 2026-11-18T06:19:20Z 2026-11-18T07:11:43Z halted (degraded: launched in the unit session, no isolated session spawned) bot-review --nested, in the unit session. cubic: its reply on this PR (2026-11-12) refused the review for a workspace limit (cubic has reviewed 40,041 of the 40,000 allowed lines this month; reviews resume on 2 December 2026); not retriggered. PR-Agent is the bot review: it ran on the pushed head and reviewed that head with one description-level finding (the template emits permissions.allow for an empty field). Declined with proof (op-render-test.sh section 31 passes: an empty field renders an empty fragment); the draft reply and proof go to mission control, nothing posted.

Ended on 4f4cdf51a98b.

  • Warning: one PR-Agent finding declined with proof; its reply is pending with mission control

Steps at post-pr (final round, run 000003, which carries every point of the second round and supersedes the halted record above)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 bot-review skill bot-review in-session in-session 4f4cdf5 2026-11-18T12:56:10Z 2026-11-18T13:44:11Z passed (degraded: launched in the unit session, no isolated session spawned) bot-review --nested, in the unit session. The one PR-Agent finding on the final head (an empty claude_permissions_allow would fail the render) was settled by the hub as a proven decline: op-render.sh drops an empty field before the rule runs and op-render-test.sh section 31 passes. The decline reply was posted as a top-level acknowledgment with the addressed marker and recorded in the decision ledger as rejected. A description-level finding has no thread, so nothing to resolve. cubic stays out (workspace limit, resumes 2 December 2026).

Ended on 4f4cdf51a98b.

Merge with main: main was merged into this branch (a merge commit; no history rewritten). Two conflicts: the CLAUDE.md row of roles/claude/files/scripts/instruction-budget.sh (main's row kept for the bot-review surface, this branch's CLAUDE.md row re-derived with --count and the formula) and scripts/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_allow would break the render). That finding was declined with proof (op-render-test.sh section 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.md row 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-fragment validation 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-item consumers; the standing-rules file documentation that the requirement describes is untouched.

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.
@github-actions
github-actions Bot commented Nov 12, 2026 •
Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 4f4cdf5)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The template always emits a permissions.allow key, even when the 1Password field claude_permissions_allow is empty. The json filter on an empty string yields null or "", which fails the validation rule in op-render.sh (which requires allow to be an array), causing the render to fail. This contradicts the documented behavior (an empty field should render {}) and the test expectation in op-render-test.sh.

{
  "permissions": {
    "allow": "{{ op://__OP_VAULT__/__OP_ITEM__/claude_permissions_allow | json }}"
  }
}

@github-actions
github-actions Bot commented Nov 12, 2026 •
Copy link
Copy Markdown

PR-Agent run 44250475662.1 on 4f4cdf5: success

@inkatze
inkatze commented Nov 12, 2026
Copy link
Copy Markdown
Owner Author

@cubic-dev-ai review this PR

@cubic-dev-ai
cubic-dev-ai Bot commented Nov 12, 2026
Copy link
Copy Markdown

@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:

Learn more →

…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
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 4f4cdf5

@inkatze
inkatze commented Nov 18, 2026
Copy link
Copy Markdown
Owner Author

Checked: an empty claude_permissions_allow does not fail the render. scripts/op-render.sh drops a key whose field is empty before the rule runs (header, "A field left empty in the item drops its key from the output, and an object or list left with nothing in it drops in turn"), so the template renders {}. scripts/op-render-test.sh section 31, "an empty field renders an empty fragment", asserts exactly that and passes. The settings-fragment rule only sees values that survive that pruning. No change made.

@inkatze
inkatze marked this pull request as ready for review November 18, 2026 15:56
@inkatze
inkatze merged commit 54de0cd into main Nov 18, 2026
14 checks passed
@inkatze
inkatze deleted the planwright/flight/mc-gusto-hub-worker-430fe8eb branch November 18, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0