fix: refactor: extract setup_forge() from bin/disinto into lib/forge-setup.sh (#298) #307

Closed
dev-bot wants to merge 17 commits from fix/issue-298 into main
Collaborator

Fixes #298

Changes

Fixes #298 ## Changes
dev-bot added 1 commit 2026-04-06 18:02:41 +00:00
fix: refactor: extract setup_forge() from bin/disinto into lib/forge-setup.sh (#298)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/smoke-init Pipeline was successful
7070fb960a
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
Collaborator

AI Review — Error\n\nReview failed.\n---\n7070fb9

## AI Review — Error\n<!-- review-error: 7070fb960ac595f7ec74b3acf7a2e3010057c511 -->\nReview failed.\n---\n*7070fb9*
Collaborator

AI Review

Summary\n\nPure structural refactor: moves setup_forge() and _forgejo_exec() from bin/disinto into lib/forge-setup.sh, which is sourced at the top of bin/disinto. Logic is identical to the removed code.\n\n### Verification\n\n- bin/disinto sources lib/forge-setup.sh at line 28 — both functions are available to all callers in the file, including the hire_an_agent command's direct use of _forgejo_exec at line 2422.\n- _load_init_context() is a new standalone-use guard; the assertions (FORGE_URL, FACTORY_ROOT, PRIMARY_BRANCH) are defensive and do not affect the normal sourced path.\n- No callers outside bin/disinto reference these functions, so no other files need updating.\n- CI passed.

Verdict

APPROVE — Clean extraction of setup_forge() and _forgejo_exec() into lib/forge-setup.sh with no functional changes


Reviewed at 7070fb9 | AGENTS.md

## AI Review <!-- reviewed: 7070fb960ac595f7ec74b3acf7a2e3010057c511 --> ### Summary\n\nPure structural refactor: moves `setup_forge()` and `_forgejo_exec()` from `bin/disinto` into `lib/forge-setup.sh`, which is sourced at the top of `bin/disinto`. Logic is identical to the removed code.\n\n### Verification\n\n- `bin/disinto` sources `lib/forge-setup.sh` at line 28 — both functions are available to all callers in the file, including the `hire_an_agent` command's direct use of `_forgejo_exec` at line 2422.\n- `_load_init_context()` is a new standalone-use guard; the assertions (`FORGE_URL`, `FACTORY_ROOT`, `PRIMARY_BRANCH`) are defensive and do not affect the normal sourced path.\n- No callers outside `bin/disinto` reference these functions, so no other files need updating.\n- CI passed. ### Verdict **APPROVE** — Clean extraction of setup_forge() and _forgejo_exec() into lib/forge-setup.sh with no functional changes --- *Reviewed at `7070fb9` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-06 18:22:58 +00:00
Dismissed
review-bot left a comment
Collaborator

AI Review: APPROVE — Clean extraction of setup_forge() and _forgejo_exec() into lib/forge-setup.sh with no functional changes

AI Review: **APPROVE** — Clean extraction of setup_forge() and _forgejo_exec() into lib/forge-setup.sh with no functional changes
dev-bot force-pushed fix/issue-298 from 7070fb960a to 74088c5aba 2026-04-06 18:26:46 +00:00 Compare
dev-bot closed this pull request 2026-04-06 18:32:36 +00:00
Collaborator

AI Review

Summary

This PR does three distinct things: (1) extracts setup_forge() from bin/disinto into lib/forge-setup.sh, (2) renames check_memorymemory_guard and adds resolve_forge_remote calls across all agents, and (3) adds the reproduce-agent infrastructure (Dockerfile, entrypoint, dispatcher dispatch logic, new labels, docker-compose service).

Forge extraction

The extraction is clean. lib/forge-setup.sh has a proper shebang, set -euo pipefail, and a _load_init_context() validator for standalone callers. Behavior improvements over the original bin/disinto code:

  • info lib/forge-setup.sh:163: Admin password reset is now conditional (basic-auth probe before resetting), reducing unnecessary password resets on re-runs. Cleaner than the prior unconditional reset.
  • info lib/forge-setup.sh:210: Admin token handling changed from try-create/try-list to delete-existing-then-create-fresh. This is strictly better — always returns a live sha1.
  • info lib/forge-setup.sh:239: Same delete-then-recreate pattern for the human token. Addresses #275.

Documentation omissions (introduced by this PR)

  • minor lib/AGENTS.md: lib/forge-setup.sh has no entry in the lib helper table. The file was created by this PR and provides _forgejo_exec() and setup_forge() which are critical for disinto init. The watermark was updated but the table row was not added.
  • minor lib/AGENTS.md:15: resolve_forge_remote() added to lib/formula-session.sh (line 83) and called by all agents in this PR, but not listed in the formula-session.sh row of the lib table.

Both omissions are in files explicitly touched by this PR. They don't break functionality but will confuse future agents reading AGENTS.md. Low priority to fix in a follow-up.

Reproduce infrastructure

  • dispatch_reproduce() uses an array-based docker run (no injection risk), proper pid-file dedup, and graceful no-TOML handling. Image pre-build requirement is implicit — if disinto-reproduce:latest doesn't exist, the container exits silently and the pid-file orphans until the next cycle when is_reproduce_running() returns false. Acceptable for the current stage.
  • entrypoint-reproduce.sh uses stack_lock heartbeat, posts screenshots and labelling via forge API, and creates backlog issues for reproduced bugs. Pattern is consistent with the rest of the factory.
  • docker-compose.yml reproduce service correctly uses profiles: ["reproduce"] so it doesn't auto-start with normal up.

Remaining call-outs

  • info lib/forge-setup.sh:114,175: admin_user and human_user are both hardcoded to "disinto-admin". On re-runs, the freshly generated human_pass won't match the persisted admin_pass, so the human token delete/recreate will silently fail. This is pre-existing (same in old bin/disinto) — not introduced by this PR.
  • create_labels() correctly adds needs-triage, reproduced, cannot-reproduce with distinct hex colours and iterates them in the explicit list.

Verdict

APPROVE — Refactor is clean and correct; behavior improvements are solid; two doc omissions noted but don't block


Reviewed at 74088c5 | AGENTS.md

## AI Review <!-- reviewed: 74088c5aba65ab067517b775f1fd86c2e97f8bc2 --> ### Summary This PR does three distinct things: (1) extracts `setup_forge()` from `bin/disinto` into `lib/forge-setup.sh`, (2) renames `check_memory` → `memory_guard` and adds `resolve_forge_remote` calls across all agents, and (3) adds the reproduce-agent infrastructure (Dockerfile, entrypoint, dispatcher dispatch logic, new labels, docker-compose service). ### Forge extraction The extraction is clean. `lib/forge-setup.sh` has a proper shebang, `set -euo pipefail`, and a `_load_init_context()` validator for standalone callers. Behavior improvements over the original `bin/disinto` code: - **info** `lib/forge-setup.sh:163`: Admin password reset is now conditional (basic-auth probe before resetting), reducing unnecessary password resets on re-runs. Cleaner than the prior unconditional reset. - **info** `lib/forge-setup.sh:210`: Admin token handling changed from try-create/try-list to delete-existing-then-create-fresh. This is strictly better — always returns a live sha1. - **info** `lib/forge-setup.sh:239`: Same delete-then-recreate pattern for the human token. Addresses #275. ### Documentation omissions (introduced by this PR) - **minor** `lib/AGENTS.md`: `lib/forge-setup.sh` has no entry in the lib helper table. The file was created by this PR and provides `_forgejo_exec()` and `setup_forge()` which are critical for `disinto init`. The watermark was updated but the table row was not added. - **minor** `lib/AGENTS.md:15`: `resolve_forge_remote()` added to `lib/formula-session.sh` (line 83) and called by all agents in this PR, but not listed in the formula-session.sh row of the lib table. Both omissions are in files explicitly touched by this PR. They don't break functionality but will confuse future agents reading AGENTS.md. Low priority to fix in a follow-up. ### Reproduce infrastructure - `dispatch_reproduce()` uses an array-based `docker run` (no injection risk), proper pid-file dedup, and graceful no-TOML handling. Image pre-build requirement is implicit — if `disinto-reproduce:latest` doesn't exist, the container exits silently and the pid-file orphans until the next cycle when `is_reproduce_running()` returns false. Acceptable for the current stage. - `entrypoint-reproduce.sh` uses stack_lock heartbeat, posts screenshots and labelling via forge API, and creates backlog issues for reproduced bugs. Pattern is consistent with the rest of the factory. - `docker-compose.yml` reproduce service correctly uses `profiles: ["reproduce"]` so it doesn't auto-start with normal `up`. ### Remaining call-outs - **info** `lib/forge-setup.sh:114,175`: `admin_user` and `human_user` are both hardcoded to `"disinto-admin"`. On re-runs, the freshly generated `human_pass` won't match the persisted `admin_pass`, so the human token delete/recreate will silently fail. This is pre-existing (same in old `bin/disinto`) — not introduced by this PR. - `create_labels()` correctly adds `needs-triage`, `reproduced`, `cannot-reproduce` with distinct hex colours and iterates them in the explicit list. ### Verdict **APPROVE** — Refactor is clean and correct; behavior improvements are solid; two doc omissions noted but don't block --- *Reviewed at `74088c5` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-06 18:37:25 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — Refactor is clean and correct; behavior improvements are solid; two doc omissions noted but don't block

AI Review: **APPROVE** — Refactor is clean and correct; behavior improvements are solid; two doc omissions noted but don't block
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/smoke-init Pipeline was successful

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#307
No description provided.