@mestreyoda/fabrica 0.2.14 → 0.2.16

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 CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  > Autonomous software engineering pipeline for OpenClaw.
7
7
 
8
- Fabrica turns a natural-language project description into a fully executed engineering workflow: intake, specification, issue decomposition, development, code review, testing, and merge — with zero manual intervention. It orchestrates AI agents as specialized workers (developers, reviewers, testers) through a deterministic finite state machine.
8
+ Fabrica turns a natural-language project description into a fully executed engineering workflow: intake, specification, issue decomposition, development, code review, testing, and merge. It orchestrates AI agents as specialized workers (developers, reviewers, testers) through a deterministic finite state machine, with repair-oriented recovery when runtime signals or stack environments are incomplete.
9
9
 
10
10
  ## How it works
11
11
 
@@ -34,7 +34,7 @@ Fabrica turns a natural-language project description into a fully executed engin
34
34
  done
35
35
  ```
36
36
 
37
- The heartbeat ticks every 60 seconds. On each tick, Fabrica alternates between a **repair** pass (fixes stale states) and a **triage** pass (advances work that is ready to move). No human intervention is required after the initial project description.
37
+ The heartbeat ticks every 60 seconds. On each tick, Fabrica alternates between a **repair** pass (fixes stale states, retries incomplete completion signals, and reconciles broken runtime ownership) and a **triage** pass (advances work that is ready to move). No human intervention is required after the initial project description.
38
38
 
39
39
  ## Features
40
40
 
@@ -43,9 +43,12 @@ The heartbeat ticks every 60 seconds. On each tick, Fabrica alternates between a
43
43
  - **Pluggable AI workers** — each role (developer, reviewer, tester, architect) maps to a configurable model and level
44
44
  - **Polling-first GitHub integration** — uses `gh` CLI for all GitHub operations; no webhook infrastructure or GitHub App required
45
45
  - **Telegram bootstrap** (optional) — describe a new project via DM; Fabrica asks clarifying questions and provisions the repo automatically
46
+ - **Stack-aware environment gate** — developer and tester dispatch only start after the project stack environment is provisioned and marked ready
47
+ - **Lifecycle-driven worker completion** — reviewer, developer, tester, and architect completion resolve from agent lifecycle plus canonical result lines, not from fragile tool availability assumptions
48
+ - **Detailed event timeline** — project topics receive explicit worker start, completion, review, rejection, and recovery events with cycle-aware dedupe
46
49
  - **Programmatic genesis** — trigger the full pipeline from a CLI script without Telegram
47
50
  - **Observability built-in** — audit log, metrics subcommand, heartbeat health checks, and OpenTelemetry tracing
48
- - **Safe-by-default** — conflict detection, mutex-guarded heartbeat, session validation, and label integrity guards
51
+ - **Safe-by-default** — conflict detection, mutex-guarded heartbeat, stack bootstrap retries, session validation, completion recovery, and label integrity guards
49
52
 
50
53
  ## Requirements
51
54
 
@@ -54,6 +57,7 @@ The heartbeat ticks every 60 seconds. On each tick, Fabrica alternates between a
54
57
  - Node.js 20+ (for local development or programmatic genesis)
55
58
  - `gh` CLI authenticated to GitHub (required for issue and PR operations)
56
59
  - A GitHub organization or personal account where repositories will be created
60
+ - For Python stacks, Fabrica provisions `uv` and project-local environments itself without `sudo`
57
61
  - (Optional) Telegram bot token and group chat IDs for DM bootstrap and notifications
58
62
 
59
63
  ## Installation
@@ -92,7 +96,17 @@ operational/workspace state, then tells you what is still missing.
92
96
 
93
97
  ## Quick start
94
98
 
95
- **1. Install Fabrica**:
99
+ This is the minimum recommended path to get Fabrica working end-to-end with the official product flow.
100
+
101
+ **1. Authenticate GitHub CLI**:
102
+
103
+ ```bash
104
+ gh auth status || gh auth login
105
+ ```
106
+
107
+ Fabrica uses authenticated `gh` CLI for GitHub operations in the default setup.
108
+
109
+ **2. Install Fabrica**:
96
110
 
97
111
  ```bash
98
112
  openclaw plugins install @mestreyoda/fabrica
@@ -100,30 +114,69 @@ openclaw plugins install @mestreyoda/fabrica
100
114
 
101
115
  The plugin should load immediately after install, without manual remediation.
102
116
 
103
- **2. Confirm loadability**:
117
+ **3. Confirm loadability**:
104
118
 
105
119
  ```bash
106
120
  openclaw plugins inspect fabrica
107
121
  ```
108
122
 
109
- **3. Configure operational state for a workspace**:
123
+ **4. Configure Fabrica for a workspace**:
110
124
 
111
125
  ```bash
112
126
  openclaw fabrica doctor workspace --workspace /path/to/workspace
113
127
  openclaw fabrica setup --workspace /path/to/workspace --new-agent fabrica
114
128
  ```
115
129
 
116
- Use `openclaw fabrica setup --agent <id>` if you already have an agent. GitHub,
117
- Telegram, and webhook behavior are separate operational concerns, not
118
- installation dependencies.
130
+ Use `openclaw fabrica setup --agent <id>` if you already have an agent.
131
+
132
+ When the official Telegram DM bootstrap flow is configured (`bootstrapDmEnabled=true`
133
+ plus `projectsForumChatId`), `openclaw fabrica setup` also prepares the dedicated
134
+ internal `genesis` agent automatically.
119
135
 
120
- **4. Restart the gateway**:
136
+ **5. Configure Telegram for the official Fabrica flow**:
137
+
138
+ The official flow is:
139
+ - Telegram DM with the bot for new-project intake
140
+ - one Telegram forum group for project topics/timelines
141
+
142
+ At minimum, when DM bootstrap is enabled, set:
143
+ - `plugins.entries.fabrica.config.telegram.bootstrapDmEnabled=true`
144
+ - `plugins.entries.fabrica.config.telegram.projectsForumChatId=<YOUR_PROJECTS_FORUM_CHAT_ID>`
145
+
146
+ If `projectsForumChatId` is missing while DM bootstrap is enabled, Fabrica can accept the DM but will fail when it needs to create the project topic.
147
+
148
+ **6. Validate operational readiness**:
149
+
150
+ ```bash
151
+ openclaw plugins inspect fabrica
152
+ openclaw fabrica doctor workspace --workspace /path/to/workspace
153
+ ```
154
+
155
+ **Environment provisioning note**:
156
+
157
+ Developer and tester pickup pass through a stack environment gate. Fabrica
158
+ prepares the project environment before dispatching real work, instead of
159
+ finding missing dependencies inside a live worker run.
160
+
161
+ For Python projects, this includes just-in-time `uv` installation when needed,
162
+ a shared toolchain, and a project-local `.venv`.
163
+
164
+ For existing Node projects, Fabrica expects a reproducible lockfile
165
+ (`package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, or `bun.lock`) before
166
+ real developer/tester dispatch. Greenfield scaffold mode can materialize the
167
+ first deterministic lockfile, but regular runtime pickup fails closed without
168
+ one.
169
+
170
+ `dryRun: true` skips environment provisioning entirely and remains side-effect
171
+ free.
172
+
173
+ **7. Restart the gateway if needed**:
121
174
 
122
175
  ```bash
123
176
  systemctl --user restart openclaw-gateway.service
124
177
  ```
125
178
 
126
- **5. Trigger a new project programmatically**:
179
+ **8. Trigger a new project programmatically**:
127
180
 
128
181
  ```bash
129
182
  cd ~/fabrica # GitHub clone install only
@@ -135,13 +188,13 @@ npx tsx scripts/genesis-trigger.ts "A CLI tool that counts words in a file" \
135
188
 
136
189
  Remove `--dry-run` to execute for real.
137
190
 
138
- **6. Watch the pipeline run**:
191
+ **9. Watch the pipeline run**:
139
192
 
140
193
  ```bash
141
194
  tail -f ~/.openclaw/workspace/logs/genesis.log
142
195
  ```
143
196
 
144
- **7. Check metrics**:
197
+ **10. Check metrics**:
145
198
 
146
199
  ```bash
147
200
  openclaw fabrica metrics
@@ -212,7 +265,11 @@ Use plugin config when you want explicit webhook behavior or provider auth profi
212
265
 
213
266
  ### With Telegram
214
267
 
215
- Telegram enables DM-based project bootstrap, per-project forum topics, and a separate ops chat for heartbeat and cron notifications.
268
+ Telegram is the primary human-facing entrypoint for Fabrica:
269
+ - DM with the bot for new-project intake and short clarifications
270
+ - one Telegram forum group where Fabrica creates one topic per project
271
+
272
+ Recommended minimum Telegram configuration:
216
273
 
217
274
  ```json
218
275
  {
@@ -232,8 +289,7 @@ Telegram enables DM-based project bootstrap, per-project forum topics, and a sep
232
289
  "telegram": {
233
290
  "bootstrapDmEnabled": true,
234
291
  "projectsForumChatId": "<YOUR_PROJECTS_FORUM_CHAT_ID>",
235
- "projectsForumAccountId": "<OPTIONAL_TELEGRAM_ACCOUNT_ID>",
236
- "opsChatId": "<YOUR_OPS_CHAT_ID>"
292
+ "projectsForumAccountId": "<OPTIONAL_TELEGRAM_ACCOUNT_ID>"
237
293
  }
238
294
  }
239
295
  }
@@ -242,7 +298,20 @@ Telegram enables DM-based project bootstrap, per-project forum topics, and a sep
242
298
  }
243
299
  ```
244
300
 
245
- With Telegram enabled, send a project idea to the bot in a DM. Fabrica will ask clarifying questions, provision the GitHub repo, create a dedicated forum topic for the project, and keep ops-only notifications on the separate `opsChatId` route.
301
+ `projectsForumChatId` is the key Fabrica-specific Telegram setting for the official DM topic flow.
302
+
303
+ When both `bootstrapDmEnabled=true` and `projectsForumChatId` are present,
304
+ `openclaw fabrica setup` automatically prepares the internal `genesis` agent used
305
+ for the DM intake path.
306
+
307
+ `opsChatId` still exists in plugin config for deployments that want a separate ops-only route, but it is not required for the core product flow.
308
+
309
+ With Telegram enabled, send a project idea to the bot in a DM. Fabrica will ask clarifying questions, provision the GitHub repo, create a dedicated forum topic for the project, and continue the project lifecycle in that topic.
310
+
311
+ Project topics are event-driven timelines. Fabrica emits explicit messages for
312
+ worker start, worker completion, review queueing, reviewer reject/approve, and
313
+ operational recovery events, with cycle-aware dedupe so late deliveries from an
314
+ older dispatch do not masquerade as current work.
246
315
 
247
316
  ## Programmatic genesis
248
317
 
@@ -1,5 +1,15 @@
1
1
  # Architect Worker Instructions
2
2
 
3
+ ## Execution Contract
4
+
5
+ You must execute the task directly in the worktree assigned to this task.
6
+ Do not leave the assigned worktree execution path.
7
+ Do not delegate implementation, testing, review, or planning to another coding agent.
8
+ Do not use nested coding agents.
9
+ Do not use planning or meta-skills such as brainstorming, writing-plans, or coding-agent.
10
+ Do not spawn, supervise, or instruct another agent to do the work for you.
11
+ If you cannot proceed directly in the assigned worktree, end with your role's canonical blocked result line.
12
+
3
13
  You research design/architecture questions and produce detailed, development-ready findings.
4
14
 
5
15
  ## Your Job
@@ -1,5 +1,15 @@
1
1
  # DEVELOPER Worker Instructions
2
2
 
3
+ ## Execution Contract
4
+
5
+ You must execute the task directly in the worktree assigned to this task.
6
+ Do not leave the assigned worktree execution path.
7
+ Do not delegate implementation, testing, review, or planning to another coding agent.
8
+ Do not use nested coding agents.
9
+ Do not use planning or meta-skills such as brainstorming, writing-plans, or coding-agent.
10
+ Do not spawn, supervise, or instruct another agent to do the work for you.
11
+ If you cannot proceed directly in the assigned worktree, end with your role's canonical blocked result line.
12
+
3
13
  ## Context You Receive
4
14
 
5
15
  When you start work, you're given:
@@ -12,9 +22,9 @@ Read the comments carefully — they often contain clarifications, decisions, or
12
22
 
13
23
  ## Workflow
14
24
 
15
- ### 1. Create a worktree
25
+ ### 1. Use the assigned worktree
16
26
 
17
- **NEVER work in the main checkout.** Create a dedicated git worktree as a sibling to the repo:
27
+ **NEVER work in the main checkout.** Use the assigned git worktree for this task. If it does not already exist, create it as a sibling to the repo:
18
28
 
19
29
  ```bash
20
30
  # Example: repo is at ~/git/myproject
@@ -26,7 +36,8 @@ git worktree add "$WORKTREE" -b "$BRANCH"
26
36
  cd "$WORKTREE"
27
37
  ```
28
38
 
29
- The `.worktrees/` directory sits NEXT TO the repo folder (not inside it). This keeps the main checkout clean for the orchestrator and other workers. If a worktree already exists from a previous task on the same branch, verify it's clean before reusing it.
39
+ The `.worktrees/` directory sits NEXT TO the repo folder (not inside it). This keeps the main checkout clean for the orchestrator and other workers. If the assigned worktree already exists from a previous task on the same branch, verify it's clean and reuse it.
40
+ Once you are in the assigned worktree, stay there for the rest of the task and do not switch back to the main checkout.
30
41
 
31
42
  ### 2. Implement the changes
32
43
 
@@ -32,6 +32,24 @@ Your review comment MUST include a checklist showing which items you verified an
32
32
 
33
33
  # REVIEWER Worker Instructions
34
34
 
35
+ ## Execution Contract
36
+
37
+ You must execute the review directly in the worktree assigned to this task.
38
+ Do not leave the assigned worktree execution path.
39
+ Do not delegate review work to another coding agent.
40
+ Do not use nested coding agents.
41
+ Do not use planning or meta-skills such as brainstorming, writing-plans, or coding-agent.
42
+ Do not spawn, supervise, or instruct another agent to do the work for you.
43
+ Keep review verdict semantics pure: emit `Review result: APPROVE` or `Review result: REJECT` only for a real review verdict.
44
+
45
+ ## Task Completion
46
+
47
+ When you finish an actual review verdict, end your response with exactly one decision line in plain text:
48
+ - `Review result: APPROVE`
49
+ - `Review result: REJECT`
50
+
51
+ The orchestrator reads that line directly from your response and advances the review stage automatically.
52
+
35
53
  You are a code reviewer. Your job is to review the PR diff for quality, correctness, security, and style.
36
54
 
37
55
  ## Context You Receive
@@ -2,6 +2,16 @@
2
2
 
3
3
  You test the code changes for the issue by running QA on the correct branch.
4
4
 
5
+ ## Execution Contract
6
+
7
+ You must execute the task directly in the worktree assigned to this task.
8
+ Do not leave the assigned worktree execution path.
9
+ Do not delegate implementation, testing, review, or planning to another coding agent.
10
+ Do not use nested coding agents.
11
+ Do not use planning or meta-skills such as brainstorming, writing-plans, or coding-agent.
12
+ Do not spawn, supervise, or instruct another agent to do the work for you.
13
+ If you cannot proceed directly in the assigned worktree, end with your role's canonical blocked result line.
14
+
5
15
  ## Context You Receive
6
16
 
7
17
  - **Issue:** the original task description, acceptance criteria, and discussion
@@ -11,27 +21,35 @@ You test the code changes for the issue by running QA on the correct branch.
11
21
 
12
22
  ## Your Job
13
23
 
14
- ### 1. Checkout the correct branch
24
+ ### 1. Open the PR branch in its dedicated worktree
15
25
 
16
- The PR may NOT be merged yet when you are dispatched. You MUST test the PR branch, not main.
26
+ The PR may NOT be merged yet when you are dispatched. You MUST test the PR branch in its dedicated worktree, not the main checkout.
27
+ Do not use the main checkout while an open PR branch exists.
17
28
 
18
29
  ```bash
19
30
  REPO_ROOT="<repo path from task message>"
20
- cd "$REPO_ROOT"
21
- git fetch origin
31
+ git -C "$REPO_ROOT" fetch origin
22
32
 
23
33
  # Find the PR for this issue by branch naming convention
24
34
  ISSUE_NUM=<issue number from task message>
25
- REMOTE_URL="$(git remote get-url origin)"
35
+ REMOTE_URL="$(git -C "$REPO_ROOT" remote get-url origin)"
26
36
  PR_BRANCH=$(gh pr list --repo "$REMOTE_URL" --state open --json headRefName --jq "[.[] | select(.headRefName | test(\"/(${ISSUE_NUM})-\"))][0].headRefName" 2>/dev/null)
27
37
 
28
38
  if [[ -n "$PR_BRANCH" && "$PR_BRANCH" != "null" ]]; then
29
- # Open PR exists with matching branch — checkout the PR branch
30
- git checkout "$PR_BRANCH" && git pull origin "$PR_BRANCH"
31
- echo "Testing PR branch: $PR_BRANCH"
39
+ WORKTREE="${REPO_ROOT}.worktrees/${PR_BRANCH}"
40
+ if [[ -d "$WORKTREE" ]]; then
41
+ # Open PR exists with matching branch — reuse the dedicated worktree
42
+ cd "$WORKTREE"
43
+ else
44
+ # Open PR exists with matching branch — create the dedicated worktree
45
+ git -C "$REPO_ROOT" worktree add "$WORKTREE" "origin/$PR_BRANCH"
46
+ cd "$WORKTREE"
47
+ fi
48
+ echo "Testing PR branch in dedicated worktree: $WORKTREE"
32
49
  else
33
50
  # No open PR for this issue — test on main (post-merge scenario)
34
- git checkout main && git pull origin main
51
+ cd "$REPO_ROOT"
52
+ git -C "$REPO_ROOT" checkout main && git -C "$REPO_ROOT" pull origin main
35
53
  echo "Testing main branch (PR already merged)"
36
54
  fi
37
55
  ```