@bli-cockpit/telemetry-core 0.1.48 → 0.1.50
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/evidence-upload.d.ts +22 -0
- package/dist/evidence-upload.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/memory-daemon-endpoint.d.ts +50 -0
- package/dist/memory-daemon-endpoint.js +50 -0
- package/dist/run-verdict.d.ts +40 -0
- package/dist/run-verdict.js +34 -0
- package/package.json +1 -1
|
@@ -495,6 +495,20 @@ export declare const CodexSessionUploadStateSchema: z.ZodEnum<{
|
|
|
495
495
|
not_uploaded: "not_uploaded";
|
|
496
496
|
}>;
|
|
497
497
|
export type CodexSessionUploadState = z.infer<typeof CodexSessionUploadStateSchema>;
|
|
498
|
+
/**
|
|
499
|
+
* BLI-10734 (Edward, 2026-09-17: "roots are labels, not gates"). Whether this
|
|
500
|
+
* session's working directory fell inside an operator-approved collection
|
|
501
|
+
* root. Both scopes upload; this is a label the collector already computed
|
|
502
|
+
* (the same `OUTSIDE_APPROVED_ROOT_REASONS` check `session-sync-health.ts` and
|
|
503
|
+
* `session-sync-counters.ts` already trust), sent explicitly so the server
|
|
504
|
+
* never has to re-derive it from `attribution_reason` string matching.
|
|
505
|
+
* Optional because an already-published CLI sends none.
|
|
506
|
+
*/
|
|
507
|
+
export declare const RootScopeSchema: z.ZodEnum<{
|
|
508
|
+
inside: "inside";
|
|
509
|
+
outside: "outside";
|
|
510
|
+
}>;
|
|
511
|
+
export type RootScope = z.infer<typeof RootScopeSchema>;
|
|
498
512
|
/**
|
|
499
513
|
* The agent that produced a session transcript. `codex_session_id` keeps its
|
|
500
514
|
* historical name across sources; `source` disambiguates. Defaulting to
|
|
@@ -566,6 +580,10 @@ export declare const CodexSessionAttributionSchema: z.ZodObject<{
|
|
|
566
580
|
worktree_fingerprint: z.ZodOptional<z.ZodString>;
|
|
567
581
|
repo_label: z.ZodOptional<z.ZodString>;
|
|
568
582
|
branch: z.ZodOptional<z.ZodString>;
|
|
583
|
+
root_scope: z.ZodOptional<z.ZodEnum<{
|
|
584
|
+
inside: "inside";
|
|
585
|
+
outside: "outside";
|
|
586
|
+
}>>;
|
|
569
587
|
cwd_basename: z.ZodOptional<z.ZodString>;
|
|
570
588
|
cwd_hash: z.ZodOptional<z.ZodString>;
|
|
571
589
|
raw_evidence_pointer_id: z.ZodOptional<z.ZodString>;
|
|
@@ -670,6 +688,10 @@ export declare const CodexSessionAttributionReportRequestSchema: z.ZodObject<{
|
|
|
670
688
|
worktree_fingerprint: z.ZodOptional<z.ZodString>;
|
|
671
689
|
repo_label: z.ZodOptional<z.ZodString>;
|
|
672
690
|
branch: z.ZodOptional<z.ZodString>;
|
|
691
|
+
root_scope: z.ZodOptional<z.ZodEnum<{
|
|
692
|
+
inside: "inside";
|
|
693
|
+
outside: "outside";
|
|
694
|
+
}>>;
|
|
673
695
|
cwd_basename: z.ZodOptional<z.ZodString>;
|
|
674
696
|
cwd_hash: z.ZodOptional<z.ZodString>;
|
|
675
697
|
raw_evidence_pointer_id: z.ZodOptional<z.ZodString>;
|
package/dist/evidence-upload.js
CHANGED
|
@@ -263,6 +263,16 @@ export const CodexSessionUploadStateSchema = z.enum([
|
|
|
263
263
|
"upload_failed",
|
|
264
264
|
"not_uploaded",
|
|
265
265
|
]);
|
|
266
|
+
/**
|
|
267
|
+
* BLI-10734 (Edward, 2026-09-17: "roots are labels, not gates"). Whether this
|
|
268
|
+
* session's working directory fell inside an operator-approved collection
|
|
269
|
+
* root. Both scopes upload; this is a label the collector already computed
|
|
270
|
+
* (the same `OUTSIDE_APPROVED_ROOT_REASONS` check `session-sync-health.ts` and
|
|
271
|
+
* `session-sync-counters.ts` already trust), sent explicitly so the server
|
|
272
|
+
* never has to re-derive it from `attribution_reason` string matching.
|
|
273
|
+
* Optional because an already-published CLI sends none.
|
|
274
|
+
*/
|
|
275
|
+
export const RootScopeSchema = z.enum(["inside", "outside"]);
|
|
266
276
|
/**
|
|
267
277
|
* The agent that produced a session transcript. `codex_session_id` keeps its
|
|
268
278
|
* historical name across sources; `source` disambiguates. Defaulting to
|
|
@@ -301,6 +311,7 @@ export const CodexSessionAttributionSchema = z
|
|
|
301
311
|
worktree_fingerprint: SafeLabelSchema.optional(),
|
|
302
312
|
repo_label: BasenameSchema.optional(),
|
|
303
313
|
branch: z.string().trim().min(1).max(200).optional(),
|
|
314
|
+
root_scope: RootScopeSchema.optional(),
|
|
304
315
|
cwd_basename: BasenameSchema.optional(),
|
|
305
316
|
cwd_hash: z
|
|
306
317
|
.string()
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./outbound-guard.js";
|
|
|
18
18
|
export * from "./paths.js";
|
|
19
19
|
export * from "./privacy.js";
|
|
20
20
|
export * from "./risk-flags.js";
|
|
21
|
+
export * from "./run-verdict.js";
|
|
21
22
|
export * from "./secret-guards.js";
|
|
22
23
|
export * from "./session-facts.js";
|
|
23
24
|
export * from "./source-adapter.js";
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./outbound-guard.js";
|
|
|
18
18
|
export * from "./paths.js";
|
|
19
19
|
export * from "./privacy.js";
|
|
20
20
|
export * from "./risk-flags.js";
|
|
21
|
+
export * from "./run-verdict.js";
|
|
21
22
|
export * from "./secret-guards.js";
|
|
22
23
|
export * from "./session-facts.js";
|
|
23
24
|
export * from "./source-adapter.js";
|
|
@@ -55,6 +55,56 @@ export declare const MEMORY_DAEMON_CONNECT_TIMEOUT_MS = 50;
|
|
|
55
55
|
export declare const MEMORY_DAEMON_SPAWN_INTERVAL_MS = 3600000;
|
|
56
56
|
/** The daemon exits after this long with no request. Two hours. */
|
|
57
57
|
export declare const MEMORY_DAEMON_IDLE_EXIT_MS = 7200000;
|
|
58
|
+
/**
|
|
59
|
+
* How long the daemon's OUTBOUND connection to Tower is allowed to sit idle
|
|
60
|
+
* before this process's OWN dispatcher considers reusing it stale (BLI-10741).
|
|
61
|
+
*
|
|
62
|
+
* The daemon existing was never the whole promise — BLI-3884's docstring
|
|
63
|
+
* calls a warm connection out by name, and structurally it never landed:
|
|
64
|
+
* Node's BUILT-IN global `fetch` does not read the external `undici`
|
|
65
|
+
* package's `setGlobalDispatcher` at all. Verified live against this build
|
|
66
|
+
* (`node@26.8.1`, `undici@6.28.1` in `node_modules`): installing a custom
|
|
67
|
+
* `Agent` as the global dispatcher and then calling the ordinary global
|
|
68
|
+
* `fetch()` left three real `/api/memory/search` calls, spaced 6 s apart,
|
|
69
|
+
* exactly as slow as an unmodified run (569 / 523 / 546 ms — cold every
|
|
70
|
+
* time). So whatever pooling the daemon's `fetch()` calls were doing, this
|
|
71
|
+
* package had NO way to see it, tune it, or even confirm it was happening —
|
|
72
|
+
* `warm-fetch.ts` exists to give the daemon a connection it actually
|
|
73
|
+
* controls, over `undici`'s own `fetch` export with an explicit `dispatcher`,
|
|
74
|
+
* which a local test proves reuses one socket across an idle gap
|
|
75
|
+
* (`warm-fetch.test.ts`).
|
|
76
|
+
*
|
|
77
|
+
* The value is sized off two measurements, not guessed. 578 real gaps
|
|
78
|
+
* between one prompt-hook call and the next on Edward's own machine
|
|
79
|
+
* (`~/.local/state/bli-cockpit/memory-hook-samples`, 2026-09-24 to
|
|
80
|
+
* 2026-09-28) put only 9.2% of them under undici's own 4,000 ms default;
|
|
81
|
+
* 120,000 ms (two minutes) covers 76.6% of the same gaps — most of a working
|
|
82
|
+
* session's back-and-forth — while staying inside what ordinary HTTP/1.1
|
|
83
|
+
* reverse proxies keep an idle keep-alive connection open for; past that,
|
|
84
|
+
* the gain per extra second shrinks fast (300,000 ms only reaches 90.3%)
|
|
85
|
+
* against a growing chance the far end has already dropped the socket
|
|
86
|
+
* anyway. `docs/architecture/agent-memory.md` (BLI-10741) carries the
|
|
87
|
+
* end-to-end replay this sizing was checked against: 50 real recent prompt
|
|
88
|
+
* strings from this machine's own transcripts, run through the real search
|
|
89
|
+
* door with the hook's own 2,000 ms request deadline, once with a fresh
|
|
90
|
+
* dispatcher per call (the daemon's old, uncontrolled shape) and once
|
|
91
|
+
* through one shared warm dispatcher (this fix) — timeouts before and after,
|
|
92
|
+
* same measurement.
|
|
93
|
+
*
|
|
94
|
+
* A connection this process believed was warm and was not is never a hang: a
|
|
95
|
+
* write to a socket the far end already closed fails fast or the request
|
|
96
|
+
* simply opens a new one, and either way the hook's own per-request
|
|
97
|
+
* `AbortController` (`HOOK_BUDGETS`) still bounds the wait. Raising this
|
|
98
|
+
* number can only ever save time, never cost more of it than today.
|
|
99
|
+
*/
|
|
100
|
+
export declare const MEMORY_DAEMON_KEEPALIVE_TIMEOUT_MS = 120000;
|
|
101
|
+
/**
|
|
102
|
+
* The absolute cap on one connection's life, warm or not — undici's own
|
|
103
|
+
* `keepAliveMaxTimeout`. Left far above the idle timeout above so the idle
|
|
104
|
+
* rule is always what actually retires a connection; it exists at all so a
|
|
105
|
+
* connection cannot be held open forever by a daemon that never goes idle.
|
|
106
|
+
*/
|
|
107
|
+
export declare const MEMORY_DAEMON_KEEPALIVE_MAX_TIMEOUT_MS = 600000;
|
|
58
108
|
/**
|
|
59
109
|
* How long a unix socket PATH may be, in bytes, before the platform refuses to
|
|
60
110
|
* bind it. `sun_path` is 104 on macOS/BSD and 108 on Linux; 100 is the safe
|
|
@@ -56,6 +56,56 @@ export const MEMORY_DAEMON_CONNECT_TIMEOUT_MS = 50;
|
|
|
56
56
|
export const MEMORY_DAEMON_SPAWN_INTERVAL_MS = 3_600_000;
|
|
57
57
|
/** The daemon exits after this long with no request. Two hours. */
|
|
58
58
|
export const MEMORY_DAEMON_IDLE_EXIT_MS = 7_200_000;
|
|
59
|
+
/**
|
|
60
|
+
* How long the daemon's OUTBOUND connection to Tower is allowed to sit idle
|
|
61
|
+
* before this process's OWN dispatcher considers reusing it stale (BLI-10741).
|
|
62
|
+
*
|
|
63
|
+
* The daemon existing was never the whole promise — BLI-3884's docstring
|
|
64
|
+
* calls a warm connection out by name, and structurally it never landed:
|
|
65
|
+
* Node's BUILT-IN global `fetch` does not read the external `undici`
|
|
66
|
+
* package's `setGlobalDispatcher` at all. Verified live against this build
|
|
67
|
+
* (`node@26.8.1`, `undici@6.28.1` in `node_modules`): installing a custom
|
|
68
|
+
* `Agent` as the global dispatcher and then calling the ordinary global
|
|
69
|
+
* `fetch()` left three real `/api/memory/search` calls, spaced 6 s apart,
|
|
70
|
+
* exactly as slow as an unmodified run (569 / 523 / 546 ms — cold every
|
|
71
|
+
* time). So whatever pooling the daemon's `fetch()` calls were doing, this
|
|
72
|
+
* package had NO way to see it, tune it, or even confirm it was happening —
|
|
73
|
+
* `warm-fetch.ts` exists to give the daemon a connection it actually
|
|
74
|
+
* controls, over `undici`'s own `fetch` export with an explicit `dispatcher`,
|
|
75
|
+
* which a local test proves reuses one socket across an idle gap
|
|
76
|
+
* (`warm-fetch.test.ts`).
|
|
77
|
+
*
|
|
78
|
+
* The value is sized off two measurements, not guessed. 578 real gaps
|
|
79
|
+
* between one prompt-hook call and the next on Edward's own machine
|
|
80
|
+
* (`~/.local/state/bli-cockpit/memory-hook-samples`, 2026-09-24 to
|
|
81
|
+
* 2026-09-28) put only 9.2% of them under undici's own 4,000 ms default;
|
|
82
|
+
* 120,000 ms (two minutes) covers 76.6% of the same gaps — most of a working
|
|
83
|
+
* session's back-and-forth — while staying inside what ordinary HTTP/1.1
|
|
84
|
+
* reverse proxies keep an idle keep-alive connection open for; past that,
|
|
85
|
+
* the gain per extra second shrinks fast (300,000 ms only reaches 90.3%)
|
|
86
|
+
* against a growing chance the far end has already dropped the socket
|
|
87
|
+
* anyway. `docs/architecture/agent-memory.md` (BLI-10741) carries the
|
|
88
|
+
* end-to-end replay this sizing was checked against: 50 real recent prompt
|
|
89
|
+
* strings from this machine's own transcripts, run through the real search
|
|
90
|
+
* door with the hook's own 2,000 ms request deadline, once with a fresh
|
|
91
|
+
* dispatcher per call (the daemon's old, uncontrolled shape) and once
|
|
92
|
+
* through one shared warm dispatcher (this fix) — timeouts before and after,
|
|
93
|
+
* same measurement.
|
|
94
|
+
*
|
|
95
|
+
* A connection this process believed was warm and was not is never a hang: a
|
|
96
|
+
* write to a socket the far end already closed fails fast or the request
|
|
97
|
+
* simply opens a new one, and either way the hook's own per-request
|
|
98
|
+
* `AbortController` (`HOOK_BUDGETS`) still bounds the wait. Raising this
|
|
99
|
+
* number can only ever save time, never cost more of it than today.
|
|
100
|
+
*/
|
|
101
|
+
export const MEMORY_DAEMON_KEEPALIVE_TIMEOUT_MS = 120_000;
|
|
102
|
+
/**
|
|
103
|
+
* The absolute cap on one connection's life, warm or not — undici's own
|
|
104
|
+
* `keepAliveMaxTimeout`. Left far above the idle timeout above so the idle
|
|
105
|
+
* rule is always what actually retires a connection; it exists at all so a
|
|
106
|
+
* connection cannot be held open forever by a daemon that never goes idle.
|
|
107
|
+
*/
|
|
108
|
+
export const MEMORY_DAEMON_KEEPALIVE_MAX_TIMEOUT_MS = 600_000;
|
|
59
109
|
/**
|
|
60
110
|
* How long a unix socket PATH may be, in bytes, before the platform refuses to
|
|
61
111
|
* bind it. `sun_path` is 104 on macOS/BSD and 108 on Linux; 100 is the safe
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BLI-10729: a shared verdict word for "did this cron's firing do real work,
|
|
3
|
+
* or did it say exactly why not" — the gap `careers-grade` fell into
|
|
4
|
+
* (`docs/engineering/railway-crash-rules.md`, "A named limitation this ticket
|
|
5
|
+
* does not close"): it ran with no `git` binary for days, every row's grade
|
|
6
|
+
* attempt recorded as a `stage_reason`, and nothing about that reads as a
|
|
7
|
+
* process failure, because it was not one — the RUN happened, it just did
|
|
8
|
+
* nothing useful on every unit it touched.
|
|
9
|
+
*
|
|
10
|
+
* This is the ONE place that turns "N units attempted, M of them failed" into
|
|
11
|
+
* a closed verdict, so `careers-grade`, `notes-sync`, `slack-sync` and
|
|
12
|
+
* `granola-sync` all print the same word for the same shape of outcome rather
|
|
13
|
+
* than four scripts each inventing their own threshold.
|
|
14
|
+
*/
|
|
15
|
+
export type RunVerdict = "ok" | "nothing_to_do" | "degraded" | "failing";
|
|
16
|
+
export interface RunVerdictInput {
|
|
17
|
+
/** Units this firing actually looked at — rows claimed, channels read, accounts synced. */
|
|
18
|
+
attempted: number;
|
|
19
|
+
/** Of those, how many did NOT come out clean. */
|
|
20
|
+
failed: number;
|
|
21
|
+
/**
|
|
22
|
+
* Said when `attempted` is 0. Never left blank: "no submitted rows to
|
|
23
|
+
* grade" and "the claim read itself failed" are both zero, and only one of
|
|
24
|
+
* them is fine.
|
|
25
|
+
*/
|
|
26
|
+
nothingToDoReason: string;
|
|
27
|
+
}
|
|
28
|
+
export interface RunVerdictResult {
|
|
29
|
+
verdict: RunVerdict;
|
|
30
|
+
/** A closed label when non-`ok`, always with the counts baked in for `degraded`/`failing`. */
|
|
31
|
+
reason: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `ok` — every attempted unit came out clean.
|
|
35
|
+
* `nothing_to_do` — the firing found nothing to attempt, named why.
|
|
36
|
+
* `degraded` — attempted something and SOME of it failed.
|
|
37
|
+
* `failing` — attempted something and ALL of it failed (the BLI-4568 shape:
|
|
38
|
+
* a firing that "ran" 60 times a day and failed every single row).
|
|
39
|
+
*/
|
|
40
|
+
export declare function classifyRunVerdict(input: RunVerdictInput): RunVerdictResult;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BLI-10729: a shared verdict word for "did this cron's firing do real work,
|
|
3
|
+
* or did it say exactly why not" — the gap `careers-grade` fell into
|
|
4
|
+
* (`docs/engineering/railway-crash-rules.md`, "A named limitation this ticket
|
|
5
|
+
* does not close"): it ran with no `git` binary for days, every row's grade
|
|
6
|
+
* attempt recorded as a `stage_reason`, and nothing about that reads as a
|
|
7
|
+
* process failure, because it was not one — the RUN happened, it just did
|
|
8
|
+
* nothing useful on every unit it touched.
|
|
9
|
+
*
|
|
10
|
+
* This is the ONE place that turns "N units attempted, M of them failed" into
|
|
11
|
+
* a closed verdict, so `careers-grade`, `notes-sync`, `slack-sync` and
|
|
12
|
+
* `granola-sync` all print the same word for the same shape of outcome rather
|
|
13
|
+
* than four scripts each inventing their own threshold.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* `ok` — every attempted unit came out clean.
|
|
17
|
+
* `nothing_to_do` — the firing found nothing to attempt, named why.
|
|
18
|
+
* `degraded` — attempted something and SOME of it failed.
|
|
19
|
+
* `failing` — attempted something and ALL of it failed (the BLI-4568 shape:
|
|
20
|
+
* a firing that "ran" 60 times a day and failed every single row).
|
|
21
|
+
*/
|
|
22
|
+
export function classifyRunVerdict(input) {
|
|
23
|
+
const { attempted, failed, nothingToDoReason } = input;
|
|
24
|
+
if (attempted <= 0) {
|
|
25
|
+
return { verdict: "nothing_to_do", reason: nothingToDoReason };
|
|
26
|
+
}
|
|
27
|
+
if (failed <= 0) {
|
|
28
|
+
return { verdict: "ok", reason: "ok" };
|
|
29
|
+
}
|
|
30
|
+
if (failed >= attempted) {
|
|
31
|
+
return { verdict: "failing", reason: `all_failed:${failed}/${attempted}` };
|
|
32
|
+
}
|
|
33
|
+
return { verdict: "degraded", reason: `partial_failures:${failed}/${attempted}` };
|
|
34
|
+
}
|