Files
lmxopcua/scripts/queue/loop-iteration.md
Joseph Doherty 2d07d716dc Recover stashed driver-gaps work from pre-v2-mxgw-merge working tree
Captures uncommitted work that lived in the working tree on
v2-mxgw-integration but was orthogonal to the migration. Stashed
during the v2-mxgw merge to master (2026-04-30) and replanted here on
a feature branch off master so it's git-visible rather than living in
the stash list.

Two distinct buckets:

1. Tracked fixture/config refinements (10 files, ~36 lines):
   - scripts/e2e/test-opcuaclient.ps1
   - src/ZB.MOM.WW.OtOpcUa.Admin/appsettings.json
   - 5 docker-compose.yml under tests/.../IntegrationTests/Docker/
     (AbCip, Modbus, OpcUaClient, S7)
   - 4 fixture .cs files (AbServerFixture, ModbusSimulatorFixture,
     OpcPlcFixture, Snap7ServerFixture)

2. Untracked driver-gaps queue artifacts (~8000 lines):
   - docs/plans/{abcip,ablegacy,focas,opcuaclient,s7,twincat}-plan.md
     — per-driver gap plans
   - docs/featuregaps.md — cross-cutting analysis
   - docs/v2/focas-deployment.md, docs/v2/implementation/focas-simulator-plan.md
   - followup.md — auto/driver-gaps queue follow-ups
   - scripts/queue/ — PR-queue automation tooling (12 files including
     pr-manifest.yaml at 1473 lines)

This commit is a snapshot for recoverability — review and split into
focused PRs (or discard) before merging anywhere downstream.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 08:28:01 -04:00

3.0 KiB

Loop iteration prompt (Mode B autonomous)

This is the single self-contained prompt that /loop re-fires until the queue empties. Each iteration handles exactly one PR end-to-end.


You are running one iteration of the autonomous plan-execution loop. The queue lives in Gitea at dohertj2/lmxopcua. Helpers: scripts/queue/*.sh.

Step 1 — pick the next PR

Run bash scripts/queue/next-pr.sh. It returns JSON.

  • If {"empty": true} → the queue is drained. Do not call ScheduleWakeup. Report "queue empty — loop terminating" and exit. The /loop will end.
  • Otherwise parse: issue_num, canonical_id, driver, phase, plan_pr_id, branch, title, url.

Step 2 — claim it

Run bash scripts/queue/start-pr.sh "$ISSUE_NUM" "$BRANCH". This swaps queue/queuedqueue/in-progress and creates the branch off auto/driver-gaps.

Step 3 — pull the issue body

Run curl -sf -H "Authorization: token $(awk '/token:/{print $2}' "$LOCALAPPDATA/tea/config.yml")" "https://gitea.dohertylan.com/api/v1/repos/dohertj2/lmxopcua/issues/$ISSUE_NUM" and extract the body field. The body contains the Plan link, summary, source files, docs/fixture/e2e files.

Step 4 — implement on a worktree

Dispatch a general-purpose Agent with isolation: "worktree". Brief it with:

  • the issue body verbatim
  • the linked plan section (read docs/plans/<driver>-plan.md and quote the relevant per-PR detail)
  • explicit instructions: implement the source-file changes, the doc updates, the fixture extensions, and the e2e test additions named in the issue
  • run dotnet build c:/Users/dohertj2/Desktop/lmxopcua/ZB.MOM.WW.OtOpcUa.slnx until green
  • run dotnet test for the relevant test project until green
  • commit on $BRANCH with message Auto: <canonical_id> — <short summary> followed by Closes #$ISSUE_NUM
  • return a brief summary of what changed

Step 5 — verify and push

Verify the agent did commit + push. If branch isn't pushed, push it: git push origin "$BRANCH".

Step 6 — open PR

Build a body file: include the issue summary + the agent's summary. Then:

PR_NUM=$(bash scripts/queue/open-pr.sh "$ISSUE_NUM" "$BRANCH" "$TITLE" /tmp/pr-body.md)

Step 7 — auto-merge (Mode B)

Run bash scripts/queue/merge-pr.sh "$PR_NUM".

Step 8 — close issue

Run bash scripts/queue/finish-pr.sh "$ISSUE_NUM" success "$PR_NUM".

On failure

If anywhere from Step 4 onward fails (build red, tests red, agent gives up, push fails, merge conflict):

  • write the failure log to /tmp/loop-fail-$ISSUE_NUM.log
  • run bash scripts/queue/finish-pr.sh "$ISSUE_NUM" failed /tmp/loop-fail-$ISSUE_NUM.log
  • the issue keeps queue/failed and stays open for retry
  • do not retry the same issue this iteration; let the loop pick a different one next fire

Re-arm

At the very end of the iteration (success OR failure), call ScheduleWakeup with the same /loop prompt and delaySeconds: 60 to fire the next iteration.

If the queue was empty in Step 1, do NOT call ScheduleWakeup.

Report a one-line summary to the user before re-arming.