forgeo-cli 0.7.1__tar.gz → 0.7.2__tar.gz
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.
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/CHANGELOG.md +18 -1
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/PKG-INFO +1 -1
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/agent-contract.md +6 -3
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/configuration.md +23 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/install.sh +1 -1
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/pyproject.toml +1 -1
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/__init__.py +1 -1
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/forgeo.py +79 -32
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/models.py +6 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/web/central/central.js +1 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_factory.py +57 -7
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_install.py +1 -1
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_models.py +5 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_runs.py +5 -5
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_web.py +1 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/.github/workflows/ci.yml +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/.gitignore +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/CONTRIBUTING.md +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/LICENSE +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/README.md +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/config/nginx-forgeo.conf +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/backlog.md +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/cli-reference.md +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/getting-started.md +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/img/console.png +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/img/demo.gif +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/img/logo.png +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/img/og.png +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/img/title.svg +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/index.md +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/docs/web-console-api.md +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/forgeo.spec +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/mkdocs.yml +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/scripts/__init__.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/scripts/render_homebrew_formula.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/__main__.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/agent.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/backlog.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/backlog_http.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/central.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/cli.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/config.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/daemon.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/daemon_control.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/git.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/instances.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/io.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/notify.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/oauth.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/paths.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/runs.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/setup.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/update.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/validate.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/web/central/central.css +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/web/central/index.html +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/web/central/instance.html +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/web/central/login.html +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/web/style.css +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/src/forgeo/web_common.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/conftest.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_agent.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_backlog.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_backlog_http.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_cli.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_daemon.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_git.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_instances.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_io.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_oauth.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_paths.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_remote_backlog_cycle.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_render_homebrew.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_setup.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_update.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_web_common.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/tests/test_web_lock.py +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/www/404.html +0 -0
- {forgeo_cli-0.7.1 → forgeo_cli-0.7.2}/www/index.html +0 -0
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.2] - 2026-08-18
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `no_changes_retry_max` config key: a task whose agent exits `0` without
|
|
15
|
+
producing any code changes is re-run immediately, in the same cycle, up to
|
|
16
|
+
that many extra times before it is marked `BLOCKED` for human review.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- A silent no-change SUCCESS (agent exits `0` with an unchanged working tree)
|
|
21
|
+
now marks the task `BLOCKED` instead of `FAILED`: the only acceptable
|
|
22
|
+
outcome for a run that ends without code changes is a blocked task awaiting
|
|
23
|
+
human review. An agent that needs no code change must still opt in
|
|
24
|
+
explicitly with `no_changes_exit_code` to complete the task.
|
|
25
|
+
|
|
10
26
|
## [0.7.1] - 2026-08-17
|
|
11
27
|
|
|
12
28
|
### Added
|
|
@@ -321,7 +337,8 @@ Initial release of the scheduled, agent-driven software forgeo.
|
|
|
321
337
|
overlapping-run skipping.
|
|
322
338
|
- Dogfooding docs removed; local configs kept out of the repository.
|
|
323
339
|
|
|
324
|
-
[Unreleased]: https://github.com/lucaGazzola/forgeo/compare/v0.7.
|
|
340
|
+
[Unreleased]: https://github.com/lucaGazzola/forgeo/compare/v0.7.2...HEAD
|
|
341
|
+
[0.7.2]: https://github.com/lucaGazzola/forgeo/compare/v0.7.1...v0.7.2
|
|
325
342
|
[0.7.1]: https://github.com/lucaGazzola/forgeo/compare/v0.7.0...v0.7.1
|
|
326
343
|
[0.7.0]: https://github.com/lucaGazzola/forgeo/compare/v0.6.0...v0.7.0
|
|
327
344
|
[0.6.0]: https://github.com/lucaGazzola/forgeo/compare/v0.5.0...v0.6.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: forgeo-cli
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: A scheduled software forgeo: executes backlog tasks on main, refactors when idle, and writes BLOCKER.md when it needs human input.
|
|
5
5
|
Project-URL: Homepage, https://forgeo.org
|
|
6
6
|
Project-URL: Documentation, https://forgeo.org
|
|
@@ -69,8 +69,11 @@ Forgeo cannot tell "the agent deliberately made no changes" from "the agent
|
|
|
69
69
|
did nothing". A `SUCCESS` exit that produces **no changes is therefore not a
|
|
70
70
|
valid completion for a task**:
|
|
71
71
|
|
|
72
|
-
- exiting `0` while leaving the working tree **unchanged**
|
|
73
|
-
(`
|
|
72
|
+
- exiting `0` while leaving the working tree **unchanged** is retried
|
|
73
|
+
immediately (`no_changes_retry_max`, see [Configuration](configuration.md))
|
|
74
|
+
and, once that budget is spent, the task is marked `BLOCKED` — never
|
|
75
|
+
`FAILED` and never silently `COMPLETED`. The only acceptable outcome for a
|
|
76
|
+
run that ends without code changes is a blocked task awaiting human review;
|
|
74
77
|
- to complete a task **without touching the code**, exit
|
|
75
78
|
`no_changes_exit_code` (default `3`). The working tree must be clean — an
|
|
76
79
|
agent that reports "no changes" while leaving uncommitted work behind fails
|
|
@@ -121,7 +124,7 @@ that, based on the exit code. The working contract is:
|
|
|
121
124
|
- **do not** run `git add`, `git commit`, `git push`, or reset the tree;
|
|
122
125
|
- exit `0` to have your changes committed and pushed as one commit;
|
|
123
126
|
- exit `no_changes_exit_code` when the task needs no code change (never exit
|
|
124
|
-
`0` with an empty tree — that
|
|
127
|
+
`0` with an empty tree — that run is retried and then marked `BLOCKED`);
|
|
125
128
|
- exit `blocked_exit_code` to have partial work preserved and a blocker
|
|
126
129
|
written;
|
|
127
130
|
- exit anything else to have your changes discarded.
|
|
@@ -42,6 +42,7 @@ paths), so `forgeo restart` is still used for those.
|
|
|
42
42
|
| <span style="white-space: nowrap">`run_output_lines`</span> | `200` | How many agent output lines each run record keeps in `runs.jsonl` (the bounded tail of the agent's stdout/stderr). `0` disables persisting agent output. |
|
|
43
43
|
| <span style="white-space: nowrap">`failed_retry_max`</span> | `0` | How many times a `FAILED` task is retried automatically. `0` (default) = a `FAILED` task stays `FAILED` until a human reopens it, exactly as before. A task may override this budget per-task with `retries_left`. |
|
|
44
44
|
| <span style="white-space: nowrap">`failed_retry_wait_cycles`</span> | `1` | How many cycles a retry-eligible `FAILED` task waits (backoff) before it is moved back to `OPEN`. |
|
|
45
|
+
| <span style="white-space: nowrap">`no_changes_retry_max`</span> | `0` | How many times a task whose agent exits `0` without producing any code changes is re-run immediately, in the same cycle, before the task is marked `BLOCKED` for human review. `0` (default) = a silent no-change SUCCESS is marked `BLOCKED` on the first attempt. |
|
|
45
46
|
| <span style="white-space: nowrap">`git_timeout_seconds`</span> | `120` | Kill a git subprocess after this many seconds. |
|
|
46
47
|
| <span style="white-space: nowrap">`telegram_bot_token`</span> | — | Telegram bot token for blocked-run notifications (disabled unless `telegram_chat_id` is also set). |
|
|
47
48
|
| <span style="white-space: nowrap">`telegram_chat_id`</span> | — | Chat ID that receives blocked-run notifications (disabled unless `telegram_bot_token` is also set). |
|
|
@@ -254,6 +255,28 @@ failed_retry_max: 3 # retry each FAILED task up to 3 times
|
|
|
254
255
|
failed_retry_wait_cycles: 2 # back off 2 cycles before each retry
|
|
255
256
|
```
|
|
256
257
|
|
|
258
|
+
### `no_changes_retry_max`
|
|
259
|
+
|
|
260
|
+
An agent that exits `0` while leaving the working tree unchanged has not
|
|
261
|
+
completed the task — the engine cannot tell "deliberately did nothing" from
|
|
262
|
+
"did nothing". By default (`no_changes_retry_max: 0`) that run is marked
|
|
263
|
+
`BLOCKED` on the first attempt: the only acceptable outcome for a no-change
|
|
264
|
+
run is a blocked task awaiting human review, never a silent completion and
|
|
265
|
+
never a `FAILED` task.
|
|
266
|
+
|
|
267
|
+
Sometimes the agent needs a second chance (a flaky model, a transient context
|
|
268
|
+
issue). Set a positive `no_changes_retry_max` and Forgeo re-runs the agent
|
|
269
|
+
immediately, back-to-back in the **same cycle**, that many extra times; a run
|
|
270
|
+
that finally produces changes completes the task, and one that still produces
|
|
271
|
+
nothing after the budget is spent is marked `BLOCKED`.
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
no_changes_retry_max: 2 # re-run the agent up to 2 extra times on a silent no-change
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
`BLOCKED` tasks are never auto-retried — a human decides whether to reopen,
|
|
278
|
+
split, or drop the task (see [Backlog](backlog.md)).
|
|
279
|
+
|
|
257
280
|
### Telegram notifications
|
|
258
281
|
|
|
259
282
|
Both `telegram_bot_token` **and** `telegram_chat_id` must be set for blocked
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "forgeo-cli"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.2"
|
|
8
8
|
description = "A scheduled software forgeo: executes backlog tasks on main, refactors when idle, and writes BLOCKER.md when it needs human input."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -359,31 +359,54 @@ class Forgeo:
|
|
|
359
359
|
# ------------------------------------------------------------------ #
|
|
360
360
|
|
|
361
361
|
async def _run_task(self, task: Task) -> None:
|
|
362
|
-
"""Execute one task: agent run, then commit/push on the main branch.
|
|
362
|
+
"""Execute one task: agent run(s), then commit/push on the main branch.
|
|
363
|
+
|
|
364
|
+
A silent no-change SUCCESS (exit 0 with an empty tree) is re-run up to
|
|
365
|
+
``no_changes_retry_max`` more times in the same cycle; once the retry
|
|
366
|
+
budget is spent the task is marked ``BLOCKED`` for human review — the
|
|
367
|
+
only acceptable outcome for a task that ends without code changes.
|
|
368
|
+
"""
|
|
363
369
|
logger.info("Running task %s (%s)", task.id, task.title)
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
max_retries = self.config.no_changes_retry_max
|
|
371
|
+
for attempt in range(max_retries + 1):
|
|
372
|
+
self._last_run_reason = None
|
|
373
|
+
result, ok = await self._run_agent(
|
|
374
|
+
task,
|
|
375
|
+
instruction=task.instruction,
|
|
376
|
+
success_message=task.title,
|
|
377
|
+
blocked_message=f"{task.title} [partial]",
|
|
378
|
+
command=task.agent_command,
|
|
379
|
+
timeout_seconds=task.agent_timeout_seconds,
|
|
380
|
+
)
|
|
372
381
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
+
if result.status is ExecutionStatus.BLOCKED:
|
|
383
|
+
await self.backlog.set_blocked(task.id, result.reason)
|
|
384
|
+
return
|
|
385
|
+
if result.status is ExecutionStatus.ERROR:
|
|
386
|
+
await self._mark_failed(task, self._failure_reason(result))
|
|
387
|
+
return
|
|
388
|
+
if ok:
|
|
389
|
+
await self.backlog.update_status(task.id, TaskStatus.COMPLETED)
|
|
390
|
+
self.config.blocker_file.unlink(missing_ok=True)
|
|
391
|
+
self._notify_webhook("completed", task, "")
|
|
392
|
+
logger.info("Task %s completed.", task.id)
|
|
393
|
+
return
|
|
394
|
+
# Not ok: either the commit failed (the task is already marked
|
|
395
|
+
# FAILED inside _handle_execution_result) or the agent exited 0
|
|
396
|
+
# without producing changes (only the reason distinguishes them).
|
|
397
|
+
if self._last_run_reason != NO_CHANGES_REASON:
|
|
398
|
+
return
|
|
399
|
+
if attempt < max_retries:
|
|
400
|
+
logger.warning(
|
|
401
|
+
"Task %s exited 0 but produced no changes "
|
|
402
|
+
"(attempt %d/%d); retrying.",
|
|
403
|
+
task.id,
|
|
404
|
+
attempt + 1,
|
|
405
|
+
max_retries,
|
|
406
|
+
)
|
|
407
|
+
continue
|
|
408
|
+
await self._block_no_changes(task)
|
|
382
409
|
return
|
|
383
|
-
await self.backlog.update_status(task.id, TaskStatus.COMPLETED)
|
|
384
|
-
self.config.blocker_file.unlink(missing_ok=True)
|
|
385
|
-
self._notify_webhook("completed", task, "")
|
|
386
|
-
logger.info("Task %s completed.", task.id)
|
|
387
410
|
|
|
388
411
|
async def _run_agent(
|
|
389
412
|
self,
|
|
@@ -491,7 +514,10 @@ class Forgeo:
|
|
|
491
514
|
# Exited 0 but produced no changes: not a completion. The
|
|
492
515
|
# engine cannot tell "deliberately did nothing" from "did
|
|
493
516
|
# nothing", so the agent must opt into no-ops explicitly.
|
|
494
|
-
|
|
517
|
+
# The caller decides between an immediate re-run
|
|
518
|
+
# (``no_changes_retry_max``) and a BLOCKED outcome.
|
|
519
|
+
self._last_run_reason = NO_CHANGES_REASON
|
|
520
|
+
logger.warning("Task %s: %s.", task.id, NO_CHANGES_REASON)
|
|
495
521
|
return False
|
|
496
522
|
return ok
|
|
497
523
|
|
|
@@ -545,22 +571,43 @@ class Forgeo:
|
|
|
545
571
|
await self.backlog.set_failed(task.id, reason)
|
|
546
572
|
self._notify_webhook("failed", task, "\n".join(reason))
|
|
547
573
|
|
|
548
|
-
async def
|
|
549
|
-
"""
|
|
574
|
+
async def _block_no_changes(self, task: Task) -> None:
|
|
575
|
+
"""Mark a task whose agent exited 0 without producing any changes as
|
|
576
|
+
BLOCKED: the only acceptable outcome for a no-change run is a blocked
|
|
577
|
+
task awaiting human review.
|
|
550
578
|
|
|
551
579
|
A no-change SUCCESS is indistinguishable from an agent that simply did
|
|
552
|
-
nothing, so it is not a valid completion
|
|
553
|
-
|
|
554
|
-
|
|
580
|
+
nothing, so it is not a valid completion. After the retry budget is
|
|
581
|
+
spent the task is blocked (never FAILED), so the run record surfaces
|
|
582
|
+
the reason and the human decides whether to reopen, split, or drop the
|
|
583
|
+
task.
|
|
555
584
|
"""
|
|
556
585
|
self._last_run_reason = NO_CHANGES_REASON
|
|
557
586
|
logger.warning(
|
|
558
|
-
"Task %s
|
|
587
|
+
"Task %s: %s; marking BLOCKED.", task.id, NO_CHANGES_REASON
|
|
559
588
|
)
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
589
|
+
blocked = ExecutionResult(
|
|
590
|
+
status=ExecutionStatus.BLOCKED,
|
|
591
|
+
output_logs=(
|
|
592
|
+
self._last_agent_result.output_logs
|
|
593
|
+
if self._last_agent_result is not None
|
|
594
|
+
else []
|
|
595
|
+
),
|
|
596
|
+
questions=[NO_CHANGES_REASON],
|
|
597
|
+
exit_code=(
|
|
598
|
+
self._last_agent_result.exit_code
|
|
599
|
+
if self._last_agent_result is not None
|
|
600
|
+
else None
|
|
601
|
+
),
|
|
602
|
+
)
|
|
603
|
+
self._last_agent_result = blocked
|
|
604
|
+
await self.backlog.set_blocked(task.id, [NO_CHANGES_REASON])
|
|
605
|
+
entry = BlockerEntry(
|
|
606
|
+
task=task,
|
|
607
|
+
result=blocked,
|
|
608
|
+
instruction=task.instruction,
|
|
563
609
|
)
|
|
610
|
+
self._notify_blocked(entry)
|
|
564
611
|
|
|
565
612
|
async def _complete_without_changes(
|
|
566
613
|
self, task: Task, *, is_refactor: bool = False
|
|
@@ -415,6 +415,11 @@ class ForgeoConfig(BaseModel):
|
|
|
415
415
|
budget per-task with ``retries_left``.
|
|
416
416
|
failed_retry_wait_cycles: How many cycles a retry-eligible ``FAILED``
|
|
417
417
|
task waits (backoff) before it is moved back to ``OPEN``.
|
|
418
|
+
no_changes_retry_max: How many times a task whose agent exits ``0``
|
|
419
|
+
without producing any code changes is re-run immediately, in the
|
|
420
|
+
same cycle, before the task is marked ``BLOCKED`` for human
|
|
421
|
+
review. ``0`` (default) = a silent no-change SUCCESS is marked
|
|
422
|
+
``BLOCKED`` on the first attempt.
|
|
418
423
|
telegram_bot_token: Telegram bot token for blocked-run
|
|
419
424
|
notifications. Disabled unless ``telegram_chat_id`` is also set.
|
|
420
425
|
telegram_chat_id: Chat ID that receives blocked-run notifications.
|
|
@@ -453,6 +458,7 @@ class ForgeoConfig(BaseModel):
|
|
|
453
458
|
run_output_lines: int = Field(default=DEFAULT_RUN_OUTPUT_LINES, ge=0)
|
|
454
459
|
failed_retry_max: int = Field(default=0, ge=0)
|
|
455
460
|
failed_retry_wait_cycles: int = Field(default=1, ge=1)
|
|
461
|
+
no_changes_retry_max: int = Field(default=0, ge=0)
|
|
456
462
|
telegram_bot_token: str | None = None
|
|
457
463
|
telegram_chat_id: str | None = None
|
|
458
464
|
notify_webhook_url: str | None = None
|
|
@@ -1213,6 +1213,7 @@
|
|
|
1213
1213
|
{ key: "run_output_lines", label: "Run output lines", type: "number", min: 0, step: 1, hint: "How many agent output lines each run record keeps in runs.jsonl (bounded tail, shown in the History tab). 0 = don't persist agent output." },
|
|
1214
1214
|
{ key: "failed_retry_max", label: "Failed retry max", type: "number", min: 0, step: 1, hint: "How many times a FAILED task is retried automatically. 0 = disabled (a FAILED task stays FAILED until a human reopens it). A task can override this with its own retries_left." },
|
|
1215
1215
|
{ key: "failed_retry_wait_cycles", label: "Failed retry wait (cycles)", type: "number", min: 1, step: 1, hint: "How many cycles a FAILED task waits (backoff) before it is retried." },
|
|
1216
|
+
{ key: "no_changes_retry_max", label: "No-change retry max", type: "number", min: 0, step: 1, hint: "How many times a task whose agent exits 0 without producing any code changes is re-run immediately, in the same cycle, before it is marked BLOCKED for human review. 0 = block on the first attempt." },
|
|
1216
1217
|
{ key: "agent_sandbox", label: "Agent sandbox", type: "select", options: ["none", "docker"], hint: "none = run directly on the host; docker = run inside a container." },
|
|
1217
1218
|
{ key: "agent_sandbox_image", label: "Sandbox image", type: "text", optional: true, hint: "Container image used when agent_sandbox is docker. Required in that mode." },
|
|
1218
1219
|
{ key: "agent_sandbox_network", label: "Sandbox network", type: "text", hint: "Docker network for the sandboxed agent (--network). Default none = networking disabled." },
|
|
@@ -57,10 +57,10 @@ async def test_task_success_is_committed_on_main(git_repo, tmp_path):
|
|
|
57
57
|
assert "forgeo" not in git(git_repo, "branch")
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
async def
|
|
61
|
-
"""Exit 0 with an empty tree is not a valid completion:
|
|
62
|
-
a silent no-change SUCCESS can never quietly
|
|
63
|
-
SELF-033 was closed without any work)."""
|
|
60
|
+
async def test_task_success_without_changes_blocks_task(git_repo, tmp_path):
|
|
61
|
+
"""Exit 0 with an empty tree is not a valid completion: the task is
|
|
62
|
+
BLOCKED (needs a human), so a silent no-change SUCCESS can never quietly
|
|
63
|
+
close a task (regression: SELF-033 was closed without any work)."""
|
|
64
64
|
forgeo, agent, backlog = make_forgeo(git_repo, tmp_path)
|
|
65
65
|
await backlog.create_task(make_task())
|
|
66
66
|
agent.result = ExecutionResult(status=ExecutionStatus.SUCCESS)
|
|
@@ -69,12 +69,12 @@ async def test_task_success_without_changes_fails_task(git_repo, tmp_path):
|
|
|
69
69
|
|
|
70
70
|
assert outcome == "task"
|
|
71
71
|
task = await backlog.get_task("TASK-001")
|
|
72
|
-
assert task.status is TaskStatus.
|
|
73
|
-
assert task.
|
|
72
|
+
assert task.status is TaskStatus.BLOCKED
|
|
73
|
+
assert task.blocker_reason == [NO_CHANGES_REASON]
|
|
74
74
|
assert git(git_repo, "rev-list", "--count", "HEAD") == "1"
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
async def
|
|
77
|
+
async def test_no_changes_blocks_logs_warning(git_repo, tmp_path, caplog):
|
|
78
78
|
"""The no-change SUCCESS case is surfaced as a warning, never silent."""
|
|
79
79
|
forgeo, agent, backlog = make_forgeo(git_repo, tmp_path)
|
|
80
80
|
await backlog.create_task(make_task())
|
|
@@ -87,6 +87,52 @@ async def test_no_changes_failure_logs_warning(git_repo, tmp_path, caplog):
|
|
|
87
87
|
assert any("produced no changes" in r.message for r in caplog.records)
|
|
88
88
|
|
|
89
89
|
|
|
90
|
+
async def test_task_no_changes_is_retried_and_can_succeed(git_repo, tmp_path):
|
|
91
|
+
"""With no_changes_retry_max, a silent no-change SUCCESS re-runs the agent
|
|
92
|
+
in the same cycle; a later run that produces changes completes the task."""
|
|
93
|
+
forgeo, agent, backlog = make_forgeo(git_repo, tmp_path, no_changes_retry_max=2)
|
|
94
|
+
await backlog.create_task(make_task())
|
|
95
|
+
agent.result = ExecutionResult(status=ExecutionStatus.SUCCESS)
|
|
96
|
+
|
|
97
|
+
def produce_changes() -> None:
|
|
98
|
+
(git_repo / "app.py").write_text("def answer():\n return 7\n", encoding="utf-8")
|
|
99
|
+
|
|
100
|
+
calls = 0
|
|
101
|
+
|
|
102
|
+
def effect() -> None:
|
|
103
|
+
nonlocal calls
|
|
104
|
+
calls += 1
|
|
105
|
+
if calls >= 3:
|
|
106
|
+
produce_changes()
|
|
107
|
+
|
|
108
|
+
agent.effect = effect
|
|
109
|
+
|
|
110
|
+
outcome = await forgeo.run_cycle()
|
|
111
|
+
|
|
112
|
+
assert outcome == "task"
|
|
113
|
+
task = await backlog.get_task("TASK-001")
|
|
114
|
+
assert task.status is TaskStatus.COMPLETED
|
|
115
|
+
assert calls == 3
|
|
116
|
+
assert git(git_repo, "log", "-1", "--format=%s") == "Do the thing"
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
async def test_task_no_changes_retries_exhausted_blocks_task(git_repo, tmp_path):
|
|
120
|
+
"""Once the retry budget is spent, a silent no-change SUCCESS is marked
|
|
121
|
+
BLOCKED — never FAILED — so a human reviews the task."""
|
|
122
|
+
forgeo, agent, backlog = make_forgeo(git_repo, tmp_path, no_changes_retry_max=2)
|
|
123
|
+
await backlog.create_task(make_task())
|
|
124
|
+
agent.result = ExecutionResult(status=ExecutionStatus.SUCCESS)
|
|
125
|
+
|
|
126
|
+
outcome = await forgeo.run_cycle()
|
|
127
|
+
|
|
128
|
+
assert outcome == "task"
|
|
129
|
+
task = await backlog.get_task("TASK-001")
|
|
130
|
+
assert task.status is TaskStatus.BLOCKED
|
|
131
|
+
assert task.blocker_reason == [NO_CHANGES_REASON]
|
|
132
|
+
assert len(agent.calls) == 3
|
|
133
|
+
assert git(git_repo, "rev-list", "--count", "HEAD") == "1"
|
|
134
|
+
|
|
135
|
+
|
|
90
136
|
async def test_task_explicit_no_changes_completes_task(git_repo, tmp_path):
|
|
91
137
|
"""Exit no_changes_exit_code is the explicit no-op contract: the task is
|
|
92
138
|
COMPLETED without a commit, and the tree stays untouched."""
|
|
@@ -798,6 +844,10 @@ async def test_task_context_refreshed_each_run(git_repo, tmp_path):
|
|
|
798
844
|
context_file.write_text("Version one.\n", encoding="utf-8")
|
|
799
845
|
forgeo, agent, backlog = make_forgeo(git_repo, tmp_path, task_context=context_file)
|
|
800
846
|
await backlog.create_task(make_task())
|
|
847
|
+
agent.result = ExecutionResult(status=ExecutionStatus.SUCCESS)
|
|
848
|
+
agent.effect = lambda: (git_repo / "app.py").write_text(
|
|
849
|
+
"def answer():\n return 7\n", encoding="utf-8"
|
|
850
|
+
)
|
|
801
851
|
await forgeo.run_cycle()
|
|
802
852
|
context_file.write_text("Version two.\n", encoding="utf-8")
|
|
803
853
|
await backlog.create_task(make_task(id="TASK-002", description="Build it again."))
|
|
@@ -23,7 +23,7 @@ from pathlib import Path
|
|
|
23
23
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
24
24
|
INSTALL_SH = REPO_ROOT / "install.sh"
|
|
25
25
|
PYPI_PACKAGE = "forgeo-cli"
|
|
26
|
-
VERSION = "0.7.
|
|
26
|
+
VERSION = "0.7.2"
|
|
27
27
|
SH = shutil.which("sh")
|
|
28
28
|
assert SH, "sh must be available to run install.sh"
|
|
29
29
|
|
|
@@ -142,6 +142,7 @@ def test_config_defaults():
|
|
|
142
142
|
assert config.notify_webhook_events == ["blocked"]
|
|
143
143
|
assert config.failed_retry_max == 0
|
|
144
144
|
assert config.failed_retry_wait_cycles == 1
|
|
145
|
+
assert config.no_changes_retry_max == 0
|
|
145
146
|
|
|
146
147
|
|
|
147
148
|
def test_config_rejects_negative_retry_settings():
|
|
@@ -149,12 +150,16 @@ def test_config_rejects_negative_retry_settings():
|
|
|
149
150
|
ForgeoConfig(agent_command="x", failed_retry_max=-1)
|
|
150
151
|
with pytest.raises(ValidationError):
|
|
151
152
|
ForgeoConfig(agent_command="x", failed_retry_wait_cycles=0)
|
|
153
|
+
with pytest.raises(ValidationError):
|
|
154
|
+
ForgeoConfig(agent_command="x", no_changes_retry_max=-1)
|
|
152
155
|
|
|
153
156
|
|
|
154
157
|
def test_config_accepts_retry_settings():
|
|
155
158
|
config = ForgeoConfig(agent_command="x", failed_retry_max=3, failed_retry_wait_cycles=2)
|
|
156
159
|
assert config.failed_retry_max == 3
|
|
157
160
|
assert config.failed_retry_wait_cycles == 2
|
|
161
|
+
config = ForgeoConfig(agent_command="x", no_changes_retry_max=5)
|
|
162
|
+
assert config.no_changes_retry_max == 5
|
|
158
163
|
|
|
159
164
|
|
|
160
165
|
def test_config_rejects_unknown_webhook_events():
|
|
@@ -52,8 +52,8 @@ async def test_task_success_appends_run_record(git_repo, tmp_path):
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
async def test_task_success_without_changes_has_reason(git_repo, tmp_path):
|
|
55
|
-
"""A no-change SUCCESS is surfaced on the run record:
|
|
56
|
-
|
|
55
|
+
"""A no-change SUCCESS is surfaced on the run record: the run ends BLOCKED
|
|
56
|
+
(the only acceptable no-change outcome) with an explicit reason, never a
|
|
57
57
|
silent null commit_sha."""
|
|
58
58
|
forgeo, agent, backlog = make_forgeo(git_repo, tmp_path)
|
|
59
59
|
await backlog.create_task(make_task())
|
|
@@ -62,10 +62,10 @@ async def test_task_success_without_changes_has_reason(git_repo, tmp_path):
|
|
|
62
62
|
assert await forgeo.run_cycle() == "task"
|
|
63
63
|
|
|
64
64
|
record = read_lines(runs_path(forgeo.config))[0]
|
|
65
|
-
assert record["outcome"] == "
|
|
65
|
+
assert record["outcome"] == "BLOCKED"
|
|
66
66
|
assert record["commit_sha"] is None
|
|
67
67
|
assert record["reason"] == NO_CHANGES_REASON
|
|
68
|
-
assert (await backlog.get_task("TASK-001")).status is TaskStatus.
|
|
68
|
+
assert (await backlog.get_task("TASK-001")).status is TaskStatus.BLOCKED
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
async def test_explicit_no_changes_record_has_reason(git_repo, tmp_path):
|
|
@@ -386,7 +386,7 @@ async def test_corrupt_runs_never_break_a_cycle(git_repo, tmp_path, caplog):
|
|
|
386
386
|
|
|
387
387
|
records = RunRecorder(runs).read()
|
|
388
388
|
assert len(records) == 1
|
|
389
|
-
assert records[0].outcome is RunOutcome.
|
|
389
|
+
assert records[0].outcome is RunOutcome.BLOCKED
|
|
390
390
|
assert records[0].task_id == "TASK-001"
|
|
391
391
|
|
|
392
392
|
|
|
@@ -1524,6 +1524,7 @@ def test_retry_config_fields_editable_in_config_tab(web_env):
|
|
|
1524
1524
|
assert status == 200
|
|
1525
1525
|
assert "failed_retry_max" in body
|
|
1526
1526
|
assert "failed_retry_wait_cycles" in body
|
|
1527
|
+
assert "no_changes_retry_max" in body
|
|
1527
1528
|
|
|
1528
1529
|
|
|
1529
1530
|
def test_tasks_endpoint_surfaces_run_at(registry, central_server):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|