@codapult/guard 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ export interface ModuleRecord {
11
11
  exports: string[];
12
12
  calls: string[];
13
13
  resolvedImports: string[];
14
- resolvedImportMap?: Record<string, string>;
14
+ resolvedImportMap?: Record<string, string> | undefined;
15
15
  dynamicImports: string[];
16
16
  declarations: {
17
17
  classes: number;
@@ -33,20 +33,20 @@ export interface CapabilitySignal {
33
33
  export interface ProjectModel {
34
34
  version: 1;
35
35
  project: {
36
- name?: string;
37
- packageManager?: string;
36
+ name?: string | undefined;
37
+ packageManager?: string | undefined;
38
38
  frameworks: string[];
39
39
  scripts: Record<string, string>;
40
40
  dependencies: Record<string, string>;
41
41
  devDependencies: Record<string, string>;
42
42
  workspacePackages: {
43
43
  path: string;
44
- name?: string;
44
+ name?: string | undefined;
45
45
  private: boolean;
46
46
  scripts: Record<string, string>;
47
47
  dependencies: string[];
48
- exports?: string[];
49
- projectReferences?: string[];
48
+ exports?: string[] | undefined;
49
+ projectReferences?: string[] | undefined;
50
50
  }[];
51
51
  };
52
52
  files: ProjectFileRecord[];
@@ -59,7 +59,7 @@ export interface ProjectModel {
59
59
  };
60
60
  git: {
61
61
  repository: boolean;
62
- branch?: string;
62
+ branch?: string | undefined;
63
63
  dirty: boolean;
64
64
  changedFiles: string[];
65
65
  status: string[];
@@ -125,16 +125,23 @@ export interface DiscoveryMetrics {
125
125
  changedFiles: number;
126
126
  reusedModules: number;
127
127
  }
128
+ export interface DiscoveryResult {
129
+ model: ProjectModel;
130
+ metrics: DiscoveryMetrics;
131
+ }
128
132
  export interface DiscoveryOptions {
129
- persistCache?: boolean;
133
+ persistCache?: boolean | undefined;
130
134
  /** Maximum number of files included in one model. */
131
- maxFiles?: number;
135
+ maxFiles?: number | undefined;
132
136
  /** Maximum size of one included file in bytes. */
133
- maxFileBytes?: number;
137
+ maxFileBytes?: number | undefined;
134
138
  }
135
139
  export declare class DiscoveryLimitError extends Error {
136
140
  constructor(message: string);
137
141
  }
142
+ export declare class DiscoveryStaleError extends Error {
143
+ constructor();
144
+ }
138
145
  export declare function clearDiscoveryCache(root: string): void;
139
146
  export declare function findGuardRoot(from?: string): string;
140
147
  /** Build the internal module graph from AST resolution plus conservative fallback resolution.
@@ -145,7 +152,4 @@ export declare function findGuardRoot(from?: string): string;
145
152
  */
146
153
  export declare function buildModuleTargetGraph(modules: ModuleRecord[]): Map<string, string[]>;
147
154
  export declare function discoverProject(root: string, options?: DiscoveryOptions): ProjectModel;
148
- export declare function discoverProjectWithMetrics(root: string, options?: DiscoveryOptions): {
149
- model: ProjectModel;
150
- metrics: DiscoveryMetrics;
151
- };
155
+ export declare function discoverProjectWithMetrics(root: string, options?: DiscoveryOptions): DiscoveryResult;
@@ -10,6 +10,12 @@ export class DiscoveryLimitError extends Error {
10
10
  this.name = 'DiscoveryLimitError';
11
11
  }
12
12
  }
13
+ export class DiscoveryStaleError extends Error {
14
+ constructor() {
15
+ super('Project changed while Guard was discovering it.');
16
+ this.name = 'DiscoveryStaleError';
17
+ }
18
+ }
13
19
  const DEFAULT_MAX_FILES = 100_000;
14
20
  const DEFAULT_MAX_FILE_BYTES = 25 * 1024 * 1024;
15
21
  const IGNORED_DIRECTORIES = new Set([
@@ -366,6 +372,17 @@ function runGit(root, args) {
366
372
  return stdout?.toString().trim() || undefined;
367
373
  }
368
374
  }
375
+ function discoverySignature(root, packageJson, allFiles) {
376
+ return JSON.stringify([
377
+ JSON.stringify(packageJson),
378
+ allFiles.map((path) => {
379
+ const stat = statSync(resolve(root, path));
380
+ return [path, stat.size, stat.mtimeMs, contentHash(root, path)];
381
+ }),
382
+ runGit(root, ['rev-parse', 'HEAD']),
383
+ runGit(root, ['status', '--porcelain']),
384
+ ]);
385
+ }
369
386
  function gitModel(root) {
370
387
  const branch = runGit(root, ['branch', '--show-current']);
371
388
  const status = runGit(root, ['status', '--porcelain'])?.split('\n').filter(Boolean) ?? [];
@@ -383,7 +400,7 @@ function gitModel(root) {
383
400
  });
384
401
  return {
385
402
  repository: runGit(root, ['rev-parse', '--is-inside-work-tree']) === 'true',
386
- branch: branch || undefined,
403
+ ...(branch ? { branch } : {}),
387
404
  dirty: status.length > 0,
388
405
  changedFiles: [...changed].sort(),
389
406
  status,
@@ -762,7 +779,7 @@ function createAstProject(root) {
762
779
  return new Project({ skipAddingFilesFromTsConfig: true });
763
780
  }
764
781
  }
765
- export function discoverProject(root, options = {}) {
782
+ function discoverProjectOnce(root, options = {}, attempt = 0) {
766
783
  const packageJson = readJsonObject(resolve(root, 'package.json'));
767
784
  const dependencies = asStringRecord(packageJson.dependencies);
768
785
  const devDependencies = asStringRecord(packageJson.devDependencies);
@@ -787,17 +804,7 @@ export function discoverProject(root, options = {}) {
787
804
  'Ignore the file or raise maxFileBytes deliberately.');
788
805
  }
789
806
  }
790
- const signature = JSON.stringify([
791
- JSON.stringify(packageJson),
792
- allFiles.map((path) => {
793
- const stat = statSync(resolve(root, path));
794
- // Size/mtime alone can miss an in-place edit that preserves both values.
795
- // The model is a correctness boundary, so include content in the cache key.
796
- return [path, stat.size, stat.mtimeMs, contentHash(root, path)];
797
- }),
798
- runGit(root, ['rev-parse', 'HEAD']),
799
- runGit(root, ['status', '--porcelain']),
800
- ]);
807
+ const signature = discoverySignature(root, packageJson, allFiles);
801
808
  const cacheKey = resolve(root);
802
809
  discoveryCacheHits.set(cacheKey, false);
803
810
  const cached = discoveryCache.get(cacheKey);
@@ -890,11 +897,12 @@ export function discoverProject(root, options = {}) {
890
897
  }
891
898
  return { path, methods: [...methods].sort() };
892
899
  });
900
+ const detectedPackageManager = packageManager(root);
893
901
  const model = {
894
902
  version: 1,
895
903
  project: {
896
- name: typeof packageJson.name === 'string' ? packageJson.name : undefined,
897
- packageManager: packageManager(root),
904
+ ...(typeof packageJson.name === 'string' ? { name: packageJson.name } : {}),
905
+ ...(detectedPackageManager ? { packageManager: detectedPackageManager } : {}),
898
906
  frameworks: inferFrameworks(dependencies, devDependencies),
899
907
  scripts,
900
908
  dependencies,
@@ -922,6 +930,15 @@ export function discoverProject(root, options = {}) {
922
930
  },
923
931
  insights: buildInsights(root, files, modules, sourceFiles, dependencies, astProject),
924
932
  };
933
+ const finalFiles = listFiles(root, root, maxFiles);
934
+ const finalSignature = finalFiles.length <= maxFiles
935
+ ? discoverySignature(root, readJsonObject(resolve(root, 'package.json')), finalFiles)
936
+ : undefined;
937
+ if (finalSignature !== signature) {
938
+ if (attempt < 2)
939
+ return discoverProjectOnce(root, options, attempt + 1);
940
+ throw new DiscoveryStaleError();
941
+ }
925
942
  discoveryCache.set(cacheKey, { signature, model });
926
943
  discoveryReuse.set(cacheKey, reusedModules);
927
944
  if (options.persistCache ?? existsSync(resolve(root, `.${config.appName}/guard`))) {
@@ -938,6 +955,9 @@ export function discoverProject(root, options = {}) {
938
955
  }
939
956
  return model;
940
957
  }
958
+ export function discoverProject(root, options = {}) {
959
+ return discoverProjectOnce(root, options);
960
+ }
941
961
  export function discoverProjectWithMetrics(root, options = {}) {
942
962
  const startedAt = Date.now();
943
963
  const model = discoverProject(root, options);
@@ -1,4 +1,4 @@
1
- export type GuardErrorCode = 'GUARD_NOT_CONFIGURED' | 'GUARD_CONFIG_INVALID' | 'GUARD_STATE_BUSY' | 'GUARD_INVALID_INPUT';
1
+ export type GuardErrorCode = 'GUARD_NOT_CONFIGURED' | 'GUARD_CONFIG_INVALID' | 'GUARD_STATE_BUSY' | 'GUARD_STATE_STALE' | 'GUARD_INVALID_INPUT';
2
2
  export interface GuardErrorPayload {
3
3
  status: 'error';
4
4
  outcome: 'not-configured' | 'error';
@@ -6,6 +6,6 @@ export interface GuardErrorPayload {
6
6
  errorCode: GuardErrorCode;
7
7
  message: string;
8
8
  recoverable: boolean;
9
- hint?: string;
9
+ hint?: string | undefined;
10
10
  }
11
11
  export declare function guardErrorPayload(errorCode: GuardErrorCode, message: string, options: Pick<GuardErrorPayload, 'configured' | 'recoverable' | 'outcome'> & Partial<Pick<GuardErrorPayload, 'hint'>>): GuardErrorPayload;
@@ -1,35 +1,59 @@
1
1
  import { type ProjectModel } from './discovery/discovery.js';
2
2
  import { clearDiscoveryCache, discoverProject, discoverProjectWithMetrics, findGuardRoot } from './discovery/discovery.js';
3
3
  import { type GuardImpactAnalysis } from './analysis/impact.js';
4
- export type GuardSeverity = 'error' | 'warning' | 'info';
4
+ import type { GuardAdapterName, GuardApprovalMode, GuardContractKind, GuardBudgetMetric, GuardRuleKind, GuardRuleStatus, GuardSeverity, GuardToolMode } from './model/types.js';
5
+ export type { GuardAdapterName, GuardApprovalMode, GuardContractKind, GuardBudgetMetric, GuardRuleKind, GuardRuleStatus, GuardSeverity, GuardToolMode, } from './model/types.js';
5
6
  export type GuardOutcomeStatus = 'pass' | 'fail' | 'warning' | 'needs-review' | 'not-configured';
6
- export declare function classifyGuardOutcome(input: {
7
- configured?: boolean;
8
- errors?: number;
9
- warnings?: number;
10
- needsReview?: boolean;
11
- }): GuardOutcomeStatus;
12
- export type GuardRuleKind = 'forbidden-import' | 'client-forbidden-import';
13
- export type GuardRuleStatus = 'active' | 'proposed';
14
- export type GuardContractKind = 'guidance' | 'import-boundary' | 'required-call' | 'package-boundary';
7
+ export interface GuardOutcomeInput {
8
+ configured?: boolean | undefined;
9
+ errors?: number | undefined;
10
+ warnings?: number | undefined;
11
+ needsReview?: boolean | undefined;
12
+ }
13
+ interface GuardStateLockOptions {
14
+ waitMs?: number | undefined;
15
+ noWait?: boolean | undefined;
16
+ }
17
+ interface GuardBaselineUpdateOptions {
18
+ add?: string[] | undefined;
19
+ remove?: string[] | undefined;
20
+ reason?: string | undefined;
21
+ }
22
+ interface GuardConfigWriteOptions extends GuardStateLockOptions {
23
+ expectedRevision?: number | undefined;
24
+ }
25
+ interface GuardPendingProposal {
26
+ id: string;
27
+ type: 'rule' | 'contract';
28
+ }
29
+ export interface GuardSensitiveText {
30
+ value: string;
31
+ redacted: boolean;
32
+ redactionCount: number;
33
+ }
34
+ export interface GuardInitializationResult {
35
+ config: GuardConfig;
36
+ report: GuardReport;
37
+ }
38
+ export declare function classifyGuardOutcome(input: GuardOutcomeInput): GuardOutcomeStatus;
15
39
  export interface GuardContract {
16
40
  id: string;
17
41
  statement: string;
18
- kind?: GuardContractKind;
19
- severity?: GuardSeverity;
20
- scope?: string[];
21
- entrypoints?: string[];
22
- exclude?: string[];
23
- guidance?: string[];
24
- references?: string[];
25
- mustImport?: string[];
26
- mustNotImport?: string[];
27
- mustCall?: string[];
28
- fromPackages?: string[];
29
- mustNotImportPackages?: string[];
30
- status?: GuardRuleStatus;
31
- confidence?: 'high' | 'medium' | 'low';
32
- evidence?: string[];
42
+ kind?: GuardContractKind | undefined;
43
+ severity?: GuardSeverity | undefined;
44
+ scope?: string[] | undefined;
45
+ entrypoints?: string[] | undefined;
46
+ exclude?: string[] | undefined;
47
+ guidance?: string[] | undefined;
48
+ references?: string[] | undefined;
49
+ mustImport?: string[] | undefined;
50
+ mustNotImport?: string[] | undefined;
51
+ mustCall?: string[] | undefined;
52
+ fromPackages?: string[] | undefined;
53
+ mustNotImportPackages?: string[] | undefined;
54
+ status?: GuardRuleStatus | undefined;
55
+ confidence?: 'high' | 'medium' | 'low' | undefined;
56
+ evidence?: string[] | undefined;
33
57
  }
34
58
  export interface GuardRule {
35
59
  id: string;
@@ -37,36 +61,60 @@ export interface GuardRule {
37
61
  severity: GuardSeverity;
38
62
  kind: GuardRuleKind;
39
63
  patterns: string[];
40
- files?: string[];
41
- status?: GuardRuleStatus;
42
- confidence?: 'high' | 'medium' | 'low';
43
- evidence?: string[];
64
+ files?: string[] | undefined;
65
+ status?: GuardRuleStatus | undefined;
66
+ confidence?: 'high' | 'medium' | 'low' | undefined;
67
+ evidence?: string[] | undefined;
68
+ }
69
+ export interface GuardBudget {
70
+ id: string;
71
+ description: string;
72
+ metric: GuardBudgetMetric;
73
+ scope: string[];
74
+ limit: number;
75
+ severity: GuardSeverity;
76
+ reason: string;
77
+ status?: GuardRuleStatus | undefined;
78
+ evidence?: string[] | undefined;
44
79
  }
45
80
  export interface GuardConfig {
46
81
  version: 1;
82
+ revision?: number | undefined;
83
+ contentFingerprint?: string | undefined;
47
84
  rules: GuardRule[];
48
- contracts?: GuardContract[];
85
+ contracts?: GuardContract[] | undefined;
86
+ budgets?: GuardBudget[] | undefined;
87
+ approval?: GuardApprovalPolicy | undefined;
88
+ }
89
+ export interface GuardApprovalPolicy {
90
+ mode: GuardApprovalMode;
91
+ allowMcpApproval: boolean;
92
+ requireDistinctActor: boolean;
49
93
  }
50
94
  export interface GuardProposalFile {
51
95
  version: 1;
52
96
  generatedAt: string;
53
- proposalId?: string;
54
- projectFingerprint?: string;
55
- revision?: number;
56
- contentFingerprint?: string;
97
+ generatedBy?: string | undefined;
98
+ proposalId?: string | undefined;
99
+ projectFingerprint?: string | undefined;
100
+ revision?: number | undefined;
101
+ contentFingerprint?: string | undefined;
57
102
  rules: GuardRule[];
58
103
  contracts: GuardContract[];
59
104
  questions: string[];
60
- decisions?: GuardProposalDecision[];
105
+ decisions?: GuardProposalDecision[] | undefined;
61
106
  }
62
107
  export interface GuardProposalDecision {
63
108
  id: string;
64
109
  type: 'rule' | 'contract';
65
110
  decision: 'approved' | 'rejected';
66
111
  decidedAt: string;
67
- proposalId?: string;
68
- proposalFingerprint?: string;
69
- revision?: number;
112
+ proposalId?: string | undefined;
113
+ proposalFingerprint?: string | undefined;
114
+ revision?: number | undefined;
115
+ source?: 'cli' | 'mcp' | 'external' | undefined;
116
+ actor?: string | undefined;
117
+ commit?: string | undefined;
70
118
  }
71
119
  export type GuardProposalFreshness = 'current' | 'stale' | 'unknown';
72
120
  export interface GuardAgentConfig {
@@ -83,26 +131,24 @@ export interface GuardAgentConfig {
83
131
  checks: ('lint' | 'typecheck' | 'test' | 'build')[];
84
132
  };
85
133
  }
86
- export type GuardToolMode = 'auto' | 'on' | 'off';
87
- export type GuardAdapterName = 'dependency-graph' | 'security' | 'dependency-hygiene';
88
134
  export interface GuardFinding {
89
135
  ruleId: string;
90
136
  severity: GuardSeverity;
91
137
  file: string;
92
138
  line: number;
93
139
  importPath: string;
94
- resolvedPath?: string;
140
+ resolvedPath?: string | undefined;
95
141
  message: string;
96
142
  fingerprint: string;
97
143
  }
98
144
  export interface GuardFileChange {
99
145
  path: string;
100
146
  status: 'added' | 'modified' | 'deleted' | 'renamed';
101
- previousPath?: string;
147
+ previousPath?: string | undefined;
102
148
  }
103
149
  export interface GuardContractIssue {
104
150
  contractId: string;
105
- field: 'scope' | 'reference' | 'definition';
151
+ field: 'scope' | 'reference' | 'definition' | 'files';
106
152
  value: string;
107
153
  message: string;
108
154
  }
@@ -113,24 +159,24 @@ export interface GuardReport {
113
159
  scannedFiles: number;
114
160
  }
115
161
  interface ScanGuardOptions {
116
- changedOnly?: boolean;
117
- changedFiles?: Set<string>;
118
- baseline?: Set<string>;
119
- includeArchitectureInsights?: boolean;
162
+ changedOnly?: boolean | undefined;
163
+ changedFiles?: Set<string> | undefined;
164
+ baseline?: Set<string> | undefined;
165
+ includeArchitectureInsights?: boolean | undefined;
120
166
  }
121
167
  export interface GuardReviewPacket {
122
168
  version: 1;
123
169
  outcome: GuardOutcomeStatus;
124
- diffBase?: string;
170
+ diffBase?: string | undefined;
125
171
  changedFiles: string[];
126
172
  changes: GuardFileChange[];
127
173
  diff: string;
128
174
  truncated: boolean;
129
175
  redacted: boolean;
130
- diffError?: string;
176
+ diffError?: string | undefined;
131
177
  project: ProjectModel;
132
178
  contracts: GuardContract[];
133
- requirement?: string;
179
+ requirement?: string | undefined;
134
180
  deterministicFindings: GuardFinding[];
135
181
  impact: GuardImpactAnalysis;
136
182
  reviewInstructions: string[];
@@ -146,6 +192,9 @@ export declare const GUARD_CONVENTIONS_FILE: string;
146
192
  export declare const GUARD_AGENT_FILE: string;
147
193
  export declare const GUARD_CONTRACTS_FILE: string;
148
194
  export declare const GUARD_PROPOSALS_FILE: string;
195
+ export declare const GUARD_STATE_DIR: string;
196
+ export declare const GUARD_STATE_GENERATIONS_DIR: string;
197
+ export declare const GUARD_STATE_CURRENT_FILE: string;
149
198
  export declare const defaultGuardConfig: GuardConfig;
150
199
  export declare const defaultGuardAgentConfig: GuardAgentConfig;
151
200
  export declare class GuardAlreadyInitializedError extends Error {
@@ -157,12 +206,20 @@ export declare class GuardConfigError extends Error {
157
206
  export declare class GuardStateBusyError extends Error {
158
207
  constructor(path: string);
159
208
  }
209
+ export declare class GuardStateStaleError extends Error {
210
+ constructor();
211
+ }
212
+ export declare class GuardBaselineReasonError extends Error {
213
+ constructor();
214
+ }
215
+ export declare function withGuardStateLock<T>(root: string, callback: () => T, options?: GuardStateLockOptions): T;
160
216
  export declare function isGuardContractsFile(value: unknown): value is {
161
217
  version: 1;
162
218
  contracts: GuardContract[];
163
219
  };
164
220
  export declare function isGuardProposalFile(value: unknown): value is GuardProposalFile;
165
221
  export declare function fingerprintProjectModel(model: ProjectModel): string;
222
+ export declare function fingerprintGuardConfig(guardConfig: GuardConfig): string;
166
223
  export declare function getGuardProposalFreshness(model: ProjectModel, proposals: GuardProposalFile | undefined): GuardProposalFreshness;
167
224
  export declare function loadGuardConfig(root: string): GuardConfig | undefined;
168
225
  export declare function loadGuardProposals(root: string): GuardProposalFile | undefined;
@@ -170,18 +227,13 @@ export declare function isGuardAgentConfig(value: unknown): value is GuardAgentC
170
227
  export declare function loadGuardAgentConfig(root: string): GuardAgentConfig;
171
228
  export declare function writeGuardAgentConfig(root: string, agentConfig?: GuardAgentConfig): void;
172
229
  export declare function loadBaseline(root: string): Set<string>;
173
- export declare function updateBaseline(root: string, options?: {
174
- add?: string[];
175
- remove?: string[];
176
- reason?: string;
177
- }): Set<string>;
178
- export declare function writeGuardConfig(root: string, guardConfig: GuardConfig): void;
230
+ export declare function updateBaseline(root: string, options?: GuardBaselineUpdateOptions): Set<string>;
231
+ export declare function writeGuardConfig(root: string, guardConfig: GuardConfig, options?: GuardConfigWriteOptions): void;
179
232
  export declare function writeGuardProposals(root: string, proposals: GuardProposalFile): void;
180
- export declare function recordGuardProposalDecision(root: string, decisions: Pick<GuardProposalDecision, 'id' | 'type' | 'decision'>[]): void;
181
- export declare function getPendingGuardProposals(proposals: GuardProposalFile | undefined): {
182
- id: string;
183
- type: 'rule' | 'contract';
184
- }[];
233
+ export declare function recordGuardProposalDecision(root: string, decisions: Pick<GuardProposalDecision, 'id' | 'type' | 'decision'>[], options?: Pick<GuardProposalDecision, 'source'>): void;
234
+ export declare function applyGuardProposalDecision(root: string, guardConfig: GuardConfig, decisions: Pick<GuardProposalDecision, 'id' | 'type' | 'decision'>[], options: Pick<GuardProposalDecision, 'source'>): void;
235
+ export declare function validateGuardProposalApproval(policy: GuardApprovalPolicy | undefined, proposals: GuardProposalFile | undefined): string | undefined;
236
+ export declare function getPendingGuardProposals(proposals: GuardProposalFile | undefined): GuardPendingProposal[];
185
237
  export declare function buildGuardProposals(model: ProjectModel, guardConfig: GuardConfig): GuardProposalFile;
186
238
  export declare function buildArchitectureMemory(model: ProjectModel): Record<string, unknown>;
187
239
  export declare function buildConventionsMemory(model: ProjectModel): Record<string, unknown>;
@@ -190,21 +242,21 @@ export declare function writeGuardMemory(root: string, model: ProjectModel): voi
190
242
  export declare function writeBaseline(root: string, findings: GuardFinding[], model?: ProjectModel): void;
191
243
  export declare function loadProjectModel(root: string): ProjectModel | undefined;
192
244
  export declare function writeProjectModel(root: string, model: ProjectModel): void;
245
+ /**
246
+ * Persist all derived project facts as one generation. Legacy root-level files remain as
247
+ * compatibility mirrors, while readers that understand generations always see a coherent set.
248
+ */
249
+ export declare function writeProjectState(root: string, model: ProjectModel, options?: GuardStateLockOptions): string;
193
250
  export declare function writeProjectSnapshot(root: string, model: ProjectModel): string;
194
251
  export declare function loadGuardArtifact(root: string, relativePath: string): unknown;
195
252
  export declare function validateGuardContracts(root: string, contracts?: GuardContract[]): GuardContractIssue[];
253
+ export declare function validateGuardBudgets(root: string, budgets?: GuardBudget[]): GuardContractIssue[];
254
+ export declare function validateGuardPolicy(root: string, guardConfig: GuardConfig): GuardContractIssue[];
196
255
  /** @internal Redacts common credential shapes before a diff enters an AI review packet. */
197
- export declare function redactSensitiveText(value: string): {
198
- value: string;
199
- redacted: boolean;
200
- redactionCount: number;
201
- };
256
+ export declare function redactSensitiveText(value: string): GuardSensitiveText;
202
257
  export declare function scanGuard(root: string, guardConfig: GuardConfig, options?: ScanGuardOptions): GuardReport;
203
258
  export declare function buildGuardReviewPacket(root: string, guardConfig: GuardConfig, baseline?: Set<string>, maxDiffChars?: number, changedOnly?: boolean, requirement?: string, base?: string): GuardReviewPacket;
204
- export declare function initializeGuard(root: string, options?: {
205
- force?: boolean;
206
- }): {
207
- config: GuardConfig;
208
- report: GuardReport;
209
- };
259
+ export declare function initializeGuard(root: string, options?: GuardConfigWriteOptions & {
260
+ force?: boolean | undefined;
261
+ }): GuardInitializationResult;
210
262
  export { clearDiscoveryCache, discoverProject, discoverProjectWithMetrics, findGuardRoot };