Skip to content

Commit 53422e1

Browse files
authored
Merge pull request #13 from d3cker/codex/reconcile-resumed-sessions
Fix stalled workflows and integrate development on devel
2 parents 90bf913 + 061d19a commit 53422e1

25 files changed

Lines changed: 1117 additions & 261 deletions

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
pull_request:
5-
branches: [release]
5+
branches: [devel, release]
66
types: [opened, synchronize, reopened, ready_for_review, edited]
77

88
permissions:

‎.github/workflows/release.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ concurrency:
1818
jobs:
1919
release:
2020
name: Publish from release and open promotion PR
21-
if: github.event_name == 'push' || github.event.pull_request.merged == true
21+
if: github.event_name == 'push' || (github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'devel' && github.event.pull_request.head.repo.full_name == github.repository)
2222
runs-on: ubuntu-latest
2323
timeout-minutes: 25
2424
permissions:
@@ -37,7 +37,7 @@ jobs:
3737
cache: npm
3838
- name: Install pipeline dependencies
3939
run: npm ci --ignore-scripts
40-
- name: Prepare version, publish package, and promote through a PR
40+
- name: Publish, prepare main PR, and synchronize devel
4141
env:
4242
GH_TOKEN: ${{ github.token }}
4343
run: node scripts/release-pipeline.mjs

‎AGENTS.md‎

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Use English for all user-facing prompts, UI labels, errors, generated bot messag
44

55
Never push commits directly to `main` or modify its files through GitHub APIs.
66
All changes reach `main` by merging a PR from `release`. Feature PRs target
7-
`release`; version and post-publication README commits belong on `release`.
7+
`devel`. Only a reviewed `devel` → `release` PR starts automatic publication.
8+
Version and post-publication README commits belong on `release`; after a stable
9+
publication, automation merges that published head back into `devel` without a
10+
PR or force push. Never reset development work to match release.
811

912
## Project context
1013

@@ -28,7 +31,7 @@ steps, project setup, headless operation, and removal.
2831
| [docs/runtime.md](docs/runtime.md) | User-visible behavior while the bot runs: GitHub questions and permission replies, branch selection, media inputs, prompt loading, follow-up comments, session tabs, and routine management commands. | Use when changing issue conversations, session continuation, runtime tools, or TUI behavior. |
2932
| [docs/advanced.md](docs/advanced.md) | Separate scheduler/dispatcher setup, multiple repositories, custom RPC jobs, full options, timeouts, management and retry commands, persistence, reconciliation, locks, and known limits. | Use for low-level configuration, operational troubleshooting, recovery, or ownership/concurrency changes. |
3033
| [docs/installation.md](docs/installation.md) | Loader registration, config-directory precedence, prerequisites, source installation, project-local installation, upgrade conflicts, testing on another machine, and migration limits. | Use when working on packaging, installers, registration, upgrades, or deployment troubleshooting. |
31-
| [docs/releases.md](docs/releases.md) | Feature-to-release PR checks, automatic patch versions, manual npm version/tag releases, exact changelog notes, publication recovery, README commits on release, and promotion PRs into protected main. | Use for CI triggers, versioning, packaging, GitHub Release publication, branch permissions, or recovery after a failed release. |
34+
| [docs/releases.md](docs/releases.md) | Feature-to-devel and devel-to-release PR checks, automatic patch versions, manual npm version/tag releases, exact changelog notes, publication recovery, README commits on release, automatic release-to-devel synchronization, and promotion PRs into protected main. | Use for CI triggers, versioning, packaging, GitHub Release publication, branch permissions, or recovery after a failed release. |
3235

3336
For common investigations:
3437

@@ -71,17 +74,42 @@ the installation block without making remote writes. Keep its markers intact.
7174
installation. `examples/` contains configuration examples; `test/` contains
7275
automated tests. `package.json` defines build and validation commands.
7376

74-
## Keeping documentation accurate
77+
## Keeping documentation accurate — required for every change
7578

76-
Treat the implementation as the source of truth for current behavior. If code
77-
and documentation disagree, inspect the relevant code and tests and make the
78-
discrepancy explicit rather than assuming the documented behavior is implemented.
79-
When changing behavior, update the relevant reference page and any affected
80-
workflow diagrams. Keep the architecture page concise; put detailed execution
81-
paths in `docs/bot-workflow.md` and user-facing runtime guidance in `docs/runtime.md`.
79+
Documentation is part of the implementation, not a later cleanup task. **If a code
80+
change affects anything already described, update that description and every
81+
affected diagram in the same change and PR.** A change is not complete while its
82+
code and documentation disagree. Do not defer documentation to a later release,
83+
follow-up issue, or another agent.
8284

83-
Validate changed Mermaid diagrams with a Mermaid parser when available; checking
84-
Markdown fences alone does not validate diagram syntax. Avoid literal semicolons
85-
in sequence-diagram message labels because they can be parsed as statement
86-
separators. For documentation-only changes, check links and formatting; application
87-
tests are not needed unless executable behavior also changes.
85+
For every code, configuration, CLI/RPC, prompt, or workflow change:
86+
87+
1. Read the affected reference pages and compare their claims with the source and
88+
relevant tests. Use the documentation map above to find all entry points.
89+
2. Update affected behavior, defaults, commands, examples, prerequisites, limits,
90+
failure/retry paths, and recovery instructions. Check README and cross-linked
91+
pages as well as the primary reference; fixing only one mention is insufficient.
92+
3. For automation changes, review all eight sections of `docs/bot-workflow.md`
93+
for impact and update every affected Mermaid diagram and its surrounding text.
94+
Show actual ordering, phase/status transitions, durable checkpoints, questions,
95+
verification/publication gates, and restart paths. Do not draw desired behavior
96+
as if it were implemented. Keep architecture concise and detailed paths in the
97+
workflow/runtime references.
98+
4. Validate modified Mermaid with a parser, and check local links, headings,
99+
examples and Markdown formatting. Fences alone do not prove valid diagrams.
100+
Avoid literal semicolons in sequence-diagram messages. Report any validation
101+
that could not be run; do not claim it passed.
102+
5. Before finishing, review the complete diff for code/documentation agreement.
103+
In the PR description, identify the documentation updated, or state why the
104+
change has no documented or user-visible behavior impact. Add accurate
105+
`Unreleased` notes for changes that enter the next release.
106+
107+
Treat implementation and verified tests as evidence of current behavior. If an
108+
existing discrepancy is discovered, correct the affected documentation within the
109+
authorized scope and make any remaining mismatch explicit. Distinguish model
110+
instructions from enforced runtime behavior, and branch/unreleased features from
111+
features already present in a published package. Do not change an unrelated
112+
runtime behavior merely to make an old description true.
113+
114+
For documentation-only changes, check links, formatting and diagram syntax;
115+
application tests are not needed unless executable behavior also changes.

‎CHANGELOG.md‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,42 @@
11
# Changelog
22

33
Release descriptions come from the exact version section committed with the tag.
4-
Add feature changes under `Unreleased`; after a PR merges into `release`, automation
4+
Add feature changes under `Unreleased`; after a `devel` PR merges into `release`, automation
55
moves them into the new patch version's section. For a manual release, prepare
66
and commit the exact version section before creating its tag. Prerelease headings
77
include the full version, for example `## 0.7.0-beta.1`.
88

99
## Unreleased
1010

11+
### Documentation
12+
13+
- Align all eight bot workflow diagrams and runtime/recovery references with the
14+
implementation, including owner lifecycle, feedback queuing, session recovery,
15+
verification gates, merge polling and TUI commands.
16+
- Require documentation and affected diagrams to be updated with each relevant
17+
implementation change in repository and bundled bot instructions.
18+
19+
### Fixed
20+
21+
- Reconcile timed-out or interrupted sessions completed manually after a blocked
22+
task or service restart. Verify and publish through the dispatcher, then process
23+
queued issue feedback on the same branch and PR, including legacy checkpoints.
24+
25+
### Added
26+
27+
- `/restartworkflow` and the matching CLI/RPC command resume a stopped task from
28+
its saved stage, preserving worktrees, sessions, PRs, and feedback. Checkpoint
29+
continuation requests across restarts without bypassing checks or permissions.
30+
31+
### Changed
32+
33+
- Collect feature PRs on `devel` without publishing a release. Run CI on PRs to
34+
`devel` and `release`, and publish automatic patches only after a same-repository
35+
`devel` to `release` PR is merged.
36+
- After stable publication and README update, automatically merge the published
37+
release head into `devel` without a synchronization PR. Preserve new development
38+
commits, retry concurrent updates, and fail safely on conflicts or denied pushes.
39+
1140
## 0.6.5
1241

1342
### Fixed
@@ -44,7 +73,7 @@ include the full version, for example `## 0.7.0-beta.1`.
4473

4574
- Run full CI when feature PRs target `release`, including new commits to open PRs.
4675
Ordinary feature pushes no longer run CI or build packages.
47-
- Publish an automatic patch after a PR merges into `release`, and support manual
76+
- Publish an automatic patch after a `devel` PR merges into `release`, and support manual
4877
version tags on that branch without a second version bump.
4978
- Recover interrupted publication without moving tags or republishing completed
5079
packages. Commit README on `release` before opening or updating its PR to `main`.

‎README.md‎

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,14 @@ installations are not removed by `npm uninstall --global`.
252252
- **Progress:** use `/bot` in the TUI, or the CLI's `status`, `scan`, `pause`, and
253253
`resume` commands from the target repository. Closing a PR closes its bot tabs
254254
while retaining session history. Authorized issue comments can continue work
255-
on an open PR without another mention.
255+
on an open PR without another mention, after the current round publishes.
256+
- **Recovery:** completing a stopped bot session manually is detected by the
257+
dispatcher, which verifies and publishes before processing queued comments.
258+
Use `/restartworkflow` in the owner project's TUI or
259+
`opencode2-automation restartworkflow 'owner/repository#123'` from its primary
260+
checkout to recover an eligible stopped task without discarding work. Pending
261+
questions and failing checks still block progress. See
262+
[workflow recovery](docs/runtime.md#interrupted-sessions-and-workflow-recovery).
256263

257264
Keep machine-specific `.opencode/automation.json` files out of Git: global `init`
258265
does not add an ignore rule. See [configuration and Git branches](docs/configuration.md#configuration-files-and-git-branches)
@@ -291,21 +298,27 @@ copy it to another machine and follow the `.tgz` instructions above.
291298

292299
## GitHub Actions and releases
293300

294-
1. Work on a feature branch and add release notes under `Unreleased` in
295-
[CHANGELOG.md](CHANGELOG.md). Ordinary branch pushes do not run CI or publish packages.
296-
2. Open a PR into the long-lived `release` branch. CI runs lint, type checking,
297-
tests, a build, and an installation check on Node 22 and 24. New commits to
298-
the open PR rerun these checks. Review and merge after they pass.
299-
3. The merge starts **Release**. It increments the patch version on `release`,
300-
moves the unreleased notes into that version's changelog section, and pushes
301-
the version commit and tag atomically. It builds and verifies the tagged
302-
package, then publishes the GitHub Release with `.tgz`, SHA-256, and exact
303-
version notes. No package is published to npm.
304-
4. Only after publication succeeds, automation commits the versioned README link
305-
on `release` and opens or updates a PR from `release` into `main`.
306-
5. Review and merge that PR with a **merge commit**. All code, version metadata,
307-
release notes, and README changes reach protected `main` through this PR.
308-
The automation never pushes to `main` or writes its files through the API.
301+
1. Create a feature branch from `devel` and add release notes under `Unreleased`
302+
in [CHANGELOG.md](CHANGELOG.md). Pushes without an open PR do not run CI.
303+
2. Open a PR into `devel`. CI runs lint, type checking, tests, a build, and an
304+
installation check on Node 22 and 24. New commits to the open PR rerun checks.
305+
Review and merge after they pass. Merging into `devel` does not publish a package.
306+
3. When ready to publish the accumulated changes, open a `devel` → `release` PR.
307+
After its checks pass, review and merge it with a **merge commit**.
308+
4. The merge starts **Release**: an automatic patch version, exact changelog notes,
309+
atomic version/tag push, and publication of the verified `.tgz` and SHA-256.
310+
No package is published to npm.
311+
5. After publication, automation commits the new README download link on `release`
312+
and opens or updates the `release` → `main` promotion PR. It also automatically
313+
merges that published head into `devel`, including version metadata and README,
314+
preserving newer development work. No synchronization PR is created.
315+
6. Review and merge the promotion PR with a **merge commit**. Protected `main`
316+
receives all released code, metadata and README through that PR only.
317+
318+
A synchronization conflict or rejected push fails the Release job without
319+
resetting `devel` or undoing publication. Resolve the conflict or permissions and
320+
rerun the job; it reuses the published version. Synchronization does not wait for
321+
the main PR to merge and does not trigger another release.
309322

310323
To choose a version manually, prepare and commit its exact changelog section on
311324
`release`, then use `npm version`, for example:
@@ -321,7 +334,8 @@ git push --atomic origin release v1.0.0
321334
The pushed tag publishes exactly `1.0.0`, without another version bump. Both
322335
`v1.0.0` and `1.0.0` tag names are accepted. The next automatic patch is `1.0.1`.
323336
Version tags must point to code on `release`; ordinary pushes to that branch
324-
never start publication. Finish the active release before merging another feature.
337+
never start publication. Finish the active release before merging another `devel` → `release` PR.
338+
Feature PRs may continue to accumulate on `devel`.
325339

326340
The README on `release` is updated after publication; the README on `main` changes
327341
when the promotion PR is merged. The tag and packaged README remain snapshots

‎docs/advanced.md‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,46 @@ node dist/manage.js run /absolute/path/to/owner-project github-issues
7171
node dist/manage.js pause /absolute/path/to/owner-project github-issues
7272
node dist/manage.js resume /absolute/path/to/owner-project github-issues
7373
node dist/manage.js retry /absolute/path/to/owner-project 'owner/repository#123'
74+
node dist/manage.js restartworkflow /absolute/path/to/owner-project 'owner/repository#123'
7475
```
7576

7677
`pause` stops scheduled scans and manual scheduler runs. It does not cancel queued
7778
work or active sessions; direct dispatcher `scan` still works.
7879

79-
`retry` resumes blocked or failed tasks. If a session failed or prompt delivery is
80-
uncertain, inspect the session and worktree before explicitly starting a new one:
80+
`retry` clears blocked or failed status at the saved phase and requires an idle
81+
worker and maintenance loop. It does not append a continuation to an interrupted
82+
session. Prefer `restartworkflow` to continue that same session. If prompt delivery
83+
is uncertain, inspect the session and worktree before explicitly starting a new one:
8184

8285
```bash
8386
node dist/manage.js retry /absolute/path/to/owner-project 'owner/repository#123' --restart-session
8487
```
8588

8689
This interrupts the previous session and reuses the worktree. It preserves code
8790
and already-published acknowledgement comments. An issue edited after analysis
88-
remains blocked for review. A new authorized comment after completion starts a
91+
still faces the phase-specific issue/route guards on its next execution. A new authorized comment after completion starts a
8992
follow-up round and updates the same open PR.
9093

94+
`restartworkflow` (also available as `/restartworkflow` in the owner TUI) queues
95+
recovery at the saved phase, without interrupting active execution or clearing
96+
the session. An interrupted session receives one checkpointed continuation
97+
request after it becomes idle; a completed session proceeds to verification.
98+
The request survives owner restarts. Uncertain delivery blocks inspection rather
99+
than replaying the continuation. Repeated requests while ready/running are no-ops.
100+
The RPC method `automation.github.restartworkflow` accepts `{ key }` and returns
101+
`{ accepted }`. A true result acknowledges queuing, not completed publication.
102+
Known tasks not blocked/failed return false after the pending-question and closed-PR
103+
guards. Missing tasks, unresolved questions, closed/merged PRs, absent routes,
104+
and unrecognized running-session errors produce errors. Recovery does not run a
105+
scan, resume a paused scheduler, or restart the service.
106+
Unlike `retry`, recovery can be queued while a different task is working.
107+
91108
## Persistence and reconciliation
92109

93110
The queue stores analysis decisions and clarification dialogue, comment ID, session ID, phase, pinned base branch,
94111
worktree, base commit, pending questions, replies, permission decisions, helper
95-
IDs, check results, PR title, publication time, PR, and merge status. Writes are
112+
IDs, session-stop classification, recovery request and admission checkpoint, check
113+
results, PR title, publication time, PR, and merge status. Writes are
96114
atomic; heartbeat locks prevent multiple owners of the same state directory.
97115

98116
After a crash, allow 30 seconds for an abandoned lock to expire. Do not remove
@@ -110,7 +128,7 @@ location are checked before renaming, and no model is prompted. Requests have a
110128
servers without a matching service registration skip this mechanism; use the
111129
shared service for unattended automation.
112130

113-
SDK adapters may ignore AbortSignal. The plugin therefore bounds its own SDK waits,
131+
SDK adapters may ignore AbortSignal. The executor therefore bounds its local SDK waits,
114132
preserves healthy worker execution on owner disposal, and settles local state writes
115133
before releasing ownership. A replacement waits up to 15 seconds for the retiring
116134
owner's locks. RPC disposal has a five-second deadline per component; cleanup still
@@ -119,6 +137,14 @@ error should be investigated via plugin details and server logs. Back up the que
119137
worktree, and session database before recovery. Reconcile an already-published PR
120138
and saved session instead of restarting implementation or deleting the worktree.
121139

140+
A blocked session stop is rechecked on worker passes (no more than once every
141+
30 seconds after an unsuccessful probe, and only when a new worker pass can start). A matching saved session with a successful
142+
final assistant response re-enters normal execution validation, checks, and
143+
publication automatically, including legacy timeout/interruption checkpoints.
144+
Failed checks, pending questions, and uncertain prompt delivery are not cleared.
145+
Queued feedback is retained until publication completes. The stop itself never
146+
automatically prompts the model; continue it manually or request workflow recovery.
147+
122148
Only one issue executes at a time. Checks must succeed before publication. Push
123149
uses the exact verified commit without force. Worktrees remain available for
124150
inspection; automatic cleanup is not implemented.

0 commit comments

Comments
 (0)