Repository navigation
Agent Issue Pipeline
JNode's hands-off issue automation: receptionist triage, a per-ticket DEV/REVIEW/FEEDBACK loop, evidence-gated label and closure logic, and CI self-healing.
JNode runs a mostly autonomous pipeline from "issue opened" to "PR merged, issue closed". Seven GitHub Actions workflows plus six JavaScript modules cooperate through issue labels, hidden HTML state comments, and slash-command issue comments.
issue opened
-> auto-triage.yml posts "/oc triage issue #N" [issues: opened]
-> triage.yml Triage runs, read-only checkout, posts report ["/oc triage" comment]
-> ticket-runner.js auto-starts DEV [Triage workflow_run]
-> opencode.yml agent works the ticket, opens a PR ["/oc Please proceed…"]
-> ant.yml Java CI the four jobs must all be green before review
-> ticket-runner.js DEV -> REVIEW, posts "/oc review" on the PR [opencode workflow_run + green CI]
-> agent review "Verdict: approve" | "Verdict: request-changes"
request-changes -> FEEDBACK -> "/oc fix Address review feedback." -> REVIEW
approve + !auto-merge-eligible -> HUMAN_REVIEW (native GitHub PR Review UI)
approve + eligible + safe diff + green CI -> MERGE -> DONE + close
red CI -> stay REVIEW; forbidden path or over-budget -> HUMAN_REVIEW
-> ant.yml Java CI green re-reviews a deferred PR; red posts CI-heal
-> watchdog.yml every 15 min: re-posts a trigger if a wakeup was provably lost
-> wiki-update.yml weekly documentation pass
orchestrator.yml / orchestrator.js is a parallel driver for batched multi-task master issues; it uses the same phases and the same gate in orchestrator-helpers.js.
| File | Role |
|---|---|
.github/workflows/auto-triage.yml |
Receptionist. Posts the triage request; re-triages on reporter replies. |
.github/workflows/triage.yml |
Triage runner. Read-only, no checkout writes, no branches, no PRs. |
.github/workflows/ticket-runner.yml |
Ticket Runner. Single job calling ticket-runner.js. |
.github/workflows/orchestrator.yml |
Task Orchestrator. Batch foreman for kind/orchestrator master issues. |
.github/workflows/opencode.yml |
The build agent itself: ISO build + QEMU, then the OpenCode agent. |
.github/workflows/watchdog.yml |
Stall watchdog: schedule every 15 min + manual. Re-emits a lost trigger; never advances a phase. |
.github/scripts/ticket-runner.js |
Per-ticket state machine (DEV/REVIEW/FEEDBACK/HUMAN_REVIEW/MERGE/DONE/FAILED). |
.github/scripts/orchestrator.js |
Batch state machine over a master issue's queue/current_task. |
.github/scripts/orchestrator-helpers.js |
Shared REST helpers: trigger, verdict parsing, merge-safety gate, isCIGreen, MAX_HISTORY_ENTRIES, DEFAULT_MAX_TURNS, parkForCI, mergePR, base-currency check, mergeSubject. |
.github/scripts/model-config.js |
Role → model mapping and reasoning-effort variants; see Agent-Factory-Controls. |
.github/scripts/report-signals.js |
The five shared report predicates (isRefusalComment, isNeedsInfoComment, isTriageComment, isTriageClearComment, isTriggerComment) imported by both runners. |
.github/scripts/trusted-author.js |
Single source of truth for TRUSTED_AUTHOR_LOGINS and isBotUser/isTrustedAuthor, shared by the helpers and the inline workflow guards. |
.github/scripts/watchdog.js |
Trigger re-emitter for provably lost wakeups; evidence-based, dry-run by default, never merges or labels. |
.github/hooks/prepare-commit-msg |
Appends Assisted-by: <model> to every agent commit and strips agent Co-authored-by: lines; no-op when OPENCODE_MODEL is unset or on a merge. |
.github/scripts/opencode-post-step.js |
Turns the agent's report into an agent/* label and (sometimes) a close; consumes PREFLIGHT_OUTCOME. |
.github/scripts/opencode-trigger.js |
Trigger classification (isOpencodeTrigger, isAnchoredNonExcluded, isAnchoredNonTriage, isTriageTrigger) shared by both workflows. |
.github/scripts/triage-trigger.js |
Testable mirror of the triage.yml job-level if: gate; delegates to opencode-trigger.js. |
.github/scripts/sync-labels.js |
Label bootstrap CLI; owns the PRESERVE set. |
.github/scripts/tests/*.test.js |
347 node:test unit tests for the state machines, helpers, trigger gates, trusted-author gate and watchdog. |
.github/AGENTS.md |
304-line spec of the pipeline: triggers, labels, decision tree, state format. |
opencode.json |
Repo-level OpenCode config; grants the agent allow on /tmp/* external-directory access. |
.opencode/skills/jnode-triage-issue/SKILL.md |
v0.2.0 triage behaviour contract. |
.opencode/skills/jnode-issue-resolver/SKILL.md |
v0.1.0 worker behaviour contract. |
a373767 grants external_directory: {"/tmp/*": "allow"}. Only paths under /tmp open; /tmp itself and /etc stay gated. This lets the filesystem-debug and jnode-qemu skills stage repro scripts and serial logs.
Three namespaces plus two bare labels. All are bootstrapped by sync-labels.js (which also PRESERVEs orchestrator-internal labels).
| Namespace | Values |
|---|---|
kind/* (blue #1d76db) |
bug, feature, investigate, wiki, review, chore, question, triage, test, plus orchestrator (not synced) |
agent/* (grey #cccccc) |
in-progress, needs-info, blocked, done, failed, skip, duplicate, investigated
|
area/* (green #0e8a16) |
core, fs, net, shell, gui, builder, docs, build, vm, test
|
| bare |
auto-merge (#0e8a16), no-auto (#d73a4a) |
| internal | orchestrator/locked |
Constants: ACTIONABLE_KINDS (ticket-runner.js:114) is the five actionable kinds; AUTO_BLOCKING_LABELS (:115) is all eight agent/* labels; SAFE_AUTO_MERGE_KINDS (orchestrator-helpers.js:69) is chore/wiki/test; COMPLETION_LABELS (:210) and SHORT_CIRCUIT_LABELS (:216, the same minus agent/done); CLOSE_KINDS (opencode-post-step.js:16) is investigate/question; AGENT_COMPLETION_RE (:15) matches any terminal agent/* label.
| Command | Consumer | Meaning |
|---|---|---|
/oc triage [issue #N] |
triage.yml only (excluded from opencode.yml) |
read-only classification |
/oc Please proceed with this task. |
opencode.yml |
bot-of-bots signature; starts the DEV phase |
/oc review |
opencode.yml |
code review; final line must be Verdict: approve or Verdict: request-changes
|
/oc fix [text] |
opencode.yml |
code fix; also the FEEDBACK phase trigger |
/oc investigate, /oc explain
|
opencode.yml |
investigation kinds |
/oc wiki |
opencode.yml |
run the update-wiki skill |
/oc chore, /oc test
|
opencode.yml |
chore / test kinds |
/oc approve [--force] |
ticket-runner.yml |
maintainer approval for a HUMAN_REVIEW PR, including your own PR; --force merges on red CI and records human_approved_forced
|
/run, /run --turns N, /run --max-turns N, /run --reset, /run --fresh
|
ticket-runner.yml |
per-ticket state machine |
/orchestrate |
orchestrator.yml |
batch foreman |
Routing is case-sensitive; the verb is the first non-whitespace token after /oc . A bare /oc is not a trigger — opencode.yml requires the trailing space. /oc triage is a hard STOP inside the resolver skill, so a triage run can never fall through into a build run.
/oc approve is excluded from opencode.yml (like triage) so it starts no agent run; ticket-runner.yml owns it. A comment carrying an opencode.ai/s/ session link is ignored, because the agent posts with GH_PAT and would otherwise pass the collaborator gate as the PAT owner.
Every automatic path is restricted to issues/PRs authored by the maintainer, so a third party cannot drive the pipeline by opening an issue. Policy lives in .github/scripts/trusted-author.js:
var TRUSTED_AUTHOR_LOGINS = ["LSantha"];
function isBotUser(user) { /* type=Bot or [bot] login */ }
function isTrustedAuthor(user) { /* allowlist membership */ }- The allowlist is deliberately a login list, not
author_association: COLLABORATOR: the automation acts as the PAT owner, so association cannot tell a human from a prompt-injected agent, and a future collaborator would be silently trusted. -
auto-triage.ymlskips untrusted issues on both theopenedand re-triage paths;ant.yml'shealjob ignores untrusted PRs;autoStartGuardsrefuses DEV for an untrusted author unless a maintainer kickoff comment (/oc triageor/run, no session link) is present. -
ant.ymlchecks out the base ref forheal(github.event.pull_request.base.sha), never the PR head, so a fork cannot swaptrusted-author.jsin a job that holdsGH_PATandissues: write. - No approval label is used: an agent-added label is indistinguishable from a human one because both arrive as the same login.
/run is triage-first: on a ticket with no clear ## Triage it requests /oc triage and starts DEV only once the report lands, so the manual escape hatch cannot skip triage.
-
run-name: "Triage #${{ github.event.issue.number }} - ${{ github.event.issue.title }}"— this exact string is whatticket-runner.jsparses out ofworkflow_run.display_titlevia/Triage #(\d+)/. - Trigger:
issue_comment: types: [created]only. Concurrencytriage-<n>,cancel-in-progress: false.timeout-minutes: 20. - Job
if: not a PR, body starts with or contains/oc triage, does not containopencode.ai/s/(the agent's own session link — the self-retrigger guard), andauthor_associationis COLLABORATOR/MEMBER/OWNER. -
Anchored non-triage exemption (
#866). A comment whose first token is an anchored/oc <verb>where the verb is nottriagehas already chosen its command, so a later quoted/oc triagein prose must not start a Triage run.opencode-trigger.jsexposesisAnchoredNonTriage(startsWith(text, "/oc ") && !startsWith(text, "/oc triage")) andisTriageTrigger;triage.ymladds the negated predicate to its jobif:andtriage-trigger.jsmirrors it fornode:test. An embedded/oc triagestill starts Triage, and an anchored/oc approveruns nothing. -
Preflight. Before running the agent,
triage.ymlcurls the anonymousapi.github.com/rate_limitand fails the step when the core quota is unreadable or<= 1, so a quota-exhausted run fails fast instead of failing inside the action.opencode.ymlandwiki-update.ymlrun the same preflight;opencode-post-step.jsturns a failed preflight intoagent/blocked. -
Permissions:
contents: read,pull-requests: read,issues: write. Noid-token, nocontents: write— committing, pushing and opening PRs are structurally impossible. - Steps: checkout with
persist-credentials: false→ setuser.name "LSantha"/user.email "LSantha@users.noreply.github.com"→ installGH_PATas the https extraheader →gh repo clone LSantha/jnode_ai.wiki .wikiwithsecrets.GH_PAT→ JDK 8 zulu → lock the checkoutchmod -R a-w .thenchmod -R u+w .git→ run the agent →opencode-post-step.js(if: success() || failure() || cancelled()) → cleanup. -
.gitis deliberately left writable so the action and the cleanup step still function; everything else is read-only. -
Deterministic prompt via
with: prompt:— a single-line string, not a skill-discovery prompt. It mandates loadingjnode-triage-issue, auditingkind/*andarea/*labels first, exactly one report opening## Triage, then the body addendum, and returning the report as the final response instead of callinggh issue comment. - Cleanup (
if: always()):git checkout -q masterfirst, then delete everyopencode/*branch, thenrm -rf /tmp/triage-* /tmp/oc-triage-*. Checking outmasterfirst is required because the lockdown can leave HEAD detached or on an agent branch. - No QEMU, no ISO build, no cache — unlike
opencode.yml. JDK is present sogit log/gh/ jar inspection work, but building is explicitly banned by the skill.
Hidden comment <!-- TICKET_RUNNER_STATE: {...} --> matched by STATE_RE. initState() (:34) produces:
{ "phase": "DEV", "pr": null, "turn": 0, "max_turns": 7, "retries": 0,
"review_in_progress": false, "review_pending_ci": false,
"started": "2026-09-06T22:00:00.000Z", "history": [] }history is capped to the most recent MAX_HISTORY_ENTRIES (200) entries when persisted — diagnostic only, nothing reads it, and the issue body has a 65536-character limit.
A rendered status block precedes it (renderStatusSection :59, CRLF-tolerant matcher STATUS_SECTION_RE :83) with rows Phase, Turn, Retries, PR, Review in progress, Started. Phase emoji: DEV 🔨, REVIEW 🔍, FEEDBACK 🔧, HUMAN_REVIEW 👤, MERGE 🚀, DONE ✅, FAILED ❌, CANCELLED (issue closed mid-run), fallback ⏳. isTerminalPhase covers DONE, FAILED and CANCELLED.
on: issue_comment:[created], issues:[labeled], workflow_run:[opencode, Java CI, Triage]/[completed], pull_request_review:[submitted]. Concurrency ticket-runner-<issue|PR|run id> with cancel-in-progress: false. Permissions: issues: write, pull-requests: write, contents: write, actions: read. Checkout is the default branch.
The YAML gate accepts any kind/ label; the script narrows to ACTIONABLE_KINDS.
- The workflow job matches the prefix
/runonly, and the script'sisRunguard narrows the body shape. The old jobiflisted/run,/run\nand/run\r; GitHub Actions treats\n/\rin a single-quoted expression as literal backslash-n characters, so every multi-line/runcomment was silently dropped (this also broke the watchdog's/run\n\n<!-- WATCHDOG:… -->nudge)./runningstill does not match. -
author_associationmust be COLLABORATOR/MEMBER/OWNER. -
PR guard:
/runis issues-only; it comments back pointing at/oc review//oc fix. -
Orchestrator guard
checkOrchestratorManaged(:235): own body hasORCHESTRATOR_STATE, or the issue is in thequeue/current_taskof an openkind/orchestratormaster withstatus === "IN_PROGRESS". -
--turns N/--max-turns N→customMaxTurns(default 3). -
--reset/--freshnulls the state. Otherwise an existingDONE/FAILEDstate is nulled ("Starting fresh"). - No state →
initState, append status, update the issue, thenh.triggerTask(issueNumber). - Existing state in
HUMAN_REVIEW→ informational comment only, no re-trigger. - Otherwise re-trigger on
state.pr || issueNumberwithphaseMessage(state): FEEDBACK →/oc fix Address review feedback., REVIEW →h.getReviewPrompt(), else/oc Please proceed with this task.
A manual /run bypasses every auto-start guard — no-auto, blocking agent/* labels, actionable kind, triage clarity, existing state. Only the PR and orchestrator guards still apply. This is the documented escape hatch.
Fails, in order, on: fetch error, pull_request, no-auto, kind/orchestrator, own body has ORCHESTRATOR_STATE, state already present, any AUTO_BLOCKING_LABELS, no ACTIONABLE_KINDS match, orchestrator-managed.
triageStatus (:306) returns {present, clear, count, requested} from the comment history:
-
requested— any comment matching/(^|\s)\/oc\s+triage(?:\s|$)/i. - comments matching
isTriggerCommentare skipped so the slash command itself is never mistaken for a report. -
count— comments matchingisTriageComment(/## .*Triage/i). -
clear— evaluated on the last triage comment only:!isNeedsInfoComment(b) && !isRefusalComment(b), both imported fromreport-signals.js.
handleIssuesLabeled (:341) reacts to a newly added actionable kind label:
- triage requested but no report yet → wait, do not double-request.
- no triage requested → post the full request text (which repeats the "Triage run ONLY … FORBIDDEN: git checkout -b, git push, gh pr create" clause).
- triage not clear, or
count > 3→ wait. - otherwise auto-start with
initState(3)andhistory: {event: "auto_start", reason}.
maybeAutoStartAfterTriage (:370) does the same from the Triage workflow completion, requiring present && clear && count <= 3.
This is the most important ordering rule in the whole pipeline:
-
findPRForIssueWithComment(issueNumber)(:838) — firsth.findPRForIssue(n)(open PRs whose head ref isopencode/issue<n>-*or whose body matchesCloses|Fixes|Resolves #n); fall back to scanning comments newest-first for/\b(?:Created|Opened) PR #(\d+)\b/ito survive API index lag. A comment may name a PR from an earlier abandoned attempt, so each candidate is fetched and skipped when it isclosedwithoutmerged; if the state cannot be read the candidate is accepted (fail-open). Open and closed+merged PRs are eligible. -
If a PR exists: unconditionally set
pr,phase = "REVIEW",retries = 0, then checkisCIGreen: green →requestReview(state, prNumber)then persist; red →parkForCI(...)and post nothing. This happens before thephaseFailedcheck and before any label inspection. - Only when no PR exists does
phaseFailed → retryOrFail, thenSHORT_CIRCUIT_LABELS → DONE, then theagent/donebranch (kind/feature/kind/bugwith no PR → retry), then fallbackretryOrFail.
A PR is the authoritative completion signal. A stale agent/needs-info or agent/skip cannot short-circuit a ticket whose agent already opened a PR, and even a failed run advances if a PR exists. orchestrator.js:488-521 mirrors this for case 'DEV'.
Two layers:
-
handleJavaCICompletion(:415) only acts onconclusion === 'success', and requiresst.phase === "REVIEW"and!st.review_in_progress. On eligibility it callsrequestReview(post, then set both flags) and persists. The orchestrator mirror isorchestrator.js:202. -
review_in_progressis cleared only inhandleReviewCompletion(:679), as its first statement — so it stays set for the whole duration of an opencode review run.
review_pending_ci is the companion: set when a review is parked on red CI with no prompt posted, cleared by requestReview. It stops the Java-CI success wakeup from firing on a ticket that is already mid-review, and stops phaseMessage() from re-prompting one that is merely waiting.
The flag is set on every /oc review schedule: handleDevCompletion, handleFeedbackCompletion, the CI-green wakeup, recoverLostState, and the manual orchestrator retrigger.
The resolver skill's review contract (.opencode/skills/jnode-issue-resolver/SKILL.md) uses three markers, and the 🟡 row changed on 2026-10-03 (c50a38d):
| Marker | Meaning | Required action |
|---|---|---|
| 🔴 | Must-fix: bug, license violation, Java 1.6 violation, missing test | request changes |
| 🟡 | Should-fix: correctness, test validity, maintainability, or a tracked follow-up | request changes; a deferred 🟡 requires a follow-up issue created in the same review |
| 🟢 | Nit: typo, formatting, optional refactor | comment, do not block |
Previously 🟡 was explicitly "comment, do not block". It is now a blocking severity, with exactly one escape hatch: the review may proceed to approve only if a follow-up issue was created and linked in the summary. This is stated twice, in the skill's marker table and in its review-instructions paragraph, and mirrored in .github/AGENTS.md's REVIEW phase:
A review must not approve with an untracked 🟡 finding: request changes or create and link a follow-up issue.
The motivation is visible in the same week's commits: two latent NumberUtils bugs (getSizeUnit("1KB") returning B, toString(f, Integer.MAX_VALUE) overflowing an int) were documented but deliberately not asserted. Without the untracked-🟡 rule that is approval with a known unfixed defect and no tracking. See Core-Test-Suite.
-
review_in_progress = false;phaseFailed → retryOrFail. - PR labels in
SHORT_CIRCUIT_LABELS→DONEwithreview_short_circuit/feedback_short_circuit. - The DEV handler records
state.prand prefixes the PR title with#<issue> -when it is missing, so the squash-merge subject stays traceable back to the ticket. -
h.getAgentReviewVerdict(pr)returns'approve','request-changes'ornull. It scans issue comments first, then falls back to native PR reviews: a PR authored by the PAT owner cannot be self-approved, so an agent's approval lands as aCOMMENTreview that the issue-comment scan cannot see.- Request-changes wins over approve in the same body; trigger comments are skipped.
-
approve +
!isAutoMergeEligible→HUMAN_REVIEW,retries = 0, PR comment "Awaiting human approval via native GitHub PR Review UI." -
approve + eligible +
isDiffSafe+isCIGreen→MERGE,h.mergePR(pr), thenDONE+merged+closeIssueWithLabel. On throw:merge_failed+ a⚠️ PR comment. -
approve + eligible but the gate refuses → follow the merge-gate ordering above (
ci_not_greenstays inREVIEW; forbidden path or over-budget routes toHUMAN_REVIEW). -
request-changes →
turn += 1; overmax_turns→FAILED+max_turns_exceeded+agent/failed; elseFEEDBACK,retries = 0, trigger/oc fix Address review feedback. -
null → if
review_pending_ci && !isCIGreen(state.pr), do nothing at all (a verdict-less completion while parked must not consume a retry); otherwiseretryOrFail("no verdict found for PR #N. Retrying review.").
turn defaults to DEFAULT_MAX_TURNS = 7 (raised from 3) and is overridable only by manual /run --turns N; retries defaults to 3 and is not overridable. Either exceeding its cap sets FAILED + agent/failed with a max_turns_exceeded / max_retries history event. --turns is ignored on auto paths (initState() uses DEFAULT_MAX_TURNS), and terminal DONE/FAILED states short-circuit every handler (handleWorkflowRun:503, handleJavaCICompletion:435).
Skips bot reviewers and non-collaborator associations. Resolves the owning issue via findIssueByPR (:870, head ref ^opencode/issue(\d+)- or a closing keyword, then a scan of recently-updated open issues for st.pr === prNumber). Requires state.phase === "HUMAN_REVIEW".
-
approved→ re-checkisCIGreen: green →MERGE→mergePR→DONE→ close; red →REVIEWwithreview_pending_ci = true,retries = 0,human_approved_ci_red, and "Human approval recorded, but Java CI is not green yet. Not merging. Will re-check and merge when CI completes." -
changes_requested→turn += 1; over limit →FAILED; elseFEEDBACKwith/oc fix Address human review feedback.
GitHub disables the "Approve" control on a PR you authored, which on a single-maintainer repo is the everyday case. /oc approve, posted as a PR comment, is the honest equivalent of a native approval:
-
PR-only, and only on a
HUMAN_REVIEWticket, so it cannot short-circuit an in-flight review or DEV run. It resolves the ticket throughfindIssueByPRand reusesapproveAndMerge, so it re-checksisCIGreenand parks on red CI. -
--forceis the emergency override: it merges on red CI and recordshuman_approved_forcedin history. Refusals (not a PR, wrong phase, no ticket reference) reply with the reason and merge nothing. - The handler and workflow trigger use one literal space, so
/oc approvematches neither;opencode.ai/s/comments are ignored (agent-spoof guard).
Agent commits are attributed to the maintainer, never a bot, and the model is recorded in a trailer:
- CI identity is
LSantha <LSantha@users.noreply.github.com>(GitHub noreply, so the personal email stays private). -
.github/hooks/prepare-commit-msg(installed viacore.hooksPath, since git does not clone hooks) appendsAssisted-by: $OPENCODE_MODEL, strips agentCo-authored-by:lines, and no-ops whenOPENCODE_MODELis unset or on a merge.OPENCODE_MODELis the same value passed aswith: model, so attribution cannot drift. - A reviewer writes
Assisted-by: <model>next toVerdict:.mergePRcollects those withcollectReviewerModels, andbuildMergeMessageaddsReviewed-by:to the squash body only (the subject stays undersquash_merge_commit_title). -
opencode.ymlusespersist-credentials: false+GH_PATas the https extraheader, so agent pushes are same-repo collaborator pushes. AGITHUB_TOKENpush is attributed togithub-actions[bot]and parks the PR's Java CI inaction_required, stalling REVIEW/FEEDBACK.
The runners are event-driven, so a dropped workflow_run delivery (for example the GitHub Actions incident on 2026-10-16/17) parks a ticket forever in REVIEW with review_pending_ci=true and nothing retries it. watchdog.yml runs every 15 minutes and is a trigger re-emitter, not a second state machine:
- It polls runner state and the Actions runs API, and only when a wakeup is provably lost re-posts the same trigger a human would (
/run,/orchestrate, or the marker-deduped CI-heal/oc fix). It skips while any run is in flight, requires a completed run that did not advance state (or an idle timeout), and applies a cooldown plus a per-state attempt cap. - It respects
no-auto, blockingagent/*, untrusted authors,HUMAN_REVIEW,MERGEand terminal phases; it never advances a phase, merges or labels. A failed runs read aborts the sweep, and REVIEW without a PR is left for a human with/run --reset(posting/runthere would callcreateComment({issue_number: null})). Dry-run by default; 22node:testcases cover it.
autoStartGuards refuses auto-start when the issue is not open, and advancePhase cancels a run whose issue closes mid-flight. CANCELLED is a terminal phase alongside DONE/FAILED, so /run on a cancelled ticket starts fresh.
A closed issue is not always an abandonment: opencode-post-step closes investigation/question tickets and duplicates as their normal success path. The guard therefore treats a closed issue as self-closed only when it has no PR and either carries agent/duplicate, or carries agent/investigated (which the post-step only produces from an investigation report). A closed kind/bug with agent/done cancels. The issues.get is fail-open: a transient fetch failure does not cancel a healthy run.
Runs in both opencode.yml and triage.yml, if: success() || failure() || cancelled(), with PREV_CONCLUSION = steps.run_agent.outcome. It reads context.payload.issue.number and pages through comments with per_page: 100.
| Function | Test | Meaning |
|---|---|---|
isRefusalComment |
/^\s*##\s*(?:🤖\s*)?Refusal\b/im |
out-of-scope refusal heading — shared with ticket-runner.js via report-signals.js
|
isNeedsInfoComment |
content match on the three needs-info literals | "needs more info from reporter" / "needs the following" / "Suggested next: needs-info" |
isTriageComment |
/## .*Triage/i |
any ## … Triage heading |
isTriageClearComment |
triage ∧ ¬needs-info ∧ ¬refusal | actionable triage |
isTriggerComment |
/(^|\s)\/(oc|run|orchestrate)(\s|$)/ |
a slash command, never a report |
isDuplicateSignal |
/duplicate-of-#\d+/i |
Suggested next: duplicate-of-#M (private to the post-step) |
isPRCreationComment |
/\b(?:Created|Opened) PR #\d+\b/i |
PR work product |
isInvestigationReport |
/## .*Investigation Report/i |
investigation work product |
findLatestAgentComment(comments) (:66) walks backwards and returns the first body that is neither a trigger comment nor a non-report. Because the review prompt itself quotes both verdicts and the triage request text contains ## Triage, the trigger exclusion is what keeps the scanners from misfiring on instructions.
- refusal →
agent/skip - needs-info literals →
agent/needs-info -
## … Investigation Report→agent/investigated(verb-override; not kind-based) -
duplicate-of-#N→agent/duplicate -
Created|Opened PR #N→agent/done - preflight failure (
PREFLIGHT_OUTCOMEfailure/failed/cancelled/canceled) →agent/blocked - clear triage →
{label: null, clearNeedsInfo: true, clearFailed: true} -
conclusion === 'failure' || 'cancelled'→agent/failed - an existing
agent/*label other thanagent/failedis respected - PR context →
agent/done - default →
agent/done
Reports 1-7 are evaluated before the failure check, so a run that dies during action finalization after the comment landed still gets the report-derived label. Steps 3-5 are evidence gates: the kind label alone is never enough. The old isInvestigationKind(labels) default was removed; agent/investigated now requires the report heading and agent/duplicate requires the link. The preflight branch wins over a bare failure because a failed preflight produced no report: agent/blocked distinguishes "the action release endpoint was unreachable" from "the agent ran and failed".
A label === null (clear triage) result removes stale agent/needs-info and agent/failed if present, but only when actually present — untouched labels are not churned. agent/in-progress is always removed at the end.
if (isPR) return false; // never close a PR
if (agentLabel === 'agent/duplicate') return true;
if (agentLabel !== 'agent/investigated') return false;
if (isInvestigationReport(latestComment)) return true; // the evidence
return CLOSE_KINDS.some(k => labels.includes(k));Because decideAgentLabel can only produce agent/investigated through the report-heading branch, the CLOSE_KINDS fallback is effectively unreachable today — the label decision is already evidence-gated. If the issue is already closed, the close call is skipped with an info log.
Auto-merge requires all of:
| Gate | Rule |
|---|---|
isAutoMergeEligible(issue, pr) |
explicit auto-merge on the issue or PR, or implicit kind/chore/kind/wiki/kind/test
|
isDiffSafe(pr) |
no path matching FORBIDDEN_DIFF_RE; per-category budgets — ≤ 100 added lines / ≤ 5 files for production, ≤ 2000 added lines / ≤ 20 files for test paths; false if the file list is not an array or hits the 100-file pagination cap |
touchesForbiddenPath(pr) |
any path matching FORBIDDEN_DIFF_RE — a hard wall no approval can pass |
isCIGreen(pr) |
all four ant.yml job ids (build, test, boot32, boot64) present in checks.listForRef, all status === "completed", none in failure/cancelled/timed_out/action_required
|
var FORBIDDEN_DIFF_RE = /(^|\/)(core\/src\/native\/x86\/|jnode\.properties$|all\/build\.xml$|all\/conf\/)/;
var TEST_PATH_RE = /(^|\/)(src\/test\/|tests\/)/;
var MAX_PROD_ADDITIONS = 100; var MAX_TEST_ADDITIONS = 2000;
var MAX_PROD_FILES = 5; var MAX_TEST_FILES = 20;
var MAX_HISTORY_ENTRIES = 200;
// ...
var prodAdditions = 0, testAdditions = 0, prodFiles = 0, testFiles = 0;
for (var i = 0; i < list.length; i++) {
var filename = list[i].filename || "";
if (FORBIDDEN_DIFF_RE.test(filename)) return false; // unconditional
var additions = list[i].additions || 0;
if (TEST_PATH_RE.test(filename)) { testAdditions += additions; testFiles += 1; }
else { prodAdditions += additions; prodFiles += 1; }
}
return prodAdditions <= MAX_PROD_ADDITIONS && testAdditions <= MAX_TEST_ADDITIONS
&& prodFiles <= MAX_PROD_FILES && testFiles <= MAX_TEST_FILES;The budgets are independent per category. The previous rule was all-or-nothing — testOnly started true and was cleared by the first non-test path, so a 7-line production fix bundled with its own 140-line regression test was rejected because the test counted against the 100-line production cap. That blocked PRs #717, #721 and #722; seven test files tripping the flat 5-file cap blocked #720. TEST_PATH_RE matches the directory src/test/ or tests/, not the filename.
The cap was raised repeatedly before the split: 100 → 300 (950b022) → 400 (718680e) → 600 (842b6d7), each time requiring the constant in orchestrator-helpers.js, the matching sentence in .github/AGENTS.md, and the test boundaries to be edited in lockstep. The per-category split then replaced the ladder.
isDiffSafe also fails closed on a malformed response (if (!Array.isArray(list)) return false;) and accepts an empty file list — zero changed files cannot exceed a budget, and reporting an empty diff as over-budget sent it to HUMAN_REVIEW on a lie.
Both runners evaluate the gate in exactly this order:
const diffSafe = await h.isDiffSafe(pr);
const ciGreen = await h.isCIGreen(pr);
const forbidden = diffSafe ? false : await h.touchesForbiddenPath(pr);
if (!ciGreen) -> stay REVIEW, merge_deferred {reason: "ci_not_green"}
else if (forbidden)-> HUMAN_REVIEW, merge_blocked_forbidden_path // names the wall
else if (!diffSafe)-> HUMAN_REVIEW, merge_blocked_diff_unsafe
else -> MERGECI is evaluated first on purpose. The only way out of HUMAN_REVIEW is a human approval, which has no wakeup; a deferred merge on red CI has a real one. Issue #746 was parked forever on a canned "waiting for CI" message while the actual cause was the diff-size budget, and nothing could ever re-check it.
review_pending_ci joins review_in_progress in the state block, giving three states: review requested, review parked on CI with no prompt posted, neither.
async function requestReview(state, prNumber) { // post FIRST, then persist
await h.triggerTask(prNumber, h.getReviewPrompt());
state.review_in_progress = true;
state.review_pending_ci = false;
state.history.push({ event: "review_requested", pr: prNumber, timestamp });
}
async function parkForCI(issueNumber, state, prNumber, reason) { // persist only
state.review_in_progress = false;
state.review_pending_ci = true;
state.history.push({ event: "review_pending_ci", reason, timestamp });
await updateIssueState(issueNumber, state);
}Setting the flag only after triggerTask resolves is deliberate: on the DEV path the Java-CI success wakeup is the only one (no /oc review was ever posted, so no completion will arrive to clear the flags). A persisted-true flag plus a throwing post would skip every subsequent green CI.
Both helpers are used at all five prompt/park sites: DEV completion, FEEDBACK completion, lost-state recovery, the Java-CI success wakeup, and the /run escape hatch. phaseMessage() lost its REVIEW branch entirely — adding one back re-opens the race.
retryOrFail gained the red-CI park as its first statement, above state.retries += 1, because a defer that posts nothing is free regardless of caller. Without the hoist, three stray failed workflow completions against a healthy parked ticket reached agent/failed.
Human PR approval re-checks isCIGreen before merging: red CI returns the ticket to REVIEW with review_pending_ci = true, retries = 0, and a human_approved_ci_red history entry rather than merging.
Both runners persist state.history into an issue body capped at 65536 characters. At ~127 bytes per entry a persistently red PR reaches unwritability in ~516 stray failures. MAX_HISTORY_ENTRIES = 200 caps the slice (state.history.slice(-h.MAX_HISTORY_ENTRIES)); history is diagnostic only and nothing reads it. The constant is exported both from createHelpers() and as module.exports.MAX_HISTORY_ENTRIES so ticket-runner.js can import it without instantiating a helper set.
The state block is <!-- TICKET_RUNNER_STATE: {…JSON…} --> in the issue body, because it is shared with triage reports and the human status table. That sharing is the vulnerability: any full-body rewrite silently removes it. With no state, handleWorkflowRun fell through to auto-start, which refused because agent/done was already set — six tickets sat with an open PR, green CI and no review for ~11 hours.
recoverLostState(issueNumber, conclusion) runs before auto-start:
-
issues.get; bail on error, on a PR, or when a state block already exists. -
h.findPRForIssue— matched by theopencode/issueN-branch prefix. No PR → return false (the ticket never reached DEV). - Rebuild
initState(3)withphase = "REVIEW",pr = found,review_in_progress = falseand astate_recoveredhistory entry, then persist. -
conclusion !== "success"→retryOrFail; otherwiserequestReview.
findIssueByPR was deliberately not widened: it receives runIssueNumber from an Issue #N title, so treating that as a PR would alias issue #42 to PR #42.
The label decider and the auto-start gate each had their own report predicates and disagreed: the post-step accepted a refusal only as a ## Refusal heading, while ticket-runner.js matched /refusal|out of scope/i anywhere in prose. "stays out of scope" was therefore clear to one and blocking to the other (issue #742).
.github/scripts/report-signals.js now exports five shared predicates: isRefusalComment (heading-only, 🤖-tolerant), isNeedsInfoComment, isTriageComment, isTriageClearComment and isTriggerComment (/(^|\s)\/(oc|run|orchestrate)(\s|$)/). Both runners import them; opencode-post-step.js keeps only isDuplicateSignal, and ticket-runner.js dropped VAGUE_RE, TRIAGE_RE, REFUSAL_RE and TRIGGER_RE (TRIAGE_REQUEST_RE stays local). Prose mentioning "out of scope" no longer blocks auto-start; only a real ## Refusal heading does.
Three times in the shell test batch an agent found a real defect, filed a follow-up, then wrote the test to assert the broken behaviour. Each shipped green and cemented the defect, so the fix had to rewrite the test:
| Test | What it asserted |
|---|---|
testChildLabelsDoesNotIncludeLeafLabels |
Javadoc read "a labelled leaf Syntax reports an empty label set" — the defect described as intended |
testToXMLRoundTripFailsOnArgNameAttribute |
that the round trip throws |
testEagerFalseFlagCurrentlyBehavesLikeTrue |
that eager='false' parses as true — the name states the defect outright |
The rule is in .opencode/skills/jnode-issue-resolver/SKILL.md §6 and §8 (anti-pattern S8: Locking a bug into a test) and in .github/AGENTS.md's REVIEW phase as a 🔴 blocking finding: a test asserting current broken behaviour, even with a follow-up issue, must be rewritten by the eventual fix.
mergePR (:155-188) squash-merges and then verifies:
Before merging, both runners call checkBaseCurrency(prNumber). If the PR head does not contain the current base tip, the merge is refused (even under --force), the ticket records merge_refused_base_stale, and the comment names the lagging commits. compareHeadToBase() resolves repos.compare/compareCommits by capability and falls back to a raw /compare/ request, so an SDK-generation mismatch cannot silently refuse every branch. The squash subject is built by mergeSubject() (#<issue> - <clean title> (#<PR>)), which strips duplicate issue prefixes, (N chars) suffixes and the trailing (#PR). See Agent-Factory-Controls.
try { await github.rest.pulls.merge({ ..., merge_method: "squash" }); }
catch (err) {
var msg = String((err && err.message) || "");
if (!(err && err.status === 204) && !/Unexpected end of JSON input/i.test(msg)) throw err;
core.info("Merge returned 204/empty body; verifying PR state");
}
var merged = await github.rest.pulls.get({ ..., pull_number: prNumber });
if (!merged.data || merged.data.merged !== true) throw new Error("merge not confirmed");
try { await github.rest.git.deleteRef({ ..., ref: "heads/" + pr.data.head.ref }); }
catch (e) { core.warning("Could not delete branch " + pr.data.head.ref + ": " + e.message); }Octokit surfaces a successful squash merge as 204 or as Unexpected end of JSON input because there is no response body to parse. Both are downgraded from throws to "verify"; every other error still propagates. Confirmation is authoritative — the PR is re-fetched and must report merged === true, or the caller throws and the ticket records merge_failed rather than claiming success. Branch deletion happens only after confirmation and is best-effort.
getAgentReviewVerdict skips trigger comments with the same /^\/(oc|run|orchestrate)(\s|$)/ guard, and tolerates decorated verdicts (**Verdict**: approve) via /(?:\*{0,2}Verdict\*{0,2}:?\*{0,2}\s*:?\s*)approve\b/i.
Two independent producers post the same marker-deduped comment, so at most one heal is ever attempted per SHA:
| Producer | Mechanism |
|---|---|
ant.yml heal job |
needs: [build, test, boot32, boot64], if: failure() && !cancelled() && github.event_name == 'pull_request', permissions issues: write + pull-requests: write, token secrets.GH_PAT || secrets.GITHUB_TOKEN
|
ticket-runner.js postCiFixOnce (:392) |
from handleJavaCICompletion, only when phase is REVIEW or FEEDBACK
|
Both compute marker = '<!-- CI-HEAL:' + sha.slice(0,7) + ' -->', skip when the PR carries no-auto or agent/in-progress, skip when any of the last 100 comments already contains the marker, and then post. A cancelled run is not a failure to heal: handleJavaCICompletion acts only on failure or timed_out, and the heal job adds !cancelled() so a manually cancelled stalled QEMU boot cannot post a bogus /oc fix with jobs: unknown.
/oc fix CI failed for <sha7> (jobs: <failed | unknown>): <runUrl>
<!-- CI-HEAL:<sha7> -->
Read the failing check output, fix the code on this branch, and push. Do not open a new PR.
heal derives the job list from toJSON(needs); ticket-runner.js only acts for REVIEW/FEEDBACK.
Run the suite with node --test .github/scripts/tests/*.test.js (347 node:test cases, Node 18+) and labels with node .github/scripts/sync-labels.js --dry-run. The state machines export _parseState, _initState, _serializeState, _replaceOrAppendState, _replaceOrAppendStatus and _renderStatusSection for tests.
-
A PR beats everything. The DEV handler checks for a PR before
phaseFailedand before anyagent/*label. Changing that order re-introduces the "ticket opened a PR but a staleagent/needs-infoclosed the issue" bug. -
A "Created PR #N" comment can point at a dead attempt. The comment fallback must fetch the candidate and skip
closed+!mergedPRs, orstate.pris set to a PR nobody can merge. The check fails open when the fetch itself fails. -
A native COMMENT review is a valid verdict. Because the PAT owner cannot approve their own PR, the agent's approval can land in the review stream instead of issue comments;
getAgentReviewVerdictreads both. Removing the fallback stalls approvals that GitHub redirects to COMMENT. -
A cancelled CI run is not a heal trigger. Only
failure/timed_outare failures; otherwise cancelling a stalled boot restarts the pipeline on a branch with nothing to fix. -
review_in_progressis the single re-review mutex;review_pending_ciis its parked counterpart. A prompt is posted exactly once, and only when CI is green. Without the pair, a green CI run and a completing review race into two concurrent reviews, or a red-CI ticket burns its retry budget on wakeups that post nothing. -
The merge gate checks CI before budget. A red-CI PR must never reach
HUMAN_REVIEW, because the only exit fromHUMAN_REVIEWis a human approval and nothing wakes the runner up again. -
The state block lives in a body humans edit. Any full-body rewrite destroys it;
recoverLostStaterebuilds it from an existing PR rather than stalling. - Per-category diff budgets, not an all-or-nothing test allowance. A production fix with its own regression test no longer has to fit both caps at once.
-
An empty changed-file list is within budget. Reporting it as over-budget routed an empty diff to
HUMAN_REVIEWon a lie. - History is capped at 200 entries because the issue body has a 65536-character ceiling; a persistently red PR would otherwise make the state block unwritable.
-
Merge confirmation is not optional. A
204or an unparseable body means "check the PR", not "it worked". The regression tests assert that an unconfirmed merge must not be reported as success. -
Slash commands are never reports.
isTriggerCommentis what stops the review prompt (which quotes both verdicts) and the triage request (which contains## Triage) from being classified as agent output. -
Refusal is matched by heading, not by prose — everywhere. The gate and the label decider now share
isRefusalCommentfromreport-signals.js. A per-file copy drifted once and silently stalled six tickets. - A test that asserts a known defect is a blocking finding. It ships green, cements the bug, and forces the eventual fix to rewrite it. See the S8 section above.
-
--turnsis manual-only. Auto-start usesDEFAULT_MAX_TURNS = 7; the old hardcoded 3 is gone. -
/runis matched by prefix. GitHub Actions does not interpret\n/\rin a single-quotedif:, so listing them drops multi-line comments entirely. -
A manual
/runis a deliberate bypass of every auto-guard except PR/orchestrator — but on a REVIEW ticket with red CI it parks instead of re-prompting. -
Triage is read-only by permissions, not by prompt.
contents: readand noid-tokenmake a push impossible even if the agent tries; the prompt's "no branches, no commits, no PRs" is defence in depth. -
An anchored
/oc <verb>is not a triage request. A comment that already chose a non-triage verb is exempt from the Triage gate even if its prose later quotes/oc triage; the workflowif:andtriage-trigger.jsmust stay in sync. -
A failed preflight is
agent/blocked, notagent/failed. The action release endpoint being unreachable is not a work failure; the preflight branch is evaluated after a PR-creation report but before the failure branch. -
.gitmust stay writable under lockdown.chmod -R a-w . && chmod -R u+w .git— without the second command the action and the branch cleanup cannot run. -
Workflow run names are load-bearing.
ticket-runner.jsextracts the issue number fromTriage #123 - titleindisplay_title, so renaming the workflow breaks auto-start. -
agent/in-progressis never added by a workflow. The skill adds it viagh issue edit;.github/AGENTS.md:204claims otherwise. It is still consumed as a busy flag byauto-triage.yml,ant.yml heal,postCiFixOnceand the orchestrator. -
CLOSE_KINDSis effectively dead code — reachable only afterdecideAgentLabelreturnedagent/investigated. -
Off-by-one across components.
auto-triage.ymlre-triages whiletriageCount < 3;ticket-runner.jsblocks auto-start atcount > 3, so 4 triage passes neither re-triage nor auto-start. -
All text is US-ASCII. The only exception is the em dash (
—, U+2014) in theopencode.ymlrun name..github/AGENTS.mdrenders it as a plain hyphen.
- GitHub-Actions-Workflows — Parent hub: every workflow file, trigger, and the CI/boot pipeline
-
Agent-Factory-Controls — Role models, capability-based compare route, base-currency guard and
mergeSubject -
Testing — The JUnit and boot verification that the
ant.ymlpipeline runs and thathealreacts to -
Build-System — The
cd-x86-combined-lite regression-testsbuild the CI and agent workflows execute - Code-Conventions — US-ASCII encoding rule enforced across the automation files