@mastra/factory 0.28.0-alpha.14 → 0.28.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/dist/boards/board-writes.d.ts +3 -3
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +24 -20
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/project-boards.d.ts +20 -0
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +35 -11
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/registry.d.ts.map +1 -1
- package/dist/boards/registry.js +0 -3
- package/dist/boards/registry.js.map +1 -1
- package/dist/factory.d.ts +5 -2
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +8 -3
- package/dist/factory.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +24 -12
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js +5 -1
- package/dist/integrations/platform/jira/integration.js.map +1 -1
- package/dist/routes/boards.d.ts +2 -3
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +49 -14
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +25 -5
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +57 -20
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +17 -4
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +24 -4
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts +19 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.js +47 -2
- package/dist/storage/domains/work-items/legacy-review.js.map +1 -1
- package/dist/tools/sessions-state-processor.js +1 -1
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-boards.js","names":[],"sources":["../../src/boards/project-boards.ts"],"sourcesContent":["import type { InlineSkill } from '@mastra/core/skills';\nimport type { FactoryStorageOps } from '@mastra/core/storage';\n\nimport { findBoardSkillProblems } from '../skills/app-skills.js';\nimport type {\n BoardMigrationContext,\n StoredBoardInput,\n StoredBoardRecord,\n StoredBoardScope,\n StoredBoardsStorage,\n} from '../storage/domains/boards/base.js';\nimport { DEFAULT_INTAKE_ROUTE_ACTOR } from '../storage/domains/boards/base.js';\nimport type { RetiredAutomationSettings } from '../storage/domains/projects/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { LEGACY_REVIEW_BOARD } from '../storage/domains/work-items/legacy-review.js';\nimport { boardRegistryOf, createBoardRegistry, defaultBoards } from './registry.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { boardForWorkItem } from './semantics.js';\nimport { boardDefinitionOf, compileStoredBoard, mergeCodeBehaviour } from './stored-board.js';\nimport { BOARD_MIGRATIONS } from './work-migrations.js';\nimport { workSeedWithTriage } from './work-seeds.js';\nimport { workBoard } from './work.js';\n\nconst DEFAULT_RECHECK_MS = 1000;\n/** A row under the retired Review board's key is never served: the key is the Review board's alone. */\nconst RESERVED_REVIEW_ROW = `Stored board \"${LEGACY_REVIEW_BOARD}\" isn't served: the key is reserved for the retired Review board.`;\nconst PRELOAD_CONCURRENCY = 8;\n/** The phases every release seeded the Review board with; only runners and tools changed between them. */\nconst REVIEW_SEED_PHASES = boardDefinitionOf(reviewBoard).phases.map(({ key, name, kind }) => ({ key, name, kind }));\n\n/**\n * Whether `row` is the Review board as Factory seeded it: written once by Factory, never\n * revised, and shaped like the seed. The actor alone is not proof, as any caller can pass it.\n */\nfunction isUntouchedReviewSeed(row: StoredBoardRecord): boolean {\n if (row.revision !== 1 || row.createdBy !== DEFAULT_INTAKE_ROUTE_ACTOR) return false;\n if (row.updatedBy !== DEFAULT_INTAKE_ROUTE_ACTOR || row.name !== reviewBoard.name) return false;\n const phases = [...row.phases].sort((a, b) => a.position - b.position);\n return (\n phases.length === REVIEW_SEED_PHASES.length &&\n phases.every(\n (phase, index) =>\n phase.key === REVIEW_SEED_PHASES[index]!.key &&\n phase.name === REVIEW_SEED_PHASES[index]!.name &&\n phase.kind === REVIEW_SEED_PHASES[index]!.kind,\n )\n );\n}\nconst SNAPSHOT_ATTEMPTS = 3;\n\n/**\n * The creator Factory records on the Work board it stores in a project as the project is\n * created: that board is today's Work, and reset gives it back. Any other Work row Factory stored\n * is the one with Triage. Only Factory writes this id; a person's writes carry their user id.\n */\nexport const NEW_PROJECT_SEED_ACTOR = 'factory:new-project';\n\n/** Where a board in a project's catalog came from. */\nexport type BoardSourceKind = 'builtin' | 'app' | 'stored';\n\nexport interface StoredBoardDetails {\n source: BoardSourceKind;\n /** Stored boards, the built-in Work board and app boards can all be edited; the retired Review board can't. */\n editable: boolean;\n problems: string[];\n}\n\n/** A project's boards: the code boards plus its stored boards, and what to report about each board. */\nexport interface ProjectBoards {\n readonly registry: BoardRegistry;\n readonly details: ReadonlyMap<string, StoredBoardDetails>;\n /** Problems with stored boards that are left out of the registry. */\n readonly problems: readonly string[];\n}\n\nconst PROJECT_BOARD_SOURCE = Symbol('ProjectBoardSource');\n\n/**\n * Serves each project its boards. `load` is the async entry point that brings a project's\n * boards up to date; `forProject` is the sync read for code that already loaded the project.\n */\nexport interface ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE]: true;\n /** The code boards: built-in and app boards, served to every project as code built them. */\n readonly codeRegistry: BoardRegistry;\n load(scope: StoredBoardScope): Promise<BoardRegistry>;\n forProject(scope: StoredBoardScope): BoardRegistry;\n describe?(scope: StoredBoardScope): Promise<ProjectBoards>;\n}\n\n/** Accepts either a fixed registry (tests, standalone services) or a per-project source. */\nexport function toBoardSource(boards: BoardRegistry | ProjectBoardSource | undefined): ProjectBoardSource {\n const source = boards ?? createBoardRegistry();\n if (isBoardSource(source)) return source;\n return {\n [PROJECT_BOARD_SOURCE]: true,\n codeRegistry: source,\n load: async () => source,\n forProject: () => source,\n };\n}\n\nfunction isBoardSource(boards: BoardRegistry | ProjectBoardSource): boards is ProjectBoardSource {\n return PROJECT_BOARD_SOURCE in boards;\n}\n\ninterface CacheEntry {\n boards: ProjectBoards;\n version: string | null;\n reviewInUse: boolean;\n checkedAt: number;\n}\n\nexport interface ProjectBoardCacheOptions {\n /** The code boards, built-ins included when enabled. */\n codeRegistry: BoardRegistry;\n storage: StoredBoardsStorage;\n /**\n * Lists every project, to warm them at boot, and reads the retired switches the board\n * migrations carry into each project's boards.\n */\n projects?: {\n listAll(): Promise<readonly { orgId: string; id: string }[]>;\n retiredAutomationSettings?(\n project: { orgId: string; id: string },\n ops: FactoryStorageOps,\n ): Promise<RetiredAutomationSettings | null>;\n };\n /** The phases cards sit in on each of the project's boards, which a board migration must not remove. */\n occupiedPhases?: (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ) => Promise<ReadonlyMap<string, ReadonlySet<string>> | null>;\n codeSkills?: readonly InlineSkill[];\n /**\n * Whether the project still uses the retired Review board (an open card is stored on it). Such\n * a project is served Review alongside its boards; without this, no project is.\n */\n reviewBoardInUse?: (scope: StoredBoardScope) => Promise<boolean>;\n recheckMs?: number;\n now?: () => number;\n warn?: (message: string) => void;\n}\n\nfunction scopeKey(scope: StoredBoardScope): string {\n return `${scope.orgId}\\0${scope.factoryProjectId}`;\n}\n\n/**\n * Reads the phases cards sit in on each of a project's boards, for `occupiedPhases`. Null while\n * cards from before the work-item split are still being copied: `listWith` can't see those yet.\n */\nexport function occupiedPhasesOf(workItems: Pick<WorkItemsStorage, 'listWith' | 'legacyBackfillPending'>) {\n return async (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ): Promise<ReadonlyMap<string, ReadonlySet<string>> | null> => {\n if (workItems.legacyBackfillPending) return null;\n const occupied = new Map<string, Set<string>>();\n for (const item of await workItems.listWith(ops, scope)) {\n const board = boardForWorkItem(item);\n const phases = occupied.get(board) ?? new Set<string>();\n for (const stage of item.stages) phases.add(stage);\n occupied.set(board, phases);\n }\n return occupied;\n };\n}\n\n/**\n * The per-project board cache. A project's boards are its rows: the Work and app boards Factory\n * stored in it, in code order, then the others. A Work or app board's row runs with the code\n * behaviour of its board and phase keys that still fits it ({@link mergeCodeBehaviour}). A project\n * that still uses the retired Review board is served it from code, never stored, until its last\n * open card there finishes. The first load of each project in a process stores the\n * boards Factory hasn't stored in it yet, each once ({@link StoredBoardsStorage.seedBoards}); a\n * release never rewrites them. Loads recheck the project's board version at most every\n * `recheckMs` and recompile when it changed, so stored edits on other replicas arrive within that\n * delay.\n */\nexport class ProjectBoardCache implements ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE] = true;\n readonly codeRegistry: BoardRegistry;\n readonly #codeDetails: ReadonlyMap<string, StoredBoardDetails>;\n readonly #storage: StoredBoardsStorage;\n readonly #projects: ProjectBoardCacheOptions['projects'];\n readonly #recheckMs: number;\n readonly #now: () => number;\n readonly #warn: (message: string) => void;\n readonly #entries = new Map<string, CacheEntry>();\n readonly #loading = new Map<string, Promise<ProjectBoards>>();\n readonly #generations = new Map<string, number>();\n readonly #warned = new Set<string>();\n readonly #seeded = new Set<string>();\n readonly #codeSkills: readonly InlineSkill[];\n readonly #seeds: ReadonlyMap<string, StoredBoardInput>;\n /** Boards the app upserted for every project, which a project with no boards gets before Factory's. */\n readonly #appBoards = new Map<string, StoredBoardInput>();\n readonly #reviewBoardInUse: ProjectBoardCacheOptions['reviewBoardInUse'];\n readonly #occupiedPhases: ProjectBoardCacheOptions['occupiedPhases'];\n\n constructor(options: ProjectBoardCacheOptions) {\n this.codeRegistry = options.codeRegistry;\n this.#storage = options.storage;\n this.#reviewBoardInUse = options.reviewBoardInUse;\n this.#occupiedPhases = options.occupiedPhases;\n this.#projects = options.projects;\n this.#codeSkills = options.codeSkills ?? [];\n this.#recheckMs = options.recheckMs ?? DEFAULT_RECHECK_MS;\n this.#now = options.now ?? Date.now;\n this.#warn = options.warn ?? (message => console.warn(`[factory] ${message}`));\n this.#codeDetails = new Map(\n [...this.codeRegistry.values()].map(board => [\n board.id,\n {\n source: defaultBoards.includes(board) ? 'builtin' : 'app',\n editable: true,\n problems: this.#skillProblems(board),\n },\n ]),\n );\n this.#seeds = new Map([...this.codeRegistry.values()].map(board => [board.id, boardDefinitionOf(board)]));\n }\n\n /**\n * The boards Factory stores once in a project it didn't create: Work as it was with Triage, so a\n * project from an older release keeps the phases its cards know, then the app boards, in order.\n */\n seeds(): StoredBoardInput[] {\n return [...this.#seeds.values()].map(seed => (this.#isFactoryWork(seed.key) ? workSeedWithTriage() : seed));\n }\n\n /**\n * The definition reset restores for `key`; undefined when there is none. A board the app upserted\n * for every project comes first, so reset never swaps an app's Work for Factory's. Factory's Work\n * is today's Work for a project Factory created with it (`row` created by\n * {@link NEW_PROJECT_SEED_ACTOR}), and Work with Triage for every other project.\n */\n seedFor(key: string, row?: Pick<StoredBoardRecord, 'createdBy'>): StoredBoardInput | undefined {\n const app = this.#appBoards.get(key);\n if (app) return app;\n const seed = this.#seeds.get(key);\n if (!seed || !this.#isFactoryWork(key) || row?.createdBy === NEW_PROJECT_SEED_ACTOR) return seed;\n return workSeedWithTriage();\n }\n\n /**\n * Stores Factory's boards in a project that was just created, with today's Work (no Triage).\n * Only the project-creation route calls this; every other load stores {@link seeds}.\n */\n async seedNewProject(scope: StoredBoardScope): Promise<ProjectBoards> {\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, [...this.#seeds.values()], {\n actor: NEW_PROJECT_SEED_ACTOR,\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n });\n }\n return this.describe(scope);\n }\n\n /**\n * Remembers a board the app upserted for every project, so a project that has no boards yet (one\n * created later, or one that never loaded) gets it on its first load before Factory's own boards;\n * having it, the project then gets no Work from Factory. Kept for this process: an app upserts\n * its boards at every startup.\n */\n rememberBoardForAllProjects(board: StoredBoardInput): void {\n this.#appBoards.set(board.key, board);\n }\n\n /** Whether `key` is Factory's own Work board, rather than none or an app board under its key. */\n #isFactoryWork(key: string): boolean {\n return key === workBoard.id && this.codeRegistry.get(key) === workBoard;\n }\n\n /** Work is stored only into a project with no boards: one that has any keeps what it has. */\n #onlyIntoEmpty(): string[] {\n return this.#isFactoryWork(workBoard.id) ? [workBoard.id] : [];\n }\n\n async load(scope: StoredBoardScope): Promise<BoardRegistry> {\n return (await this.describe(scope)).registry;\n }\n\n /** The project's boards with their source, whether they can be edited, and problems, brought up to date. */\n async describe(scope: StoredBoardScope): Promise<ProjectBoards> {\n const key = scopeKey(scope);\n const entry = this.#entries.get(key);\n if (entry && this.#now() - entry.checkedAt < this.#recheckMs) return entry.boards;\n const inFlight = this.#loading.get(key);\n if (inFlight) return inFlight;\n const generation = this.#generations.get(key) ?? 0;\n const loading = this.#refresh(scope, key, generation).finally(() => {\n if (this.#loading.get(key) === loading) this.#loading.delete(key);\n });\n this.#loading.set(key, loading);\n return loading;\n }\n\n /**\n * The project's loaded boards. Before the project's first load (boot preload not finished, or a\n * project created on another replica) this is the code boards alone, without the project's\n * stored boards.\n */\n forProject(scope: StoredBoardScope): BoardRegistry {\n // Storage asks about a row it is about to insert by its board and stages alone, with no\n // project to look up; the code boards answer for it.\n if (!scope.orgId || !scope.factoryProjectId) return this.codeRegistry;\n const entry = this.#entries.get(scopeKey(scope));\n if (entry) return entry.boards.registry;\n // Warm the project so the next sync read sees its stored boards.\n void this.load(scope).catch(() => {});\n this.#warnOnce(\n `cold:${scopeKey(scope)}`,\n `Boards for project ${scope.factoryProjectId} were read before they were loaded; using the code boards.`,\n true,\n );\n return this.codeRegistry;\n }\n\n /** The code skills stored runners may name. */\n get codeSkills(): readonly InlineSkill[] {\n return this.#codeSkills;\n }\n\n /** Makes the next load reread the project. The loaded boards keep serving sync reads until then. */\n invalidate(scope: StoredBoardScope): void {\n const key = scopeKey(scope);\n this.#generations.set(key, (this.#generations.get(key) ?? 0) + 1);\n this.#loading.delete(key);\n const entry = this.#entries.get(key);\n if (entry) entry.checkedAt = Number.NEGATIVE_INFINITY;\n }\n\n /** Loads every project, a few at a time, so sync reads find them warm and each has its boards stored. */\n async preload(): Promise<void> {\n const projects = (await this.#projects?.listAll()) ?? [];\n let next = 0;\n const worker = async () => {\n while (next < projects.length) {\n const project = projects[next++]!;\n // A project that fails to load here loads on first use; the others still load now.\n await this.load({ orgId: project.orgId, factoryProjectId: project.id }).catch(error =>\n this.#warn(\n `Boards for project ${project.id} did not load at startup; they load on first use: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n };\n await Promise.all(Array.from({ length: Math.min(PRELOAD_CONCURRENCY, projects.length) }, worker));\n }\n\n async #refresh(scope: StoredBoardScope, key: string, generation: number): Promise<ProjectBoards> {\n await this.#seed(scope, key);\n const current = this.#entries.get(key);\n const version = await this.#storage.readVersion(scope);\n const reviewInUse = (await this.#reviewBoardInUse?.(scope)) ?? false;\n if (current && current.version === version && current.reviewInUse === reviewInUse) {\n if ((this.#generations.get(key) ?? 0) === generation) current.checkedAt = this.#now();\n return current.boards;\n }\n const snapshot = await this.#consistentSnapshot(scope);\n const boards = this.#compile(scope, snapshot.boards, reviewInUse);\n if ((this.#generations.get(key) ?? 0) === generation) {\n this.#entries.set(key, { boards, version: snapshot.version, reviewInUse, checkedAt: this.#now() });\n }\n return boards;\n }\n\n /** Boards and phases are read in two statements; reread when a write landed between them. */\n async #consistentSnapshot(scope: StoredBoardScope) {\n let snapshot = await this.#storage.snapshot(scope);\n for (let attempt = 1; attempt < SNAPSHOT_ATTEMPTS; attempt++) {\n if ((await this.#storage.readVersion(scope)) === snapshot.version) break;\n snapshot = await this.#storage.snapshot(scope);\n }\n return snapshot;\n }\n\n /**\n * Stores the boards Factory hasn't stored in the project yet, once per process. A failure is\n * logged and retried on the next load; the boards it didn't store aren't served meanwhile.\n */\n async #seed(scope: StoredBoardScope, key: string): Promise<void> {\n if (this.#seeded.has(key)) return;\n try {\n // Read before seeding records Work's key: a project whose list lacked it has no Work of Factory's.\n const seeded = await this.#storage.seededBoardKeys(scope);\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, this.seeds(), {\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n });\n }\n await this.#migrate(scope, seeded);\n this.#seeded.add(key);\n } catch (error) {\n this.#warnOnce(\n `seed:${key}`,\n `Boards for project ${scope.factoryProjectId} could not be stored; Factory stores them on the next load: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Runs the board migrations of the boards Factory stores here that the project hasn't had yet. */\n async #migrate(scope: StoredBoardScope, seededBefore: readonly string[] | null): Promise<void> {\n // A migration of one board rewrites Factory's own board; an app board under the same key keeps\n // its settings. One that carries a project setting into every board rewrites them all. A board\n // Factory never stored in the project (an app wrote the row first), or one the app upserts for\n // every project, is an app's: its one-board migrations are recorded as applied without running.\n const migrations = BOARD_MIGRATIONS.filter(migration => {\n if (migration.boardKey === null) return true;\n const code = this.codeRegistry.get(migration.boardKey);\n return code !== undefined && defaultBoards.includes(code);\n }).map(migration =>\n migration.boardKey !== null &&\n (this.#appBoards.has(migration.boardKey) || (seededBefore !== null && !seededBefore.includes(migration.boardKey)))\n ? { ...migration, migrate: () => undefined }\n : migration,\n );\n const changed = await this.#storage.applyBoardMigrations(scope, migrations, ops =>\n this.#migrationContext(scope, ops),\n );\n if (changed.length === 0) return;\n const filled = changed.map(({ boardKey, filled }) => `${boardKey}: ${filled.join(', ')}`).join('; ');\n console.info(`[factory] Migrated the boards of project ${scope.factoryProjectId} (${filled}).`);\n }\n\n /** Read through the migration transaction's `ops`, so card moves can't slip in unseen on LibSQL. */\n async #migrationContext(scope: StoredBoardScope, ops: FactoryStorageOps): Promise<BoardMigrationContext> {\n const retiredSettings =\n (await this.#projects?.retiredAutomationSettings?.({ orgId: scope.orgId, id: scope.factoryProjectId }, ops)) ??\n null;\n return {\n retiredSettings,\n occupiedPhases: retiredSettings && this.#occupiedPhases ? await this.#occupiedPhases(scope, ops) : null,\n codePhases: boardKey => {\n const code = this.codeRegistry.get(boardKey);\n return code ? new Set(Object.keys(code.phases)) : undefined;\n },\n warn: message =>\n this.#warnOnce(`migration:${scopeKey(scope)}:${message}`, `${message} (project ${scope.factoryProjectId})`),\n };\n }\n\n #compile(scope: StoredBoardScope, rows: readonly StoredBoardRecord[], reviewInUse: boolean): ProjectBoards {\n const byKey = new Map(rows.map(row => [row.key, row]));\n const details = new Map(this.#codeDetails);\n const problems: string[] = [];\n const report = (row: StoredBoardRecord, messages: readonly string[]) => {\n problems.push(...messages);\n for (const message of messages) {\n this.#warnOnce(\n `row:${scopeKey(scope)}:${row.key}:${row.revision}:${message}`,\n `${message} (project ${scope.factoryProjectId})`,\n );\n }\n };\n const boards: InstalledBoard[] = [];\n // Work and app boards keep their code order, each served from its row.\n for (const code of this.codeRegistry.values()) {\n const row = byKey.get(code.id);\n if (!row) {\n details.delete(code.id);\n // Stored once and deleted since, or not stored because storing failed.\n if (!this.#seeded.has(scopeKey(scope))) {\n problems.push(`Board \"${code.id}\" isn't stored in this project yet; Factory stores it on the next load.`);\n }\n continue;\n }\n let merged: ReturnType<typeof mergeCodeBehaviour>;\n try {\n merged = mergeCodeBehaviour(row, code);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n report(row, merged.problems);\n details.set(code.id, {\n ...details.get(code.id)!,\n problems: [...merged.problems, ...this.#skillProblems(merged.board)],\n });\n boards.push(merged.board);\n }\n // Served from code and never stored, so nobody edits a board on its way out.\n if (reviewInUse) {\n boards.push(reviewBoard);\n details.set(reviewBoard.id, { source: 'builtin', editable: false, problems: [] });\n }\n for (const row of rows) {\n if (this.codeRegistry.has(row.key)) continue;\n if (row.key === LEGACY_REVIEW_BOARD) {\n // Factory seeded this row while Review was a built-in board and nobody edited it since:\n // there is nothing in it to lose, so it is no problem. A person's edits are reported.\n if (isUntouchedReviewSeed(row)) continue;\n report(row, [\n reviewInUse\n ? `Stored board \"${row.key}\" is hidden by the code board with the same key.`\n : RESERVED_REVIEW_ROW,\n ]);\n continue;\n }\n let board: InstalledBoard;\n try {\n board = compileStoredBoard(row);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n boards.push(board);\n details.set(row.key, { source: 'stored', editable: true, problems: this.#skillProblems(board) });\n }\n return {\n registry: boardRegistryOf(boards),\n details,\n problems,\n };\n }\n\n #skillProblems(board: InstalledBoard): string[] {\n return findBoardSkillProblems(boardRegistryOf([board]), this.#codeSkills);\n }\n\n #warnOnce(key: string, message: string, debug = false): void {\n if (this.#warned.has(key)) return;\n this.#warned.add(key);\n if (debug) {\n console.debug(`[factory] ${message}`);\n return;\n }\n this.#warn(message);\n }\n}\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,qBAAqB;;AAE3B,MAAM,sBAAsB,iBAAiB,oBAAoB;AACjE,MAAM,sBAAsB;;AAE5B,MAAM,qBAAqB,kBAAkB,WAAW,CAAC,CAAC,OAAO,KAAK,EAAE,KAAK,MAAM,YAAY;CAAE;CAAK;CAAM;AAAK,EAAE;;;;;AAMnH,SAAS,sBAAsB,KAAiC;CAC9D,IAAI,IAAI,aAAa,KAAK,IAAI,cAAA,WAA0C,OAAO;CAC/E,IAAI,IAAI,cAAA,aAA4C,IAAI,SAAS,YAAY,MAAM,OAAO;CAC1F,MAAM,SAAS,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,QA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cACI,iBAAiB,IAAI,IAAI,oDACzB,mBACN,CAAC;IACD;GACF;GACA,IAAI;GACJ,IAAI;IACF,QAAQ,mBAAmB,GAAG;GAChC,SAAS,OAAO;IACd,OAAO,KAAK,CACV,UAAU,IAAI,IAAI,yBAAyB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAClG,CAAC;IACD;GACF;GACA,OAAO,KAAK,KAAK;GACjB,QAAQ,IAAI,IAAI,KAAK;IAAE,QAAQ;IAAU,UAAU;IAAM,UAAU,KAAK,eAAe,KAAK;GAAE,CAAC;EACjG;EACA,OAAO;GACL,UAAU,gBAAgB,MAAM;GAChC;GACA;EACF;CACF;CAEA,eAAe,OAAiC;EAC9C,OAAO,uBAAuB,gBAAgB,CAAC,KAAK,CAAC,GAAG,KAAK,WAAW;CAC1E;CAEA,UAAU,KAAa,SAAiB,QAAQ,OAAa;EAC3D,IAAI,KAAK,QAAQ,IAAI,GAAG,GAAG;EAC3B,KAAK,QAAQ,IAAI,GAAG;EACpB,IAAI,OAAO;GACT,QAAQ,MAAM,aAAa,SAAS;GACpC;EACF;EACA,KAAK,MAAM,OAAO;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"project-boards.js","names":[],"sources":["../../src/boards/project-boards.ts"],"sourcesContent":["import type { InlineSkill } from '@mastra/core/skills';\nimport type { FactoryStorageOps } from '@mastra/core/storage';\n\nimport { findBoardSkillProblems } from '../skills/app-skills.js';\nimport type {\n BoardMigrationContext,\n StoredBoardInput,\n StoredBoardRecord,\n StoredBoardScope,\n StoredBoardsStorage,\n} from '../storage/domains/boards/base.js';\nimport { DEFAULT_INTAKE_ROUTE_ACTOR, readStoredBoard } from '../storage/domains/boards/base.js';\nimport type { RetiredAutomationSettings } from '../storage/domains/projects/base.js';\nimport type { WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { LEGACY_REVIEW_BOARD } from '../storage/domains/work-items/legacy-review.js';\nimport type { ReviewBoardInUse } from '../storage/domains/work-items/legacy-review.js';\nimport { boardRegistryOf, createBoardRegistry, defaultBoards } from './registry.js';\nimport type { BoardRegistry, InstalledBoard } from './registry.js';\nimport { reviewBoard } from './review.js';\nimport { boardForWorkItem } from './semantics.js';\nimport { boardDefinitionOf, compileStoredBoard, mergeCodeBehaviour } from './stored-board.js';\nimport { BOARD_MIGRATIONS } from './work-migrations.js';\nimport { workSeedWithTriage } from './work-seeds.js';\nimport { workBoard } from './work.js';\n\nconst DEFAULT_RECHECK_MS = 1000;\nconst PRELOAD_CONCURRENCY = 8;\n/** The phases every release seeded the Review board with; only runners and tools changed between them. */\nconst REVIEW_SEED_PHASES = boardDefinitionOf(reviewBoard).phases.map(({ key, name, kind }) => ({ key, name, kind }));\n\n/**\n * Whether `row` is the Review board as Factory seeded it: written once by Factory, never\n * revised, and shaped like the seed. The actor alone is not proof, as any caller can pass it.\n */\nexport function isUntouchedReviewSeed(row: StoredBoardRecord): boolean {\n if (row.revision !== 1 || row.createdBy !== DEFAULT_INTAKE_ROUTE_ACTOR) return false;\n if (row.updatedBy !== DEFAULT_INTAKE_ROUTE_ACTOR || row.name !== reviewBoard.name) return false;\n const phases = [...row.phases].sort((a, b) => a.position - b.position);\n return (\n phases.length === REVIEW_SEED_PHASES.length &&\n phases.every(\n (phase, index) =>\n phase.key === REVIEW_SEED_PHASES[index]!.key &&\n phase.name === REVIEW_SEED_PHASES[index]!.name &&\n phase.kind === REVIEW_SEED_PHASES[index]!.kind,\n )\n );\n}\n\n/**\n * Whether a project has a board of its own under `review`: a stored row other than the seed an\n * earlier release left behind. Cards stored on it are its own; anywhere else they are the retired\n * Review board's. An app that defines the board owns it in a project from when its row is stored\n * there. Without stored boards (`stored: false`) the app's boards are served as they are.\n */\nexport function ownReviewBoard(codeRegistry: BoardRegistry, { stored = true } = {}): ReviewBoardInUse {\n if (!stored) return async () => codeRegistry.has(LEGACY_REVIEW_BOARD);\n return async (ops, scope) => {\n const row = await readStoredBoard(ops, scope, LEGACY_REVIEW_BOARD);\n return row !== null && !isUntouchedReviewSeed(row);\n };\n}\n\nconst SNAPSHOT_ATTEMPTS = 3;\n\n/**\n * The creator Factory records on the Work board it stores in a project as the project is\n * created: that board is today's Work, and reset gives it back. Any other Work row Factory stored\n * is the one with Triage. Only Factory writes this id; a person's writes carry their user id.\n */\nexport const NEW_PROJECT_SEED_ACTOR = 'factory:new-project';\n\n/** Where a board in a project's catalog came from. */\nexport type BoardSourceKind = 'builtin' | 'app' | 'stored';\n\nexport interface StoredBoardDetails {\n source: BoardSourceKind;\n /** Stored boards, the built-in Work board and app boards can all be edited; the retired Review board can't. */\n editable: boolean;\n problems: string[];\n}\n\n/** A project's boards: the code boards plus its stored boards, and what to report about each board. */\nexport interface ProjectBoards {\n readonly registry: BoardRegistry;\n readonly details: ReadonlyMap<string, StoredBoardDetails>;\n /** Problems with stored boards that are left out of the registry. */\n readonly problems: readonly string[];\n}\n\nconst PROJECT_BOARD_SOURCE = Symbol('ProjectBoardSource');\n\n/**\n * Serves each project its boards. `load` is the async entry point that brings a project's\n * boards up to date; `forProject` is the sync read for code that already loaded the project.\n */\nexport interface ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE]: true;\n /** The code boards: built-in and app boards, served to every project as code built them. */\n readonly codeRegistry: BoardRegistry;\n load(scope: StoredBoardScope): Promise<BoardRegistry>;\n forProject(scope: StoredBoardScope): BoardRegistry;\n describe?(scope: StoredBoardScope): Promise<ProjectBoards>;\n}\n\n/** Accepts either a fixed registry (tests, standalone services) or a per-project source. */\nexport function toBoardSource(boards: BoardRegistry | ProjectBoardSource | undefined): ProjectBoardSource {\n const source = boards ?? createBoardRegistry();\n if (isBoardSource(source)) return source;\n return {\n [PROJECT_BOARD_SOURCE]: true,\n codeRegistry: source,\n load: async () => source,\n forProject: () => source,\n };\n}\n\nfunction isBoardSource(boards: BoardRegistry | ProjectBoardSource): boards is ProjectBoardSource {\n return PROJECT_BOARD_SOURCE in boards;\n}\n\ninterface CacheEntry {\n boards: ProjectBoards;\n version: string | null;\n reviewInUse: boolean;\n checkedAt: number;\n}\n\nexport interface ProjectBoardCacheOptions {\n /** The code boards, built-ins included when enabled. */\n codeRegistry: BoardRegistry;\n storage: StoredBoardsStorage;\n /**\n * Lists every project, to warm them at boot, and reads the retired switches the board\n * migrations carry into each project's boards.\n */\n projects?: {\n listAll(): Promise<readonly { orgId: string; id: string }[]>;\n retiredAutomationSettings?(\n project: { orgId: string; id: string },\n ops: FactoryStorageOps,\n ): Promise<RetiredAutomationSettings | null>;\n };\n /** The phases cards sit in on each of the project's boards, which a board migration must not remove. */\n occupiedPhases?: (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ) => Promise<ReadonlyMap<string, ReadonlySet<string>> | null>;\n codeSkills?: readonly InlineSkill[];\n /**\n * Whether the project still uses the retired Review board (an open card is stored on it). Such\n * a project is served Review alongside its boards; without this, no project is.\n */\n reviewBoardInUse?: (scope: StoredBoardScope) => Promise<boolean>;\n /**\n * Stores the Work placement of every card the retired Review board left on `review`, through\n * `ops`. Run in the transaction that stores an app's board under that key in a project.\n */\n releaseReviewCards?: (ops: FactoryStorageOps, scope: StoredBoardScope) => Promise<void>;\n recheckMs?: number;\n now?: () => number;\n warn?: (message: string) => void;\n}\n\nfunction scopeKey(scope: StoredBoardScope): string {\n return `${scope.orgId}\\0${scope.factoryProjectId}`;\n}\n\n/**\n * Reads the phases cards sit in on each of a project's boards, for `occupiedPhases`. Null while\n * cards from before the work-item split are still being copied: `listWith` can't see those yet.\n */\nexport function occupiedPhasesOf(workItems: Pick<WorkItemsStorage, 'listWith' | 'legacyBackfillPending'>) {\n return async (\n scope: StoredBoardScope,\n ops: FactoryStorageOps,\n ): Promise<ReadonlyMap<string, ReadonlySet<string>> | null> => {\n if (workItems.legacyBackfillPending) return null;\n const occupied = new Map<string, Set<string>>();\n for (const item of await workItems.listWith(ops, scope)) {\n const board = boardForWorkItem(item);\n const phases = occupied.get(board) ?? new Set<string>();\n for (const stage of item.stages) phases.add(stage);\n occupied.set(board, phases);\n }\n return occupied;\n };\n}\n\n/**\n * The per-project board cache. A project's boards are its rows: the Work and app boards Factory\n * stored in it, in code order, then the others. A Work or app board's row runs with the code\n * behaviour of its board and phase keys that still fits it ({@link mergeCodeBehaviour}). A project\n * that still uses the retired Review board is served it from code, never stored, until its last\n * open card there finishes. The first load of each project in a process stores the\n * boards Factory hasn't stored in it yet, each once ({@link StoredBoardsStorage.seedBoards}); a\n * release never rewrites them. Loads recheck the project's board version at most every\n * `recheckMs` and recompile when it changed, so stored edits on other replicas arrive within that\n * delay.\n */\nexport class ProjectBoardCache implements ProjectBoardSource {\n readonly [PROJECT_BOARD_SOURCE] = true;\n readonly codeRegistry: BoardRegistry;\n readonly #codeDetails: ReadonlyMap<string, StoredBoardDetails>;\n readonly #storage: StoredBoardsStorage;\n readonly #projects: ProjectBoardCacheOptions['projects'];\n readonly #recheckMs: number;\n readonly #now: () => number;\n readonly #warn: (message: string) => void;\n readonly #entries = new Map<string, CacheEntry>();\n readonly #loading = new Map<string, Promise<ProjectBoards>>();\n readonly #generations = new Map<string, number>();\n readonly #warned = new Set<string>();\n readonly #seeded = new Set<string>();\n readonly #codeSkills: readonly InlineSkill[];\n readonly #seeds: ReadonlyMap<string, StoredBoardInput>;\n /** Boards the app upserted for every project, which a project with no boards gets before Factory's. */\n readonly #appBoards = new Map<string, StoredBoardInput>();\n readonly #reviewBoardInUse: ProjectBoardCacheOptions['reviewBoardInUse'];\n readonly #releaseReviewCards: ProjectBoardCacheOptions['releaseReviewCards'];\n readonly #occupiedPhases: ProjectBoardCacheOptions['occupiedPhases'];\n\n constructor(options: ProjectBoardCacheOptions) {\n this.codeRegistry = options.codeRegistry;\n this.#storage = options.storage;\n this.#reviewBoardInUse = options.reviewBoardInUse;\n this.#releaseReviewCards = options.releaseReviewCards;\n this.#occupiedPhases = options.occupiedPhases;\n this.#projects = options.projects;\n this.#codeSkills = options.codeSkills ?? [];\n this.#recheckMs = options.recheckMs ?? DEFAULT_RECHECK_MS;\n this.#now = options.now ?? Date.now;\n this.#warn = options.warn ?? (message => console.warn(`[factory] ${message}`));\n this.#codeDetails = new Map(\n [...this.codeRegistry.values()].map(board => [\n board.id,\n {\n source: defaultBoards.includes(board) ? 'builtin' : 'app',\n editable: true,\n problems: this.#skillProblems(board),\n },\n ]),\n );\n this.#seeds = new Map([...this.codeRegistry.values()].map(board => [board.id, boardDefinitionOf(board)]));\n }\n\n /**\n * The boards Factory stores once in a project it didn't create: Work as it was with Triage, so a\n * project from an older release keeps the phases its cards know, then the app boards, in order.\n */\n seeds(): StoredBoardInput[] {\n return [...this.#seeds.values()].map(seed => (this.#isFactoryWork(seed.key) ? workSeedWithTriage() : seed));\n }\n\n /**\n * The definition reset restores for `key`; undefined when there is none. A board the app upserted\n * for every project comes first, so reset never swaps an app's Work for Factory's. Factory's Work\n * is today's Work for a project Factory created with it (`row` created by\n * {@link NEW_PROJECT_SEED_ACTOR}), and Work with Triage for every other project.\n */\n seedFor(key: string, row?: Pick<StoredBoardRecord, 'createdBy'>): StoredBoardInput | undefined {\n const app = this.#appBoards.get(key);\n if (app) return app;\n const seed = this.#seeds.get(key);\n if (!seed || !this.#isFactoryWork(key) || row?.createdBy === NEW_PROJECT_SEED_ACTOR) return seed;\n return workSeedWithTriage();\n }\n\n /**\n * Stores Factory's boards in a project that was just created, with today's Work (no Triage).\n * Only the project-creation route calls this; every other load stores {@link seeds}.\n */\n async seedNewProject(scope: StoredBoardScope): Promise<ProjectBoards> {\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, [...this.#seeds.values()], {\n actor: NEW_PROJECT_SEED_ACTOR,\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n });\n }\n return this.describe(scope);\n }\n\n /**\n * Remembers a board the app upserted for every project, so a project that has no boards yet (one\n * created later, or one that never loaded) gets it on its first load before Factory's own boards;\n * having it, the project then gets no Work from Factory. Kept for this process: an app upserts\n * its boards at every startup.\n */\n rememberBoardForAllProjects(board: StoredBoardInput): void {\n this.#appBoards.set(board.key, board);\n }\n\n /** Whether `key` is Factory's own Work board, rather than none or an app board under its key. */\n #isFactoryWork(key: string): boolean {\n return key === workBoard.id && this.codeRegistry.get(key) === workBoard;\n }\n\n /** Work is stored only into a project with no boards: one that has any keeps what it has. */\n #onlyIntoEmpty(): string[] {\n return this.#isFactoryWork(workBoard.id) ? [workBoard.id] : [];\n }\n\n async load(scope: StoredBoardScope): Promise<BoardRegistry> {\n return (await this.describe(scope)).registry;\n }\n\n /** The project's boards with their source, whether they can be edited, and problems, brought up to date. */\n async describe(scope: StoredBoardScope): Promise<ProjectBoards> {\n const key = scopeKey(scope);\n const entry = this.#entries.get(key);\n if (entry && this.#now() - entry.checkedAt < this.#recheckMs) return entry.boards;\n const inFlight = this.#loading.get(key);\n if (inFlight) return inFlight;\n const generation = this.#generations.get(key) ?? 0;\n const loading = this.#refresh(scope, key, generation).finally(() => {\n if (this.#loading.get(key) === loading) this.#loading.delete(key);\n });\n this.#loading.set(key, loading);\n return loading;\n }\n\n /**\n * The project's loaded boards. Before the project's first load (boot preload not finished, or a\n * project created on another replica) this is the code boards alone, without the project's\n * stored boards.\n */\n forProject(scope: StoredBoardScope): BoardRegistry {\n // Storage asks about a row it is about to insert by its board and stages alone, with no\n // project to look up; the code boards answer for it.\n if (!scope.orgId || !scope.factoryProjectId) return this.codeRegistry;\n const entry = this.#entries.get(scopeKey(scope));\n if (entry) return entry.boards.registry;\n // Warm the project so the next sync read sees its stored boards.\n void this.load(scope).catch(() => {});\n this.#warnOnce(\n `cold:${scopeKey(scope)}`,\n `Boards for project ${scope.factoryProjectId} were read before they were loaded; using the code boards.`,\n true,\n );\n return this.codeRegistry;\n }\n\n /** The code skills stored runners may name. */\n get codeSkills(): readonly InlineSkill[] {\n return this.#codeSkills;\n }\n\n /** Makes the next load reread the project. The loaded boards keep serving sync reads until then. */\n invalidate(scope: StoredBoardScope): void {\n const key = scopeKey(scope);\n this.#generations.set(key, (this.#generations.get(key) ?? 0) + 1);\n this.#loading.delete(key);\n const entry = this.#entries.get(key);\n if (entry) entry.checkedAt = Number.NEGATIVE_INFINITY;\n }\n\n /** Loads every project, a few at a time, so sync reads find them warm and each has its boards stored. */\n async preload(): Promise<void> {\n const projects = (await this.#projects?.listAll()) ?? [];\n let next = 0;\n const worker = async () => {\n while (next < projects.length) {\n const project = projects[next++]!;\n // A project that fails to load here loads on first use; the others still load now.\n await this.load({ orgId: project.orgId, factoryProjectId: project.id }).catch(error =>\n this.#warn(\n `Boards for project ${project.id} did not load at startup; they load on first use: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n };\n await Promise.all(Array.from({ length: Math.min(PRELOAD_CONCURRENCY, projects.length) }, worker));\n }\n\n async #refresh(scope: StoredBoardScope, key: string, generation: number): Promise<ProjectBoards> {\n await this.#seed(scope, key);\n const current = this.#entries.get(key);\n const version = await this.#storage.readVersion(scope);\n const reviewInUse = (await this.#reviewBoardInUse?.(scope)) ?? false;\n if (current && current.version === version && current.reviewInUse === reviewInUse) {\n if ((this.#generations.get(key) ?? 0) === generation) current.checkedAt = this.#now();\n return current.boards;\n }\n const snapshot = await this.#consistentSnapshot(scope);\n const boards = this.#compile(scope, snapshot.boards, reviewInUse);\n if ((this.#generations.get(key) ?? 0) === generation) {\n this.#entries.set(key, { boards, version: snapshot.version, reviewInUse, checkedAt: this.#now() });\n }\n return boards;\n }\n\n /** Boards and phases are read in two statements; reread when a write landed between them. */\n async #consistentSnapshot(scope: StoredBoardScope) {\n let snapshot = await this.#storage.snapshot(scope);\n for (let attempt = 1; attempt < SNAPSHOT_ATTEMPTS; attempt++) {\n if ((await this.#storage.readVersion(scope)) === snapshot.version) break;\n snapshot = await this.#storage.snapshot(scope);\n }\n return snapshot;\n }\n\n /**\n * Stores the boards Factory hasn't stored in the project yet, once per process. A failure is\n * logged and retried on the next load; the boards it didn't store aren't served meanwhile.\n */\n async #seed(scope: StoredBoardScope, key: string): Promise<void> {\n if (this.#seeded.has(key)) return;\n try {\n // Read before seeding records Work's key: a project whose list lacked it has no Work of Factory's.\n const seeded = await this.#storage.seededBoardKeys(scope);\n const release = this.#releaseReviewCards;\n const review = this.#seeds.get(LEGACY_REVIEW_BOARD);\n if (this.#seeds.size > 0 || this.#appBoards.size > 0) {\n await this.#storage.seedBoards(scope, this.seeds(), {\n onlyIntoEmpty: this.#onlyIntoEmpty(),\n intoEmpty: [...this.#appBoards.values()],\n // An app's board under `review` starts without the cards the retired Review board left there.\n before: async (ops, board) => {\n if (board === LEGACY_REVIEW_BOARD) await release?.(ops, scope);\n },\n });\n }\n // The row an earlier release seeded for the retired board becomes the app's board.\n if (review) {\n await this.#storage.adoptSeed(scope, review, {\n when: isUntouchedReviewSeed,\n before: ops => release?.(ops, scope) ?? Promise.resolve(),\n });\n }\n await this.#migrate(scope, seeded);\n this.#seeded.add(key);\n } catch (error) {\n this.#warnOnce(\n `seed:${key}`,\n `Boards for project ${scope.factoryProjectId} could not be stored; Factory stores them on the next load: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Runs the board migrations of the boards Factory stores here that the project hasn't had yet. */\n async #migrate(scope: StoredBoardScope, seededBefore: readonly string[] | null): Promise<void> {\n // A migration of one board rewrites Factory's own board; an app board under the same key keeps\n // its settings. One that carries a project setting into every board rewrites them all. A board\n // Factory never stored in the project (an app wrote the row first), or one the app upserts for\n // every project, is an app's: its one-board migrations are recorded as applied without running.\n const migrations = BOARD_MIGRATIONS.filter(migration => {\n if (migration.boardKey === null) return true;\n const code = this.codeRegistry.get(migration.boardKey);\n return code !== undefined && defaultBoards.includes(code);\n }).map(migration =>\n migration.boardKey !== null &&\n (this.#appBoards.has(migration.boardKey) || (seededBefore !== null && !seededBefore.includes(migration.boardKey)))\n ? { ...migration, migrate: () => undefined }\n : migration,\n );\n const changed = await this.#storage.applyBoardMigrations(scope, migrations, ops =>\n this.#migrationContext(scope, ops),\n );\n if (changed.length === 0) return;\n const filled = changed.map(({ boardKey, filled }) => `${boardKey}: ${filled.join(', ')}`).join('; ');\n console.info(`[factory] Migrated the boards of project ${scope.factoryProjectId} (${filled}).`);\n }\n\n /** Read through the migration transaction's `ops`, so card moves can't slip in unseen on LibSQL. */\n async #migrationContext(scope: StoredBoardScope, ops: FactoryStorageOps): Promise<BoardMigrationContext> {\n const retiredSettings =\n (await this.#projects?.retiredAutomationSettings?.({ orgId: scope.orgId, id: scope.factoryProjectId }, ops)) ??\n null;\n return {\n retiredSettings,\n occupiedPhases: retiredSettings && this.#occupiedPhases ? await this.#occupiedPhases(scope, ops) : null,\n codePhases: boardKey => {\n const code = this.codeRegistry.get(boardKey);\n return code ? new Set(Object.keys(code.phases)) : undefined;\n },\n warn: message =>\n this.#warnOnce(`migration:${scopeKey(scope)}:${message}`, `${message} (project ${scope.factoryProjectId})`),\n };\n }\n\n #compile(scope: StoredBoardScope, rows: readonly StoredBoardRecord[], reviewInUse: boolean): ProjectBoards {\n const byKey = new Map(rows.map(row => [row.key, row]));\n const details = new Map(this.#codeDetails);\n const problems: string[] = [];\n const report = (row: StoredBoardRecord, messages: readonly string[]) => {\n problems.push(...messages);\n for (const message of messages) {\n this.#warnOnce(\n `row:${scopeKey(scope)}:${row.key}:${row.revision}:${message}`,\n `${message} (project ${scope.factoryProjectId})`,\n );\n }\n };\n const boards: InstalledBoard[] = [];\n // Work and app boards keep their code order, each served from its row.\n for (const code of this.codeRegistry.values()) {\n const row = byKey.get(code.id);\n // Still the retired board's seed: the app's board is served once its row replaces it.\n if (row && code.id === LEGACY_REVIEW_BOARD && isUntouchedReviewSeed(row)) {\n details.delete(code.id);\n continue;\n }\n if (!row) {\n details.delete(code.id);\n // Stored once and deleted since, or not stored because storing failed.\n if (!this.#seeded.has(scopeKey(scope))) {\n problems.push(`Board \"${code.id}\" isn't stored in this project yet; Factory stores it on the next load.`);\n }\n continue;\n }\n let merged: ReturnType<typeof mergeCodeBehaviour>;\n try {\n merged = mergeCodeBehaviour(row, code);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n report(row, merged.problems);\n details.set(code.id, {\n ...details.get(code.id)!,\n problems: [...merged.problems, ...this.#skillProblems(merged.board)],\n });\n boards.push(merged.board);\n }\n // A board of the project's own under the retired Review board's key is served like any other.\n const reviewRow = byKey.get(LEGACY_REVIEW_BOARD);\n const ownsReview = reviewRow !== undefined && !isUntouchedReviewSeed(reviewRow);\n // Served from code and never stored, so nobody edits a board on its way out.\n if (reviewInUse && !ownsReview) {\n boards.push(reviewBoard);\n details.set(reviewBoard.id, { source: 'builtin', editable: false, problems: [] });\n }\n for (const row of rows) {\n if (this.codeRegistry.has(row.key)) continue;\n // Factory seeded this row while Review was a built-in board and nobody edited it since:\n // it is not a board the project made, so it is not served.\n if (row.key === LEGACY_REVIEW_BOARD && !ownsReview) continue;\n let board: InstalledBoard;\n try {\n board = compileStoredBoard(row);\n } catch (error) {\n report(row, [\n `Board '${row.key}' could not be loaded: ${error instanceof Error ? error.message : String(error)}`,\n ]);\n continue;\n }\n boards.push(board);\n details.set(row.key, { source: 'stored', editable: true, problems: this.#skillProblems(board) });\n }\n return {\n registry: boardRegistryOf(boards),\n details,\n problems,\n };\n }\n\n #skillProblems(board: InstalledBoard): string[] {\n return findBoardSkillProblems(boardRegistryOf([board]), this.#codeSkills);\n }\n\n #warnOnce(key: string, message: string, debug = false): void {\n if (this.#warned.has(key)) return;\n this.#warned.add(key);\n if (debug) {\n console.debug(`[factory] ${message}`);\n return;\n }\n this.#warn(message);\n }\n}\n"],"mappings":";;;;;;;;;;;AAyBA,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;;AAE5B,MAAM,qBAAqB,kBAAkB,WAAW,CAAC,CAAC,OAAO,KAAK,EAAE,KAAK,MAAM,YAAY;CAAE;CAAK;CAAM;AAAK,EAAE;;;;;AAMnH,SAAgB,sBAAsB,KAAiC;CACrE,IAAI,IAAI,aAAa,KAAK,IAAI,cAAA,WAA0C,OA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AAO;GACL,UAAU,gBAAgB,MAAM;GAChC;GACA;EACF;CACF;CAEA,eAAe,OAAiC;EAC9C,OAAO,uBAAuB,gBAAgB,CAAC,KAAK,CAAC,GAAG,KAAK,WAAW;CAC1E;CAEA,UAAU,KAAa,SAAiB,QAAQ,OAAa;EAC3D,IAAI,KAAK,QAAQ,IAAI,GAAG,GAAG;EAC3B,KAAK,QAAQ,IAAI,GAAG;EACpB,IAAI,OAAO;GACT,QAAQ,MAAM,aAAa,SAAS;GACpC;EACF;EACA,KAAK,MAAM,OAAO;CACpB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/boards/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/boards/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7D,MAAM,WAAW,aAAc,SAAQ,QAAQ,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,IAAI,WAAW,CAAC,cAAc,CAAC,CAAC;IACtC,OAAO,IAAI,WAAW,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CAClD;AAED,eAAO,MAAM,aAAa,EAAiC,SAAS,cAAc,EAAE,CAAC;AAErF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;CAAO,GAAG,aAAa,CAYvG;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,aAAa,CAmBhF"}
|
package/dist/boards/registry.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { LEGACY_REVIEW_BOARD } from "../storage/domains/work-items/legacy-review.js";
|
|
2
|
-
import { reviewBoard } from "./review.js";
|
|
3
1
|
import { workBoard } from "./work.js";
|
|
4
2
|
// src/boards/registry.ts
|
|
5
3
|
const defaultBoards = Object.freeze([workBoard]);
|
|
@@ -20,7 +18,6 @@ function createBoardRegistry(options = {}) {
|
|
|
20
18
|
function boardRegistryOf(boards) {
|
|
21
19
|
const registry = /* @__PURE__ */ new Map();
|
|
22
20
|
for (const board of boards) {
|
|
23
|
-
if (board.id === "review" && board !== reviewBoard) throw new Error(`MastraFactory: board id '${LEGACY_REVIEW_BOARD}' is reserved for the retired Review board.`);
|
|
24
21
|
if (registry.has(board.id)) throw new Error(`MastraFactory: duplicate board id '${board.id}' in 'boards'.`);
|
|
25
22
|
registry.set(board.id, board);
|
|
26
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../../src/boards/registry.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../src/boards/registry.ts"],"sourcesContent":["import type { BoardDefinition } from './define-board.js';\nimport { workBoard } from './work.js';\n\nexport type InstalledBoard = BoardDefinition<string, string>;\nexport interface BoardRegistry extends Iterable<[string, InstalledBoard]> {\n readonly size: number;\n get(id: string): InstalledBoard | undefined;\n has(id: string): boolean;\n keys(): MapIterator<string>;\n values(): MapIterator<InstalledBoard>;\n entries(): MapIterator<[string, InstalledBoard]>;\n}\n\nexport const defaultBoards = Object.freeze([workBoard]) as readonly InstalledBoard[];\n\n/**\n * Factory's boards: its Work board, then `boards`. Work is always installed; to run another Work,\n * store it under the `work` key with `factory.upsertBoard()`. The exported `workBoard` itself is\n * accepted in `boards` and installed once.\n */\nexport function createBoardRegistry(options: { boards?: readonly InstalledBoard[] } = {}): BoardRegistry {\n const boards = (options.boards ?? []).filter(board => !defaultBoards.includes(board));\n for (const board of boards) {\n const builtIn = defaultBoards.find(candidate => candidate.id === board.id);\n if (builtIn) {\n throw new Error(\n `MastraFactory: board id '${board.id}' is Factory's ${builtIn.name} board, which every project has. ` +\n `To run your own, store it under '${board.id}' with factory.upsertBoard(board, { projects: 'all' }).`,\n );\n }\n }\n return boardRegistryOf([...defaultBoards, ...boards]);\n}\n\n/** A registry of exactly `boards`, in order, such as the boards a project stored. */\nexport function boardRegistryOf(boards: readonly InstalledBoard[]): BoardRegistry {\n const registry = new Map<string, InstalledBoard>();\n\n for (const board of boards) {\n if (registry.has(board.id)) {\n throw new Error(`MastraFactory: duplicate board id '${board.id}' in 'boards'.`);\n }\n registry.set(board.id, board);\n }\n\n return Object.freeze({\n size: registry.size,\n get: registry.get.bind(registry),\n has: registry.has.bind(registry),\n keys: registry.keys.bind(registry),\n values: registry.values.bind(registry),\n entries: registry.entries.bind(registry),\n [Symbol.iterator]: registry[Symbol.iterator].bind(registry),\n });\n}\n"],"mappings":";;AAaA,MAAa,gBAAgB,OAAO,OAAO,CAAC,SAAS,CAAC;;;;;;AAOtD,SAAgB,oBAAoB,UAAkD,CAAC,GAAkB;CACvG,MAAM,UAAU,QAAQ,UAAU,CAAC,EAAA,CAAG,QAAO,UAAS,CAAC,cAAc,SAAS,KAAK,CAAC;CACpF,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,UAAU,cAAc,MAAK,cAAa,UAAU,OAAO,MAAM,EAAE;EACzE,IAAI,SACF,MAAM,IAAI,MACR,4BAA4B,MAAM,GAAG,iBAAiB,QAAQ,KAAK,oEAC7B,MAAM,GAAG,wDACjD;CAEJ;CACA,OAAO,gBAAgB,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC;AACtD;;AAGA,SAAgB,gBAAgB,QAAkD;CAChF,MAAM,2BAAW,IAAI,IAA4B;CAEjD,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,SAAS,IAAI,MAAM,EAAE,GACvB,MAAM,IAAI,MAAM,sCAAsC,MAAM,GAAG,eAAe;EAEhF,SAAS,IAAI,MAAM,IAAI,KAAK;CAC9B;CAEA,OAAO,OAAO,OAAO;EACnB,MAAM,SAAS;EACf,KAAK,SAAS,IAAI,KAAK,QAAQ;EAC/B,KAAK,SAAS,IAAI,KAAK,QAAQ;EAC/B,MAAM,SAAS,KAAK,KAAK,QAAQ;EACjC,QAAQ,SAAS,OAAO,KAAK,QAAQ;EACrC,SAAS,SAAS,QAAQ,KAAK,QAAQ;GACtC,OAAO,WAAW,SAAS,OAAO,SAAS,CAAC,KAAK,QAAQ;CAC5D,CAAC;AACH"}
|
package/dist/factory.d.ts
CHANGED
|
@@ -275,8 +275,11 @@ export declare class MastraFactory {
|
|
|
275
275
|
* so the definition is checked as an edit is; a new key gets none (no tool, source-closed or
|
|
276
276
|
* event rules). The board is validated once, as the boards API does, and each write is audited
|
|
277
277
|
* as `factory.board.created` or `factory.board.updated` by `system:factory`. Refusals throw a
|
|
278
|
-
* `BoardWriteError` (`invalid_board`, `unknown_skill`, `code_behaviour`, `
|
|
279
|
-
*
|
|
278
|
+
* `BoardWriteError` (`invalid_board`, `unknown_skill`, `code_behaviour`, `phase_in_use` when cards
|
|
279
|
+
* sit in a phase it removes, `board_in_use` when the key is `review` and the retired Review board
|
|
280
|
+
* still has an open card in the project, `project_not_found`). Projects are written one at a
|
|
281
|
+
* time and the call stops at the first one that refuses: the projects before it keep the board,
|
|
282
|
+
* so fix what was refused and run it again.
|
|
280
283
|
* Available after `prepare()`.
|
|
281
284
|
*
|
|
282
285
|
* @example
|
package/dist/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;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AC,EAAE,mBAAmB,CAAC;YAC5B;;;eAGG;YACH,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;KACH,CAAC;CACH;AAED,YAAY,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC3G,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAsID,qBAAa,aAAa;;IAkCxB,YAAY,MAAM,EAAE,mBAAmB,EAuBtC;IAED;;;;OAIG;IACH,IAAI,kBAAkB,IAAI,yBAAyB,GAAG,SAAS,CAI9D;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACG,WAAW,CACf,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE;QAAE,QAAQ,EAAE,KAAK,GAAG,SAAS,gBAAgB,EAAE,CAAA;KAAE,GACzD,OAAO,CAAC;QAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;QAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAAC,SAAS,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC,CA6CvG;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,qBAAqB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAKtG;IAED;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CA0rDnC;IAED;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAsB9B;IAED,oGAAoG;IAC9F,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAsC9B;CACF"}
|
package/dist/factory.js
CHANGED
|
@@ -2,7 +2,7 @@ import { buildAuthDisabledRoutes, buildAuthRoutes, createFactoryAuthGate, create
|
|
|
2
2
|
import { BoardWriteError, BoardWrites } from "./boards/board-writes.js";
|
|
3
3
|
import { isDefinedBoard } from "./boards/define-board.js";
|
|
4
4
|
import "./boards/index.js";
|
|
5
|
-
import { ProjectBoardCache, occupiedPhasesOf, toBoardSource } from "./boards/project-boards.js";
|
|
5
|
+
import { ProjectBoardCache, occupiedPhasesOf, ownReviewBoard, toBoardSource } from "./boards/project-boards.js";
|
|
6
6
|
import { publishDispatchWake, subscribeDispatchWakes } from "./dispatch-wake.js";
|
|
7
7
|
import { EnvironmentBuildRunner } from "./environment/build-runner.js";
|
|
8
8
|
import { ENVIRONMENT_BUILD_WORKFLOW_ID } from "./environment/build-workflow.js";
|
|
@@ -297,8 +297,11 @@ var MastraFactory = class {
|
|
|
297
297
|
* so the definition is checked as an edit is; a new key gets none (no tool, source-closed or
|
|
298
298
|
* event rules). The board is validated once, as the boards API does, and each write is audited
|
|
299
299
|
* as `factory.board.created` or `factory.board.updated` by `system:factory`. Refusals throw a
|
|
300
|
-
* `BoardWriteError` (`invalid_board`, `unknown_skill`, `code_behaviour`, `
|
|
301
|
-
*
|
|
300
|
+
* `BoardWriteError` (`invalid_board`, `unknown_skill`, `code_behaviour`, `phase_in_use` when cards
|
|
301
|
+
* sit in a phase it removes, `board_in_use` when the key is `review` and the retired Review board
|
|
302
|
+
* still has an open card in the project, `project_not_found`). Projects are written one at a
|
|
303
|
+
* time and the call stops at the first one that refuses: the projects before it keep the board,
|
|
304
|
+
* so fix what was refused and run it again.
|
|
302
305
|
* Available after `prepare()`.
|
|
303
306
|
*
|
|
304
307
|
* @example
|
|
@@ -525,6 +528,7 @@ var MastraFactory = class {
|
|
|
525
528
|
if (error === void 0) continue;
|
|
526
529
|
console.error(`[factory] storage domain "${domain}" failed to initialize; features that use it stay unavailable until it does:`, error);
|
|
527
530
|
}
|
|
531
|
+
workItemsStorage.useOwnReviewBoard(ownReviewBoard(this.#boards, { stored: storage.isDomainReady("boards") }));
|
|
528
532
|
if (storage.isDomainReady("boards") && storage.isDomainReady("projects")) {
|
|
529
533
|
const projectBoards = new ProjectBoardCache({
|
|
530
534
|
codeRegistry: this.#boards,
|
|
@@ -533,6 +537,7 @@ var MastraFactory = class {
|
|
|
533
537
|
codeSkills: this.#skills,
|
|
534
538
|
...storage.isDomainReady("work-items") ? {
|
|
535
539
|
reviewBoardInUse: (scope) => workItemsStorage.reviewBoardInUse(scope),
|
|
540
|
+
releaseReviewCards: (ops, scope) => workItemsStorage.releaseReviewCards(ops, scope, { open: "move" }),
|
|
536
541
|
occupiedPhases: occupiedPhasesOf(workItemsStorage)
|
|
537
542
|
} : {}
|
|
538
543
|
});
|