@mestreyoda/fabrica 0.2.13 → 0.2.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.15 - 2026-04-03
4
+
5
+ - Hardened Telegram DM intake around durable `pending_classify` / `classifying` recovery, newer-attempt ownership, and explicit late-classify reconciliation.
6
+ - Added runtime-aware DM claiming via `before_dispatch` plus short-lived message/conversation guards so Telegram prompts stay inside Fabrica instead of leaking to the generic OpenClaw agent.
7
+ - Fixed greenfield scaffold canonical repo path handling so `metadata.repo_path` / `scaffold_plan.repo_local` survive all the way into `scaffold-project.sh` and published genesis assets.
8
+ - Tightened bootstrap and register fail-closed behavior for unsupported stacks and missing materialized repositories, preventing half-registered validation projects.
9
+ - Reset and revalidated the temporary Telegram validation harness, including a reusable runner path and regression coverage for read/wait flows.
10
+ - Extended regression coverage for Telegram bootstrap recovery, scaffold path ownership, classify-step typing, and end-to-end hot-path stability.
11
+
12
+ ## 0.2.14 - 2026-04-02
13
+
14
+ - Added a stack-aware environment gate so developer and tester pickup only start after project environments are provisioned and marked ready.
15
+ - Hardened Python stack bootstrap around durable environment state, retry scheduling, and stale provisioning recovery without `sudo`.
16
+ - Reworked worker recovery so observable activity without a canonical result enters bounded completion recovery instead of immediately corrupting dispatch health.
17
+ - Made heartbeat distinguish accepted-but-idle dispatches, inconclusive completion, terminal sessions, and true dead sessions with cycle-aware ownership checks.
18
+ - Added explicit timeline events for reviewer outcomes and worker recovery exhaustion, with cycle-aware dedupe and corrected destination-state messaging.
19
+ - Preserved reviewer notification routing through plugin notification config instead of bypassing runtime settings.
20
+ - Extended regression coverage for environment provisioning, gateway session transcript activity, heartbeat recovery, reviewer notifications, and end-to-end hot-path orchestration.
21
+
3
22
  ## 0.2.13 - 2026-03-31
4
23
 
5
24
  - Disabled automatic pretty logging on TTY so the plugin no longer depends on `pino-pretty` during load.
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
@@ -117,6 +121,13 @@ Use `openclaw fabrica setup --agent <id>` if you already have an agent. GitHub,
117
121
  Telegram, and webhook behavior are separate operational concerns, not
118
122
  installation dependencies.
119
123
 
124
+ **Environment provisioning note**:
125
+
126
+ Developer and tester pickup now pass through a stack environment gate. For
127
+ supported stacks such as `python-cli`, Fabrica provisions the required toolchain
128
+ and project-local environment before dispatching workers, instead of discovering
129
+ missing dependencies inside a live worker run.
130
+
120
131
  **4. Restart the gateway**:
121
132
 
122
133
  ```bash
@@ -244,6 +255,11 @@ Telegram enables DM-based project bootstrap, per-project forum topics, and a sep
244
255
 
245
256
  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.
246
257
 
258
+ Project topics are event-driven timelines. Fabrica emits explicit messages for
259
+ worker start, worker completion, review queueing, reviewer reject/approve, and
260
+ operational recovery events, with cycle-aware dedupe so late deliveries from an
261
+ older dispatch do not masquerade as current work.
262
+
247
263
  ## Programmatic genesis
248
264
 
249
265
  In addition to Telegram DM bootstrap, the full pipeline can be triggered from a CLI script — no Telegram or running agent session required:
@@ -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
@@ -48,7 +58,7 @@ What exists today? Current limitations? Relevant code paths.
48
58
 
49
59
  ## MANDATORY: Create ONE Implementation Task
50
60
 
51
- After posting your findings, you MUST create **exactly one comprehensive implementation task** for the recommended approach before calling work_finish.
61
+ After posting your findings, you MUST create **exactly one comprehensive implementation task** for the recommended approach before ending with your final architecture result line.
52
62
 
53
63
  **⚠️ CRITICAL: Always create ONE task, never multiple.** Do not split work into separate issues. A single developer will pick up the task and work through the checklist. This keeps scope clear, reduces issue noise, and makes tracking easy.
54
64
 
@@ -101,22 +111,16 @@ Brief summary of what needs to be implemented and why.
101
111
  - `description`: use the format above — detailed enough for a developer to start immediately
102
112
 
103
113
  2. Collect the returned issue `id`, `title`, and `url` from the `task_create` response
104
- 3. Pass the created task to `work_finish` in the `createdTasks` array this makes it show up as a clickable link in the notification
114
+ 3. Mention the created task number and URL in your final prose before the result line so the operator can see what was created
105
115
 
106
116
  **Example:**
107
117
  ```
108
118
  task_create({ projectSlug: "<project slug from the 'Channel:' line in the task message>", title: "Implement SQLite session persistence", description: "From research #42\n\n## Overview\nReplace in-memory Map with SQLite...\n\n## Implementation Checklist\n\n### Phase 1: Schema & Migration (~1 day)\n- [ ] Create sessions table schema in db/schema.sql\n- [ ] Add migration logic in db/migrate.ts\n..." })
109
119
  // → returns issue id: 43, url: "https://github.com/.../43"
110
120
 
111
- work_finish({
112
- role: "architect",
113
- result: "done",
114
- channelId: "my-app",
115
- summary: "Recommended SQLite approach. Created task #43.",
116
- createdTasks: [
117
- { id: 43, title: "Implement SQLite session persistence", url: "https://github.com/.../43" }
118
- ]
119
- })
121
+ Recommended SQLite approach. Created implementation task #43:
122
+ https://github.com/.../43
123
+ Architecture result: DONE
120
124
  ```
121
125
 
122
126
  The task is created in Planning state — the operator reviews and moves it to the queue when ready.
@@ -128,16 +132,18 @@ The task is created in Planning state — the operator reviews and moves it to t
128
132
  ## Important
129
133
 
130
134
  - **Be thorough** — Your output becomes the spec for development. Missing detail = blocked developer.
131
- - **If you need user input** — Call work_finish with result "blocked" and explain what you need. Do NOT guess on ambiguous requirements.
135
+ - **If you need user input** — End with `Architecture result: BLOCKED` and explain what you need. Do NOT guess on ambiguous requirements.
132
136
  - **Post findings as issue comments** — Use task_comment to write your analysis on the issue.
133
- - **Always create a task** — Do not call work_finish(done) without first creating an implementation task via task_create.
137
+ - **Always create a task** — Do not end with `Architecture result: DONE` without first creating an implementation task via task_create.
134
138
 
135
139
  ## Completing Your Task
136
140
 
137
- When you are done, **call `work_finish` yourself** do not just announce in text.
141
+ When you are done, end your response with exactly one final result line in plain text:
142
+
143
+ - `Architecture result: DONE`
144
+ - `Architecture result: BLOCKED`
138
145
 
139
- - **Done:** `work_finish({ role: "architect", result: "done", channelId: "<project slug from the 'Channel:' line in the task message>", summary: "<recommendation + created task numbers>", createdTasks: [{ id, title, url }] })`
140
- - **Blocked:** `work_finish({ role: "architect", result: "blocked", channelId: "<project slug from the 'Channel:' line in the task message>", summary: "<what you need>" })`
146
+ Write any recommendation summary and created task references before that final line.
141
147
 
142
148
  The project slug is included on the `Channel:` line in your task message. Your session is persistent — you may be called back for refinements.
143
149
 
@@ -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
 
@@ -110,7 +121,7 @@ When your task message includes a **PR Feedback** section, it means a reviewer r
110
121
  ```
111
122
  4. Address **only** the reviewer's comments — do not re-implement the original issue from scratch
112
123
  5. Commit and push to the **same branch** — the existing PR updates automatically
113
- 6. Call `work_finish` as usual
124
+ 6. End your response with the canonical developer result line described below
114
125
 
115
126
  ### QA Evidence (MANDATORY)
116
127
 
@@ -132,19 +143,16 @@ gh pr edit "$PR_NUM" --body "$(printf '%s\n\n## QA Evidence\n\n```\n%s\n```\n\nE
132
143
 
133
144
  **Do NOT post QA evidence only as a comment.** PR comments are not canonical QA evidence; the reviewer and the workflow both validate the PR description body.
134
145
 
135
- ### 5. Call work_finish (API tool NOT a shell command)
146
+ ### 5. End with the canonical result line
136
147
 
137
- `work_finish` is a **Fabrica API tool**. You must invoke it as a **tool call** (tool_use), the same way you call any other tool like `task_create` or `gh`. Do **NOT** run it as a bash command — it is not on your PATH, and attempting to execute it in a shell will fail with "command not found".
148
+ After you finish the implementation work, end your response with exactly one final result line in plain text:
138
149
 
139
- Use the `work_finish` tool with these arguments:
140
- - `role`: `"developer"`
141
- - `result`: `"done"` (or `"blocked"` if stuck)
142
- - `channelId`: the project slug from the `"Project: <name>"` line in your task message (e.g., `"gestao-notas"`)
143
- - `summary`: brief description of what you did
150
+ - `Work result: DONE`
151
+ - `Work result: BLOCKED`
144
152
 
145
- **If blocked:** call `work_finish` with `result: "blocked"` and explain why in `summary`.
153
+ Use `Work result: BLOCKED` if you hit an external blocker, ambiguity, or missing dependency that prevents completion.
146
154
 
147
- **Always call work_finish** even if you hit errors or can't complete the task.
155
+ Do **not** rely on tool availability to conclude the task. Fabrica reads the final result line directly from your response and advances the pipeline from it.
148
156
 
149
157
  ## Security Checklist (MANDATORY before commit)
150
158
 
@@ -182,9 +190,9 @@ Choose the pattern appropriate to your stack:
182
190
  These are orchestrator-only tools. Do not call them:
183
191
  - `task_start`, `tasks_status`, `health`, `project_register`
184
192
 
185
- ## Anti-Pattern Checklist (MANDATORY before work_finish)
193
+ ## Anti-Pattern Checklist (MANDATORY before declaring done)
186
194
 
187
- Before calling `work_finish(done)`, verify ALL of these:
195
+ Before ending with `Work result: DONE`, verify ALL of these:
188
196
 
189
197
  ### Code Quality
190
198
  - [ ] Every function has a descriptive name (no `data`, `temp`, `result`, `handle`)
@@ -196,7 +204,7 @@ Before calling `work_finish(done)`, verify ALL of these:
196
204
 
197
205
  ### QA Contract
198
206
  - [ ] Run `scripts/qa.sh` and verify ALL 5 gates pass (lint, types, security, tests, coverage)
199
- - [ ] If qa.sh fails, FIX the issue — do NOT call work_finish with failing gates
207
+ - [ ] If qa.sh fails, FIX the issue — do NOT declare done with failing gates
200
208
  - [ ] Coverage meets or exceeds the threshold in qa.sh (default: 80%)
201
209
 
202
210
  ### Git Hygiene
@@ -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
  ```
@@ -122,17 +140,23 @@ Use `task_comment` to post your findings in this format:
122
140
  <brief summary>
123
141
  ```
124
142
 
125
- ### 6. Call work_finish
143
+ ### 6. End with the canonical result line
144
+
145
+ After posting the QA report, end your response with exactly one final result line in plain text:
146
+
147
+ - `Test result: PASS`
148
+ - `Test result: FAIL`
149
+ - `Test result: FAIL_INFRA`
150
+ - `Test result: REFINE`
151
+ - `Test result: BLOCKED`
126
152
 
127
- - **Pass:** `work_finish({ role: "tester", result: "pass", channelId: "<project slug from the 'Channel:' line in the task message>", summary: "<brief summary>" })`
128
- - **Fail:** `work_finish({ role: "tester", result: "fail", channelId: "<project slug from the 'Channel:' line in the task message>", summary: "<specific failures>" })`
129
- - **Fail Infra:** `work_finish({ role: "tester", result: "fail_infra", channelId: "<project slug from the 'Channel:' line in the task message>", summary: "<toolchain or environment failure that prevented QA>" })`
130
- - **Refine:** `work_finish({ role: "tester", result: "refine", channelId: "<project slug from the 'Channel:' line in the task message>", summary: "<what needs human input>" })`
131
- - **Blocked:** `work_finish({ role: "tester", result: "blocked", channelId: "<project slug from the 'Channel:' line in the task message>", summary: "<what you need>" })`
153
+ Use:
154
+ - `FAIL` when the implementation is wrong or acceptance criteria fail.
155
+ - `FAIL_INFRA` when the toolchain or environment prevented valid QA execution.
156
+ - `REFINE` when human clarification or non-code product refinement is required before testing can conclude.
157
+ - `BLOCKED` when you cannot proceed for another reason.
132
158
 
133
- > **IMPORTANT:** The `channelId` parameter accepts the project slug (e.g., "gestao-notas").
134
- > Extract it from the "Channel: <slug>" line in your task message. Do NOT use the numeric
135
- > channel ID — use the project slug to avoid resolution errors when channels are shared.
159
+ Do **not** rely on tool availability to conclude the task. Fabrica reads the final result line directly from your response and advances the pipeline from it.
136
160
 
137
161
  ## Conventions
138
162