fix(gateguard): gate first-touch edits to .claude/settings files (#3845)

The settings exemption skipped the first-touch gate for the files that hold ECC's own off-switches. Settings files now go through the normal gate, including the MultiEdit subagent path.

Co-Authored-By: TRAE <noreply@trae.ai>
This commit is contained in:
huangpz6andTRAE committed 2026-11-04 10:09:15 +08:00
1 parent b38be6a7f6
commit eb770f263f
2 files changed
+9 -15

No files matched your search

+4 -8
View File
@@ -2010,12 +2010,6 @@ function normalizeForMatch(value) {
.toLowerCase();
}
function isClaudeSettingsPath(filePath) {
const normalized = normalizeForMatch(filePath);
return /(^|\/)\.claude\/settings(?:\.[^/]+)?\.json$/.test(normalized);
}
function isReadOnlyGitIntrospection(command) {
const trimmed = String(command || '').trim();
if (!trimmed || /[\r\n;&|><`$()]/.test(trimmed)) return false;
@@ -2444,7 +2438,9 @@ function flushMetrics() {
function exemptReason(filePath, data) {
if (!filePath) return 'no-path';
if (isClaudeSettingsPath(filePath)) return 'claude-settings';
// .claude/settings*.json holds the switches for GateGuard and the other
// hooks, so a first-touch edit there must go through the same gate as any
// other new target. Exempting it let an agent disable the guard (#3845).
return isExemptPath(filePath, data) ? 'exempt-glob' : '';
}
@@ -2618,7 +2614,7 @@ function gateMultiEdit(ctx) {
function gateMultiEditSubagent(edits, data, rawInput) {
for (const edit of edits) {
const filePath = (edit && edit.file_path) || '';
if (!filePath || isClaudeSettingsPath(filePath) || isExemptPath(filePath, data)) continue;
if (!filePath || isExemptPath(filePath, data)) continue;
const denial = subagentRestrictedDenial(filePath, data, false);
if (denial) return denial;
}