@mastra/factory 0.13.0-alpha.6 → 0.13.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.
Files changed (119) hide show
  1. package/README.md +153 -0
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +15 -1
  4. package/dist/auth.js.map +1 -1
  5. package/dist/boards/define-board.d.ts +3 -0
  6. package/dist/boards/define-board.d.ts.map +1 -1
  7. package/dist/boards/define-board.js +2 -0
  8. package/dist/boards/define-board.js.map +1 -1
  9. package/dist/boards/index.d.ts +5 -3
  10. package/dist/boards/index.d.ts.map +1 -1
  11. package/dist/boards/index.js +2 -1
  12. package/dist/boards/index.js.map +1 -1
  13. package/dist/boards/registry.d.ts +16 -0
  14. package/dist/boards/registry.d.ts.map +1 -0
  15. package/dist/boards/registry.js +27 -0
  16. package/dist/boards/registry.js.map +1 -0
  17. package/dist/boards/review.js +1 -1
  18. package/dist/boards/transition-policy.d.ts +63 -0
  19. package/dist/boards/transition-policy.d.ts.map +1 -0
  20. package/dist/boards/transition-policy.js +36 -0
  21. package/dist/boards/transition-policy.js.map +1 -0
  22. package/dist/boards/work-transition-policy.d.ts +3 -0
  23. package/dist/boards/work-transition-policy.d.ts.map +1 -0
  24. package/dist/boards/work-transition-policy.js +31 -0
  25. package/dist/boards/work-transition-policy.js.map +1 -0
  26. package/dist/boards/work.d.ts.map +1 -1
  27. package/dist/boards/work.js +4 -2
  28. package/dist/boards/work.js.map +1 -1
  29. package/dist/factory.d.ts +6 -1
  30. package/dist/factory.d.ts.map +1 -1
  31. package/dist/factory.js +10 -0
  32. package/dist/factory.js.map +1 -1
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +3 -2
  36. package/dist/integrations/github/default-rules.d.ts +194 -0
  37. package/dist/integrations/github/default-rules.d.ts.map +1 -0
  38. package/dist/integrations/github/default-rules.js +230 -0
  39. package/dist/integrations/github/default-rules.js.map +1 -0
  40. package/dist/integrations/github/integration.d.ts +4 -0
  41. package/dist/integrations/github/integration.d.ts.map +1 -1
  42. package/dist/integrations/github/integration.js +6 -0
  43. package/dist/integrations/github/integration.js.map +1 -1
  44. package/dist/integrations/github/routes.js +1 -1
  45. package/dist/integrations/github/rules.d.ts +3 -1
  46. package/dist/integrations/github/rules.d.ts.map +1 -1
  47. package/dist/integrations/github/rules.js +1 -2
  48. package/dist/integrations/github/rules.js.map +1 -1
  49. package/dist/integrations/github/webhook.js +1 -1
  50. package/dist/integrations/linear/default-rules.d.ts +44 -0
  51. package/dist/integrations/linear/default-rules.d.ts.map +1 -0
  52. package/dist/integrations/linear/default-rules.js +65 -0
  53. package/dist/integrations/linear/default-rules.js.map +1 -0
  54. package/dist/integrations/linear/integration.d.ts +5 -1
  55. package/dist/integrations/linear/integration.d.ts.map +1 -1
  56. package/dist/integrations/linear/integration.js +7 -1
  57. package/dist/integrations/linear/integration.js.map +1 -1
  58. package/dist/integrations/linear/issue-reconciler.d.ts +1 -1
  59. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
  60. package/dist/integrations/linear/issue-reconciler.js +2 -1
  61. package/dist/integrations/linear/issue-reconciler.js.map +1 -1
  62. package/dist/integrations/linear/rules.d.ts +5 -1
  63. package/dist/integrations/linear/rules.d.ts.map +1 -1
  64. package/dist/integrations/linear/rules.js +4 -4
  65. package/dist/integrations/linear/rules.js.map +1 -1
  66. package/dist/integrations/platform/github/integration.d.ts +4 -0
  67. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  68. package/dist/integrations/platform/github/integration.js +6 -0
  69. package/dist/integrations/platform/github/integration.js.map +1 -1
  70. package/dist/integrations/platform/linear/integration.d.ts +5 -1
  71. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  72. package/dist/integrations/platform/linear/integration.js +9 -3
  73. package/dist/integrations/platform/linear/integration.js.map +1 -1
  74. package/dist/integrations/slack/slack.d.ts +3 -1
  75. package/dist/integrations/slack/slack.d.ts.map +1 -1
  76. package/dist/integrations/slack/slack.js +20 -2
  77. package/dist/integrations/slack/slack.js.map +1 -1
  78. package/dist/routes/surface.d.ts +3 -0
  79. package/dist/routes/surface.d.ts.map +1 -1
  80. package/dist/routes/surface.js +2 -1
  81. package/dist/routes/surface.js.map +1 -1
  82. package/dist/routes/work-items.d.ts +3 -0
  83. package/dist/routes/work-items.d.ts.map +1 -1
  84. package/dist/routes/work-items.js +48 -15
  85. package/dist/routes/work-items.js.map +1 -1
  86. package/dist/rules/defaults.d.ts.map +1 -1
  87. package/dist/rules/defaults.js +2 -325
  88. package/dist/rules/defaults.js.map +1 -1
  89. package/dist/rules/dispatcher.js +1 -1
  90. package/dist/rules/index.d.ts +2 -2
  91. package/dist/rules/index.d.ts.map +1 -1
  92. package/dist/rules/index.js +2 -2
  93. package/dist/rules/processor.d.ts +2 -0
  94. package/dist/rules/processor.d.ts.map +1 -1
  95. package/dist/rules/processor.js +9 -7
  96. package/dist/rules/processor.js.map +1 -1
  97. package/dist/rules/resolve.d.ts +4 -5
  98. package/dist/rules/resolve.d.ts.map +1 -1
  99. package/dist/rules/resolve.js +4 -9
  100. package/dist/rules/resolve.js.map +1 -1
  101. package/dist/rules/transition-service.d.ts +2 -0
  102. package/dist/rules/transition-service.d.ts.map +1 -1
  103. package/dist/rules/transition-service.js +46 -28
  104. package/dist/rules/transition-service.js.map +1 -1
  105. package/dist/rules/types.d.ts +2 -17
  106. package/dist/rules/types.d.ts.map +1 -1
  107. package/dist/rules/types.js +1 -1
  108. package/dist/rules/types.js.map +1 -1
  109. package/dist/rules/validation.d.ts.map +1 -1
  110. package/dist/rules/validation.js +2 -38
  111. package/dist/rules/validation.js.map +1 -1
  112. package/dist/storage/domains/comments/domain.js +1 -1
  113. package/dist/storage/domains/comments/routes.js +1 -1
  114. package/dist/storage/domains/work-items/base.d.ts +11 -1
  115. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  116. package/dist/storage/domains/work-items/base.js +22 -2
  117. package/dist/storage/domains/work-items/base.js.map +1 -1
  118. package/factory-skills/configure-factory-rules/SKILL.md +42 -11
  119. package/package.json +13 -7
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: configure-factory-rules
3
- description: Configure typed Mastra Factory rules and exact-leaf overrides in deployment code
3
+ description: Configure definition-owned board handlers, integration event rules, and global tool-result rules
4
4
  ---
5
5
 
6
6
  # Configure Factory Rules
@@ -9,33 +9,64 @@ Help the user change Factory policy in the typed deployment configuration. Facto
9
9
 
10
10
  ## Find the configuration
11
11
 
12
- 1. Search for `new MastraFactory`, `defaultFactoryRules`, and the `rules` property.
12
+ 1. Search for `new MastraFactory`, its `boards` and `includeDefaultBoards` options, `defineBoard`, `defaultFactoryRules`, and the installed `GithubIntegration`, `PlatformGithubIntegration`, `LinearIntegration`, or `PlatformLinearIntegration` constructors and their `rules` options.
13
13
  2. Read the existing rule configuration and its tests before editing.
14
14
  3. Import rule helpers and types from the same local Factory module used by the deployment.
15
- 4. If the deployment doesn't configure `rules`, start with `defaultFactoryRules({ version, overrides })` and pass the result to `MastraFactory`.
15
+ 4. For custom-board handlers, edit the installed `defineBoard()` definition. For tool rules, use `defaultFactoryRules({ version, overrides: { tools } })` and pass the result to `MastraFactory`. For GitHub or Linear rules, configure the installed integration constructor directly.
16
16
 
17
17
  Do not guess a file path. Factory deployments can assemble `MastraFactory` from different entry points.
18
18
 
19
19
  ## Preserve the public shape
20
20
 
21
- Use one rules tree:
21
+ Installed board definitions exclusively own lifecycle handlers: use `phases.<phase>.onEnter.<source>` and `phases.<phase>.onExit.<source>` in `defineBoard()`. Sources are `issue`, `pullRequest`, `linearIssue`, and `manual`. Work and Review install automatically with preferred defaults. Custom boards are installed through `boards`; `includeDefaultBoards: false` supports custom-only installations.
22
22
 
23
- - `work.<stage>.<source>.onEnter` or `onExit`
24
- - `review.<stage>.<source>.onEnter` or `onExit`
25
- - `tools.<toolName>.onResult`
26
- - `github.<event>.onEvent`
23
+ Remove former global `rules.work` and `rules.review` configuration. Built-in customization is deferred: do not invent a board override API, derive replacements, or use reserved IDs `work` and `review`. The global rules tree contains only `version` and `tools.<toolName>.onResult`.
24
+
25
+ Work automatic intake requires both `linked_item_materialized` and `autoStartCandidate: true`. Do not remove these guards to reproduce the web deployment's former unconditional intake override. Noncandidate and manual arrivals stay unstarted merely from entering Intake; explicit issue triage and human-approval safeguards remain. Linear Intake and Review retain their existing defaults and guards.
26
+
27
+ Configure GitHub on the installed `GithubIntegration` or `PlatformGithubIntegration` constructor, and Linear on `LinearIntegration` or `PlatformLinearIntegration`, instead:
28
+
29
+ ```typescript
30
+ new PlatformGithubIntegration({ rules: { issueCommentCreated: null } });
31
+ new PlatformLinearIntegration({ rules: { issueClosed: null } });
32
+ ```
33
+
34
+ GitHub and Linear integrations exclusively own their event handlers; configure them through constructor `rules[event]`, not the global Factory rules tree. Move former `rules.linear[event].onEvent` values to the Linear constructor's `rules[event]`. Every built-in handler is enabled automatically; never import or spread defaults just to install an integration. A function replaces the default, `null` disables that event's handler, and omitted or `undefined` values retain defaults. Constructors validate names and handler values, then copy and freeze the effective map per instance. Disabling a handler does not disable authentication, ingestion, or reconciliation bookkeeping. Linear fetch, platform polling, and reconciliation all use the owning instance's handlers.
27
35
 
28
36
  Do not create an `actions` config or execute authoritative policy in React. Each handler returns one typed `FactoryRuleDecision` or `undefined`.
29
37
 
30
38
  Work and Review cards move independently. Never mirror their stages or mark Work Done only because a pull request merged.
31
39
 
32
- ## Apply exact-leaf overrides
40
+ ## Configure board transition policy
41
+
42
+ Search the installed `defineBoard()` definition for `transitionPolicy`. Read `src/boards/transition-policy.ts` for the public contract and `src/boards/work-transition-policy.ts` for Work's automatic classification, approval, and acceptance policy. Review has no additional policy. Custom boards without a policy do not inherit Work's classification or acceptance behavior through phase or role names.
43
+
44
+ Topology declares allowed moves; transition policy adds business restrictions; lifecycle handlers return effects. Add custom restrictions to the board definition, not the generic transition service or global rules:
45
+
46
+ ```typescript
47
+ import type { BoardTransitionPolicy } from '@mastra/factory/boards';
48
+
49
+ const transitionPolicy: BoardTransitionPolicy = context => {
50
+ if (context.toStage === 'shipped' && !context.isHumanTransition) {
51
+ return { type: 'reject', code: 'approval_required', reason: 'A person must approve this release.' };
52
+ }
53
+ };
54
+ // Pass transitionPolicy to the installed custom defineBoard() definition.
55
+ ```
56
+
57
+ The policy receives a deeply readonly snapshot with ISO-string dates. Return `undefined`, `{ type: 'allow', triageType?, accept?: true }`, or `{ type: 'reject', code, reason }`, never skill calls, transitions, consent overrides, or patches. Classification intents require the existing triage-agent path and must match its requested classification. Acceptance requires both human actor and human ingress. Runtime validates results and commits intents atomically only after successful lifecycle evaluation.
58
+
59
+ Policies must be side-effect-free and share the lifecycle timeout budget. Initial entry, reentry, and same-stage requests evaluate policy; completed replay does not. Concurrent attempts may evaluate more than once, and timing out does not cancel work started by a callback. Do not access storage or integrations from a policy.
60
+
61
+ Policy allowance cannot bypass topology, board ownership, ingress authorization, external-author safety, revision checks, replay, or decision validation. Working/resting phase semantics, role routing, terminal cleanup, consent, and kickoff behavior still contain built-in naming assumptions; custom policies do not generalize them. Do not advertise a custom `shipped` phase as terminal or invent built-in replacement APIs.
62
+
63
+ ## Apply supported overrides
33
64
 
34
- An override replaces the exact handler leaf. It does not compose with the built-in handler at that leaf. Sibling leaves remain unchanged.
65
+ Tool-result overrides replace the exact handler leaf. Integration overrides replace one event handler. Neither composes with the built-in handler; siblings remain unchanged. Board handlers belong to their definitions, not this override mechanism.
35
66
 
36
67
  Before replacing a built-in leaf:
37
68
 
38
- 1. Read the built-in handler in `src/web/factory/rules/defaults.ts`.
69
+ 1. Find and read the built-in handler: GitHub handlers live in `src/integrations/github/default-rules.ts`, Linear handlers in `src/integrations/linear/default-rules.ts`, and tool defaults in `src/rules/defaults.ts` within the Factory package. Inspect Work and Review defaults in `src/boards/work.ts` and `src/boards/review.ts`, and custom handlers in their installed definitions.
39
70
  2. Decide whether the replacement must preserve part of that behavior explicitly.
40
71
  3. Use only fields exposed by the typed context. Do not reach into Factory storage or raw webhook payloads.
41
72
  4. Return `undefined` to allow the ingress with no decision, or return a typed rejection or bounded structured decision.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/factory",
3
- "version": "0.13.0-alpha.6",
3
+ "version": "0.13.0-alpha.8",
4
4
  "description": "Mastra Software Factory module: the server core behind the Mastra Software Factory — storage domains, integrations, and surfaces for agent-powered software delivery",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -19,6 +19,12 @@
19
19
  "default": "./dist/index.js"
20
20
  }
21
21
  },
22
+ "./boards": {
23
+ "import": {
24
+ "types": "./dist/boards/index.d.ts",
25
+ "default": "./dist/boards/index.js"
26
+ }
27
+ },
22
28
  "./*": {
23
29
  "import": {
24
30
  "types": "./dist/*.d.ts",
@@ -52,9 +58,9 @@
52
58
  "zod": "^4.3.6",
53
59
  "@mastra/auth-studio": "1.3.5",
54
60
  "@mastra/auth-workos": "1.6.5",
55
- "@mastra/code-sdk": "1.7.0-alpha.5",
56
- "@mastra/core": "1.65.0-alpha.4",
57
- "@mastra/slack": "1.6.3"
61
+ "@mastra/code-sdk": "1.7.0-alpha.7",
62
+ "@mastra/slack": "1.6.3",
63
+ "@mastra/core": "1.65.0-alpha.6"
58
64
  },
59
65
  "devDependencies": {
60
66
  "@types/node": "22.20.1",
@@ -63,11 +69,11 @@
63
69
  "typescript": "^6.0.3",
64
70
  "typescript-eslint": "^8.57.0",
65
71
  "vitest": "4.1.10",
72
+ "@internal/lint": "0.0.130",
66
73
  "@mastra/libsql": "1.22.4-alpha.0",
67
74
  "@mastra/pg": "1.23.0-alpha.1",
68
- "@internal/lint": "0.0.130",
69
- "@internal/workspace": "0.0.2",
70
- "@internal/types-builder": "0.0.105"
75
+ "@internal/types-builder": "0.0.105",
76
+ "@internal/workspace": "0.0.2"
71
77
  },
72
78
  "engines": {
73
79
  "node": ">=22.19.0"