@bli-cockpit/telemetry-core 0.1.64 → 0.1.65

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.
@@ -15,5 +15,5 @@ export { VERCEL_PROJECT, VERCEL_SCOPE, readDashboard, routeTemplate, vercelRecor
15
15
  export { readStdin } from "./sources/stdin.js";
16
16
  export { LOCAL_ACCESS_REFUSALS, STORED_MAX_TEMPLATES_PER_WINDOW, digestLines, mergeStored, notReadLines, scrubRow, storedRowBytes, toStoredRows, type DigestedLines, type StillRefusing, type StoredMerge, type StoredRow, type StoredWindow, type UnreadableSource, } from "./stored.js";
17
17
  export { PROJECT_TABLES, projectClassTable } from "./project-classes.js";
18
- export { LOG_EXCLUDED, LOG_EXCLUDED_SUPABASE_REFS, LOG_PROJECTS, LOG_PROJECT_IDS, LOG_PROJECT_PATTERN, TOWER_RAILWAY, VERCEL_TEAM_ID, findLogProject, type GcpSource, type LogProject, type LogSource, type NotWiredSource, type RailwaySource, type SupabaseSource, type SupabaseStream, type VercelSource, } from "./log-projects.js";
18
+ export { BRAIN_PROJECT_IDS, LOG_EXCLUDED, LOG_EXCLUDED_SUPABASE_REFS, LOG_PROJECTS, LOG_PROJECT_IDS, LOG_PROJECT_PATTERN, TOWER_RAILWAY, VERCEL_TEAM_ID, brainRouteFor, findLogProject, type BrainConfig, type BrainMergePolicy, type BrainRoute, type GcpSource, type LogProject, type LogSource, type NotWiredSource, type RailwaySource, type SupabaseSource, type SupabaseStream, type VercelSource, } from "./log-projects.js";
19
19
  export { STORED_EXAMPLE_CHARS, STORED_TEMPLATE_CHARS, scrubForStorage, scrubLine, scrubUnit } from "./scrub.js";
@@ -15,5 +15,5 @@ export { VERCEL_PROJECT, VERCEL_SCOPE, readDashboard, routeTemplate, vercelRecor
15
15
  export { readStdin } from "./sources/stdin.js";
16
16
  export { LOCAL_ACCESS_REFUSALS, STORED_MAX_TEMPLATES_PER_WINDOW, digestLines, mergeStored, notReadLines, scrubRow, storedRowBytes, toStoredRows, } from "./stored.js";
17
17
  export { PROJECT_TABLES, projectClassTable } from "./project-classes.js";
18
- export { LOG_EXCLUDED, LOG_EXCLUDED_SUPABASE_REFS, LOG_PROJECTS, LOG_PROJECT_IDS, LOG_PROJECT_PATTERN, TOWER_RAILWAY, VERCEL_TEAM_ID, findLogProject, } from "./log-projects.js";
18
+ export { BRAIN_PROJECT_IDS, LOG_EXCLUDED, LOG_EXCLUDED_SUPABASE_REFS, LOG_PROJECTS, LOG_PROJECT_IDS, LOG_PROJECT_PATTERN, TOWER_RAILWAY, VERCEL_TEAM_ID, brainRouteFor, findLogProject, } from "./log-projects.js";
19
19
  export { STORED_EXAMPLE_CHARS, STORED_TEMPLATE_CHARS, scrubForStorage, scrubLine, scrubUnit } from "./scrub.js";
@@ -71,11 +71,35 @@ export interface NotWiredSource extends SourceBase {
71
71
  reason: string;
72
72
  }
73
73
  export type LogSource = VercelSource | RailwaySource | SupabaseSource | GcpSource | NotWiredSource;
74
+ /**
75
+ * How the brain may land a fix (BLI-12859). `on_green`: the PR gets auto-merge, which GitHub performs only once the
76
+ * repo's own required checks pass. `pr_only`: the brain opens the PR and stops; a person merges.
77
+ */
78
+ export type BrainMergePolicy = "on_green" | "pr_only";
79
+ /**
80
+ * Where and how the brain may act on one project (BLI-12859). A project WITHOUT this block is never acted on: the
81
+ * brain reads the registry, finds no route and leaves the incident alone, which is how Kaiben stays out of reach.
82
+ */
83
+ export interface BrainConfig {
84
+ repos: {
85
+ /** `owner/name` the fix goes to when no source below is named. */
86
+ default: string;
87
+ /** `owner/name` per source label (`LogSource.source`), for a project whose sources live in different repos. */
88
+ by_source?: Readonly<Record<string, string>>;
89
+ };
90
+ /** The branch the PR targets and the checkout starts from. */
91
+ base_branch: string;
92
+ merge: BrainMergePolicy;
93
+ /** Claude sessions the brain may start for this project per UTC day (triage and workers both count). */
94
+ daily_runs: number;
95
+ }
74
96
  export interface LogProject {
75
97
  /** What `cockpit logs <project>` takes. */
76
98
  id: string;
77
99
  name: string;
78
100
  sources: readonly LogSource[];
101
+ /** Absent means the brain never acts on this project. */
102
+ brain?: BrainConfig;
79
103
  }
80
104
  export declare const LOG_PROJECTS: readonly LogProject[];
81
105
  /** Not Tower, so not here: Veetesh's own Vercel project. */
@@ -87,6 +111,24 @@ export declare const LOG_EXCLUDED: readonly ["bli-cockpit-oversight"];
87
111
  export declare const LOG_EXCLUDED_SUPABASE_REFS: Readonly<Record<string, string>>;
88
112
  export declare function findLogProject(id: string): LogProject | null;
89
113
  export declare const LOG_PROJECT_IDS: readonly string[];
114
+ /** Ids of the projects the brain may act on: the ones with a `brain` block. */
115
+ export declare const BRAIN_PROJECT_IDS: readonly string[];
116
+ export interface BrainRoute {
117
+ project: string;
118
+ /** `owner/name` the fix is made in. */
119
+ repo: string;
120
+ base_branch: string;
121
+ merge: BrainMergePolicy;
122
+ daily_runs: number;
123
+ /** The source label that chose the repo, or `default` when none did. */
124
+ matched: string;
125
+ }
126
+ /**
127
+ * Where the brain may work on one incident: the project's `brain` block, with the repo chosen by the incident's source
128
+ * labels (the first label that has its own repo wins, otherwise `default`). `null` means the brain must not act: the
129
+ * project is unknown or has no `brain` block.
130
+ */
131
+ export declare function brainRouteFor(projectId: string, sources?: readonly string[]): BrainRoute | null;
90
132
  /** A project id as `cockpit logs <project>` spells it: lowercase letters, digits and dashes. */
91
133
  export declare const LOG_PROJECT_PATTERN: RegExp;
92
134
  export {};
@@ -56,6 +56,8 @@ export const LOG_PROJECTS = [
56
56
  { kind: "railway", source: "railway:bli-cockpit-inference", family: "railway", ...TOWER_RAILWAY },
57
57
  supabase("BLI-Cockpit", "bnwolptxyrjalnppqyaf"),
58
58
  ],
59
+ // AGENTS.md "Velocity": merge on green without asking. `main`'s ruleset requires its checks and allows squash only.
60
+ brain: { repos: { default: "BLI-INC/bli-cockpit" }, base_branch: "main", merge: "on_green", daily_runs: 10 },
59
61
  },
60
62
  {
61
63
  id: "portpal",
@@ -64,6 +66,11 @@ export const LOG_PROJECTS = [
64
66
  vercel("portpal-2", "prj_QfzQ7rmAAlIdYphezkFXY4JebM3W"),
65
67
  supabase("PortPal", "qcnozghkxbnlofahaqig"),
66
68
  ],
69
+ // The Vercel project portpal-2 is git-linked to BLI-INC/portpal-2 (production branch main; `vercel api /v9/projects`,
70
+ // 2026-10-07); BLI-INC/PORTPAL has not been pushed since 2026-07-31. Its AGENTS.md lets in-session subagents "merge on
71
+ // local green" for the speed check but never says an autonomous agent may merge a PR, and a merge to main applies
72
+ // production migrations and ships phone updates, so the brain stops at the PR.
73
+ brain: { repos: { default: "BLI-INC/portpal-2" }, base_branch: "main", merge: "pr_only", daily_runs: 4 },
67
74
  },
68
75
  {
69
76
  id: "blue-pearl-website",
@@ -87,6 +94,14 @@ export const LOG_PROJECTS = [
87
94
  gcpCloudRun("buildlaunchiterate", "blue-pearl-mortgage"),
88
95
  notWired("sentry:build-launch-iterate/javascript-nextjs", "sentry", "sentry_token_not_mintable: the Pearl frontend also reports to Sentry (org build-launch-iterate, project javascript-nextjs); a read-only internal-integration token (event:read, project:read, org:read) needs org-level write that the existing Sentry login lacks (creating the integration answered 403), so no token was minted and Edward's broader personal token was not copied; create the integration in Sentry settings, then register the source"),
89
96
  ],
97
+ // Both repos' AGENTS.md say "Do not auto-merge. Stop at PR unless user says merge" (read 2026-10-07), so pr_only. A line
98
+ // from the Cloud Run backend is fixed in its own repo; every other source is the frontend.
99
+ brain: {
100
+ repos: { default: "BLI-INC/bluepearl-frontend", by_source: { "gcp:blue-pearl-mortgage": "BLI-INC/blue-pearl-mortgage-backend" } },
101
+ base_branch: "main",
102
+ merge: "pr_only",
103
+ daily_runs: 6,
104
+ },
90
105
  },
91
106
  {
92
107
  id: "triage-ocr",
@@ -112,6 +127,9 @@ export const LOG_PROJECTS = [
112
127
  // Kolm PRODUCTION (the Kolm session's handoff on ticket 12860). The CLI lists this ref under the name "kolm-v15-staging".
113
128
  supabase("Kolm", "hvhoyqalnkvbnpteggpi"),
114
129
  ],
130
+ // Ticket 12860's comment: PRs only, and never apply a migration (its AGENTS.md rule 24 puts them behind independent
131
+ // review). Its AGENTS.md has no merge-on-green permission either.
132
+ brain: { repos: { default: "BLI-INC/kolm-dashboard-v15" }, base_branch: "main", merge: "pr_only", daily_runs: 6 },
115
133
  },
116
134
  {
117
135
  id: "kaiben",
@@ -169,5 +187,27 @@ export function findLogProject(id) {
169
187
  return LOG_PROJECTS.find((project) => project.id === id) ?? null;
170
188
  }
171
189
  export const LOG_PROJECT_IDS = LOG_PROJECTS.map((project) => project.id);
190
+ /** Ids of the projects the brain may act on: the ones with a `brain` block. */
191
+ export const BRAIN_PROJECT_IDS = LOG_PROJECTS.filter((project) => project.brain).map((project) => project.id);
192
+ /**
193
+ * Where the brain may work on one incident: the project's `brain` block, with the repo chosen by the incident's source
194
+ * labels (the first label that has its own repo wins, otherwise `default`). `null` means the brain must not act: the
195
+ * project is unknown or has no `brain` block.
196
+ */
197
+ export function brainRouteFor(projectId, sources = []) {
198
+ const brain = findLogProject(projectId)?.brain;
199
+ if (!brain)
200
+ return null;
201
+ const bySource = brain.repos.by_source ?? {};
202
+ const matched = sources.find((label) => Object.hasOwn(bySource, label));
203
+ return {
204
+ project: projectId,
205
+ repo: matched === undefined ? brain.repos.default : bySource[matched],
206
+ base_branch: brain.base_branch,
207
+ merge: brain.merge,
208
+ daily_runs: brain.daily_runs,
209
+ matched: matched ?? "default",
210
+ };
211
+ }
172
212
  /** A project id as `cockpit logs <project>` spells it: lowercase letters, digits and dashes. */
173
213
  export const LOG_PROJECT_PATTERN = /^[a-z][a-z0-9-]{1,40}$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bli-cockpit/telemetry-core",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",