@forkstage/verify 0.1.0 → 0.3.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/dist/flow.d.ts +21 -0
- package/dist/flow.js +169 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.d.ts +25 -3
- package/dist/index.js +38 -4
- package/dist/index.js.map +1 -1
- package/dist/migrations.d.ts +26 -0
- package/dist/migrations.js +119 -0
- package/dist/migrations.js.map +1 -0
- package/dist/plan.d.ts +98 -0
- package/dist/plan.js +68 -0
- package/dist/plan.js.map +1 -0
- package/dist/routes.d.ts +22 -0
- package/dist/routes.js +85 -0
- package/dist/routes.js.map +1 -0
- package/dist/scope.d.ts +17 -0
- package/dist/scope.js +75 -0
- package/dist/scope.js.map +1 -0
- package/package.json +4 -3
package/dist/flow.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Check } from "@forkstage/recipe";
|
|
2
|
+
import type { Exec, MailMessage, Outcome } from "./index.js";
|
|
3
|
+
export interface FlowContext {
|
|
4
|
+
base?: string | undefined;
|
|
5
|
+
appService?: string | undefined;
|
|
6
|
+
exec: (service: string, command: string) => Promise<Exec>;
|
|
7
|
+
/** Captured mail since a moment, oldest first; absent when the stack captures none. */
|
|
8
|
+
readMail?: ((since: string) => Promise<MailMessage[]>) | undefined;
|
|
9
|
+
/** Extra starting variables. */
|
|
10
|
+
vars?: Record<string, string> | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface FlowOutcome extends Outcome {
|
|
13
|
+
evidence: string[];
|
|
14
|
+
/** The variables at the end, for the record. Secrets are not among them by construction. */
|
|
15
|
+
vars: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export declare const fill: (text: string, vars: Record<string, string>) => string;
|
|
18
|
+
/** `$.a.b[0].c` over parsed JSON; undefined when any hop is missing. */
|
|
19
|
+
export declare function jsonPath(value: unknown, path: string): unknown;
|
|
20
|
+
/** Run one flow. Stops at the first failing step; every step before it is evidence too. */
|
|
21
|
+
export declare function runFlow(check: Check, ctx: FlowContext): Promise<FlowOutcome>;
|
package/dist/flow.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// Flow checks: a sequence of steps against the fork, each recorded as one evidence line.
|
|
2
|
+
// Steps are HTTP requests, reads of captured mail, or commands in a service. Placeholders
|
|
3
|
+
// ({{email}}, {{password}}, {{uuid}}, {{now}}) are fresh per flow; `save` keeps values from
|
|
4
|
+
// a JSON response; `mail.extract` pulls a code or a link out of a captured message.
|
|
5
|
+
import { randomBytes, randomUUID } from "node:crypto";
|
|
6
|
+
const freshVars = () => {
|
|
7
|
+
const tag = randomBytes(3).toString("hex");
|
|
8
|
+
return {
|
|
9
|
+
email: `fs-${tag}@example.com`,
|
|
10
|
+
password: `Fs-${randomBytes(6).toString("base64url")}9a`,
|
|
11
|
+
uuid: randomUUID(),
|
|
12
|
+
now: new Date().toISOString(),
|
|
13
|
+
rand: String(100000 + Math.floor(Math.random() * 900000)),
|
|
14
|
+
tag,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export const fill = (text, vars) => text.replace(/\{\{\s*([a-zA-Z_][\w.-]*)\s*\}\}/g, (m, k) => vars[k] ?? m);
|
|
18
|
+
/** `$.a.b[0].c` over parsed JSON; undefined when any hop is missing. */
|
|
19
|
+
export function jsonPath(value, path) {
|
|
20
|
+
const parts = path.replace(/^\$\.?/, "").match(/[^.[\]]+/g) ?? [];
|
|
21
|
+
let cur = value;
|
|
22
|
+
for (const p of parts) {
|
|
23
|
+
if (cur === null || cur === undefined)
|
|
24
|
+
return undefined;
|
|
25
|
+
cur = cur[/^\d+$/.test(p) ? Number(p) : p];
|
|
26
|
+
}
|
|
27
|
+
return cur;
|
|
28
|
+
}
|
|
29
|
+
const brief = (s, n = 240) => {
|
|
30
|
+
const t = s.replace(/\s+/g, " ").trim();
|
|
31
|
+
return t.length > n ? `${t.slice(0, n)}…` : t;
|
|
32
|
+
};
|
|
33
|
+
const stripHtml = (html) => html
|
|
34
|
+
.replace(/<style[\s\S]*?<\/style>/gi, " ")
|
|
35
|
+
.replace(/<[^>]+>/g, " ")
|
|
36
|
+
.replace(/ /g, " ")
|
|
37
|
+
.replace(/&/g, "&")
|
|
38
|
+
.replace(/\s+/g, " ");
|
|
39
|
+
/** Run one flow. Stops at the first failing step; every step before it is evidence too. */
|
|
40
|
+
export async function runFlow(check, ctx) {
|
|
41
|
+
const started = Date.now();
|
|
42
|
+
const startedAt = new Date().toISOString();
|
|
43
|
+
const vars = { ...freshVars(), ...(ctx.vars ?? {}) };
|
|
44
|
+
const evidence = [];
|
|
45
|
+
const steps = check.steps ?? [];
|
|
46
|
+
const fail = (detail) => ({
|
|
47
|
+
status: "failed",
|
|
48
|
+
detail,
|
|
49
|
+
evidence,
|
|
50
|
+
vars,
|
|
51
|
+
ms: Date.now() - started,
|
|
52
|
+
tail: evidence.slice(-6).join("\n"),
|
|
53
|
+
});
|
|
54
|
+
for (let i = 0; i < steps.length; i++) {
|
|
55
|
+
const step = steps[i];
|
|
56
|
+
const label = step.name ?? `step ${i + 1}`;
|
|
57
|
+
if (step.http) {
|
|
58
|
+
if (!ctx.base)
|
|
59
|
+
return fail(`${label}: the app has no HTTP address`);
|
|
60
|
+
const [method, rawPath] = step.http.split(" ");
|
|
61
|
+
const path = fill(rawPath, vars);
|
|
62
|
+
const body = step.body ? fill(step.body, vars) : undefined;
|
|
63
|
+
const headers = {};
|
|
64
|
+
for (const [k, v] of Object.entries(step.headers ?? {}))
|
|
65
|
+
headers[k] = fill(v, vars);
|
|
66
|
+
if (body && !Object.keys(headers).some((h) => h.toLowerCase() === "content-type"))
|
|
67
|
+
headers["content-type"] = "application/json";
|
|
68
|
+
const t0 = Date.now();
|
|
69
|
+
let status = 0;
|
|
70
|
+
let text = "";
|
|
71
|
+
try {
|
|
72
|
+
const res = await fetch(`${ctx.base}${path}`, {
|
|
73
|
+
method,
|
|
74
|
+
headers,
|
|
75
|
+
...(body ? { body } : {}),
|
|
76
|
+
redirect: "manual",
|
|
77
|
+
signal: AbortSignal.timeout(30_000),
|
|
78
|
+
});
|
|
79
|
+
status = res.status;
|
|
80
|
+
text = await res.text().catch(() => "");
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
text = error.message;
|
|
84
|
+
}
|
|
85
|
+
const ms = Date.now() - t0;
|
|
86
|
+
const expect = step.expect ?? 200;
|
|
87
|
+
const line = `${method} ${path} → ${status || "no answer"} (${ms} ms)`;
|
|
88
|
+
if (status !== expect) {
|
|
89
|
+
evidence.push(`${line}, expected ${expect}${text ? `: ${brief(text)}` : ""}`);
|
|
90
|
+
return fail(`${label}: ${method} ${path} answered ${status || "nothing"}, expected ${expect}`);
|
|
91
|
+
}
|
|
92
|
+
if (step.contains && !text.includes(fill(step.contains, vars))) {
|
|
93
|
+
evidence.push(`${line}, body lacks "${fill(step.contains, vars)}": ${brief(text)}`);
|
|
94
|
+
return fail(`${label}: the response does not contain "${fill(step.contains, vars)}"`);
|
|
95
|
+
}
|
|
96
|
+
if (step.save) {
|
|
97
|
+
let json = null;
|
|
98
|
+
try {
|
|
99
|
+
json = JSON.parse(text);
|
|
100
|
+
}
|
|
101
|
+
catch { }
|
|
102
|
+
for (const [name, pathExpr] of Object.entries(step.save)) {
|
|
103
|
+
const v = jsonPath(json, pathExpr);
|
|
104
|
+
if (v === undefined || v === null) {
|
|
105
|
+
evidence.push(`${line}, but ${pathExpr} is missing from the response: ${brief(text)}`);
|
|
106
|
+
return fail(`${label}: ${pathExpr} not found in the response`);
|
|
107
|
+
}
|
|
108
|
+
vars[name] = typeof v === "string" ? v : JSON.stringify(v);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
evidence.push(line);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (step.mail) {
|
|
115
|
+
if (!ctx.readMail)
|
|
116
|
+
return fail(`${label}: this stack captures no mail`);
|
|
117
|
+
const want = step.mail;
|
|
118
|
+
const to = want.to ? fill(want.to, vars).toLowerCase() : null;
|
|
119
|
+
const subject = want.subject ? fill(want.subject, vars).toLowerCase() : null;
|
|
120
|
+
const deadline = Date.now() + (want.timeout_seconds ?? 20) * 1000;
|
|
121
|
+
let found = null;
|
|
122
|
+
while (Date.now() < deadline && !found) {
|
|
123
|
+
const messages = await ctx.readMail(startedAt).catch(() => []);
|
|
124
|
+
found =
|
|
125
|
+
messages.find((m) => (!to || m.to.some((a) => a.toLowerCase() === to)) &&
|
|
126
|
+
(!subject || m.subject.toLowerCase().includes(subject))) ?? null;
|
|
127
|
+
if (!found)
|
|
128
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
129
|
+
}
|
|
130
|
+
if (!found) {
|
|
131
|
+
evidence.push(`mail${to ? ` to ${to}` : ""}${subject ? ` about "${subject}"` : ""}: nothing captured within ${want.timeout_seconds ?? 20} s`);
|
|
132
|
+
return fail(`${label}: no captured message${to ? ` to ${to}` : ""} arrived`);
|
|
133
|
+
}
|
|
134
|
+
const haystack = `${found.subject}\n${found.text ?? ""}\n${stripHtml(found.html ?? "")}\n${found.snippet}`;
|
|
135
|
+
const got = [];
|
|
136
|
+
for (const [name, pattern] of Object.entries(want.extract ?? {})) {
|
|
137
|
+
const m = new RegExp(pattern).exec(haystack);
|
|
138
|
+
if (!m) {
|
|
139
|
+
evidence.push(`mail to ${found.to.join(", ")}: "${found.subject}", but /${pattern}/ matched nothing`);
|
|
140
|
+
return fail(`${label}: ${name} not found in the message`);
|
|
141
|
+
}
|
|
142
|
+
vars[name] = m[1] ?? m[0];
|
|
143
|
+
got.push(`${name}=${vars[name]}`);
|
|
144
|
+
}
|
|
145
|
+
evidence.push(`mail to ${found.to.join(", ")}: "${found.subject}"${got.length ? ` · ${got.join(" ")}` : ""}`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (step.run) {
|
|
149
|
+
const service = step.in ?? ctx.appService;
|
|
150
|
+
if (!service)
|
|
151
|
+
return fail(`${label}: no service to run in`);
|
|
152
|
+
const r = await ctx.exec(service, fill(step.run, vars));
|
|
153
|
+
const line = `${fill(step.run, vars)} in ${service} → exit ${r.exitCode} (${r.ms} ms)`;
|
|
154
|
+
if (r.exitCode !== 0) {
|
|
155
|
+
evidence.push(`${line}: ${brief(r.output, 300)}`);
|
|
156
|
+
return fail(`${label}: command exited ${r.exitCode}`);
|
|
157
|
+
}
|
|
158
|
+
evidence.push(line);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
status: "passed",
|
|
163
|
+
detail: `${steps.length} step${steps.length === 1 ? "" : "s"} as expected`,
|
|
164
|
+
evidence,
|
|
165
|
+
vars,
|
|
166
|
+
ms: Date.now() - started,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=flow.js.map
|
package/dist/flow.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,0FAA0F;AAC1F,4FAA4F;AAC5F,oFAAoF;AACpF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoBtD,MAAM,SAAS,GAAG,GAA2B,EAAE;IAC7C,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO;QACL,KAAK,EAAE,MAAM,GAAG,cAAc;QAC9B,QAAQ,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI;QACxD,IAAI,EAAE,UAAU,EAAE;QAClB,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;QACzD,GAAG;KACJ,CAAC;AACJ,CAAC,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stage/recipe";
|
|
3
|
+
import { type FlowContext } from "./flow.js";
|
|
3
4
|
export interface Outcome {
|
|
4
5
|
status: "passed" | "failed" | "warn" | "skipped";
|
|
5
6
|
/** One line: what was checked and the numbers. */
|
|
@@ -24,6 +25,11 @@ export type DiscoveredApi = {
|
|
|
24
25
|
path: string;
|
|
25
26
|
fields: number;
|
|
26
27
|
};
|
|
28
|
+
/** The OpenAPI document itself, when the app publishes one, with the path it was found at. */
|
|
29
|
+
export declare function fetchOpenApi(base: string): Promise<{
|
|
30
|
+
path: string;
|
|
31
|
+
doc: unknown;
|
|
32
|
+
} | null>;
|
|
27
33
|
/** The app's own description of its API, when it publishes one. */
|
|
28
34
|
export declare function discoverApi(base: string): Promise<DiscoveredApi | null>;
|
|
29
35
|
/**
|
|
@@ -31,7 +37,14 @@ export declare function discoverApi(base: string): Promise<DiscoveredApi | null>
|
|
|
31
37
|
* route once and count the ones that crash (5xx, timeout, connection error). Not a test of
|
|
32
38
|
* correctness; a test that nothing explodes when touched.
|
|
33
39
|
*/
|
|
34
|
-
export declare function apiSmoke(base: string | undefined, log?: (line: string) => void)
|
|
40
|
+
export declare function apiSmoke(base: string | undefined, log?: (line: string) => void, fallback?: () => Promise<{
|
|
41
|
+
kind: "routes";
|
|
42
|
+
source: string;
|
|
43
|
+
routes: string[];
|
|
44
|
+
} | {
|
|
45
|
+
kind: "grpc";
|
|
46
|
+
services: string[];
|
|
47
|
+
} | null>): Promise<Outcome>;
|
|
35
48
|
export interface CheckContext {
|
|
36
49
|
/** The app's address, for `http` checks. */
|
|
37
50
|
base?: string | undefined;
|
|
@@ -40,8 +53,12 @@ export interface CheckContext {
|
|
|
40
53
|
/** Run a command in a service and return its exit code and output. */
|
|
41
54
|
exec: (service: string, command: string) => Promise<Exec>;
|
|
42
55
|
}
|
|
43
|
-
/** One `checks:` entry: a command that must exit 0, or one request that must answer a status. */
|
|
44
|
-
export declare function runCheck(check: Check, ctx: CheckContext
|
|
56
|
+
/** One `checks:` entry: a flow of steps, a command that must exit 0, or one request that must answer a status. */
|
|
57
|
+
export declare function runCheck(check: Check, ctx: CheckContext & {
|
|
58
|
+
readMail?: FlowContext["readMail"];
|
|
59
|
+
}): Promise<Outcome & {
|
|
60
|
+
evidence?: string[];
|
|
61
|
+
}>;
|
|
45
62
|
/** The outcome recorded when a recipe declares no checks: a skip, with the reason that matters. */
|
|
46
63
|
export declare const NO_CHECKS: Outcome;
|
|
47
64
|
/**
|
|
@@ -77,3 +94,8 @@ export declare function emailEvents(messages: MailMessage[]): EmailEvent[];
|
|
|
77
94
|
/** The step's outcome for a set of captured messages. */
|
|
78
95
|
export declare function mailOutcome(messages: MailMessage[], hosts: string[], ms: number): Outcome;
|
|
79
96
|
export declare const NO_CAPTURE: Outcome;
|
|
97
|
+
export { type FlowContext, type FlowOutcome, fill, jsonPath, runFlow } from "./flow.js";
|
|
98
|
+
export { detectScript, MIGRATION_TOOLS, type MigrationsContext, type MigrationsOutcome, type MigrationTool, migrationsProbe, parseDetected, } from "./migrations.js";
|
|
99
|
+
export { ApiSurface, Intent, Plan, PlanCheck, PlanRequest, surfaceFromOpenApi, } from "./plan.js";
|
|
100
|
+
export { grpcScript, parseGrpc, parseRoutes, type RoutesByCommand, routesFallback, routesScript, } from "./routes.js";
|
|
101
|
+
export { type ChangeFiles, changeScope, type Scope, serviceFor } from "./scope.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runFlow } from "./flow.js";
|
|
1
2
|
/** The last lines of a text, enough to read, never the whole thing. */
|
|
2
3
|
export function tailText(text, lines = 12, chars = 1200) {
|
|
3
4
|
const t = text.trim().split("\n").slice(-lines).join("\n");
|
|
@@ -24,6 +25,15 @@ async function getJson(url) {
|
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
26
27
|
}
|
|
28
|
+
/** The OpenAPI document itself, when the app publishes one, with the path it was found at. */
|
|
29
|
+
export async function fetchOpenApi(base) {
|
|
30
|
+
for (const path of API_DOCS) {
|
|
31
|
+
const doc = await getJson(`${base}${path}`);
|
|
32
|
+
if (doc && typeof doc === "object" && "paths" in doc)
|
|
33
|
+
return { path, doc };
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
27
37
|
/** The app's own description of its API, when it publishes one. */
|
|
28
38
|
export async function discoverApi(base) {
|
|
29
39
|
for (const path of API_DOCS) {
|
|
@@ -56,15 +66,26 @@ export async function discoverApi(base) {
|
|
|
56
66
|
* route once and count the ones that crash (5xx, timeout, connection error). Not a test of
|
|
57
67
|
* correctness; a test that nothing explodes when touched.
|
|
58
68
|
*/
|
|
59
|
-
export async function apiSmoke(base, log = () => { }) {
|
|
69
|
+
export async function apiSmoke(base, log = () => { }, fallback) {
|
|
60
70
|
const started = Date.now();
|
|
61
71
|
if (!base)
|
|
62
72
|
return { status: "skipped", detail: "the app has no HTTP address", ms: 0 };
|
|
63
|
-
|
|
73
|
+
let found = await discoverApi(base);
|
|
74
|
+
if (!found && fallback) {
|
|
75
|
+
const fb = await fallback().catch(() => null);
|
|
76
|
+
if (fb?.kind === "grpc")
|
|
77
|
+
return {
|
|
78
|
+
status: "passed",
|
|
79
|
+
detail: `gRPC reflection lists ${plural(fb.services.length, "service")}: ${fb.services.slice(0, 6).join(", ")}${fb.services.length > 6 ? ", …" : ""}`,
|
|
80
|
+
ms: Date.now() - started,
|
|
81
|
+
};
|
|
82
|
+
if (fb?.kind === "routes")
|
|
83
|
+
found = { kind: "openapi", path: `the ${fb.source} route table`, routes: fb.routes };
|
|
84
|
+
}
|
|
64
85
|
if (!found)
|
|
65
86
|
return {
|
|
66
87
|
status: "skipped",
|
|
67
|
-
detail: `no API description found (tried ${API_DOCS.join(", ")}
|
|
88
|
+
detail: `no API description found (tried ${API_DOCS.join(", ")}, GraphQL at /graphql, and the Laravel, Rails and Django route tables)`,
|
|
68
89
|
ms: Date.now() - started,
|
|
69
90
|
};
|
|
70
91
|
if (found.kind === "graphql")
|
|
@@ -73,6 +94,12 @@ export async function apiSmoke(base, log = () => { }) {
|
|
|
73
94
|
detail: `GraphQL schema at ${found.path}: ${plural(found.fields, "query field")}, introspection answered`,
|
|
74
95
|
ms: Date.now() - started,
|
|
75
96
|
};
|
|
97
|
+
if (!found.routes.length)
|
|
98
|
+
return {
|
|
99
|
+
status: "skipped",
|
|
100
|
+
detail: `${found.path} lists no parameterless GET route to call`,
|
|
101
|
+
ms: Date.now() - started,
|
|
102
|
+
};
|
|
76
103
|
log(`API smoke: ${plural(found.routes.length, "read route")} from ${found.path}`);
|
|
77
104
|
const failures = [];
|
|
78
105
|
const queue = [...found.routes];
|
|
@@ -100,8 +127,10 @@ export async function apiSmoke(base, log = () => { }) {
|
|
|
100
127
|
ms: Date.now() - started,
|
|
101
128
|
};
|
|
102
129
|
}
|
|
103
|
-
/** One `checks:` entry: a command that must exit 0, or one request that must answer a status. */
|
|
130
|
+
/** One `checks:` entry: a flow of steps, a command that must exit 0, or one request that must answer a status. */
|
|
104
131
|
export async function runCheck(check, ctx) {
|
|
132
|
+
if (check.steps)
|
|
133
|
+
return runFlow(check, ctx);
|
|
105
134
|
const started = Date.now();
|
|
106
135
|
if (check.run) {
|
|
107
136
|
const service = check.in ?? ctx.appService;
|
|
@@ -238,4 +267,9 @@ export const NO_CAPTURE = {
|
|
|
238
267
|
detail: "no outside host in capture mode; mail the stack sends is not observed",
|
|
239
268
|
ms: 0,
|
|
240
269
|
};
|
|
270
|
+
export { fill, jsonPath, runFlow } from "./flow.js";
|
|
271
|
+
export { detectScript, MIGRATION_TOOLS, migrationsProbe, parseDetected, } from "./migrations.js";
|
|
272
|
+
export { ApiSurface, Intent, Plan, PlanCheck, PlanRequest, surfaceFromOpenApi, } from "./plan.js";
|
|
273
|
+
export { grpcScript, parseGrpc, parseRoutes, routesFallback, routesScript, } from "./routes.js";
|
|
274
|
+
export { changeScope, serviceFor } from "./scope.js";
|
|
241
275
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|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nB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EAEX,cAAc,EACd,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAoB,WAAW,EAAc,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Exec, Outcome } from "./index.js";
|
|
2
|
+
export interface MigrationTool {
|
|
3
|
+
name: string;
|
|
4
|
+
/** A shell test that succeeds when the tool is in use, run in the app's working directory. */
|
|
5
|
+
detect: string;
|
|
6
|
+
/** The command that applies pending migrations; empty when they apply at application start. */
|
|
7
|
+
command: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const MIGRATION_TOOLS: MigrationTool[];
|
|
10
|
+
/** One shell command that prints the name of every tool detected, one per line. */
|
|
11
|
+
export declare function detectScript(): string;
|
|
12
|
+
export declare function parseDetected(output: string): MigrationTool[];
|
|
13
|
+
export interface MigrationsContext {
|
|
14
|
+
/** The recipe's own `migrate:` command, when set; it wins. */
|
|
15
|
+
recipeMigrate?: string | undefined;
|
|
16
|
+
appService?: string | undefined;
|
|
17
|
+
exec: (service: string, command: string) => Promise<Exec>;
|
|
18
|
+
/** Whether the app answers its ready check; run after migrations when given. */
|
|
19
|
+
healthy?: (() => Promise<boolean>) | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface MigrationsOutcome extends Outcome {
|
|
22
|
+
tool?: string;
|
|
23
|
+
command?: string;
|
|
24
|
+
}
|
|
25
|
+
/** The migrations step. */
|
|
26
|
+
export declare function migrationsProbe(ctx: MigrationsContext): Promise<MigrationsOutcome>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export const MIGRATION_TOOLS = [
|
|
2
|
+
{ name: "alembic", detect: "test -f alembic.ini", command: "alembic upgrade head" },
|
|
3
|
+
{
|
|
4
|
+
name: "django",
|
|
5
|
+
detect: "test -f manage.py",
|
|
6
|
+
command: "python manage.py migrate --noinput 2>&1 || python3 manage.py migrate --noinput",
|
|
7
|
+
},
|
|
8
|
+
{ name: "prisma", detect: "test -f prisma/schema.prisma", command: "npx prisma migrate deploy" },
|
|
9
|
+
{
|
|
10
|
+
name: "rails",
|
|
11
|
+
detect: "test -d db/migrate",
|
|
12
|
+
command: "bin/rails db:migrate 2>&1 || bundle exec rails db:migrate",
|
|
13
|
+
},
|
|
14
|
+
{ name: "knex", detect: "ls knexfile.* >/dev/null 2>&1", command: "npx knex migrate:latest" },
|
|
15
|
+
{ name: "sequelize", detect: "test -f .sequelizerc", command: "npx sequelize-cli db:migrate" },
|
|
16
|
+
{
|
|
17
|
+
name: "drizzle",
|
|
18
|
+
detect: "ls drizzle.config.* >/dev/null 2>&1",
|
|
19
|
+
command: "npx drizzle-kit migrate",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "typeorm",
|
|
23
|
+
detect: "ls ormconfig.* >/dev/null 2>&1",
|
|
24
|
+
command: "npx typeorm migration:run",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "golang-migrate",
|
|
28
|
+
detect: "ls migrations/*.sql >/dev/null 2>&1 && command -v migrate >/dev/null",
|
|
29
|
+
command: 'migrate -path migrations -database "$DATABASE_URL" up',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "goose",
|
|
33
|
+
detect: "command -v goose >/dev/null && test -d migrations",
|
|
34
|
+
command: "goose up",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "dbmate",
|
|
38
|
+
detect: "command -v dbmate >/dev/null && test -d db/migrations",
|
|
39
|
+
command: "dbmate up",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "ef-core",
|
|
43
|
+
detect: "ls *.csproj >/dev/null 2>&1 && test -d Migrations && command -v dotnet >/dev/null",
|
|
44
|
+
command: "dotnet ef database update",
|
|
45
|
+
},
|
|
46
|
+
{ name: "flyway", detect: "test -d src/main/resources/db/migration", command: "" },
|
|
47
|
+
{
|
|
48
|
+
name: "liquibase",
|
|
49
|
+
detect: "test -d src/main/resources/db/changelog || test -f liquibase.properties",
|
|
50
|
+
command: "",
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
/** One shell command that prints the name of every tool detected, one per line. */
|
|
54
|
+
export function detectScript() {
|
|
55
|
+
return `${MIGRATION_TOOLS.map((t) => `(${t.detect}) 2>/dev/null && echo ${t.name}`).join("; ")}; true`;
|
|
56
|
+
}
|
|
57
|
+
export function parseDetected(output) {
|
|
58
|
+
const names = new Set(output
|
|
59
|
+
.split("\n")
|
|
60
|
+
.map((l) => l.trim())
|
|
61
|
+
.filter(Boolean));
|
|
62
|
+
return MIGRATION_TOOLS.filter((t) => names.has(t.name));
|
|
63
|
+
}
|
|
64
|
+
const LOOKED_FOR = "alembic.ini, manage.py, prisma/schema.prisma, db/migrate, knexfile, drizzle.config, .sequelizerc, ormconfig, migrations/*.sql with migrate, goose or dbmate, EF Core Migrations, flyway and liquibase folders";
|
|
65
|
+
/** The migrations step. */
|
|
66
|
+
export async function migrationsProbe(ctx) {
|
|
67
|
+
const started = Date.now();
|
|
68
|
+
if (!ctx.appService)
|
|
69
|
+
return { status: "skipped", detail: "no app service to run migrations in", ms: 0 };
|
|
70
|
+
let tool = null;
|
|
71
|
+
if (ctx.recipeMigrate)
|
|
72
|
+
tool = { name: "recipe", detect: "", command: ctx.recipeMigrate };
|
|
73
|
+
else {
|
|
74
|
+
const found = await ctx.exec(ctx.appService, detectScript());
|
|
75
|
+
const tools = parseDetected(found.output);
|
|
76
|
+
tool = tools[0] ?? null;
|
|
77
|
+
}
|
|
78
|
+
if (!tool)
|
|
79
|
+
return {
|
|
80
|
+
status: "skipped",
|
|
81
|
+
detail: `no migration tool found (looked for ${LOOKED_FOR})`,
|
|
82
|
+
ms: Date.now() - started,
|
|
83
|
+
};
|
|
84
|
+
if (!tool.command) {
|
|
85
|
+
const ok = ctx.healthy ? await ctx.healthy() : true;
|
|
86
|
+
return {
|
|
87
|
+
status: ok ? "passed" : "warn",
|
|
88
|
+
tool: tool.name,
|
|
89
|
+
detail: ok
|
|
90
|
+
? `${tool.name} migrations apply at application start; the app answered after boot`
|
|
91
|
+
: `${tool.name} migrations apply at application start, but the app is not answering`,
|
|
92
|
+
ms: Date.now() - started,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const r = await ctx.exec(ctx.appService, tool.command);
|
|
96
|
+
if (r.exitCode !== 0)
|
|
97
|
+
return {
|
|
98
|
+
status: "failed",
|
|
99
|
+
tool: tool.name,
|
|
100
|
+
command: tool.command,
|
|
101
|
+
detail: `${tool.name}: ${tool.command} exited ${r.exitCode}`,
|
|
102
|
+
tail: r.output.trim().split("\n").slice(-12).join("\n").slice(-1600),
|
|
103
|
+
ms: Date.now() - started,
|
|
104
|
+
};
|
|
105
|
+
const healthy = ctx.healthy ? await ctx.healthy() : true;
|
|
106
|
+
return {
|
|
107
|
+
status: healthy ? "passed" : "failed",
|
|
108
|
+
tool: tool.name,
|
|
109
|
+
command: tool.command,
|
|
110
|
+
detail: healthy
|
|
111
|
+
? `${tool.name}: ${tool.command} exited 0 in ${(r.ms / 1000).toFixed(1)} s; the app answers`
|
|
112
|
+
: `${tool.name}: ${tool.command} exited 0, but the app stopped answering`,
|
|
113
|
+
...(r.output.trim()
|
|
114
|
+
? { tail: r.output.trim().split("\n").slice(-6).join("\n").slice(-600) }
|
|
115
|
+
: {}),
|
|
116
|
+
ms: Date.now() - started,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,OAAO,EAAE,sBAAsB,EAAE;IACnF;QACE,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,mB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C;IACJ,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;QACrC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,OAAO;YACb,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB;YAC5F,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,0CAA0C;QAC3E,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE;YACjB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE;YACxE,CAAC,CAAC,EAAE,CAAC;QACP,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO;KACzB,CAAC;AACJ,CAAC"}
|
package/dist/plan.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const Intent: z.ZodObject<{
|
|
3
|
+
feature: z.ZodString;
|
|
4
|
+
must: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
5
|
+
must_not: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type Intent = z.infer<typeof Intent>;
|
|
8
|
+
export declare const ApiSurface: z.ZodObject<{
|
|
9
|
+
source: z.ZodString;
|
|
10
|
+
paths: z.ZodArray<z.ZodObject<{
|
|
11
|
+
path: z.ZodString;
|
|
12
|
+
methods: z.ZodArray<z.ZodString>;
|
|
13
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type ApiSurface = z.infer<typeof ApiSurface>;
|
|
17
|
+
export declare const PlanRequest: z.ZodObject<{
|
|
18
|
+
intent: z.ZodObject<{
|
|
19
|
+
feature: z.ZodString;
|
|
20
|
+
must: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
21
|
+
must_not: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
stack: z.ZodString;
|
|
24
|
+
app: z.ZodObject<{
|
|
25
|
+
api: z.ZodNullable<z.ZodObject<{
|
|
26
|
+
source: z.ZodString;
|
|
27
|
+
paths: z.ZodArray<z.ZodObject<{
|
|
28
|
+
path: z.ZodString;
|
|
29
|
+
methods: z.ZodArray<z.ZodString>;
|
|
30
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
mail_capture: z.ZodBoolean;
|
|
34
|
+
readiness: z.ZodNullable<z.ZodString>;
|
|
35
|
+
recipe_checks: z.ZodArray<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
max_checks: z.ZodDefault<z.ZodNumber>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type PlanRequest = z.infer<typeof PlanRequest>;
|
|
40
|
+
export declare const PlanCheck: z.ZodObject<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
goal: z.ZodEnum<{
|
|
43
|
+
must: "must";
|
|
44
|
+
must_not: "must_not";
|
|
45
|
+
smoke: "smoke";
|
|
46
|
+
}>;
|
|
47
|
+
claim: z.ZodString;
|
|
48
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
49
|
+
name: z.ZodOptional<z.ZodString>;
|
|
50
|
+
http: z.ZodOptional<z.ZodString>;
|
|
51
|
+
body: z.ZodOptional<z.ZodString>;
|
|
52
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
53
|
+
expect: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
contains: z.ZodOptional<z.ZodString>;
|
|
55
|
+
save: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
56
|
+
mail: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
to: z.ZodOptional<z.ZodString>;
|
|
58
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
59
|
+
extract: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
60
|
+
timeout_seconds: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strict>>;
|
|
62
|
+
run: z.ZodOptional<z.ZodString>;
|
|
63
|
+
in: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export type PlanCheck = z.infer<typeof PlanCheck>;
|
|
67
|
+
export declare const Plan: z.ZodObject<{
|
|
68
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
69
|
+
name: z.ZodString;
|
|
70
|
+
goal: z.ZodEnum<{
|
|
71
|
+
must: "must";
|
|
72
|
+
must_not: "must_not";
|
|
73
|
+
smoke: "smoke";
|
|
74
|
+
}>;
|
|
75
|
+
claim: z.ZodString;
|
|
76
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
77
|
+
name: z.ZodOptional<z.ZodString>;
|
|
78
|
+
http: z.ZodOptional<z.ZodString>;
|
|
79
|
+
body: z.ZodOptional<z.ZodString>;
|
|
80
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
81
|
+
expect: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
contains: z.ZodOptional<z.ZodString>;
|
|
83
|
+
save: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
84
|
+
mail: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
to: z.ZodOptional<z.ZodString>;
|
|
86
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
87
|
+
extract: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
88
|
+
timeout_seconds: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
}, z.core.$strict>>;
|
|
90
|
+
run: z.ZodOptional<z.ZodString>;
|
|
91
|
+
in: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>>;
|
|
93
|
+
}, z.core.$strip>>;
|
|
94
|
+
not_covered: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
export type Plan = z.infer<typeof Plan>;
|
|
97
|
+
/** The OpenAPI document reduced to the surface a plan needs. */
|
|
98
|
+
export declare function surfaceFromOpenApi(doc: unknown, source: string): ApiSurface | null;
|
package/dist/plan.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The verification agent's contract: what the CLI sends the control plane about the change
|
|
2
|
+
// and the fork, and what comes back. Both sides validate against these schemas; the plan is
|
|
3
|
+
// then run with the same flow runner a recipe check uses.
|
|
4
|
+
import { FlowStep } from "@forkstage/recipe";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
export const Intent = z.object({
|
|
7
|
+
/** What the change is, in the words of whoever asked for it. */
|
|
8
|
+
feature: z.string().min(1).max(4000),
|
|
9
|
+
/** Behaviours that must hold. */
|
|
10
|
+
must: z.array(z.string().min(1).max(500)).max(30).default([]),
|
|
11
|
+
/** Behaviours that must not be possible. */
|
|
12
|
+
must_not: z.array(z.string().min(1).max(500)).max(30).default([]),
|
|
13
|
+
});
|
|
14
|
+
export const ApiSurface = z.object({
|
|
15
|
+
/** Where the description came from: /openapi.json, the rails route table, … */
|
|
16
|
+
source: z.string(),
|
|
17
|
+
/** Paths with the methods they accept, trimmed to what a plan can use. */
|
|
18
|
+
paths: z
|
|
19
|
+
.array(z.object({ path: z.string(), methods: z.array(z.string()), summary: z.string().optional() }))
|
|
20
|
+
.max(400),
|
|
21
|
+
});
|
|
22
|
+
export const PlanRequest = z.object({
|
|
23
|
+
intent: Intent,
|
|
24
|
+
stack: z.string(),
|
|
25
|
+
app: z.object({
|
|
26
|
+
api: ApiSurface.nullable(),
|
|
27
|
+
mail_capture: z.boolean(),
|
|
28
|
+
readiness: z.string().nullable(),
|
|
29
|
+
/** Checks the recipe already declares, by name, so the plan does not repeat them. */
|
|
30
|
+
recipe_checks: z.array(z.string()).max(100),
|
|
31
|
+
}),
|
|
32
|
+
max_checks: z.number().int().min(1).max(12).default(8),
|
|
33
|
+
});
|
|
34
|
+
export const PlanCheck = z.object({
|
|
35
|
+
/** kebab-case, unique within the plan. */
|
|
36
|
+
name: z.string().regex(/^[a-z][a-z0-9-]{1,39}$/, "lowercase letters, digits and dashes"),
|
|
37
|
+
goal: z.enum(["must", "must_not", "smoke"]),
|
|
38
|
+
/** One sentence: what this check proves if it passes. */
|
|
39
|
+
claim: z.string().min(1).max(300),
|
|
40
|
+
steps: z.array(FlowStep).min(1).max(12),
|
|
41
|
+
});
|
|
42
|
+
export const Plan = z.object({
|
|
43
|
+
checks: z.array(PlanCheck).max(12),
|
|
44
|
+
/** What the agent could not test and why, one line each. */
|
|
45
|
+
not_covered: z.array(z.string().max(300)).max(20).default([]),
|
|
46
|
+
});
|
|
47
|
+
/** The OpenAPI document reduced to the surface a plan needs. */
|
|
48
|
+
export function surfaceFromOpenApi(doc, source) {
|
|
49
|
+
if (!doc || typeof doc !== "object" || !("paths" in doc))
|
|
50
|
+
return null;
|
|
51
|
+
const paths = doc.paths;
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const [path, ops] of Object.entries(paths)) {
|
|
54
|
+
if (!ops || typeof ops !== "object")
|
|
55
|
+
continue;
|
|
56
|
+
const methods = Object.keys(ops)
|
|
57
|
+
.filter((m) => /^(get|post|put|patch|delete|head)$/i.test(m))
|
|
58
|
+
.map((m) => m.toUpperCase());
|
|
59
|
+
if (!methods.length)
|
|
60
|
+
continue;
|
|
61
|
+
const summary = Object.values(ops).find((o) => o && typeof o === "object" && o.summary)?.summary;
|
|
62
|
+
out.push({ path, methods, ...(summary ? { summary: summary.slice(0, 120) } : {}) });
|
|
63
|
+
if (out.length >= 400)
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return { source, paths: out };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=plan.js.map
|
package/dist/plan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,4FAA4F;AAC5F,0DAA0D;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,gEAAgE;IAChE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACpC,iCAAiC;IACjC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7D,4CAA4C;IAC5C,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OA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AC,CAAC,CAAC,EAAE,EAAE,CAAC,qCAAqC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,SAAS;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,CAC/C,EAAE,OAAO,CAAC;QACX,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACpF,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG;YAAE,MAAM;IAC/B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/routes.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Exec } from "./index.js";
|
|
2
|
+
export interface RoutesByCommand {
|
|
3
|
+
source: string;
|
|
4
|
+
/** GET paths without parameters, for the smoke. */
|
|
5
|
+
routes: string[];
|
|
6
|
+
}
|
|
7
|
+
/** Prints `== <source>` then the framework's own route listing, for the first framework found. */
|
|
8
|
+
export declare function routesScript(): string;
|
|
9
|
+
/** The GET paths without parameters from a framework's listing; null when nothing was printed. */
|
|
10
|
+
export declare function parseRoutes(output: string): RoutesByCommand | null;
|
|
11
|
+
/** Lists gRPC services through reflection when grpcurl is in the app container. */
|
|
12
|
+
export declare function grpcScript(port: number): string;
|
|
13
|
+
export declare function parseGrpc(output: string): string[];
|
|
14
|
+
/** The probes that need a command in the app, as one function for the API smoke to call. */
|
|
15
|
+
export declare function routesFallback(exec: (service: string, command: string) => Promise<Exec>, appService: string | undefined, port: number | undefined): Promise<{
|
|
16
|
+
kind: "routes";
|
|
17
|
+
source: string;
|
|
18
|
+
routes: string[];
|
|
19
|
+
} | {
|
|
20
|
+
kind: "grpc";
|
|
21
|
+
services: string[];
|
|
22
|
+
} | null>;
|
package/dist/routes.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** Prints `== <source>` then the framework's own route listing, for the first framework found. */
|
|
2
|
+
export function routesScript() {
|
|
3
|
+
return [
|
|
4
|
+
// Laravel: JSON, the cleanest.
|
|
5
|
+
'if [ -f artisan ]; then echo "== laravel"; php artisan route:list --json 2>/dev/null; exit 0; fi',
|
|
6
|
+
// Rails: the text table.
|
|
7
|
+
'if [ -f bin/rails ]; then echo "== rails"; bin/rails routes 2>/dev/null; exit 0; fi',
|
|
8
|
+
// Django with django-extensions: show_urls.
|
|
9
|
+
'if [ -f manage.py ]; then echo "== django"; (python manage.py show_urls 2>/dev/null || python3 manage.py show_urls 2>/dev/null); exit 0; fi',
|
|
10
|
+
"true",
|
|
11
|
+
].join("; ");
|
|
12
|
+
}
|
|
13
|
+
/** The GET paths without parameters from a framework's listing; null when nothing was printed. */
|
|
14
|
+
export function parseRoutes(output) {
|
|
15
|
+
const m = /^== (\w+)\n?([\s\S]*)$/.exec(output.trim());
|
|
16
|
+
if (!m)
|
|
17
|
+
return null;
|
|
18
|
+
const [, source, body] = m;
|
|
19
|
+
const routes = new Set();
|
|
20
|
+
if (source === "laravel") {
|
|
21
|
+
try {
|
|
22
|
+
const list = JSON.parse(body);
|
|
23
|
+
for (const r of list)
|
|
24
|
+
if (r.uri && /(^|\|)GET(\||$)/.test(r.method ?? "") && !r.uri.includes("{"))
|
|
25
|
+
routes.add(`/${r.uri.replace(/^\/+/, "")}`);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return { source, routes: [] };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (source === "rails") {
|
|
32
|
+
for (const line of body.split("\n")) {
|
|
33
|
+
const cols = line.trim().split(/\s+/);
|
|
34
|
+
// "prefix GET /path(.:format) controller#action" or "GET /path(.:format) controller#action"
|
|
35
|
+
const i = cols.indexOf("GET");
|
|
36
|
+
const uri = i >= 0 ? cols[i + 1]?.replace(/\(\.:format\)$/, "") : undefined;
|
|
37
|
+
if (uri?.startsWith("/") && !uri.includes(":") && !uri.includes("*"))
|
|
38
|
+
routes.add(uri || "/");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (source === "django") {
|
|
42
|
+
for (const line of body.split("\n")) {
|
|
43
|
+
const uri = line.trim().split(/\s+/)[0];
|
|
44
|
+
if (uri?.startsWith("/") && !uri.includes("<") && !uri.includes("^"))
|
|
45
|
+
routes.add(uri);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!body.trim())
|
|
49
|
+
return { source, routes: [] };
|
|
50
|
+
return {
|
|
51
|
+
source,
|
|
52
|
+
routes: [...routes].filter((r) => !/\.(js|css|png|ico)$/.test(r)).slice(0, 200),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Lists gRPC services through reflection when grpcurl is in the app container. */
|
|
56
|
+
export function grpcScript(port) {
|
|
57
|
+
return `command -v grpcurl >/dev/null 2>&1 && grpcurl -plaintext localhost:${port} list 2>&1`;
|
|
58
|
+
}
|
|
59
|
+
export function parseGrpc(output) {
|
|
60
|
+
return output
|
|
61
|
+
.split("\n")
|
|
62
|
+
.map((l) => l.trim())
|
|
63
|
+
.filter((l) => l && !l.startsWith("grpc.reflection") && !/^(Failed|Error)/i.test(l));
|
|
64
|
+
}
|
|
65
|
+
/** The probes that need a command in the app, as one function for the API smoke to call. */
|
|
66
|
+
export async function routesFallback(exec, appService, port) {
|
|
67
|
+
if (!appService)
|
|
68
|
+
return null;
|
|
69
|
+
const r = await exec(appService, routesScript()).catch(() => null);
|
|
70
|
+
if (r && r.exitCode === 0) {
|
|
71
|
+
const parsed = parseRoutes(r.output);
|
|
72
|
+
if (parsed)
|
|
73
|
+
return { kind: "routes", ...parsed };
|
|
74
|
+
}
|
|
75
|
+
if (port) {
|
|
76
|
+
const g = await exec(appService, grpcScript(port)).catch(() => null);
|
|
77
|
+
if (g && g.exitCode === 0) {
|
|
78
|
+
const services = parseGrpc(g.output);
|
|
79
|
+
if (services.length)
|
|
80
|
+
return { kind: "grpc", services };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAYA,kGAAkG;AAClG,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL,+BAA+B;QAC/B,kGAAkG;QAClG,yBAAyB;QACzB,qFAAqF;QACrF,4CAA4C;QAC5C,6IAA6I;QAC7I,MAAM;KACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAwC,CAAC;IAClE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAwC,CAAC;YACrE,KAAK,MAAM,CAAC,IAAI,IAAI;gBAClB,IAAI,CAAC,CAAC,GAAG,IAAI,iBAAiB,CAA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KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnE,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,MAAM;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;IACnD,CAAC;IACD,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACrC,IAAI,QAAQ,CAAC,MAAM;gBAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Recipe } from "@forkstage/recipe";
|
|
2
|
+
import type { Outcome } from "./index.js";
|
|
3
|
+
export interface ChangeFiles {
|
|
4
|
+
changed: string[];
|
|
5
|
+
deleted: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface Scope extends Outcome {
|
|
8
|
+
services: string[];
|
|
9
|
+
source: number;
|
|
10
|
+
tests: number;
|
|
11
|
+
migrations: number;
|
|
12
|
+
recipe: boolean;
|
|
13
|
+
docs: number;
|
|
14
|
+
}
|
|
15
|
+
/** The service whose build context or source folder holds the path; the longest match wins. */
|
|
16
|
+
export declare function serviceFor(path: string, recipe: Recipe): string | null;
|
|
17
|
+
export declare function changeScope(files: ChangeFiles, recipe: Recipe): Scope;
|
package/dist/scope.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const TEST_FILE = /(^|\/)(tests?|__tests__|spec|specs|e2e|cypress)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.go$|(^|\/)test_[^/]*\.py$|_test\.py$|Tests?\.java$|Spec\.(scala|groovy|kt)$|_spec\.rb$|Test\.php$|_test\.rs$/;
|
|
2
|
+
const MIGRATION_FILE = /(^|\/)(migrations?|db\/migrate|alembic\/versions|prisma\/migrations|db\/changelog|db\/migration|supabase\/migrations)\//;
|
|
3
|
+
const DOC_FILE = /\.(md|mdx|rst|txt|adoc)$|(^|\/)(docs?|LICENSE|CHANGELOG)(\/|$)/i;
|
|
4
|
+
/** The service whose build context or source folder holds the path; the longest match wins. */
|
|
5
|
+
export function serviceFor(path, recipe) {
|
|
6
|
+
let best = null;
|
|
7
|
+
for (const [name, s] of Object.entries(recipe.services)) {
|
|
8
|
+
// Only services the repository builds or mounts own files; an image has no source here.
|
|
9
|
+
if (!s.build && !s.source)
|
|
10
|
+
continue;
|
|
11
|
+
const dir = (s.build ?? s.source ?? "").replace(/^\.\/?/, "").replace(/\/+$/, "");
|
|
12
|
+
const inside = dir === "" || path === dir || path.startsWith(`${dir}/`);
|
|
13
|
+
if (!inside)
|
|
14
|
+
continue;
|
|
15
|
+
if (!best || dir.length > best.len)
|
|
16
|
+
best = { name, len: dir.length };
|
|
17
|
+
}
|
|
18
|
+
return best?.name ?? null;
|
|
19
|
+
}
|
|
20
|
+
export function changeScope(files, recipe) {
|
|
21
|
+
const all = [...files.changed, ...files.deleted];
|
|
22
|
+
const services = new Set();
|
|
23
|
+
let source = 0;
|
|
24
|
+
let tests = 0;
|
|
25
|
+
let migrations = 0;
|
|
26
|
+
let docs = 0;
|
|
27
|
+
let recipeChanged = false;
|
|
28
|
+
for (const p of all) {
|
|
29
|
+
const svc = serviceFor(p, recipe);
|
|
30
|
+
if (svc)
|
|
31
|
+
services.add(svc);
|
|
32
|
+
if (p === "forkstage.yaml" || p.endsWith("/forkstage.yaml")) {
|
|
33
|
+
recipeChanged = true;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (TEST_FILE.test(p))
|
|
37
|
+
tests += 1;
|
|
38
|
+
else if (MIGRATION_FILE.test(p))
|
|
39
|
+
migrations += 1;
|
|
40
|
+
else if (DOC_FILE.test(p))
|
|
41
|
+
docs += 1;
|
|
42
|
+
else
|
|
43
|
+
source += 1;
|
|
44
|
+
}
|
|
45
|
+
const parts = [];
|
|
46
|
+
if (source)
|
|
47
|
+
parts.push(`${source} source`);
|
|
48
|
+
if (tests)
|
|
49
|
+
parts.push(`${tests} test`);
|
|
50
|
+
if (migrations)
|
|
51
|
+
parts.push(`${migrations} migration`);
|
|
52
|
+
if (docs)
|
|
53
|
+
parts.push(`${docs} docs`);
|
|
54
|
+
if (recipeChanged)
|
|
55
|
+
parts.push("the recipe");
|
|
56
|
+
const where = services.size ? ` in ${[...services].join(", ")}` : "";
|
|
57
|
+
const base = {
|
|
58
|
+
services: [...services],
|
|
59
|
+
source,
|
|
60
|
+
tests,
|
|
61
|
+
migrations,
|
|
62
|
+
recipe: recipeChanged,
|
|
63
|
+
docs,
|
|
64
|
+
ms: 0,
|
|
65
|
+
};
|
|
66
|
+
if (!all.length)
|
|
67
|
+
return { ...base, status: "passed", detail: "no files differ from the snapshot's commit" };
|
|
68
|
+
const unproven = source > 0 && tests === 0 && !recipeChanged;
|
|
69
|
+
return {
|
|
70
|
+
...base,
|
|
71
|
+
status: unproven ? "warn" : "passed",
|
|
72
|
+
detail: `${all.length} file${all.length === 1 ? "" : "s"}${where}: ${parts.join(", ")}${unproven ? "; no test or check came with the source change" : ""}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAqBA,MAAM,SAAS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AC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,MAAM,IAAI,GAAG;QACX,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC;QACvB,MAAM;QACN,KAAK;QACL,UAAU;QACV,MAAM,EAAE,aAAa;QACrB,IAAI;QACJ,EAAE,EAAE,CAAC;KACN,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,MAAM;QACb,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,4CAA4C,EAAE,CAAC;IAC7F,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC;IAC7D,OAAO;QACL,GAAG,IAAI;QACP,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;QACpC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAC,EAAE,EAAE;KAC3J,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forkstage/verify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The verification probes Forkstage runs against a fork: API smoke, change checks, captured mail, log scan. Portable; the CLI and the control plane share them.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"@forkstage/
|
|
19
|
+
"zod": "^4.3.6",
|
|
20
|
+
"@forkstage/proof": "^0.5.0",
|
|
21
|
+
"@forkstage/recipe": "^0.8.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/node": "^26.6.4",
|