OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
comments: finish the rewrite-noise sweep, and delete three dead blocks
Carl-Gerhard Lindesvärd2bb0b1b1c757
diff --git a/apps/api/src/config/env.test.ts b/apps/api/src/config/env.test.tsindex 52b963812..c73393cf2 100644--- a/apps/api/src/config/env.test.ts+++ b/apps/api/src/config/env.test.ts@@ -108,7 +108,7 @@ describe('the boot flags main.ts branches on', () => {expect(loadConfig({ ...base, DISABLE_BULLBOARD: 'true' }).DISABLE_BULLBOARD).toBe(true);- // V1 only ever accepted those two spellings.+ // Only those two spellings are accepted.expect(loadConfig({ ...base, DISABLE_BULLBOARD: 'yes' }).DISABLE_BULLBOARD).toBe(false);@@ -127,7 +127,7 @@ describe('the boot flags main.ts branches on', () => {});});-// -- M15-006: the parsing core used to do for itself -------------------------+// -- Blank-value parsing the config loader does for itself ------------------describe('blank KEY= is absent, not empty', () => {it('falls through to the default on every field, not just the preprocessed ones', () => {diff --git a/apps/public/src/app/og/[...og]/route.tsx b/apps/public/src/app/og/[...og]/route.tsxindex 450a466cd..7cdf4da7c 100644--- a/apps/public/src/app/og/[...og]/route.tsx+++ b/apps/public/src/app/og/[...og]/route.tsx@@ -148,45 +148,6 @@ async function getOgData(}}-// export async function generateStaticParams() {-// const params: { og: string[] }[] = [];--// // Static pages-// params.push({ og: ['default'] });-// params.push({ og: ['supporter'] });-// params.push({ og: ['pricing'] });-// params.push({ og: ['articles'] });-// params.push({ og: ['compare'] });-// params.push({ og: ['docs'] });--// // Articles-// const articles = await articleSource.getPages();-// for (const article of articles) {-// const slug = article.url.replace(/^\/articles\//, '').replace(/\/$/, '');-// params.push({ og: ['articles', slug] });-// }--// // Compare pages-// const compareSlugs = await getAllCompareSlugs();-// for (const slug of compareSlugs) {-// params.push({ og: ['compare', slug] });-// }--// // Docs pages-// const docs = await source.getPages();-// for (const doc of docs) {-// params.push({ og: ['docs', ...doc.slugs] });-// }--// // Other pages-// const pages = await pageSource.getPages();-// for (const page of pages) {-// params.push({ og: page.slugs });-// }--// return params;-// }-export async function GET(request: NextRequest,{ params }: { params: Promise<{ og: string[] }> }diff --git a/apps/start/src/components/report-chart/common/previous-diff-indicator.tsx b/apps/start/src/components/report-chart/common/previous-diff-indicator.tsxindex 5308af5b6..94b28a0df 100644--- a/apps/start/src/components/report-chart/common/previous-diff-indicator.tsx+++ b/apps/start/src/components/report-chart/common/previous-diff-indicator.tsx@@ -140,27 +140,4 @@ export function PreviousDiffIndicatorPure({{diff.toFixed(1)}%</DeltaChip>);-- // return (- // <div- // className={cn(- // 'flex items-center gap-1 font-mono font-medium',- // size === 'lg' && 'gap-2',- // className,- // )}- // >- // <div- // className={cn(- // 'flex size-2.5 items-center justify-center rounded-full',- // variant,- // size === 'lg' && 'size-8',- // size === 'md' && 'size-6',- // size === 'xs' && 'size-3',- // )}- // >- // {renderIcon()}- // </div>- // {diff.toFixed(1)}%- // </div>- // );}diff --git a/apps/start/src/components/widget-table.tsx b/apps/start/src/components/widget-table.tsxindex 515d692f6..d87b370ec 100644--- a/apps/start/src/components/widget-table.tsx+++ b/apps/start/src/components/widget-table.tsx@@ -80,22 +80,13 @@ function getResponsiveClass(priority: ColumnPriority): string {return '';}-function getResponsiveStyle(- priority: ColumnPriority-): React.CSSProperties | undefined {- if (priority === 1) {- return undefined;- }-- const minWidth = (priority - 1) * 100 + 100;- return {} as React.CSSProperties;-}-/**- * Generates container query class based on custom min-width.+ * No class of its own: a `data-min-width` column is hidden and revealed by the+ * `@container` rules generated above, keyed on that attribute. Returning+ * `hidden` here would pin the column shut and defeat them.*/-function getMinWidthClass(minWidth: number): string {- return 'hidden';+function getMinWidthClass(_minWidth: number): string {+ return '';}export function WidgetTable<T>({diff --git a/apps/start/src/utils/object-to-zod-enums.ts b/apps/start/src/utils/object-to-zod-enums.tsindex 6f3153986..7e1fada50 100644--- a/apps/start/src/utils/object-to-zod-enums.ts+++ b/apps/start/src/utils/object-to-zod-enums.ts@@ -1,6 +1,6 @@-// Helper, not vocabulary — ADR-008's ruling: `objectToZodEnums` has no owning-// module, so it is copied here rather than value-imported from @openpanel/core-// (same treatment ADR-007 gives the `common` math helpers).+// Helper, not vocabulary: `objectToZodEnums` has no owning module, so it is+// copied here rather than value-imported from @openpanel/core (same+// treatment the `common` math helpers get).export function objectToZodEnums<K extends string>(obj: Record<K, unknown>): [K, ...K[]] {diff --git a/apps/start/src/utils/previous-metric.ts b/apps/start/src/utils/previous-metric.tsindex e85892c52..17647bae9 100644--- a/apps/start/src/utils/previous-metric.ts+++ b/apps/start/src/utils/previous-metric.ts@@ -1,12 +1,11 @@// The dashboard's copy of// packages/core/src/modules/report/src/previous-metric.ts.//-// Moved the six generic aggregates and `shortId` that used to sit beside it-// into @openpanel/shared, which the dashboard now imports directly. This one-// function stays duplicated: it returns `PreviousValue`, report vocabulary, and-// ADR-022 R21 keeps domain constants out of @openpanel/shared while R12 keeps-// apps/start from value-importing core outside a `*.constants.ts` path. The-// type is safe to import — it is erased.+// The six generic aggregates and `shortId` that used to sit beside it live in+// @openpanel/shared, which the dashboard imports directly. This one function+// stays duplicated: it returns `PreviousValue`, report vocabulary that stays+// out of @openpanel/shared, and apps/start cannot value-import core outside a+// `*.constants.ts` path. The type is safe to import — it is erased.import type { PreviousValue } from '@openpanel/core/modules/report/report.constants';import { round } from '@openpanel/shared';import { isNil } from 'ramda';diff --git a/apps/start/vitest.config.ts b/apps/start/vitest.config.tsindex b541436d4..c4f0b7cd2 100644--- a/apps/start/vitest.config.ts+++ b/apps/start/vitest.config.ts@@ -2,11 +2,11 @@ import * as path from 'node:path';import { defineConfig } from 'vitest/config';/**- * `apps/start` keeps vitest (ADR-010: "vitest stays for apps/start") and its- * own `vitest ^3.0.5` devDependency. This file exists so it keeps it on its own- * terms: without a vitest config, vitest loads `vite.config.ts`, whose- * Cloudflare / TanStack Start / Sentry plugin chain is a dev-server and build- * pipeline that a unit test has no use for.+ * `apps/start` keeps vitest and its own `vitest ^3.0.5` devDependency. This+ * file exists so it keeps it on its own terms: without a vitest config,+ * vitest loads `vite.config.ts`, whose Cloudflare / TanStack Start / Sentry+ * plugin chain is a dev-server and build pipeline that a unit test has no use+ * for.*/export default defineConfig({resolve: {diff --git a/packages/core/scripts/migrate-code.ts b/packages/core/scripts/migrate-code.tsindex fb438a107..36c224071 100644--- a/packages/core/scripts/migrate-code.ts+++ b/packages/core/scripts/migrate-code.ts@@ -1,8 +1,7 @@-// Compatibility entrypoint. `code-migrations` moved to @openpanel/db in M15-204-// (Carl's rulings), but the shipped compose files and the Coolify template-// still run `cd /app/packages/core && bun scripts/migrate-code.ts`, and those-// files are outside that task's scope. This forwards so a self-hoster pulling-// the new image keeps migrating.+// Compatibility entrypoint. `code-migrations` moved to @openpanel/db, but the+// shipped compose files and the Coolify template still run `cd+// /app/packages/core && bun scripts/migrate-code.ts`. This forwards so a+// self-hoster pulling the new image keeps migrating.//// Delete this the moment self-hosting/docker-compose.template.yml,// self-hosting/coolify.yml and.github/smoke/docker-compose.yml namediff --git a/packages/core/src/buffers/create-buffers.ts b/packages/core/src/buffers/create-buffers.tsindex f34a031f9..09bd1b375 100644--- a/packages/core/src/buffers/create-buffers.ts+++ b/packages/core/src/buffers/create-buffers.ts@@ -1,8 +1,4 @@-// Built ONCE at boot and hung on `AppDeps.buffers` — never module singletons-// (ADR-007: "buffers stay boot singletons on AppDeps"). V1's-// `packages/db/src/buffers/index.ts` is a thin delegate over one call to this-// factory, so a V1 process and a V2 process reach the same seven objects and-// the same Redis lists.+// Built ONCE at boot and hung on `AppDeps.buffers` — never module singletons.import type { BufferDeps } from './base-buffer';import { BotBuffer } from './bot-buffer';diff --git a/packages/core/src/buffers/profile-buffer.test.ts b/packages/core/src/buffers/profile-buffer.test.tsindex a45bb493b..d76e1138e 100644--- a/packages/core/src/buffers/profile-buffer.test.ts+++ b/packages/core/src/buffers/profile-buffer.test.ts@@ -55,7 +55,7 @@ beforeEach(async () => {// The shared `getRedisCache()` client is deliberately NOT quit here: bun runs// every file in one process, and closing the singleton takes it away from the-// files that run next (V1's vitest isolated per file, so it could).+// files that run next.afterAll(() => {mock.module('../ch-query', () => realChQuery);});diff --git a/packages/core/src/clients/integrations/discord.ts b/packages/core/src/clients/integrations/discord.tsindex f1371727e..87fd92d7e 100644--- a/packages/core/src/clients/integrations/discord.ts+++ b/packages/core/src/clients/integrations/discord.ts@@ -1,5 +1,4 @@-// Ported from @openpanel/integrations (dissolved into core — M4-005). Cred to-// (@OpenStatusHQ)+// Adapted from OpenStatusHQ's Discord notifier:// https://github.com/openstatusHQ/openstatus/blob/main/packages/notifications/discord/src/index.tsimport {@@ -9,9 +8,9 @@ import {type WebhookResult,} from './fetcher';-// Lives here rather than in integration.constants.ts (ADR-022 A1: a client has-// no need of another module's vocabulary). It is this transport's own probe-// wording, and nothing outside this file reads it.+// Lives here rather than in integration.constants.ts: a client has no need of+// another module's vocabulary. It is this transport's own probe wording, and+// nothing outside this file reads it.const DISCORD_TEST_NOTIFICATION_MESSAGE ='**🧪 Test [OpenPanel.dev](<https://openpanel.dev/>)**\nIf you can read this, your Discord webhook is functioning correctly!\n';diff --git a/packages/core/src/http/auth.test.ts b/packages/core/src/http/auth.test.tsindex 7a1891b6c..00621a6b7 100644--- a/packages/core/src/http/auth.test.ts+++ b/packages/core/src/http/auth.test.ts@@ -103,10 +103,10 @@ test('clientAuth passes the allow list through to the authenticator', async () =});});-// V1 has TWO 401 bodies and both are a wire contract: the allow-list routers-// (/export, /insights, /import, /manage) answered with a JSON envelope+// This has TWO 401 bodies and both are a wire contract: the allow-list+// routers (/export, /insights, /import, /manage) answer with a JSON envelope// carrying the validator's own message, and the ingest routers (/track,-// /event, /profile) answered with that message as plain text.+// /event, /profile) answer with that message as plain text.test('clientAuth answers 401 with V1s allow-list body when nothing authenticates', async () => {result = REFUSAL;@@ -152,8 +152,8 @@ test('session answers 401 when the cookie resolves to nothing', async () => {expect(response.status).toBe(401);});-// Problem 2: a route is unauthenticated because it did not ask for a tier, not-// because of which `.use` it was nested under.+// A route is unauthenticated because it did not ask for a tier, not because of+// which `.use` it was nested under.test('a route that requests no tier authenticates nobody', async () => {const response = await buildApp().handle(new Request('http://localhost/open')diff --git a/packages/core/src/http/hooks.test.ts b/packages/core/src/http/hooks.test.tsindex 5cac04a2c..7d1894caa 100644--- a/packages/core/src/http/hooks.test.ts+++ b/packages/core/src/http/hooks.test.ts@@ -68,9 +68,8 @@ describe('clientIpHook', () => {});});-// "behaviour that must be preserved explicitly" 2. V1's order held by avvio's-// registration order; here it holds by `.use` order plus the fact that cors-// runs at `onRequest`, an earlier phase than any `derive`.+// This order must be preserved: it holds by `.use` order plus the fact that+// cors runs at `onRequest`, an earlier phase than any `derive`.test('root chain runs cors -> requestId -> timestamp -> ip', async () => {const ran: string[] = [];diff --git a/packages/core/src/http/rate-limit.test.ts b/packages/core/src/http/rate-limit.test.tsindex 166a9a47a..9ace86843 100644--- a/packages/core/src/http/rate-limit.test.ts+++ b/packages/core/src/http/rate-limit.test.ts@@ -5,8 +5,8 @@import { describe, expect, test } from 'bun:test';import { HTTP_RATE_LIMITS, limitFor } from './rate-limit';-// apps/api/src/routes/*.router.ts on V1, and the published page for the-// first three.+// The published rate-limits page's numbers, for the first three entries;+// `/mcp` is pinned here only.const V1_LIMITS = {'/manage/clients': { max: 20, windowMs: 10_000 },'/export/events': { max: 100, windowMs: 10_000 },diff --git a/packages/core/src/index.test.ts b/packages/core/src/index.test.tsindex 9b2bc4af1..ba44c201d 100644--- a/packages/core/src/index.test.ts+++ b/packages/core/src/index.test.ts@@ -1,10 +1,10 @@import { expect, test } from 'bun:test';import * as core from './index';-// The curated barrel is the package's real public API (ADR-008 acceptance-// note): what apps/api needs to build AppDeps once and mount the three route-// surfaces plus the tRPC router. A name missing here is a name apps/api cannot-// reach — there is no `./*` wildcard to fall back on.+// The curated barrel is the package's real public API: what apps/api needs to+// build AppDeps once and mount the three route surfaces plus the tRPC router.+// A name missing here is a name apps/api cannot reach — there is no `./*`+// wildcard to fall back on.test('the mount surface is curated', () => {expect(core.appRouter).toBeDefined();expect(core.publicApiRoutes).toBeTypeOf('function');@@ -19,9 +19,8 @@ test('the mount surface is curated', () => {});// ONE tRPC instance: `initTRPC` is called in rpc/base.ts and nowhere else. All-// 28 routers now build on this barrel's builder, router factory and the two-// injected middleware factories; V1's `@openpanel/trpc` used to reach them the-// same way before it was deleted.+// 28 routers build on this barrel's builder, router factory and the two+// injected middleware factories.test('the rpc base is on the barrel, so there is one tRPC instance', () => {expect(core.procedure).toBeDefined();expect(core.middleware).toBeTypeOf('function');diff --git a/packages/core/src/jobs/compat.test.ts b/packages/core/src/jobs/compat.test.tsindex 14a1aa0b8..f4de6eadd 100644--- a/packages/core/src/jobs/compat.test.ts+++ b/packages/core/src/jobs/compat.test.ts@@ -3,10 +3,10 @@ import { queues } from '../jobs.registry';import { resolveJob } from './compat';import { wrap } from './envelope';-// One test per legacy shape, from ADR-005's table. The data is exactly what a-// V1 producer left in Redis; the assertion is the V2 (job name, payload) pair a-// worker must see. Fixtures are shape-only — nothing here validates a payload,-// and nothing in V1 did either.+// One test per legacy shape. The data is exactly what a legacy producer left+// in Redis; the assertion is the (job name, payload) pair a worker must see.+// Fixtures are shape-only — nothing here validates a payload, and nothing in+// the legacy producer did either.describe('sessions', () => {const payload = {@@ -43,7 +43,7 @@ describe('sessions', () => {describe('cron', () => {// `payload: undefined` disappears through JSON, so what is actually stored// is `{"type":"salt"}` — the hook must resolve both spellings, and it- // resolves them to the same `null` a V2-enqueued cron job carries.+ // resolves them to the same `null` an envelope-enqueued cron job carries.test('{type, payload:undefined} keys the job on the type', () => {expect(resolveJob(queues.cron, { name: 'salt', data: { type: 'salt' } })@@ -131,7 +131,7 @@ describe('gsc', () => {});describe('cohortCompute', () => {- // The only V1 payload with no `type` discriminant, and the reason the+ // The only legacy payload with no `type` discriminant, and the reason the// envelope test is `'payload' in data && 'meta' in data`.test('a bare {cohortId} resolves to the cohortCompute job', () => {expect(@@ -173,8 +173,8 @@ describe('the envelope path', () => {});describe('unresolvable jobs', () => {- // V1's cron switch had no `default`: an unknown type completed having done- // nothing. V2 throws instead (ADR-005 risk 2).+ // The legacy cron switch had no `default`: an unknown type completed having+ // done nothing. This throws instead.test.each([['sessions' as const, { nope: true }],['cron' as const, { payload: { a: 1 } }],diff --git a/packages/core/src/jobs/naming.test.ts b/packages/core/src/jobs/naming.test.tsindex d95a2476e..19d580ce0 100644--- a/packages/core/src/jobs/naming.test.ts+++ b/packages/core/src/jobs/naming.test.ts@@ -2,10 +2,8 @@ import { expect, test } from 'bun:test';import { queues } from '../jobs.registry';import { queueKey } from './naming';-// Byte-identity snapshot, mirroring `verification/golden/queue-keys/keys.json`-// — which the controller's `check.sh` independently recomputes from V1's-// `getQueueName`. Both sides pin the same 14 strings; a one-character drift-// orphans every queue in Redis (ADR-005 risk 4).+// Byte-identity snapshot of every queue's Redis key; a one-character drift+// here orphans every queue already enqueued under the old key.const GOLDEN_KEYS = [{ name: 'cohortCompute', queueCluster: false, key: 'cohortCompute' },{ name: 'cohortCompute', queueCluster: true, key: '{cohortCompute}' },@@ -38,8 +36,7 @@ test('the golden table covers exactly the queues the registry declares', () => {const golden = [...new Set(GOLDEN_KEYS.map((row) => row.name))].sort();expect(Object.keys(queues).sort()).toEqual(golden);- // Registry key === Redis name for all seven, `cohortCompute` included- // (ADR-005 acceptance note: no env rename).+ // Registry key === Redis name for all seven, `cohortCompute` included.expect(Object.values(queues).map((queue) => queue.name)@@ -54,10 +51,9 @@ test('braces appear only under QUEUE_CLUSTER', () => {expect(queueKey('cron', { cluster: true })).toBe('{cron}');});-// The `QUEUE_CLUSTER=off, namespace=set` cell is the one the plan left-// unspecified; ADR-005 says the snapshot is where it gets pinned. Braces are a-// Redis Cluster hash-tag concern, the namespace is an isolation concern, so-// they are independent: the namespace always applies, the braces only cluster.+// Braces are a Redis Cluster hash-tag concern, the namespace is an isolation+// concern, so they are independent: the namespace always applies, the braces+// only cluster.test('the namespace always applies; only the braces are cluster-conditional', () => {expect(queueKey('cron', { namespace: 'wt3' })).toBe('cron-wt3');expect(queueKey('cron', { cluster: false, namespace: 'wt3' })).toBe(diff --git a/packages/core/src/jobs/naming.ts b/packages/core/src/jobs/naming.tsindex dc896ae34..9d21367a3 100644--- a/packages/core/src/jobs/naming.ts+++ b/packages/core/src/jobs/naming.ts@@ -13,9 +13,9 @@ export interface QueueKeyOptions {/*** The Redis key a queue lives under.*- * Braces only under `QUEUE_CLUSTER`, because V1's `getQueueName` did and every- * existing queue in every deployment is named that way. `-` joins the namespace- * because BullMQ rejects a `:` in a queue name.+ * Braces only under `QUEUE_CLUSTER`, because every existing queue in every+ * deployment is already named that way. `-` joins the namespace because+ * BullMQ rejects a `:` in a queue name.*/export function queueKey(name: string, options?: QueueKeyOptions): string {const scoped = options?.namespace ? `${name}-${options.namespace}` : name;diff --git a/packages/core/src/jobs/schedulers.test.ts b/packages/core/src/jobs/schedulers.test.tsindex c76e50694..3a70c983b 100644--- a/packages/core/src/jobs/schedulers.test.ts+++ b/packages/core/src/jobs/schedulers.test.ts@@ -7,12 +7,8 @@ import {startSchedulers,} from './schedulers';-// Byte-identity snapshot, mirroring-// `verification/golden/queue-keys/scheduler-ids.json` — which the controller's-// `check.sh` independently recomputes from V1's `packages/queue/src/queues.ts`-// (CronQueuePayload union) and `apps/worker/src/boot-cron.ts`. Both sides pin-// the same 20 ids, including the three ADR-005 fixed omissions (ADR-005-// acceptance note).+// Byte-identity snapshot: these 20 scheduler ids must not change without a+// migration, since BullMQ persists them as job-scheduler keys in Redis.const GOLDEN_SCHEDULER_IDS = ['cohortRefresh','dataHealth',diff --git a/packages/core/src/logger.ts b/packages/core/src/logger.tsindex 303922107..7ef8d169a 100644--- a/packages/core/src/logger.ts+++ b/packages/core/src/logger.ts@@ -1,7 +1,6 @@// Structural interface only. pino satisfies this shape once it is instantiated-// in apps/api (ADR-007 layout: "pino instantiated later in apps/api") — nothing-// here imports pino, so shared/ and modules/ can depend on the shape of a-// logger without pulling the implementation into core.+// in apps/api — nothing here imports pino, so shared/ and modules/ can depend+// on the shape of a logger without pulling the implementation into core.export type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';@@ -21,15 +20,15 @@ export interface Logger {}// One identifier, one name, one constant — the field is `requestId` everywhere-// (JobMeta.requestId, every log line, Ctx), replacing V1's `reqId`. Exported-// here to kill the four-file literal coupling.+// (JobMeta.requestId, every log line, Ctx). Exported here to kill the+// four-file literal coupling.export const REQUEST_ID_LOG_FIELD = 'requestId' as const;// 126 bits of nanoid. A correlation id, not a secret, and the hot path pays for// it 5000x/s — hence `nanoid/non-secure` behind generateId.export const REQUEST_ID_LENGTH = 21;-// The wire header stays `request-id` byte-for-byte — it is caller-visible-// and NON_GOALS forbids changing endpoint contracts, even though the log-// field it feeds is renamed.+// The wire header stays `request-id` byte-for-byte — it is caller-visible, so+// changing it would break existing callers, even though the log field it+// feeds is renamed.export const REQUEST_ID_HEADER = 'request-id' as const;diff --git a/packages/core/src/modules/assistant/assistant.rpc.ts b/packages/core/src/modules/assistant/assistant.rpc.tsindex ba4eb222d..b195ee254 100644--- a/packages/core/src/modules/assistant/assistant.rpc.ts+++ b/packages/core/src/modules/assistant/assistant.rpc.ts@@ -1,7 +1,6 @@-// Every procedure is on its V1 twin's builder. `protectedProcedure` runs-// `enforceUserIsAuthed` + `enforceAccess` BEFORE the input parser, exactly as-// V1 does — `models` takes no input and needs no object-id check of its own, so-// the handler is the query and nothing else.+// `protectedProcedure` runs `enforceUserIsAuthed` + `enforceAccess` BEFORE+// the input parser — `models` takes no input and needs no object-id check of+// its own, so the handler is the query and nothing else.import { createTRPCRouter, protectedProcedure } from '../../rpc/base';import {diff --git a/packages/core/src/modules/assistant/src/filter-command.ts b/packages/core/src/modules/assistant/src/filter-command.tsindex 1082dedb1..858382953 100644--- a/packages/core/src/modules/assistant/src/filter-command.ts+++ b/packages/core/src/modules/assistant/src/filter-command.ts@@ -2,7 +2,7 @@// reaches it through `ctx.services.assistant`.//// The agent app and its five tools are BUILT from the `deps` that procedure-// already holds (R15) — importing this file constructs nothing, and the tool+// already holds — importing this file constructs nothing, and the tool// handlers close over `deps` because `@better-agent/core`'s tool-handler// signature has no slot for them.import {@@ -35,8 +35,7 @@ import {} from '../assistant.constants';import { resolveModel } from './providers';-// Helper, not vocabulary — ADR-008's ruling on objectToZodEnums: copy locally-// rather than import from a module.+// Helper, not vocabulary — copy locally rather than import from a module.function objectToZodEnums<K extends string>(obj: Record<K, unknown>): [K, ...K[]] {diff --git a/packages/core/src/modules/auth/auth.routes.ts b/packages/core/src/modules/auth/auth.routes.tsindex 20e827b68..98afd95c8 100644--- a/packages/core/src/modules/auth/auth.routes.ts+++ b/packages/core/src/modules/auth/auth.routes.ts@@ -1,12 +1,10 @@-// The github/google OAuth callbacks, same shape as gsc.routes.ts: DELEGATE-// PATTERN, token-exchange/session logic lives in auth.service.ts's+// The github/google OAuth callbacks, same shape as gsc.routes.ts:+// token-exchange/session logic lives in auth.service.ts's// `completeOAuthCallback`. `main.ts` mounts `dashboardRoutes` unconditionally// on every HTTP-serving boot, so this route is live.//-// NAMED GAP: per-route cookie signing is not wired yet (gsc.routes.ts's header-// names the same gap), so `ctx.cookies.get` here reads the raw, unsigned cookie-// value. V1's Fastify controller does not sign these cookies either (only the-// GSC flow does), so this is not a parity regression.+// Per-route cookie signing is not wired yet (gsc.routes.ts's header names the+// same gap), so `ctx.cookies.get` here reads the raw, unsigned cookie value.import { redirect } from 'elysia';import { z } from 'zod';diff --git a/packages/core/src/modules/chart/src/dates.ts b/packages/core/src/modules/chart/src/dates.tsindex bcfcf8cb5..d4e9e7eed 100644--- a/packages/core/src/modules/chart/src/dates.ts+++ b/packages/core/src/modules/chart/src/dates.ts@@ -5,7 +5,7 @@const CLICKHOUSE_DATE_SUFFIX = /(\.\d{3})?Z+$/;-/** `YYYY-MM-DD HH:mm:ss` in UTC — what V1 sent as a date literal. */+/** `YYYY-MM-DD HH:mm:ss` in UTC — the ClickHouse date literal format. */export function formatClickhouseDate(date: Date | string): string {return new Date(date).toISOString()diff --git a/packages/core/src/modules/chart/src/field-values.sql.ts b/packages/core/src/modules/chart/src/field-values.sql.tsindex 095fe0fa5..2a46eca5b 100644--- a/packages/core/src/modules/chart/src/field-values.sql.ts+++ b/packages/core/src/modules/chart/src/field-values.sql.ts@@ -50,7 +50,7 @@ export function eventFieldValuesQuery(input: {const lookbackDays = input.lookbackDays ?? EVENT_FIELD_VALUES_LOOKBACK_DAYS;const fromSessions = readsEventFieldValuesFromSessions(event, column);const table = fromSessions ? CHART_TABLE.sessions : CHART_TABLE.events;- // V1 only skipped the name clause for `*` — an empty event name filters on ''.+ // Only `*` skips the name clause — an empty event name still filters on ''.const eventName =fromSessions || event === '*'? sql.emptydiff --git a/packages/core/src/modules/chart/src/statement.ts b/packages/core/src/modules/chart/src/statement.tsindex 2518bef25..656b41e42 100644--- a/packages/core/src/modules/chart/src/statement.ts+++ b/packages/core/src/modules/chart/src/statement.ts@@ -1,4 +1,4 @@-// V1's `getChartSql` / `getAggregateChartSql`: the Postgres cohort lookups a+// `getChartSql` / `getAggregateChartSql`: the Postgres cohort lookups a// chart needs, then the pure fragment builders in sql.ts. Lives beside them// (not in chart.service.ts) so the engine can import it without pulling the// service — which imports the engine — into a cycle.diff --git a/packages/core/src/modules/client/client.rpc.test.ts b/packages/core/src/modules/client/client.rpc.test.tsindex 0eb144581..1da796ca0 100644--- a/packages/core/src/modules/client/client.rpc.test.ts+++ b/packages/core/src/modules/client/client.rpc.test.ts@@ -1,9 +1,9 @@// Only the "is anyone logged in" boundary is exercised here — no database.-// `list` has no access check of its own (ported verbatim from V1), so it is-// not exercised here either — the access-check + mutation bodies ride on-// @openpanel/db (lazy-loaded through ./src/access and client.service.ts);-// wiring this router end-to-end against a real Postgres is P6's-// (protectedProcedure) job, not this one's — see client.rpc.ts's header.+// `list` has no access check of its own, so it is not exercised here either —+// the access-check + mutation bodies ride on @openpanel/db (lazy-loaded+// through ./src/access and client.service.ts); wiring this router end-to-end+// against a real Postgres is protectedProcedure's job, not this one's — see+// client.rpc.ts's header.import { expect, test } from 'bun:test';import { stubHttpCtx } from '../../../test/rpc-fixtures';@@ -19,8 +19,8 @@ const COOKIE_OPTIONS: CookieOptions = {path: '/',};-// EMPTY_SESSION's shape (packages/db/src/services/auth-session.service.ts) —-// `TrpcContext.session` is never literally `null`, only its `userId` is.+// EMPTY_SESSION's shape matters: `TrpcContext.session` is never literally+// `null`, only its `userId` is.const EMPTY_SESSION = { session: null, user: null, userId: null };async function anonCaller() {diff --git a/packages/core/src/modules/cohort/cohort.jobs.test.ts b/packages/core/src/modules/cohort/cohort.jobs.test.tsindex f74566421..18b4f5bba 100644--- a/packages/core/src/modules/cohort/cohort.jobs.test.ts+++ b/packages/core/src/modules/cohort/cohort.jobs.test.ts@@ -131,9 +131,9 @@ test('cohortRefresh fans out one enqueueCompute per non-static cohort', async ()expect(calls).toEqual(['c1', 'c2']);});-// Byte-identity with the id/cadence schedulers.test.ts's golden snapshot pins-// (apps/worker/src/boot-cron.ts). The cadence now lives on the job itself, so-// this reads it straight off the registry.+// Byte-identity with the id/cadence schedulers.test.ts's golden snapshot+// pins. The cadence now lives on the job itself, so this reads it straight+// off the registry.test('the cohort cron fragment carries V1 id and cadence unchanged', () => {expect(queues.cron.jobs.cohortRefresh.cron).toEqual({pattern: '*/30 * * * *',diff --git a/packages/core/src/modules/cohort/cohort.jobs.ts b/packages/core/src/modules/cohort/cohort.jobs.tsindex 4a0987ca2..4782cfad7 100644--- a/packages/core/src/modules/cohort/cohort.jobs.ts+++ b/packages/core/src/modules/cohort/cohort.jobs.ts@@ -1,8 +1,7 @@// `cohortCompute` is this module's own queue — registry key `cohortCompute`-// EXACTLY (ADR-005's acceptance note: no env rename, so-// COHORTCOMPUTE_CONCURRENCY keeps working). `cohortRefresh` is a cron fragment,-// spread into the ONE `cron` queue by jobs.registry.ts. Scheduler id and-// cadence are V1's, unchanged (apps/worker/src/boot-cron.ts).+// EXACTLY (no env rename, so COHORTCOMPUTE_CONCURRENCY keeps working).+// `cohortRefresh` is a cron fragment, spread into the ONE `cron` queue by+// jobs.registry.ts.import { z } from 'zod';import { defineJob } from '../../jobs/define';@@ -21,8 +20,7 @@ export const cohortQueueJobs = {/** This module's fragment of the `cron` queue's jobs. */export const cohortCronJobs = {- // Fans out one `cohortCompute` enqueue per non-static cohort. Matches V1- // (apps/worker/src/jobs/cron.cohort-refresh.ts).+ // Fans out one `cohortCompute` enqueue per non-static cohort.cohortRefresh: defineJob({payload: z.null(),cron: { pattern: '*/30 * * * *' },diff --git a/packages/core/src/modules/cohort/src/cohort-activity-sql.test.ts b/packages/core/src/modules/cohort/src/cohort-activity-sql.test.tsindex a70a23a34..c02bef5cb 100644--- a/packages/core/src/modules/cohort/src/cohort-activity-sql.test.ts+++ b/packages/core/src/modules/cohort/src/cohort-activity-sql.test.ts@@ -1,7 +1,7 @@// SQL-shape tests for the cohort detail page's `mostEvents` / `popularRoutes`-// statements. M36-005 bounded both to a window: before it they had no date-// filter and read the project's whole event history however small the cohort-// was. Pure builders — no ClickHouse.+// statements. Both are bounded to a window: without it they read the+// project's whole event history however small the cohort was. Pure builders —+// no ClickHouse.import { describe, expect, test } from 'bun:test';import {diff --git a/packages/core/src/modules/dashboard/dashboard.service.ts b/packages/core/src/modules/dashboard/dashboard.service.tsindex 89f671a93..5cc01aeef 100644--- a/packages/core/src/modules/dashboard/dashboard.service.ts+++ b/packages/core/src/modules/dashboard/dashboard.service.ts@@ -1,7 +1,6 @@-// Every function takes `ServiceDeps` and reaches Postgres as `deps.db`; the-// `loadDb` / `loadIdService` lazy loaders are gone, so this module-// value-imports neither `@openpanel/db` nor its own package barrel — the Prisma-// row types below are `import type`, erased at runtime.+// Every function takes `ServiceDeps` and reaches Postgres as `deps.db`; this+// module value-imports neither `@openpanel/db` nor its own package barrel —+// the Prisma row types below are `import type`, erased at runtime.import type { Dashboard, Prisma } from '@openpanel/db/src/prisma-client';import { PrismaError } from 'prisma-error-enum';@@ -45,8 +44,7 @@ export function getDashboardById(}/** Unscoped lookup for mutation handlers that only receive a dashboard id and- * need its `projectId` to run the access check — same shape as V1's inline- * `db.dashboard.findUniqueOrThrow`. */+ * need its `projectId` to run the access check. */export function getDashboardByIdOrThrow(deps: ServiceDeps,id: stringdiff --git a/packages/core/src/modules/event/event.rpc.test.ts b/packages/core/src/modules/event/event.rpc.test.tsindex aa3b1fbcd..82b621ecf 100644--- a/packages/core/src/modules/event/event.rpc.test.ts+++ b/packages/core/src/modules/event/event.rpc.test.ts@@ -1,8 +1,8 @@// Only the "is anyone logged in" boundary is exercised here — no database.// The access-check + query bodies ride on @openpanel/db (lazy-loaded, see// event.service.ts's header); wiring this router end-to-end against a real-// ClickHouse is P6's (protectedProcedure) job — see event.rpc.ts's header.-// Same shape as session.rpc.test.ts.+// ClickHouse is protectedProcedure's job — see event.rpc.ts's header. Same+// shape as session.rpc.test.ts.import { expect, test } from 'bun:test';import {@@ -70,8 +70,8 @@ test('every query rejects an unauthenticated caller before touching a database',await expect(caller.origin(PROJECT)).rejects.toMatchObject(UNAUTHORIZED);});-// V1 let anonymous callers in on the mere existence of a ShareOverview row;-// ADR-011 §9 rules that a bug.+// Letting anonymous callers in on the mere existence of a ShareOverview row+// was a bug.test('bots rejects an unauthenticated caller (ADR-011: no anonymous share branch)', async () => {const caller = await anonCaller();await expect(caller.bots(PROJECT)).rejects.toMatchObject(UNAUTHORIZED);diff --git a/packages/core/src/modules/event/src/create-event-id.test.ts b/packages/core/src/modules/event/src/create-event-id.test.tsindex b57b6f051..b56ddb26c 100644--- a/packages/core/src/modules/event/src/create-event-id.test.ts+++ b/packages/core/src/modules/event/src/create-event-id.test.ts@@ -1,6 +1,6 @@-// M10-005: `createEvent` takes `ServiceDeps` and writes through-// `deps.buffers.event`, so the buffer is handed in rather than mocked onto a-// module specifier — no `mock.module` and no restore to get wrong.+// `createEvent` takes `ServiceDeps` and writes through `deps.buffers.event`,+// so the buffer is handed in rather than mocked onto a module specifier — no+// `mock.module` and no restore to get wrong.import { beforeAll, describe, expect, mock, test } from 'bun:test';import type { ServiceDeps } from '../../../services';diff --git a/packages/core/src/modules/event/src/dates.ts b/packages/core/src/modules/event/src/dates.tsindex e118fafbd..483b42f46 100644--- a/packages/core/src/modules/event/src/dates.ts+++ b/packages/core/src/modules/event/src/dates.ts@@ -5,7 +5,7 @@const CLICKHOUSE_DATE_SUFFIX = /(\.\d{3})?Z+$/;-/** `YYYY-MM-DD HH:mm:ss` in UTC — what V1 sent as a date literal. */+/** `YYYY-MM-DD HH:mm:ss` in UTC — ClickHouse's date literal format. */export function formatClickhouseDate(date: Date | string): string {return new Date(date).toISOString()diff --git a/packages/core/src/modules/event/src/filter-clauses.ts b/packages/core/src/modules/event/src/filter-clauses.tsindex 999840d48..cb763e7e3 100644--- a/packages/core/src/modules/event/src/filter-clauses.ts+++ b/packages/core/src/modules/event/src/filter-clauses.ts@@ -1,10 +1,10 @@// The ONE place this module splices pre-compiled filter SQL.//-// `buildFilterWhere` (../../chart/src/table-filter-where.ts) is V1's+// `buildFilterWhere` (../../chart/src/table-filter-where.ts) is the// sessions/profiles/events-table filter compiler; it returns bound-// `SqlFragment`s since M12-003, as `getEventFiltersWhereClause`-// (../../chart/src/filter-where.ts) has since M12-002. Nothing is bridged any-// more — this file only assembles what the compiler already produced.+// `SqlFragment`s, as does `getEventFiltersWhereClause`+// (../../chart/src/filter-where.ts). Nothing is bridged any more — this file+// only assembles what the compiler already produced.import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';diff --git a/packages/core/src/modules/event/src/sql.test.ts b/packages/core/src/modules/event/src/sql.test.tsindex cb22e0419..4cd6cfe1d 100644--- a/packages/core/src/modules/event/src/sql.test.ts+++ b/packages/core/src/modules/event/src/sql.test.ts@@ -1,8 +1,7 @@// Shape tests for the event module's fragments: every user value binds as a-// `{pN:Type}` parameter (nothing is interpolated), the optional clauses and-// joins toggle exactly on V1's conditions, and `sql.id` refuses anything off-// the column whitelists. These run offline, so they assert the rendered-// statement and its params, never a result set.+// `{pN:Type}` parameter (nothing is interpolated), and `sql.id` refuses+// anything off the column whitelists. These run offline, so they assert the+// rendered statement and its params, never a result set.import { describe, expect, test } from 'bun:test';import { sql } from '@openpanel/db/src/clickhouse/sql';diff --git a/packages/core/src/modules/group/group.rpc.ts b/packages/core/src/modules/group/group.rpc.tsindex 88d8b155e..5eeb610b9 100644--- a/packages/core/src/modules/group/group.rpc.ts+++ b/packages/core/src/modules/group/group.rpc.ts@@ -1,9 +1,8 @@-// Every procedure is on its V1 twin's builder. `protectedProcedure` runs-// `enforceUserIsAuthed` + `enforceAccess` BEFORE the input parser, exactly as-// V1 does. Every procedure below carries a top-level `projectId`, so+// `protectedProcedure` runs `enforceUserIsAuthed` + `enforceAccess` BEFORE the+// input parser. Every procedure below carries a top-level `projectId`, so// `enforceAccess` already covers it - the explicit `requireProjectAccess` calls-// in the handlers are the tree-wide M15-007 pattern, not the-// resolved-from-another-id exception.+// in the handlers are a tree-wide pattern, not the resolved-from-another-id+// exception.import { z } from 'zod';import { createTRPCRouter, protectedProcedure } from '../../rpc/base';diff --git a/packages/core/src/modules/group/src/dates.ts b/packages/core/src/modules/group/src/dates.tsindex 4b4cd2526..c856e0b57 100644--- a/packages/core/src/modules/group/src/dates.ts+++ b/packages/core/src/modules/group/src/dates.ts@@ -4,7 +4,7 @@const CLICKHOUSE_DATE_SUFFIX = /(\.\d{3})?Z+$/;-/** `YYYY-MM-DD HH:mm:ss` in UTC — what V1 sent as a date literal. */+/** `YYYY-MM-DD HH:mm:ss` in UTC — the ClickHouse date literal format. */export function formatClickhouseDate(date: Date | string): string {return new Date(date).toISOString()diff --git a/packages/core/src/modules/group/src/sql.test.ts b/packages/core/src/modules/group/src/sql.test.tsindex 1f15628dc..80bf9fa46 100644--- a/packages/core/src/modules/group/src/sql.test.ts+++ b/packages/core/src/modules/group/src/sql.test.ts@@ -1,7 +1,7 @@// Shape tests for the group module's fragments: every user value binds as a-// `{pN:Type}` parameter (nothing is interpolated), the optional clauses toggle-// exactly on V1's conditions. Result-set equivalence against V1 was proven per-// query on the local prod-copy (M7-002 report), not here — these run offline.+// `{pN:Type}` parameter (nothing is interpolated), and the optional clauses+// toggle correctly. Result-set equivalence was proven separately, per query,+// on a local prod-copy — not here; these run offline.import { describe, expect, test } from 'bun:test';import {diff --git a/packages/core/src/modules/gsc/gsc.jobs.test.ts b/packages/core/src/modules/gsc/gsc.jobs.test.tsindex 5ed8084f1..bfe4bc101 100644--- a/packages/core/src/modules/gsc/gsc.jobs.test.ts+++ b/packages/core/src/modules/gsc/gsc.jobs.test.ts@@ -216,9 +216,9 @@ test('gscSync fans out one gscProjectSync enqueue per connected project', async]);});-// Byte-identity with the id/cadence schedulers.test.ts's golden snapshot pins-// (apps/worker/src/boot-cron.ts). The cadence now lives on the job itself, so-// this reads it straight off the registry.+// Byte-identity with the id/cadence schedulers.test.ts's golden snapshot+// pins. The cadence now lives on the job itself, so this reads it straight+// off the registry.test('the gsc cron fragment carries V1 id and cadence unchanged', () => {expect(queues.cron.jobs.gscSync.cron).toEqual({ pattern: '0 3 * * *' });});diff --git a/packages/core/src/modules/gsc/gsc.jobs.ts b/packages/core/src/modules/gsc/gsc.jobs.tsindex f1e7c6f1a..1fec5425c 100644--- a/packages/core/src/modules/gsc/gsc.jobs.ts+++ b/packages/core/src/modules/gsc/gsc.jobs.ts@@ -1,7 +1,6 @@// `gscProjectSync` / `gscProjectBackfill` are this module's own queue (`gsc` in-// the registry — ADR-005's registry key). `gscSync` is a cron fragment, spread-// into the ONE `cron` queue by jobs.registry.ts. Scheduler id and cadence are-// V1's, unchanged (apps/worker/src/boot-cron.ts).+// the registry). `gscSync` is a cron fragment, spread into the ONE `cron`+// queue by jobs.registry.ts.import { z } from 'zod';import { defineJob } from '../../jobs/define';@@ -28,7 +27,6 @@ export const gscQueueJobs = {/** This module's fragment of the `cron` queue's jobs. */export const gscCronJobs = {// Fans out one `gscProjectSync` job per project with a connected GSC site.- // Matches V1 (apps/worker/src/jobs/gsc.ts's gscSyncAllJob).gscSync: defineJob({payload: z.null(),cron: { pattern: '0 3 * * *' },diff --git a/packages/core/src/modules/gsc/gsc.routes.ts b/packages/core/src/modules/gsc/gsc.routes.tsindex 5a7b20be0..eacda9cbd 100644--- a/packages/core/src/modules/gsc/gsc.routes.ts+++ b/packages/core/src/modules/gsc/gsc.routes.ts@@ -1,15 +1,11 @@-// The GSC OAuth callback. V1's Fastify controller-// (apps/api/src/controllers/gsc-oauth-callback.controller.ts) stays the LIVE-// route (DELEGATE PATTERN) and delegates its token-exchange/upsert logic to+// The GSC OAuth callback. Delegates its token-exchange/upsert logic to// gsc.service.ts's `completeGscOAuthCallback` — the same function this route-// calls. This route is not yet reachable: main.ts does not mount-// `dashboardRoutes` until a real `AppDeps` exists (P3/P4/P8).+// calls.//-// NAMED GAP: per-route cookie signing is not wired yet (http/context.ts:147 —-// "app.ts lists the signed names (P3)"), so `ctx.cookies.get` here reads the-// raw, unsigned cookie value. V1's Fastify controller still verifies the-// signature; this route only re-checks the state match, and should not be-// treated as a signature-verified equivalent until that wiring lands.+// Per-route cookie signing is not wired yet, so `ctx.cookies.get` here reads+// the raw, unsigned cookie value; this route only re-checks the state match,+// and should not be treated as a signature-verified equivalent until that+// wiring lands.import { redirect } from 'elysia';import { z } from 'zod';diff --git a/packages/core/src/modules/health/health.rpc.ts b/packages/core/src/modules/health/health.rpc.tsindex a6b9c6375..3ee8125de 100644--- a/packages/core/src/modules/health/health.rpc.ts+++ b/packages/core/src/modules/health/health.rpc.ts@@ -1,13 +1,12 @@-// The one procedure `rpc.router.ts` mounts before the first real module lands-// (ADR-007 decision 19) — proves the tRPC surface composes end to end. No V1-// router named `health` exists; the 28 real ones arrived with their module-// waves (P5-P8). Public, as a liveness probe has to be.+// The one procedure `rpc.router.ts` mounts before the first real module+// lands — proves the tRPC surface composes end to end. Public, as a liveness+// probe has to be.//-// R2: no frontend caller exists for this procedure, and by the letter of the-// rule a health module is routes-only. Left in place — see the M15-111 report —-// because `../../rpc.router.test.ts:16-34` pins this exact procedure ("the-// composed appRouter serves the health procedure", asserting a 200 from-// `/trpc/health.live`), and that file is outside this module's scope to edit.+// No frontend caller exists for this procedure, and by the letter of the+// module rule a health module would be routes-only. Left in place because+// `rpc.router.test.ts` pins this exact procedure ("the composed appRouter+// serves the health procedure", asserting a 200 from `/trpc/health.live`),+// which is outside this module's scope to edit.import { createTRPCRouter, publicProcedure } from '../../rpc/base';export const healthRouter = createTRPCRouter({diff --git a/packages/core/src/modules/health/src/readiness.test.ts b/packages/core/src/modules/health/src/readiness.test.tsindex 4f9a4e049..1cb02f89c 100644--- a/packages/core/src/modules/health/src/readiness.test.ts+++ b/packages/core/src/modules/health/src/readiness.test.ts@@ -14,8 +14,8 @@ test('no events consumer on this instance skips the heartbeat check', () => {expect(evaluateReadiness({shuttingDown: false,- // V1 left the heartbeat disabled on instances with no events worker,- // whose lastActivityAt then never moves off boot time.+ // An instance with no events consumer has the heartbeat disabled,+ // since lastActivityAt then never moves off boot time.heartbeat: { enabled: false, lastActivityAt: 0 },now: NOW,})diff --git a/packages/core/src/modules/health/src/readiness.ts b/packages/core/src/modules/health/src/readiness.tsindex aba6ef422..d3fbae7e5 100644--- a/packages/core/src/modules/health/src/readiness.ts+++ b/packages/core/src/modules/health/src/readiness.ts@@ -1,15 +1,14 @@-// V1's `/healthz/ready` decision, lifted out of the express handler-// (apps/worker/src/index.ts) so it can be asserted without a server.+// The `/healthz/ready` decision, kept pure so it can be asserted without a+// server.//// Shallow + shutdown-aware, and — only where this process runs the events-// consumer — heartbeat-aware. V1 skipped the heartbeat check on instances-// with no events worker; V2 keeps that by leaving `enabled` false unless the-// role actually started the consumer.+// consumer — heartbeat-aware. `enabled` stays false unless the role actually+// started the consumer, so an instance with no events worker never fails+// readiness on a heartbeat that was never real.import { getEventsHeartbeat } from '../../ingest/src/heartbeat';import { isShuttingDown } from './shutdown';-/** V1's threshold (apps/worker/src/index.ts `EVENTS_HEARTBEAT_STALE_MS`). */export const EVENTS_HEARTBEAT_STALE_MS = 60_000;export type ReadinessResult =diff --git a/packages/core/src/modules/import/import.jobs.ts b/packages/core/src/modules/import/import.jobs.tsindex cd725b5ad..911278c5d 100644--- a/packages/core/src/modules/import/import.jobs.ts+++ b/packages/core/src/modules/import/import.jobs.ts@@ -6,8 +6,8 @@//// Core's own worker has no live BullMQ job to hand `updateImportStatus` for// progress reporting (see import.service.ts's `ImportJobProgress` header), so-// this handler runs with the no-op default — inert until ADR-007's P9 worker-// cutover, same as gsc/cohort/insight's job handlers today.+// this handler runs with the no-op default — inert until the worker cutover,+// same as gsc/cohort/insight's job handlers today.import { z } from 'zod';import { defineJob } from '../../jobs/define';diff --git a/packages/core/src/modules/import/import.rpc.ts b/packages/core/src/modules/import/import.rpc.tsindex 524e9f2a9..80c11c7f2 100644--- a/packages/core/src/modules/import/import.rpc.ts+++ b/packages/core/src/modules/import/import.rpc.ts@@ -3,11 +3,6 @@// only sees a TOP-LEVEL `projectId` / `organizationId`, so anything resolved// from another id needs its own.//-// V1's router has no compute-heavy or ClickHouse-touching logic to delegate (it-// is Prisma CRUD + a BullMQ enqueue, unlike gsc/cohort), so-// packages/trpc/src/routers/import.ts stays completely unmodified — there is-// nothing here for it to delegate to.-//// The per-project access ladder itself is bound once, in auth.service.ts; every// procedure here reaches it through `ctx.services.auth`.@@ -116,7 +111,6 @@ export const importRouter = createTRPCRouter({level: 'write',});- // Only allow retry for failed importsif (importRecord.status !== 'failed') {throw new Error('Only failed imports can be retried');}diff --git a/packages/core/src/modules/ingest/src/bot-check.test.ts b/packages/core/src/modules/ingest/src/bot-check.test.tsindex dd65741e6..786a737eb 100644--- a/packages/core/src/modules/ingest/src/bot-check.test.ts+++ b/packages/core/src/modules/ingest/src/bot-check.test.ts@@ -1,6 +1,5 @@/**- * Tests for checkIngestBot — the bot filter V1 runs as `isBotHook` on ingestion- * (apps/api/src/hooks/is-bot.hook.test.ts, moved with M8-002).+ * Tests for checkIngestBot — the bot filter run on ingestion.** The key behaviour guarded here: requests authenticated with a client secret* (server-side SDKs) are never treated as bots, regardless of user agent. Botdiff --git a/packages/core/src/modules/ingest/src/deduplicate.ts b/packages/core/src/modules/ingest/src/deduplicate.tsindex e55ec058f..b77fa15ef 100644--- a/packages/core/src/modules/ingest/src/deduplicate.ts+++ b/packages/core/src/modules/ingest/src/deduplicate.ts@@ -1,12 +1,9 @@-// Ported from apps/api/src/utils/deduplicate.ts. The web SDK can fire the same-// event twice (pagehide + visibilitychange); a short-lived Redis lock keyed on-// the whole payload collapses the pair.+// The web SDK can fire the same event twice (pagehide + visibilitychange); a+// short-lived Redis lock keyed on the whole payload collapses the pair.import { getLock } from '@openpanel/redis';import fastJsonStableHash from 'fast-json-stable-hash';-// Live Redis key prefix — byte-identical to V1's, so a V1 and a V2 process-// deduplicate against the same locks during the rollout.const DEDUPLICATE_KEY_PREFIX = 'fastify:deduplicate:';const DEDUPLICATE_TTL_MS = 100;diff --git a/packages/core/src/modules/ingest/src/heartbeat.ts b/packages/core/src/modules/ingest/src/heartbeat.tsindex ae3c11842..076d3005f 100644--- a/packages/core/src/modules/ingest/src/heartbeat.ts+++ b/packages/core/src/modules/ingest/src/heartbeat.ts@@ -1,9 +1,8 @@-// The events consumer-loop heartbeat, ported verbatim from-// apps/worker/src/utils/worker-heartbeat.ts (P9). It is what turns "the-// process is up" into "the Kafka consumer is still turning": the timestamp is-// refreshed on every kafkajs HEARTBEAT and after every handled batch-// (consumer.ts's `onActivity`), so a healthy loop refreshes it even with no-// traffic, and a wedged one goes stale.+// The events consumer-loop heartbeat. It is what turns "the process is up"+// into "the Kafka consumer is still turning": the timestamp is refreshed on+// every kafkajs HEARTBEAT and after every handled batch (consumer.ts's+// `onActivity`), so a healthy loop refreshes it even with no traffic, and a+// wedged one goes stale.//// Module state rather than a field on `AppDeps` because the readiness probe// and the consumer are on opposite sides of the process and neither owns thediff --git a/packages/core/src/modules/ingest/src/incoming-event.ts b/packages/core/src/modules/ingest/src/incoming-event.tsindex 1444c28b5..39972aa4c 100644--- a/packages/core/src/modules/ingest/src/incoming-event.ts+++ b/packages/core/src/modules/ingest/src/incoming-event.ts@@ -1,10 +1,9 @@// The Kafka topic payload and the producer signature over it.//-// This is a WIRE FORMAT, not an internal type: a rolling deploy overlaps a V1-// producer with a V2 consumer on the same topic, so it stays byte-compatible-// with V1's `EventsQueuePayloadIncomingEvent['payload']`. A leaf file, so-// both./kafka.ts's producer and the consumer can name the payload without-// reaching into the ingest service.+// This is a WIRE FORMAT, not an internal type: it must stay byte-compatible+// across a rolling deploy where two producer/consumer versions overlap on the+// same topic. A leaf file, so both./kafka.ts's producer and the consumer can+// name the payload without reaching into the ingest service.import type { parseUserAgent } from '@openpanel/shared/server';import type { GeoLocation } from '../../../clients/geo';@@ -12,8 +11,9 @@ import type { ITrackPayload } from '../ingest.constants';export interface IncomingEventPayload {// Minted by the producer (/track, /event) so a Kafka redelivery becomes an- // identical-id row instead of a new one. Optional on the wire: a V1- // producer omits it and a V1 consumer ignores it.+ // identical-id row instead of a new one. Optional on the wire, for+ // compatibility with producers and consumers from before this field+ // existed.id?: string;projectId: string;event: ITrackPayload & {diff --git a/packages/core/src/modules/ingest/src/producer-errors.test.ts b/packages/core/src/modules/ingest/src/producer-errors.test.tsindex 65fce21ae..af50d0929 100644--- a/packages/core/src/modules/ingest/src/producer-errors.test.ts+++ b/packages/core/src/modules/ingest/src/producer-errors.test.ts@@ -1,8 +1,7 @@/**- * The producer's fatal-error classification, split out of `kafka.ts` with- * M16-002's batching. Only these failures invalidate the idempotent producer's- * PID/sequence state; everything else must be retried against the SAME producer- * rather than silently rebuilding it.+ * The producer's fatal-error classification. Only these failures invalidate+ * the idempotent producer's PID/sequence state; everything else must be+ * retried against the SAME producer rather than silently rebuilding it.*/import { describe, expect, mock, test } from 'bun:test';diff --git a/packages/core/src/modules/ingest/src/producer-tuning.test.ts b/packages/core/src/modules/ingest/src/producer-tuning.test.tsindex 6c316188c..ee0095eb6 100644--- a/packages/core/src/modules/ingest/src/producer-tuning.test.ts+++ b/packages/core/src/modules/ingest/src/producer-tuning.test.ts@@ -1,8 +1,8 @@/**- * ADR-023's decision, expressed as a test: batching is ON at the shipped- * defaults (size 25, linger 5 ms) and `maxInFlightRequests` stays 1. There are- * no fallbacks left to test — the three knobs are required `KafkaConfig`- * fields, so a config that omits one does not compile.+ * Batching is ON at the shipped defaults (size 25, linger 5 ms) and+ * `maxInFlightRequests` stays 1. There are no fallbacks left to test — the+ * three knobs are required `KafkaConfig` fields, so a config that omits one+ * does not compile.*/import { describe, expect, test } from 'bun:test';diff --git a/packages/core/src/modules/ingest/src/producer-tuning.ts b/packages/core/src/modules/ingest/src/producer-tuning.tsindex ad039a4b0..6be48d146 100644--- a/packages/core/src/modules/ingest/src/producer-tuning.ts+++ b/packages/core/src/modules/ingest/src/producer-tuning.ts@@ -1,5 +1,4 @@-// The Kafka producer's throughput knobs (turned on by ADR-023), resolved in one-// place.+// The Kafka producer's throughput knobs, resolved in one place.//// The three fields are required members of `KafkaConfig`// (`packages/core/src/config.ts`): the config loader always sets them, so there@@ -15,7 +14,7 @@ export interface ResolvedProducerTuning {maxInFlight: number;batchSize: number;lingerMs: number;- /** False keeps the pre-ADR-023 path: one message per awaited `send()`. */+ /** False keeps the unbatched path: one message per awaited `send()`. */batchingEnabled: boolean;}diff --git a/packages/core/src/modules/insight/insight.jobs.test.ts b/packages/core/src/modules/insight/insight.jobs.test.tsindex 178e332af..a63e45cf2 100644--- a/packages/core/src/modules/insight/insight.jobs.test.ts+++ b/packages/core/src/modules/insight/insight.jobs.test.ts@@ -236,9 +236,9 @@ test('weeklyDigest delegates to sendWeeklyDigests', async () => {expect(called).toBe(true);});-// Byte-identity with the ids/cadences schedulers.test.ts's golden snapshot pins-// (apps/worker/src/boot-cron.ts). The cadences now live on the jobs themselves,-// so this reads them straight off the registry.+// Byte-identity with the ids/cadences schedulers.test.ts's golden snapshot+// pins. The cadences now live on the jobs themselves, so this reads them+// straight off the registry.test('the insight cron fragment carries V1 ids and cadences unchanged', () => {expect(queues.cron.jobs.insightsDaily.cron).toEqual({pattern: '0 2 * * *',diff --git a/packages/core/src/modules/insight/insight.jobs.ts b/packages/core/src/modules/insight/insight.jobs.tsindex 915a601d1..850798c6e 100644--- a/packages/core/src/modules/insight/insight.jobs.ts+++ b/packages/core/src/modules/insight/insight.jobs.ts@@ -1,8 +1,6 @@-// `insightsProject` is this module's own queue (`insights` in the registry —-// ADR-005's registry key). `insightsDaily` / `insightCleanup` / `weeklyDigest`-// are cron fragments, spread into the ONE `cron` queue by jobs.registry.ts.-// Scheduler ids and cadences are V1's, unchanged-// (apps/worker/src/boot-cron.ts).+// `insightsProject` is this module's own queue (`insights` in the registry).+// `insightsDaily` / `insightCleanup` / `weeklyDigest` are cron fragments,+// spread into the ONE `cron` queue by jobs.registry.ts.import { z } from 'zod';import { defineJob } from '../../jobs/define';@@ -25,8 +23,7 @@ export const insightQueueJobs = {/** This module's fragment of the `cron` queue's jobs. */export const insightCronJobs = {// Fans out one `insightsProject` job per eligible project. Jobs are- // deduplicated by a per-day, per-project jobId — matches V1- // (apps/worker/src/jobs/insights.ts).+ // deduplicated by a per-day, per-project jobId.insightsDaily: defineJob({payload: z.null(),cron: { pattern: '0 2 * * *' },diff --git a/packages/core/src/modules/insight/src/narrative.ts b/packages/core/src/modules/insight/src/narrative.tsindex 46b352be6..9e2663a2d 100644--- a/packages/core/src/modules/insight/src/narrative.ts+++ b/packages/core/src/modules/insight/src/narrative.ts@@ -1,5 +1,3 @@-// Ported from @openpanel/ai (dissolved into core — M4-005).-//// Weekly-digest narrative: one short OpenAI call that turns a project's// week-over-week stats + notable insights into a friendly intro paragraph.// Structured output (a single `narrative` string) reuses the same reliablediff --git a/packages/core/src/modules/integration/integration.jobs.ts b/packages/core/src/modules/integration/integration.jobs.tsindex 729b29d12..593a8999d 100644--- a/packages/core/src/modules/integration/integration.jobs.ts+++ b/packages/core/src/modules/integration/integration.jobs.ts@@ -1,8 +1,5 @@-// ADR-005's acceptance note gives `flushExports` to this module; the schedule-// moved onto the job at ADR-021.-//// `flushExports` is this module's fragment of the ONE `cron` queue's jobs,-// spread into jobs.registry.ts. Scheduler id and cadence are V1's, unchanged.+// spread into jobs.registry.ts.import { z } from 'zod';import { defineJob } from '../../jobs/define';diff --git a/packages/core/src/modules/integration/src/object-store/index.ts b/packages/core/src/modules/integration/src/object-store/index.tsindex 2938f6de1..ef847912b 100644--- a/packages/core/src/modules/integration/src/object-store/index.ts+++ b/packages/core/src/modules/integration/src/object-store/index.ts@@ -1,5 +1,3 @@-// Ported from @openpanel/integrations (dissolved into core — M4-005).-export { createGCSAdapter, GCSAdapter } from './gcs-adapter';export { createS3Adapter, S3Adapter } from './s3-adapter';export type {diff --git a/packages/core/src/modules/integration/src/safe-fetcher.ts b/packages/core/src/modules/integration/src/safe-fetcher.tsindex 5e888924e..13d8008e3 100644--- a/packages/core/src/modules/integration/src/safe-fetcher.ts+++ b/packages/core/src/modules/integration/src/safe-fetcher.ts@@ -1,5 +1,3 @@-// Ported from @openpanel/integrations (dissolved into core — M4-005).-import { safeFetch } from '@openpanel/shared/server';import type { WebhookFetcher } from '../../../clients/integrations/fetcher';diff --git a/packages/core/src/modules/mcp/src/tools/analytics/profiles.test.ts b/packages/core/src/modules/mcp/src/tools/analytics/profiles.test.tsindex 0917746f6..bff659d69 100644--- a/packages/core/src/modules/mcp/src/tools/analytics/profiles.test.ts+++ b/packages/core/src/modules/mcp/src/tools/analytics/profiles.test.ts@@ -34,8 +34,8 @@ beforeAll(async () => {({ findProfilesCore } = await import('../../../../profile/profile.service'));});-// Since M7-002 the service hands ClickHouse a `sql` fragment: the text carries-// `{pN:Type}` placeholders and every value travels in params.+// The service hands ClickHouse a `sql` fragment: the text carries `{pN:Type}`+// placeholders and every value travels in params.function captured(): { query: string; params: Record<string, unknown> } {const call = chQuery.mock.calls[0]?.[0];return {diff --git a/packages/core/src/modules/misc/misc.jobs.ts b/packages/core/src/modules/misc/misc.jobs.tsindex e7e51b3fa..7433add88 100644--- a/packages/core/src/modules/misc/misc.jobs.ts+++ b/packages/core/src/modules/misc/misc.jobs.ts@@ -1,15 +1,14 @@// `ping` is this module's fragment of the ONE `cron` queue's jobs: declared// here and spread into jobs.registry.ts, same shape as organization.jobs.ts's-// `delete`. Its `cron` is explicitly `null` (ADR-021's on-demand state, not-// "always scheduled") — `PING_SCHEDULE` in jobs/schedulers.ts adds it-// separately, conditionally on `SELF_HOSTED && production`, because it is the-// one scheduler that isn't always-on.+// `delete`. Its `cron` is explicitly `null` (on-demand, not "always+// scheduled") — `PING_SCHEDULE` in jobs/schedulers.ts adds it separately,+// conditionally on `SELF_HOSTED && production`, because it is the one+// scheduler that isn't always-on.import { z } from 'zod';import { defineJob } from '../../jobs/define';import { type DataHealthDb, runDataHealthCron } from './src/data-health';-/** Daily 07:30 UTC — V1's cadence (apps/worker/src/boot-cron.ts). */const DATA_HEALTH_CRON = '30 7 * * *';/** This module's fragment of the `cron` queue's jobs. */diff --git a/packages/core/src/modules/misc/misc.routes.ts b/packages/core/src/modules/misc/misc.routes.tsindex 781a0ea63..c46fc54b3 100644--- a/packages/core/src/modules/misc/misc.routes.ts+++ b/packages/core/src/modules/misc/misc.routes.ts@@ -1,8 +1,3 @@-// Ported from apps/api/src/routes/misc.router.ts +-// apps/api/src/controllers/misc.controller.ts. V1's Fastify router stays the-// LIVE route (DELEGATE PATTERN) and calls the same misc.service.ts functions-// this file does.-//// `GET /misc/og/clear` and `GET /misc/favicon/clear` are deliberately absent:// nothing depends on them.diff --git a/packages/core/src/modules/misc/src/image-proxy.test.ts b/packages/core/src/modules/misc/src/image-proxy.test.tsindex 47d622082..e97223365 100644--- a/packages/core/src/modules/misc/src/image-proxy.test.ts+++ b/packages/core/src/modules/misc/src/image-proxy.test.ts@@ -1,5 +1,3 @@-// Ported from apps/api/src/utils/image-proxy.test.ts.-import { describe, expect, it } from 'bun:test';import sharp from 'sharp';import {diff --git a/packages/core/src/modules/notification/notification.rpc.ts b/packages/core/src/modules/notification/notification.rpc.tsindex 07d03b2bf..c18570c4f 100644--- a/packages/core/src/modules/notification/notification.rpc.ts+++ b/packages/core/src/modules/notification/notification.rpc.ts@@ -3,10 +3,9 @@// only sees a TOP-LEVEL `projectId` / `organizationId`, so anything resolved// from another id needs its own.//-// `list`/`rules` have no access check here either — same gap V1's router has-// (ported verbatim, not fixed; see notification.service.ts's header for why-// `deleteRule` and `createOrUpdateRule` re-check access against the *existing*-// rule's project, not just the input's).+// `list`/`rules` have no access check here either. `deleteRule` and+// `createOrUpdateRule` re-check access against the *existing* rule's project,+// not just the input's.//// The permission ladder itself is bound once, in auth.service.ts; every// procedure here reaches it through `ctx.services.auth`.diff --git a/packages/core/src/modules/onboarding/onboarding.jobs.test.ts b/packages/core/src/modules/onboarding/onboarding.jobs.test.tsindex 67f209e25..4a0aa31a4 100644--- a/packages/core/src/modules/onboarding/onboarding.jobs.test.ts+++ b/packages/core/src/modules/onboarding/onboarding.jobs.test.ts@@ -123,9 +123,8 @@ test('onboarding does not log when the cron is a self-hosted no-op', async () =>expect(logged).toEqual([]);});-// Byte-identity with the id/cadence schedulers.test.ts's golden snapshot pins-// (apps/worker/src/boot-cron.ts). The cadence now lives on the job itself, so-// this reads it straight off the registry.+// The cadence lives on the job itself, so this reads it straight off the+// registry.test('the onboarding cron fragment carries V1 id and cadence unchanged', () => {expect(queues.cron.jobs.onboarding.cron).toEqual({pattern: '0 * * * *',diff --git a/packages/core/src/modules/onboarding/onboarding.jobs.ts b/packages/core/src/modules/onboarding/onboarding.jobs.tsindex e7a375138..b485dce5e 100644--- a/packages/core/src/modules/onboarding/onboarding.jobs.ts+++ b/packages/core/src/modules/onboarding/onboarding.jobs.ts@@ -1,6 +1,5 @@-// `onboarding` is this module's fragment of the ONE `cron` queue's jobs, spread-// into jobs.registry.ts. Scheduler id and cadence are V1's, unchanged-// (apps/worker/src/boot-cron.ts) — same shape as organization.jobs.ts.+// `onboarding` is this module's fragment of the ONE `cron` queue's jobs,+// spread into jobs.registry.ts — same shape as organization.jobs.ts.import { z } from 'zod';import { defineJob } from '../../jobs/define';diff --git a/packages/core/src/modules/organization/organization.jobs.test.ts b/packages/core/src/modules/organization/organization.jobs.test.tsindex 445fed302..91506ce0c 100644--- a/packages/core/src/modules/organization/organization.jobs.test.ts+++ b/packages/core/src/modules/organization/organization.jobs.test.ts@@ -109,9 +109,9 @@ test('delete delegates to runDeleteCron', async () => {expect(called).toBe(true);});-// Byte-identity with the id/cadence schedulers.test.ts's golden snapshot pins-// (apps/worker/src/boot-cron.ts). The cadences now live on the jobs themselves,-// so this reads them straight off the registry.+// Byte-identity with schedulers.test.ts's golden snapshot pins. The cadences+// now live on the jobs themselves, so this reads them straight off the+// registry.test('the organization cron fragment carries V1 id and cadence unchanged', () => {expect(queues.cron.jobs.delete.cron).toEqual({ pattern: '0 * * * *' });expect(queues.cron.jobs.windDown.cron).toEqual({ pattern: '0 * * * *' });diff --git a/packages/core/src/modules/organization/organization.rpc.ts b/packages/core/src/modules/organization/organization.rpc.tsindex 4d49d9b57..79870365f 100644--- a/packages/core/src/modules/organization/organization.rpc.ts+++ b/packages/core/src/modules/organization/organization.rpc.ts@@ -6,9 +6,8 @@// The organization-admin ladder itself is bound once, in auth.service.ts; every// procedure here reaches it through `ctx.services.auth`.//-// `getInvite` still drops V1's rate limiting: `rateLimitMiddleware` did NOT-// move with M11-001. `createRateLimitMiddleware` in rpc/base.ts is the seam-// that will carry it.+// `getInvite` has no rate limiting yet. `createRateLimitMiddleware` in+// rpc/base.ts is the seam that will carry it.import { z } from 'zod';import {diff --git a/packages/core/src/modules/profile/src/dates.ts b/packages/core/src/modules/profile/src/dates.tsindex a53929669..26f81dff3 100644--- a/packages/core/src/modules/profile/src/dates.ts+++ b/packages/core/src/modules/profile/src/dates.ts@@ -5,7 +5,7 @@const CLICKHOUSE_DATE_SUFFIX = /(\.\d{3})?Z+$/;-/** `YYYY-MM-DD HH:mm:ss` in UTC — what V1 sent as a date literal. */+/** `YYYY-MM-DD HH:mm:ss` in UTC — ClickHouse's date literal format. */export function formatClickhouseDate(date: Date | string): string {return new Date(date).toISOString()diff --git a/packages/core/src/modules/profile/src/filter-clauses.ts b/packages/core/src/modules/profile/src/filter-clauses.tsindex 999840d48..cb763e7e3 100644--- a/packages/core/src/modules/profile/src/filter-clauses.ts+++ b/packages/core/src/modules/profile/src/filter-clauses.ts@@ -1,10 +1,10 @@// The ONE place this module splices pre-compiled filter SQL.//-// `buildFilterWhere` (../../chart/src/table-filter-where.ts) is V1's+// `buildFilterWhere` (../../chart/src/table-filter-where.ts) is the// sessions/profiles/events-table filter compiler; it returns bound-// `SqlFragment`s since M12-003, as `getEventFiltersWhereClause`-// (../../chart/src/filter-where.ts) has since M12-002. Nothing is bridged any-// more — this file only assembles what the compiler already produced.+// `SqlFragment`s, as does `getEventFiltersWhereClause`+// (../../chart/src/filter-where.ts). Nothing is bridged any more — this file+// only assembles what the compiler already produced.import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';diff --git a/packages/core/src/modules/profile/src/sql.test.ts b/packages/core/src/modules/profile/src/sql.test.tsindex ed35d1a83..1fa20d3f6 100644--- a/packages/core/src/modules/profile/src/sql.test.ts+++ b/packages/core/src/modules/profile/src/sql.test.ts@@ -1,8 +1,7 @@// Shape tests for the profile module's fragments: every user value binds as a-// `{pN:Type}` parameter (nothing is interpolated), the optional clauses toggle-// exactly on V1's conditions, and `sql.id` refuses anything off the column-// whitelist. Result-set equivalence against V1 was proven per query on the-// local prod-copy (M7-002 report), not here — these run offline.+// `{pN:Type}` parameter (nothing is interpolated), and `sql.id` refuses+// anything off the column whitelist. These run offline, so they assert the+// rendered statement and its params, never a result set.import { describe, expect, test } from 'bun:test';import { sql } from '@openpanel/db/src/clickhouse/sql';diff --git a/packages/core/src/modules/project/project.routes.ts b/packages/core/src/modules/project/project.routes.tsindex d9eb535d0..25aa09554 100644--- a/packages/core/src/modules/project/project.routes.ts+++ b/packages/core/src/modules/project/project.routes.ts@@ -1,16 +1,11 @@-// The /manage/projects REST surface. V1's Fastify controller-// (apps/api/src/controllers/manage.controller.ts) stays the LIVE route-// (DELEGATE PATTERN) and delegates its CRUD bodies to project.service.ts's-// createProjectForOrganization/updateProjectForOrganization/etc — the same-// functions this route calls. Response envelopes (`{ data }` / `{ success }`)-// match V1's `reply.send(...)` shape exactly (byte-unchanged URL surface).+// The /manage/projects REST surface: root-only project CRUD, delegating to+// project.service.ts's create/update functions.//// NAMED GAP, same as import.routes.ts: this route is not yet reachable.-// `authenticateClient` (http/client-auth.ts) is a P8 stub that always returns-// null, so `clientAuth` 401s every request until it is filled in; main.ts also-// does not mount `publicApiRoutes` until a real `AppDeps` exists. `allow:-// ['root']` mirrors V1's rule (utils/auth.ts's `validateManageRequest`: only-// root clients may manage resources).+// `authenticateClient` (http/client-auth.ts) is a stub that always returns+// null, so `clientAuth` 401s every request until it is filled in; main.ts+// also does not mount `publicApiRoutes` until a real `AppDeps` exists.+// `allow: ['root']` restricts project management to root clients.import { z } from 'zod';import { defineRoutes } from '../../http/define';diff --git a/packages/core/src/modules/realtime/realtime.rpc.test.ts b/packages/core/src/modules/realtime/realtime.rpc.test.tsindex 2b9011680..8bdc7bbeb 100644--- a/packages/core/src/modules/realtime/realtime.rpc.test.ts+++ b/packages/core/src/modules/realtime/realtime.rpc.test.ts@@ -1,8 +1,8 @@// Only the "is anyone logged in" boundary is exercised here — no database. The-// query bodies run on `deps.ch` (M12-005: statically imported `sql` fragments,-// no @openpanel/db client anywhere in the module); wiring this router-// end-to-end against a real ClickHouse is P6's (protectedProcedure) job, not-// this one's — see realtime.rpc.ts's header. Same shape as cohort.rpc.test.ts.+// query bodies run on `deps.ch` (statically imported `sql` fragments, no+// @openpanel/db client anywhere in the module); wiring this router end-to-end+// against a real ClickHouse is protectedProcedure's job, not this one's — see+// realtime.rpc.ts's header. Same shape as cohort.rpc.test.ts.import { expect, test } from 'bun:test';import { stubHttpCtx } from '../../../test/rpc-fixtures';@@ -18,8 +18,8 @@ const COOKIE_OPTIONS: CookieOptions = {path: '/',};-// EMPTY_SESSION's shape (packages/db/src/services/auth-session.service.ts) —-// `TrpcContext.session` is never literally `null`, only its `userId` is.+// EMPTY_SESSION's shape matters: `TrpcContext.session` is never literally+// `null`, only its `userId` is.const EMPTY_SESSION = { session: null, user: null, userId: null };async function anonCaller() {diff --git a/packages/core/src/modules/reference/reference.constants.ts b/packages/core/src/modules/reference/reference.constants.tsindex 44f519c8f..ad6c21ee9 100644--- a/packages/core/src/modules/reference/reference.constants.ts+++ b/packages/core/src/modules/reference/reference.constants.ts@@ -1,5 +1,5 @@-// ADR-008 records two diverged `zCreateReference` copies in V1 as one of the-// two drift bugs the dissolution exists to prevent; this is now the only one.+// Two diverged `zCreateReference` copies were a drift bug this file exists to+// prevent; this is now the only one.import { z } from 'zod';diff --git a/packages/core/src/modules/reference/reference.rpc.ts b/packages/core/src/modules/reference/reference.rpc.tsindex e010952e8..9c3fec533 100644--- a/packages/core/src/modules/reference/reference.rpc.ts+++ b/packages/core/src/modules/reference/reference.rpc.ts@@ -7,8 +7,8 @@// requestId minted at the edge reaches the Postgres call.//// The permission ladder itself is bound once, in auth.service.ts; every-// procedure here reaches it through `ctx.services.auth`. `create` has no access-// check here either — same gap V1's router has (ported verbatim, not fixed).+// procedure here reaches it through `ctx.services.auth`. `create` has no+// access check here either — a known gap, not yet fixed.import { z } from 'zod';import {diff --git a/packages/core/src/modules/reference/reference.service.ts b/packages/core/src/modules/reference/reference.service.tsindex cbc533a62..c4bb11ce4 100644--- a/packages/core/src/modules/reference/reference.service.ts+++ b/packages/core/src/modules/reference/reference.service.ts@@ -1,9 +1,7 @@-// Every function takes `ServiceDeps` and reaches Postgres as `deps.db`. The-// `loadDb` / `loadDateService` / `loadOrganizationService` lazy loaders are-// gone: nothing here value-imports `@openpanel/db` or this package's own barrel-// any more (the Prisma row type below is `import type`, erased at runtime), so-// there is no import-time client — and no pino-pretty worker per test file —-// left to defer.+// Every function takes `ServiceDeps` and reaches Postgres as `deps.db`.+// Nothing here value-imports `@openpanel/db` or this package's own barrel (the+// Prisma row type below is `import type`, erased at runtime), so there is no+// import-time client — and no pino-pretty worker per test file — to defer.import type { Reference } from '@openpanel/db/src/prisma-client';import type { ServiceDeps, Services } from '../../services';@@ -48,9 +46,8 @@ export function getReferenceById(return deps.db.reference.findUnique({ where: { id } });}-/** Throws Prisma's own not-found error, same as V1's inline- * `findUniqueOrThrow` call sites — used by both routers' ownership lookup- * ahead of their own access check. */+/** Throws Prisma's own not-found error. Used by both routers' ownership+ * lookup ahead of their own access check. */export function getReferenceByIdOrThrow(deps: ServiceDeps,id: stringdiff --git a/packages/core/src/modules/report/report.service.test.ts b/packages/core/src/modules/report/report.service.test.tsindex 7ecd2c7c3..0ed23b0f5 100644--- a/packages/core/src/modules/report/report.service.test.ts+++ b/packages/core/src/modules/report/report.service.test.ts@@ -1,8 +1,8 @@/*** Unit tests for mergeGlobalFilters — the helper that combines report-level* global filters with each event series' own filters (AND semantics). Pure- * function, no ClickHouse/Postgres needed. Test. M10-003 moved the helper- * to./src/series.ts — see that file for why.+ * function, no ClickHouse/Postgres needed. See ./src/series.ts for the+ * helper itself.*/import { describe, expect, it } from 'bun:test';import type { IChartEventFilter, IChartEventItem } from './report.constants';diff --git a/packages/core/src/modules/report/src/chart-dates.ts b/packages/core/src/modules/report/src/chart-dates.tsindex 48efe3d2b..93e4ebad9 100644--- a/packages/core/src/modules/report/src/chart-dates.ts+++ b/packages/core/src/modules/report/src/chart-dates.ts@@ -1,7 +1,7 @@-// The two date helpers that read the report vocabulary. Split out of-// `shared/date.ts` at M15-009: they take `IChartRange` / `IReportInput`, which-// are this module's own constants, so a file in the bottom layer could not hold-// them. The generic Date/Luxon math they build on stays in `shared/date.ts`.+// The two date helpers that read the report vocabulary. They take+// `IChartRange` / `IReportInput`, which are this module's own constants, so a+// file in the bottom layer could not hold them. The generic Date/Luxon math+// they build on stays in `shared/date.ts`.import { DateTime } from '@openpanel/shared';import type { IChartRange, IReportInput } from '../report.constants';diff --git a/packages/core/src/modules/report/src/previous-metric.ts b/packages/core/src/modules/report/src/previous-metric.tsindex c6aa8b235..aaeba2997 100644--- a/packages/core/src/modules/report/src/previous-metric.ts+++ b/packages/core/src/modules/report/src/previous-metric.ts@@ -1,8 +1,7 @@-// The previous-period comparison a report card renders. Split out of-// `shared/math.ts` at M15-009: it returns `PreviousValue`, this module's own-// vocabulary, so it belongs to the report module rather than to the layer below-// every transport. The generic aggregates it is built on stay in-// `shared/math.ts`.+// The previous-period comparison a report card renders. It returns+// `PreviousValue`, this module's own vocabulary, so it belongs to the report+// module rather than to the layer below every transport. The generic+// aggregates it is built on stay in `shared/math.ts`.import { round } from '@openpanel/shared';import { isNil } from 'ramda';diff --git a/packages/core/src/modules/report/src/series.ts b/packages/core/src/modules/report/src/series.tsindex 27b6c786b..c91f9daaa 100644--- a/packages/core/src/modules/report/src/series.ts+++ b/packages/core/src/modules/report/src/series.ts@@ -1,9 +1,8 @@-// The two pure series helpers V1 kept on `reports.service`. They live here, not-// on report.service.ts, because the chart module needs them and-// report.service.ts imports the chart engine — a static import back would close-// a real cycle (report.service -> chart/funnel.service -> report.service).-// Nothing here touches a database, so both sides stay eager and neither needs a-// lazy loader.+// The two pure series helpers live here, not on report.service.ts, because+// the chart module needs them and report.service.ts imports the chart+// engine — a static import back would close a real cycle (report.service ->+// chart/funnel.service -> report.service). Nothing here touches a database,+// so both sides stay eager and neither needs a lazy loader.import type { IChartEventFilter, IChartEventItem } from '../report.constants';diff --git a/packages/core/src/modules/salt/salt.jobs.ts b/packages/core/src/modules/salt/salt.jobs.tsindex c97c0e510..2d896df2f 100644--- a/packages/core/src/modules/salt/salt.jobs.ts+++ b/packages/core/src/modules/salt/salt.jobs.ts@@ -1,6 +1,5 @@// `salt` is this module's fragment of the ONE `cron` queue's jobs, spread into-// jobs.registry.ts. Its schedule is now derived straight from `cron` below — id-// and cadence are V1's, unchanged (apps/worker/src/boot-cron.ts).+// jobs.registry.ts.import { z } from 'zod';import { defineJob } from '../../jobs/define';diff --git a/packages/core/src/modules/session/session.rpc.ts b/packages/core/src/modules/session/session.rpc.tsindex 2ff23853b..33dae33a6 100644--- a/packages/core/src/modules/session/session.rpc.ts+++ b/packages/core/src/modules/session/session.rpc.ts@@ -2,10 +2,6 @@// input parser. The explicit checks in the handlers below stay: `enforceAccess`// only sees a TOP-LEVEL `projectId` / `organizationId`, so anything resolved// from another id needs its own.-//-// V1's file also exported `encodeCursor` / `decodeCursor`; nothing imports them-// and `shared/pagination.ts` already has the generic pair, so they were not-// ported.import { z } from 'zod';import { createTRPCRouter, protectedProcedure } from '../../rpc/base';diff --git a/packages/core/src/modules/session/src/dates.ts b/packages/core/src/modules/session/src/dates.tsindex bcfcf8cb5..d6f734889 100644--- a/packages/core/src/modules/session/src/dates.ts+++ b/packages/core/src/modules/session/src/dates.ts@@ -5,7 +5,7 @@const CLICKHOUSE_DATE_SUFFIX = /(\.\d{3})?Z+$/;-/** `YYYY-MM-DD HH:mm:ss` in UTC — what V1 sent as a date literal. */+/** `YYYY-MM-DD HH:mm:ss` in UTC — the date literal format ClickHouse expects. */export function formatClickhouseDate(date: Date | string): string {return new Date(date).toISOString()diff --git a/packages/core/src/modules/session/src/filter-clauses.ts b/packages/core/src/modules/session/src/filter-clauses.tsindex 3518e7770..6ce11b2e2 100644--- a/packages/core/src/modules/session/src/filter-clauses.ts+++ b/packages/core/src/modules/session/src/filter-clauses.ts@@ -1,10 +1,10 @@// The ONE place this module splices pre-compiled filter SQL.//-// `buildFilterWhere` (../../chart/src/table-filter-where.ts) is V1's+// `buildFilterWhere` (../../chart/src/table-filter-where.ts) is the// sessions/profiles/events-table filter compiler; it returns bound-// `SqlFragment`s since M12-003, as `getEventFiltersWhereClause`-// (../../chart/src/filter-where.ts) has since M12-002. Nothing is bridged any-// more — this file only assembles what the compiler already produced.+// `SqlFragment`s, same as `getEventFiltersWhereClause`+// (../../chart/src/filter-where.ts). Nothing is bridged any more — this file+// only assembles what the compiler already produced.import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';diff --git a/packages/core/src/modules/session/src/keys.ts b/packages/core/src/modules/session/src/keys.tsindex 3d82c8a2b..a8f4067e8 100644--- a/packages/core/src/modules/session/src/keys.ts+++ b/packages/core/src/modules/session/src/keys.ts@@ -1,6 +1,6 @@-// The Redis index the session buffer (packages/db/src/buffers/session-buffer.ts,-// moves at P8) maintains and the reaper/vacuum walk. Redefined here exactly as-// V1's reaper and vacuum redefine them — the buffer keeps its own copy and+// The Redis index the session buffer+// (packages/core/src/buffers/session-buffer.ts) maintains and the+// reaper/vacuum walk. Redefined here — the buffer keeps its own copy and// importing it would construct the ClickHouse client at import time./** Idle time after which a session is over; also the reaper's deadman default.diff --git a/packages/core/src/modules/session/src/sql.test.ts b/packages/core/src/modules/session/src/sql.test.tsindex bbf2bffee..9feedbec4 100644--- a/packages/core/src/modules/session/src/sql.test.ts+++ b/packages/core/src/modules/session/src/sql.test.ts@@ -1,8 +1,8 @@// Shape tests for the session module's fragments: every user value binds as a// `{pN:Type}` parameter (nothing is interpolated), the optional clauses toggle-// exactly on V1's conditions, and `sql.id` rejects a column outside the-// whitelist. Result-set equivalence against V1 was proven per query on the-// local prod-copy (M7-001 report), not here — these tests run offline.+// correctly, and `sql.id` rejects a column outside the whitelist. Result-set+// equivalence was proven per query against the local prod-copy separately —+// not here; these tests run offline.import { describe, expect, test } from 'bun:test';import { sql } from '@openpanel/db/src/clickhouse/sql';diff --git a/packages/core/src/modules/share/share.rpc.ts b/packages/core/src/modules/share/share.rpc.tsindex 4480ca374..374313b1b 100644--- a/packages/core/src/modules/share/share.rpc.ts+++ b/packages/core/src/modules/share/share.rpc.ts@@ -8,8 +8,7 @@//// The permission ladder itself is bound once, in auth.service.ts; every// procedure here reaches it through `ctx.services.auth`. `createOverview` has-// no in-handler check — the same gap V1's router has, ported verbatim, not-// fixed.+// no in-handler check — a known gap, not fixed.import { z } from 'zod';import {diff --git a/packages/core/src/modules/subscription/subscription.routes.ts b/packages/core/src/modules/subscription/subscription.routes.tsindex 5a884c086..c83ccf103 100644--- a/packages/core/src/modules/subscription/subscription.routes.ts+++ b/packages/core/src/modules/subscription/subscription.routes.ts@@ -4,14 +4,11 @@// RAW BYTES, deliberately: `validatePolarEvent` verifies Polar's signature over// the exact request body, so this handler reads `await request.text` and// declares no `body` schema — any parsing (JSON or otherwise) before the-// signature check breaks it. V1 gets the same raw bytes via-// `fastify-raw-body`'s `{ rawBody: true }` route config; this is the Elysia-// equivalent named in ADR-002's plugin substitutions ("raw body → `await-// request.text` in the one polar webhook handler").+// signature check breaks it.//// `parse: 'none'` is what makes that possible: Elysia parses the body before// the handler runs by default, and reading the consumed stream throws "Body-// already used" (which mounted this surface).+// already used".import { defineRoutes } from '../../http/define';diff --git a/packages/core/src/modules/tools/tools.routes.test.ts b/packages/core/src/modules/tools/tools.routes.test.tsindex 3ed9229a5..5d9f4e174 100644--- a/packages/core/src/modules/tools/tools.routes.test.ts+++ b/packages/core/src/modules/tools/tools.routes.test.ts@@ -1,9 +1,8 @@-// The `/tools` prefix came from `instance.register(toolsRouter, { prefix:-// '/tools' })` in V1's app.ts, over a router whose own urls were bare.-// `defineRoutes` has no prefix mechanism, so the port dropped the segment and-// both routes answered at the root — apps/public's own pages call-// `${API_URL}/tools/ip-lookup` and were 404ing. Nothing covered the path,-// which is why it slipped.+// The `/tools` prefix came from a wrapper that mounted the router under+// `/tools`, over a router whose own urls were bare. `defineRoutes` has no+// prefix mechanism, so the port dropped the segment and both routes answered+// at the root — apps/public's own pages call `${API_URL}/tools/ip-lookup`+// and were 404ing. Nothing covered the path, which is why it slipped.import { describe, expect, test } from 'bun:test';import { readFileSync } from 'node:fs';diff --git a/packages/core/src/modules/tools/tools.routes.ts b/packages/core/src/modules/tools/tools.routes.tsindex 064b82d9b..ac36c0ea5 100644--- a/packages/core/src/modules/tools/tools.routes.ts+++ b/packages/core/src/modules/tools/tools.routes.ts@@ -1,15 +1,9 @@-// Ported from apps/api/src/routes/tools.router.ts +-// apps/api/src/controllers/tools.controller.ts, calling the same-// src/site-checker.ts + src/ip-lookup.ts functions this file does. Mounted into-// publicApiRoutes since M9-004; both routes stay unauthenticated (V1's shape)-// and hidden from the OpenAPI document, matching V1's `schema: { hide: true }`.+// Both routes stay unauthenticated and hidden from the OpenAPI document,+// deliberately.//-// The `/tools` prefix is spelled out here. V1 got it from-// `instance.register(toolsRouter, { prefix: '/tools' })` (app.ts:386) over a-// router whose own urls were bare, and `defineRoutes` has no prefix mechanism —-// so the port dropped the segment and both routes answered at the root.-// apps/public's own pages call `${API_URL}/tools/ip-lookup` and-// `/tools/site-checker`, so they were 404ing.+// The `/tools` prefix is spelled out on each path since `defineRoutes` has no+// prefix mechanism; apps/public calls these URLs with the full+// `/tools/ip-lookup` and `/tools/site-checker` paths.import { z } from 'zod';import { defineRoutes } from '../../http/define';diff --git a/packages/core/src/rest.routes.test.ts b/packages/core/src/rest.routes.test.tsindex a86620605..9a16d4e89 100644--- a/packages/core/src/rest.routes.test.ts+++ b/packages/core/src/rest.routes.test.ts@@ -6,8 +6,8 @@ import { requestContext } from './http/context';import { registry } from './metrics';import { dashboardRoutes, opsRoutes, publicApiRoutes } from './rest.routes';-// The acceptance shape for ADR-007 decision 19: an app built from the mounts-// plus requestContext answers a real request, end to end.+// An app built from the mounts plus requestContext answers a real request,+// end to end.test('opsRoutes answers a liveness probe through requestContext', async () => {const { deps } = stubAppDeps();@@ -37,8 +37,8 @@ test('publicApiRoutes and dashboardRoutes compose, dashboardRoutes carrying gsc'expect(response.status).toBe(200);});-// The M3 gate: /metrics serves prometheus text exposition from THE core-// registry — not a route-local one, not the prom-client global default.+// /metrics serves prometheus text exposition from THE core registry — not a+// route-local one, not the prom-client global default.test('/metrics serves the one core registry, prometheus text exposition', async () => {const { deps } = stubAppDeps();const probeName = 'core_rest_routes_metrics_probe_total';@@ -61,11 +61,9 @@ test('/metrics serves the one core registry, prometheus text exposition', asyncregistry.removeSingleMetric(probeName);});-// V1 hides /healthz/live, /healthz/ready and /healthcheck from its OpenAPI-// document (apps/api/src/app.ts: `schema: { hide: true }` — liveness probes-// aren't public API); V2 ports that with `detail: { hide: true }`-// (health.routes.ts), which is what verification/golden/openapi's-// migrated-route gate pins /healthz to against V1's captured document.+// Liveness probes aren't public API: /healthz/live, /healthz/ready and+// /healthcheck are hidden from the OpenAPI document via `detail: { hide: true }`+// (health.routes.ts).test('/openapi.json hides both /healthz/live and /metrics', async () => {const { deps } = stubAppDeps();diff --git a/packages/core/src/rpc.router.ts b/packages/core/src/rpc.router.tsindex b059908ad..eafcd6e4c 100644--- a/packages/core/src/rpc.router.ts+++ b/packages/core/src/rpc.router.ts@@ -1,8 +1,5 @@// The one static composition point for every tRPC procedure this package-// serves. No `defineModule`, no filesystem discovery — adding a module's RPC-// half is one line here, which is what keeps `AppRouter` a real type (ADR-007-// decision 19). Only `health` exists so far; the 28 real routers land with-// their module waves (P5-P8).+// serves.import { chatRouter } from './modules/assistant/assistant.rpc';import { authRouter } from './modules/auth/auth.rpc';diff --git a/packages/core/src/rpc/rate-limit.test.ts b/packages/core/src/rpc/rate-limit.test.tsindex ef653a1a7..792dcb743 100644--- a/packages/core/src/rpc/rate-limit.test.ts+++ b/packages/core/src/rpc/rate-limit.test.ts@@ -31,7 +31,6 @@ describe('rate limit escalation', () => {});});-// V1's limits, procedure for procedure (packages/trpc/src/routers/auth.ts).const V1_AUTH_LIMITS: Record<string, { max: number; windowMs: number }> = {signUpEmail: { max: 5, windowMs: 60_000 },signInEmail: { max: 3, windowMs: 30_000 },diff --git a/packages/core/src/shared/als-session.ts b/packages/core/src/shared/als-session.tsindex 9d08c12fe..984d8293f 100644--- a/packages/core/src/shared/als-session.ts+++ b/packages/core/src/shared/als-session.ts@@ -4,8 +4,8 @@// transport may reach it.//// The ALS scopes a request's dashboard session id so anything downstream —-// today only the Prisma read-replica consistency extension ADR-012 retires —-// can read it without threading a parameter.+// today only the Prisma read-replica consistency extension — can read it+// without threading a parameter.import { AsyncLocalStorage } from 'node:async_hooks';diff --git a/packages/core/src/shared/ch-dates.parity.test.ts b/packages/core/src/shared/ch-dates.parity.test.tsindex 7403c612a..08fa83acb 100644--- a/packages/core/src/shared/ch-dates.parity.test.ts+++ b/packages/core/src/shared/ch-dates.parity.test.ts@@ -1,4 +1,4 @@-// Guards the second duplication M10-009 introduced: core owns its own copies of+// Guards the second duplication this creates: core owns its own copies of// @openpanel/db's ClickHouse date helpers (see ch-dates.ts's header for why),// and a divergence would show up as silently wrong date literals in a query// rather than as a failing test.diff --git a/packages/core/src/shared/ch-tables.parity.test.ts b/packages/core/src/shared/ch-tables.parity.test.tsindex ad44b7532..419cbf16d 100644--- a/packages/core/src/shared/ch-tables.parity.test.ts+++ b/packages/core/src/shared/ch-tables.parity.test.ts@@ -1,4 +1,4 @@-// Guards the one duplication M10-009 introduced: core owns its own copy of+// Guards the one duplication this creates: core owns its own copy of// @openpanel/db's `TABLE_NAMES` (see ch-tables.ts's header for why), and a// table added on one side only would otherwise be found by a failing query in// production rather than by CI.@@ -16,10 +16,10 @@ describe('ch-tables parity with @openpanel/db', () => {expect(TABLE_NAMES).toEqual(dbClient.TABLE_NAMES);});- // The cluster VERDICT is the config loader's since M15-006- // (`config.clickhouseClustered` = CLICKHOUSE_CLUSTER); @openpanel/db still- // reads it itself. Feeding db's verdict in is what makes this a parity check- // of the NAME derivation rather than of two env reads.+ // The cluster VERDICT is the config loader's (`config.clickhouseClustered` =+ // CLICKHOUSE_CLUSTER); @openpanel/db still reads it itself. Feeding db's+ // verdict in is what makes this a parity check of the NAME derivation+ // rather than of two env reads.it('derives the same mutation table name for the same verdict', () => {const clustered = dbClient.isClickhouseClustered();for (const name of Object.values(TABLE_NAMES)) {diff --git a/packages/core/src/shared/client-secret.ts b/packages/core/src/shared/client-secret.tsindex 0f1df3cf3..05211484e 100644--- a/packages/core/src/shared/client-secret.ts+++ b/packages/core/src/shared/client-secret.ts@@ -6,15 +6,15 @@ import {const ARGON2_PREFIX = '$argon2';-/** Client secrets are scrypt (`salt.hash`), the format V1 and the seed write. */+/** Client secrets are scrypt (`salt.hash`), the format the seed writes. */export function hashClientSecret(secret: string): Promise<string> {return hashScrypt(secret);}/**- * Reads both formats: scrypt, and the argon2 rows the ported client, project- * and onboarding services minted while they imported the user-password hasher- * by mistake. A malformed stored hash is a failed verification, never a 500 on+ * Reads both formats: scrypt, and the argon2 rows the client, project and+ * onboarding services minted while they imported the user-password hasher by+ * mistake. A malformed stored hash is a failed verification, never a 500 on* the ingest path.*/export async function verifyClientSecret(diff --git a/packages/core/src/shared/encryption.test.ts b/packages/core/src/shared/encryption.test.tsindex d8096b307..1426eab8d 100644--- a/packages/core/src/shared/encryption.test.ts+++ b/packages/core/src/shared/encryption.test.ts@@ -1,8 +1,8 @@// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// four workspaces explicitly and hasn't picked up the new one — so moving this+// file would take it out of every gate. Move it when that line can gain the+// filter.import { describe, expect, it } from 'bun:test';import {decrypt,diff --git a/packages/core/src/shared/errors.ts b/packages/core/src/shared/errors.tsindex 12bf4459c..f888f4feb 100644--- a/packages/core/src/shared/errors.ts+++ b/packages/core/src/shared/errors.ts@@ -1,6 +1,6 @@-// Ported from apps/api/src/utils/errors.ts. Transport-agnostic: HTTP, jobs and-// the Kafka consumer all throw and normalize through this, not through an-// rpc/-specific error type (see rpc/errors.ts for the TRPCError family).+// Transport-agnostic: HTTP, jobs and the Kafka consumer all throw and+// normalize through this, not through an rpc/-specific error type (see+// rpc/errors.ts for the TRPCError family).import { classifyDriverError } from './driver-errors';diff --git a/packages/core/src/shared/headers.ts b/packages/core/src/shared/headers.tsindex 73bba398a..12ab8a43d 100644--- a/packages/core/src/shared/headers.ts+++ b/packages/core/src/shared/headers.ts@@ -1,13 +1,13 @@// A lowercase header record — Fastify's `IncomingHttpHeaders`, or a `Headers`-// flattened with `Object.fromEntries`. The ingest path reads headers exactly as-// V1 read them, so no transport has to build a `Headers` from a raw record-// (which throws on a malformed name V1 simply ignored).+// flattened with `Object.fromEntries`. No transport has to build a real+// `Headers` object from a raw record, which throws on a malformed name where+// a plain record would not.//-// Moved down out of `modules/ingest/src/`. Both auth macros in `http/` convert-// Elysia's `Headers` here before anything else runs, and a transport may not-// deep-import a module's `src/`. The names keep the `Ingest` prefix because the-// record shape is the ingest wire contract; the three declarations are-// dependency-free and belong below every layer.+// Both auth macros in `http/` convert Elysia's `Headers` here before anything+// else runs, and a transport may not deep-import a module's `src/`. The names+// keep the `Ingest` prefix because the record shape is the ingest wire+// contract; the three declarations are dependency-free and belong below every+// layer.export type IngestHeaders = Record<string, string | string[] | undefined>;diff --git a/packages/core/src/shared/id.test.ts b/packages/core/src/shared/id.test.tsindex caad20cea..a225f82e6 100644--- a/packages/core/src/shared/id.test.ts+++ b/packages/core/src/shared/id.test.ts@@ -1,8 +1,8 @@-// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs-// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// Subject moved to @openpanel/shared; the suite did not follow it. Nothing+// runs a `test` script in packages/shared yet — the root `test` script names+// its four workspaces explicitly and root package.json was outside that+// move's scope — so moving this file would take it out of every gate. Move+// it when that line can gain the filter.import { describe, expect, test } from 'bun:test';import { generateId, shortId } from '@openpanel/shared';diff --git a/packages/core/src/shared/json.test.ts b/packages/core/src/shared/json.test.tsindex f792b75b7..0176fc847 100644--- a/packages/core/src/shared/json.test.ts+++ b/packages/core/src/shared/json.test.ts@@ -1,8 +1,7 @@-// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs-// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// Subject moved to @openpanel/shared; the suite did not follow it, since+// nothing runs a `test` script in packages/shared yet and the root `test`+// script names its four workspaces explicitly. Move this file once that+// script can include packages/shared.import { describe, expect, test } from 'bun:test';import { getSafeJson, getSuperJson, setSuperJson } from '@openpanel/shared';diff --git a/packages/core/src/shared/json.ts b/packages/core/src/shared/json.tsindex 61463a209..d9fb38406 100644--- a/packages/core/src/shared/json.ts+++ b/packages/core/src/shared/json.ts@@ -1,11 +1,10 @@-// A re-export seam, not an implementation: the JSON helpers moved to-// @openpanel/shared in M15-010, and every caller inside core imports them from-// there.+// A re-export seam, not an implementation: the JSON helpers live in+// @openpanel/shared, and every caller inside core imports them from there.//// This file survives for ONE importer: packages/db/src/clickhouse/client.ts// reaches `getSafeJson` by relative path across the package boundary// (`../../../core/src/shared/json`), because core depends on @openpanel/db and-// importing the core barrel there would invert that edge. That import is now-// pointed at the wrong package — the fix is one line in packages/db, which was-// outside M15-010's scope. Delete this file with it.+// importing the core barrel there would invert that edge. That import is+// pointed at the wrong package — the fix is one line in packages/db. Delete+// this file with it.export { getSafeJson, getSuperJson, setSuperJson } from '@openpanel/shared';diff --git a/packages/core/src/shared/object.test.ts b/packages/core/src/shared/object.test.tsindex d3ee86b61..969d11e6e 100644--- a/packages/core/src/shared/object.test.ts+++ b/packages/core/src/shared/object.test.ts@@ -1,8 +1,8 @@// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// four workspaces explicitly, and root package.json was out of scope for that+// move — so moving this file would take it out of every gate. Move it when+// that line can gain the filter.import { describe, expect, it } from 'bun:test';import { toDots } from '@openpanel/shared';diff --git a/packages/core/src/shared/pagination.ts b/packages/core/src/shared/pagination.tsindex 3fe53a5a4..fe82ef495 100644--- a/packages/core/src/shared/pagination.ts+++ b/packages/core/src/shared/pagination.ts@@ -1,7 +1,5 @@-// Two pagination shapes ported from V1's routers, generalized: numeric-page-// offsets (packages/trpc's reference.ts: `cursor ? cursor * 50 : 0`) and-// opaque keyset cursors (packages/trpc's session.ts encodeCursor/decodeCursor,-// generalized from its {createdAt, id} shape to any JSON-serializable cursor).+// Two pagination shapes: numeric-page offsets and opaque keyset cursors+// (generalized to any JSON-serializable cursor).export const DEFAULT_PAGE_SIZE = 50;diff --git a/packages/core/src/shared/safe-fetch.test.ts b/packages/core/src/shared/safe-fetch.test.tsindex ff29876e8..6276726ff 100644--- a/packages/core/src/shared/safe-fetch.test.ts+++ b/packages/core/src/shared/safe-fetch.test.ts@@ -1,8 +1,7 @@// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// four workspaces explicitly, so moving this file would take it out of every+// gate. Move it when that line can gain the filter.import { afterAll, beforeAll, describe, expect, it } from 'bun:test';import http from 'node:http';import type { AddressInfo } from 'node:net';diff --git a/packages/core/src/shared/slug.test.ts b/packages/core/src/shared/slug.test.tsindex 44dbd10b3..bfab1be54 100644--- a/packages/core/src/shared/slug.test.ts+++ b/packages/core/src/shared/slug.test.ts@@ -1,8 +1,8 @@// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// four workspaces explicitly and hasn't picked up the new one — so moving this+// file would take it out of every gate. Move it when that line can gain the+// filter.import { describe, expect, it } from 'bun:test';import { slug } from '@openpanel/shared';diff --git a/packages/core/src/shared/ssrf.test.ts b/packages/core/src/shared/ssrf.test.tsindex 4f5835c13..36d7ef84d 100644--- a/packages/core/src/shared/ssrf.test.ts+++ b/packages/core/src/shared/ssrf.test.ts@@ -1,8 +1,7 @@-// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs-// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// Subject moved to @openpanel/shared; the suite did not follow it. Nothing+// runs a `test` script in packages/shared yet — the root `test` script names+// its four workspaces explicitly — so moving this file would take it out of+// every gate. Move it when that line can gain the filter.import { describe, expect, it, mock } from 'bun:test';import {assertSafeUrl,diff --git a/packages/core/src/shared/try-catch.test.ts b/packages/core/src/shared/try-catch.test.tsindex 46a47756b..39ac8117c 100644--- a/packages/core/src/shared/try-catch.test.ts+++ b/packages/core/src/shared/try-catch.test.ts@@ -1,8 +1,8 @@-// Subject moved to @openpanel/shared; the suite did not follow it. Nothing runs-// a `test` script in packages/shared yet — the root `test` script names its-// four workspaces explicitly and root package.json was outside M15-010's scope-// — so moving this file would take it out of every gate. Move it when that line-// can gain the filter.+// Subject moved to @openpanel/shared; the suite did not follow it. Nothing+// runs a `test` script in packages/shared yet — the root `test` script names+// its four workspaces explicitly and root package.json was outside that+// move's scope — so moving this file would take it out of every gate. Move+// it when that line can gain the filter.import { describe, expect, test } from 'bun:test';import { tryCatch } from '@openpanel/shared';diff --git a/packages/core/test/preload.ts b/packages/core/test/preload.tsindex 5ff697bda..ccd0adcb5 100644--- a/packages/core/test/preload.ts+++ b/packages/core/test/preload.ts@@ -3,12 +3,9 @@// `preload` runs per test PROCESS, not once per run — bun test has no// `globalSetup` — so everything here must be idempotent and cheap.//-// The pins below are a safety property, not a convenience: they are the-// successor to vitest.shared.ts's "always point at local, ISOLATED test-// databases — never production, and never the application's own". A test must-// not be able to reach a real database because someone's .env happened to be-// loaded. Kept in step with test/databases.ts by hand — core does not import-// from the V1 root test directory.+// The pins below are a safety property, not a convenience: a test must not be+// able to reach a real database because someone's .env happened to be loaded.+// Kept in step with test/databases.ts by hand.process.env.DATABASE_URL ='postgresql://postgres:postgres@localhost:23432/openpanel_test?schema=public';process.env.CLICKHOUSE_URL = 'http://localhost:23123/openpanel_test';diff --git a/packages/core/test/service-deps.ts b/packages/core/test/service-deps.tsindex d472387f4..b698b0787 100644--- a/packages/core/test/service-deps.ts+++ b/packages/core/test/service-deps.ts@@ -40,7 +40,7 @@ function unavailable(name: string): never {throw new Error(`${name} is not built in this test`);}-/** The `services()` thunk every factory takes (ADR-022 R3). No suite here+/** The `services()` thunk every factory takes. No suite here* reaches a sibling, so calling it is a named error rather than a silently* half-built container; a suite that needs one passes its own thunk. */export function testServices(): () => Services {diff --git a/packages/db/scripts/ch-update-sessions-with-revenue.ts b/packages/db/scripts/ch-update-sessions-with-revenue.tsindex 6d88325f4..8f3abe048 100644--- a/packages/db/scripts/ch-update-sessions-with-revenue.ts+++ b/packages/db/scripts/ch-update-sessions-with-revenue.ts@@ -1,6 +1,6 @@// Local fixture script: give a couple of sessions per hour a random revenue.//-// Took it off `clix` (deleted with ADR-013 decision 21) and onto the `sql` tag.+// Took it off `clix` (since deleted) and onto the `sql` tag.// Both statements bind every value as a `{pN:Type}` param instead of splicing// it into the text, which is also what removes the hand-rolled `'${id}'`// quoting the ALTER used to do.diff --git a/packages/db/scripts/migrate-code.ts b/packages/db/scripts/migrate-code.tsindex 10a8b9de8..0847dda8f 100644--- a/packages/db/scripts/migrate-code.ts+++ b/packages/db/scripts/migrate-code.ts@@ -1,12 +1,11 @@// The shell for `src/code-migrations`. It reads the environment, the runner// does the work — the same split `apps/api/src/main.ts` and `config/env.ts`-// have, and what keeps every migration file free of `process.env` (which-// travelled with the directory in M15-204).+// have, and what keeps every migration file free of `process.env`.//-// `code-migrations` is not a conformance target (Carl's rulings): it lives in-// @openpanel/db, runs as a script with direct database access and no services,-// and copies the vocabulary it needs from core rather than importing it —-// isolation beats reuse.+// `code-migrations` is not a conformance target: it lives in @openpanel/db,+// runs as a script with direct database access and no services, and copies+// the vocabulary it needs from core rather than importing it — isolation+// beats reuse.import type { CodeMigrationEnv } from '../src/code-migrations/helpers';import { runCodeMigrations } from '../src/code-migrations/migrate';diff --git a/packages/db/src/code-migrations/helpers.test.ts b/packages/db/src/code-migrations/helpers.test.tsindex 9aae4f6c1..5337ad849 100644--- a/packages/db/src/code-migrations/helpers.test.ts+++ b/packages/db/src/code-migrations/helpers.test.ts@@ -1,4 +1,3 @@-// Ported from the redaction main #511 added to code-migrations/migrate.ts.import { describe, expect, it } from 'bun:test';import { redactConnectionUrls } from './helpers';diff --git a/packages/db/src/prisma-client.ts b/packages/db/src/prisma-client.tsindex 7f986dd46..67fc94fb2 100644--- a/packages/db/src/prisma-client.ts+++ b/packages/db/src/prisma-client.ts@@ -15,13 +15,12 @@ const getPrismaClient = () => {// emit: 'event' keeps the engine from writing prisma:error lines straight// to stderr, so they flow through pino to the OTLP pipeline instead.const client = new PrismaClient({- // Callsite-free error messages. V1 shipped a bundle, so Prisma could not- // resolve a call site and always produced the short- // `Invalid \`prisma.model.action()\` invocation:` form; V2 runs from- // source, where the default format would splice the file, the line and a- // source snippet into a message that reaches API clients verbatim (three- // golden error responses caught exactly that). `minimal` keeps V1's body- // and keeps our source layout out of a 500.+ // Callsite-free error messages: running from source (not a compiled+ // bundle), Prisma's default error format would splice the file, the line+ // and a source snippet into a message that reaches API clients verbatim+ // (three golden error responses caught exactly that). `minimal` keeps the+ // short `Invalid \`prisma.model.action()\` invocation:` form and keeps our+ // source layout out of a 500.errorFormat: 'minimal',log: [{ emit: 'event', level: 'error' },diff --git a/packages/db/src/services/access.service.ts b/packages/db/src/services/access.service.tsindex 4160f0949..ddd81daad 100644--- a/packages/db/src/services/access.service.ts+++ b/packages/db/src/services/access.service.ts@@ -1,13 +1,10 @@// The concrete project/organization/client access lookups live in// @openpanel/core now: packages/core/src/shared/access-lookups.ts.//-// Kept here as a deep-path-only re-export (NOT part of packages/db's index.ts-// barrel — that shrank to the final surface at M9-CLEANUP-001) solely because-// the controller's protected `verification/contracts/auth/-// group-b-project-access.mts` hard-imports this exact path-// ('packages/db/src/services/access.service.ts') to exercise ADR-011 benchmark-// 2's getProjectAccess golden table. Every real importer in this repo now-// reaches these functions through `@openpanel/core` directly.+// Kept here as a deep-path-only re-export (not part of packages/db's index.ts+// barrel) because this exact path is still imported directly, with no app+// boot at all. Every real importer in this repo now reaches these functions+// through `@openpanel/core` directly.export {canWriteProject,getClientAccess,diff --git a/packages/shared/src/date.ts b/packages/shared/src/date.tsindex 2caf38bb3..699c34192 100644--- a/packages/shared/src/date.ts+++ b/packages/shared/src/date.ts@@ -1,16 +1,9 @@-// Generic date helpers (ADR-007 shared/ layout: "date"). Pure Date/Luxon math,-// no ClickHouse or Postgres access.+// Generic date helpers: pure Date/Luxon math, no ClickHouse or Postgres+// access. This is the one place core re-exports luxon's DateTime from.//-// `DateTime` and `getTime` moved here from packages/common/src/date.ts, which-// was the workspace's only luxon declaration. This file is now the one place-// core re-exports luxon's DateTime from.-//-// `getDatesFromRange` and `getChartStartEndDate` left with the report-// vocabulary they read (`IChartRange`, `IReportInput`) — they are-// `packages/core/src/modules/report/src/chart-dates.ts` now.-//-// What was left knows nothing above it and nothing about the domain, so it is-// @openpanel/shared's.+// `getDatesFromRange` and `getChartStartEndDate` are not here: they read+// report vocabulary (`IChartRange`, `IReportInput`), so they live in+// `packages/core/src/modules/report/src/chart-dates.ts`.import { DateTime } from 'luxon';export { DateTime } from 'luxon';diff --git a/vitest.workspace.ts b/vitest.workspace.tsindex d89907da3..d69beaa38 100644--- a/vitest.workspace.ts+++ b/vitest.workspace.ts@@ -1,15 +1,9 @@/**- * The workspaces that still run on vitest.+ * The workspaces that still run on vitest: the two suites that have never had+ * their own `test` script or `vitest` devDependency and only ran because the+ * previous glob was `packages/*`.*- * Moved `packages/core`, `packages/db` and `apps/api` onto `bun test` and gave- * `apps/start` its own vitest config and `test` script, so all four run from- * their own package. What is left here is the two suites that have never had a- * `test` script or a `vitest` devDependency of their own and only ever ran- * because the previous glob was `packages/*`: `packages/redis/cachable.test.ts`- * (29 tests) and `packages/payments/src/subscription-state.test.ts` (35 tests).- *- * Both are outside M12-011's scope. This is an explicit list rather than a glob- * so that a new package does not silently join the vitest side of the split —- * the direction of travel is `bun test` ("Test split").+ * An explicit list rather than a glob, so a new package does not silently+ * join the vitest side of the split.*/export default ['packages/redis', 'packages/payments'];