@codapult/guard 0.3.0 → 0.4.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.
- package/README.md +55 -1
- package/dist/adapters/command.d.ts +10 -8
- package/dist/adapters/project-checks.d.ts +23 -20
- package/dist/cli/commands/guard.d.ts +53 -60
- package/dist/cli/commands/guard.js +32 -19
- package/dist/cli/index.js +22 -9
- package/dist/core/analysis/doctor.d.ts +1 -1
- package/dist/core/analysis/doctor.js +2 -3
- package/dist/core/discovery/discovery.d.ts +18 -14
- package/dist/core/discovery/discovery.js +35 -15
- package/dist/core/errors.d.ts +2 -2
- package/dist/core/guard.d.ts +124 -72
- package/dist/core/guard.js +542 -89
- package/dist/core/history/runs.d.ts +28 -0
- package/dist/core/history/runs.js +59 -0
- package/dist/core/model/types.d.ts +10 -0
- package/dist/core/model/types.js +1 -0
- package/dist/core/policy/schemas.d.ts +69 -0
- package/dist/core/policy/schemas.js +25 -0
- package/dist/core/verification/verify.d.ts +20 -16
- package/dist/core/verification/verify.js +55 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/mcp/resources.js +64 -29
- package/dist/mcp/tools/guard.js +147 -28
- package/package.json +7 -7
|
@@ -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
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
897
|
-
packageManager:
|
|
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);
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -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;
|
package/dist/core/guard.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
7
|
-
configured?: boolean;
|
|
8
|
-
errors?: number;
|
|
9
|
-
warnings?: number;
|
|
10
|
-
needsReview?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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
|
|
182
|
-
|
|
183
|
-
|
|
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 };
|