@mastra/factory 0.29.0-alpha.6 → 0.29.0-alpha.8
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 +50 -20
- package/dist/boards/board-events.d.ts +23 -0
- package/dist/boards/board-events.d.ts.map +1 -1
- package/dist/boards/board-events.js +37 -3
- package/dist/boards/board-events.js.map +1 -1
- package/dist/boards/board-writes.d.ts +6 -4
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +9 -6
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/intake-routing.d.ts +30 -16
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +41 -28
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/project-boards.d.ts +15 -0
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +43 -7
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/factory.d.ts +4 -14
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +22 -15
- package/dist/factory.js.map +1 -1
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +101 -0
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +7 -3
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +7 -1
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +15 -1
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +1 -1
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +2 -1
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.d.ts +1 -0
- package/dist/integrations/slack/channel-reply-processor.d.ts.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.js +4 -1
- package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
- package/dist/integrations/slack/run-error-card.js +6 -1
- package/dist/integrations/slack/run-error-card.js.map +1 -1
- package/dist/links.d.ts +4 -2
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +5 -3
- package/dist/links.js.map +1 -1
- package/dist/routes/boards.d.ts +1 -1
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/contracts.d.ts +32 -5
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +36 -9
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/intake-check.d.ts.map +1 -1
- package/dist/routes/intake-check.js +3 -1
- package/dist/routes/intake-check.js.map +1 -1
- package/dist/routes/intake-routes.d.ts +0 -3
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +1 -1
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/skills.d.ts +1 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +92 -28
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/surface.d.ts +0 -3
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +0 -1
- package/dist/routes/surface.js.map +1 -1
- package/dist/rules/dispatch-errors.d.ts +6 -0
- package/dist/rules/dispatch-errors.d.ts.map +1 -1
- package/dist/rules/dispatch-errors.js +10 -1
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +74 -32
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +3 -2
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +5 -3
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/public-failure-reason.d.ts +11 -0
- package/dist/rules/public-failure-reason.d.ts.map +1 -0
- package/dist/rules/public-failure-reason.js +136 -0
- package/dist/rules/public-failure-reason.js.map +1 -0
- package/dist/rules/transition-service.d.ts +13 -0
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +5 -1
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +12 -0
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +11 -2
- package/dist/rules/validation.js.map +1 -1
- package/dist/run-error.d.ts +1 -1
- package/dist/run-error.d.ts.map +1 -1
- package/dist/run-error.js +21 -12
- package/dist/run-error.js.map +1 -1
- package/dist/session/environment-state-processor.d.ts.map +1 -1
- package/dist/session/environment-state-processor.js +6 -2
- package/dist/session/environment-state-processor.js.map +1 -1
- package/dist/session/session-row-view.js +1 -1
- package/dist/session/session-row-view.js.map +1 -1
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +5 -3
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/skills/app-skills.d.ts +3 -2
- package/dist/skills/app-skills.d.ts.map +1 -1
- package/dist/skills/app-skills.js +5 -3
- package/dist/skills/app-skills.js.map +1 -1
- package/dist/skills/catalog.d.ts +23 -4
- package/dist/skills/catalog.d.ts.map +1 -1
- package/dist/skills/catalog.js +61 -28
- package/dist/skills/catalog.js.map +1 -1
- package/dist/storage/domains/audit/actions.d.ts +1 -1
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +6 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +12 -0
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +3 -0
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +4 -0
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/skill-overrides/base.d.ts +28 -4
- package/dist/storage/domains/skill-overrides/base.d.ts.map +1 -1
- package/dist/storage/domains/skill-overrides/base.js +54 -1
- package/dist/storage/domains/skill-overrides/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +2 -0
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +13 -5
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/tools/audit-events-tool.d.ts +1 -1
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +0 -1
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +0 -3
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +2 -1
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/workspace.d.ts +5 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +69 -9
- package/dist/workspace.js.map +1 -1
- package/package.json +8 -8
|
@@ -149,9 +149,10 @@ export declare function closedByRoutes<T extends Omit<FactoryTransitionDecision,
|
|
|
149
149
|
export declare function pullRequestMoveByRoutes<T extends Omit<FactoryTransitionDecision, 'type' | 'event'>>(event: PullRequestEvent, move: T): FactoryTransitionDecision;
|
|
150
150
|
/**
|
|
151
151
|
* A decision carrying a pull request event, tagged with whether that pull request's author has
|
|
152
|
-
* write access (or is Factory)
|
|
152
|
+
* write access (or is Factory) — what a route's `pullRequest.trusted` tests — and with whether
|
|
153
|
+
* the actor who caused the event does, which run approval reads.
|
|
153
154
|
*/
|
|
154
|
-
export declare function withPullRequestTrust(entry: Record<string, unknown>, trusted: boolean): Record<string, unknown>;
|
|
155
|
+
export declare function withPullRequestTrust(entry: Record<string, unknown>, trusted: boolean, actorTrusted: boolean): Record<string, unknown>;
|
|
155
156
|
/**
|
|
156
157
|
* A decision the deployment's own handler returned stays its answer: a stock close move it
|
|
157
158
|
* wrapped or reused loses the event tag that would hand it to the project's intake routes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-rules.d.ts","sourceRoot":"","sources":["../../src/rules/event-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUnF,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEpF,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE3G,KAAK,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAC3G,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAIvH;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,MAAM,EAC1D,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,GACvD,CAAC,CAMH;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EACvC,SAAS,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,SAAS,EAC1D,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,IAAI,GACxC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,IAAI,CASrC;AAED;;;GAGG;AACH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gB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzF"}
|
|
@@ -256,9 +256,10 @@ function pullRequestMoveByRoutes(event, move) {
|
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* A decision carrying a pull request event, tagged with whether that pull request's author has
|
|
259
|
-
* write access (or is Factory)
|
|
259
|
+
* write access (or is Factory) — what a route's `pullRequest.trusted` tests — and with whether
|
|
260
|
+
* the actor who caused the event does, which run approval reads.
|
|
260
261
|
*/
|
|
261
|
-
function withPullRequestTrust(entry, trusted) {
|
|
262
|
+
function withPullRequestTrust(entry, trusted, actorTrusted) {
|
|
262
263
|
if (entry.type !== "transition" && entry.type !== "routeEvent") return entry;
|
|
263
264
|
const event = entry.event;
|
|
264
265
|
if (!event || !isPullRequestEvent(event.type)) return entry;
|
|
@@ -266,7 +267,8 @@ function withPullRequestTrust(entry, trusted) {
|
|
|
266
267
|
...entry,
|
|
267
268
|
event: {
|
|
268
269
|
...event,
|
|
269
|
-
pullRequestTrusted: trusted
|
|
270
|
+
pullRequestTrusted: trusted,
|
|
271
|
+
actorTrusted
|
|
270
272
|
}
|
|
271
273
|
};
|
|
272
274
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-rules.js","names":[],"sources":["../../src/rules/event-rules.ts"],"sourcesContent":["import type { BoardEventFacts, PullRequestEvent } from '../boards/board-events.js';\nimport {\n closeReason,\n eventMovesCard,\n isPullRequestEvent,\n isUpdateEvent,\n listChange,\n updateEventFacts,\n} from '../boards/board-events.js';\nimport { WorkItemUpdateConflictError } from '../storage/domains/work-items/base.js';\nimport type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { isPullRequestCard } from '../work-items/change-requests.js';\nimport type { FactoryRouteEventDecision, FactoryRuleHandler, FactoryTransitionDecision } from './types.js';\n\ntype EventRuleTable<E extends string, TContext> = Readonly<Record<E, FactoryRuleHandler<TContext> | null>>;\ntype BoardEventRuleMap<E extends string, TContext> = Readonly<Partial<Record<E, FactoryRuleHandler<TContext> | null>>>;\n\nconst explicitOverrides = new WeakMap<object, ReadonlySet<string>>();\n\n/**\n * Records which events a deployment set explicitly on an integration's `rules`. Those handlers keep\n * precedence over board event handlers, so integration-level wrappers behave exactly as before.\n */\nexport function recordExplicitRuleOverrides<T extends object>(\n rules: T,\n overrides: Readonly<Record<string, unknown>> | undefined,\n): T {\n const keys = Object.entries(overrides ?? {})\n .filter(([, handler]) => handler !== undefined)\n .map(([event]) => event);\n explicitOverrides.set(rules, Object.freeze(new Set(keys)));\n return rules;\n}\n\n/**\n * Runs a board event handler ahead of the integration default. A board handler that returns no\n * decision leaves the default in force, so card-independent defaults (filing a new card,\n * dismissing stale reviews) keep running on every board; `null` switches the default off.\n */\nexport function composeEventRule<TContext>(\n boardRule: FactoryRuleHandler<TContext> | null | undefined,\n base: FactoryRuleHandler<TContext> | null,\n): FactoryRuleHandler<TContext> | null {\n if (boardRule === null) return null;\n if (!boardRule) return base;\n if (!base) return boardRule;\n return context => {\n const decision = boardRule(context);\n if (isPromiseLike(decision)) return Promise.resolve(decision).then(resolved => resolved ?? base(context));\n return decision ?? base(context);\n };\n}\n\n/**\n * Handler that answers one integration event: a handler the deployment set explicitly on the\n * integration, else the card's board handler composed over the integration default.\n */\nexport function selectEventRule<E extends string, TContext>(\n rules: EventRuleTable<E, TContext>,\n boardRules: BoardEventRuleMap<E, TContext> | undefined,\n event: E,\n): FactoryRuleHandler<TContext> | null {\n const base = rules[event];\n if (hasExplicitRuleOverride(rules, event)) return base;\n return composeEventRule(boardRules?.[event], base);\n}\n\n/**\n * Whether the deployment answers the event itself: with a handler or `null` set explicitly on the\n * integration's `rules`, or with `null` on the card's board handlers. Intake routes then stay out\n * of it, so an override that moves nothing really moves nothing.\n */\nexport function deploymentOwnsEvent<E extends string, TContext>(\n rules: EventRuleTable<E, TContext>,\n boardRules: BoardEventRuleMap<E, TContext> | undefined,\n event: E,\n): boolean {\n return hasExplicitRuleOverride(rules, event) || boardRules?.[event] === null;\n}\n\n/** Whether the deployment set this event explicitly on the integration's `rules`. */\nexport function hasExplicitRuleOverride(rules: object, event: string): boolean {\n return explicitOverrides.get(rules)?.has(event) ?? false;\n}\n\nfunction isPromiseLike<T>(value: T | PromiseLike<T>): value is PromiseLike<T> {\n return typeof (value as { then?: unknown } | null | undefined)?.then === 'function';\n}\n\n/**\n * A decision that carries a work item's status event (a close, a reopen) for the card's routes.\n * Those overtake one another, so the source's last word wins. Pull request events don't: a merge,\n * a close or a push each concerns its own pull request, and the default rules already decided it.\n * Neither do updates: a label change never cancels a close or a reopen, nor is cancelled by one.\n */\nexport const isStatusEventDecision = (decision: Record<string, unknown>): boolean => {\n if (decision.type !== 'routeEvent' && decision.type !== 'transition') return false;\n const event = decision.event as BoardEventFacts | undefined;\n return event !== undefined && !isPullRequestEvent(event.type) && !isUpdateEvent(event.type);\n};\n\nconst QUEUED_STATUSES = ['pending', 'retry', 'leased'] as const;\n\n/**\n * The decision that hands a delivery's status event to the project's intake routes, when no rule\n * decided anything for it. Only an existing card is moved; new cards are placed when filed.\n */\nexport async function routeEventDecision(\n context: {\n item?: { id: string };\n phase?: { kind: string };\n boardEvent?: BoardEventFacts;\n ingress: { id: string };\n },\n storage: Pick<WorkItemsStorage, 'listDeferredDecisions'>,\n scope: { orgId: string; factoryProjectId: string },\n): Promise<FactoryRouteEventDecision | undefined> {\n const event = context.boardEvent;\n if (!context.item || !event || event.type === 'work_item.opened') return undefined;\n const decision = routeEvent(context.ingress.id, event);\n // A close moves only an unfinished card and a reopen only a finished one, unless an earlier\n // status event is still queued for the card: this one overtakes it, so the last one wins.\n if (eventMovesCard(event.type, context.phase?.kind === 'terminal')) return decision;\n const queued = await storage.listDeferredDecisions(scope.orgId, scope.factoryProjectId, {\n workItemId: context.item.id,\n statuses: QUEUED_STATUSES,\n });\n return queued.some(record => isStatusEventDecision(record.decision)) ? decision : undefined;\n}\n\nfunction routeEvent(ingressId: string, event: BoardEventFacts): FactoryRouteEventDecision {\n return { type: 'routeEvent', idempotencyKey: `${ingressId}:event-route`, event };\n}\n\n/**\n * The decision handing a label or assignee change to the card's routes. A change the card's own\n * session made (`fromCardSession`) is held until its run ends.\n */\nexport function cardUpdateDecision(\n ingressId: string,\n event: BoardEventFacts,\n fromCardSession: boolean,\n): FactoryRouteEventDecision {\n return { ...routeEvent(ingressId, event), ...(fromCardSession ? { fromCardSession: true as const } : {}) };\n}\n\n/**\n * Commits a label or assignee change on a card as an update event for the card's routes. Nothing\n * is committed when nothing changed. `fromCardSession` marks a change Factory made itself, which\n * the dispatcher holds until the card's run ends. The change has already been written to the card,\n * so a stale revision only means another write landed; re-read and commit against it.\n */\n/**\n * How handing an update to the card's routes went: queued (or already queued), nothing to hand\n * over, or not queued (the card is gone or kept changing), in which case the caller must not\n * record the change as seen, so a redelivery or the next sighting hands it over again.\n */\nexport type CardUpdateStatus = 'committed' | 'replayed' | 'unchanged' | 'ignored';\n\nexport async function commitCardUpdate(\n storage: Pick<WorkItemsStorage, 'commitRuleEvaluation' | 'get'>,\n input: {\n orgId: string;\n factoryProjectId: string;\n item: { id: string; revision: number };\n ingress: { identity: string };\n actor: Record<string, unknown>;\n event: BoardEventFacts | undefined;\n fromCardSession: boolean;\n now?: Date;\n },\n): Promise<CardUpdateStatus> {\n if (!input.event) return 'unchanged';\n const decision = cardUpdateDecision(input.ingress.identity, input.event, input.fromCardSession);\n let revision = input.item.revision;\n for (let attempt = 1; attempt <= 3; attempt++) {\n const committed = await storage.commitRuleEvaluation({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n workItemId: input.item.id,\n ingress: input.ingress,\n expectedRevision: revision,\n actor: input.actor,\n outcome: { status: 'accepted' },\n decisions: [{ ...decision }],\n causalChain: [],\n now: input.now ?? new Date(),\n });\n if (committed.status === 'committed' || committed.status === 'replayed') return committed.status;\n if (committed.status === 'missing') return 'ignored';\n const current = await storage.get({ orgId: input.orgId, id: input.item.id });\n if (!current) return 'ignored';\n revision = current.revision;\n }\n return 'ignored';\n}\n\n/** The labels and assignees a polled provider last reported for a card's item. */\nconst OBSERVED_ITEM_METADATA_KEY = 'observedItem';\n\nfunction observedItem(\n item: Pick<Card, 'metadata' | 'workItem'>,\n): { labels: string[]; assignees: string[]; observedAt: number | undefined } | undefined {\n const value = item.metadata?.[OBSERVED_ITEM_METADATA_KEY] ?? item.workItem.metadata?.[OBSERVED_ITEM_METADATA_KEY];\n if (!value || typeof value !== 'object') return undefined;\n const list = (entry: unknown) =>\n Array.isArray(entry) ? entry.filter((name): name is string => typeof name === 'string') : [];\n const record = value as Record<string, unknown>;\n const observedAt = typeof record.observedAt === 'string' ? Date.parse(record.observedAt) : Number.NaN;\n return {\n labels: list(record.labels),\n assignees: list(record.assignees),\n observedAt: Number.isNaN(observedAt) ? undefined : observedAt,\n };\n}\n\n/**\n * For a provider that only reports \"the item changed\" (Linear, Jira, incident.io are polled):\n * diffs the item's labels and assignee against the ones the last sighting recorded, records the\n * new ones, and hands the change to the card's routes as a `work_item.updated` event. The first\n * sighting only records them, so cards filed before this existed don't all fire at once. Polling\n * cannot tell who made the change, so it is never held for the card's run.\n */\nexport async function commitObservedChange(\n storage: Pick<WorkItemsStorage, 'commitRuleEvaluation' | 'get' | 'syncCard'>,\n input: {\n orgId: string;\n factoryProjectId: string;\n item: Pick<Card, 'id' | 'revision' | 'metadata' | 'workItem'>;\n ingressId: string;\n actor: Record<string, unknown>;\n labels: readonly string[];\n assignee: string | null;\n /** When the provider last changed the item, as it reported it: older sightings are ignored. */\n observedAt: string;\n /** Provider-specific metadata to record next to the labels and assignees. */\n metadata?: Record<string, unknown>;\n },\n): Promise<CardUpdateStatus> {\n const assignees = input.assignee ? [input.assignee] : [];\n const observedAt = Date.parse(input.observedAt);\n const metadata = {\n ...input.metadata,\n labels: [...input.labels],\n assignees,\n assignee: input.assignee,\n [OBSERVED_ITEM_METADATA_KEY]: { labels: [...input.labels], assignees, observedAt: input.observedAt },\n };\n let item = input.item;\n for (let attempt = 1; attempt <= 3; attempt++) {\n const seen = observedItem(item);\n // A late or replayed sighting older than the one recorded would report its change in reverse.\n if (seen?.observedAt !== undefined && observedAt < seen.observedAt) return 'unchanged';\n // The sighting already recorded: nothing to hand over, nothing new to record.\n if (\n seen?.observedAt === observedAt &&\n sameNames(seen.labels, input.labels) &&\n sameNames(seen.assignees, assignees)\n ) {\n return 'unchanged';\n }\n const event =\n seen &&\n updateEventFacts('work_item.updated', {\n labels: listChange(seen.labels, input.labels),\n assignees: listChange(seen.assignees, assignees),\n });\n // Both writes hold only while the card is at the revision this diff was worked out against,\n // so a concurrent sighting can't record over (or report against) what this one saw.\n if (!event) {\n // Nothing to hand over, but the sighting is still recorded, so an older one arriving later is ignored.\n try {\n await storage.syncCard({\n orgId: input.orgId,\n id: item.id,\n userId: CARD_SYNC_USER_ID,\n patch: { metadata },\n expectedRevision: item.revision,\n });\n return 'unchanged';\n } catch (error) {\n if (!(error instanceof WorkItemUpdateConflictError)) throw error;\n }\n } else {\n // Queued and recorded as seen in one write: a failure leaves neither, so the next sighting hands it over.\n const identity = `${input.ingressId}:update`;\n const committed = await storage.commitRuleEvaluation({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n workItemId: item.id,\n ingress: { identity },\n expectedRevision: item.revision,\n actor: input.actor,\n outcome: { status: 'accepted' },\n decisions: [{ ...cardUpdateDecision(identity, event, false) }],\n causalChain: [],\n now: new Date(),\n cardMetadata: { userId: CARD_SYNC_USER_ID, metadata },\n });\n if (committed.status === 'committed' || committed.status === 'replayed') return committed.status;\n if (committed.status === 'missing') return 'ignored';\n }\n // Another write moved the card: diff again against what it left.\n const current = await storage.get({ orgId: input.orgId, id: item.id });\n if (!current) return 'ignored';\n item = current;\n }\n return 'ignored';\n}\n\nconst CARD_SYNC_USER_ID = 'factory-rule-dispatcher';\n\nfunction sameNames(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((name, index) => name === b[index]);\n}\n\n/**\n * Tells whether a delivery's item was turned away by intake (Not routed): it has no card, but an\n * update to it should run intake again. Storage that keeps Not routed records provides it.\n */\nexport interface NotRoutedLookup {\n isNotRouted(scope: { orgId: string; factoryProjectId: string }, sourceKey: string): Promise<boolean>;\n}\n\n/** A pull or merge request's own card on a board with no pull request loop: Factory doesn't review it there. */\nexport function unreviewedPullRequestCard(context: {\n item?: { readonly source: string };\n flow?: { pullRequestReview?: string };\n}): boolean {\n return context.item !== undefined && isPullRequestCard(context.item) && context.flow?.pullRequestReview === undefined;\n}\n\n/**\n * A merge or close on a board with no pull request loop moves the card only where a route on its\n * board says; there is no move of Factory's own to fall back on.\n */\nexport function routedOnly(\n context: { phase?: { kind: string }; ingress: { id: string } },\n event: 'pull_request.merged' | 'pull_request.closed',\n): FactoryRouteEventDecision | undefined {\n if (context.phase?.kind === 'terminal') return undefined;\n return routeEvent(context.ingress.id, { type: event });\n}\n\n/**\n * A default close handler's answer: the board's `sourceClosed` move, which the project's intake\n * routes replace when a route on the card's board handles closes.\n */\nexport function closedByRoutes<T extends Omit<FactoryTransitionDecision, 'type' | 'event'>>(\n canceled: boolean,\n move: T,\n): FactoryTransitionDecision {\n return { type: 'transition', ...move, event: { type: 'work_item.closed', reason: closeReason(canceled) } };\n}\n\n/**\n * A default pull request handler's answer: the move it decided on, which a route on the card's\n * board naming the event sends elsewhere. A route to the same phase keeps the move as it is\n * (its message, its re-entry).\n */\nexport function pullRequestMoveByRoutes<T extends Omit<FactoryTransitionDecision, 'type' | 'event'>>(\n event: PullRequestEvent,\n move: T,\n): FactoryTransitionDecision {\n return { type: 'transition', ...move, event: { type: event } };\n}\n\n/**\n * A decision carrying a pull request event, tagged with whether that pull request's author has\n * write access (or is Factory): what a route's `pullRequest.trusted` tests.\n */\nexport function withPullRequestTrust(entry: Record<string, unknown>, trusted: boolean): Record<string, unknown> {\n if (entry.type !== 'transition' && entry.type !== 'routeEvent') return entry;\n const event = entry.event as BoardEventFacts | undefined;\n if (!event || !isPullRequestEvent(event.type)) return entry;\n return { ...entry, event: { ...event, pullRequestTrusted: trusted } };\n}\n\n/**\n * A decision the deployment's own handler returned stays its answer: a stock close move it\n * wrapped or reused loses the event tag that would hand it to the project's intake routes.\n */\nexport function withoutRouteEvent(entry: Record<string, unknown>): Record<string, unknown> {\n if (entry.type !== 'transition' || entry.event === undefined) return entry;\n const { event: _event, ...move } = entry;\n return move;\n}\n"],"mappings":";;;;AAiBA,MAAM,oCAAoB,IAAI,QAAqC;;;;;AAMnE,SAAgB,4BACd,OACA,WACG;CACH,MAAM,OAAO,OAAO,QAAQ,aAAa,CAAC,CAAC,CAAC,CACzC,QAAQ,GAAG,aAAa,YAAY,KAAA,CAAS,CAAC,CAC9C,KAAK,CAAC,WAAW,KAAK;CACzB,kBAAkB,IAAI,OAAO,OAAO,OAAO,IAAI,IAAI,IAAI,CAAC,CAAC;CACzD,OAAO;AACT;;;;;;AAOA,SAAgB,iBACd,WACA,MACqC;CACrC,IAAI,cAAc,MAAM,OAAO;CAC/B,IAAI,CAAC,WAAW,OAAO;CACvB,IAAI,CAAC,MAAM,OAAO;CAClB,QAAO,YAAW;EAChB,MAAM,WAAW,UAAU,OAAO;EAClC,IAAI,cAAc,QAAQ,GAAG,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CAAC,MAAK,aAAY,YAAY,KAAK,OAAO,CAAC;EACxG,OAAO,YAAY,KAAK,OAAO;CACjC;AACF;;;;;AAMA,SAAgB,gBACd,OACA,YACA,OACqC;CACrC,MAAM,OAAO,MAAM;CACnB,IAAI,wBAAwB,OAAO,KAAK,GAAG,OAAO;CAClD,OAAO,iBAAiB,aAAa,QAAQ,IAAI;AACnD;;;;;;AAOA,SAAgB,oBACd,OACA,YACA,OACS;CACT,OAAO,wBAAwB,OAAO,KAAK,KAAK,aAAa,WAAW;AAC1E;;AAGA,SAAgB,wBAAwB,OAAe,OAAwB;CAC7E,OAAO,kBAAkB,IAAI,KAAK,CA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,gBAAgB,MAAM,UAAU,KAAA,GAAW,OAAO;CACrE,MAAM,EAAE,OAAO,QAAQ,GAAG,SAAS;CACnC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"event-rules.js","names":[],"sources":["../../src/rules/event-rules.ts"],"sourcesContent":["import type { BoardEventFacts, PullRequestEvent } from '../boards/board-events.js';\nimport {\n closeReason,\n eventMovesCard,\n isPullRequestEvent,\n isUpdateEvent,\n listChange,\n updateEventFacts,\n} from '../boards/board-events.js';\nimport { WorkItemUpdateConflictError } from '../storage/domains/work-items/base.js';\nimport type { Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { isPullRequestCard } from '../work-items/change-requests.js';\nimport type { FactoryRouteEventDecision, FactoryRuleHandler, FactoryTransitionDecision } from './types.js';\n\ntype EventRuleTable<E extends string, TContext> = Readonly<Record<E, FactoryRuleHandler<TContext> | null>>;\ntype BoardEventRuleMap<E extends string, TContext> = Readonly<Partial<Record<E, FactoryRuleHandler<TContext> | null>>>;\n\nconst explicitOverrides = new WeakMap<object, ReadonlySet<string>>();\n\n/**\n * Records which events a deployment set explicitly on an integration's `rules`. Those handlers keep\n * precedence over board event handlers, so integration-level wrappers behave exactly as before.\n */\nexport function recordExplicitRuleOverrides<T extends object>(\n rules: T,\n overrides: Readonly<Record<string, unknown>> | undefined,\n): T {\n const keys = Object.entries(overrides ?? {})\n .filter(([, handler]) => handler !== undefined)\n .map(([event]) => event);\n explicitOverrides.set(rules, Object.freeze(new Set(keys)));\n return rules;\n}\n\n/**\n * Runs a board event handler ahead of the integration default. A board handler that returns no\n * decision leaves the default in force, so card-independent defaults (filing a new card,\n * dismissing stale reviews) keep running on every board; `null` switches the default off.\n */\nexport function composeEventRule<TContext>(\n boardRule: FactoryRuleHandler<TContext> | null | undefined,\n base: FactoryRuleHandler<TContext> | null,\n): FactoryRuleHandler<TContext> | null {\n if (boardRule === null) return null;\n if (!boardRule) return base;\n if (!base) return boardRule;\n return context => {\n const decision = boardRule(context);\n if (isPromiseLike(decision)) return Promise.resolve(decision).then(resolved => resolved ?? base(context));\n return decision ?? base(context);\n };\n}\n\n/**\n * Handler that answers one integration event: a handler the deployment set explicitly on the\n * integration, else the card's board handler composed over the integration default.\n */\nexport function selectEventRule<E extends string, TContext>(\n rules: EventRuleTable<E, TContext>,\n boardRules: BoardEventRuleMap<E, TContext> | undefined,\n event: E,\n): FactoryRuleHandler<TContext> | null {\n const base = rules[event];\n if (hasExplicitRuleOverride(rules, event)) return base;\n return composeEventRule(boardRules?.[event], base);\n}\n\n/**\n * Whether the deployment answers the event itself: with a handler or `null` set explicitly on the\n * integration's `rules`, or with `null` on the card's board handlers. Intake routes then stay out\n * of it, so an override that moves nothing really moves nothing.\n */\nexport function deploymentOwnsEvent<E extends string, TContext>(\n rules: EventRuleTable<E, TContext>,\n boardRules: BoardEventRuleMap<E, TContext> | undefined,\n event: E,\n): boolean {\n return hasExplicitRuleOverride(rules, event) || boardRules?.[event] === null;\n}\n\n/** Whether the deployment set this event explicitly on the integration's `rules`. */\nexport function hasExplicitRuleOverride(rules: object, event: string): boolean {\n return explicitOverrides.get(rules)?.has(event) ?? false;\n}\n\nfunction isPromiseLike<T>(value: T | PromiseLike<T>): value is PromiseLike<T> {\n return typeof (value as { then?: unknown } | null | undefined)?.then === 'function';\n}\n\n/**\n * A decision that carries a work item's status event (a close, a reopen) for the card's routes.\n * Those overtake one another, so the source's last word wins. Pull request events don't: a merge,\n * a close or a push each concerns its own pull request, and the default rules already decided it.\n * Neither do updates: a label change never cancels a close or a reopen, nor is cancelled by one.\n */\nexport const isStatusEventDecision = (decision: Record<string, unknown>): boolean => {\n if (decision.type !== 'routeEvent' && decision.type !== 'transition') return false;\n const event = decision.event as BoardEventFacts | undefined;\n return event !== undefined && !isPullRequestEvent(event.type) && !isUpdateEvent(event.type);\n};\n\nconst QUEUED_STATUSES = ['pending', 'retry', 'leased'] as const;\n\n/**\n * The decision that hands a delivery's status event to the project's intake routes, when no rule\n * decided anything for it. Only an existing card is moved; new cards are placed when filed.\n */\nexport async function routeEventDecision(\n context: {\n item?: { id: string };\n phase?: { kind: string };\n boardEvent?: BoardEventFacts;\n ingress: { id: string };\n },\n storage: Pick<WorkItemsStorage, 'listDeferredDecisions'>,\n scope: { orgId: string; factoryProjectId: string },\n): Promise<FactoryRouteEventDecision | undefined> {\n const event = context.boardEvent;\n if (!context.item || !event || event.type === 'work_item.opened') return undefined;\n const decision = routeEvent(context.ingress.id, event);\n // A close moves only an unfinished card and a reopen only a finished one, unless an earlier\n // status event is still queued for the card: this one overtakes it, so the last one wins.\n if (eventMovesCard(event.type, context.phase?.kind === 'terminal')) return decision;\n const queued = await storage.listDeferredDecisions(scope.orgId, scope.factoryProjectId, {\n workItemId: context.item.id,\n statuses: QUEUED_STATUSES,\n });\n return queued.some(record => isStatusEventDecision(record.decision)) ? decision : undefined;\n}\n\nfunction routeEvent(ingressId: string, event: BoardEventFacts): FactoryRouteEventDecision {\n return { type: 'routeEvent', idempotencyKey: `${ingressId}:event-route`, event };\n}\n\n/**\n * The decision handing a label or assignee change to the card's routes. A change the card's own\n * session made (`fromCardSession`) is held until its run ends.\n */\nexport function cardUpdateDecision(\n ingressId: string,\n event: BoardEventFacts,\n fromCardSession: boolean,\n): FactoryRouteEventDecision {\n return { ...routeEvent(ingressId, event), ...(fromCardSession ? { fromCardSession: true as const } : {}) };\n}\n\n/**\n * Commits a label or assignee change on a card as an update event for the card's routes. Nothing\n * is committed when nothing changed. `fromCardSession` marks a change Factory made itself, which\n * the dispatcher holds until the card's run ends. The change has already been written to the card,\n * so a stale revision only means another write landed; re-read and commit against it.\n */\n/**\n * How handing an update to the card's routes went: queued (or already queued), nothing to hand\n * over, or not queued (the card is gone or kept changing), in which case the caller must not\n * record the change as seen, so a redelivery or the next sighting hands it over again.\n */\nexport type CardUpdateStatus = 'committed' | 'replayed' | 'unchanged' | 'ignored';\n\nexport async function commitCardUpdate(\n storage: Pick<WorkItemsStorage, 'commitRuleEvaluation' | 'get'>,\n input: {\n orgId: string;\n factoryProjectId: string;\n item: { id: string; revision: number };\n ingress: { identity: string };\n actor: Record<string, unknown>;\n event: BoardEventFacts | undefined;\n fromCardSession: boolean;\n now?: Date;\n },\n): Promise<CardUpdateStatus> {\n if (!input.event) return 'unchanged';\n const decision = cardUpdateDecision(input.ingress.identity, input.event, input.fromCardSession);\n let revision = input.item.revision;\n for (let attempt = 1; attempt <= 3; attempt++) {\n const committed = await storage.commitRuleEvaluation({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n workItemId: input.item.id,\n ingress: input.ingress,\n expectedRevision: revision,\n actor: input.actor,\n outcome: { status: 'accepted' },\n decisions: [{ ...decision }],\n causalChain: [],\n now: input.now ?? new Date(),\n });\n if (committed.status === 'committed' || committed.status === 'replayed') return committed.status;\n if (committed.status === 'missing') return 'ignored';\n const current = await storage.get({ orgId: input.orgId, id: input.item.id });\n if (!current) return 'ignored';\n revision = current.revision;\n }\n return 'ignored';\n}\n\n/** The labels and assignees a polled provider last reported for a card's item. */\nconst OBSERVED_ITEM_METADATA_KEY = 'observedItem';\n\nfunction observedItem(\n item: Pick<Card, 'metadata' | 'workItem'>,\n): { labels: string[]; assignees: string[]; observedAt: number | undefined } | undefined {\n const value = item.metadata?.[OBSERVED_ITEM_METADATA_KEY] ?? item.workItem.metadata?.[OBSERVED_ITEM_METADATA_KEY];\n if (!value || typeof value !== 'object') return undefined;\n const list = (entry: unknown) =>\n Array.isArray(entry) ? entry.filter((name): name is string => typeof name === 'string') : [];\n const record = value as Record<string, unknown>;\n const observedAt = typeof record.observedAt === 'string' ? Date.parse(record.observedAt) : Number.NaN;\n return {\n labels: list(record.labels),\n assignees: list(record.assignees),\n observedAt: Number.isNaN(observedAt) ? undefined : observedAt,\n };\n}\n\n/**\n * For a provider that only reports \"the item changed\" (Linear, Jira, incident.io are polled):\n * diffs the item's labels and assignee against the ones the last sighting recorded, records the\n * new ones, and hands the change to the card's routes as a `work_item.updated` event. The first\n * sighting only records them, so cards filed before this existed don't all fire at once. Polling\n * cannot tell who made the change, so it is never held for the card's run.\n */\nexport async function commitObservedChange(\n storage: Pick<WorkItemsStorage, 'commitRuleEvaluation' | 'get' | 'syncCard'>,\n input: {\n orgId: string;\n factoryProjectId: string;\n item: Pick<Card, 'id' | 'revision' | 'metadata' | 'workItem'>;\n ingressId: string;\n actor: Record<string, unknown>;\n labels: readonly string[];\n assignee: string | null;\n /** When the provider last changed the item, as it reported it: older sightings are ignored. */\n observedAt: string;\n /** Provider-specific metadata to record next to the labels and assignees. */\n metadata?: Record<string, unknown>;\n },\n): Promise<CardUpdateStatus> {\n const assignees = input.assignee ? [input.assignee] : [];\n const observedAt = Date.parse(input.observedAt);\n const metadata = {\n ...input.metadata,\n labels: [...input.labels],\n assignees,\n assignee: input.assignee,\n [OBSERVED_ITEM_METADATA_KEY]: { labels: [...input.labels], assignees, observedAt: input.observedAt },\n };\n let item = input.item;\n for (let attempt = 1; attempt <= 3; attempt++) {\n const seen = observedItem(item);\n // A late or replayed sighting older than the one recorded would report its change in reverse.\n if (seen?.observedAt !== undefined && observedAt < seen.observedAt) return 'unchanged';\n // The sighting already recorded: nothing to hand over, nothing new to record.\n if (\n seen?.observedAt === observedAt &&\n sameNames(seen.labels, input.labels) &&\n sameNames(seen.assignees, assignees)\n ) {\n return 'unchanged';\n }\n const event =\n seen &&\n updateEventFacts('work_item.updated', {\n labels: listChange(seen.labels, input.labels),\n assignees: listChange(seen.assignees, assignees),\n });\n // Both writes hold only while the card is at the revision this diff was worked out against,\n // so a concurrent sighting can't record over (or report against) what this one saw.\n if (!event) {\n // Nothing to hand over, but the sighting is still recorded, so an older one arriving later is ignored.\n try {\n await storage.syncCard({\n orgId: input.orgId,\n id: item.id,\n userId: CARD_SYNC_USER_ID,\n patch: { metadata },\n expectedRevision: item.revision,\n });\n return 'unchanged';\n } catch (error) {\n if (!(error instanceof WorkItemUpdateConflictError)) throw error;\n }\n } else {\n // Queued and recorded as seen in one write: a failure leaves neither, so the next sighting hands it over.\n const identity = `${input.ingressId}:update`;\n const committed = await storage.commitRuleEvaluation({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n workItemId: item.id,\n ingress: { identity },\n expectedRevision: item.revision,\n actor: input.actor,\n outcome: { status: 'accepted' },\n decisions: [{ ...cardUpdateDecision(identity, event, false) }],\n causalChain: [],\n now: new Date(),\n cardMetadata: { userId: CARD_SYNC_USER_ID, metadata },\n });\n if (committed.status === 'committed' || committed.status === 'replayed') return committed.status;\n if (committed.status === 'missing') return 'ignored';\n }\n // Another write moved the card: diff again against what it left.\n const current = await storage.get({ orgId: input.orgId, id: item.id });\n if (!current) return 'ignored';\n item = current;\n }\n return 'ignored';\n}\n\nconst CARD_SYNC_USER_ID = 'factory-rule-dispatcher';\n\nfunction sameNames(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((name, index) => name === b[index]);\n}\n\n/**\n * Tells whether a delivery's item was turned away by intake (Not routed): it has no card, but an\n * update to it should run intake again. Storage that keeps Not routed records provides it.\n */\nexport interface NotRoutedLookup {\n isNotRouted(scope: { orgId: string; factoryProjectId: string }, sourceKey: string): Promise<boolean>;\n}\n\n/** A pull or merge request's own card on a board with no pull request loop: Factory doesn't review it there. */\nexport function unreviewedPullRequestCard(context: {\n item?: { readonly source: string };\n flow?: { pullRequestReview?: string };\n}): boolean {\n return context.item !== undefined && isPullRequestCard(context.item) && context.flow?.pullRequestReview === undefined;\n}\n\n/**\n * A merge or close on a board with no pull request loop moves the card only where a route on its\n * board says; there is no move of Factory's own to fall back on.\n */\nexport function routedOnly(\n context: { phase?: { kind: string }; ingress: { id: string } },\n event: 'pull_request.merged' | 'pull_request.closed',\n): FactoryRouteEventDecision | undefined {\n if (context.phase?.kind === 'terminal') return undefined;\n return routeEvent(context.ingress.id, { type: event });\n}\n\n/**\n * A default close handler's answer: the board's `sourceClosed` move, which the project's intake\n * routes replace when a route on the card's board handles closes.\n */\nexport function closedByRoutes<T extends Omit<FactoryTransitionDecision, 'type' | 'event'>>(\n canceled: boolean,\n move: T,\n): FactoryTransitionDecision {\n return { type: 'transition', ...move, event: { type: 'work_item.closed', reason: closeReason(canceled) } };\n}\n\n/**\n * A default pull request handler's answer: the move it decided on, which a route on the card's\n * board naming the event sends elsewhere. A route to the same phase keeps the move as it is\n * (its message, its re-entry).\n */\nexport function pullRequestMoveByRoutes<T extends Omit<FactoryTransitionDecision, 'type' | 'event'>>(\n event: PullRequestEvent,\n move: T,\n): FactoryTransitionDecision {\n return { type: 'transition', ...move, event: { type: event } };\n}\n\n/**\n * A decision carrying a pull request event, tagged with whether that pull request's author has\n * write access (or is Factory) — what a route's `pullRequest.trusted` tests — and with whether\n * the actor who caused the event does, which run approval reads.\n */\nexport function withPullRequestTrust(\n entry: Record<string, unknown>,\n trusted: boolean,\n actorTrusted: boolean,\n): Record<string, unknown> {\n if (entry.type !== 'transition' && entry.type !== 'routeEvent') return entry;\n const event = entry.event as BoardEventFacts | undefined;\n if (!event || !isPullRequestEvent(event.type)) return entry;\n return { ...entry, event: { ...event, pullRequestTrusted: trusted, actorTrusted } };\n}\n\n/**\n * A decision the deployment's own handler returned stays its answer: a stock close move it\n * wrapped or reused loses the event tag that would hand it to the project's intake routes.\n */\nexport function withoutRouteEvent(entry: Record<string, unknown>): Record<string, unknown> {\n if (entry.type !== 'transition' || entry.event === undefined) return entry;\n const { event: _event, ...move } = entry;\n return move;\n}\n"],"mappings":";;;;AAiBA,MAAM,oCAAoB,IAAI,QAAqC;;;;;AAMnE,SAAgB,4BACd,OACA,WACG;CACH,MAAM,OAAO,OAAO,QAAQ,aAAa,CAAC,CAAC,CAAC,CACzC,QAAQ,GAAG,aAAa,YAAY,KAAA,CAAS,CAAC,CAC9C,KAAK,CAAC,WAAW,KAAK;CACzB,kBAAkB,IAAI,OAAO,OAAO,OAAO,IAAI,IAAI,IAAI,CAAC,CAAC;CACzD,OAAO;AACT;;;;;;AAOA,SAAgB,iBACd,WACA,MACqC;CACrC,IAAI,cAAc,MAAM,OAAO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AAMA,SAAgB,eACd,UACA,MAC2B;CAC3B,OAAO;EAAE,MAAM;EAAc,GAAG;EAAM,OAAO;GAAE,MAAM;GAAoB,QAAQ,YAAY,QAAQ;EAAE;CAAE;AAC3G;;;;;;AAOA,SAAgB,wBACd,OACA,MAC2B;CAC3B,OAAO;EAAE,MAAM;EAAc,GAAG;EAAM,OAAO,EAAE,MAAM,MAAM;CAAE;AAC/D;;;;;;AAOA,SAAgB,qBACd,OACA,SACA,cACyB;CACzB,IAAI,MAAM,SAAS,gBAAgB,MAAM,SAAS,cAAc,OAAO;CACvE,MAAM,QAAQ,MAAM;CACpB,IAAI,CAAC,SAAS,CAAC,mBAAmB,MAAM,IAAI,GAAG,OAAO;CACtD,OAAO;EAAE,GAAG;EAAO,OAAO;GAAE,GAAG;GAAO,oBAAoB;GAAS;EAAa;CAAE;AACpF;;;;;AAMA,SAAgB,kBAAkB,OAAyD;CACzF,IAAI,MAAM,SAAS,gBAAgB,MAAM,UAAU,KAAA,GAAW,OAAO;CACrE,MAAM,EAAE,OAAO,QAAQ,GAAG,SAAS;CACnC,OAAO;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FactoryDispatchFailureCode } from '../storage/domains/work-items/base.js';
|
|
2
|
+
export declare function causeOf(error: unknown): unknown;
|
|
3
|
+
export declare function isProviderCallError(error: unknown): boolean;
|
|
4
|
+
export declare const FACTORY_ERROR_NAMES: ReadonlySet<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Why a run failed, safe to show on a public pull request: the failure code's label,
|
|
7
|
+
* plus a detail drawn from a fixed vocabulary when the error can be classified.
|
|
8
|
+
* Error messages are never included; operators read those from the decision's stored error.
|
|
9
|
+
*/
|
|
10
|
+
export declare function publicFailureReason(code: FactoryDispatchFailureCode, error: unknown): string;
|
|
11
|
+
//# sourceMappingURL=public-failure-reason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-failure-reason.d.ts","sourceRoot":"","sources":["../../src/rules/public-failure-reason.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAIxF,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/C;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI3D;AA4CD,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAiClD,CAAC;AA4DH;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAI5F"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { FactoryRuleRejectedError, factoryDispatchFailureMetadata } from "./dispatch-errors.js";
|
|
2
|
+
import { PROVIDER_CALL_ERROR_NAME, classifyProviderError } from "@mastra/core/error";
|
|
3
|
+
// src/rules/public-failure-reason.ts
|
|
4
|
+
function causeOf(error) {
|
|
5
|
+
return error && typeof error === "object" && "cause" in error ? error.cause : void 0;
|
|
6
|
+
}
|
|
7
|
+
function isProviderCallError(error) {
|
|
8
|
+
if (!error || typeof error !== "object") return false;
|
|
9
|
+
if ("name" in error && typeof error.name === "string" && PROVIDER_CALL_ERROR_NAME.test(error.name)) return true;
|
|
10
|
+
return "statusCode" in error || "responseBody" in error;
|
|
11
|
+
}
|
|
12
|
+
const PROVIDER_FAILURE_DETAIL = {
|
|
13
|
+
auth: "the model provider rejected the credentials",
|
|
14
|
+
quota: "the model provider quota is exhausted",
|
|
15
|
+
rate_limited: "the model provider rate-limited the run",
|
|
16
|
+
context_overflow: "the conversation exceeded the model context window",
|
|
17
|
+
model_rejected: "the model provider rejected the model",
|
|
18
|
+
tool_history_rejected: "the model provider rejected the tool-call history",
|
|
19
|
+
timeout: "the model provider timed out",
|
|
20
|
+
unavailable: "the model provider was unavailable",
|
|
21
|
+
invalid_request: "the model provider rejected the request"
|
|
22
|
+
};
|
|
23
|
+
const RULE_REJECTION_DETAIL = {
|
|
24
|
+
forbidden: "the board refused the move",
|
|
25
|
+
invalid_transition: "the board does not allow that move",
|
|
26
|
+
missing_binding: "the card has no run binding for that move",
|
|
27
|
+
stale: "the card changed while it was being moved",
|
|
28
|
+
timeout: "a board rule timed out",
|
|
29
|
+
rule_error: "a board rule threw an error",
|
|
30
|
+
causal_depth_exceeded: "too many automatic moves chained from one change",
|
|
31
|
+
repeated_transition: "the same automatic move repeated too often",
|
|
32
|
+
approval_required: "the move needs approval from a person",
|
|
33
|
+
card_busy: "a run is already in flight on the card"
|
|
34
|
+
};
|
|
35
|
+
const BUILT_IN_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
36
|
+
"AbortError",
|
|
37
|
+
"EvalError",
|
|
38
|
+
"RangeError",
|
|
39
|
+
"ReferenceError",
|
|
40
|
+
"SyntaxError",
|
|
41
|
+
"TimeoutError",
|
|
42
|
+
"TypeError",
|
|
43
|
+
"URIError"
|
|
44
|
+
]);
|
|
45
|
+
const FACTORY_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
46
|
+
"BoardDefinitionError",
|
|
47
|
+
"BoardWriteError",
|
|
48
|
+
"FactoryProjectNotFoundError",
|
|
49
|
+
"FactoryRuleValidationError",
|
|
50
|
+
"FactoryRunBindingSupersededError",
|
|
51
|
+
"FactorySecretDecryptionError",
|
|
52
|
+
"FactorySourceControlConflictError",
|
|
53
|
+
"FactorySourceSessionResolutionError",
|
|
54
|
+
"FactoryStartTransitionError",
|
|
55
|
+
"GitLabApiError",
|
|
56
|
+
"IncidentioApiError",
|
|
57
|
+
"JiraApiError",
|
|
58
|
+
"LinearReauthRequiredError",
|
|
59
|
+
"MastraGatewayError",
|
|
60
|
+
"MaterializeError",
|
|
61
|
+
"PlatformApiError",
|
|
62
|
+
"PullRequestClosedError",
|
|
63
|
+
"RealtimeSessionError",
|
|
64
|
+
"ReviewBoardInUseError",
|
|
65
|
+
"SessionBranchHeldError",
|
|
66
|
+
"SessionOwnershipMismatchError",
|
|
67
|
+
"SetupCommandError",
|
|
68
|
+
"SkillInvocationError",
|
|
69
|
+
"SlackSessionStartError",
|
|
70
|
+
"SourceControlConnectionNotFoundError",
|
|
71
|
+
"StoredBoardError",
|
|
72
|
+
"UntrustedSharedSessionError",
|
|
73
|
+
"WorkItemRelationError",
|
|
74
|
+
"WorkItemRepositoryError",
|
|
75
|
+
"WorkItemSourceConflictError",
|
|
76
|
+
"WorkItemSplitModeError",
|
|
77
|
+
"WorkItemUpdateConflictError"
|
|
78
|
+
]);
|
|
79
|
+
const MAX_CAUSE_DEPTH = 8;
|
|
80
|
+
function causeChain(error) {
|
|
81
|
+
const chain = [];
|
|
82
|
+
for (let current = error; current && chain.length < MAX_CAUSE_DEPTH; current = causeOf(current)) {
|
|
83
|
+
if (typeof current !== "object" || chain.includes(current)) break;
|
|
84
|
+
chain.push(current);
|
|
85
|
+
}
|
|
86
|
+
return chain;
|
|
87
|
+
}
|
|
88
|
+
function field(error, key) {
|
|
89
|
+
return error[key];
|
|
90
|
+
}
|
|
91
|
+
/** The error's name, or its class name when it never set one; bundlers may suffix a renamed class with `$n`. */
|
|
92
|
+
function namesOf(error) {
|
|
93
|
+
const names = [];
|
|
94
|
+
const name = field(error, "name");
|
|
95
|
+
if (typeof name === "string") names.push(name);
|
|
96
|
+
const constructorName = error.constructor?.name;
|
|
97
|
+
if (typeof constructorName === "string") names.push(constructorName.replace(/\$\d+$/, ""));
|
|
98
|
+
return names;
|
|
99
|
+
}
|
|
100
|
+
function providerDetail(error) {
|
|
101
|
+
if (!isProviderCallError(error)) return void 0;
|
|
102
|
+
const kind = classifyProviderError(error);
|
|
103
|
+
if (kind === "unknown") return void 0;
|
|
104
|
+
const status = field(error, "statusCode");
|
|
105
|
+
return typeof status === "number" && Number.isInteger(status) && status >= 400 && status < 600 ? `${PROVIDER_FAILURE_DETAIL[kind]}, HTTP ${status}` : PROVIDER_FAILURE_DETAIL[kind];
|
|
106
|
+
}
|
|
107
|
+
function ruleRejectionDetail(error) {
|
|
108
|
+
if (!(error instanceof FactoryRuleRejectedError)) return void 0;
|
|
109
|
+
return Object.hasOwn(RULE_REJECTION_DETAIL, error.code) ? RULE_REJECTION_DETAIL[error.code] : void 0;
|
|
110
|
+
}
|
|
111
|
+
function first(chain, pick) {
|
|
112
|
+
for (const error of chain) {
|
|
113
|
+
const picked = pick(error);
|
|
114
|
+
if (picked !== void 0) return picked;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function publicDetail(error) {
|
|
118
|
+
const chain = causeChain(error);
|
|
119
|
+
const where = first(chain, (candidate) => namesOf(candidate).find((name) => FACTORY_ERROR_NAMES.has(name)));
|
|
120
|
+
const what = first(chain, providerDetail) ?? first(chain, ruleRejectionDetail) ?? first(chain, (candidate) => namesOf(candidate).find((name) => BUILT_IN_ERROR_NAMES.has(name)));
|
|
121
|
+
if (where && what) return `${where}: ${what}`;
|
|
122
|
+
return where ?? what;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Why a run failed, safe to show on a public pull request: the failure code's label,
|
|
126
|
+
* plus a detail drawn from a fixed vocabulary when the error can be classified.
|
|
127
|
+
* Error messages are never included; operators read those from the decision's stored error.
|
|
128
|
+
*/
|
|
129
|
+
function publicFailureReason(code, error) {
|
|
130
|
+
const label = factoryDispatchFailureMetadata(code).label;
|
|
131
|
+
const detail = publicDetail(error);
|
|
132
|
+
return detail ? `${label} (${detail})` : label;
|
|
133
|
+
}
|
|
134
|
+
export { FACTORY_ERROR_NAMES, causeOf, isProviderCallError, publicFailureReason };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=public-failure-reason.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-failure-reason.js","names":[],"sources":["../../src/rules/public-failure-reason.ts"],"sourcesContent":["import { classifyProviderError, PROVIDER_CALL_ERROR_NAME } from '@mastra/core/error';\nimport type { ProviderFailureKind } from '@mastra/core/error';\n\nimport type { FactoryDispatchFailureCode } from '../storage/domains/work-items/base.js';\nimport { factoryDispatchFailureMetadata, FactoryRuleRejectedError } from './dispatch-errors.js';\nimport type { FactoryRuleRejectionCode } from './types.js';\n\nexport function causeOf(error: unknown): unknown {\n return error && typeof error === 'object' && 'cause' in error ? error.cause : undefined;\n}\n\nexport function isProviderCallError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n if ('name' in error && typeof error.name === 'string' && PROVIDER_CALL_ERROR_NAME.test(error.name)) return true;\n return 'statusCode' in error || 'responseBody' in error;\n}\n\n// Everything below is fixed wording or a name from Factory's public source:\n// a public pull request must never see provider or internal error text.\n\nconst PROVIDER_FAILURE_DETAIL: Record<Exclude<ProviderFailureKind, 'unknown'>, string> = {\n auth: 'the model provider rejected the credentials',\n quota: 'the model provider quota is exhausted',\n rate_limited: 'the model provider rate-limited the run',\n context_overflow: 'the conversation exceeded the model context window',\n model_rejected: 'the model provider rejected the model',\n tool_history_rejected: 'the model provider rejected the tool-call history',\n timeout: 'the model provider timed out',\n unavailable: 'the model provider was unavailable',\n invalid_request: 'the model provider rejected the request',\n};\n\nconst RULE_REJECTION_DETAIL: Record<FactoryRuleRejectionCode, string> = {\n forbidden: 'the board refused the move',\n invalid_transition: 'the board does not allow that move',\n missing_binding: 'the card has no run binding for that move',\n stale: 'the card changed while it was being moved',\n timeout: 'a board rule timed out',\n rule_error: 'a board rule threw an error',\n causal_depth_exceeded: 'too many automatic moves chained from one change',\n repeated_transition: 'the same automatic move repeated too often',\n approval_required: 'the move needs approval from a person',\n card_busy: 'a run is already in flight on the card',\n};\n\n// Built-in error names say what kind of fault it was without saying anything about where.\nconst BUILT_IN_ERROR_NAMES = new Set([\n 'AbortError',\n 'EvalError',\n 'RangeError',\n 'ReferenceError',\n 'SyntaxError',\n 'TimeoutError',\n 'TypeError',\n 'URIError',\n]);\n\n// Factory's own error classes say where it failed; the names are in its public source.\n// A test fails when a new error class is neither listed here nor excluded in public-failure-reason.test.ts.\nexport const FACTORY_ERROR_NAMES: ReadonlySet<string> = new Set([\n 'BoardDefinitionError',\n 'BoardWriteError',\n 'FactoryProjectNotFoundError',\n 'FactoryRuleValidationError',\n 'FactoryRunBindingSupersededError',\n 'FactorySecretDecryptionError',\n 'FactorySourceControlConflictError',\n 'FactorySourceSessionResolutionError',\n 'FactoryStartTransitionError',\n 'GitLabApiError',\n 'IncidentioApiError',\n 'JiraApiError',\n 'LinearReauthRequiredError',\n 'MastraGatewayError',\n 'MaterializeError',\n 'PlatformApiError',\n 'PullRequestClosedError',\n 'RealtimeSessionError',\n 'ReviewBoardInUseError',\n 'SessionBranchHeldError',\n 'SessionOwnershipMismatchError',\n 'SetupCommandError',\n 'SkillInvocationError',\n 'SlackSessionStartError',\n 'SourceControlConnectionNotFoundError',\n 'StoredBoardError',\n 'UntrustedSharedSessionError',\n 'WorkItemRelationError',\n 'WorkItemRepositoryError',\n 'WorkItemSourceConflictError',\n 'WorkItemSplitModeError',\n 'WorkItemUpdateConflictError',\n]);\n\nconst MAX_CAUSE_DEPTH = 8;\n\nfunction causeChain(error: unknown): object[] {\n const chain: object[] = [];\n for (let current = error; current && chain.length < MAX_CAUSE_DEPTH; current = causeOf(current)) {\n if (typeof current !== 'object' || chain.includes(current)) break;\n chain.push(current);\n }\n return chain;\n}\n\nfunction field(error: object, key: string): unknown {\n return (error as Record<string, unknown>)[key];\n}\n\n/** The error's name, or its class name when it never set one; bundlers may suffix a renamed class with `$n`. */\nfunction namesOf(error: object): string[] {\n const names: string[] = [];\n const name = field(error, 'name');\n if (typeof name === 'string') names.push(name);\n const constructorName = (error as { constructor?: { name?: unknown } }).constructor?.name;\n if (typeof constructorName === 'string') names.push(constructorName.replace(/\\$\\d+$/, ''));\n return names;\n}\n\nfunction providerDetail(error: object): string | undefined {\n if (!isProviderCallError(error)) return undefined;\n const kind = classifyProviderError(error);\n if (kind === 'unknown') return undefined;\n const status = field(error, 'statusCode');\n const http = typeof status === 'number' && Number.isInteger(status) && status >= 400 && status < 600;\n return http ? `${PROVIDER_FAILURE_DETAIL[kind]}, HTTP ${status}` : PROVIDER_FAILURE_DETAIL[kind];\n}\n\nfunction ruleRejectionDetail(error: object): string | undefined {\n if (!(error instanceof FactoryRuleRejectedError)) return undefined;\n return Object.hasOwn(RULE_REJECTION_DETAIL, error.code) ? RULE_REJECTION_DETAIL[error.code] : undefined;\n}\n\nfunction first<T>(chain: object[], pick: (error: object) => T | undefined): T | undefined {\n for (const error of chain) {\n const picked = pick(error);\n if (picked !== undefined) return picked;\n }\n return undefined;\n}\n\nfunction publicDetail(error: unknown): string | undefined {\n const chain = causeChain(error);\n const where = first(chain, candidate => namesOf(candidate).find(name => FACTORY_ERROR_NAMES.has(name)));\n const what =\n first(chain, providerDetail) ??\n first(chain, ruleRejectionDetail) ??\n first(chain, candidate => namesOf(candidate).find(name => BUILT_IN_ERROR_NAMES.has(name)));\n if (where && what) return `${where}: ${what}`;\n return where ?? what;\n}\n\n/**\n * Why a run failed, safe to show on a public pull request: the failure code's label,\n * plus a detail drawn from a fixed vocabulary when the error can be classified.\n * Error messages are never included; operators read those from the decision's stored error.\n */\nexport function publicFailureReason(code: FactoryDispatchFailureCode, error: unknown): string {\n const label = factoryDispatchFailureMetadata(code).label;\n const detail = publicDetail(error);\n return detail ? `${label} (${detail})` : label;\n}\n"],"mappings":";;;AAOA,SAAgB,QAAQ,OAAyB;CAC/C,OAAO,SAAS,OAAO,UAAU,YAAY,WAAW,QAAQ,MAAM,QAAQ,KAAA;AAChF;AAEA,SAAgB,oBAAoB,OAAyB;CAC3D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,IAAI,UAAU,SAAS,OAAO,MAAM,SAAS,YAAY,yBAAyB,KAAK,MAAM,IAAI,GAAG,OAAO;CAC3G,OAAO,gBAAgB,SAAS,kBAAkB;AACpD;AAKA,MAAM,0BAAmF;CACvF,MAAM;CACN,OAAO;CACP,cAAc;CACd,kBAAkB;CAClB,gBAAgB;CAChB,uBAAuB;CACvB,SAAS;CACT,aA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OAAO,WAAW,YAAY,OAAO,UAAU,MAAM,KAAK,UAAU,OAAO,SAAS,MACnF,GAAG,wBAAwB,MAAM,SAAS,WAAW,wBAAwB;AAC7F;AAEA,SAAS,oBAAoB,OAAmC;CAC9D,IAAI,EAAE,iBAAiB,2BAA2B,OAAO,KAAA;CACzD,OAAO,OAAO,OAAO,uBAAuB,MAAM,IAAI,IAAI,sBAAsB,MAAM,QAAQ,KAAA;AAChG;AAEA,SAAS,MAAS,OAAiB,MAAuD;CACxF,KAAK,MAAM,SAAS,OAAO;EACzB,MAAM,SAAS,KAAK,KAAK;EACzB,IAAI,WAAW,KAAA,GAAW,OAAO;CACnC;AAEF;AAEA,SAAS,aAAa,OAAoC;CACxD,MAAM,QAAQ,WAAW,KAAK;CAC9B,MAAM,QAAQ,MAAM,QAAO,cAAa,QAAQ,SAAS,CAAC,CAAC,MAAK,SAAQ,oBAAoB,IAAI,IAAI,CAAC,CAAC;CACtG,MAAM,OACJ,MAAM,OAAO,cAAc,KAC3B,MAAM,OAAO,mBAAmB,KAChC,MAAM,QAAO,cAAa,QAAQ,SAAS,CAAC,CAAC,MAAK,SAAQ,qBAAqB,IAAI,IAAI,CAAC,CAAC;CAC3F,IAAI,SAAS,MAAM,OAAO,GAAG,MAAM,IAAI;CACvC,OAAO,SAAS;AAClB;;;;;;AAOA,SAAgB,oBAAoB,MAAkC,OAAwB;CAC5F,MAAM,QAAQ,+BAA+B,IAAI,CAAC,CAAC;CACnD,MAAM,SAAS,aAAa,KAAK;CACjC,OAAO,SAAS,GAAG,MAAM,IAAI,OAAO,KAAK;AAC3C"}
|
|
@@ -39,6 +39,19 @@ export interface FactoryTransitionRequest {
|
|
|
39
39
|
eventRoute?: {
|
|
40
40
|
routeId: string;
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* The move answers an outside author's pull request event. The move stands — a rule or a
|
|
44
|
+
* provider's default decided it — but any run the destination phase queues is compute and code
|
|
45
|
+
* execution on that author's say-so: it must wait for a person, however the phase starts.
|
|
46
|
+
*/
|
|
47
|
+
untrustedPullRequestEvent?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Internal: intake filing moves a fresh card from the board's first phase to the phase its
|
|
50
|
+
* route names. Like `eventRoute` the target is admin-authored, so the first phase's next
|
|
51
|
+
* phases don't restrict it — but only while the card still sits in that first phase; every
|
|
52
|
+
* other check (phase, card shape, consent) still applies.
|
|
53
|
+
*/
|
|
54
|
+
routeFiling?: boolean;
|
|
42
55
|
/**
|
|
43
56
|
* Internal, with `eventRoute` only: the installed board the route moves the card to, at `stage`.
|
|
44
57
|
* `board` stays the card's current board. The target board's next phases don't restrict the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition-service.d.ts","sourceRoot":"","sources":["../../src/rules/transition-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,oBAAoB,CAAC;AAIxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC7G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAGxE,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEpF,OAAO,KAAK,EAEV,gBAAgB,EAEhB,sBAAsB,EAEtB,gBAAgB,EAEhB,uBAAuB,EAExB,MAAM,YAAY,CAAC;AAiBpB,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,gBAAgB,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,CAAC,EAAE,sB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EAAE,MAAM,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,IAAI,CAAC;KACZ,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC5B;AA0BD,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,CAWpG;AAiBD,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,CAEpF;AAyFD,qBAAa,wBAAwB;;IAanC,YAAY,OAAO,EAAE,+BAA+B,EAYnD;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,UAAU,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4BpF;CA0dF"}
|
|
@@ -261,7 +261,8 @@ var FactoryTransitionService = class {
|
|
|
261
261
|
})
|
|
262
262
|
}, request.stage);
|
|
263
263
|
if (cardShapeRejection) return this.#commitRejection(request, transitionId, "invalid_transition", cardShapeRejection);
|
|
264
|
-
|
|
264
|
+
const filesPastEdges = request.routeFiling === true && fromStage === fromBoard.initialPhase;
|
|
265
|
+
if (!Object.prototype.hasOwnProperty.call(board.phases, request.stage) || !request.eventRoute && !filesPastEdges && !board.allowsTransition(fromStage, request.stage)) {
|
|
265
266
|
if (board !== fromBoard) return this.#commitRejection(request, transitionId, "invalid_transition", `The ${board.name} board has no phase ${request.stage}.`);
|
|
266
267
|
const nextStages = [...new Set((board.transitions[fromStage] ?? []).map((transition) => transition.to))];
|
|
267
268
|
const nextStagesReason = nextStages.length > 0 ? `Next stages declared from ${fromStage}: ${nextStages.join(", ")}.` : `No next stage is declared from ${fromStage}.`;
|
|
@@ -339,6 +340,9 @@ var FactoryTransitionService = class {
|
|
|
339
340
|
assertFactoryDecisionTarget(decision, boards, board.id);
|
|
340
341
|
return !(startsRun(decision) && runAlreadyUnderway(request, decision));
|
|
341
342
|
});
|
|
343
|
+
if (request.untrustedPullRequestEvent) {
|
|
344
|
+
for (const decision of validated) if (decision.type === "invokeSkill" || decision.type === "sendMessage" && decision.prepareBinding === true) decision.untrustedPullRequestEvent = true;
|
|
345
|
+
}
|
|
342
346
|
if (humanMove) {
|
|
343
347
|
const message = stageTransitionMessage(fromStage, request.stage);
|
|
344
348
|
const skill = validated.find((decision) => decision.type === "invokeSkill");
|