@bli-cockpit/telemetry-core 0.1.58 → 0.1.60
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/log-digest/classify.d.ts +48 -0
- package/dist/log-digest/classify.js +81 -0
- package/dist/log-digest/digest-source.d.ts +101 -0
- package/dist/log-digest/digest-source.js +131 -0
- package/dist/log-digest/digest.d.ts +81 -0
- package/dist/log-digest/digest.js +262 -0
- package/dist/log-digest/index.d.ts +19 -0
- package/dist/log-digest/index.js +19 -0
- package/dist/log-digest/judge.d.ts +33 -0
- package/dist/log-digest/judge.js +198 -0
- package/dist/log-digest/log-projects.d.ts +78 -0
- package/dist/log-digest/log-projects.js +163 -0
- package/dist/log-digest/mask.d.ts +12 -0
- package/dist/log-digest/mask.js +106 -0
- package/dist/log-digest/merge.d.ts +12 -0
- package/dist/log-digest/merge.js +65 -0
- package/dist/log-digest/project-classes.d.ts +16 -0
- package/dist/log-digest/project-classes.js +31 -0
- package/dist/log-digest/render.d.ts +51 -0
- package/dist/log-digest/render.js +214 -0
- package/dist/log-digest/scrub.d.ts +11 -0
- package/dist/log-digest/scrub.js +73 -0
- package/dist/log-digest/sources/collector.d.ts +15 -0
- package/dist/log-digest/sources/collector.js +166 -0
- package/dist/log-digest/sources/process.d.ts +2 -0
- package/dist/log-digest/sources/process.js +78 -0
- package/dist/log-digest/sources/railway.d.ts +6 -0
- package/dist/log-digest/sources/railway.js +156 -0
- package/dist/log-digest/sources/stdin.d.ts +9 -0
- package/dist/log-digest/sources/stdin.js +56 -0
- package/dist/log-digest/sources/types.d.ts +67 -0
- package/dist/log-digest/sources/types.js +13 -0
- package/dist/log-digest/sources/vercel.d.ts +40 -0
- package/dist/log-digest/sources/vercel.js +194 -0
- package/dist/log-digest/stored.d.ts +98 -0
- package/dist/log-digest/stored.js +149 -0
- package/dist/log-digest/tagged.d.ts +37 -0
- package/dist/log-digest/tagged.js +114 -0
- package/dist/log-digest/tower-classes.d.ts +28 -0
- package/dist/log-digest/tower-classes.js +301 -0
- package/dist/log-digest/window.d.ts +21 -0
- package/dist/log-digest/window.js +39 -0
- package/package.json +6 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stored digests (BLI-12855): the server-side half of `cockpit logs`.
|
|
3
|
+
*
|
|
4
|
+
* Plain words: Tower's cron reads each project's platform logs every 15 minutes,
|
|
5
|
+
* digests them (the same masking, counting and classifying as a local
|
|
6
|
+
* `cockpit logs`) and keeps ONLY the digest: one row per template per window,
|
|
7
|
+
* never a raw line. `digestLines` is the write half (lines to rows);
|
|
8
|
+
* `mergeStored` is the read half (many windows of rows back into one capped
|
|
9
|
+
* digest, real bugs first), which is what `cockpit logs <project>` and the MCP
|
|
10
|
+
* `logs_digest` print when no local log is in reach.
|
|
11
|
+
*
|
|
12
|
+
* Pure functions: no I/O, no clock. The cron and the dashboard door own both.
|
|
13
|
+
*/
|
|
14
|
+
import { CLASS_ORDER } from "./classify.js";
|
|
15
|
+
import { Digest } from "./digest.js";
|
|
16
|
+
import { classifyTemplates } from "./digest-source.js";
|
|
17
|
+
import { mergeResults } from "./merge.js";
|
|
18
|
+
import { renderCapped } from "./render.js";
|
|
19
|
+
import { STORED_EXAMPLE_CHARS, STORED_TEMPLATE_CHARS, scrubForStorage, scrubLine, scrubUnit } from "./scrub.js";
|
|
20
|
+
/**
|
|
21
|
+
* The refusals of a LOCAL read that mean "this machine cannot reach the platform": the stored digest is the answer
|
|
22
|
+
* for them, in `cockpit logs` and in the MCP `logs_digest` alike.
|
|
23
|
+
*/
|
|
24
|
+
export const LOCAL_ACCESS_REFUSALS = new Set([
|
|
25
|
+
"vercel_cli_missing", "vercel_not_logged_in", "vercel_scope_denied", "railway_cli_missing", "railway_not_logged_in", "railway_project_unreachable",
|
|
26
|
+
]);
|
|
27
|
+
/** A window keeps at most this many templates; the rest are counted, never silently lost. */
|
|
28
|
+
export const STORED_MAX_TEMPLATES_PER_WINDOW = 200;
|
|
29
|
+
const iso = (epoch) => (epoch ? new Date(epoch * 1000).toISOString() : null);
|
|
30
|
+
/** Digests one window's lines and classifies every template with the project's table. */
|
|
31
|
+
export function digestLines(lines, options) {
|
|
32
|
+
const digest = new Digest({ noise: options.table.noiseUnits, taggedLines: true });
|
|
33
|
+
let rawChars = 0;
|
|
34
|
+
for (const line of lines) {
|
|
35
|
+
rawChars += line.message.length + 1;
|
|
36
|
+
// Storage path only: people are removed from each line BEFORE it is digested, so the template id is stable across
|
|
37
|
+
// borrowers and a cut can never land inside an email. The local `cockpit logs` digest does not do this.
|
|
38
|
+
digest.addLine(scrubUnit(line.unit), scrubLine(line.message), line.ts, { level: line.level });
|
|
39
|
+
}
|
|
40
|
+
const result = digest.result();
|
|
41
|
+
const all = classifyTemplates(result, options.table, options.family);
|
|
42
|
+
const cap = options.maxTemplates ?? STORED_MAX_TEMPLATES_PER_WINDOW;
|
|
43
|
+
return { lines: result.lines, noise: result.noise, rawChars, templates: all.slice(0, cap), dropped: Math.max(0, all.length - cap) };
|
|
44
|
+
}
|
|
45
|
+
/** Template rows ready to store: the redacted example and the masked template, never a raw line. */
|
|
46
|
+
export function toStoredRows(templates, window) {
|
|
47
|
+
return templates.map((template) => ({
|
|
48
|
+
...window,
|
|
49
|
+
tid: template.tid,
|
|
50
|
+
unit: scrubUnit(template.unit),
|
|
51
|
+
class: template.class,
|
|
52
|
+
severity: template.severity,
|
|
53
|
+
// What is stored is a masked line, never a raw one (see scrub.ts).
|
|
54
|
+
template: scrubForStorage(template.template, STORED_TEMPLATE_CHARS),
|
|
55
|
+
example: scrubForStorage(template.example, STORED_EXAMPLE_CHARS),
|
|
56
|
+
count: template.count,
|
|
57
|
+
first_at: iso(template.first),
|
|
58
|
+
last_at: iso(template.last),
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
/** A stored row as it may leave the table. */
|
|
62
|
+
export function scrubRow(row) {
|
|
63
|
+
return {
|
|
64
|
+
...row,
|
|
65
|
+
unit: scrubUnit(row.unit),
|
|
66
|
+
template: scrubForStorage(row.template, STORED_TEMPLATE_CHARS),
|
|
67
|
+
example: scrubForStorage(row.example, STORED_EXAMPLE_CHARS),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** The size of one stored row as JSON: what "bytes stored" counts. */
|
|
71
|
+
export function storedRowBytes(row) {
|
|
72
|
+
return Buffer.byteLength(JSON.stringify(row), "utf8");
|
|
73
|
+
}
|
|
74
|
+
const MAX_REFUSALS_NOTED = 4;
|
|
75
|
+
/** Many windows of stored rows merged by template id into one capped digest (about 2 KB, real bugs first). */
|
|
76
|
+
export function mergeStored(storedRows, windows, options) {
|
|
77
|
+
// Defence in depth: whatever wrote the rows, what leaves the table is scrubbed again (the scrub is idempotent).
|
|
78
|
+
const rows = storedRows.map(scrubRow);
|
|
79
|
+
const newestFirst = [...rows].sort((a, b) => (a.window_end < b.window_end ? 1 : a.window_end > b.window_end ? -1 : 0));
|
|
80
|
+
// The exact verdict of a template id (newest window wins), and a verdict by printed text for the renderer, which only
|
|
81
|
+
// sees unit and template: two ids whose scrubbed text is identical share it, and the WORSE class wins, so a
|
|
82
|
+
// collision can only make a line louder, never hide a bug.
|
|
83
|
+
const verdictOfTid = new Map();
|
|
84
|
+
const verdicts = new Map();
|
|
85
|
+
const sources = new Map();
|
|
86
|
+
for (const row of newestFirst) {
|
|
87
|
+
const key = `${row.unit}\x1f${row.template}`;
|
|
88
|
+
if (!verdictOfTid.has(row.tid))
|
|
89
|
+
verdictOfTid.set(row.tid, { class: row.class, severity: row.severity });
|
|
90
|
+
const known = verdicts.get(key);
|
|
91
|
+
if (!known || (CLASS_ORDER[row.class] ?? 0) < (CLASS_ORDER[known.class] ?? 0))
|
|
92
|
+
verdicts.set(key, { class: row.class, severity: row.severity });
|
|
93
|
+
const names = sources.get(row.tid) ?? new Set();
|
|
94
|
+
names.add(row.source);
|
|
95
|
+
sources.set(row.tid, names);
|
|
96
|
+
}
|
|
97
|
+
const groups = rows.map((row) => ({
|
|
98
|
+
tid: row.tid,
|
|
99
|
+
unit: row.unit,
|
|
100
|
+
event: "stored",
|
|
101
|
+
template: row.template,
|
|
102
|
+
count: row.count,
|
|
103
|
+
first: row.first_at ? Date.parse(row.first_at) / 1000 : null,
|
|
104
|
+
last: row.last_at ? Date.parse(row.last_at) / 1000 : null,
|
|
105
|
+
example: row.example,
|
|
106
|
+
instances: [],
|
|
107
|
+
}));
|
|
108
|
+
const okWindows = windows.filter((window) => window.status === "ok");
|
|
109
|
+
const lines = okWindows.reduce((sum, window) => sum + window.lines_read, 0);
|
|
110
|
+
const noise = okWindows.reduce((sum, window) => sum + window.noise, 0);
|
|
111
|
+
const merged = mergeResults([{ lines, noise, groups, span: [null, null] }]);
|
|
112
|
+
const refusals = [...new Set(windows.filter((window) => window.status !== "ok").map((window) => `${window.source}: ${window.status}`))];
|
|
113
|
+
const notes = [];
|
|
114
|
+
const spans = okWindows.map((window) => [Date.parse(window.window_start), Date.parse(window.window_end)]);
|
|
115
|
+
if (spans.length > 0) {
|
|
116
|
+
const from = new Date(Math.min(...spans.map((span) => span[0]))).toISOString().slice(0, 16);
|
|
117
|
+
const to = new Date(Math.max(...spans.map((span) => span[1]))).toISOString().slice(0, 16);
|
|
118
|
+
const names = new Set(okWindows.map((window) => window.source));
|
|
119
|
+
notes.push(`stored digests: ${okWindows.length} window${okWindows.length === 1 ? "" : "s"} of ${names.size} source${names.size === 1 ? "" : "s"}, ${from}Z to ${to}Z`);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
notes.push("stored digests: no window was read in this span (the cron has not run for this project yet, or every read was refused)");
|
|
123
|
+
}
|
|
124
|
+
if (refusals.length > 0) {
|
|
125
|
+
notes.push(`unread: ${refusals.slice(0, MAX_REFUSALS_NOTED).join("; ")}${refusals.length > MAX_REFUSALS_NOTED ? ` +${refusals.length - MAX_REFUSALS_NOTED}` : ""}`);
|
|
126
|
+
}
|
|
127
|
+
notes.push(...(options.extraNotes ?? []));
|
|
128
|
+
const text = renderCapped(merged, {
|
|
129
|
+
source: options.project,
|
|
130
|
+
window: options.label,
|
|
131
|
+
maxBytes: options.maxBytes,
|
|
132
|
+
notes,
|
|
133
|
+
classify: (unit, template) => {
|
|
134
|
+
const verdict = verdicts.get(`${unit}\x1f${template}`);
|
|
135
|
+
return { class: verdict?.class ?? "unknown", severity: (verdict?.severity ?? "ERROR"), pattern: null, note: "" };
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
const templates = merged.groups
|
|
139
|
+
.map((group) => {
|
|
140
|
+
const verdict = verdictOfTid.get(group.tid);
|
|
141
|
+
return {
|
|
142
|
+
tid: group.tid, unit: group.unit, class: verdict?.class ?? "unknown", severity: verdict?.severity ?? "ERROR", pattern: null,
|
|
143
|
+
count: group.count, first: group.first, last: group.last, template: group.template, example: group.example, instances: [],
|
|
144
|
+
sources: [...(sources.get(group.tid) ?? [])].sort(),
|
|
145
|
+
};
|
|
146
|
+
})
|
|
147
|
+
.sort((a, b) => (CLASS_ORDER[a.class] ?? 0) - (CLASS_ORDER[b.class] ?? 0) || b.count - a.count || (a.tid < b.tid ? -1 : 1));
|
|
148
|
+
return { text, templates, windows: windows.length, windows_ok: okWindows.length, lines, noise, refusals };
|
|
149
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tower's own log shape: `[tag] what happened {"reason":"x","http_status":502}`.
|
|
3
|
+
*
|
|
4
|
+
* `docs/engineering/message-standard.md` makes every deciding branch log a tag,
|
|
5
|
+
* a sentence and one JSON object of metadata. Judging such a line by the words
|
|
6
|
+
* anywhere in it misreads its keys (`"failed":{}` is an empty map, not a
|
|
7
|
+
* failure), so this reads the three parts separately:
|
|
8
|
+
*
|
|
9
|
+
* - the SENTENCE is judged by the trouble words (`looksImportant`);
|
|
10
|
+
* - the FIELDS are judged by their values: an HTTP-like status, a bad state
|
|
11
|
+
* word, a `reason` whose words say failure, a non-empty `error`;
|
|
12
|
+
* - the source's own LEVEL: warn is a line the unit itself declared a WARNING
|
|
13
|
+
* (counted, never escalated). The error level is NOT a verdict here: Tower
|
|
14
|
+
* writes ordinary lines with console.error, so Vercel marks them error.
|
|
15
|
+
*
|
|
16
|
+
* Opt-in (`DigestOptions.taggedLines`): Kaiben's journals are not in this shape,
|
|
17
|
+
* and the Python-pinned tests run with it off.
|
|
18
|
+
*/
|
|
19
|
+
import { type JsonObject } from "./judge.js";
|
|
20
|
+
/** The line with its zero counters removed, so `failed=0` does not read as a failure. */
|
|
21
|
+
export declare function withoutZeroCounters(text: string): string;
|
|
22
|
+
export interface Tagged {
|
|
23
|
+
tag: string;
|
|
24
|
+
/** The sentence between the tag and the metadata. */
|
|
25
|
+
text: string;
|
|
26
|
+
fields: JsonObject | null;
|
|
27
|
+
}
|
|
28
|
+
/** `[tag] sentence {json}` split into its parts, or null when the line does not start with a tag. */
|
|
29
|
+
export declare function parseTagged(message: string): Tagged | null;
|
|
30
|
+
export interface TaggedJudgement {
|
|
31
|
+
important: boolean;
|
|
32
|
+
/** The template when important; the tag (the routine event name) otherwise. */
|
|
33
|
+
template: string;
|
|
34
|
+
declaredWarning: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Whether a tagged line can mean trouble, and the template it groups under. */
|
|
37
|
+
export declare function judgeTagged(parsed: Tagged, level: string | undefined): TaggedJudgement;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tower's own log shape: `[tag] what happened {"reason":"x","http_status":502}`.
|
|
3
|
+
*
|
|
4
|
+
* `docs/engineering/message-standard.md` makes every deciding branch log a tag,
|
|
5
|
+
* a sentence and one JSON object of metadata. Judging such a line by the words
|
|
6
|
+
* anywhere in it misreads its keys (`"failed":{}` is an empty map, not a
|
|
7
|
+
* failure), so this reads the three parts separately:
|
|
8
|
+
*
|
|
9
|
+
* - the SENTENCE is judged by the trouble words (`looksImportant`);
|
|
10
|
+
* - the FIELDS are judged by their values: an HTTP-like status, a bad state
|
|
11
|
+
* word, a `reason` whose words say failure, a non-empty `error`;
|
|
12
|
+
* - the source's own LEVEL: warn is a line the unit itself declared a WARNING
|
|
13
|
+
* (counted, never escalated). The error level is NOT a verdict here: Tower
|
|
14
|
+
* writes ordinary lines with console.error, so Vercel marks them error.
|
|
15
|
+
*
|
|
16
|
+
* Opt-in (`DigestOptions.taggedLines`): Kaiben's journals are not in this shape,
|
|
17
|
+
* and the Python-pinned tests run with it off.
|
|
18
|
+
*/
|
|
19
|
+
import { jsonRecords, looksImportant } from "./judge.js";
|
|
20
|
+
import { mask, TEMPLATE_CHARS, cut } from "./mask.js";
|
|
21
|
+
const TAGGED = /^\[([^\]\n]{1,60})\]\s*([\s\S]*)$/;
|
|
22
|
+
// "exhausted" is bad only with a thing that ran out (retries, a budget); alone it is how a paginated read says it reached the end.
|
|
23
|
+
const RAN_OUT_OF = new Set(["retries", "retry", "attempts", "budget", "quota", "credits", "tokens", "memory", "disk"]);
|
|
24
|
+
const BAD_WORDS = new Set([
|
|
25
|
+
"fail", "failed", "failure", "error", "errors", "exception", "refused", "denied", "blocked", "timeout", "timed",
|
|
26
|
+
"fatal", "crash", "crashed", "killed", "abort", "aborted", "rejected", "unreachable", "invalid",
|
|
27
|
+
"missing", "unreadable", "stalled", "throttled",
|
|
28
|
+
]);
|
|
29
|
+
const BAD_STATE = /^(fail|failed|failure|error|errored|fatal|blocked|refused|timeout|timed_out|crash|crashed|killed|aborted|rejected)$/i;
|
|
30
|
+
const EXPLAIN = [
|
|
31
|
+
"reason", "status", "outcome", "result", "http", "http_status", "code", "step", "what", "error", "error_name",
|
|
32
|
+
"exception", "detail", "server_reason", "sync_reason", "error_code", "error_syscall",
|
|
33
|
+
];
|
|
34
|
+
const WORD = /[A-Za-z]+/g;
|
|
35
|
+
// `failed=0`, `errors: 0`: a counter at zero is a routine summary, not a failure.
|
|
36
|
+
const ZERO_COUNTER = /\b(?:fail(?:ed|ures?)?|errors?)\s*[=:]\s*0\b/gi;
|
|
37
|
+
/** The line with its zero counters removed, so `failed=0` does not read as a failure. */
|
|
38
|
+
export function withoutZeroCounters(text) {
|
|
39
|
+
return text.replace(ZERO_COUNTER, "");
|
|
40
|
+
}
|
|
41
|
+
/** `[tag] sentence {json}` split into its parts, or null when the line does not start with a tag. */
|
|
42
|
+
export function parseTagged(message) {
|
|
43
|
+
const head = TAGGED.exec(message);
|
|
44
|
+
if (!head)
|
|
45
|
+
return null;
|
|
46
|
+
const rest = head[2];
|
|
47
|
+
let text = rest;
|
|
48
|
+
let fields = null;
|
|
49
|
+
for (let at = rest.indexOf("{"); at >= 0; at = rest.indexOf("{", at + 1)) {
|
|
50
|
+
if (at > 0 && rest[at - 1] !== " ")
|
|
51
|
+
continue;
|
|
52
|
+
const records = jsonRecords(rest.slice(at).trim());
|
|
53
|
+
if (records && records.length === 1) {
|
|
54
|
+
text = rest.slice(0, at).trim();
|
|
55
|
+
fields = records[0];
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { tag: head[1], text, fields };
|
|
60
|
+
}
|
|
61
|
+
function fieldsSayTrouble(fields) {
|
|
62
|
+
for (const key of ["http", "http_status", "code", "status"]) {
|
|
63
|
+
const value = fields[key];
|
|
64
|
+
if (typeof value === "number" && Number.isInteger(value) && (value === 403 || value === 429 || (value >= 500 && value <= 599)))
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
for (const key of ["status", "outcome", "result", "state", "verdict", "sync_status"]) {
|
|
68
|
+
const value = fields[key];
|
|
69
|
+
if (typeof value === "string" && BAD_STATE.test(value))
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
const reason = fields["reason"];
|
|
73
|
+
if (typeof reason === "string") {
|
|
74
|
+
const words = (reason.match(WORD) ?? []).map((word) => word.toLowerCase());
|
|
75
|
+
if (words.some((word) => BAD_WORDS.has(word)))
|
|
76
|
+
return true;
|
|
77
|
+
if (words.includes("exhausted") && words.some((word) => RAN_OUT_OF.has(word)))
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
for (const key of ["error", "error_name", "error_detail"]) {
|
|
81
|
+
const value = fields[key];
|
|
82
|
+
if (value !== null && value !== undefined && value !== "" && value !== 0 && value !== false)
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
function brief(value) {
|
|
88
|
+
if (typeof value === "number")
|
|
89
|
+
return Number.isInteger(value) && value >= 100 && value <= 599 ? String(value) : Number.isInteger(value) && value >= -9 && value <= 9 ? String(value) : "#";
|
|
90
|
+
if (typeof value === "boolean" || value === null)
|
|
91
|
+
return String(value);
|
|
92
|
+
if (typeof value === "string")
|
|
93
|
+
return mask(value);
|
|
94
|
+
return Array.isArray(value) ? "<list>" : "<dict>";
|
|
95
|
+
}
|
|
96
|
+
/** Whether a tagged line can mean trouble, and the template it groups under. */
|
|
97
|
+
export function judgeTagged(parsed, level) {
|
|
98
|
+
const lowered = (level ?? "").toLowerCase();
|
|
99
|
+
// Not the error level: Tower writes plenty of ordinary lines with console.error, so Vercel's level
|
|
100
|
+
// "error" is not a verdict (measured 2026-10-07: most error-level lines in an hour were routine).
|
|
101
|
+
const warnLevel = lowered === "warn" || lowered === "warning";
|
|
102
|
+
const important = warnLevel || looksImportant(withoutZeroCounters(parsed.text)) || (parsed.fields !== null && fieldsSayTrouble(parsed.fields));
|
|
103
|
+
if (!important)
|
|
104
|
+
return { important: false, template: parsed.tag, declaredWarning: false };
|
|
105
|
+
const parts = [mask(`[${parsed.tag}] ${parsed.text}`)];
|
|
106
|
+
if (parsed.fields) {
|
|
107
|
+
for (const key of EXPLAIN) {
|
|
108
|
+
const value = parsed.fields[key];
|
|
109
|
+
if (value !== undefined && value !== null && value !== "")
|
|
110
|
+
parts.push(`${key}=${brief(value)}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { important: true, template: cut(parts.join(" ").replace(/\s+/g, " ").trim(), TEMPLATE_CHARS), declaredWarning: warnLevel };
|
|
114
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tower's own class table: which masked log templates are bugs, which are
|
|
3
|
+
* hiccups, which are harmless. `docs/runbooks/tower-logs.md` ("Teach it a new
|
|
4
|
+
* pattern") is how to add one.
|
|
5
|
+
*
|
|
6
|
+
* Seeded on 2026-10-07 (BLI-12833) from real windows of every wired source: the
|
|
7
|
+
* dashboard (Vercel, 1 h of every level and 12 h of error/warning/5xx), Railway
|
|
8
|
+
* (every service, 1 d: crons keep only their latest deployment's logs) and this
|
|
9
|
+
* machine's collector logs (3 d, including the rotated archives). Each pattern
|
|
10
|
+
* names the evidence it came from. A template NO pattern matches is `unknown`
|
|
11
|
+
* and alerts: a new kind of problem must reach a person, so this table only ever
|
|
12
|
+
* grows by explaining something, never by silencing.
|
|
13
|
+
*
|
|
14
|
+
* Labels follow what the raw lines showed, not what a name suggests:
|
|
15
|
+
* - benign / dead_source are counted on one line and never alerted;
|
|
16
|
+
* - hiccup / rate_pushback are things the code retries or degrades on its own,
|
|
17
|
+
* each with the line that proves the retry;
|
|
18
|
+
* - a real defect is labelled our_bug / config_drift / capacity explicitly, so
|
|
19
|
+
* it stays an ERROR with a note saying why, instead of sitting in `unknown`.
|
|
20
|
+
* First match wins, so specific patterns sit above generic ones.
|
|
21
|
+
*/
|
|
22
|
+
import { ClassTable, type ClassInfo, type ClassTableData, type TablePattern } from "./classify.js";
|
|
23
|
+
export declare const TOWER_CLASSES: Record<string, ClassInfo>;
|
|
24
|
+
/** Patterns, most specific first. */
|
|
25
|
+
export declare const TOWER_PATTERNS: readonly TablePattern[];
|
|
26
|
+
export declare const TOWER_TABLE: ClassTableData;
|
|
27
|
+
/** The compiled Tower table (built once per process). */
|
|
28
|
+
export declare function towerClassTable(): ClassTable;
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tower's own class table: which masked log templates are bugs, which are
|
|
3
|
+
* hiccups, which are harmless. `docs/runbooks/tower-logs.md` ("Teach it a new
|
|
4
|
+
* pattern") is how to add one.
|
|
5
|
+
*
|
|
6
|
+
* Seeded on 2026-10-07 (BLI-12833) from real windows of every wired source: the
|
|
7
|
+
* dashboard (Vercel, 1 h of every level and 12 h of error/warning/5xx), Railway
|
|
8
|
+
* (every service, 1 d: crons keep only their latest deployment's logs) and this
|
|
9
|
+
* machine's collector logs (3 d, including the rotated archives). Each pattern
|
|
10
|
+
* names the evidence it came from. A template NO pattern matches is `unknown`
|
|
11
|
+
* and alerts: a new kind of problem must reach a person, so this table only ever
|
|
12
|
+
* grows by explaining something, never by silencing.
|
|
13
|
+
*
|
|
14
|
+
* Labels follow what the raw lines showed, not what a name suggests:
|
|
15
|
+
* - benign / dead_source are counted on one line and never alerted;
|
|
16
|
+
* - hiccup / rate_pushback are things the code retries or degrades on its own,
|
|
17
|
+
* each with the line that proves the retry;
|
|
18
|
+
* - a real defect is labelled our_bug / config_drift / capacity explicitly, so
|
|
19
|
+
* it stays an ERROR with a note saying why, instead of sitting in `unknown`.
|
|
20
|
+
* First match wins, so specific patterns sit above generic ones.
|
|
21
|
+
*/
|
|
22
|
+
import { ClassTable } from "./classify.js";
|
|
23
|
+
export const TOWER_CLASSES = {
|
|
24
|
+
our_bug: { severity: "ERROR", about: "our code is wrong: exceptions, schema errors, crashes, a 5xx we caused" },
|
|
25
|
+
unknown: { severity: "ERROR", about: "no pattern matched: a new kind of problem, so it reaches a person" },
|
|
26
|
+
capacity: { severity: "ERROR", about: "memory, disk, CPU or quota exhausted" },
|
|
27
|
+
config_drift: { severity: "ERROR", about: "a key, env var, schedule, PATH or file not as documented" },
|
|
28
|
+
hiccup: { severity: "hiccup", about: "timeouts and 5xx from a dependency: retried or degraded by the code itself, a WARNING only when retries run out" },
|
|
29
|
+
rate_pushback: { severity: "hiccup", about: "429 or a provider slowing us down: lower the rate" },
|
|
30
|
+
dead_source: { severity: "WARNING", about: "the thing asked for is gone or was never shared (404, revoked, repo deleted): count only" },
|
|
31
|
+
benign: { severity: "WARNING", about: "looks like trouble but is known harmless: count only" },
|
|
32
|
+
};
|
|
33
|
+
const raw = String.raw;
|
|
34
|
+
/** Patterns, most specific first. */
|
|
35
|
+
export const TOWER_PATTERNS = [
|
|
36
|
+
// ------------------------------------------------------------------ collector (this machine's sync.log / sync.err.log)
|
|
37
|
+
{
|
|
38
|
+
id: "collector-git-diff-no-index",
|
|
39
|
+
class: "our_bug",
|
|
40
|
+
source: "^collector$",
|
|
41
|
+
match: raw `^\[raw-evidence\] git diff failed `,
|
|
42
|
+
note: "git printed its `diff --no-index` usage, which is what git does when the directory is not a git repository (error_detail: unknown option `cached`, pathspec limiting). The collector should skip such a root the way it skips repo_root_missing. A lead on the cause, the usage text itself is the evidence.",
|
|
43
|
+
basis: "collector logs, 3 d: 1,218 lines, both diff_target values, every tick",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "collector-git-diff-root-missing",
|
|
47
|
+
class: "dead_source",
|
|
48
|
+
source: "^collector$",
|
|
49
|
+
match: raw `^\[raw-evidence\] git diff skipped, repository root is no longer on disk`,
|
|
50
|
+
note: "a repository that was deleted or moved: nothing to diff, the collector says so and moves on",
|
|
51
|
+
basis: "collector logs, 3 d: 26 lines",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "collector-evidence-file-vanished",
|
|
55
|
+
class: "dead_source",
|
|
56
|
+
source: "^collector$",
|
|
57
|
+
match: raw `^\[raw-evidence\] evidence file could not be stat'd reason=file_read_failed .*error_code=ENOENT`,
|
|
58
|
+
note: "a session file that was listed and then deleted before it was read: nothing to collect",
|
|
59
|
+
basis: "collector logs, 3 d: 1 line (error_code ENOENT, syscall stat)",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "collector-redelivery-nothing-plannable",
|
|
63
|
+
class: "our_bug",
|
|
64
|
+
source: "^collector$",
|
|
65
|
+
match: raw `^\[evidence-redelivery\] staged evidence could not be delivered reason=nothing_plannable`,
|
|
66
|
+
note: "staged evidence packs whose manifest is unreadable (unplannable.manifest_unreadable) are terminal and never delivered; the line repeats every tick. Staged bytes that never leave the machine.",
|
|
67
|
+
basis: "collector logs, 3 d: 201 lines, terminal=6 packs, 25 MB",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "collector-stubs-exhausted",
|
|
71
|
+
class: "benign",
|
|
72
|
+
source: "^collector$",
|
|
73
|
+
match: raw `^\[collector stubs\] redaction-crash stubs asked reason=stubs_exhausted`,
|
|
74
|
+
note: "a count line: the stub list was read to its end (exhausted is the pagination word for complete)",
|
|
75
|
+
basis: "collector logs, 3 d: 197 lines, each with pages, stub_count and session_count",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "collector-work-context-missing",
|
|
79
|
+
class: "benign",
|
|
80
|
+
source: "^collector$",
|
|
81
|
+
match: raw `^\[upload-envelope\] work context present but unreadable, reporting it as missing`,
|
|
82
|
+
note: "a repo with no `cockpit start` binding: the envelope goes up with no ticket label, by session-first design (a label, never a gate)",
|
|
83
|
+
basis: "collector logs, 3 d: 24 lines, error_detail `Active work context missing for <repo>`",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "collector-heartbeat-reports-failure",
|
|
87
|
+
class: "benign",
|
|
88
|
+
source: "^collector$",
|
|
89
|
+
match: raw `^\[heartbeat\] checked in reason=heartbeat_recorded http_status=202 sync_reason=(sync_failed|network_failed)`,
|
|
90
|
+
note: "the heartbeat itself succeeded (202); it only carries the last sync's reason. The sync failure shows as its own template.",
|
|
91
|
+
basis: "collector logs, 3 d: 20 lines",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "collector-transport-hiccups",
|
|
95
|
+
class: "hiccup",
|
|
96
|
+
source: "^collector$",
|
|
97
|
+
match: raw `^\[(evidence-upload|session-reports|cockpit-sync|install-receipts)\] .*(before a status came back|spooled for retry|entry kept for retry)`,
|
|
98
|
+
note: "the network dropped a request (TypeError fetch failed); the entry is kept or spooled and retried on the next tick",
|
|
99
|
+
basis: "collector logs, 3 d: 20 lines, every one says retry, spooled or kept",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "collector-commit-409-backoff",
|
|
103
|
+
class: "hiccup",
|
|
104
|
+
source: "^collector$",
|
|
105
|
+
match: raw `^(\[cockpit-sync\] raw evidence delivery failed reason=commit_failed_http_409|\[session-sync\] raw evidence held by delivery backoff)`,
|
|
106
|
+
note: "the server answered 409 to a commit: the pack is held by delivery backoff and tried again",
|
|
107
|
+
basis: "collector logs, 3 d: 9 lines, `held_backoff` names the same 409",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "collector-restage-missing-chunks",
|
|
111
|
+
class: "hiccup",
|
|
112
|
+
source: "^collector$",
|
|
113
|
+
match: raw `^\[evidence-upload\] restaging missing chunks reason=staging_missing_between_passes`,
|
|
114
|
+
note: "the server's staging disagreed between two passes; the client restages the missing chunks (the dashboard logs the other half as evidence-commit upload failed closed)",
|
|
115
|
+
basis: "collector logs 3 d and dashboard 12 h: the same reason on both sides",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "collector-agent-artifacts-pointer-not-ingested",
|
|
119
|
+
class: "hiccup",
|
|
120
|
+
source: "^collector$",
|
|
121
|
+
match: raw `^\[agent-artifacts\] report refused reason=report_failed http_status=404 server_reason=BLI-E004: Artifact raw evidence pointer has not been ingested`,
|
|
122
|
+
note: "the artifact report named a raw-evidence pointer the server had not ingested yet; the dashboard logs it as WARNING and the report is sent again. A count that never falls means the pointer never ingests.",
|
|
123
|
+
basis: "collector logs, 3 d: 49 lines; dashboard 1 h: 5 lines at level WARNING",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "collector-secret-guard-rejected",
|
|
127
|
+
class: "our_bug",
|
|
128
|
+
source: "^collector$",
|
|
129
|
+
match: raw `^\[cockpit-sync\] raw evidence (delivery failed reason=secret_guard_rejected|permanently rejected reason=raw_evidence_permanently_rejected:secret_guard_rejected)`,
|
|
130
|
+
note: "session-first collection says a secret guard masks the match and uploads the rest, never drops a file; a rejection is a finding to trace (which file, which rule), not noise",
|
|
131
|
+
basis: "collector logs, 3 d: 9 lines",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "collector-spawn-cockpit-enoent",
|
|
135
|
+
class: "config_drift",
|
|
136
|
+
source: "^collector$",
|
|
137
|
+
match: raw `^\[process-runner\] spawn failed reason=spawn_failed error_code=ENOENT error_syscall=spawn cockpit`,
|
|
138
|
+
note: "the scheduled tick could not find `cockpit` on its PATH; `cockpit doctor` repairs the scheduler",
|
|
139
|
+
basis: "collector logs, 3 d: 8 lines (error_code ENOENT, syscall `spawn cockpit`)",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: "collector-prune-blocked-by-uncommitted",
|
|
143
|
+
class: "capacity",
|
|
144
|
+
source: "^collector$",
|
|
145
|
+
match: raw `^\[collector prune\] still over the cap and nothing committed is left to take`,
|
|
146
|
+
note: "the staging area is over its cap and everything left is uncommitted, so nothing can be freed",
|
|
147
|
+
basis: "collector logs, 3 d: 1 line",
|
|
148
|
+
},
|
|
149
|
+
// ------------------------------------------------------------------ dashboard (Vercel runtime logs)
|
|
150
|
+
{
|
|
151
|
+
id: "dashboard-http-429-403",
|
|
152
|
+
class: "rate_pushback",
|
|
153
|
+
source: "^dashboard$",
|
|
154
|
+
match: raw `^HTTP (429|403) `,
|
|
155
|
+
note: "a request answered 429 or 403: a caller is being slowed or refused (the 403 may be an auth refusal, read the route)",
|
|
156
|
+
basis: "synthetic line the dashboard source adds for a request that ended 429 or 403",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "dashboard-http-gateway",
|
|
160
|
+
class: "hiccup",
|
|
161
|
+
source: "^dashboard$",
|
|
162
|
+
match: raw `^HTTP (502|503|504) `,
|
|
163
|
+
note: "a gateway or timeout answer: clients retry; a burst on one route is worth a look",
|
|
164
|
+
basis: "synthetic line for a 502, 503 or 504",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: "dashboard-http-500",
|
|
168
|
+
class: "our_bug",
|
|
169
|
+
source: "^dashboard$",
|
|
170
|
+
match: raw `^HTTP 5\d\d `,
|
|
171
|
+
note: "one of our routes answered with a server error",
|
|
172
|
+
basis: "synthetic line for a 5xx other than the gateway three; one HTTP 500 on evidence/upload/chunk in 12 h",
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: "dashboard-ops-reader-timeout",
|
|
176
|
+
class: "hiccup",
|
|
177
|
+
source: "^dashboard$",
|
|
178
|
+
match: raw `^\[ops status\] reader over budget reason=reader_timeout`,
|
|
179
|
+
note: "one ops reader ran past its time budget and the board shows the rest without it (declared WARNING by the code)",
|
|
180
|
+
basis: "dashboard 12 h: 15 lines",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: "dashboard-memory-arm-deadline",
|
|
184
|
+
class: "hiccup",
|
|
185
|
+
match: raw `\barm_deadline_exceeded\b`,
|
|
186
|
+
note: "a BLI Memory arm hit its deadline and the answer was built from the other arms (docs/architecture/agent-memory.md: never fixed by moving a timeout)",
|
|
187
|
+
basis: "dashboard 12 h: 14 lines across eight arms, all declared WARNING",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
id: "dashboard-evidence-staging-missing",
|
|
191
|
+
class: "hiccup",
|
|
192
|
+
source: "^dashboard$",
|
|
193
|
+
match: raw `^\[(evidence-assembly|evidence-commit)\] .*reason=staging_missing_between_passes`,
|
|
194
|
+
note: "the commit failed closed because staging changed between two passes; the collector restages and commits again",
|
|
195
|
+
basis: "dashboard 12 h: 6 lines; the collector logs the restage",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "dashboard-storage-bad-gateway",
|
|
199
|
+
class: "hiccup",
|
|
200
|
+
source: "^dashboard$",
|
|
201
|
+
match: raw `StorageApiError: Bad Gateway`,
|
|
202
|
+
note: "Supabase storage answered 502 on an offload write; the data was kept inline, nothing lost",
|
|
203
|
+
basis: "dashboard 12 h: 1 line `offload write failed, kept inline`",
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: "dashboard-agent-artifacts-pointer-404",
|
|
207
|
+
class: "hiccup",
|
|
208
|
+
source: "^dashboard$",
|
|
209
|
+
match: raw `^\[ambient agent-artifacts\] report refused reason=report_refused status=404`,
|
|
210
|
+
note: "the other half of collector-agent-artifacts-pointer-not-ingested: refused while the pointer is not ingested, sent again",
|
|
211
|
+
basis: "dashboard 1 h: 5 lines at level WARNING",
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: "dashboard-work-ref-refused",
|
|
215
|
+
class: "benign",
|
|
216
|
+
source: "^dashboard$",
|
|
217
|
+
match: raw `^\[work (issues|issue-ref)\] refused reason=issue_not_found_or_unreadable`,
|
|
218
|
+
note: "a person or agent asked for a ticket that does not exist or that their RLS cannot read; the refusal is the design",
|
|
219
|
+
basis: "dashboard 1 h: 2 lines for a made-up ticket id",
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: "dashboard-work-completeness-capped",
|
|
223
|
+
class: "benign",
|
|
224
|
+
source: "^dashboard$",
|
|
225
|
+
match: raw `^\[work issues\] completeness reason=capped`,
|
|
226
|
+
note: "a list read stopped at its cap on purpose and says so (exhausted / capped / failed-partial); only failed-partial is trouble",
|
|
227
|
+
basis: "dashboard 1 h: 1 line at level WARNING",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "dashboard-msg-audit-escape-read",
|
|
231
|
+
class: "benign",
|
|
232
|
+
source: "^dashboard$",
|
|
233
|
+
match: raw `^\[msg audit\] escape read`,
|
|
234
|
+
note: "the audit record of a message read outside the caller's channels; written at WARNING on purpose so it is counted, never an alert",
|
|
235
|
+
basis: "dashboard 12 h: 22 lines",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: "dashboard-mcp-oversized",
|
|
239
|
+
class: "benign",
|
|
240
|
+
source: "^dashboard$",
|
|
241
|
+
match: raw `^\[bli-cockpit-mcp tool\] warn outcome=answered_oversized`,
|
|
242
|
+
note: "an MCP tool answered over its per-half byte budget; measured by scripts/smoke.ts, not a failure",
|
|
243
|
+
basis: "dashboard 1 h: 1 line",
|
|
244
|
+
},
|
|
245
|
+
// ------------------------------------------------------------------ railway cron services
|
|
246
|
+
{
|
|
247
|
+
id: "railway-cal-sync-token-expired",
|
|
248
|
+
class: "hiccup",
|
|
249
|
+
source: "^railway$",
|
|
250
|
+
unit: "^cal-sync$",
|
|
251
|
+
match: raw `(sync_token_expired|\[cal sync\] token expired|\[cal-sync\] stage # attempt # failed \(exit \d+\); retrying in #s$|^npm error (path|workspace|location|command|code|Lifecycle script))`,
|
|
252
|
+
note: "Google expired a calendar's sync token; attempt 1 exits 1 (the npm error lines are that exit), the stage retries after 60 s with a full sync and succeeds",
|
|
253
|
+
basis: "railway cal-sync 1 d: 04:01 attempt 1 failed, 04:02 attempt 2 ok, 98 events read in full mode. A stage that fails every attempt is NOT matched here and stays an alert.",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: "railway-docs-import-notion-page-not-shared",
|
|
257
|
+
class: "dead_source",
|
|
258
|
+
source: "^railway$",
|
|
259
|
+
unit: "^docs-import-notion$",
|
|
260
|
+
match: raw `^error: Public API request failed \(# Not Found object_not_found\): Could not find page with ID`,
|
|
261
|
+
note: "the Notion integration cannot see a page that was never shared with it (notion_page_unreadable): the world, nothing to fix here",
|
|
262
|
+
basis: "railway docs-import-notion 1 d: 51 lines, `Make sure the relevant pages and databases are shared with your integration`",
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
id: "railway-docs-import-notion-database-as-page",
|
|
266
|
+
class: "our_bug",
|
|
267
|
+
source: "^railway$",
|
|
268
|
+
unit: "^docs-import-notion$",
|
|
269
|
+
match: raw `^error: Public API request failed \(# Bad Request validation_error\): Provided ID <uuid> is a database, not a page`,
|
|
270
|
+
note: "the importer asked Notion for a PAGE with a DATABASE's id; it should use the retrieve-database API (the importer places each database as a folder)",
|
|
271
|
+
basis: "railway docs-import-notion 1 d: 10 lines, Notion's own message names the fix",
|
|
272
|
+
},
|
|
273
|
+
// ------------------------------------------------------------------ any source
|
|
274
|
+
{
|
|
275
|
+
id: "any-ai-sdk-warning",
|
|
276
|
+
class: "benign",
|
|
277
|
+
match: raw `^AI SDK Warning`,
|
|
278
|
+
note: "the AI SDK notes that a knob (temperature) is ignored by a reasoning model, once per call, plus its own switch-off hint; the provider ignores the knob. Dropping it at the call site (reasoning-policy) is the cleanup.",
|
|
279
|
+
basis: "dashboard 12 h: 46 lines on /api/memory/save; railway ladder 1 d: 6 lines",
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: "any-npm-warn-production",
|
|
283
|
+
class: "benign",
|
|
284
|
+
source: "^railway$",
|
|
285
|
+
match: raw `^npm warn config production Use \`--omit=dev\` instead\.$`,
|
|
286
|
+
note: "every Railway service's npm command still passes the deprecated --production flag: harmless until npm removes it (a config_drift cleanup, not an incident)",
|
|
287
|
+
basis: "railway, every service, once per start: about 20 lines in 1 d",
|
|
288
|
+
},
|
|
289
|
+
];
|
|
290
|
+
export const TOWER_TABLE = {
|
|
291
|
+
version: 1,
|
|
292
|
+
classes: TOWER_CLASSES,
|
|
293
|
+
patterns: TOWER_PATTERNS,
|
|
294
|
+
noiseUnits: [],
|
|
295
|
+
};
|
|
296
|
+
let cached = null;
|
|
297
|
+
/** The compiled Tower table (built once per process). */
|
|
298
|
+
export function towerClassTable() {
|
|
299
|
+
cached ??= new ClassTable(TOWER_TABLE);
|
|
300
|
+
return cached;
|
|
301
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The time window a digest covers: `90s`, `15m`, `2h`, `1d`, a bare number of
|
|
3
|
+
* minutes, or an ISO timestamp. Kaiben's `--since` took the same relative forms.
|
|
4
|
+
*/
|
|
5
|
+
export interface LogWindow {
|
|
6
|
+
/** Epoch seconds: lines older than this are outside the window. */
|
|
7
|
+
fromEpoch: number;
|
|
8
|
+
/** Epoch seconds the window was cut at (now). */
|
|
9
|
+
toEpoch: number;
|
|
10
|
+
/** How the person wrote it, for the header line. */
|
|
11
|
+
label: string;
|
|
12
|
+
}
|
|
13
|
+
/** The only shapes `--since` may take: a count and one unit, or an ISO timestamp. Nothing else reaches a program. */
|
|
14
|
+
export declare const SINCE_ALLOWLIST: RegExp;
|
|
15
|
+
export declare class WindowError extends Error {
|
|
16
|
+
readonly reason = "invalid_since";
|
|
17
|
+
}
|
|
18
|
+
/** Seconds in a relative window like `15m`, or null when the text is not one. */
|
|
19
|
+
export declare function relativeSeconds(text: string): number | null;
|
|
20
|
+
export declare function parseWindow(text: string | undefined, nowMs?: number): LogWindow;
|
|
21
|
+
export declare function isoOf(epochSeconds: number): string;
|