run402 4.159.3 → 4.161.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/lib/assets.mjs +12 -7
- package/lib/errors.mjs +173 -38
- package/lib/errors.test.mjs +2 -1
- package/package.json +1 -1
- package/sdk/dist/namespaces/errors.d.ts +29 -7
- package/sdk/dist/namespaces/errors.d.ts.map +1 -1
- package/sdk/dist/namespaces/errors.js +56 -9
- package/sdk/dist/namespaces/errors.js.map +1 -1
- package/sdk/dist/namespaces/errors.types.d.ts +65 -12
- package/sdk/dist/namespaces/errors.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/errors.types.js +2 -1
- package/sdk/dist/namespaces/errors.types.js.map +1 -1
- package/sdk/dist/scoped.d.ts +7 -1
- package/sdk/dist/scoped.d.ts.map +1 -1
- package/sdk/dist/scoped.js +12 -0
- package/sdk/dist/scoped.js.map +1 -1
- package/vault-surface.json +1 -1
package/lib/assets.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Usage:
|
|
5
5
|
* run402 assets put <file> [files...] [--project <project_id>] [--key <dest>] [--content-type <mime>] [--private] [--immutable] [--stream]
|
|
6
6
|
* run402 assets get <key> --output <file> [--project <project_id>]
|
|
7
|
-
* run402 assets ls [--project <project_id>] [--prefix <p>] [--limit <n>]
|
|
7
|
+
* run402 assets ls [--project <project_id>] [--prefix <p>] [--limit <n>] [--cursor <c>]
|
|
8
8
|
* run402 assets rm <key> [--project <project_id>]
|
|
9
9
|
* run402 assets sign <key> [keys...] [--project <project_id>] [--ttl <seconds>] [--variant <kind>[,<kind>...]]
|
|
10
10
|
*
|
|
@@ -52,6 +52,7 @@ Options:
|
|
|
52
52
|
printed.
|
|
53
53
|
--prefix <p> Prefix filter (ls only)
|
|
54
54
|
--limit <n> Max results (ls only; default 100, max 1000)
|
|
55
|
+
--cursor <c> ls only: the next_cursor of the previous page, echoed as is.
|
|
55
56
|
--sort <key> v1.50 ls only: key:asc | createdAt:asc | createdAt:desc (default key:asc).
|
|
56
57
|
--filter <k=v> v1.50 ls only: media-picker filter (repeatable). Keys: uploaded_by, tag,
|
|
57
58
|
format, is_image, min_width, max_width, min_height, max_height.
|
|
@@ -132,6 +133,8 @@ Options:
|
|
|
132
133
|
--project <project_id> Project ID (defaults to active project)
|
|
133
134
|
--prefix <p> Only list keys starting with this prefix
|
|
134
135
|
--limit <n> Max results (default 100, max 1000)
|
|
136
|
+
--cursor <c> Next page: pass the previous page's next_cursor unchanged
|
|
137
|
+
(opaque). Repeat while has_more is true.
|
|
135
138
|
--sort <key> v1.50: key:asc (default) | createdAt:asc | createdAt:desc.
|
|
136
139
|
Cursor is sort-pinned — a cursor reused under another sort returns
|
|
137
140
|
the first page with "reset": true.
|
|
@@ -144,6 +147,7 @@ Options:
|
|
|
144
147
|
Examples:
|
|
145
148
|
run402 assets ls --project prj_abc123
|
|
146
149
|
run402 assets ls --project prj_abc123 --prefix images/ --limit 500
|
|
150
|
+
run402 assets ls --project prj_abc123 --prefix images/ --limit 1000 --cursor <next_cursor>
|
|
147
151
|
run402 assets ls --project prj_abc123 --sort createdAt:desc --filter is_image=true --filter min_width=320
|
|
148
152
|
run402 assets ls --project prj_abc123 --filter uploaded_by=agent_abc --filter tag=hero
|
|
149
153
|
`,
|
|
@@ -232,7 +236,7 @@ function parseArgs(rawArgs) {
|
|
|
232
236
|
const valueFlags = [
|
|
233
237
|
"--project", "--key", "--content-type", "--prefix",
|
|
234
238
|
"--limit", "--output", "-o", "--ttl", "--variant",
|
|
235
|
-
"--meta", "--exif-policy", "--sort", "--filter",
|
|
239
|
+
"--meta", "--exif-policy", "--sort", "--filter", "--cursor",
|
|
236
240
|
];
|
|
237
241
|
assertKnownFlags(args, [
|
|
238
242
|
"--project",
|
|
@@ -251,13 +255,14 @@ function parseArgs(rawArgs) {
|
|
|
251
255
|
"--exif-policy",
|
|
252
256
|
"--sort",
|
|
253
257
|
"--filter",
|
|
258
|
+
"--cursor",
|
|
254
259
|
"--help",
|
|
255
260
|
"-h",
|
|
256
261
|
], valueFlags);
|
|
257
262
|
const out = { positional: [], project: null, key: null, private: false, immutable: false,
|
|
258
263
|
stream: false, prefix: null, limit: null,
|
|
259
264
|
output: null, ttl: null, variant: null, contentType: null,
|
|
260
|
-
metadata: null, exifPolicy: null, sort: null, filter: null };
|
|
265
|
+
metadata: null, exifPolicy: null, sort: null, filter: null, cursor: null };
|
|
261
266
|
for (let i = 0; i < args.length; i++) {
|
|
262
267
|
const a = args[i];
|
|
263
268
|
if (a === "--project") out.project = args[++i];
|
|
@@ -281,6 +286,7 @@ function parseArgs(rawArgs) {
|
|
|
281
286
|
}
|
|
282
287
|
else if (a === "--exif-policy") out.exifPolicy = parseExifPolicyFlag(args[++i]);
|
|
283
288
|
// ls --sort and repeatable --filter k=v.
|
|
289
|
+
else if (a === "--cursor") out.cursor = args[++i];
|
|
284
290
|
else if (a === "--sort") out.sort = parseSortFlag(args[++i]);
|
|
285
291
|
else if (a === "--filter") {
|
|
286
292
|
if (out.filter === null) out.filter = {};
|
|
@@ -532,10 +538,9 @@ async function ls(argv) {
|
|
|
532
538
|
const data = await getSdk().assets.ls(resolvedId, {
|
|
533
539
|
prefix: opts.prefix ?? undefined,
|
|
534
540
|
limit: opts.limit ?? undefined,
|
|
535
|
-
//
|
|
536
|
-
//
|
|
537
|
-
|
|
538
|
-
// separate `--cursor` flag here yet.
|
|
541
|
+
// The cursor is opaque and the gateway's: forwarded unchanged, and an
|
|
542
|
+
// unusable one comes back as the first page with `reset: true`.
|
|
543
|
+
...(opts.cursor ? { cursor: opts.cursor } : {}),
|
|
539
544
|
...(opts.sort ? { sort: opts.sort } : {}),
|
|
540
545
|
...(opts.filter ? { filter: opts.filter } : {}),
|
|
541
546
|
});
|
package/lib/errors.mjs
CHANGED
|
@@ -14,10 +14,15 @@
|
|
|
14
14
|
* accepted no-op; stdout shape is never gated on it.
|
|
15
15
|
*
|
|
16
16
|
* The promote gate: `--new-in <release> --fail-on-new` exits 0 when no error
|
|
17
|
-
* identity was first seen under that release
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* identity was first seen under that release and none it had resolved came
|
|
18
|
+
* back, 1 when new or reopened groups appear, and 2 when a verdict could not
|
|
19
|
+
* be produced (outage / auth / gate misuse) — so a script can never mistake an
|
|
20
|
+
* outage for a clean verdict. `--watch` tails the release under real traffic
|
|
21
|
+
* and fails fast the moment a new or reopened group lands.
|
|
22
|
+
*
|
|
23
|
+
* A group's status: `resolve` / `ignore` / `reopen <fingerprint_id>` call the
|
|
24
|
+
* gateway's status actions and print the response; the gateway decides and
|
|
25
|
+
* fences each write. `list --status` filters by it.
|
|
21
26
|
*/
|
|
22
27
|
|
|
23
28
|
import { resolveProjectId } from "./config.mjs";
|
|
@@ -35,6 +40,10 @@ import {
|
|
|
35
40
|
|
|
36
41
|
/** Wire `kind` vocabulary (mirrors the gateway's KINDS set). */
|
|
37
42
|
export const KINDS = ["uncaught", "boot_crash", "invoke_failed", "handled_5xx"];
|
|
43
|
+
/** Wire `status` vocabulary (the gateway validates it; listed for --help and a local refusal). */
|
|
44
|
+
export const STATUSES = ["open", "resolved", "ignored"];
|
|
45
|
+
/** The status actions, each a POST the gateway fences. */
|
|
46
|
+
const STATUS_ACTIONS = ["resolve", "ignore", "reopen"];
|
|
38
47
|
|
|
39
48
|
/** Poll cadence floor for --watch, enforced client-side. */
|
|
40
49
|
export const INTERVAL_FLOOR_MS = 5000;
|
|
@@ -46,6 +55,9 @@ const HELP = `run402 errors — grouped error fingerprints + a promote/revert ve
|
|
|
46
55
|
Usage:
|
|
47
56
|
run402 errors list [--project <project_id>] [filters] [--human]
|
|
48
57
|
run402 errors get <fingerprint_id> [--project <project_id>] [--human]
|
|
58
|
+
run402 errors resolve <fingerprint_id> [--project <project_id>] [--human]
|
|
59
|
+
run402 errors ignore <fingerprint_id> [--project <project_id>] [--human]
|
|
60
|
+
run402 errors reopen <fingerprint_id> [--project <project_id>] [--human]
|
|
49
61
|
run402 errors list --new-in <release_id|active> --fail-on-new [--human]
|
|
50
62
|
run402 errors list --new-in <release_id|active> --watch <dur> [--fail-on-new]
|
|
51
63
|
|
|
@@ -64,7 +76,15 @@ What this is:
|
|
|
64
76
|
history (not lineage) — so it is rollback-safe: after A -> B -> rollback to
|
|
65
77
|
A -> C, C's baseline is A, and identities first seen under B are not
|
|
66
78
|
attributed to C. "--new-in <release>" selects the identities first seen
|
|
67
|
-
under that release
|
|
79
|
+
under that release, and the resolved ones it brought back; "active"
|
|
80
|
+
resolves the project's live release.
|
|
81
|
+
|
|
82
|
+
Every group has a status: open (as first seen), resolved, or ignored. Once
|
|
83
|
+
your fix is live, run "run402 errors resolve <fingerprint_id>"; if the error
|
|
84
|
+
is seen again the group opens again and you are told once more. An ignored
|
|
85
|
+
group keeps counting and announces nothing. The platform never resolves a
|
|
86
|
+
group on its own. Setting a status takes the project's service key or a
|
|
87
|
+
principal with project.deploy; the anon key and a CI session can only read.
|
|
68
88
|
|
|
69
89
|
Filters (each maps 1:1 to a query param):
|
|
70
90
|
--project <project_id> Project to read (defaults to the active project)
|
|
@@ -73,8 +93,9 @@ Filters (each maps 1:1 to a query param):
|
|
|
73
93
|
--function <name> Only this function's fingerprints
|
|
74
94
|
--kind <kind> One of: ${KINDS.join(", ")}
|
|
75
95
|
--fingerprint <fingerprint_id> Only this fingerprint id (exact)
|
|
76
|
-
--
|
|
77
|
-
|
|
96
|
+
--status <status> One of: ${STATUSES.join(", ")} (default: every status)
|
|
97
|
+
--new-in <rel|active> Only identities first seen under this release, or
|
|
98
|
+
reopened under it (a release id, or "active" for live)
|
|
78
99
|
--limit <n> Page size (default 50, max 200)
|
|
79
100
|
--cursor <cursor> Opaque cursor from a prior response's next_cursor.
|
|
80
101
|
Never parse or compare it — pass it back as-is.
|
|
@@ -94,15 +115,18 @@ Output:
|
|
|
94
115
|
Quality tiers (fingerprint_quality):
|
|
95
116
|
frame_names full fidelity — grouped by stable stack frames
|
|
96
117
|
message_only medium — grouped by normalized message
|
|
97
|
-
coarse
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
coarse no error detail, grouped by function, status, method and
|
|
119
|
+
route. coarse_reason says why: no_error_thrown (the function
|
|
120
|
+
answered the status itself), or function_predates_side_channel
|
|
121
|
+
(redeploy it and future occurrences fingerprint at full
|
|
122
|
+
fidelity; the verdict's coverage line counts those functions).
|
|
100
123
|
|
|
101
124
|
Exit codes (the promote gate — only when --fail-on-new is set):
|
|
102
|
-
0 clean — no identity was first seen under the --new-in release
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
125
|
+
0 clean — no identity was first seen under the --new-in release, and no
|
|
126
|
+
resolved group came back under it
|
|
127
|
+
1 new — new or reopened groups appeared (printed with a sample id + a
|
|
128
|
+
runnable logs command for each, so you can act without another
|
|
129
|
+
query). Under --watch this fails FAST the instant one lands.
|
|
106
130
|
2 unknown — a verdict could NOT be produced: network / auth / API failure,
|
|
107
131
|
or gate misuse (--fail-on-new without --new-in). A script must
|
|
108
132
|
never read an outage as a clean verdict, so this is distinct
|
|
@@ -111,9 +135,10 @@ Exit codes (the promote gate — only when --fail-on-new is set):
|
|
|
111
135
|
Auth:
|
|
112
136
|
The addressed project's own service_key when it is cached locally; otherwise
|
|
113
137
|
your wallet / session / grant key, which the gateway authorizes with
|
|
114
|
-
project.read
|
|
115
|
-
|
|
116
|
-
|
|
138
|
+
project.read for the reads and project.deploy for resolve / ignore / reopen.
|
|
139
|
+
An org member or teammate agent needs no project key. A key for project A
|
|
140
|
+
addressing project B's errors gets 403 (never a 404 that leaks existence).
|
|
141
|
+
The reads are never lifecycle-gated; the status actions are.
|
|
117
142
|
|
|
118
143
|
The golden path — gate a promote:
|
|
119
144
|
run402 deploy promote <release_id> --project <project_id>
|
|
@@ -127,6 +152,8 @@ Examples:
|
|
|
127
152
|
run402 errors list --function checkout --kind uncaught
|
|
128
153
|
run402 errors list --since 2026-07-11T00:00:00Z --limit 200
|
|
129
154
|
run402 errors get fp_9b21fa # one fingerprint, all samples
|
|
155
|
+
run402 errors list --status open # what is broken now
|
|
156
|
+
run402 errors resolve fp_9b21fa # after the fix is live
|
|
130
157
|
run402 errors list --new-in active # what's new under the live release
|
|
131
158
|
run402 errors list --new-in rel_01JX --fail-on-new # one-shot gate (CI)
|
|
132
159
|
run402 errors list --new-in rel_01JX --watch 10m --interval 30s --fail-on-new
|
|
@@ -141,15 +168,51 @@ export async function run(sub, args = []) {
|
|
|
141
168
|
switch (sub) {
|
|
142
169
|
case "list": return runErrors("list", rest);
|
|
143
170
|
case "get": return runErrors("get", rest);
|
|
171
|
+
case "resolve":
|
|
172
|
+
case "ignore":
|
|
173
|
+
case "reopen":
|
|
174
|
+
return runStatusAction(sub, rest);
|
|
144
175
|
default:
|
|
145
176
|
failUnknownSubcommand("errors", sub);
|
|
146
177
|
}
|
|
147
178
|
}
|
|
148
179
|
|
|
180
|
+
/** `errors resolve|ignore|reopen <fingerprint_id>`: one SDK call, the API response printed as received. */
|
|
181
|
+
async function runStatusAction(action, args) {
|
|
182
|
+
const a = normalizeArgv(args);
|
|
183
|
+
const valueFlags = ["--project"];
|
|
184
|
+
assertKnownFlags(a, ["--project", "--json", "--human", "--help", "-h"], valueFlags);
|
|
185
|
+
const positionals = positionalArgs(a, valueFlags);
|
|
186
|
+
if (positionals.length !== 1) {
|
|
187
|
+
fail({
|
|
188
|
+
code: "BAD_USAGE",
|
|
189
|
+
message: positionals.length === 0 ? "Missing <fingerprint_id>." : `Unexpected extra argument: ${positionals[1]}`,
|
|
190
|
+
hint: `Usage: run402 errors ${action} <fingerprint_id> [--project <project_id>] [--human]`,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
const human = a.includes("--human");
|
|
194
|
+
if (human && a.includes("--json")) {
|
|
195
|
+
fail({
|
|
196
|
+
code: "BAD_USAGE",
|
|
197
|
+
message: "--human cannot be combined with --json.",
|
|
198
|
+
hint: "JSON is the default; drop --json to keep it, or keep --human alone for the rendered view.",
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const projectId = resolveProjectId(flagValue(a, "--project"));
|
|
202
|
+
let result;
|
|
203
|
+
try {
|
|
204
|
+
result = await getSdk().errors[action](projectId, positionals[0]);
|
|
205
|
+
} catch (err) {
|
|
206
|
+
reportSdkError(err);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
console.log(human ? renderStatusChange(result) : JSON.stringify(result, null, 2));
|
|
210
|
+
}
|
|
211
|
+
|
|
149
212
|
async function runErrors(mode, args) {
|
|
150
213
|
const a = normalizeArgv(args);
|
|
151
214
|
const valueFlags = [
|
|
152
|
-
"--project", "--since", "--until", "--function", "--kind",
|
|
215
|
+
"--project", "--since", "--until", "--function", "--kind", "--status",
|
|
153
216
|
"--fingerprint", "--new-in", "--limit", "--cursor", "--watch", "--interval",
|
|
154
217
|
];
|
|
155
218
|
const boolFlags = ["--json", "--human", "--fail-on-new", "--help", "-h"];
|
|
@@ -192,7 +255,7 @@ async function runErrors(mode, args) {
|
|
|
192
255
|
// ---- Detail view (single positional fingerprint id) ----------------------
|
|
193
256
|
if (fingerprintId) {
|
|
194
257
|
const listOnly = [
|
|
195
|
-
"--since", "--until", "--function", "--kind", "--fingerprint",
|
|
258
|
+
"--since", "--until", "--function", "--kind", "--status", "--fingerprint",
|
|
196
259
|
"--new-in", "--limit", "--cursor", "--watch", "--interval", "--fail-on-new",
|
|
197
260
|
];
|
|
198
261
|
const offending = listOnly.find((f) => a.includes(f));
|
|
@@ -246,6 +309,7 @@ async function runErrors(mode, args) {
|
|
|
246
309
|
const until = flagValue(a, "--until");
|
|
247
310
|
const fn = flagValue(a, "--function");
|
|
248
311
|
const kind = flagValue(a, "--kind");
|
|
312
|
+
const status = flagValue(a, "--status");
|
|
249
313
|
const fingerprint = flagValue(a, "--fingerprint");
|
|
250
314
|
const limit = flagValue(a, "--limit");
|
|
251
315
|
const cursor = flagValue(a, "--cursor");
|
|
@@ -256,6 +320,10 @@ async function runErrors(mode, args) {
|
|
|
256
320
|
assertAllowedValue(kind, KINDS, "--kind");
|
|
257
321
|
opts.kind = kind;
|
|
258
322
|
}
|
|
323
|
+
if (status != null) {
|
|
324
|
+
assertAllowedValue(status, STATUSES, "--status");
|
|
325
|
+
opts.status = status;
|
|
326
|
+
}
|
|
259
327
|
if (fingerprint != null) opts.fingerprint = fingerprint;
|
|
260
328
|
if (newIn != null) opts.newIn = newIn;
|
|
261
329
|
if (limit != null) opts.limit = parseIntegerFlag("--limit", limit, { min: 1, max: 200 });
|
|
@@ -295,7 +363,7 @@ async function runErrors(mode, args) {
|
|
|
295
363
|
|
|
296
364
|
// ---- Watch mode ----------------------------------------------------------
|
|
297
365
|
if (watchConfig != null) {
|
|
298
|
-
await runWatch({ projectId, newIn, ...watchConfig, failOnNew,
|
|
366
|
+
await runWatch({ projectId, newIn, ...watchConfig, failOnNew, human });
|
|
299
367
|
return;
|
|
300
368
|
}
|
|
301
369
|
|
|
@@ -315,8 +383,9 @@ async function runErrors(mode, args) {
|
|
|
315
383
|
|
|
316
384
|
if (failOnNew) {
|
|
317
385
|
const totalNew = Number(page?.verdict?.new_fingerprints ?? 0);
|
|
318
|
-
|
|
319
|
-
|
|
386
|
+
const totalReopened = Number(page?.verdict?.reopened_fingerprints ?? 0);
|
|
387
|
+
if (totalNew > 0 || totalReopened > 0) {
|
|
388
|
+
if (human) console.log(renderFailOnNewList(page?.errors ?? [], newIn, totalNew, totalReopened, page?.verdict?.compared_release_id));
|
|
320
389
|
process.exit(1);
|
|
321
390
|
}
|
|
322
391
|
if (human) console.log(renderCleanGate(page?.verdict, newIn));
|
|
@@ -328,18 +397,19 @@ async function runErrors(mode, args) {
|
|
|
328
397
|
|
|
329
398
|
// ─── Watch driver ────────────────────────────────────────────────────────────
|
|
330
399
|
|
|
331
|
-
async function runWatch({ projectId, newIn, durationMs, intervalMs, failOnNew,
|
|
400
|
+
async function runWatch({ projectId, newIn, durationMs, intervalMs, failOnNew, human }) {
|
|
332
401
|
let lastPage = null;
|
|
333
402
|
let triggeringPage = null;
|
|
334
403
|
|
|
335
404
|
const onPoll = (page, meta) => {
|
|
336
405
|
if (page && typeof page === "object") lastPage = page;
|
|
337
406
|
const newSoFar = Number(page?.verdict?.new_fingerprints ?? 0);
|
|
338
|
-
|
|
407
|
+
const reopenedSoFar = Number(page?.verdict?.reopened_fingerprints ?? 0);
|
|
408
|
+
if (failOnNew && (newSoFar > 0 || reopenedSoFar > 0) && !triggeringPage) triggeringPage = page;
|
|
339
409
|
const poll = meta?.poll ?? "?";
|
|
340
410
|
const elapsed = fmtDuration(meta?.elapsedMs ?? 0);
|
|
341
411
|
// Progress lives on stderr so stdout carries only the final page / render.
|
|
342
|
-
process.stderr.write(`watch · poll ${poll} · ${elapsed} elapsed · ${fmtInt(newSoFar)} new
|
|
412
|
+
process.stderr.write(`watch · poll ${poll} · ${elapsed} elapsed · ${fmtInt(newSoFar)} new, ${fmtInt(reopenedSoFar)} reopened so far\n`);
|
|
343
413
|
};
|
|
344
414
|
|
|
345
415
|
let result;
|
|
@@ -359,14 +429,16 @@ async function runWatch({ projectId, newIn, durationMs, intervalMs, failOnNew, j
|
|
|
359
429
|
|
|
360
430
|
const clean = result?.clean === true;
|
|
361
431
|
const newErrors = Array.isArray(result?.new_errors) ? result.new_errors : [];
|
|
432
|
+
const reopenedErrors = Array.isArray(result?.reopened_errors) ? result.reopened_errors : [];
|
|
362
433
|
const totalNew = Number(result?.verdict?.new_fingerprints ?? newErrors.length);
|
|
434
|
+
const totalReopened = Number(result?.verdict?.reopened_fingerprints ?? reopenedErrors.length);
|
|
363
435
|
|
|
364
436
|
if (!human) {
|
|
365
437
|
// The triggering page if we fired early, else the last poll's page. Fall
|
|
366
438
|
// back to a page-shaped envelope only if no poll ever ran (edge case).
|
|
367
439
|
const page = triggeringPage ?? lastPage ?? {
|
|
368
440
|
verdict: result?.verdict ?? null,
|
|
369
|
-
errors: newErrors,
|
|
441
|
+
errors: [...newErrors, ...reopenedErrors],
|
|
370
442
|
has_more: false,
|
|
371
443
|
};
|
|
372
444
|
console.log(JSON.stringify(page, null, 2));
|
|
@@ -374,7 +446,9 @@ async function runWatch({ projectId, newIn, durationMs, intervalMs, failOnNew, j
|
|
|
374
446
|
|
|
375
447
|
if (failOnNew) {
|
|
376
448
|
if (!clean) {
|
|
377
|
-
if (human)
|
|
449
|
+
if (human) {
|
|
450
|
+
console.log(renderFailOnNewList([...newErrors, ...reopenedErrors], newIn, totalNew, totalReopened, result?.verdict?.compared_release_id));
|
|
451
|
+
}
|
|
378
452
|
process.exit(1);
|
|
379
453
|
}
|
|
380
454
|
if (human) {
|
|
@@ -524,6 +598,14 @@ export function renderVerdict(verdict) {
|
|
|
524
598
|
: `${L("new error identities")}${newVal}`,
|
|
525
599
|
);
|
|
526
600
|
lines.push(`${L("recurring")}${fmtInt(v.recurring_fingerprints ?? 0)}`);
|
|
601
|
+
lines.push(
|
|
602
|
+
v.compared_release_id
|
|
603
|
+
? `${L("reopened")}${fmtInt(v.reopened_fingerprints ?? 0)} ← resolved groups seen again under ${v.compared_release_id}`
|
|
604
|
+
: `${L("reopened")}${fmtInt(v.reopened_fingerprints ?? 0)}`,
|
|
605
|
+
);
|
|
606
|
+
if (v.by_status) {
|
|
607
|
+
lines.push(`${L("by status")}${fmtInt(v.by_status.open ?? 0)} open · ${fmtInt(v.by_status.resolved ?? 0)} resolved · ${fmtInt(v.by_status.ignored ?? 0)} ignored`);
|
|
608
|
+
}
|
|
527
609
|
lines.push(`${L("invocations in window")}${fmtInt(v.invocations_in_window ?? 0)}`);
|
|
528
610
|
|
|
529
611
|
const full = Number(v.coverage?.full_fidelity_functions ?? 0);
|
|
@@ -543,8 +625,36 @@ export function renderVerdict(verdict) {
|
|
|
543
625
|
export function renderListRow(row) {
|
|
544
626
|
const r = row || {};
|
|
545
627
|
const coarse = r.fingerprint_quality === "coarse" ? " [coarse]" : "";
|
|
628
|
+
const status = r.status && r.status !== "open" ? ` [${r.status}]` : "";
|
|
629
|
+
const reopened = r.status === "open" && Number(r.reopen_count ?? 0) > 0 ? " [reopened]" : "";
|
|
546
630
|
const msg = truncate(r.message_template, 100);
|
|
547
|
-
return `${r.fingerprint_id} ${r.kind} ×${fmtInt(r.count)} ${r.error_name} fn:${r.function} "${msg}" · ${relativeTime(r.last_seen)}${coarse}`;
|
|
631
|
+
return `${r.fingerprint_id} ${r.kind} ×${fmtInt(r.count)} ${r.error_name} fn:${r.function} "${msg}" · ${relativeTime(r.last_seen)}${coarse}${status}${reopened}`;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** Why a coarse row has no detail, as the gateway computed it (`coarse_reason`). */
|
|
635
|
+
function coarseExplanation(reason) {
|
|
636
|
+
if (reason === "no_error_thrown") {
|
|
637
|
+
return "The function answered this status itself; nothing was thrown, so there is no error detail. Read a sample's logs for why it answered so.";
|
|
638
|
+
}
|
|
639
|
+
if (reason === "function_predates_side_channel") {
|
|
640
|
+
return "This function predates the error side-channel; redeploying it upgrades future fingerprint fidelity (frame-level grouping).";
|
|
641
|
+
}
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/** A status action's result: the group's status, the release it was resolved in, and how many rows changed. */
|
|
646
|
+
export function renderStatusChange(result) {
|
|
647
|
+
const r = result || {};
|
|
648
|
+
const changed = Number(r.changed ?? 0);
|
|
649
|
+
const parts = [];
|
|
650
|
+
const verb = r.status === "resolved" ? "resolved" : r.status === "ignored" ? "ignored" : "open";
|
|
651
|
+
parts.push(`${r.fingerprint_id} is ${verb} (${fmtInt(changed)} row${changed === 1 ? "" : "s"} changed${changed === 0 ? "; it already was" : ""}).`);
|
|
652
|
+
if (r.status === "resolved") {
|
|
653
|
+
parts.push(` resolved in ${r.resolved_in_release_id ?? "(no live release)"}`);
|
|
654
|
+
parts.push(" It opens again if this error is seen again.");
|
|
655
|
+
}
|
|
656
|
+
if (r.status_changed_at) parts.push(` status changed ${r.status_changed_at}`);
|
|
657
|
+
return parts.join("\n");
|
|
548
658
|
}
|
|
549
659
|
|
|
550
660
|
/** The full human list render: verdict, rows (or the empty note), a drill-down. */
|
|
@@ -592,7 +702,14 @@ export function renderHumanDetail(detail) {
|
|
|
592
702
|
parts.push(` function fn:${d.function}`);
|
|
593
703
|
parts.push(` quality ${d.fingerprint_quality}`);
|
|
594
704
|
if (d.fingerprint_quality === "coarse") {
|
|
595
|
-
|
|
705
|
+
const why = coarseExplanation(d.coarse_reason);
|
|
706
|
+
if (why) parts.push(` ${why}`);
|
|
707
|
+
if (d.route_pattern) parts.push(` route ${d.method ?? ""} ${d.route_pattern}`.trimEnd());
|
|
708
|
+
}
|
|
709
|
+
parts.push(` status ${d.status ?? "open"}${d.status_changed_at ? ` (since ${d.status_changed_at})` : ""}`);
|
|
710
|
+
if (d.resolved_in_release_id) parts.push(` resolved in ${d.resolved_in_release_id}`);
|
|
711
|
+
if (Number(d.reopen_count ?? 0) > 0) {
|
|
712
|
+
parts.push(` reopened ${fmtInt(d.reopen_count)}×, last ${d.reopened_at ?? "?"} (release ${d.reopened_in_release_id ?? "unknown"})`);
|
|
596
713
|
}
|
|
597
714
|
parts.push(` count ${fmtInt(d.count)}`);
|
|
598
715
|
parts.push(` first seen ${d.first_seen} (release ${d.first_seen_release_id ?? "unknown"})`);
|
|
@@ -625,25 +742,43 @@ export function renderHumanDetail(detail) {
|
|
|
625
742
|
return parts.join("\n");
|
|
626
743
|
}
|
|
627
744
|
|
|
628
|
-
/**
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
745
|
+
/**
|
|
746
|
+
* Actionable exit-1 render: each new or reopened group with a sample id + logs
|
|
747
|
+
* command. A row is named reopened when the compared release brought it back
|
|
748
|
+
* (`reopened_in_release_id`), not because it was first seen there.
|
|
749
|
+
*/
|
|
750
|
+
export function renderFailOnNewList(rowsIn, newIn, totalNew, totalReopened = 0, comparedReleaseId = null) {
|
|
751
|
+
const rows = Array.isArray(rowsIn) ? rowsIn : [];
|
|
752
|
+
const compared = comparedReleaseId ?? newIn;
|
|
753
|
+
const isReopened = (row) => row?.reopened_in_release_id === compared && row?.first_seen_release_id !== compared;
|
|
754
|
+
const total = Number.isFinite(Number(totalNew)) ? Number(totalNew) : rows.filter((r) => !isReopened(r)).length;
|
|
755
|
+
const reopened = Number.isFinite(Number(totalReopened)) ? Number(totalReopened) : rows.filter(isReopened).length;
|
|
632
756
|
const parts = [];
|
|
633
|
-
|
|
757
|
+
const counts = [
|
|
758
|
+
...(total > 0 || reopened === 0 ? [`${fmtInt(total)} new error identit${total === 1 ? "y" : "ies"} first seen`] : []),
|
|
759
|
+
...(reopened > 0 ? [`${fmtInt(reopened)} resolved group${reopened === 1 ? "" : "s"} reopened`] : []),
|
|
760
|
+
];
|
|
761
|
+
parts.push(`FAIL — ${counts.join(" and ")} under ${newIn}:`);
|
|
634
762
|
for (const row of rows) {
|
|
635
763
|
const sid = topSampleId(row);
|
|
636
764
|
parts.push("");
|
|
637
|
-
parts.push(` ${row.fingerprint_id} ${row.kind} ×${fmtInt(row.count)} ${row.error_name} fn:${row.function}`);
|
|
765
|
+
parts.push(` ${row.fingerprint_id} ${isReopened(row) ? "REOPENED " : ""}${row.kind} ×${fmtInt(row.count)} ${row.error_name} fn:${row.function}`);
|
|
638
766
|
parts.push(` "${truncate(row.message_template, 100)}"`);
|
|
639
767
|
if (sid) {
|
|
640
768
|
parts.push(` sample ${sid}`);
|
|
641
769
|
parts.push(` ${logsCommand(row.function, sid)}`);
|
|
642
770
|
}
|
|
643
771
|
}
|
|
644
|
-
|
|
772
|
+
for (const row of rows) {
|
|
773
|
+
const resolve = Array.isArray(row?.next_actions) ? row.next_actions.find((x) => x?.type === "resolve_error") : null;
|
|
774
|
+
if (isReopened(row) && resolve?.command) {
|
|
775
|
+
parts.push("");
|
|
776
|
+
parts.push(` After a fix for ${row.fingerprint_id} is live: ${resolve.command}`);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
if (total + reopened > rows.length) {
|
|
645
780
|
parts.push("");
|
|
646
|
-
parts.push(` … and ${fmtInt(total - rows.length)} more not shown (raise --limit or page with --cursor).`);
|
|
781
|
+
parts.push(` … and ${fmtInt(total + reopened - rows.length)} more not shown (raise --limit or page with --cursor).`);
|
|
647
782
|
}
|
|
648
783
|
return parts.join("\n");
|
|
649
784
|
}
|
|
@@ -654,7 +789,7 @@ export function renderCleanGate(verdict, newIn, opts = {}) {
|
|
|
654
789
|
const watched = opts.watched
|
|
655
790
|
? `Watched ${fmtDuration(opts.durationMs)}${opts.polls != null ? ` (${fmtInt(opts.polls)} polls)` : ""} — `
|
|
656
791
|
: "";
|
|
657
|
-
parts.push(`PASS — ${watched}no new error identities first seen under ${newIn}.`);
|
|
792
|
+
parts.push(`PASS — ${watched}no new error identities first seen under ${newIn}, and no resolved group came back.`);
|
|
658
793
|
if (verdict) parts.push(renderVerdict(verdict));
|
|
659
794
|
return parts.join("\n");
|
|
660
795
|
}
|
package/lib/errors.test.mjs
CHANGED
|
@@ -179,6 +179,7 @@ test("renderHumanDetail — both release attributions, coarse hint, per-sample l
|
|
|
179
179
|
const detail = {
|
|
180
180
|
...ROW,
|
|
181
181
|
fingerprint_quality: "coarse",
|
|
182
|
+
coarse_reason: "function_predates_side_channel",
|
|
182
183
|
first_seen: "2026-07-11T00:00:00Z",
|
|
183
184
|
last_seen: "2026-07-12T11:57:00Z",
|
|
184
185
|
first_seen_release_id: "rel_01JW",
|
|
@@ -211,7 +212,7 @@ test("renderFailOnNewList — pluralizes and notes the un-shown remainder", () =
|
|
|
211
212
|
});
|
|
212
213
|
|
|
213
214
|
test("renderCleanGate — PASS line, watched variant carries duration + polls", () => {
|
|
214
|
-
assert.match(renderCleanGate(VERDICT, "rel_01JX"), /^PASS — no new error identities first seen under rel_01JX\./);
|
|
215
|
+
assert.match(renderCleanGate(VERDICT, "rel_01JX"), /^PASS — no new error identities first seen under rel_01JX, and no resolved group came back\./);
|
|
215
216
|
const watched = renderCleanGate(VERDICT, "rel_01JX", { watched: true, durationMs: 600_000, polls: 40 });
|
|
216
217
|
assert.match(watched, /^PASS — Watched 10m \(40 polls\) — no new error identities/);
|
|
217
218
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run402",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.161.0",
|
|
4
4
|
"description": "CLI for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,18 +20,25 @@
|
|
|
20
20
|
* // release. w.new_errors carries the grouped rows + fetch_logs drill-downs.
|
|
21
21
|
* }
|
|
22
22
|
*
|
|
23
|
-
* `clean
|
|
23
|
+
* `clean` is the gateway's counts (no new and no reopened group), never a
|
|
24
24
|
* client recount. Exposed both unscoped (`r.errors.list(projectId, …)`) and
|
|
25
25
|
* project-scoped (`r.project(id).errors.list(…)`), mirroring `r.events`.
|
|
26
26
|
*
|
|
27
|
+
* A group's status: `resolve` once a fix is live, `ignore` to stop counting
|
|
28
|
+
* it as broken, `reopen` to undo either. The gateway decides and fences each
|
|
29
|
+
* write and reopens a resolved group the next time its error is seen; the SDK
|
|
30
|
+
* only calls. Setting a status takes the project's service key or a principal
|
|
31
|
+
* with `project.deploy`.
|
|
32
|
+
*
|
|
27
33
|
* Auth: the addressed project's OWN key when it is cached locally; otherwise
|
|
28
34
|
* the client's principal (SIWX wallet / session / grant key) with
|
|
29
35
|
* `project.read`. A key for a different project gets 403, never a 404 that
|
|
30
36
|
* would confirm existence.
|
|
31
37
|
*/
|
|
32
38
|
import type { Client } from "../kernel.js";
|
|
33
|
-
import type { ErrorsPage, ErrorFingerprintDetail, ListErrorsOptions, WatchErrorsOptions, WatchErrorsResult } from "./errors.types.js";
|
|
39
|
+
import type { ErrorsPage, ErrorFingerprintDetail, ErrorStatusChange, ListErrorsOptions, WatchErrorsOptions, WatchErrorsResult } from "./errors.types.js";
|
|
34
40
|
export declare class Errors {
|
|
41
|
+
#private;
|
|
35
42
|
private readonly client;
|
|
36
43
|
constructor(client: Client);
|
|
37
44
|
/**
|
|
@@ -51,17 +58,32 @@ export declare class Errors {
|
|
|
51
58
|
* authorized project.
|
|
52
59
|
*/
|
|
53
60
|
get(projectId: string, fingerprintId: string): Promise<ErrorFingerprintDetail>;
|
|
61
|
+
/**
|
|
62
|
+
* Mark a group resolved once its fix is live
|
|
63
|
+
* (`POST /projects/v1/:project_id/errors/:fingerprint_id/resolve`). The
|
|
64
|
+
* gateway records the project's live release as `resolved_in_release_id`
|
|
65
|
+
* and reopens the group the next time its error is seen. Resolving a group
|
|
66
|
+
* that is already resolved answers `changed: 0`.
|
|
67
|
+
*/
|
|
68
|
+
resolve(projectId: string, fingerprintId: string): Promise<ErrorStatusChange>;
|
|
69
|
+
/**
|
|
70
|
+
* Mark a group ignored (`POST …/errors/:fingerprint_id/ignore`). An ignored
|
|
71
|
+
* group keeps counting and stays listed, and its recurrence announces nothing.
|
|
72
|
+
*/
|
|
73
|
+
ignore(projectId: string, fingerprintId: string): Promise<ErrorStatusChange>;
|
|
74
|
+
/** Open a resolved or ignored group again (`POST …/errors/:fingerprint_id/reopen`). */
|
|
75
|
+
reopen(projectId: string, fingerprintId: string): Promise<ErrorStatusChange>;
|
|
54
76
|
/**
|
|
55
77
|
* The promote-gate poll loop. Run it right after an apply/promote activates a
|
|
56
78
|
* release to watch that release under real traffic. Polls {@link list} with
|
|
57
79
|
* `{ newIn }` immediately, then every `intervalMs`, and does one final poll
|
|
58
80
|
* when the `durationMs` window elapses. With `failFast` (the default), stops
|
|
59
|
-
* the moment a poll reports
|
|
81
|
+
* the moment a poll reports a new group or a reopened one.
|
|
60
82
|
*
|
|
61
|
-
* The verdict is the gateway's — `clean
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
83
|
+
* The verdict is the gateway's — `clean` is `new_fingerprints === 0` and
|
|
84
|
+
* `reopened_fingerprints === 0`, read straight off the last observed page;
|
|
85
|
+
* nothing is recomputed here. `new_errors` and `reopened_errors` split that
|
|
86
|
+
* page's `errors[]` by the compared release.
|
|
65
87
|
*
|
|
66
88
|
* Fault tolerance so an outage can't masquerade as a verdict: a 4xx (other
|
|
67
89
|
* than 408/429) rethrows immediately — auth/validation won't heal; network
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/namespaces/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/namespaces/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EACV,UAAU,EAEV,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAiF3B,qBAAa,MAAM;;IACL,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAnC,YAA6B,MAAM,EAAE,MAAM,EAAI;IAE/C;;;;;;OAMG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,iBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CAY/E;IAED;;;;;;;OAOG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAenF;IAED;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE5E;IAED;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE3E;IAED,uFAAuF;IACvF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE3E;IAoBD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA8FnF;CACF"}
|