critical-gate 2.0.0 → 2.1.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 +163 -0
- package/dist/cli.d.ts +7 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +469 -20
- package/dist/cli.js.map +1 -1
- package/dist/config/critical-gate-config.d.ts +41 -0
- package/dist/config/critical-gate-config.d.ts.map +1 -1
- package/dist/config/critical-gate-config.js +193 -4
- package/dist/config/critical-gate-config.js.map +1 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/learning-policy.d.ts +9 -0
- package/dist/config/learning-policy.d.ts.map +1 -0
- package/dist/config/learning-policy.js +34 -0
- package/dist/config/learning-policy.js.map +1 -0
- package/dist/detectors/api-surface-detector.d.ts.map +1 -1
- package/dist/detectors/api-surface-detector.js +123 -5
- package/dist/detectors/api-surface-detector.js.map +1 -1
- package/dist/detectors/confidence-calibration.d.ts +11 -0
- package/dist/detectors/confidence-calibration.d.ts.map +1 -0
- package/dist/detectors/confidence-calibration.js +53 -0
- package/dist/detectors/confidence-calibration.js.map +1 -0
- package/dist/detectors/existing-solution-detector.js +6 -0
- package/dist/detectors/existing-solution-detector.js.map +1 -1
- package/dist/detectors/expected-companions-detector.d.ts.map +1 -1
- package/dist/detectors/expected-companions-detector.js +208 -10
- package/dist/detectors/expected-companions-detector.js.map +1 -1
- package/dist/detectors/index.d.ts +1 -0
- package/dist/detectors/index.d.ts.map +1 -1
- package/dist/detectors/index.js +1 -0
- package/dist/detectors/index.js.map +1 -1
- package/dist/detectors/intent-verification-detector.d.ts.map +1 -1
- package/dist/detectors/intent-verification-detector.js +64 -1
- package/dist/detectors/intent-verification-detector.js.map +1 -1
- package/dist/detectors/reason-chain.d.ts +4 -0
- package/dist/detectors/reason-chain.d.ts.map +1 -0
- package/dist/detectors/reason-chain.js +102 -0
- package/dist/detectors/reason-chain.js.map +1 -0
- package/dist/detectors/repair-contract.d.ts +4 -0
- package/dist/detectors/repair-contract.d.ts.map +1 -0
- package/dist/detectors/repair-contract.js +45 -0
- package/dist/detectors/repair-contract.js.map +1 -0
- package/dist/detectors/repository-intelligence-detector.d.ts.map +1 -1
- package/dist/detectors/repository-intelligence-detector.js +17 -4
- package/dist/detectors/repository-intelligence-detector.js.map +1 -1
- package/dist/detectors/rewrite-detector.d.ts.map +1 -1
- package/dist/detectors/rewrite-detector.js +5 -2
- package/dist/detectors/rewrite-detector.js.map +1 -1
- package/dist/detectors/runner.d.ts +1 -0
- package/dist/detectors/runner.d.ts.map +1 -1
- package/dist/detectors/runner.js +50 -3
- package/dist/detectors/runner.js.map +1 -1
- package/dist/detectors/scope-detector.js +1 -1
- package/dist/detectors/scope-detector.js.map +1 -1
- package/dist/detectors/secret-path-detector.js +1 -1
- package/dist/detectors/secret-path-detector.js.map +1 -1
- package/dist/detectors/test-weakening-detector.d.ts.map +1 -1
- package/dist/detectors/test-weakening-detector.js +188 -39
- package/dist/detectors/test-weakening-detector.js.map +1 -1
- package/dist/detectors/types.d.ts +2 -0
- package/dist/detectors/types.d.ts.map +1 -1
- package/dist/diff/git-diff-reader.d.ts +1 -0
- package/dist/diff/git-diff-reader.d.ts.map +1 -1
- package/dist/diff/git-diff-reader.js +11 -4
- package/dist/diff/git-diff-reader.js.map +1 -1
- package/dist/diff/path-classifier.d.ts.map +1 -1
- package/dist/diff/path-classifier.js +9 -1
- package/dist/diff/path-classifier.js.map +1 -1
- package/dist/frameworks/detect.d.ts +11 -0
- package/dist/frameworks/detect.d.ts.map +1 -0
- package/dist/frameworks/detect.js +29 -0
- package/dist/frameworks/detect.js.map +1 -0
- package/dist/frameworks/index.d.ts +5 -0
- package/dist/frameworks/index.d.ts.map +1 -0
- package/dist/frameworks/index.js +4 -0
- package/dist/frameworks/index.js.map +1 -0
- package/dist/frameworks/packs.d.ts +3 -0
- package/dist/frameworks/packs.d.ts.map +1 -0
- package/dist/frameworks/packs.js +146 -0
- package/dist/frameworks/packs.js.map +1 -0
- package/dist/frameworks/path-patterns.d.ts +3 -0
- package/dist/frameworks/path-patterns.d.ts.map +1 -0
- package/dist/frameworks/path-patterns.js +16 -0
- package/dist/frameworks/path-patterns.js.map +1 -0
- package/dist/frameworks/types.d.ts +15 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +2 -0
- package/dist/frameworks/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/intent/diff-coherence-score.d.ts +13 -0
- package/dist/intent/diff-coherence-score.d.ts.map +1 -0
- package/dist/intent/diff-coherence-score.js +125 -0
- package/dist/intent/diff-coherence-score.js.map +1 -0
- package/dist/intent/index.d.ts +2 -0
- package/dist/intent/index.d.ts.map +1 -1
- package/dist/intent/index.js +2 -0
- package/dist/intent/index.js.map +1 -1
- package/dist/intent/intent-core.d.ts.map +1 -1
- package/dist/intent/intent-core.js +17 -1
- package/dist/intent/intent-core.js.map +1 -1
- package/dist/intent/intent-model.d.ts.map +1 -1
- package/dist/intent/intent-model.js +39 -2
- package/dist/intent/intent-model.js.map +1 -1
- package/dist/intent/task-intent-quality.d.ts +4 -0
- package/dist/intent/task-intent-quality.d.ts.map +1 -0
- package/dist/intent/task-intent-quality.js +98 -0
- package/dist/intent/task-intent-quality.js.map +1 -0
- package/dist/knowledge/cache.d.ts +1 -0
- package/dist/knowledge/cache.d.ts.map +1 -1
- package/dist/knowledge/cache.js +5 -1
- package/dist/knowledge/cache.js.map +1 -1
- package/dist/knowledge/history-index.d.ts.map +1 -1
- package/dist/knowledge/history-index.js +10 -3
- package/dist/knowledge/history-index.js.map +1 -1
- package/dist/knowledge/index.d.ts +3 -2
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +2 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/normal-change-model.d.ts +8 -0
- package/dist/knowledge/normal-change-model.d.ts.map +1 -0
- package/dist/knowledge/normal-change-model.js +121 -0
- package/dist/knowledge/normal-change-model.js.map +1 -0
- package/dist/knowledge/solution-index.d.ts.map +1 -1
- package/dist/knowledge/solution-index.js +43 -3
- package/dist/knowledge/solution-index.js.map +1 -1
- package/dist/knowledge/types.d.ts +11 -0
- package/dist/knowledge/types.d.ts.map +1 -1
- package/dist/reporters/index.d.ts +4 -1
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js +6 -0
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/markdown-reporter.d.ts.map +1 -1
- package/dist/reporters/markdown-reporter.js +67 -0
- package/dist/reporters/markdown-reporter.js.map +1 -1
- package/dist/reporters/pr-comment-reporter.d.ts +3 -0
- package/dist/reporters/pr-comment-reporter.d.ts.map +1 -0
- package/dist/reporters/pr-comment-reporter.js +105 -0
- package/dist/reporters/pr-comment-reporter.js.map +1 -0
- package/dist/reporters/repair-contract.d.ts +3 -0
- package/dist/reporters/repair-contract.d.ts.map +1 -0
- package/dist/reporters/repair-contract.js +25 -0
- package/dist/reporters/repair-contract.js.map +1 -0
- package/dist/reporters/repair-reporter.d.ts.map +1 -1
- package/dist/reporters/repair-reporter.js +19 -1
- package/dist/reporters/repair-reporter.js.map +1 -1
- package/dist/reporters/reviewer-checklist.d.ts +10 -0
- package/dist/reporters/reviewer-checklist.d.ts.map +1 -0
- package/dist/reporters/reviewer-checklist.js +112 -0
- package/dist/reporters/reviewer-checklist.js.map +1 -0
- package/dist/repository/api-snapshot.d.ts +41 -0
- package/dist/repository/api-snapshot.d.ts.map +1 -0
- package/dist/repository/api-snapshot.js +219 -0
- package/dist/repository/api-snapshot.js.map +1 -0
- package/dist/repository/index.d.ts +2 -0
- package/dist/repository/index.d.ts.map +1 -1
- package/dist/repository/index.js +2 -0
- package/dist/repository/index.js.map +1 -1
- package/dist/repository/monorepo.d.ts +7 -0
- package/dist/repository/monorepo.d.ts.map +1 -0
- package/dist/repository/monorepo.js +189 -0
- package/dist/repository/monorepo.js.map +1 -0
- package/dist/schema/gate-result.schema.d.ts +272 -0
- package/dist/schema/gate-result.schema.d.ts.map +1 -1
- package/dist/schema/gate-result.schema.js +148 -1
- package/dist/schema/gate-result.schema.js.map +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/types.d.ts +63 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,157 @@ Current detectors focus on TypeScript and JavaScript repositories:
|
|
|
36
36
|
Every finding includes severity, confidence, evidence, tags, and a repair hint that another agent or
|
|
37
37
|
developer can act on.
|
|
38
38
|
|
|
39
|
+
## Concrete Examples
|
|
40
|
+
|
|
41
|
+
Critical Gate is most useful when an AI-generated diff looks plausible at a glance but breaks the
|
|
42
|
+
shape of the task.
|
|
43
|
+
|
|
44
|
+
### Dependency Drift
|
|
45
|
+
|
|
46
|
+
Task:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
Add CSV export using the existing file writer utilities.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Risky diff:
|
|
53
|
+
|
|
54
|
+
- Adds `papaparse` or another production dependency.
|
|
55
|
+
- Changes `package.json` and the lockfile.
|
|
56
|
+
- Does not document why the existing repository utilities are insufficient.
|
|
57
|
+
|
|
58
|
+
What Critical Gate reports:
|
|
59
|
+
|
|
60
|
+
- The manifest changed.
|
|
61
|
+
- A dependency was added.
|
|
62
|
+
- The task did not ask for a dependency.
|
|
63
|
+
- Repair guidance asks the agent to remove the package, use existing utilities, or add explicit
|
|
64
|
+
justification.
|
|
65
|
+
|
|
66
|
+
### Test Weakening
|
|
67
|
+
|
|
68
|
+
Task:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
Refactor signup validation internals without changing behavior.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Risky diff:
|
|
75
|
+
|
|
76
|
+
```diff
|
|
77
|
+
- expect(result.error.message).toContain("email is required");
|
|
78
|
+
+ expect(result.error).toBeDefined();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
What Critical Gate reports:
|
|
82
|
+
|
|
83
|
+
- A behavioral assertion became a generic existence assertion.
|
|
84
|
+
- The replacement is less specific even though the test still passes.
|
|
85
|
+
- Repair guidance asks for an equally specific behavioral assertion.
|
|
86
|
+
|
|
87
|
+
### Unrelated Edits
|
|
88
|
+
|
|
89
|
+
Task:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
Fix font weight in the profile heading.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Risky diff:
|
|
96
|
+
|
|
97
|
+
- Changes the intended stylesheet.
|
|
98
|
+
- Also rewrites unrelated layout files.
|
|
99
|
+
- Touches CI config or package metadata.
|
|
100
|
+
|
|
101
|
+
What Critical Gate reports:
|
|
102
|
+
|
|
103
|
+
- The changed files do not fit the small task boundary.
|
|
104
|
+
- Diff Cost Score and Scope Expansion Score increase.
|
|
105
|
+
- Repair guidance asks to split unrelated edits or expand the task explicitly.
|
|
106
|
+
|
|
107
|
+
### Utility Reinvention
|
|
108
|
+
|
|
109
|
+
Task:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
Add signup date formatting.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Risky diff:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
export function formatDateForSignup(value: Date): string {
|
|
119
|
+
return value.toISOString();
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
when the repository already has:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
export function formatDate(value: Date): string;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
What Critical Gate reports:
|
|
130
|
+
|
|
131
|
+
- A similar exported helper already exists.
|
|
132
|
+
- Evidence includes existing export name, signature shape, folder role, path, and import count.
|
|
133
|
+
- Repair guidance points the agent toward reuse instead of another local abstraction.
|
|
134
|
+
|
|
135
|
+
### Public API Changes
|
|
136
|
+
|
|
137
|
+
Task:
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
Improve internal validation.
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Risky diff:
|
|
144
|
+
|
|
145
|
+
```diff
|
|
146
|
+
- export interface SignupOptions {}
|
|
147
|
+
+ interface SignupOptions {}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
What Critical Gate reports:
|
|
151
|
+
|
|
152
|
+
- A public export was removed without task or release evidence.
|
|
153
|
+
- If `.critical-gate/api-surface.json` exists, the finding cites the snapshotted public contract.
|
|
154
|
+
- Repair guidance asks for restore, migration notes, changelog/changeset evidence, or an updated API
|
|
155
|
+
snapshot.
|
|
156
|
+
|
|
157
|
+
### Clean Diff Certification
|
|
158
|
+
|
|
159
|
+
When the gate passes, the Markdown report still explains what was checked:
|
|
160
|
+
|
|
161
|
+
- Changed file count and churn.
|
|
162
|
+
- Diff Coherence Score.
|
|
163
|
+
- Dependency discipline.
|
|
164
|
+
- Test integrity.
|
|
165
|
+
- Public API surface.
|
|
166
|
+
- Secret/path checks.
|
|
167
|
+
|
|
168
|
+
This makes clean runs useful in PRs and agent handoffs instead of just saying “no findings.”
|
|
169
|
+
|
|
170
|
+
## Positioning
|
|
171
|
+
|
|
172
|
+
Critical Gate is adjacent to linters, test suites, security scanners, and AI code review tools, but
|
|
173
|
+
it is not trying to replace them.
|
|
174
|
+
|
|
175
|
+
- **Linters and formatters** enforce code style and static rules. Critical Gate checks whether the
|
|
176
|
+
diff stayed inside the task and repository contract.
|
|
177
|
+
- **Test suites** prove selected behavior still passes. Critical Gate looks for tests that were
|
|
178
|
+
weakened, skipped, or changed to assert less meaningful behavior.
|
|
179
|
+
- **Security scanners** look for known vulnerabilities or secrets. Critical Gate includes lightweight
|
|
180
|
+
diff-only secret/path checks but focuses on agent failure patterns beyond security.
|
|
181
|
+
- **AI code reviewers** often produce broad suggestions. Critical Gate is deterministic-first and
|
|
182
|
+
evidence-first; optional model help is for explanation, not primary detection.
|
|
183
|
+
- **CI checks** usually answer whether the project builds. Critical Gate answers whether the diff is
|
|
184
|
+
acceptable for the task before it is merged.
|
|
185
|
+
|
|
186
|
+
The category is a **diff integrity gate for AI-assisted development**: a cheap, local, repository-
|
|
187
|
+
aware enforcement layer that catches high-risk agent behavior before humans have to infer it from a
|
|
188
|
+
large patch.
|
|
189
|
+
|
|
39
190
|
## Surfaces
|
|
40
191
|
|
|
41
192
|
Critical Gate has one analysis core and multiple surfaces:
|
|
@@ -78,6 +229,17 @@ node dist/cli.js check --task "Add signup validation" --format sarif --output cr
|
|
|
78
229
|
node dist/cli.js check --task "Add signup validation" --format repair
|
|
79
230
|
```
|
|
80
231
|
|
|
232
|
+
Create a public API contract snapshot for repositories that expose TS/JS entrypoints:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
node dist/cli.js snapshot-api
|
|
236
|
+
git add .critical-gate/api-surface.json
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
After the snapshot is committed, normal `check` runs compare export removals, additions, and
|
|
240
|
+
signature changes against it. Public contract changes should include snapshot, changelog, changeset,
|
|
241
|
+
or migration evidence.
|
|
242
|
+
|
|
81
243
|
Exit codes:
|
|
82
244
|
|
|
83
245
|
- `0`: gate passed.
|
|
@@ -226,6 +388,7 @@ Branch and commit conventions for this repository:
|
|
|
226
388
|
- [docs/github-integration.md](docs/github-integration.md): GitHub Action, SARIF, and threshold guidance.
|
|
227
389
|
- [docs/codex-integration.md](docs/codex-integration.md): Codex hook and repair-loop guidance.
|
|
228
390
|
- [docs/versioning-policy.md](docs/versioning-policy.md): release and versioning policy.
|
|
391
|
+
- [docs/improvements-task-plan.md](docs/improvements-task-plan.md): trust and calibration roadmap.
|
|
229
392
|
- [CHANGELOG.md](CHANGELOG.md): project-level release notes.
|
|
230
393
|
|
|
231
394
|
## Project Status
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type GitDiffResult } from "./index.js";
|
|
3
|
-
export declare const CLI_VERSION = "2.
|
|
3
|
+
export declare const CLI_VERSION = "2.1.0";
|
|
4
4
|
export declare const ExitCode: {
|
|
5
5
|
readonly Pass: 0;
|
|
6
6
|
readonly FindingsFailed: 1;
|
|
@@ -12,8 +12,13 @@ interface CliIo {
|
|
|
12
12
|
stdout: (message: string) => void;
|
|
13
13
|
stderr: (message: string) => void;
|
|
14
14
|
writeFile: (path: string, content: string) => void;
|
|
15
|
+
chmodFile?: (path: string, mode: number) => void;
|
|
15
16
|
now: () => Date;
|
|
16
|
-
readDiff: (baseRef?: string
|
|
17
|
+
readDiff: (baseRef?: string, options?: {
|
|
18
|
+
staged?: boolean;
|
|
19
|
+
}) => GitDiffResult;
|
|
20
|
+
exists?: (path: string) => boolean;
|
|
21
|
+
readFile?: (path: string) => string;
|
|
17
22
|
}
|
|
18
23
|
export declare function main(argv?: string[], io?: CliIo): ExitCode;
|
|
19
24
|
export {};
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAMA,OAAO,EAyBL,KAAK,aAAa,EAEnB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,QAAQ;;;;;CAKX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAYhE,UAAU,KAAK;IACb,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,aAAa,CAAC;IAC9E,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC;AAyBD,wBAAgB,IAAI,CAAC,IAAI,WAAwB,EAAE,EAAE,QAAY,GAAG,QAAQ,CAQ3E"}
|