@mastra/factory 0.28.0-alpha.3 → 0.28.0-alpha.5
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 +110 -56
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +7 -1
- package/dist/auth.js.map +1 -1
- package/dist/boards/board-events.d.ts +1 -1
- package/dist/boards/board-events.d.ts.map +1 -1
- package/dist/boards/card-facts.d.ts +3 -1
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +26 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/default-board.d.ts +2 -2
- package/dist/boards/default-board.js +2 -2
- package/dist/boards/default-board.js.map +1 -1
- package/dist/boards/define-board.d.ts +1 -1
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/intake-routing.d.ts +3 -5
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +3 -4
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/project-boards.d.ts +18 -1
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +40 -3
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/semantics.d.ts +4 -4
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +8 -10
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/work-migrations.d.ts +24 -1
- package/dist/boards/work-migrations.d.ts.map +1 -1
- package/dist/boards/work-migrations.js +97 -2
- package/dist/boards/work-migrations.js.map +1 -1
- package/dist/boards/work-routes.d.ts +6 -1
- package/dist/boards/work-routes.d.ts.map +1 -1
- package/dist/boards/work-routes.js +20 -6
- package/dist/boards/work-routes.js.map +1 -1
- package/dist/factory.d.ts +23 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +62 -59
- package/dist/factory.js.map +1 -1
- package/dist/feed-events.d.ts +3 -2
- package/dist/feed-events.d.ts.map +1 -1
- package/dist/feed-events.js +3 -2
- package/dist/feed-events.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +3 -5
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +0 -6
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +23 -70
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +1 -3
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +4 -9
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/agent-tools.js +5 -5
- package/dist/integrations/incidentio/agent-tools.js.map +1 -1
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.js.map +1 -1
- package/dist/integrations/incidentio/routes.d.ts +2 -2
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +10 -13
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +1 -3
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +1 -3
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/binding-scope.d.ts +5 -6
- package/dist/integrations/jira/binding-scope.d.ts.map +1 -1
- package/dist/integrations/jira/binding-scope.js +9 -11
- package/dist/integrations/jira/binding-scope.js.map +1 -1
- package/dist/integrations/jira/default-rules.d.ts.map +1 -1
- package/dist/integrations/jira/default-rules.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +3 -5
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +1 -3
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +1 -3
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +11 -14
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +1 -3
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +1 -3
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/session-tools.d.ts +5 -0
- package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
- package/dist/integrations/platform/connect/session-tools.js +5 -0
- package/dist/integrations/platform/connect/session-tools.js.map +1 -1
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +3 -5
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/integrations/slack/run-error-card.js +1 -0
- package/dist/integrations/slack/run-error-card.js.map +1 -1
- package/dist/provider-display-name.d.ts.map +1 -1
- package/dist/provider-display-name.js +1 -0
- package/dist/provider-display-name.js.map +1 -1
- package/dist/routes/automation-runs.d.ts +1 -1
- package/dist/routes/automation-runs.js.map +1 -1
- package/dist/routes/config.d.ts +7 -1
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +105 -22
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +3 -10
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +11 -9
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +6 -1
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +0 -23
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +13 -310
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts +19 -0
- package/dist/routes/mastra-gateway.d.ts.map +1 -0
- package/dist/routes/mastra-gateway.js +120 -0
- package/dist/routes/mastra-gateway.js.map +1 -0
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +1 -1
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +6 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +32 -2
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/route.d.ts +6 -0
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js.map +1 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +0 -2
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.d.ts.map +1 -1
- package/dist/routes/tenant-credentials.js +5 -1
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +0 -5
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +18 -22
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/rule-group.d.ts +1 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +13 -5
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/transition-service.d.ts +2 -3
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +0 -1
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +7 -11
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.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 +38 -5
- package/dist/run-error.js.map +1 -1
- package/dist/session/live-sessions.d.ts +11 -4
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +31 -10
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +0 -2
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +1 -8
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +39 -13
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +54 -60
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts +1 -4
- package/dist/session/work-item-state-processor.d.ts.map +1 -1
- package/dist/session/work-item-state-processor.js +5 -18
- package/dist/session/work-item-state-processor.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +30 -8
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +43 -25
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/comments/base.d.ts.map +1 -1
- package/dist/storage/domains/comments/base.js +2 -2
- package/dist/storage/domains/comments/base.js.map +1 -1
- package/dist/storage/domains/comments/routes.d.ts.map +1 -1
- package/dist/storage/domains/comments/routes.js +4 -2
- package/dist/storage/domains/comments/routes.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +5 -45
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +11 -89
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +17 -9
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +15 -7
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +13 -11
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +37 -33
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/board-version.d.ts +6 -2
- package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
- package/dist/storage/domains/work-items/board-version.js +20 -9
- package/dist/storage/domains/work-items/board-version.js.map +1 -1
- package/dist/work-items/providers/base.d.ts +4 -1
- package/dist/work-items/providers/base.d.ts.map +1 -1
- package/dist/work-items/providers/base.js +6 -1
- package/dist/work-items/providers/base.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +2 -1
- package/dist/work-items/providers/github.js.map +1 -1
- package/dist/work-items/providers/gitlab.d.ts.map +1 -1
- package/dist/work-items/providers/gitlab.js +2 -1
- package/dist/work-items/providers/gitlab.js.map +1 -1
- package/dist/work-items/providers/jira.d.ts.map +1 -1
- package/dist/work-items/providers/jira.js +3 -2
- package/dist/work-items/providers/jira.js.map +1 -1
- package/dist/work-items/providers/linear.d.ts.map +1 -1
- package/dist/work-items/providers/linear.js +3 -2
- package/dist/work-items/providers/linear.js.map +1 -1
- package/dist/work-items/providers/types.d.ts +6 -0
- package/dist/work-items/providers/types.d.ts.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +2 -2
- package/factory-skills/factory-build/SKILL.md +5 -5
- package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
- package/factory-skills/factory-gitlab-review/SKILL.md +5 -5
- package/factory-skills/factory-rereview/SKILL.md +69 -23
- package/factory-skills/factory-review/SKILL.md +69 -23
- package/factory-skills/factory-self-review/SKILL.md +5 -6
- package/factory-skills/factory-triage/SKILL.md +8 -20
- package/package.json +8 -8
package/dist/feed-events.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export interface FeedScope {
|
|
|
6
6
|
export declare function feedTopic(orgId: string, factoryProjectId: string): string;
|
|
7
7
|
/**
|
|
8
8
|
* One frame for the whole project: `workItemId` names the item whose comments
|
|
9
|
-
* moved, and its absence means
|
|
10
|
-
*
|
|
9
|
+
* moved, and its absence means something else on the board did — a card, a
|
|
10
|
+
* decision, a run, or the attention list. Never awaited — a slow or dead broker
|
|
11
|
+
* must not hold up the write it describes.
|
|
11
12
|
*/
|
|
12
13
|
export declare function touchFeed(pubsub: PubSub, scope: FeedScope, workItemId?: string): void;
|
|
13
14
|
//# sourceMappingURL=feed-events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feed-events.d.ts","sourceRoot":"","sources":["../src/feed-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED
|
|
1
|
+
{"version":3,"file":"feed-events.d.ts","sourceRoot":"","sources":["../src/feed-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAarF"}
|
package/dist/feed-events.js
CHANGED
|
@@ -4,8 +4,9 @@ function feedTopic(orgId, factoryProjectId) {
|
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* One frame for the whole project: `workItemId` names the item whose comments
|
|
7
|
-
* moved, and its absence means
|
|
8
|
-
*
|
|
7
|
+
* moved, and its absence means something else on the board did — a card, a
|
|
8
|
+
* decision, a run, or the attention list. Never awaited — a slow or dead broker
|
|
9
|
+
* must not hold up the write it describes.
|
|
9
10
|
*/
|
|
10
11
|
function touchFeed(pubsub, scope, workItemId) {
|
|
11
12
|
pubsub.publish(feedTopic(scope.orgId, scope.factoryProjectId), {
|
package/dist/feed-events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feed-events.js","names":[],"sources":["../src/feed-events.ts"],"sourcesContent":["import type { PubSub } from '@mastra/core/events';\n\nexport interface FeedScope {\n orgId: string;\n factoryProjectId: string;\n}\n\nexport function feedTopic(orgId: string, factoryProjectId: string): string {\n return `factory.feed.${orgId}.${factoryProjectId}`;\n}\n\n/**\n * One frame for the whole project: `workItemId` names the item whose comments\n * moved, and its absence means
|
|
1
|
+
{"version":3,"file":"feed-events.js","names":[],"sources":["../src/feed-events.ts"],"sourcesContent":["import type { PubSub } from '@mastra/core/events';\n\nexport interface FeedScope {\n orgId: string;\n factoryProjectId: string;\n}\n\nexport function feedTopic(orgId: string, factoryProjectId: string): string {\n return `factory.feed.${orgId}.${factoryProjectId}`;\n}\n\n/**\n * One frame for the whole project: `workItemId` names the item whose comments\n * moved, and its absence means something else on the board did — a card, a\n * decision, a run, or the attention list. Never awaited — a slow or dead broker\n * must not hold up the write it describes.\n */\nexport function touchFeed(pubsub: PubSub, scope: FeedScope, workItemId?: string): void {\n pubsub\n .publish(feedTopic(scope.orgId, scope.factoryProjectId), {\n type: 'factory.feed.touched',\n runId: workItemId ?? scope.factoryProjectId,\n data: workItemId ? { workItemId } : {},\n })\n .catch((error: unknown) => {\n console.warn('[Factory] Failed to publish a feed touch', {\n factoryProjectId: scope.factoryProjectId,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n}\n"],"mappings":";AAOA,SAAgB,UAAU,OAAe,kBAAkC;CACzE,OAAO,gBAAgB,MAAM,GAAG;AAClC;;;;;;;AAQA,SAAgB,UAAU,QAAgB,OAAkB,YAA2B;CACrF,OACG,QAAQ,UAAU,MAAM,OAAO,MAAM,gBAAgB,GAAG;EACvD,MAAM;EACN,OAAO,cAAc,MAAM;EAC3B,MAAM,aAAa,EAAE,WAAW,IAAI,CAAC;CACvC,CAAC,CAAC,CACD,OAAO,UAAmB;EACzB,QAAQ,KAAK,4CAA4C;GACvD,kBAAkB,MAAM;GACxB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D,CAAC;CACH,CAAC;AACL"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,4 +24,7 @@ export type { DecryptedFactorySecret, FactorySecretEncryption, FactorySecretEncr
|
|
|
24
24
|
export { createFactoryRouteAuth } from './auth.js';
|
|
25
25
|
export type { RouteAuth } from './routes/route.js';
|
|
26
26
|
export type { FactoryIntegration, IntegrationContext, IntegrationHooks, IntegrationTools, } from './integrations/base.js';
|
|
27
|
+
export type { ReviewedChangeRequest, PublishReviewedCommitCheckInput } from './session/source-control-tools.js';
|
|
28
|
+
export type { CommitCheck, CommitCheckStatus } from './capabilities/version-control.js';
|
|
29
|
+
export { platformConnectTools } from './integrations/platform/connect/session-tools.js';
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,cAAc,EACd,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAC7G,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,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"}
|
package/dist/index.js
CHANGED
|
@@ -13,4 +13,5 @@ import { primarySource } from "./storage/domains/work-items/work-item-schema.js"
|
|
|
13
13
|
import { createStateSigner } from "./state-signing.js";
|
|
14
14
|
import { createFactorySecretEncryption, createPlaintextFactorySecretEncryption } from "./secret-encryption.js";
|
|
15
15
|
import { createFactoryRouteAuth } from "./auth.js";
|
|
16
|
-
|
|
16
|
+
import { platformConnectTools } from "./integrations/platform/connect/session-tools.js";
|
|
17
|
+
export { BoardDefinitionError, BoardWriteError, ChannelIdentityStorage, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, FactoryProjectsStorage, LocalFactorySandbox, MastraFactory, WorkItemsStorage, createBoardRegistry, createFactoryRouteAuth, createFactorySecretEncryption, createPlaintextFactorySecretEncryption, createStateSigner, defaultBoards, defineBoard, platformConnectTools, primarySource, waitForPendingFilesystemCapture, workBoard };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/github/default-rules.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAKjH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CACvC,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAChG,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACrC,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,IAAI,CAAC,CACpF,CAAC;AAuFF,iBAAS,WAAW,CAAC,OAAO,EAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"default-rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/github/default-rules.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAA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mBAAmB,GAAG,gBAAgB,CAgBpF"}
|
|
@@ -101,10 +101,9 @@ function issueClosed(context) {
|
|
|
101
101
|
message: { text: `GitHub issue #${context.issue.number} was closed${context.issue.stateReason ? ` (${context.issue.stateReason})` : ""}; this ${closure.boardTitle} card was moved to ${target.title}.` }
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
function materializePullRequestIntake(context, { idempotencyKey, autoStartCandidate
|
|
104
|
+
function materializePullRequestIntake(context, { idempotencyKey, autoStartCandidate }) {
|
|
105
105
|
const { intake } = context;
|
|
106
106
|
if (!context.pullRequest || !intake) return;
|
|
107
|
-
const stage = review ? intake.pullRequestReview ?? intake.initialPhase : intake.initialPhase;
|
|
108
107
|
const home = context.pullRequestHome;
|
|
109
108
|
return {
|
|
110
109
|
type: "upsertLinkedWorkItem",
|
|
@@ -114,7 +113,7 @@ function materializePullRequestIntake(context, { idempotencyKey, autoStartCandid
|
|
|
114
113
|
sourceKey: githubSourceKey(context, "github-pr", context.pullRequest.number),
|
|
115
114
|
title: context.pullRequest.title,
|
|
116
115
|
url: context.pullRequest.url,
|
|
117
|
-
stage,
|
|
116
|
+
stage: intake.initialPhase,
|
|
118
117
|
...home ? home.reason === "closes" ? { closesIssue: { workItemId: home.workItemId } } : { attachTo: { workItemId: home.workItemId } } : {},
|
|
119
118
|
metadata: {
|
|
120
119
|
githubRepositoryId: context.repository.id,
|
|
@@ -275,8 +274,7 @@ function reReviewRequestedPullRequest(context) {
|
|
|
275
274
|
if (context.actor.type === "github" && context.actor.factoryAuthored) return;
|
|
276
275
|
if (!context.item) return materializePullRequestIntake(context, {
|
|
277
276
|
idempotencyKey: `${context.ingress.id}:pull-request-review-requested-intake`,
|
|
278
|
-
autoStartCandidate: true
|
|
279
|
-
review: true
|
|
277
|
+
autoStartCandidate: true
|
|
280
278
|
});
|
|
281
279
|
const stage = context.flow?.pullRequestReview;
|
|
282
280
|
if (!context.board || !stage) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-rules.js","names":[],"sources":["../../../src/integrations/github/default-rules.ts"],"sourcesContent":["import {\n isPullRequestCard,\n newestOpenPullRequestNumber,\n pullRequestSourceNumber,\n pullRequestSources,\n reviewedPullRequest,\n reviewsPullRequest,\n} from '../../boards/index.js';\nimport { hasRecordedVerdict } from '../../boards/semantics.js';\nimport { requestsChangesVerdict } from '../../review-verdict.js';\nimport {\n closedByRoutes,\n pullRequestMoveByRoutes,\n recordExplicitRuleOverrides,\n routedOnly,\n unreviewedPullRequestCard,\n} from '../../rules/event-rules.js';\nimport type { FactoryGithubEventName, FactoryGithubRuleContext, FactoryRuleHandler } from '../../rules/types.js';\nimport type { WorkItemSourceRow } from '../../storage/domains/work-items/work-item-schema.js';\nimport { isRepositoryPullRequest } from './pull-request-source.js';\nimport { isFactoryApproveVerdict } from './stale-reviews.js';\n\nexport type GithubRuleOverrides = Partial<\n Record<FactoryGithubEventName, FactoryRuleHandler<FactoryGithubRuleContext> | null | undefined>\n>;\nexport type GithubEventRules = Readonly<\n Record<FactoryGithubEventName, FactoryRuleHandler<FactoryGithubRuleContext> | null>\n>;\n\nfunction trustedGithubActor(context: Pick<FactoryGithubRuleContext, 'actor'>): boolean {\n return context.actor.type === 'github' && context.actor.trusted;\n}\n\nfunction githubActorLogin(context: Pick<FactoryGithubRuleContext, 'actor'>): string | undefined {\n return context.actor.type === 'github' ? context.actor.login : undefined;\n}\n\n/**\n * The card whose session authored the pull request, as opposed to the PR's own card, on a board\n * that reviews pull requests.\n */\nfunction authoringCard(context: FactoryGithubRuleContext): boolean {\n return (\n context.flow?.pullRequestReview !== undefined && context.item !== undefined && !isPullRequestCard(context.item)\n );\n}\n\n/** Whether the card sits in `selfReview` with an approve verdict on the head its pull request opened with. */\nfunction selfReviewApprovedHead(context: FactoryGithubRuleContext, selfReview: string): boolean {\n const { item, pullRequest } = context;\n const metadata = item?.metadata;\n const approvedHead = metadata?.selfReviewedHeadSha;\n return (\n item?.stages.length === 1 &&\n item.stages[0] === selfReview &&\n metadata?.selfReviewVerdict === 'approve' &&\n typeof approvedHead === 'string' &&\n pullRequest?.headSha !== undefined &&\n approvedHead.toLowerCase() === pullRequest.headSha\n );\n}\n\n/** Whether the card sits in its board's pull request review phase, alone. */\nfunction inPullRequestReview(context: FactoryGithubRuleContext): boolean {\n const phase = context.flow?.pullRequestReview;\n return phase !== undefined && context.item?.stages.length === 1 && context.item.stages[0] === phase;\n}\n\n/** Whether the rule's card carries the event's pull request as one of its sources, attached to its issue. */\nfunction attachedPullRequest(context: FactoryGithubRuleContext): boolean {\n const { item, pullRequest } = context;\n if (!item || !pullRequest || isPullRequestCard(item)) return false;\n return pullRequestSources(item).some(source => isEventPullRequest(context, source));\n}\n\n/** Whether a source row is the event's pull request: the same number in the same repository. */\nfunction isEventPullRequest(context: FactoryGithubRuleContext, source: WorkItemSourceRow): boolean {\n return (\n context.pullRequest !== undefined &&\n isRepositoryPullRequest(source, context.repository.id, context.repository.fullName, context.pullRequest.number)\n );\n}\n\n/** Whether the card's PR review covers the event's pull request: its own, or the attached one it reviews. */\nfunction reviewsThisPullRequest(context: FactoryGithubRuleContext): boolean {\n if (!context.item || !context.pullRequest || !reviewsPullRequest(context)) return false;\n if (isPullRequestCard(context.item)) return true;\n const reviewed = reviewedPullRequest(context.item);\n return reviewed !== undefined && isEventPullRequest(context, reviewed);\n}\n\nfunction createdAfterFactory(createdAt: string | undefined, factoryCreatedAt: string): boolean {\n if (!createdAt) return false;\n const sourceCreatedAt = Date.parse(createdAt);\n const projectCreatedAt = Date.parse(factoryCreatedAt);\n return Number.isFinite(sourceCreatedAt) && Number.isFinite(projectCreatedAt) && sourceCreatedAt > projectCreatedAt;\n}\n\n/**\n * Issue and pull request numbers repeat across repositories, so new cards are\n * keyed by repository. A card this repository already owns keeps its key —\n * including canonical `github-issue:N` / `github-pr:N` keys from before\n * scoping — but only when it is the same kind of source: pull request intake\n * runs with the authoring issue as `context.item`.\n */\nfunction githubSourceKey(\n context: FactoryGithubRuleContext,\n source: 'github-issue' | 'github-pr',\n itemNumber: number,\n): string {\n if (context.item?.source === source && context.item.sourceKey) return context.item.sourceKey;\n return `github:${context.repository.id}:${source === 'github-issue' ? 'issue' : 'pull-request'}:${itemNumber}`;\n}\n\nfunction issueOpened(context: FactoryGithubRuleContext) {\n if (!context.issue || !context.intake) return;\n // Everything arrives on the routed board's initial phase (the project's default board when no\n // label route or binding selects another). Trust/timing stamps remain available to custom board\n // rules.\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:issue-intake`,\n board: context.intake.board,\n source: 'github-issue',\n sourceKey: githubSourceKey(context, 'github-issue', context.issue.number),\n title: context.issue.title,\n url: context.issue.url,\n stage: context.intake.initialPhase,\n metadata: {\n githubRepositoryId: context.repository.id,\n githubIssueNumber: context.issue.number,\n ...(context.issue.createdAt ? { sourceCreatedAt: context.issue.createdAt } : {}),\n ...(context.issue.author || githubActorLogin(context)\n ? { author: context.issue.author ?? githubActorLogin(context) }\n : {}),\n state: context.issue.state ?? 'open',\n authorTrusted: trustedGithubActor(context),\n autoStartCandidate:\n trustedGithubActor(context) && createdAfterFactory(context.issue.createdAt, context.factory.createdAt),\n assignees: context.issue.assignees ?? [],\n labels: context.issue.labels ?? [],\n },\n } as const;\n}\n\nfunction issueClosed(context: FactoryGithubRuleContext) {\n if (!context.item || context.item.source !== 'github-issue' || !context.issue) return;\n // The project's intake routes decide where a closed source sends the card. The board's\n // `sourceClosed` mapping applies only when no route on the board handles closes; without\n // one the close goes to the routes alone (see `routeEventDecision`).\n const closure = context.boardClosure;\n if (!context.board || !closure || closure.itemTerminal) return;\n // Issue closure is a repository fact, not third-party input — no actor trust\n // gate. `not_planned` (and `duplicate`) means abandoned, everything else is\n // completed work.\n const canceled = context.issue.stateReason === 'not_planned' || context.issue.stateReason === 'duplicate';\n const target = canceled ? closure.canceled : closure.completed;\n return closedByRoutes(canceled, {\n idempotencyKey: `${context.ingress.id}:issue-closed`,\n board: context.board,\n stage: target.phase,\n message: {\n text:\n `GitHub issue #${context.issue.number} was closed` +\n `${context.issue.stateReason ? ` (${context.issue.stateReason})` : ''}; ` +\n `this ${closure.boardTitle} card was moved to ${target.title}.`,\n },\n });\n}\n\nfunction materializePullRequestIntake(\n context: FactoryGithubRuleContext,\n {\n idempotencyKey,\n autoStartCandidate,\n review = false,\n }: { idempotencyKey: string; autoStartCandidate: boolean; review?: boolean },\n) {\n const { intake } = context;\n if (!context.pullRequest || !intake) return;\n // A requested review lands straight in the board's pull request review phase; a board without\n // one files the pull request where everything else arrives.\n const stage = review ? (intake.pullRequestReview ?? intake.initialPhase) : intake.initialPhase;\n const home = context.pullRequestHome;\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey,\n board: intake.board,\n source: 'github-pr',\n sourceKey: githubSourceKey(context, 'github-pr', context.pullRequest.number),\n title: context.pullRequest.title,\n url: context.pullRequest.url,\n stage,\n // A pull request for a card already on the board is filed on that card; the authoring card's\n // own evaluation moves it. For one that closes an issue on the board, the project's intake\n // routes decide whether it joins that card.\n ...(home\n ? home.reason === 'closes'\n ? { closesIssue: { workItemId: home.workItemId } }\n : { attachTo: { workItemId: home.workItemId } }\n : {}),\n metadata: {\n githubRepositoryId: context.repository.id,\n githubPullRequestNumber: context.pullRequest.number,\n ...(context.pullRequest.createdAt ? { sourceCreatedAt: context.pullRequest.createdAt } : {}),\n factoryAuthored: context.pullRequest.factoryAuthored,\n authorTrusted: trustedGithubActor(context),\n autoStartCandidate,\n state: context.pullRequest.state,\n draft: context.pullRequest.draft,\n merged: context.pullRequest.merged,\n assignees: context.pullRequest.assignees ?? [],\n requestedReviewers: context.pullRequest.requestedReviewers ?? [],\n labels: context.pullRequest.labels ?? [],\n headBranch: context.pullRequest.headBranch,\n baseBranch: context.pullRequest.baseBranch,\n ...(context.pullRequest.author ? { author: context.pullRequest.author } : {}),\n },\n } as const;\n}\n\nfunction pullRequestOpened(context: FactoryGithubRuleContext) {\n if (!context.pullRequest) return;\n // Opening a pull request is evaluated once per card it concerns. This rule\n // files the pull request's own card, which is the arrival — the\n // evaluation carrying `pullRequestIntake` — so the authoring card's own\n // evaluation only moves it out for review: from its build phase (a board\n // without self-review, or a pull request opened before self-review ran), or\n // from self-review once it approved the very head the pull request opens\n // with. Opening the pull request writes it onto the card, so the agent's own\n // move at its pre-PR revision always loses that race; the event moves the\n // card instead. It rests in the board's pull request review phase through\n // every round of feedback — the builder is woken in place — until the merge\n // closes it.\n if (context.item && context.pullRequestIntake !== true) {\n if (!authoringCard(context) || context.pullRequest.state !== 'open') return;\n const { build, selfReview, pullRequestReview } = context.flow ?? {};\n if (!context.board || !build || !pullRequestReview) return;\n if (!context.item.stages.includes(build) && !(selfReview && selfReviewApprovedHead(context, selfReview))) return;\n // Someone else's pull request attached to the issue does not mean this card's build is out.\n if (attachedPullRequest(context) && !context.pullRequest.factoryAuthored) return;\n // Resolution can match a card by branch alone, so a fork's pull\n // request must not be able to move it: same bar as auto-starting a review.\n if (!trustedGithubActor(context) && !context.pullRequest.factoryAuthored) return;\n return pullRequestMoveByRoutes('pull_request.opened', {\n idempotencyKey: `${context.ingress.id}:out-for-review`,\n board: context.board,\n stage: pullRequestReview,\n });\n }\n // A GitHub App bot is never a collaborator, so Factory's own PRs score\n // untrusted; their authorship is the trust signal.\n const autoStartCandidate =\n (trustedGithubActor(context) || context.pullRequest.factoryAuthored) &&\n createdAfterFactory(context.pullRequest.createdAt, context.factory.createdAt);\n return materializePullRequestIntake(context, {\n idempotencyKey: `${context.ingress.id}:pull-request-intake`,\n autoStartCandidate,\n });\n}\n\nfunction pullRequestMerged(context: FactoryGithubRuleContext) {\n if (!context.item || !context.board || !context.pullRequest?.merged) return;\n if (unreviewedPullRequestCard(context)) return routedOnly(context, 'pull_request.merged');\n const done = context.boardClosure?.completed ?? context.flow?.completed;\n if (!done) return;\n if (isPullRequestCard(context.item) && reviewsPullRequest(context)) {\n // The event is bound to the PR's own card: a merged PR is finished\n // review work, so always move the card to its board's completed phase. The\n // message only reaches an active session (if any) — cards without one just\n // move, instead of failing retries against a binding that never existed.\n return pullRequestMoveByRoutes('pull_request.merged', {\n idempotencyKey: `${context.ingress.id}:pull-request-merged`,\n board: context.board,\n stage: done.phase,\n message: {\n text:\n `Pull request #${context.pullRequest.number} merged; this pull request card was moved to ${done.title}. ` +\n 'No further review is needed unless follow-up work was requested.',\n },\n });\n }\n if (!authoringCard(context)) return;\n // Provenance bound the event to the card that authored the pull request instead: the merge\n // is what finishes the work, so it closes that card alongside the PR's own card —\n // unless the card has since opened another pull request, which is still out.\n // A card carrying several pull requests waits for the one it has out, else for any still open.\n const recorded = context.item.metadata?.openPullRequestNumber;\n const openPullRequestNumber =\n typeof recorded === 'number'\n ? recorded\n : newestOpenPullRequestNumber(context.item, context.pullRequest.number);\n if (typeof openPullRequestNumber === 'number' && openPullRequestNumber !== context.pullRequest.number) {\n const role = context.flow?.buildRole;\n if (!role) return;\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:work-merged`,\n role,\n message:\n `Pull request #${context.pullRequest.number} merged. Pull request #${openPullRequestNumber} is still open, ` +\n 'so this card stays where it is until it merges.',\n } as const;\n }\n return pullRequestMoveByRoutes('pull_request.merged', {\n idempotencyKey: `${context.ingress.id}:work-merged`,\n board: context.board,\n stage: done.phase,\n message: { text: `Pull request #${context.pullRequest.number} merged; this card was moved to ${done.title}.` },\n });\n}\n\nfunction addressReviewFeedback(context: FactoryGithubRuleContext) {\n if (!context.item || !context.pullRequest || !context.review) return;\n // Only the card that authored the PR can act on the feedback. Provenance\n // binds the event there; the PR's own card seeing its posted review must not\n // react to it (that would loop the reviewer against itself).\n const role = context.flow?.buildRole;\n if (!authoringCard(context) || !role) return;\n // Someone else's pull request attached to the issue is not the builder's to fix.\n if (attachedPullRequest(context) && !context.pullRequest.factoryAuthored) return;\n // A closed or merged pull request has no branch left to push fixes to.\n if (context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // `approved` needs no work, and `commented` is how a reviewer leaves notes\n // without blocking — only a verdict that asks for changes should pull the\n // author back in. GitHub will not let Factory's app request changes on a pull\n // request it authored, so there Factory's own `commented` review carries the\n // verdict on its first line instead; that one counts too.\n const state = context.review.state.toLowerCase();\n const factoryVerdict =\n state === 'commented' &&\n context.actor.type === 'github' &&\n context.actor.factoryAuthored &&\n context.pullRequest.factoryAuthored &&\n requestsChangesVerdict(context.review.body);\n if (state !== 'changes_requested' && !factoryVerdict) return;\n // The authoring thread is already subscribed to this PR (`gh pr create`\n // subscribes automatically), so it can read the individual line comments\n // from its own notification inbox — the message only has to wake it and\n // point at the review.\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:address-review-feedback`,\n role,\n priority: 'high',\n message:\n `Changes were requested on pull request #${context.pullRequest.number} (${context.review.url}). ` +\n 'Read the review comments on this PR, address the ones you agree with, and push the fixes to the PR branch. ' +\n 'Reply on GitHub to anything you are deliberately not changing, explaining why.',\n } as const;\n}\n\n/**\n * A Factory approval does not clear a change request left by a different\n * Factory identity (an earlier reviewer token, say), so GitHub would keep the\n * pull request blocked. Ask the dispatcher to dismiss those superseded reviews.\n */\nfunction dismissStaleFactoryReviews(context: FactoryGithubRuleContext) {\n const { pullRequest, review, repository } = context;\n if (!pullRequest || !review || !review.author || !repository.installationId) return;\n if (review.state.toLowerCase() !== 'approved' || !isFactoryApproveVerdict(review.body)) return;\n if (!pullRequest.factoryAuthored || pullRequest.state !== 'open' || pullRequest.merged) return;\n return {\n type: 'dismissStaleReviews',\n idempotencyKey: `${context.ingress.id}:dismiss-stale-reviews`,\n installationId: repository.installationId,\n repository: repository.fullName,\n pullRequestNumber: pullRequest.number,\n approvingReviewId: String(review.id),\n approvingAuthor: review.author,\n } as const;\n}\n\nfunction pullRequestReviewSubmitted(context: FactoryGithubRuleContext) {\n return addressReviewFeedback(context) ?? dismissStaleFactoryReviews(context);\n}\n\nfunction addressPullRequestComment(context: FactoryGithubRuleContext) {\n // A validated Factory mention is a review-entry request, not feedback for the\n // authoring session. Invalid or unrecognized comments retain the normal\n // feedback route below.\n if (context.reviewCommand) return reReviewRequestedPullRequest(context);\n if (!context.item || !context.pullRequest || !context.issueComment) return;\n // Provenance binds the comment to the card that authored the PR — the\n // only session that can act on it. The PR's own card must not react to\n // comments on the PR it is reviewing.\n const role = context.flow?.buildRole;\n if (!authoringCard(context) || !role) return;\n if (attachedPullRequest(context) && !context.pullRequest.factoryAuthored) return;\n if (context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // `factoryAuthored` is one bit for the whole Factory, so Factory's own\n // comments are indistinguishable between roles — waking on all of them would\n // let the builder's own progress comments wake itself in a loop. The one\n // exception is the review verdict the Review run had to post as a comment\n // because GitHub refused a self-review: that is the handoff, and it only ever\n // asks for changes once per review, so it cannot sustain a loop.\n if (\n context.actor.type === 'github' &&\n context.actor.factoryAuthored &&\n !requestsChangesVerdict(context.issueComment.body)\n ) {\n return;\n }\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:address-pull-request-comment`,\n role,\n priority: 'high',\n message:\n `${context.issueComment.author ?? 'Someone'} commented on pull request #${context.pullRequest.number} ` +\n `(${context.issueComment.url ?? context.pullRequest.url}). Read the comment, address it if you agree, and push ` +\n 'the fixes to the PR branch. Reply on GitHub to anything you are deliberately not changing, explaining why.',\n } as const;\n}\n\nfunction pullRequestClosed(context: FactoryGithubRuleContext) {\n if (!context.item || !context.board || !context.pullRequest || context.pullRequest.merged) return;\n if (unreviewedPullRequestCard(context)) return routedOnly(context, 'pull_request.closed');\n if (!reviewsPullRequest(context)) return;\n if (!isPullRequestCard(context.item)) {\n // An issue card waiting in pull request review on its last open pull request goes back to\n // where its board's cards rest; the issue is still open, and another pull request keeps the\n // review going.\n const initialPhase = context.flow?.initialPhase;\n if (!initialPhase || !attachedPullRequest(context) || !inPullRequestReview(context)) return;\n if (newestOpenPullRequestNumber(context.item, context.pullRequest.number) !== null) return;\n return pullRequestMoveByRoutes('pull_request.closed', {\n idempotencyKey: `${context.ingress.id}:pull-request-closed`,\n board: context.board,\n stage: initialPhase,\n message: {\n text: `Pull request #${context.pullRequest.number} was closed without merging; this card was moved back to ${initialPhase}.`,\n },\n });\n }\n // A PR closed without merging is abandoned review work: clear the card off\n // the board instead of leaving it in review forever.\n const canceled = context.boardClosure?.canceled ?? context.flow?.canceled;\n if (!canceled) return;\n return pullRequestMoveByRoutes('pull_request.closed', {\n idempotencyKey: `${context.ingress.id}:pull-request-closed`,\n board: context.board,\n stage: canceled.phase,\n message: {\n text:\n `Pull request #${context.pullRequest.number} was closed without merging; ` +\n `this pull request card was moved to ${canceled.title}.`,\n },\n });\n}\n\nfunction reReviewRequestedPullRequest(context: FactoryGithubRuleContext) {\n // GitHub reviewer requests and Factory's exact mention command are both\n // explicit requests to enter the same Review lifecycle.\n const factoryReviewEntry = context.reviewRequest?.factoryReviewer || context.reviewCommand !== undefined;\n if ((context.item && !reviewsPullRequest(context)) || !factoryReviewEntry) return;\n if (!context.pullRequest || context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // Trusted (write/admin) requesters only: creating or re-entering review checks\n // out and executes PR code, the same bar pullRequestOpened applies to auto-review.\n if (!trustedGithubActor(context)) return;\n if (context.actor.type === 'github' && context.actor.factoryAuthored) return;\n if (!context.item) {\n // On this path the actor is the *requester*, so the materialized\n // `authorTrusted` stamp records their trust (always true past the gate\n // above), not the PR author's: a trusted maintainer requesting a Factory\n // review vouches for the PR.\n return materializePullRequestIntake(context, {\n idempotencyKey: `${context.ingress.id}:pull-request-review-requested-intake`,\n autoStartCandidate: true,\n review: true,\n });\n }\n // Already in review with no verdict yet: a pass is pending or running.\n // Once a verdict is recorded the card rests in review, so a fresh request\n // re-enters the phase to start another pass.\n const stage = context.flow?.pullRequestReview;\n if (!context.board || !stage) return;\n const reviewing = inPullRequestReview(context);\n // On an issue card the pass reviews one pull request at a time; a request for another\n // waits until that one is reviewed or settled.\n if (reviewing && !reviewsThisPullRequest(context)) return;\n if (reviewing && !hasRecordedVerdict(context.item)) return;\n return pullRequestMoveByRoutes('pull_request.review_requested', {\n idempotencyKey: `${context.ingress.id}:re-review-requested`,\n board: context.board,\n stage,\n ...(reviewing ? { reenter: true } : {}),\n });\n}\n\nfunction reReviewUpdatedPullRequest(context: FactoryGithubRuleContext) {\n if (!context.item || !context.board || !reviewsPullRequest(context)) return;\n if (!context.pullRequest || context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n const stage = context.flow?.pullRequestReview;\n if (!stage) return;\n const reviewing = inPullRequestReview(context);\n // An issue card re-reviews only while its PR review covers this pull request: a push to the\n // builder's own pull request while it builds or self-reviews is the build, not a review cue.\n if (!isPullRequestCard(context.item) && !(reviewing && reviewsThisPullRequest(context))) return;\n // A resting card has not started a review pass yet, so a push there is just\n // more of the code the first pass will read. A push to a card sitting in\n // review is different: it invalidates whatever that pass is reading, so\n // re-enter the phase to supersede it. The phase runner cancels the stale run\n // and the review skill picks the right skill for the entry it sees.\n if (context.phase?.kind === 'resting') return;\n // A fork's author controls its head branch, so an untrusted push must not be\n // able to start review passes on demand; a maintainer can still request one.\n if (!trustedGithubActor(context) && !context.pullRequest.factoryAuthored) return;\n return pullRequestMoveByRoutes('pull_request.synchronized', {\n idempotencyKey: `${context.ingress.id}:re-review-updated`,\n board: context.board,\n stage,\n // Re-entry is the point when the card is already in review: the phase's\n // entry rule is what cancels the superseded pass and starts one on the code\n // that just landed.\n ...(reviewing ? { reenter: true } : {}),\n });\n}\n\nexport const defaultGithubRules = Object.freeze({\n issueOpened: issueOpened,\n // Triage runs once, when a person moves the card into Triage or starts the run; later edits and\n // comments on the issue don't run it again.\n issueEdited: null,\n issueClosed: issueClosed,\n issueReopened: null,\n issueCommentCreated: null,\n issueCommentEdited: null,\n issueCommentDeleted: null,\n pullRequestOpened: pullRequestOpened,\n pullRequestUpdated: reReviewUpdatedPullRequest,\n pullRequestCommentCreated: addressPullRequestComment,\n pullRequestReviewRequested: reReviewRequestedPullRequest,\n pullRequestReviewSubmitted: pullRequestReviewSubmitted,\n pullRequestMerged: pullRequestMerged,\n pullRequestClosed: pullRequestClosed,\n} satisfies GithubEventRules);\n\nexport function resolveGithubRules(overrides?: GithubRuleOverrides): GithubEventRules {\n if (overrides !== undefined && (overrides === null || typeof overrides !== 'object' || Array.isArray(overrides))) {\n throw new Error('GitHub rules must be an object.');\n }\n const rules: Record<string, FactoryRuleHandler<FactoryGithubRuleContext> | null> = { ...defaultGithubRules };\n for (const key of Reflect.ownKeys(overrides ?? {})) {\n if (typeof key !== 'string' || !Object.hasOwn(defaultGithubRules, key)) {\n throw new Error(`Unknown GitHub rule event: ${String(key)}.`);\n }\n const handler = overrides?.[key as FactoryGithubEventName];\n if (handler !== undefined && handler !== null && typeof handler !== 'function') {\n throw new Error(`GitHub rule ${key} must be a function, null, or undefined.`);\n }\n if (handler !== undefined) rules[key] = handler;\n }\n return recordExplicitRuleOverrides(Object.freeze(rules) as GithubEventRules, overrides);\n}\n"],"mappings":";;;;;;;AA6BA,SAAS,mBAAmB,SAA2D;CACrF,OAAO,QAAQ,MAAM,SAAS,YAAY,QAAQ,MAAM;AAC1D;AAEA,SAAS,iBAAiB,SAAsE;CAC9F,OAAO,QAAQ,MAAM,SAAS,WAAW,QAAQ,MAAM,QAAQ,KAAA;AACjE;;;;;AAMA,SAAS,cAAc,SAA4C;CACjE,OACE,QAAQ,MAAM,sBAAsB,KAAA,KAAa,QAAQ,SAAS,KAAA,KAAa,CAAC,kBAAkB,QAAQ,IAAI;AAElH;;AAGA,SAAS,uBAAuB,SAAmC,YAA6B;CAC9F,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,WAAW,MAAM;CACvB,MAAM,eAAe,UAAU;CAC/B,OACE,MAAM,OAAO,WAAW,KACxB,KAAK,OAAO,OAAO,cACnB,UAAU,sBAAsB,aAChC,OAAO,iBAAiB,YACxB,aAAa,YAAY,KAAA,KACzB,aAAa,YAAY,MAAM,YAAY;AAE/C;;AAGA,SAAS,oBAAoB,SAA4C;CACvE,MAAM,QAAQ,QAAQ,MAAM;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AoB;CACpB,2BAA2B;CAC3B,4BAA4B;CACA;CACT;CACA;AACrB,CAA4B;AAE5B,SAAgB,mBAAmB,WAAmD;CACpF,IAAI,cAAc,KAAA,MAAc,cAAc,QAAQ,OAAO,cAAc,YAAY,MAAM,QAAQ,SAAS,IAC5G,MAAM,IAAI,MAAM,iCAAiC;CAEnD,MAAM,QAA6E,EAAE,GAAG,mBAAmB;CAC3G,KAAK,MAAM,OAAO,QAAQ,QAAQ,aAAa,CAAC,CAAC,GAAG;EAClD,IAAI,OAAO,QAAQ,YAAY,CAAC,OAAO,OAAO,oBAAoB,GAAG,GACnE,MAAM,IAAI,MAAM,8BAA8B,OAAO,GAAG,EAAE,EAAE;EAE9D,MAAM,UAAU,YAAY;EAC5B,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,OAAO,YAAY,YAClE,MAAM,IAAI,MAAM,eAAe,IAAI,yCAAyC;EAE9E,IAAI,YAAY,KAAA,GAAW,MAAM,OAAO;CAC1C;CACA,OAAO,4BAA4B,OAAO,OAAO,KAAK,GAAuB,SAAS;AACxF"}
|
|
1
|
+
{"version":3,"file":"default-rules.js","names":[],"sources":["../../../src/integrations/github/default-rules.ts"],"sourcesContent":["import {\n isPullRequestCard,\n newestOpenPullRequestNumber,\n pullRequestSourceNumber,\n pullRequestSources,\n reviewedPullRequest,\n reviewsPullRequest,\n} from '../../boards/index.js';\nimport { hasRecordedVerdict } from '../../boards/semantics.js';\nimport { requestsChangesVerdict } from '../../review-verdict.js';\nimport {\n closedByRoutes,\n pullRequestMoveByRoutes,\n recordExplicitRuleOverrides,\n routedOnly,\n unreviewedPullRequestCard,\n} from '../../rules/event-rules.js';\nimport type { FactoryGithubEventName, FactoryGithubRuleContext, FactoryRuleHandler } from '../../rules/types.js';\nimport type { WorkItemSourceRow } from '../../storage/domains/work-items/work-item-schema.js';\nimport { isRepositoryPullRequest } from './pull-request-source.js';\nimport { isFactoryApproveVerdict } from './stale-reviews.js';\n\nexport type GithubRuleOverrides = Partial<\n Record<FactoryGithubEventName, FactoryRuleHandler<FactoryGithubRuleContext> | null | undefined>\n>;\nexport type GithubEventRules = Readonly<\n Record<FactoryGithubEventName, FactoryRuleHandler<FactoryGithubRuleContext> | null>\n>;\n\nfunction trustedGithubActor(context: Pick<FactoryGithubRuleContext, 'actor'>): boolean {\n return context.actor.type === 'github' && context.actor.trusted;\n}\n\nfunction githubActorLogin(context: Pick<FactoryGithubRuleContext, 'actor'>): string | undefined {\n return context.actor.type === 'github' ? context.actor.login : undefined;\n}\n\n/**\n * The card whose session authored the pull request, as opposed to the PR's own card, on a board\n * that reviews pull requests.\n */\nfunction authoringCard(context: FactoryGithubRuleContext): boolean {\n return (\n context.flow?.pullRequestReview !== undefined && context.item !== undefined && !isPullRequestCard(context.item)\n );\n}\n\n/** Whether the card sits in `selfReview` with an approve verdict on the head its pull request opened with. */\nfunction selfReviewApprovedHead(context: FactoryGithubRuleContext, selfReview: string): boolean {\n const { item, pullRequest } = context;\n const metadata = item?.metadata;\n const approvedHead = metadata?.selfReviewedHeadSha;\n return (\n item?.stages.length === 1 &&\n item.stages[0] === selfReview &&\n metadata?.selfReviewVerdict === 'approve' &&\n typeof approvedHead === 'string' &&\n pullRequest?.headSha !== undefined &&\n approvedHead.toLowerCase() === pullRequest.headSha\n );\n}\n\n/** Whether the card sits in its board's pull request review phase, alone. */\nfunction inPullRequestReview(context: FactoryGithubRuleContext): boolean {\n const phase = context.flow?.pullRequestReview;\n return phase !== undefined && context.item?.stages.length === 1 && context.item.stages[0] === phase;\n}\n\n/** Whether the rule's card carries the event's pull request as one of its sources, attached to its issue. */\nfunction attachedPullRequest(context: FactoryGithubRuleContext): boolean {\n const { item, pullRequest } = context;\n if (!item || !pullRequest || isPullRequestCard(item)) return false;\n return pullRequestSources(item).some(source => isEventPullRequest(context, source));\n}\n\n/** Whether a source row is the event's pull request: the same number in the same repository. */\nfunction isEventPullRequest(context: FactoryGithubRuleContext, source: WorkItemSourceRow): boolean {\n return (\n context.pullRequest !== undefined &&\n isRepositoryPullRequest(source, context.repository.id, context.repository.fullName, context.pullRequest.number)\n );\n}\n\n/** Whether the card's PR review covers the event's pull request: its own, or the attached one it reviews. */\nfunction reviewsThisPullRequest(context: FactoryGithubRuleContext): boolean {\n if (!context.item || !context.pullRequest || !reviewsPullRequest(context)) return false;\n if (isPullRequestCard(context.item)) return true;\n const reviewed = reviewedPullRequest(context.item);\n return reviewed !== undefined && isEventPullRequest(context, reviewed);\n}\n\nfunction createdAfterFactory(createdAt: string | undefined, factoryCreatedAt: string): boolean {\n if (!createdAt) return false;\n const sourceCreatedAt = Date.parse(createdAt);\n const projectCreatedAt = Date.parse(factoryCreatedAt);\n return Number.isFinite(sourceCreatedAt) && Number.isFinite(projectCreatedAt) && sourceCreatedAt > projectCreatedAt;\n}\n\n/**\n * Issue and pull request numbers repeat across repositories, so new cards are\n * keyed by repository. A card this repository already owns keeps its key —\n * including canonical `github-issue:N` / `github-pr:N` keys from before\n * scoping — but only when it is the same kind of source: pull request intake\n * runs with the authoring issue as `context.item`.\n */\nfunction githubSourceKey(\n context: FactoryGithubRuleContext,\n source: 'github-issue' | 'github-pr',\n itemNumber: number,\n): string {\n if (context.item?.source === source && context.item.sourceKey) return context.item.sourceKey;\n return `github:${context.repository.id}:${source === 'github-issue' ? 'issue' : 'pull-request'}:${itemNumber}`;\n}\n\nfunction issueOpened(context: FactoryGithubRuleContext) {\n if (!context.issue || !context.intake) return;\n // Everything arrives on the default board's initial phase; the project's intake routes place\n // the card from there. Trust/timing stamps remain available to custom board rules.\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:issue-intake`,\n board: context.intake.board,\n source: 'github-issue',\n sourceKey: githubSourceKey(context, 'github-issue', context.issue.number),\n title: context.issue.title,\n url: context.issue.url,\n stage: context.intake.initialPhase,\n metadata: {\n githubRepositoryId: context.repository.id,\n githubIssueNumber: context.issue.number,\n ...(context.issue.createdAt ? { sourceCreatedAt: context.issue.createdAt } : {}),\n ...(context.issue.author || githubActorLogin(context)\n ? { author: context.issue.author ?? githubActorLogin(context) }\n : {}),\n state: context.issue.state ?? 'open',\n authorTrusted: trustedGithubActor(context),\n autoStartCandidate:\n trustedGithubActor(context) && createdAfterFactory(context.issue.createdAt, context.factory.createdAt),\n assignees: context.issue.assignees ?? [],\n labels: context.issue.labels ?? [],\n },\n } as const;\n}\n\nfunction issueClosed(context: FactoryGithubRuleContext) {\n if (!context.item || context.item.source !== 'github-issue' || !context.issue) return;\n // The project's intake routes decide where a closed source sends the card. The board's\n // `sourceClosed` mapping applies only when no route on the board handles closes; without\n // one the close goes to the routes alone (see `routeEventDecision`).\n const closure = context.boardClosure;\n if (!context.board || !closure || closure.itemTerminal) return;\n // Issue closure is a repository fact, not third-party input — no actor trust\n // gate. `not_planned` (and `duplicate`) means abandoned, everything else is\n // completed work.\n const canceled = context.issue.stateReason === 'not_planned' || context.issue.stateReason === 'duplicate';\n const target = canceled ? closure.canceled : closure.completed;\n return closedByRoutes(canceled, {\n idempotencyKey: `${context.ingress.id}:issue-closed`,\n board: context.board,\n stage: target.phase,\n message: {\n text:\n `GitHub issue #${context.issue.number} was closed` +\n `${context.issue.stateReason ? ` (${context.issue.stateReason})` : ''}; ` +\n `this ${closure.boardTitle} card was moved to ${target.title}.`,\n },\n });\n}\n\nfunction materializePullRequestIntake(\n context: FactoryGithubRuleContext,\n { idempotencyKey, autoStartCandidate }: { idempotencyKey: string; autoStartCandidate: boolean },\n) {\n const { intake } = context;\n if (!context.pullRequest || !intake) return;\n const home = context.pullRequestHome;\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey,\n board: intake.board,\n source: 'github-pr',\n sourceKey: githubSourceKey(context, 'github-pr', context.pullRequest.number),\n title: context.pullRequest.title,\n url: context.pullRequest.url,\n stage: intake.initialPhase,\n // A pull request for a card already on the board is filed on that card; the authoring card's\n // own evaluation moves it. For one that closes an issue on the board, the project's intake\n // routes decide whether it joins that card.\n ...(home\n ? home.reason === 'closes'\n ? { closesIssue: { workItemId: home.workItemId } }\n : { attachTo: { workItemId: home.workItemId } }\n : {}),\n metadata: {\n githubRepositoryId: context.repository.id,\n githubPullRequestNumber: context.pullRequest.number,\n ...(context.pullRequest.createdAt ? { sourceCreatedAt: context.pullRequest.createdAt } : {}),\n factoryAuthored: context.pullRequest.factoryAuthored,\n authorTrusted: trustedGithubActor(context),\n autoStartCandidate,\n state: context.pullRequest.state,\n draft: context.pullRequest.draft,\n merged: context.pullRequest.merged,\n assignees: context.pullRequest.assignees ?? [],\n requestedReviewers: context.pullRequest.requestedReviewers ?? [],\n labels: context.pullRequest.labels ?? [],\n headBranch: context.pullRequest.headBranch,\n baseBranch: context.pullRequest.baseBranch,\n ...(context.pullRequest.author ? { author: context.pullRequest.author } : {}),\n },\n } as const;\n}\n\nfunction pullRequestOpened(context: FactoryGithubRuleContext) {\n if (!context.pullRequest) return;\n // Opening a pull request is evaluated once per card it concerns. This rule\n // files the pull request's own card, which is the arrival — the\n // evaluation carrying `pullRequestIntake` — so the authoring card's own\n // evaluation only moves it out for review: from its build phase (a board\n // without self-review, or a pull request opened before self-review ran), or\n // from self-review once it approved the very head the pull request opens\n // with. Opening the pull request writes it onto the card, so the agent's own\n // move at its pre-PR revision always loses that race; the event moves the\n // card instead. It rests in the board's pull request review phase through\n // every round of feedback — the builder is woken in place — until the merge\n // closes it.\n if (context.item && context.pullRequestIntake !== true) {\n if (!authoringCard(context) || context.pullRequest.state !== 'open') return;\n const { build, selfReview, pullRequestReview } = context.flow ?? {};\n if (!context.board || !build || !pullRequestReview) return;\n if (!context.item.stages.includes(build) && !(selfReview && selfReviewApprovedHead(context, selfReview))) return;\n // Someone else's pull request attached to the issue does not mean this card's build is out.\n if (attachedPullRequest(context) && !context.pullRequest.factoryAuthored) return;\n // Resolution can match a card by branch alone, so a fork's pull\n // request must not be able to move it: same bar as auto-starting a review.\n if (!trustedGithubActor(context) && !context.pullRequest.factoryAuthored) return;\n return pullRequestMoveByRoutes('pull_request.opened', {\n idempotencyKey: `${context.ingress.id}:out-for-review`,\n board: context.board,\n stage: pullRequestReview,\n });\n }\n // A GitHub App bot is never a collaborator, so Factory's own PRs score\n // untrusted; their authorship is the trust signal.\n const autoStartCandidate =\n (trustedGithubActor(context) || context.pullRequest.factoryAuthored) &&\n createdAfterFactory(context.pullRequest.createdAt, context.factory.createdAt);\n return materializePullRequestIntake(context, {\n idempotencyKey: `${context.ingress.id}:pull-request-intake`,\n autoStartCandidate,\n });\n}\n\nfunction pullRequestMerged(context: FactoryGithubRuleContext) {\n if (!context.item || !context.board || !context.pullRequest?.merged) return;\n if (unreviewedPullRequestCard(context)) return routedOnly(context, 'pull_request.merged');\n const done = context.boardClosure?.completed ?? context.flow?.completed;\n if (!done) return;\n if (isPullRequestCard(context.item) && reviewsPullRequest(context)) {\n // The event is bound to the PR's own card: a merged PR is finished\n // review work, so always move the card to its board's completed phase. The\n // message only reaches an active session (if any) — cards without one just\n // move, instead of failing retries against a binding that never existed.\n return pullRequestMoveByRoutes('pull_request.merged', {\n idempotencyKey: `${context.ingress.id}:pull-request-merged`,\n board: context.board,\n stage: done.phase,\n message: {\n text:\n `Pull request #${context.pullRequest.number} merged; this pull request card was moved to ${done.title}. ` +\n 'No further review is needed unless follow-up work was requested.',\n },\n });\n }\n if (!authoringCard(context)) return;\n // Provenance bound the event to the card that authored the pull request instead: the merge\n // is what finishes the work, so it closes that card alongside the PR's own card —\n // unless the card has since opened another pull request, which is still out.\n // A card carrying several pull requests waits for the one it has out, else for any still open.\n const recorded = context.item.metadata?.openPullRequestNumber;\n const openPullRequestNumber =\n typeof recorded === 'number'\n ? recorded\n : newestOpenPullRequestNumber(context.item, context.pullRequest.number);\n if (typeof openPullRequestNumber === 'number' && openPullRequestNumber !== context.pullRequest.number) {\n const role = context.flow?.buildRole;\n if (!role) return;\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:work-merged`,\n role,\n message:\n `Pull request #${context.pullRequest.number} merged. Pull request #${openPullRequestNumber} is still open, ` +\n 'so this card stays where it is until it merges.',\n } as const;\n }\n return pullRequestMoveByRoutes('pull_request.merged', {\n idempotencyKey: `${context.ingress.id}:work-merged`,\n board: context.board,\n stage: done.phase,\n message: { text: `Pull request #${context.pullRequest.number} merged; this card was moved to ${done.title}.` },\n });\n}\n\nfunction addressReviewFeedback(context: FactoryGithubRuleContext) {\n if (!context.item || !context.pullRequest || !context.review) return;\n // Only the card that authored the PR can act on the feedback. Provenance\n // binds the event there; the PR's own card seeing its posted review must not\n // react to it (that would loop the reviewer against itself).\n const role = context.flow?.buildRole;\n if (!authoringCard(context) || !role) return;\n // Someone else's pull request attached to the issue is not the builder's to fix.\n if (attachedPullRequest(context) && !context.pullRequest.factoryAuthored) return;\n // A closed or merged pull request has no branch left to push fixes to.\n if (context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // `approved` needs no work, and `commented` is how a reviewer leaves notes\n // without blocking — only a verdict that asks for changes should pull the\n // author back in. GitHub will not let Factory's app request changes on a pull\n // request it authored, so there Factory's own `commented` review carries the\n // verdict on its first line instead; that one counts too.\n const state = context.review.state.toLowerCase();\n const factoryVerdict =\n state === 'commented' &&\n context.actor.type === 'github' &&\n context.actor.factoryAuthored &&\n context.pullRequest.factoryAuthored &&\n requestsChangesVerdict(context.review.body);\n if (state !== 'changes_requested' && !factoryVerdict) return;\n // The authoring thread is already subscribed to this PR (`gh pr create`\n // subscribes automatically), so it can read the individual line comments\n // from its own notification inbox — the message only has to wake it and\n // point at the review.\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:address-review-feedback`,\n role,\n priority: 'high',\n message:\n `Changes were requested on pull request #${context.pullRequest.number} (${context.review.url}). ` +\n 'Read the review comments on this PR, address the ones you agree with, and push the fixes to the PR branch. ' +\n 'Reply on GitHub to anything you are deliberately not changing, explaining why.',\n } as const;\n}\n\n/**\n * A Factory approval does not clear a change request left by a different\n * Factory identity (an earlier reviewer token, say), so GitHub would keep the\n * pull request blocked. Ask the dispatcher to dismiss those superseded reviews.\n */\nfunction dismissStaleFactoryReviews(context: FactoryGithubRuleContext) {\n const { pullRequest, review, repository } = context;\n if (!pullRequest || !review || !review.author || !repository.installationId) return;\n if (review.state.toLowerCase() !== 'approved' || !isFactoryApproveVerdict(review.body)) return;\n if (!pullRequest.factoryAuthored || pullRequest.state !== 'open' || pullRequest.merged) return;\n return {\n type: 'dismissStaleReviews',\n idempotencyKey: `${context.ingress.id}:dismiss-stale-reviews`,\n installationId: repository.installationId,\n repository: repository.fullName,\n pullRequestNumber: pullRequest.number,\n approvingReviewId: String(review.id),\n approvingAuthor: review.author,\n } as const;\n}\n\nfunction pullRequestReviewSubmitted(context: FactoryGithubRuleContext) {\n return addressReviewFeedback(context) ?? dismissStaleFactoryReviews(context);\n}\n\nfunction addressPullRequestComment(context: FactoryGithubRuleContext) {\n // A validated Factory mention is a review-entry request, not feedback for the\n // authoring session. Invalid or unrecognized comments retain the normal\n // feedback route below.\n if (context.reviewCommand) return reReviewRequestedPullRequest(context);\n if (!context.item || !context.pullRequest || !context.issueComment) return;\n // Provenance binds the comment to the card that authored the PR — the\n // only session that can act on it. The PR's own card must not react to\n // comments on the PR it is reviewing.\n const role = context.flow?.buildRole;\n if (!authoringCard(context) || !role) return;\n if (attachedPullRequest(context) && !context.pullRequest.factoryAuthored) return;\n if (context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // `factoryAuthored` is one bit for the whole Factory, so Factory's own\n // comments are indistinguishable between roles — waking on all of them would\n // let the builder's own progress comments wake itself in a loop. The one\n // exception is the review verdict the Review run had to post as a comment\n // because GitHub refused a self-review: that is the handoff, and it only ever\n // asks for changes once per review, so it cannot sustain a loop.\n if (\n context.actor.type === 'github' &&\n context.actor.factoryAuthored &&\n !requestsChangesVerdict(context.issueComment.body)\n ) {\n return;\n }\n return {\n type: 'sendMessage',\n idempotencyKey: `${context.ingress.id}:address-pull-request-comment`,\n role,\n priority: 'high',\n message:\n `${context.issueComment.author ?? 'Someone'} commented on pull request #${context.pullRequest.number} ` +\n `(${context.issueComment.url ?? context.pullRequest.url}). Read the comment, address it if you agree, and push ` +\n 'the fixes to the PR branch. Reply on GitHub to anything you are deliberately not changing, explaining why.',\n } as const;\n}\n\nfunction pullRequestClosed(context: FactoryGithubRuleContext) {\n if (!context.item || !context.board || !context.pullRequest || context.pullRequest.merged) return;\n if (unreviewedPullRequestCard(context)) return routedOnly(context, 'pull_request.closed');\n if (!reviewsPullRequest(context)) return;\n if (!isPullRequestCard(context.item)) {\n // An issue card waiting in pull request review on its last open pull request goes back to\n // where its board's cards rest; the issue is still open, and another pull request keeps the\n // review going.\n const initialPhase = context.flow?.initialPhase;\n if (!initialPhase || !attachedPullRequest(context) || !inPullRequestReview(context)) return;\n if (newestOpenPullRequestNumber(context.item, context.pullRequest.number) !== null) return;\n return pullRequestMoveByRoutes('pull_request.closed', {\n idempotencyKey: `${context.ingress.id}:pull-request-closed`,\n board: context.board,\n stage: initialPhase,\n message: {\n text: `Pull request #${context.pullRequest.number} was closed without merging; this card was moved back to ${initialPhase}.`,\n },\n });\n }\n // A PR closed without merging is abandoned review work: clear the card off\n // the board instead of leaving it in review forever.\n const canceled = context.boardClosure?.canceled ?? context.flow?.canceled;\n if (!canceled) return;\n return pullRequestMoveByRoutes('pull_request.closed', {\n idempotencyKey: `${context.ingress.id}:pull-request-closed`,\n board: context.board,\n stage: canceled.phase,\n message: {\n text:\n `Pull request #${context.pullRequest.number} was closed without merging; ` +\n `this pull request card was moved to ${canceled.title}.`,\n },\n });\n}\n\nfunction reReviewRequestedPullRequest(context: FactoryGithubRuleContext) {\n // GitHub reviewer requests and Factory's exact mention command are both\n // explicit requests to enter the same Review lifecycle.\n const factoryReviewEntry = context.reviewRequest?.factoryReviewer || context.reviewCommand !== undefined;\n if ((context.item && !reviewsPullRequest(context)) || !factoryReviewEntry) return;\n if (!context.pullRequest || context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n // Trusted (write/admin) requesters only: creating or re-entering review checks\n // out and executes PR code, the same bar pullRequestOpened applies to auto-review.\n if (!trustedGithubActor(context)) return;\n if (context.actor.type === 'github' && context.actor.factoryAuthored) return;\n if (!context.item) {\n // On this path the actor is the *requester*, so the materialized\n // `authorTrusted` stamp records their trust (always true past the gate\n // above), not the PR author's: a trusted maintainer requesting a Factory\n // review vouches for the PR, so the project's pull request route sends it to review.\n return materializePullRequestIntake(context, {\n idempotencyKey: `${context.ingress.id}:pull-request-review-requested-intake`,\n autoStartCandidate: true,\n });\n }\n // Already in review with no verdict yet: a pass is pending or running.\n // Once a verdict is recorded the card rests in review, so a fresh request\n // re-enters the phase to start another pass.\n const stage = context.flow?.pullRequestReview;\n if (!context.board || !stage) return;\n const reviewing = inPullRequestReview(context);\n // On an issue card the pass reviews one pull request at a time; a request for another\n // waits until that one is reviewed or settled.\n if (reviewing && !reviewsThisPullRequest(context)) return;\n if (reviewing && !hasRecordedVerdict(context.item)) return;\n return pullRequestMoveByRoutes('pull_request.review_requested', {\n idempotencyKey: `${context.ingress.id}:re-review-requested`,\n board: context.board,\n stage,\n ...(reviewing ? { reenter: true } : {}),\n });\n}\n\nfunction reReviewUpdatedPullRequest(context: FactoryGithubRuleContext) {\n if (!context.item || !context.board || !reviewsPullRequest(context)) return;\n if (!context.pullRequest || context.pullRequest.state !== 'open' || context.pullRequest.merged) return;\n const stage = context.flow?.pullRequestReview;\n if (!stage) return;\n const reviewing = inPullRequestReview(context);\n // An issue card re-reviews only while its PR review covers this pull request: a push to the\n // builder's own pull request while it builds or self-reviews is the build, not a review cue.\n if (!isPullRequestCard(context.item) && !(reviewing && reviewsThisPullRequest(context))) return;\n // A resting card has not started a review pass yet, so a push there is just\n // more of the code the first pass will read. A push to a card sitting in\n // review is different: it invalidates whatever that pass is reading, so\n // re-enter the phase to supersede it. The phase runner cancels the stale run\n // and the review skill picks the right skill for the entry it sees.\n if (context.phase?.kind === 'resting') return;\n // A fork's author controls its head branch, so an untrusted push must not be\n // able to start review passes on demand; a maintainer can still request one.\n if (!trustedGithubActor(context) && !context.pullRequest.factoryAuthored) return;\n return pullRequestMoveByRoutes('pull_request.synchronized', {\n idempotencyKey: `${context.ingress.id}:re-review-updated`,\n board: context.board,\n stage,\n // Re-entry is the point when the card is already in review: the phase's\n // entry rule is what cancels the superseded pass and starts one on the code\n // that just landed.\n ...(reviewing ? { reenter: true } : {}),\n });\n}\n\nexport const defaultGithubRules = Object.freeze({\n issueOpened: issueOpened,\n // Triage runs once, when a person moves the card into Triage or starts the run; later edits and\n // comments on the issue don't run it again.\n issueEdited: null,\n issueClosed: issueClosed,\n issueReopened: null,\n issueCommentCreated: null,\n issueCommentEdited: null,\n issueCommentDeleted: null,\n pullRequestOpened: pullRequestOpened,\n pullRequestUpdated: reReviewUpdatedPullRequest,\n pullRequestCommentCreated: addressPullRequestComment,\n pullRequestReviewRequested: reReviewRequestedPullRequest,\n pullRequestReviewSubmitted: pullRequestReviewSubmitted,\n pullRequestMerged: pullRequestMerged,\n pullRequestClosed: pullRequestClosed,\n} satisfies GithubEventRules);\n\nexport function resolveGithubRules(overrides?: GithubRuleOverrides): GithubEventRules {\n if (overrides !== undefined && (overrides === null || typeof overrides !== 'object' || Array.isArray(overrides))) {\n throw new Error('GitHub rules must be an object.');\n }\n const rules: Record<string, FactoryRuleHandler<FactoryGithubRuleContext> | null> = { ...defaultGithubRules };\n for (const key of Reflect.ownKeys(overrides ?? {})) {\n if (typeof key !== 'string' || !Object.hasOwn(defaultGithubRules, key)) {\n throw new Error(`Unknown GitHub rule event: ${String(key)}.`);\n }\n const handler = overrides?.[key as FactoryGithubEventName];\n if (handler !== undefined && handler !== null && typeof handler !== 'function') {\n throw new Error(`GitHub rule ${key} must be a function, null, or undefined.`);\n }\n if (handler !== undefined) rules[key] = handler;\n }\n return recordExplicitRuleOverrides(Object.freeze(rules) as GithubEventRules, overrides);\n}\n"],"mappings":";;;;;;;AA6BA,SAAS,mBAAmB,SAA2D;CACrF,OAAO,QAAQ,MAAM,SAAS,YAAY,QAAQ,MAAM;AAC1D;AA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import type { ProjectBoardSource } from '../../boards/project-boards.js';
|
|
4
4
|
import type { FactoryGithubRuleContext, FactorySignalActivityDecision } from '../../rules/types.js';
|
|
5
5
|
import type { StoredBoardScope } from '../../storage/domains/boards/base.js';
|
|
6
|
-
import type { IntakeStorage } from '../../storage/domains/intake/base.js';
|
|
7
6
|
import type { IntegrationStorageHandle } from '../../storage/domains/integrations/base.js';
|
|
8
7
|
import type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';
|
|
9
8
|
import type { SourceControlStorageHandle } from '../../storage/domains/source-control/base.js';
|
|
@@ -58,11 +57,6 @@ export interface GithubRulesOptions {
|
|
|
58
57
|
configVersion: string;
|
|
59
58
|
/** The code boards, or the per-project source so a project's stored boards run its cards. */
|
|
60
59
|
boards: BoardRegistry | ProjectBoardSource;
|
|
61
|
-
/**
|
|
62
|
-
* Decides which installed board an issue lands on: a label route first, then the repository's
|
|
63
|
-
* intake source binding. Absent means the default board.
|
|
64
|
-
*/
|
|
65
|
-
intake?: Pick<IntakeStorage, 'listLabelRoutes' | 'listBindings'>;
|
|
66
60
|
/** Hands a push to a linked repository off for an environment build. */
|
|
67
61
|
onRepositoryPush?: IntegrationHooks['onRepositoryPush'];
|
|
68
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/github/rules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/github/rules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAgBpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,OAAO,KAAK,EAEV,wBAAwB,EAIxB,6BAA6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UAAU,EAAE,mBAAmB,EAC/B,iBAAiB,EAAE,MAAM,EACzB,KAAK,EAAE,yBAAyB,GAC/B,mBAAmB,CAerB;AAiFD;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,gBAAgB,EAAE,wBAAwB,GACzC,2BAA2B,CAkN7B;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,kBAAkB,GAC1B,kBAAkB,GAAG,SAAS,CAYhC;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,kBAAkB,GAC1B,CAAC,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAKhE;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,kBAAkB,EAC3B,gBAAgB,EAAE,wBAAwB,GACzC,2BAA2B,GAAG,SAAS,CAIzC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { closeReason } from "../../boards/board-events.js";
|
|
2
2
|
import "../../boards/index.js";
|
|
3
|
-
import { placedByIntakeRoute } from "../../boards/intake-routing.js";
|
|
4
3
|
import { toBoardSource } from "../../boards/project-boards.js";
|
|
5
|
-
import "../../boards/
|
|
4
|
+
import { cardLabels } from "../../boards/relocate.js";
|
|
6
5
|
import { boardEventHandlers, boardForWorkItem, cardBoardFlow, cardOwnsBranch, eventBoardId, intakeTarget, isTerminalWorkItem, newestOwnedOpenPullRequestNumber, pullRequestSources, rulePhaseField, withBoardClosure, withBoardFlow, workItemPhaseSemantics } from "../../boards/semantics.js";
|
|
7
|
-
import { cardLabels, moveCardToBoard } from "../../boards/relocate.js";
|
|
8
6
|
import { requestsChangesVerdict } from "../../review-verdict.js";
|
|
9
7
|
import { deploymentOwnsEvent, routeEventDecision, selectEventRule, withoutRouteEvent } from "../../rules/event-rules.js";
|
|
10
8
|
import { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from "../../rules/validation.js";
|
|
11
|
-
import { resolveIntakeLabelRoute } from "../../storage/domains/intake/base.js";
|
|
12
9
|
import { FACTORY_PULL_REQUEST_RECONCILIATION_KEY, WorkItemUpdateConflictError } from "../../storage/domains/work-items/base.js";
|
|
13
10
|
import { primarySource } from "../../storage/domains/work-items/work-item-schema.js";
|
|
14
11
|
import { workItemBranch, workItemBranchSource } from "../../work-item-branch.js";
|
|
@@ -268,8 +265,8 @@ function pullRequestProvenance(data, factoryProjectId) {
|
|
|
268
265
|
workItemId: data.workItemId
|
|
269
266
|
};
|
|
270
267
|
}
|
|
271
|
-
/** Identity under which label
|
|
272
|
-
const
|
|
268
|
+
/** Identity under which label and assignee syncs are recorded. */
|
|
269
|
+
const CARD_SYNC_USER_ID = "factory-rule-dispatcher";
|
|
273
270
|
/**
|
|
274
271
|
* Whether a login is Factory itself. Prefers the resolved identity, which is
|
|
275
272
|
* observed from Factory's own writes, and falls back to the configured slug.
|
|
@@ -309,74 +306,31 @@ var GithubRules = class {
|
|
|
309
306
|
return slug ? `${slug.toLowerCase()}[bot]` : void 0;
|
|
310
307
|
}
|
|
311
308
|
/**
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
* Only installed boards count.
|
|
309
|
+
* `labeled` / `unlabeled` are not rule events: the card's label metadata is refreshed and the card
|
|
310
|
+
* stays where it is. Intake routes placed it when it arrived; a label change doesn't move it.
|
|
315
311
|
*/
|
|
316
|
-
async #
|
|
317
|
-
const boards = this.#boards(project);
|
|
318
|
-
const intake = this.options.intake;
|
|
319
|
-
if (!intake) return intakeTarget(boards);
|
|
320
|
-
const { orgId, factoryProjectId } = project;
|
|
321
|
-
if (labels.length > 0) {
|
|
322
|
-
const routes = await intake.listLabelRoutes({
|
|
323
|
-
orgId,
|
|
324
|
-
factoryProjectId,
|
|
325
|
-
integrationId: "github"
|
|
326
|
-
});
|
|
327
|
-
const route = resolveIntakeLabelRoute(routes, labels);
|
|
328
|
-
const board = route ? boards.get(route.board) : void 0;
|
|
329
|
-
if (board) return intakeTarget(boards, board);
|
|
330
|
-
}
|
|
331
|
-
const slug = repositoryName.toLowerCase();
|
|
332
|
-
const binding = (await intake.listBindings({
|
|
333
|
-
orgId,
|
|
334
|
-
integrationId: "github"
|
|
335
|
-
})).find((candidate) => candidate.factoryProjectId === factoryProjectId && (candidate.sourceId === project.projectRepository.repositoryId || candidate.sourceId.toLowerCase() === slug));
|
|
336
|
-
return intakeTarget(boards, binding?.board ? boards.get(binding.board) : void 0);
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* `labeled` / `unlabeled` are not rule events: the labels only decide which board the card belongs
|
|
340
|
-
* on, so the card is re-routed here and its label metadata refreshed. Cards a run owns, and
|
|
341
|
-
* finished cards, stay where they are.
|
|
342
|
-
*/
|
|
343
|
-
async #relocateLabeledIssue(parsed, repositoryId, repositoryName, project) {
|
|
312
|
+
async #syncIssueLabels(parsed, repositoryId, repositoryName, project) {
|
|
344
313
|
const issue = object(parsed.payload.issue);
|
|
345
314
|
const issueNumber = issue?.pull_request === void 0 ? number(issue?.number) : void 0;
|
|
346
315
|
if (!issueNumber) return { status: "ignored" };
|
|
347
316
|
const found = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, void 0, void 0, null);
|
|
348
317
|
if (!found || found.externalSource?.type !== "issue") return { status: "ignored" };
|
|
349
318
|
const labels = labelNames(issue?.labels);
|
|
350
|
-
|
|
351
|
-
let
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (!(error instanceof WorkItemUpdateConflictError)) throw error;
|
|
364
|
-
return { status: "ignored" };
|
|
365
|
-
}
|
|
366
|
-
if (!updated) return { status: "ignored" };
|
|
367
|
-
item = updated.item;
|
|
368
|
-
changed = true;
|
|
319
|
+
if (sameLabels(cardLabels(found), labels)) return { status: "ignored" };
|
|
320
|
+
let updated;
|
|
321
|
+
try {
|
|
322
|
+
updated = await this.options.storage.syncCard({
|
|
323
|
+
orgId: found.orgId,
|
|
324
|
+
id: found.id,
|
|
325
|
+
userId: CARD_SYNC_USER_ID,
|
|
326
|
+
patch: { metadata: { labels } },
|
|
327
|
+
expectedSourceRevision: primarySource(found)?.revision
|
|
328
|
+
});
|
|
329
|
+
} catch (error) {
|
|
330
|
+
if (!(error instanceof WorkItemUpdateConflictError)) throw error;
|
|
331
|
+
return { status: "ignored" };
|
|
369
332
|
}
|
|
370
|
-
|
|
371
|
-
const target = await this.#intakeTarget(project, repositoryName, labels);
|
|
372
|
-
const outcome = await moveCardToBoard({
|
|
373
|
-
workItems: this.options.storage,
|
|
374
|
-
boardRegistry: this.#boards(project),
|
|
375
|
-
userId: LABEL_ROUTE_USER_ID,
|
|
376
|
-
item,
|
|
377
|
-
targetBoard: target?.board ?? "work"
|
|
378
|
-
});
|
|
379
|
-
return { status: changed || outcome === "moved" ? "committed" : "ignored" };
|
|
333
|
+
return { status: updated ? "committed" : "ignored" };
|
|
380
334
|
}
|
|
381
335
|
/**
|
|
382
336
|
* `assigned` / `unassigned` are not rule events either: an existing issue card only mirrors the
|
|
@@ -399,7 +353,7 @@ var GithubRules = class {
|
|
|
399
353
|
return { status: await this.options.storage.syncCard({
|
|
400
354
|
orgId: item.orgId,
|
|
401
355
|
id: item.id,
|
|
402
|
-
userId:
|
|
356
|
+
userId: CARD_SYNC_USER_ID,
|
|
403
357
|
patch: { metadata: {
|
|
404
358
|
assignees,
|
|
405
359
|
...payloadTime !== void 0 ? { githubAssigneesUpdatedAt: updatedAt } : {}
|
|
@@ -416,7 +370,7 @@ var GithubRules = class {
|
|
|
416
370
|
if (parsed.event !== "issues") return void 0;
|
|
417
371
|
switch (string(parsed.payload.action)) {
|
|
418
372
|
case "labeled":
|
|
419
|
-
case "unlabeled": return (...args) => this.#
|
|
373
|
+
case "unlabeled": return (...args) => this.#syncIssueLabels(...args);
|
|
420
374
|
case "assigned":
|
|
421
375
|
case "unassigned": return (...args) => this.#syncIssueAssignees(...args);
|
|
422
376
|
default: return;
|
|
@@ -500,7 +454,7 @@ var GithubRules = class {
|
|
|
500
454
|
const pullRequestFactoryAuthored = provenance !== null || this.#isFactoryLogin(pullRequestAuthor);
|
|
501
455
|
const resolvedItem = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, pullRequestNumber, sameRepositoryHeadBranch(pullRequest, repositoryId), reReviewEvent ? null : provenance, senderIsResponder && !reviewEntryRequested);
|
|
502
456
|
const matchedItem = reviewEntryRequested && resolvedItem?.externalSource?.type !== "pull-request" && !(resolvedItem && pullRequestNumber && attachedPullRequestSource(resolvedItem, repositoryId, repositoryName, pullRequestNumber)) ? void 0 : resolvedItem;
|
|
503
|
-
const intake =
|
|
457
|
+
const intake = intakeTarget(this.#boards(project));
|
|
504
458
|
const actor = await githubActor(this.options.github, {
|
|
505
459
|
installationId,
|
|
506
460
|
repository: repositoryName,
|
|
@@ -1305,7 +1259,6 @@ function githubRulesOptions(github, context) {
|
|
|
1305
1259
|
storage: context.runtime.workItems,
|
|
1306
1260
|
configVersion: context.runtime.configVersion,
|
|
1307
1261
|
boards: context.runtime.boards,
|
|
1308
|
-
intake: context.storage.intake,
|
|
1309
1262
|
...context.hooks?.onRepositoryPush ? { onRepositoryPush: context.hooks.onRepositoryPush } : {}
|
|
1310
1263
|
};
|
|
1311
1264
|
}
|