configure-factory-rules

Configure typed Mastra Factory rules and exact-leaf overrides in deployment code.

27.6k|2.7k|Updated Aug 6, 2024
One-click install
npx skills add https://github.com/mastra-ai/mastra --skill configure-factory-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: configure-factory-rules
Source: https://github.com/mastra-ai/mastra/tree/main/mastracode/factory/factory-skills/configure-factory-rules
Command: npx skills add https://github.com/mastra-ai/mastra --skill configure-factory-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Changing deployment policy in a Mastra Factory setup requires editing typed rule configuration safely, without breaking sibling handlers, weakening tests, or leaking trusted server logic into browser code.

Core Features & Use Cases

  • Locate rule configuration: Find new MastraFactory, defaultFactoryRules, and the rules property without guessing file paths.
  • Apply exact-leaf overrides: Replace a single handler leaf (e.g., work.<stage>.<source>.onEnter) while leaving sibling leaves and built-in behavior intact.
  • Enforce safety constraints: Keep handlers within the five-second evaluation budget, use stable idempotency keys, and return typed FactoryRuleDecision values.
  • Use Case: A deployment needs to reject work-stage transitions from untrusted GitHub actors. The skill guides reading the built-in handler in src/web/factory/rules/defaults.ts, replacing only that leaf, bumping the deployment-owned version, and running focused rule tests plus typecheck.

Quick Start

Ask the assistant to update the Factory rules configuration to override a specific rule leaf and verify the change with the narrow Factory rule tests.

Frequently Asked Questions about configure-factory-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I override a Mastra Factory rule handler?

Override a Factory rule by replacing the exact handler leaf in the rules tree, such as work.<stage>.<source>.onEnter. The override does not compose with the built-in handler, so read the default in src/web/factory/rules/defaults.ts first and preserve any needed behavior explicitly.

How do I find the Factory rules configuration in a deployment?

Search for new MastraFactory, defaultFactoryRules, and the rules property rather than guessing a file path. If the deployment does not configure rules, start with defaultFactoryRules({ version, overrides }) and pass the result to MastraFactory.

Can Factory rules run in React or browser code?

No. Factory rules are trusted server code and must live in the typed deployment configuration. Never place deployment policy in repository instructions, browser code, or a parallel actions system, and never execute authoritative policy in React.

What safety constraints apply to Factory rule handlers?

Handlers must finish within a five-second evaluation budget, return a typed FactoryRuleDecision or undefined, and use stable idempotency keys derived from immutable ingress identity. They must never access credentials, storage handles, worktree paths, or raw webhook payloads.

When should I change the Factory rules version?

Set an explicit deployment-owned version and change it whenever rule behavior changes. The version identifies persisted evaluations and audit records, but it must not be used as event identity or added to ingress deduplication keys.