@bli-cockpit/telemetry-core 0.1.99 → 0.1.101
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/collector-heartbeat.d.ts +4 -0
- package/dist/collector-heartbeat.js +4 -2
- package/dist/excluded-folders-contract.d.ts +40 -0
- package/dist/excluded-folders-contract.js +128 -0
- package/dist/founder-standing-contract.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/local-config.d.ts +1 -0
- package/dist/local-config.js +5 -0
- package/dist/log-digest/tower-classes.js +7 -0
- package/dist/memory-capture-contract.d.ts +7 -1
- package/dist/memory-capture-contract.js +3 -1
- package/package.json +1 -1
|
@@ -55,12 +55,14 @@ export declare const CaptureOptOutsSchema: z.ZodObject<{
|
|
|
55
55
|
collect_claude_jsonl_false: "collect_claude_jsonl_false";
|
|
56
56
|
collect_codex_jsonl_false: "collect_codex_jsonl_false";
|
|
57
57
|
raw_evidence_upload_disabled: "raw_evidence_upload_disabled";
|
|
58
|
+
excluded_folder: "excluded_folder";
|
|
58
59
|
}>>;
|
|
59
60
|
ignored: z.ZodArray<z.ZodEnum<{
|
|
60
61
|
memory_capture_off: "memory_capture_off";
|
|
61
62
|
collect_claude_jsonl_false: "collect_claude_jsonl_false";
|
|
62
63
|
collect_codex_jsonl_false: "collect_codex_jsonl_false";
|
|
63
64
|
raw_evidence_upload_disabled: "raw_evidence_upload_disabled";
|
|
65
|
+
excluded_folder: "excluded_folder";
|
|
64
66
|
}>>;
|
|
65
67
|
}, z.core.$strict>;
|
|
66
68
|
export type CaptureOptOuts = z.infer<typeof CaptureOptOutsSchema>;
|
|
@@ -395,12 +397,14 @@ export declare const CollectorHeartbeatSchema: z.ZodObject<{
|
|
|
395
397
|
collect_claude_jsonl_false: "collect_claude_jsonl_false";
|
|
396
398
|
collect_codex_jsonl_false: "collect_codex_jsonl_false";
|
|
397
399
|
raw_evidence_upload_disabled: "raw_evidence_upload_disabled";
|
|
400
|
+
excluded_folder: "excluded_folder";
|
|
398
401
|
}>>;
|
|
399
402
|
ignored: z.ZodArray<z.ZodEnum<{
|
|
400
403
|
memory_capture_off: "memory_capture_off";
|
|
401
404
|
collect_claude_jsonl_false: "collect_claude_jsonl_false";
|
|
402
405
|
collect_codex_jsonl_false: "collect_codex_jsonl_false";
|
|
403
406
|
raw_evidence_upload_disabled: "raw_evidence_upload_disabled";
|
|
407
|
+
excluded_folder: "excluded_folder";
|
|
404
408
|
}>>;
|
|
405
409
|
}, z.core.$strict>>;
|
|
406
410
|
}, z.core.$strict>;
|
|
@@ -58,12 +58,14 @@ const CaptureOptOutLabelSchema = z.enum([
|
|
|
58
58
|
"collect_claude_jsonl_false",
|
|
59
59
|
"collect_codex_jsonl_false",
|
|
60
60
|
"raw_evidence_upload_disabled",
|
|
61
|
+
// BLI-24635: the machine holds excluded folders.
|
|
62
|
+
"excluded_folder",
|
|
61
63
|
]);
|
|
62
64
|
export const CaptureOptOutsSchema = z
|
|
63
65
|
.object({
|
|
64
66
|
standing: z.enum(["founder", "not_founder", "unknown"]),
|
|
65
|
-
obeyed: z.array(CaptureOptOutLabelSchema).max(
|
|
66
|
-
ignored: z.array(CaptureOptOutLabelSchema).max(
|
|
67
|
+
obeyed: z.array(CaptureOptOutLabelSchema).max(5),
|
|
68
|
+
ignored: z.array(CaptureOptOutLabelSchema).max(5),
|
|
67
69
|
})
|
|
68
70
|
.strict();
|
|
69
71
|
/**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BLI-24635: a founder's excluded folders. A session whose working folder is inside one of these never leaves the
|
|
3
|
+
* machine by any path (scheduled sync, backfill, raw evidence, images, the memory hooks).
|
|
4
|
+
*
|
|
5
|
+
* The list lives in the collector config (`excluded_folders`, absolute paths) and survives every config rewrite like
|
|
6
|
+
* the source opt-outs do. Like them it is obeyed ONLY for a founder, on Tower's LIVE answer
|
|
7
|
+
* (`founder-standing-contract.ts`, `optOutVerdict`): ignored and reported for anyone else, held (treated as obeyed)
|
|
8
|
+
* while Tower cannot answer.
|
|
9
|
+
*
|
|
10
|
+
* This file is the ONE matching rule, shared by the collector and the memory hooks so they cannot disagree. It is
|
|
11
|
+
* pure (no filesystem): a caller that can resolve symlinks passes `realpath`, and both the raw and the resolved form
|
|
12
|
+
* of each side are compared.
|
|
13
|
+
*
|
|
14
|
+
* - The platform is read from each path itself: a drive letter, a UNC share or a backslash is Windows. Windows
|
|
15
|
+
* compares case-insensitively with either slash; macOS and Linux compare exactly.
|
|
16
|
+
* - Trailing slashes, `.` and `..` segments and doubled separators are normalised away.
|
|
17
|
+
* - Containment is whole segments: `Personal Projects 2` is NOT inside `Personal Projects`.
|
|
18
|
+
* - A Windows path never matches a POSIX folder, or the reverse.
|
|
19
|
+
*
|
|
20
|
+
* Logs say `excluded_folder` with counts only. Never a path or a folder name.
|
|
21
|
+
*/
|
|
22
|
+
/** The reason label every withhold logs, and the label a heartbeat reports. */
|
|
23
|
+
export declare const EXCLUDED_FOLDER_REASON = "excluded_folder";
|
|
24
|
+
/** A config holds at most this many; more is refused by the schema. */
|
|
25
|
+
export declare const EXCLUDED_FOLDERS_MAX = 100;
|
|
26
|
+
/**
|
|
27
|
+
* The comparison key for one path, or null when it is not absolute (a relative path cannot be placed, so it never
|
|
28
|
+
* matches anything). Windows keys are lower-case with forward slashes (`c:/users/me/personal projects`); POSIX keys
|
|
29
|
+
* keep their case (`/Users/me/Personal Projects`).
|
|
30
|
+
*/
|
|
31
|
+
export declare function excludedFolderKey(value: string | null | undefined): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Is this working folder inside any excluded folder? `realpath` is optional: when given, a symlinked folder and its
|
|
34
|
+
* target both count, on either side. It must not throw (a throw reads as "could not resolve").
|
|
35
|
+
*/
|
|
36
|
+
export declare function pathInsideExcludedFolders(cwd: string | null | undefined, folders: readonly string[], realpath?: (value: string) => string | null): boolean;
|
|
37
|
+
/** The list a config holds, deduplicated by key, or [] when it holds none. Never throws. */
|
|
38
|
+
export declare function configExcludedFolders(config: {
|
|
39
|
+
excluded_folders?: unknown;
|
|
40
|
+
} | Record<string, unknown> | null | undefined): string[];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BLI-24635: a founder's excluded folders. A session whose working folder is inside one of these never leaves the
|
|
3
|
+
* machine by any path (scheduled sync, backfill, raw evidence, images, the memory hooks).
|
|
4
|
+
*
|
|
5
|
+
* The list lives in the collector config (`excluded_folders`, absolute paths) and survives every config rewrite like
|
|
6
|
+
* the source opt-outs do. Like them it is obeyed ONLY for a founder, on Tower's LIVE answer
|
|
7
|
+
* (`founder-standing-contract.ts`, `optOutVerdict`): ignored and reported for anyone else, held (treated as obeyed)
|
|
8
|
+
* while Tower cannot answer.
|
|
9
|
+
*
|
|
10
|
+
* This file is the ONE matching rule, shared by the collector and the memory hooks so they cannot disagree. It is
|
|
11
|
+
* pure (no filesystem): a caller that can resolve symlinks passes `realpath`, and both the raw and the resolved form
|
|
12
|
+
* of each side are compared.
|
|
13
|
+
*
|
|
14
|
+
* - The platform is read from each path itself: a drive letter, a UNC share or a backslash is Windows. Windows
|
|
15
|
+
* compares case-insensitively with either slash; macOS and Linux compare exactly.
|
|
16
|
+
* - Trailing slashes, `.` and `..` segments and doubled separators are normalised away.
|
|
17
|
+
* - Containment is whole segments: `Personal Projects 2` is NOT inside `Personal Projects`.
|
|
18
|
+
* - A Windows path never matches a POSIX folder, or the reverse.
|
|
19
|
+
*
|
|
20
|
+
* Logs say `excluded_folder` with counts only. Never a path or a folder name.
|
|
21
|
+
*/
|
|
22
|
+
/** The reason label every withhold logs, and the label a heartbeat reports. */
|
|
23
|
+
export const EXCLUDED_FOLDER_REASON = "excluded_folder";
|
|
24
|
+
/** A config holds at most this many; more is refused by the schema. */
|
|
25
|
+
export const EXCLUDED_FOLDERS_MAX = 100;
|
|
26
|
+
function looksWindows(value) {
|
|
27
|
+
return /^[A-Za-z]:([\\/]|$)/u.test(value) || value.startsWith("\\\\") || value.startsWith("//?/") || value.includes("\\");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The comparison key for one path, or null when it is not absolute (a relative path cannot be placed, so it never
|
|
31
|
+
* matches anything). Windows keys are lower-case with forward slashes (`c:/users/me/personal projects`); POSIX keys
|
|
32
|
+
* keep their case (`/Users/me/Personal Projects`).
|
|
33
|
+
*/
|
|
34
|
+
export function excludedFolderKey(value) {
|
|
35
|
+
const raw = (value ?? "").trim();
|
|
36
|
+
if (!raw)
|
|
37
|
+
return null;
|
|
38
|
+
const windows = looksWindows(raw);
|
|
39
|
+
let text = windows ? raw.replace(/\\/gu, "/") : raw;
|
|
40
|
+
if (windows) {
|
|
41
|
+
text = text.replace(/^\/\/\?\/(unc\/)?/iu, (_match, unc) => (unc ? "//" : ""));
|
|
42
|
+
}
|
|
43
|
+
let prefix;
|
|
44
|
+
let rest;
|
|
45
|
+
if (windows && /^[A-Za-z]:(\/|$)/u.test(text)) {
|
|
46
|
+
prefix = `${text.slice(0, 2).toLowerCase()}/`;
|
|
47
|
+
rest = text.slice(2);
|
|
48
|
+
}
|
|
49
|
+
else if (windows && text.startsWith("//")) {
|
|
50
|
+
prefix = "//";
|
|
51
|
+
rest = text.slice(2);
|
|
52
|
+
}
|
|
53
|
+
else if (!windows && text.startsWith("/")) {
|
|
54
|
+
prefix = "/";
|
|
55
|
+
rest = text;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const parts = [];
|
|
61
|
+
for (const part of rest.split("/")) {
|
|
62
|
+
if (!part || part === ".")
|
|
63
|
+
continue;
|
|
64
|
+
if (part === "..") {
|
|
65
|
+
parts.pop();
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
parts.push(windows ? part.toLowerCase() : part);
|
|
69
|
+
}
|
|
70
|
+
return prefix + parts.join("/");
|
|
71
|
+
}
|
|
72
|
+
/** True when `candidateKey` is `folderKey` or a path below it, by whole segments. */
|
|
73
|
+
function keyWithin(candidateKey, folderKey) {
|
|
74
|
+
if (candidateKey === folderKey)
|
|
75
|
+
return true;
|
|
76
|
+
const base = folderKey.endsWith("/") ? folderKey : `${folderKey}/`;
|
|
77
|
+
return candidateKey.startsWith(base);
|
|
78
|
+
}
|
|
79
|
+
/** Every key a path is known by: as written, and resolved through symlinks when the caller can. */
|
|
80
|
+
function keysOf(value, realpath) {
|
|
81
|
+
const keys = new Set();
|
|
82
|
+
const direct = excludedFolderKey(value);
|
|
83
|
+
if (direct)
|
|
84
|
+
keys.add(direct);
|
|
85
|
+
if (realpath) {
|
|
86
|
+
let resolved = null;
|
|
87
|
+
try {
|
|
88
|
+
resolved = realpath(value);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
resolved = null;
|
|
92
|
+
}
|
|
93
|
+
const resolvedKey = excludedFolderKey(resolved);
|
|
94
|
+
if (resolvedKey)
|
|
95
|
+
keys.add(resolvedKey);
|
|
96
|
+
}
|
|
97
|
+
return [...keys];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Is this working folder inside any excluded folder? `realpath` is optional: when given, a symlinked folder and its
|
|
101
|
+
* target both count, on either side. It must not throw (a throw reads as "could not resolve").
|
|
102
|
+
*/
|
|
103
|
+
export function pathInsideExcludedFolders(cwd, folders, realpath) {
|
|
104
|
+
if (!cwd || folders.length === 0)
|
|
105
|
+
return false;
|
|
106
|
+
const cwdKeys = keysOf(cwd, realpath);
|
|
107
|
+
if (cwdKeys.length === 0)
|
|
108
|
+
return false;
|
|
109
|
+
return folders.some((folder) => keysOf(folder, realpath).some((folderKey) => cwdKeys.some((key) => keyWithin(key, folderKey))));
|
|
110
|
+
}
|
|
111
|
+
/** The list a config holds, deduplicated by key, or [] when it holds none. Never throws. */
|
|
112
|
+
export function configExcludedFolders(config) {
|
|
113
|
+
const value = config?.excluded_folders;
|
|
114
|
+
if (!Array.isArray(value))
|
|
115
|
+
return [];
|
|
116
|
+
const seen = new Set();
|
|
117
|
+
const folders = [];
|
|
118
|
+
for (const entry of value) {
|
|
119
|
+
if (typeof entry !== "string")
|
|
120
|
+
continue;
|
|
121
|
+
const key = excludedFolderKey(entry);
|
|
122
|
+
if (!key || seen.has(key))
|
|
123
|
+
continue;
|
|
124
|
+
seen.add(key);
|
|
125
|
+
folders.push(entry);
|
|
126
|
+
}
|
|
127
|
+
return folders;
|
|
128
|
+
}
|
|
@@ -120,7 +120,9 @@ export declare function founderAnswerFromReply(reply: {
|
|
|
120
120
|
body: unknown;
|
|
121
121
|
}): LiveFounderAnswer;
|
|
122
122
|
/** The labels a machine's opt-outs are reported under (heartbeat, doctor, logs). */
|
|
123
|
-
export type CaptureOptOutLabel = "memory_capture_off" | "collect_claude_jsonl_false" | "collect_codex_jsonl_false" | "raw_evidence_upload_disabled"
|
|
123
|
+
export type CaptureOptOutLabel = "memory_capture_off" | "collect_claude_jsonl_false" | "collect_codex_jsonl_false" | "raw_evidence_upload_disabled"
|
|
124
|
+
/** BLI-24635: the machine holds excluded folders (`excluded-folders-contract.ts`). */
|
|
125
|
+
| "excluded_folder";
|
|
124
126
|
/** The refusal a non-founder gets from every door that records an "off". */
|
|
125
127
|
export declare const FOUNDERS_ONLY_REFUSAL = "memory_off_founders_only";
|
|
126
128
|
/** The refusal when Tower could not be asked; nothing is recorded. */
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/local-config.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const LocalCollectorConfigSchema: z.ZodObject<{
|
|
|
30
30
|
tool: "tool";
|
|
31
31
|
day: "day";
|
|
32
32
|
}>>>;
|
|
33
|
+
excluded_folders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
34
|
session_file_path: z.ZodOptional<z.ZodString>;
|
|
34
35
|
state_dir_path: z.ZodOptional<z.ZodString>;
|
|
35
36
|
}, z.core.$strict>;
|
package/dist/local-config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CollectionScopeSchema } from "./collection-scope.js";
|
|
3
|
+
import { EXCLUDED_FOLDERS_MAX } from "./excluded-folders-contract.js";
|
|
3
4
|
import { IsoDateTimeSchema, NonEmptyStringSchema, VersionStringSchema, } from "./common.js";
|
|
4
5
|
export const LocalCollectorConfigSchema = z
|
|
5
6
|
.object({
|
|
@@ -39,6 +40,10 @@ export const LocalCollectorConfigSchema = z
|
|
|
39
40
|
shelf_default: z.enum(["team", "drawer"]).optional(),
|
|
40
41
|
// BLI-23478: the opt-in categories a founder allows on a bare record (all off when absent).
|
|
41
42
|
shelf_metrics_allow: z.array(z.enum(["day", "tool", "model", "spawn"])).max(4).optional(),
|
|
43
|
+
// BLI-24635: a founder's excluded folders (absolute paths). A session whose working folder is inside one never
|
|
44
|
+
// leaves the machine. Obeyed only for a founder on Tower's live answer (`excluded-folders-contract.ts`). Optional
|
|
45
|
+
// with no default and written only when non-empty, so a machine that never set it keeps a config every CLI reads.
|
|
46
|
+
excluded_folders: z.array(NonEmptyStringSchema).max(EXCLUDED_FOLDERS_MAX).optional(),
|
|
42
47
|
session_file_path: NonEmptyStringSchema.optional(),
|
|
43
48
|
state_dir_path: NonEmptyStringSchema.optional(),
|
|
44
49
|
})
|
|
@@ -187,6 +187,13 @@ export const TOWER_PATTERNS = [
|
|
|
187
187
|
note: "one ops reader ran past its time budget and the board shows the rest without it (declared WARNING by the code)",
|
|
188
188
|
basis: "dashboard 12 h: 15 lines",
|
|
189
189
|
},
|
|
190
|
+
{
|
|
191
|
+
id: "ops-pipeline-read-reader-timeout",
|
|
192
|
+
class: "hiccup",
|
|
193
|
+
match: raw `^\[ops status\] pipeline read .*reason=reader_timeout`,
|
|
194
|
+
note: "the per-job gauge line for a row whose reader ran past its budget: that row is shown as not judged and the other rows still answer (pipeline-read.ts readerFailure)",
|
|
195
|
+
basis: "dashboard and inference service: 28 lines in 28 days (BLI incident ecc2d6c5), classed unknown before this rule",
|
|
196
|
+
},
|
|
190
197
|
{
|
|
191
198
|
id: "dashboard-memory-arm-deadline",
|
|
192
199
|
class: "hiccup",
|
|
@@ -81,7 +81,8 @@ export type MemoryHookHost = "claude_code" | "codex";
|
|
|
81
81
|
* unreadable (no source opt-out can be read from it, so none applies).
|
|
82
82
|
*/
|
|
83
83
|
export interface MemoryCaptureGate {
|
|
84
|
-
|
|
84
|
+
/** `excluded_folder` (BLI-24635): the hook's working folder is inside one of the machine's excluded folders. */
|
|
85
|
+
refusal: "memory_opt_out" | "session_upload_opt_out" | "excluded_folder" | null;
|
|
85
86
|
/** Opt-outs found and NOT obeyed because Tower says this person is not a founder. */
|
|
86
87
|
ignored: CaptureOptOutLabel[];
|
|
87
88
|
/** Why the refusal was obeyed; null when nothing was. */
|
|
@@ -95,6 +96,11 @@ export declare function memoryCaptureGate(input: {
|
|
|
95
96
|
host: MemoryHookHost;
|
|
96
97
|
standing: FounderStanding;
|
|
97
98
|
saveHook: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* BLI-24635: the hook's working folder is inside an excluded folder. EVERY hook skips (recall would send the
|
|
101
|
+
* prompt as a search). Founders only, like the rest.
|
|
102
|
+
*/
|
|
103
|
+
excludedFolder?: boolean;
|
|
98
104
|
}): MemoryCaptureGate;
|
|
99
105
|
/** The config's opt-out for one host's sessions, or null when they upload. */
|
|
100
106
|
export declare function sessionOptOutLabel(config: Record<string, unknown> | null, host: MemoryHookHost): CaptureOptOutLabel | null;
|
|
@@ -67,9 +67,11 @@ export function renderMemoryCaptureChoice(choice) {
|
|
|
67
67
|
export function memoryCaptureGate(input) {
|
|
68
68
|
const memoryOff = input.choice.state === "off";
|
|
69
69
|
const sessionLabel = input.saveHook ? sessionOptOutLabel(input.config, input.host) : null;
|
|
70
|
+
const excluded = input.excludedFolder === true;
|
|
70
71
|
const found = [
|
|
71
72
|
...(memoryOff ? ["memory_capture_off"] : []),
|
|
72
73
|
...(sessionLabel ? [sessionLabel] : []),
|
|
74
|
+
...(excluded ? ["excluded_folder"] : []),
|
|
73
75
|
];
|
|
74
76
|
if (found.length === 0)
|
|
75
77
|
return { refusal: null, ignored: [], obeyedReason: null, held: false };
|
|
@@ -77,7 +79,7 @@ export function memoryCaptureGate(input) {
|
|
|
77
79
|
if (!verdict.obeyed)
|
|
78
80
|
return { refusal: null, ignored: found, obeyedReason: null, held: false };
|
|
79
81
|
return {
|
|
80
|
-
refusal: memoryOff ? "memory_opt_out" : "session_upload_opt_out",
|
|
82
|
+
refusal: memoryOff ? "memory_opt_out" : excluded ? "excluded_folder" : "session_upload_opt_out",
|
|
81
83
|
ignored: [],
|
|
82
84
|
obeyedReason: verdict.reason,
|
|
83
85
|
held: verdict.held,
|