These docs never existed — gardener and review-pr referenced them
as if they did. AGENTS.md tree is now the single architecture
reference for all agents.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Explains how to seed the AGENTS.md tree with watermarks before the
first planner run to avoid the first-run flood. Also adds planner
to cron schedule and lifecycle diagram.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove STATE_FILE variable and all STATE.md references from phase 2
- Restore matrix_send for gap analysis issue creation
- Replace broad `git add -A "*.md"` with targeted `find -name AGENTS.md`
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 1 rewritten:
- Claude gets --dangerously-skip-permissions to navigate code, read
diffs, and update AGENTS.md files directly
- Per-file <!-- last-reviewed: SHA --> watermarks replace global marker
- Sub-directory AGENTS.md files discovered and updated independently
- ~200 line convention enforced via prompt
- Changes committed on branch and PR'd
Phase 2 now reads AGENTS.md tree + STATE.md for gap analysis.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
STATE.md was a machine-generated system description that was always
worse than the human-curated AGENTS.md. Killed STATE.md entirely.
Phase 1: Reviews recent git history against AGENTS.md, suggests
updates via PR to keep the file tree, conventions, and architecture
descriptions current.
Phase 2: Gap analysis — compares AGENTS.md + VISION.md + open issues,
creates backlog issues for missing capabilities.
Add unconditional worktree cleanup to factory supervisor:
- Remove review + dev worktrees older than 2h with no active agent
- Use git worktree remove --force instead of rm -rf
- Run git worktree prune every poll to clear dangling refs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Feeds AGENTS.md, PRODUCT-TRUTH.md, ARCHITECTURE.md, UX-DECISIONS.md
into the prompt so the planner understands the system at a conceptual
level. Rewritten prompt emphasizes describing the system, not the
changes. Good/bad examples guide output style.
do_merge() is defined at line 876, but recovery mode calls it at
line ~498. Bash requires functions to be defined before use.
Inlined the merge→rebase→re-approve→retry logic directly.
1. Recovery mode: if PR already has approval + green CI, try merge
immediately instead of entering the review wait loop forever.
2. do_merge: on 405/merge failure, rebase → force push → wait CI →
re-approve via review_bot → retry merge. Covers the stale-approval
dismissal problem end-to-end.
3. Codeberg mergeable field is unreliable — rebase on any merge failure.
Sonnet sometimes narrates what it did instead of outputting the actual
STATE.md. Added validation that first line starts with '- ' and
strengthened the output-only instruction.
set -o pipefail causes head -1 to fail the pipeline when git log
is still producing output. The || fallback then appends a second
line. Fix: capture first SHA separately with || true.
Codeberg's mergeable field flickers between true/false — unreliable
for deciding whether to rebase. Just attempt rebase on any non-200/204.
Worst case it's a no-op. Also added git fetch before rebase.
- Remove write_state_entry/append_state_log from dev-agent (#10)
- Add planner-agent.sh: rebuilds STATE.md from git history + closed
issues, then gap-analyses against VISION.md to create backlog
issues (#6, #7)
- Add planner-poll.sh: cron wrapper with lock + memory guard
STATE.md is now solely owned by the planner — one compact snapshot
rebuilt each run, not an ever-growing append log.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When merge returns non-200, check mergeable flag. If false,
rebase the PR branch onto master via worktree. If rebase fails,
spawn dev-agent to resolve. Prevents infinite 405 retry loops.
Extracted try_merge_or_rebase() helper used at all 3 merge points.
pgrep matched all claude processes including manual screen sessions.
Narrow to "claude -p" so only non-interactive (factory-spawned) processes
get reaped by the stale-process cleanup.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dev-agent failed with exit 127 (command not found) because claude
is installed in ~/.local/bin which wasn't in the PATH set by env.sh.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add matrix_send() to lib/env.sh and matrix_listener.sh daemon for
real-time notifications, threaded escalations, and human-in-the-loop
replies. All agents now notify via Matrix instead of openclaw.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PRs #684 and #710 had no issue number in branch name or title.
Now also checks PR body for 'Closes #NNN'. If still no issue found,
logs a skip (dev-agent requires an issue number to work).
PRs with custom branch names (fix/fitness-factory-address,
chore/seed-consolidation) were invisible to priority 1.5.
Now also extracts issue number from PR title (#NNN) as fallback.
Function was defined at line 867 but called at line 550. Bash requires
functions to be defined before invocation. Moved to top with other
helpers. Also removed duplicate definition.
Claude was silently skipping ambiguous issues instead of escalating.
Made output format mandatory and explicit: every issue in the list
must result in ACTION (promoted) or ESCALATE (needs decision).
1. PRIORITY 1.5 in dev-poll: scan ALL open PRs for REQUEST_CHANGES or CI
failure before picking new backlog issues. Stuck PRs get fixed first
to avoid complex rebases piling up.
2. STATE.md written in worktree before claude starts (included in first
commit, not a separate push that dismisses stale approvals).
3. Removed HTTP 405 from merge success check in dev-poll.sh (was fixed
in dev-agent.sh but not here — 2 occurrences).
codeberg_api is a bash function in the gardener script's own process,
not available to claude-p's tool execution environment. Claude was
silently failing to call it and returning CLEAN.
Switch to curl commands with $CODEBERG_TOKEN env var that claude-p
can actually execute via its bash tool.
Tech-debt→backlog promotion was only in prompt text, not in the
problem list. Claude focused on detected problems (dupes, thin issues)
and printed CLEAN, ignoring the primary mission.
Fix: explicitly list up to 10 tech-debt issues in the problem list
so claude sees them as actionable items.
Also bumped --max-turns from 10 to 30 — promoting issues requires
reading + editing + relabeling via API, needs more turns.
When PR has merge conflicts (mergeable=false), attempt git rebase
before merge. If rebase fails, abort and escalate via notify.
Flow: approval → check mergeable → rebase if needed → wait CI → merge
Resolves the serial seed PR bottleneck where append-only files
(manifest.jsonl) create trivial conflicts that block the pipeline.
Root cause: Two bugs combined to silently close PRs without merging.
1. HTTP 405 ('not allowed to merge') was in the success condition
alongside 200/204. Codeberg returns 405 when branch protection
blocks the merge (e.g., stale approvals).
2. append_state_log pushed a new commit AFTER review_bot approved,
but BEFORE the merge attempt. With dismiss_stale_approvals=true,
the new commit automatically dismissed the approval → 405.
Impact: 6 PRs (#683, #688, #692, #695, #696, #699) were 'merged'
(logged as success, branch deleted, issue closed) but never actually
merged into master. All work was lost.
Fixes:
- Remove 405 from merge success check
- Move STATE.md append out of pre-merge path
The merged-PR search was over-engineered and caused false negatives
(couldn't match PR to issue when title/body didn't contain #NNN).
Issue closed = dep satisfied. Factory only closes after merging.
Codeberg uses shared issue/PR numbering. When a PR IS the dep issue
(e.g. PR #665 fixes issue #665), the title search misses it.
Fallback checks if pulls/{dep_num} is merged.
Moved from dark-factory to harb. Dev-agent appends one line to
STATE.md on the PR branch right before merge — goes through
review like any other change.
After each successful PR merge, dev-agent appends one line to
STATE.md: - [date] what now exists (#PR)
Lives in dark-factory repo (harb master is protected).
Planner will collapse this into a compact snapshot later.