Skip to content

Commit bbd1f59

Browse files
committed
docs: align workflow diagrams and require documentation with code changes
1 parent d9eb0d1 commit bbd1f59

10 files changed

Lines changed: 467 additions & 192 deletions

File tree

‎AGENTS.md‎

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,42 @@ the installation block without making remote writes. Keep its markers intact.
7171
installation. `examples/` contains configuration examples; `test/` contains
7272
automated tests. `package.json` defines build and validation commands.
7373

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

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ 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+
1119
### Fixed
1220

1321
- Reconcile timed-out or interrupted sessions completed manually after a blocked

‎README.md‎

Lines changed: 8 additions & 1 deletion
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)

‎docs/advanced.md‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,18 @@ node dist/manage.js restartworkflow /absolute/path/to/owner-project 'owner/repos
7777
`pause` stops scheduled scans and manual scheduler runs. It does not cancel queued
7878
work or active sessions; direct dispatcher `scan` still works.
7979

80-
`retry` resumes blocked or failed tasks. If a session failed or prompt delivery is
81-
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:
8284

8385
```bash
8486
node dist/manage.js retry /absolute/path/to/owner-project 'owner/repository#123' --restart-session
8587
```
8688

8789
This interrupts the previous session and reuses the worktree. It preserves code
8890
and already-published acknowledgement comments. An issue edited after analysis
89-
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
9092
follow-up round and updates the same open PR.
9193

9294
`restartworkflow` (also available as `/restartworkflow` in the owner TUI) queues
@@ -95,7 +97,12 @@ the session. An interrupted session receives one checkpointed continuation
9597
request after it becomes idle; a completed session proceeds to verification.
9698
The request survives owner restarts. Uncertain delivery blocks inspection rather
9799
than replaying the continuation. Repeated requests while ready/running are no-ops.
98-
Questions, permissions, closed PRs, and missing execution routes remain guarded.
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.
99106
Unlike `retry`, recovery can be queued while a different task is working.
100107

101108
## Persistence and reconciliation
@@ -121,7 +128,7 @@ location are checked before renaming, and no model is prompted. Requests have a
121128
servers without a matching service registration skip this mechanism; use the
122129
shared service for unattended automation.
123130

124-
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,
125132
preserves healthy worker execution on owner disposal, and settles local state writes
126133
before releasing ownership. A replacement waits up to 15 seconds for the retiring
127134
owner's locks. RPC disposal has a five-second deadline per component; cleanup still
@@ -131,7 +138,7 @@ worktree, and session database before recovery. Reconcile an already-published P
131138
and saved session instead of restarting implementation or deleting the worktree.
132139

133140
A blocked session stop is rechecked on worker passes (no more than once every
134-
30 seconds after an unsuccessful probe). A matching saved session with a successful
141+
30 seconds after an unsuccessful probe, and only when a new worker pass can start). A matching saved session with a successful
135142
final assistant response re-enters normal execution validation, checks, and
136143
publication automatically, including legacy timeout/interruption checkpoints.
137144
Failed checks, pending questions, and uncertain prompt delivery are not cleared.

‎docs/architecture.md‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ loads a generic scheduler, a GitHub dispatcher, and a terminal UI component.
88
- **Scheduler:** durable interval jobs, pause/resume, backoff, and no overlapping
99
invocation of the same job. Calls dispatcher RPC rather than GitHub directly.
1010
- **Dispatcher:** discovers issues and authorized comments, persists the queue,
11-
coordinates execution, publishes PRs, and polls for merge approval.
11+
coordinates execution and recovery, publishes PRs, and polls for merge approval.
1212
- **Executor:** generates an acknowledgement, runs an OpenCode session in an
1313
isolated Git worktree, verifies changes, and pushes the verified commit.
1414
- **Terminal UI:** subscribes to activity events and polls for missed updates.
@@ -18,20 +18,26 @@ loads a generic scheduler, a GitHub dispatcher, and a terminal UI component.
1818
## Workflow
1919

2020
1. Match a configured mention in an authorized issue or comment.
21-
2. Generate an English problem summary and plan without editing code.
22-
3. Publish a signed acknowledgement before starting implementation.
21+
2. Generate a structured analysis without tools. Questions and proposals requiring
22+
a choice wait for an authorized reply before implementation can begin.
23+
3. Publish a signed acknowledgement, resolve the base branch, and pin that choice.
2324
4. Create or reuse the task worktree and checkpoint the session identity before
2425
prompting the executor. The executor must not publish directly.
25-
5. Verify changes, generate a descriptive PR title, push, and create the PR.
26-
6. Process subsequent authorized issue comments as new rounds on the same branch.
26+
5. Validate session success, verify changes, then push and create or reconcile the
27+
PR. Generate its title only if creating a PR without an already-saved title.
28+
6. After publication, process queued authorized issue comments as new rounds on
29+
the same worktree and branch, with a new main session and the existing open PR.
2730
7. Merge only after eligible approval of the published head, repository permission
2831
checks, and GitHub merge readiness checks. Post a signed acknowledgement.
2932

30-
A failure retains the current phase and retry state. A possibly running session
31-
is reconciled before starting another issue. Unknown prompt delivery is blocked
32-
for inspection. Stopped sessions completed manually are detected automatically and
33+
A failure retains the current phase and retry state. An eligible `running` task
34+
with a saved session takes priority over other ready tasks. Unknown prompt
35+
delivery is blocked for inspection. Stopped sessions completed manually are detected automatically and
3336
rejoin verification/publication before queued feedback runs. Explicit workflow
34-
recovery preserves checkpoints and continues the same session when needed. RPC events are ephemeral; they are not the durable queue.
37+
recovery preserves checkpoints and continues the same session when needed. It does
38+
not resume a paused scheduler or clear pending questions and failing checks. RPC
39+
events are ephemeral; they are not the durable queue. See the eight
40+
[workflow diagrams](bot-workflow.md) for exact sequencing and guards.
3541

3642
## Configuration and ownership
3743

0 commit comments

Comments
 (0)