gateproof 0.2.4 → 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.
- package/README.md +1447 -153
- package/dist/cloudflare/index.d.ts +4 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +9 -43
- package/dist/cloudflare/index.js.map +1 -1
- package/dist/index.d.ts +263 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1327 -212
- package/dist/index.js.map +1 -1
- package/package.json +18 -48
- package/dist/act.d.ts +0 -78
- package/dist/act.d.ts.map +0 -1
- package/dist/act.js +0 -47
- package/dist/act.js.map +0 -1
- package/dist/action-executors.d.ts +0 -39
- package/dist/action-executors.d.ts.map +0 -1
- package/dist/action-executors.js +0 -195
- package/dist/action-executors.js.map +0 -1
- package/dist/assert.d.ts +0 -59
- package/dist/assert.d.ts.map +0 -1
- package/dist/assert.js +0 -120
- package/dist/assert.js.map +0 -1
- package/dist/authority.d.ts +0 -34
- package/dist/authority.d.ts.map +0 -1
- package/dist/authority.js +0 -141
- package/dist/authority.js.map +0 -1
- package/dist/cli/gateproof.d.ts +0 -3
- package/dist/cli/gateproof.d.ts.map +0 -1
- package/dist/cli/gateproof.js +0 -548
- package/dist/cli/gateproof.js.map +0 -1
- package/dist/cloudflare/analytics.d.ts +0 -9
- package/dist/cloudflare/analytics.d.ts.map +0 -1
- package/dist/cloudflare/analytics.js +0 -98
- package/dist/cloudflare/analytics.js.map +0 -1
- package/dist/cloudflare/cli-stream.d.ts +0 -7
- package/dist/cloudflare/cli-stream.d.ts.map +0 -1
- package/dist/cloudflare/cli-stream.js +0 -85
- package/dist/cloudflare/cli-stream.js.map +0 -1
- package/dist/cloudflare/polling-backend.d.ts +0 -18
- package/dist/cloudflare/polling-backend.d.ts.map +0 -1
- package/dist/cloudflare/polling-backend.js +0 -53
- package/dist/cloudflare/polling-backend.js.map +0 -1
- package/dist/cloudflare/workers-logs.d.ts +0 -9
- package/dist/cloudflare/workers-logs.d.ts.map +0 -1
- package/dist/cloudflare/workers-logs.js +0 -51
- package/dist/cloudflare/workers-logs.js.map +0 -1
- package/dist/constants.d.ts +0 -11
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -11
- package/dist/constants.js.map +0 -1
- package/dist/filepath-backend.d.ts +0 -64
- package/dist/filepath-backend.d.ts.map +0 -1
- package/dist/filepath-backend.js +0 -126
- package/dist/filepath-backend.js.map +0 -1
- package/dist/filepath-protocol.d.ts +0 -214
- package/dist/filepath-protocol.d.ts.map +0 -1
- package/dist/filepath-protocol.js +0 -239
- package/dist/filepath-protocol.js.map +0 -1
- package/dist/filepath-runtime.d.ts +0 -100
- package/dist/filepath-runtime.d.ts.map +0 -1
- package/dist/filepath-runtime.js +0 -190
- package/dist/filepath-runtime.js.map +0 -1
- package/dist/http-backend.d.ts +0 -32
- package/dist/http-backend.d.ts.map +0 -1
- package/dist/http-backend.js +0 -166
- package/dist/http-backend.js.map +0 -1
- package/dist/observe.d.ts +0 -26
- package/dist/observe.d.ts.map +0 -1
- package/dist/observe.js +0 -84
- package/dist/observe.js.map +0 -1
- package/dist/prd/define-prd.d.ts +0 -7
- package/dist/prd/define-prd.d.ts.map +0 -1
- package/dist/prd/define-prd.js +0 -8
- package/dist/prd/define-prd.js.map +0 -1
- package/dist/prd/index.d.ts +0 -7
- package/dist/prd/index.d.ts.map +0 -1
- package/dist/prd/index.js +0 -8
- package/dist/prd/index.js.map +0 -1
- package/dist/prd/loop.d.ts +0 -160
- package/dist/prd/loop.d.ts.map +0 -1
- package/dist/prd/loop.js +0 -462
- package/dist/prd/loop.js.map +0 -1
- package/dist/prd/runner.d.ts +0 -19
- package/dist/prd/runner.d.ts.map +0 -1
- package/dist/prd/runner.js +0 -253
- package/dist/prd/runner.js.map +0 -1
- package/dist/prd/scope-check.d.ts +0 -28
- package/dist/prd/scope-check.d.ts.map +0 -1
- package/dist/prd/scope-check.js +0 -135
- package/dist/prd/scope-check.js.map +0 -1
- package/dist/prd/scope-defaults.d.ts +0 -75
- package/dist/prd/scope-defaults.d.ts.map +0 -1
- package/dist/prd/scope-defaults.js +0 -235
- package/dist/prd/scope-defaults.js.map +0 -1
- package/dist/prd/types.d.ts +0 -101
- package/dist/prd/types.d.ts.map +0 -1
- package/dist/prd/types.js +0 -2
- package/dist/prd/types.js.map +0 -1
- package/dist/provider.d.ts +0 -6
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js +0 -2
- package/dist/provider.js.map +0 -1
- package/dist/report.d.ts +0 -137
- package/dist/report.d.ts.map +0 -1
- package/dist/report.js +0 -234
- package/dist/report.js.map +0 -1
- package/dist/test-helpers.d.ts +0 -12
- package/dist/test-helpers.d.ts.map +0 -1
- package/dist/test-helpers.js +0 -33
- package/dist/test-helpers.js.map +0 -1
- package/dist/types.d.ts +0 -41
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -22
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -49
- package/dist/utils.js.map +0 -1
- package/dist/validation.d.ts +0 -6
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -38
- package/dist/validation.js.map +0 -1
package/dist/report.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stable, versioned report schemas for machine-readable gate outputs.
|
|
3
|
-
* All types are fully JSON-serializable (no Error objects, no functions).
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Converts an Error (or Error-like object) into a SerializableError.
|
|
7
|
-
* Preserves Effect-tagged errors (_tag) when present.
|
|
8
|
-
*/
|
|
9
|
-
export function serializeError(error) {
|
|
10
|
-
if (error instanceof Error) {
|
|
11
|
-
const errorWithTag = error;
|
|
12
|
-
return {
|
|
13
|
-
tag: errorWithTag._tag,
|
|
14
|
-
name: error.name || "Error",
|
|
15
|
-
message: error.message || String(error),
|
|
16
|
-
stack: error.stack,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
if (error && typeof error === "object" && "_tag" in error) {
|
|
20
|
-
const tagged = error;
|
|
21
|
-
return {
|
|
22
|
-
tag: tagged._tag,
|
|
23
|
-
name: tagged._tag,
|
|
24
|
-
message: tagged.message || String(error),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
name: "Error",
|
|
29
|
-
message: String(error),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Sorts arrays deterministically (alphabetically) for stable output.
|
|
34
|
-
*/
|
|
35
|
-
export function sortDeterministic(arr) {
|
|
36
|
-
return [...arr].sort();
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Converts a GateResult to a fully serializable GateResultV1.
|
|
40
|
-
*/
|
|
41
|
-
export function toGateResultV1(result) {
|
|
42
|
-
return {
|
|
43
|
-
version: "1",
|
|
44
|
-
status: result.status,
|
|
45
|
-
durationMs: result.durationMs,
|
|
46
|
-
logs: result.logs,
|
|
47
|
-
evidence: result.evidence,
|
|
48
|
-
error: result.error ? serializeError(result.error) : undefined,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Creates an LLM-friendly failure summary from a PRD report.
|
|
53
|
-
*
|
|
54
|
-
* This format is optimized for AI agents to understand:
|
|
55
|
-
* - What failed (specific assertions)
|
|
56
|
-
* - Why it failed (evidence from logs)
|
|
57
|
-
* - What to fix (suggestions)
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* const summary = createLLMFailureSummary(report, {
|
|
62
|
-
* diffSnippet: gitDiffOutput,
|
|
63
|
-
* });
|
|
64
|
-
* console.log(JSON.stringify(summary, null, 2));
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export function createLLMFailureSummary(report, options) {
|
|
68
|
-
const failedStory = report.failedStory;
|
|
69
|
-
const failedResult = report.stories.find((s) => s.id === failedStory?.id);
|
|
70
|
-
const failedAssertions = [];
|
|
71
|
-
const suggestions = [];
|
|
72
|
-
// Parse error to extract assertion details
|
|
73
|
-
if (failedResult?.error) {
|
|
74
|
-
const err = failedResult.error;
|
|
75
|
-
if (err.tag === "AssertionFailed" || err.name === "AssertionFailed") {
|
|
76
|
-
const match = err.message.match(/(\w+):\s*(.+)/);
|
|
77
|
-
if (match) {
|
|
78
|
-
failedAssertions.push({
|
|
79
|
-
name: match[1],
|
|
80
|
-
message: match[2],
|
|
81
|
-
});
|
|
82
|
-
// Add specific suggestions based on assertion type
|
|
83
|
-
if (match[1] === "HasAction") {
|
|
84
|
-
suggestions.push(`Ensure the code logs an action named "${match[2].replace("missing ", "").replace(/'/g, "")}"`);
|
|
85
|
-
suggestions.push("Check if the relevant code path is being executed");
|
|
86
|
-
}
|
|
87
|
-
else if (match[1] === "NoErrors") {
|
|
88
|
-
suggestions.push("Fix the error indicated in the logs");
|
|
89
|
-
suggestions.push("Check error handling in the relevant code");
|
|
90
|
-
}
|
|
91
|
-
else if (match[1] === "HasStage") {
|
|
92
|
-
suggestions.push(`Ensure a stage named "${match[2].replace("missing ", "").replace(/'/g, "")}" is logged`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
failedAssertions.push({
|
|
97
|
-
name: err.name || "Unknown",
|
|
98
|
-
message: err.message,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (err.tag === "NoPositiveSignal" || err.name === "NoPositiveSignal") {
|
|
103
|
-
failedAssertions.push({
|
|
104
|
-
name: "NoPositiveSignal",
|
|
105
|
-
message: "No actions or stages were observed in logs",
|
|
106
|
-
});
|
|
107
|
-
suggestions.push("Ensure the code is logging actions or stages");
|
|
108
|
-
suggestions.push("Check if the observe resource is configured correctly");
|
|
109
|
-
}
|
|
110
|
-
else if (err.tag === "ScopeViolation" || err.name === "ScopeViolation") {
|
|
111
|
-
failedAssertions.push({
|
|
112
|
-
name: "ScopeViolation",
|
|
113
|
-
message: err.message,
|
|
114
|
-
});
|
|
115
|
-
suggestions.push("Restrict changes to files within allowedPaths");
|
|
116
|
-
suggestions.push("Avoid modifying files in forbiddenPaths");
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
failedAssertions.push({
|
|
120
|
-
name: err.name || "Error",
|
|
121
|
-
message: err.message,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Build summary
|
|
126
|
-
let summary = "Gate failed";
|
|
127
|
-
if (failedStory) {
|
|
128
|
-
summary = `Gate "${failedStory.id}" failed`;
|
|
129
|
-
}
|
|
130
|
-
if (failedResult?.error) {
|
|
131
|
-
summary += `: ${failedResult.error.message}`;
|
|
132
|
-
}
|
|
133
|
-
// Extract evidence from logs if available
|
|
134
|
-
const logs = options?.logs ?? [];
|
|
135
|
-
const evidence = {
|
|
136
|
-
actionsSeen: [],
|
|
137
|
-
stagesSeen: [],
|
|
138
|
-
errorTags: [],
|
|
139
|
-
logCount: logs.length,
|
|
140
|
-
};
|
|
141
|
-
for (const log of logs) {
|
|
142
|
-
if (log && typeof log === "object") {
|
|
143
|
-
const l = log;
|
|
144
|
-
if (l.action && typeof l.action === "string") {
|
|
145
|
-
if (!evidence.actionsSeen.includes(l.action)) {
|
|
146
|
-
evidence.actionsSeen.push(l.action);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (l.stage && typeof l.stage === "string") {
|
|
150
|
-
if (!evidence.stagesSeen.includes(l.stage)) {
|
|
151
|
-
evidence.stagesSeen.push(l.stage);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (l.error && typeof l.error === "object") {
|
|
155
|
-
const err = l.error;
|
|
156
|
-
if (err.tag && typeof err.tag === "string") {
|
|
157
|
-
if (!evidence.errorTags.includes(err.tag)) {
|
|
158
|
-
evidence.errorTags.push(err.tag);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// Add default suggestions if none
|
|
165
|
-
if (suggestions.length === 0) {
|
|
166
|
-
suggestions.push("Read the gate file to understand expected behavior");
|
|
167
|
-
suggestions.push("Check if all required actions are being logged");
|
|
168
|
-
suggestions.push("Verify the observe resource is receiving logs");
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
summary,
|
|
172
|
-
failedAssertions,
|
|
173
|
-
prdRelevantSlice: options?.prdSlice ?? (failedStory ? {
|
|
174
|
-
storyId: failedStory.id,
|
|
175
|
-
storyTitle: failedStory.title,
|
|
176
|
-
gateFile: failedStory.gateFile,
|
|
177
|
-
} : undefined),
|
|
178
|
-
evidence,
|
|
179
|
-
diffSnippet: options?.diffSnippet,
|
|
180
|
-
suggestions,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Formats an LLM failure summary as a string block.
|
|
185
|
-
* Useful for including in prompts or console output.
|
|
186
|
-
*/
|
|
187
|
-
export function formatLLMFailureSummary(summary) {
|
|
188
|
-
const lines = [
|
|
189
|
-
"=== GATEPROOF FAILURE SUMMARY (LLM-FRIENDLY) ===",
|
|
190
|
-
"",
|
|
191
|
-
`Summary: ${summary.summary}`,
|
|
192
|
-
"",
|
|
193
|
-
];
|
|
194
|
-
if (summary.prdRelevantSlice) {
|
|
195
|
-
lines.push("PRD Context:");
|
|
196
|
-
lines.push(` Story: ${summary.prdRelevantSlice.storyId}`);
|
|
197
|
-
lines.push(` Title: ${summary.prdRelevantSlice.storyTitle}`);
|
|
198
|
-
lines.push(` Gate: ${summary.prdRelevantSlice.gateFile}`);
|
|
199
|
-
if (summary.prdRelevantSlice.scope?.allowedPaths) {
|
|
200
|
-
lines.push(` Allowed paths: ${summary.prdRelevantSlice.scope.allowedPaths.join(", ")}`);
|
|
201
|
-
}
|
|
202
|
-
lines.push("");
|
|
203
|
-
}
|
|
204
|
-
if (summary.failedAssertions.length > 0) {
|
|
205
|
-
lines.push("Failed Assertions:");
|
|
206
|
-
for (const assertion of summary.failedAssertions) {
|
|
207
|
-
lines.push(` - ${assertion.name}: ${assertion.message}`);
|
|
208
|
-
if (assertion.expected)
|
|
209
|
-
lines.push(` Expected: ${assertion.expected}`);
|
|
210
|
-
if (assertion.actual)
|
|
211
|
-
lines.push(` Actual: ${assertion.actual}`);
|
|
212
|
-
}
|
|
213
|
-
lines.push("");
|
|
214
|
-
}
|
|
215
|
-
lines.push("Evidence:");
|
|
216
|
-
lines.push(` Actions seen: ${summary.evidence.actionsSeen.join(", ") || "(none)"}`);
|
|
217
|
-
lines.push(` Stages seen: ${summary.evidence.stagesSeen.join(", ") || "(none)"}`);
|
|
218
|
-
lines.push(` Error tags: ${summary.evidence.errorTags.join(", ") || "(none)"}`);
|
|
219
|
-
lines.push(` Log count: ${summary.evidence.logCount}`);
|
|
220
|
-
lines.push("");
|
|
221
|
-
if (summary.diffSnippet) {
|
|
222
|
-
lines.push("Recent Diff:");
|
|
223
|
-
lines.push(summary.diffSnippet.split("\n").slice(0, 20).join("\n"));
|
|
224
|
-
lines.push("");
|
|
225
|
-
}
|
|
226
|
-
lines.push("Suggestions:");
|
|
227
|
-
for (const suggestion of summary.suggestions) {
|
|
228
|
-
lines.push(` - ${suggestion}`);
|
|
229
|
-
}
|
|
230
|
-
lines.push("");
|
|
231
|
-
lines.push("=== END FAILURE SUMMARY ===");
|
|
232
|
-
return lines.join("\n");
|
|
233
|
-
}
|
|
234
|
-
//# sourceMappingURL=report.js.map
|
package/dist/report.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,YAAY,GAAG,KAAkC,CAAC;QACxD,OAAO;YACL,GAAG,EAAE,YAAY,CAAC,IAAI;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AAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC;IACnF,KAAK,CAAC,IAAI,CAAC,iBAAiB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC;IACjF,KAAK,CAAC,IAAI,CAAC,gBAAgB,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3B,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,OAAO,UAAU,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAE1C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/test-helpers.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test utilities for gateproof
|
|
3
|
-
* Shared helpers used across test files
|
|
4
|
-
*/
|
|
5
|
-
import { Queue } from "effect";
|
|
6
|
-
import type { Log } from "./types";
|
|
7
|
-
/**
|
|
8
|
-
* Creates a test observe resource from a queue
|
|
9
|
-
* Used in test files to simulate log streams
|
|
10
|
-
*/
|
|
11
|
-
export declare function createTestObserveResource(queue: Queue.Queue<Log>): import("./observe").ObserveResource;
|
|
12
|
-
//# sourceMappingURL=test-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../src/test-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAU,KAAK,EAAW,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAGnC;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,uCAwBhE"}
|
package/dist/test-helpers.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test utilities for gateproof
|
|
3
|
-
* Shared helpers used across test files
|
|
4
|
-
*/
|
|
5
|
-
import { Effect, Queue, Runtime } from "effect";
|
|
6
|
-
import { createObserveResource } from "./observe";
|
|
7
|
-
/**
|
|
8
|
-
* Creates a test observe resource from a queue
|
|
9
|
-
* Used in test files to simulate log streams
|
|
10
|
-
*/
|
|
11
|
-
export function createTestObserveResource(queue) {
|
|
12
|
-
const backend = {
|
|
13
|
-
start: () => Effect.succeed({
|
|
14
|
-
async *[Symbol.asyncIterator]() {
|
|
15
|
-
const runtime = Runtime.defaultRuntime;
|
|
16
|
-
while (true) {
|
|
17
|
-
try {
|
|
18
|
-
const log = await Runtime.runPromise(runtime)(Queue.take(queue).pipe(Effect.timeout("100 millis"), Effect.catchAll(() => Effect.succeed(null))));
|
|
19
|
-
if (log === null)
|
|
20
|
-
break;
|
|
21
|
-
yield log;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}),
|
|
29
|
-
stop: () => Effect.void
|
|
30
|
-
};
|
|
31
|
-
return createObserveResource(backend);
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=test-helpers.js.map
|
package/dist/test-helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../src/test-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAgB,MAAM,WAAW,CAAC;AAEhE;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAuB;IAC/D,MAAM,OAAO,GAAY;QACvB,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAqB;YAC9C,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;gBAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;gBACvC,OAAO,IAAI,EAAE,CAAC;oBACZ,IAAI,CAAC;wBACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAC3C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CACpB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAC5B,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAkB,CAAC,CAAC,CAC1D,CACF,CAAC;wBACF,IAAI,GAAG,KAAK,IAAI;4BAAE,MAAM;wBACxB,MAAM,GAAG,CAAC;oBACZ,CAAC;oBAAC,MAAM,CAAC;wBACP,MAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;QACF,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;KACxB,CAAC;IACF,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export interface Log {
|
|
2
|
-
requestId?: string;
|
|
3
|
-
timestamp?: string;
|
|
4
|
-
stage?: string;
|
|
5
|
-
action?: string;
|
|
6
|
-
status?: "start" | "success" | "error" | "info";
|
|
7
|
-
error?: {
|
|
8
|
-
tag: string;
|
|
9
|
-
message: string;
|
|
10
|
-
stack?: string;
|
|
11
|
-
};
|
|
12
|
-
data?: Record<string, unknown>;
|
|
13
|
-
durationMs?: number;
|
|
14
|
-
[k: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
export interface LogFilter {
|
|
17
|
-
requestId?: string;
|
|
18
|
-
stage?: string;
|
|
19
|
-
action?: string;
|
|
20
|
-
status?: "start" | "success" | "error" | "info";
|
|
21
|
-
since?: Date;
|
|
22
|
-
until?: Date;
|
|
23
|
-
}
|
|
24
|
-
export type LogStream = AsyncIterable<Log>;
|
|
25
|
-
export interface GateResult {
|
|
26
|
-
status: "success" | "failed" | "timeout";
|
|
27
|
-
durationMs: number;
|
|
28
|
-
logs: Log[];
|
|
29
|
-
evidence: {
|
|
30
|
-
requestIds: string[];
|
|
31
|
-
stagesSeen: string[];
|
|
32
|
-
actionsSeen: string[];
|
|
33
|
-
errorTags: string[];
|
|
34
|
-
};
|
|
35
|
-
error?: Error;
|
|
36
|
-
}
|
|
37
|
-
export interface ObserveConfig {
|
|
38
|
-
backend: string;
|
|
39
|
-
[k: string]: unknown;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,M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 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utilities for gateproof gates
|
|
3
|
-
* These utilities reduce boilerplate and standardize common patterns
|
|
4
|
-
*/
|
|
5
|
-
import { type GateSpec, type GateResult } from "./index";
|
|
6
|
-
import { type Backend } from "./observe";
|
|
7
|
-
/**
|
|
8
|
-
* Creates an empty backend that yields no logs
|
|
9
|
-
* Useful for gates that validate HTTP endpoints without log observation
|
|
10
|
-
*/
|
|
11
|
-
export declare function createEmptyBackend(): Backend;
|
|
12
|
-
/**
|
|
13
|
-
* Creates an observe resource from an empty backend
|
|
14
|
-
* Convenience wrapper for the common pattern
|
|
15
|
-
*/
|
|
16
|
-
export declare function createEmptyObserveResource(): import("./observe").ObserveResource;
|
|
17
|
-
/**
|
|
18
|
-
* Runs a gate with standardized error handling
|
|
19
|
-
* Returns a result object with consistent structure even on errors
|
|
20
|
-
*/
|
|
21
|
-
export declare function runGateWithErrorHandling(gate: GateSpec, name: string): Promise<GateResult>;
|
|
22
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAQ,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAGhE;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAU5C;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,wCAEzC;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,CAAC,CAcrB"}
|
package/dist/utils.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utilities for gateproof gates
|
|
3
|
-
* These utilities reduce boilerplate and standardize common patterns
|
|
4
|
-
*/
|
|
5
|
-
import { Effect } from "effect";
|
|
6
|
-
import { Gate } from "./index";
|
|
7
|
-
import { createObserveResource } from "./observe";
|
|
8
|
-
/**
|
|
9
|
-
* Creates an empty backend that yields no logs
|
|
10
|
-
* Useful for gates that validate HTTP endpoints without log observation
|
|
11
|
-
*/
|
|
12
|
-
export function createEmptyBackend() {
|
|
13
|
-
return {
|
|
14
|
-
start: () => Effect.succeed({
|
|
15
|
-
async *[Symbol.asyncIterator]() {
|
|
16
|
-
return;
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
stop: () => Effect.void,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Creates an observe resource from an empty backend
|
|
24
|
-
* Convenience wrapper for the common pattern
|
|
25
|
-
*/
|
|
26
|
-
export function createEmptyObserveResource() {
|
|
27
|
-
return createObserveResource(createEmptyBackend());
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Runs a gate with standardized error handling
|
|
31
|
-
* Returns a result object with consistent structure even on errors
|
|
32
|
-
*/
|
|
33
|
-
export async function runGateWithErrorHandling(gate, name) {
|
|
34
|
-
try {
|
|
35
|
-
return await Gate.run(gate);
|
|
36
|
-
}
|
|
37
|
-
catch (unknownError) {
|
|
38
|
-
const error = unknownError instanceof Error ? unknownError : new Error(String(unknownError));
|
|
39
|
-
console.error(` ❌ Error: ${error.message}`);
|
|
40
|
-
return {
|
|
41
|
-
status: "failed",
|
|
42
|
-
durationMs: 0,
|
|
43
|
-
logs: [],
|
|
44
|
-
evidence: { actionsSeen: [], errorTags: [], requestIds: [], stagesSeen: [] },
|
|
45
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAkC,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAgB,MAAM,WAAW,CAAC;AAGhE;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,CACV,MAAM,CAAC,OAAO,CAAqB;YACnC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;gBAC3B,OAAO;YACT,CAAC;SACF,CAAC;QACF,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;KACxB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,qBAAqB,CAAC,kBAAkB,EAAE,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,IAAc,EACd,IAAY;IAEZ,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,YAAY,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,YAAY,YAAY,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;QAC7F,OAAO,CAAC,KAAK,CAAC,eAAe,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9C,OAAO;YACL,MAAM,EAAE,QAAiB;YACzB,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,EAAE;YACR,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;YAC5E,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACjE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/validation.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { GateError } from "./index";
|
|
3
|
-
export declare function validateWorkerName(name: string): Effect.Effect<string, GateError>;
|
|
4
|
-
export declare function validateUrl(url: string): Effect.Effect<string, GateError>;
|
|
5
|
-
export declare function validateCommand(command: string): Effect.Effect<string, GateError>;
|
|
6
|
-
//# sourceMappingURL=validation.d.ts.map
|
package/dist/validation.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAQjF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAUzE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAgBjF"}
|
package/dist/validation.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { GateError } from "./index";
|
|
3
|
-
export function validateWorkerName(name) {
|
|
4
|
-
if (!name || typeof name !== "string") {
|
|
5
|
-
return Effect.fail(new GateError({ cause: new Error("Worker name must be a non-empty string") }));
|
|
6
|
-
}
|
|
7
|
-
if (!/^[a-z0-9_-]+$/i.test(name)) {
|
|
8
|
-
return Effect.fail(new GateError({ cause: new Error("Worker name contains invalid characters") }));
|
|
9
|
-
}
|
|
10
|
-
return Effect.succeed(name);
|
|
11
|
-
}
|
|
12
|
-
export function validateUrl(url) {
|
|
13
|
-
try {
|
|
14
|
-
const parsed = new URL(url);
|
|
15
|
-
if (!["http:", "https:"].includes(parsed.protocol)) {
|
|
16
|
-
return Effect.fail(new GateError({ cause: new Error("URL must use http or https protocol") }));
|
|
17
|
-
}
|
|
18
|
-
return Effect.succeed(url);
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return Effect.fail(new GateError({ cause: new Error("Invalid URL format") }));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export function validateCommand(command) {
|
|
25
|
-
if (!command || typeof command !== "string") {
|
|
26
|
-
return Effect.fail(new GateError({ cause: new Error("Command must be a non-empty string") }));
|
|
27
|
-
}
|
|
28
|
-
// Extremely strict shell safety: block common shell metacharacters and expansion patterns
|
|
29
|
-
const dangerous = /[;&|`$(){}[\]<>\\'"\n\r\t]/;
|
|
30
|
-
const envExpansion = /\$\w+|\$\{[^}]+\}/;
|
|
31
|
-
if (dangerous.test(command) || envExpansion.test(command)) {
|
|
32
|
-
return Effect.fail(new GateError({
|
|
33
|
-
cause: new Error("Command contains potentially dangerous shell characters")
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
return Effect.succeed(command);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=validation.js.map
|
package/dist/validation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAA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