feat(set): validate autoMode structure + flag it in shared settings (CA-SET)

settings-validator now validates the autoMode block (auto-mode classifier
config). Structure (medium): autoMode must be an object whose only keys are
environment/allow/soft_deny/hard_deny, each a string array ("$defaults" is a
valid entry); flags not-an-object, unknown-subkey, not-string-array. Dead-config
(low): Claude Code does not read autoMode from shared project settings
(.claude/settings.json), so an autoMode block committed there has no effect —
keyed on file.scope === 'project'.

Both premises primary-source-verified (code.claude.com/docs/en/auto-mode-config).
The plan's "test per-file scope first" gate passed: ConfigFile already carries
scope. SET is in the orchestrator; SC-5 re-checked, byte-equal (snapshot fixture
has no autoMode). Fixtures force-added (.claude/ is gitignored).

Tests +5 (944->949). Scanner count unchanged (13). --json/--raw byte-stable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ter3E2JSi1Khgmuf2kady8
This commit is contained in:
Kjell Tore Guttormsen 2026-06-19 22:14:26 +02:00
commit 3633571c7e
8 changed files with 225 additions and 2 deletions

View file

@ -142,7 +142,27 @@ export const TRANSLATIONS = {
recommendation: 'Open the file and fix the JSON syntax shown in the details (often a missing comma or quote).',
},
},
patterns: [],
patterns: [
{
// Specific case first: well-formed autoMode placed in the wrong scope.
regex: /^autoMode in shared project settings/,
translation: {
title: 'Your auto-mode rules are in a file Claude Code ignores',
description: 'Claude Code doesn\'t read `autoMode` from shared project settings (`.claude/settings.json`), so a checked-in repo can\'t grant itself auto-approval rules. The block has no effect where it is.',
recommendation: 'Move `autoMode` to your user settings (`~/.claude/settings.json`), the local (gitignored) project settings (`.claude/settings.local.json`), or managed settings.',
},
},
{
// Catch-all for autoMode structure problems (not-an-object, unknown
// sub-key, sub-key not a string array).
regex: /^autoMode/,
translation: {
title: 'Your `autoMode` block is malformed',
description: '`autoMode` must be an object with `environment`, `allow`, `soft_deny`, and `hard_deny`, each a list of plain-text rules. Part of it doesn\'t match that shape, so those rules may not apply.',
recommendation: 'Fix the `autoMode` entry shown in the details — use only the four known keys, each set to a list of strings.',
},
},
],
_default: {
title: 'Your settings file has an issue',
description: 'A check on your settings file flagged something worth a look.',