From 35ca4e14d2e2fceda716d355c0f6ca968bcd6e3c Mon Sep 17 00:00:00 2001 From: Moshe Krupper Date: Wed, 8 Jul 2026 21:10:24 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20rename=20src/guard/catalog.ts=20?= =?UTF-8?q?=E2=86=92=20guard-actions.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File + internal map (catalog → guardedActions). The concept stays "the action catalog" in prose (the term the requirements/decisions docs and the conformance banner use); exported symbols (registerGuardedAction, GuardedActionSpec, …) unchanged. Co-Authored-By: Claude Fable 5 --- src/guard/conformance.test.ts | 2 +- src/guard/{catalog.ts => guard-actions.ts} | 10 +++++----- src/guard/guard.test.ts | 2 +- src/guard/guard.ts | 2 +- src/guard/index.ts | 10 ++++++++-- src/guard/types.ts | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) rename src/guard/{catalog.ts => guard-actions.ts} (87%) diff --git a/src/guard/conformance.test.ts b/src/guard/conformance.test.ts index bc945546d..7f476321a 100644 --- a/src/guard/conformance.test.ts +++ b/src/guard/conformance.test.ts @@ -27,7 +27,7 @@ import { listCommands } from '../cli/registry.js'; import { commandGuardAction } from '../cli/guard.js'; import { listDeliveryActions, registerDeliveryAction } from '../delivery.js'; import { EXEMPT_DELIVERY_ACTIONS, guardConformanceViolations } from '../guard-conformance.js'; -import { getGuardedAction } from './catalog.js'; +import { getGuardedAction } from './guard-actions.js'; describe('guard conformance', () => { it('the full walk (shared with the boot check) reports zero violations', () => { diff --git a/src/guard/catalog.ts b/src/guard/guard-actions.ts similarity index 87% rename from src/guard/catalog.ts rename to src/guard/guard-actions.ts index 1a00d4e3e..32ce0da09 100644 --- a/src/guard/catalog.ts +++ b/src/guard/guard-actions.ts @@ -35,19 +35,19 @@ export interface GuardedActionSpec { grantMatches?: (grant: PendingApproval, input: GuardInput) => boolean; } -const catalog = new Map(); +const guardedActions = new Map(); export function registerGuardedAction(spec: GuardedActionSpec): void { - if (catalog.has(spec.action)) { + if (guardedActions.has(spec.action)) { log.warn('Guarded action re-registered (overwriting)', { action: spec.action }); } - catalog.set(spec.action, spec); + guardedActions.set(spec.action, spec); } export function getGuardedAction(action: string): GuardedActionSpec | undefined { - return catalog.get(action); + return guardedActions.get(action); } export function listGuardedActions(): GuardedActionSpec[] { - return [...catalog.values()].sort((a, b) => a.action.localeCompare(b.action)); + return [...guardedActions.values()].sort((a, b) => a.action.localeCompare(b.action)); } diff --git a/src/guard/guard.test.ts b/src/guard/guard.test.ts index d072e9537..88cf203a8 100644 --- a/src/guard/guard.test.ts +++ b/src/guard/guard.test.ts @@ -10,7 +10,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { guard } from './guard.js'; -import { registerGuardedAction } from './catalog.js'; +import { registerGuardedAction } from './guard-actions.js'; import { ALLOW, DENY, HOLD, type GuardInput } from './types.js'; const mockGetPendingApproval = vi.fn(); diff --git a/src/guard/guard.ts b/src/guard/guard.ts index b38a3ccad..55bed0223 100644 --- a/src/guard/guard.ts +++ b/src/guard/guard.ts @@ -20,7 +20,7 @@ */ import { getPendingApproval } from '../db/sessions.js'; import { log } from '../log.js'; -import { getGuardedAction } from './catalog.js'; +import { getGuardedAction } from './guard-actions.js'; import { ALLOW, DENY, type GuardDecision, type GuardInput } from './types.js'; export function guard(input: GuardInput): GuardDecision { diff --git a/src/guard/index.ts b/src/guard/index.ts index 7bf897e1a..89781dfb3 100644 --- a/src/guard/index.ts +++ b/src/guard/index.ts @@ -2,9 +2,15 @@ * Guard — the privileged-action decision seam (guarded-actions phase 2). * * See the guarded-actions decisions doc on the team hub. One decision - * function (guard.ts) and a registration-derived action catalog (catalog.ts). + * function (guard.ts) and a registration-derived action catalog + * (guard-actions.ts). * Domain-free leaf: domain baselines register from the domain modules' edges. */ export { guard } from './guard.js'; -export { registerGuardedAction, getGuardedAction, listGuardedActions, type GuardedActionSpec } from './catalog.js'; +export { + registerGuardedAction, + getGuardedAction, + listGuardedActions, + type GuardedActionSpec, +} from './guard-actions.js'; export { ALLOW, DENY, HOLD, type GuardActor, type GuardDecision, type GuardInput } from './types.js'; diff --git a/src/guard/types.ts b/src/guard/types.ts index 4925effa7..03233a42f 100644 --- a/src/guard/types.ts +++ b/src/guard/types.ts @@ -4,7 +4,7 @@ * The guard is a domain-free leaf: this module may import the DB read layer, * config, log, and shared types — never src/cli/* or src/modules/*. Domain * knowledge (what an action's structural baseline checks) arrives via - * registration: catalog entries (catalog.ts) are registered by the domain + * registration: catalog entries (guard-actions.ts) are registered by the domain * modules at their module edges. */ import type { PendingApproval } from '../types.js';