Skip to content

factory: WorkAF r8 engine fixes — finished-before-quit run, outcome note by meaning, nothing to change - #2518

Merged
santoshkumarradha merged 3 commits into
factory/general-intakefrom
fix/workaf-r8-engine
Nov 8, 2026
Merged

santoshkumarradha merged 3 commits into
factory/general-intakefrom
fix/workaf-r8-engine

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

Engine fixes from WorkAF live e2e round 8 (~/factory-e2e/workaf-ab-r8/SUMMARY.md).

1. A run that finished just before ⌘Q came back "Runner went offline mid-step" (job 77)

Cause: the run ended 17:18:25.7Z and its end + PR were on the job, but follow was still in its post-end drain (a context.Background() wait of up to 15 s) when the quit came. The hold then expired and lease.queueJob stamped machine_lost (Manual → no retry).

  • factory.AgentFieldRunOwed: an AF run that ended while its step is still running, started no earlier than the step's round, is owed a reader, not a failure. queueJob queues it with no failure.
  • factoryrun.Job.Continuing (set by the loop for the round a restart revived): afRemote.Step reads that ended run's outcome (PR, words) instead of dispatching a second run. A fresh round (Run again / Try again) still dispatches.
  • The drain is now bounded by the reading's ctx, so a closing engine is never held by it.
  • Tests: TestTheRoundARestartPicksUpReadsItsRunsEndInsteadOfStartingAnother, TestRecoveryARunThatEndedThisRoundIsReadNotLost, TestTheDrainAfterARunsEndStopsWhenTheEngineCloses. TestRecoveryAnEndedRemoteRunIsStillAnInterruptedStep narrowed to a run that ended before the round began.

2. Failed build headline was the finalize note (job 84)

afOutcomeNote now uses factory.AgentFieldTellingNote: notes ranked by meaning (no PR opened / empty change > any failure > progress), newest within a rank. No pipeline or step names. Test uses r8's exact note order (finalize 8 ms after "No pull request").

3. A run that changed nothing ended "shipped" silently (job 79)

Detected generically from the run's notes/summary (No commits between|ahead, changed nothing, nothing to commit…). The step ends done (not a failure), output Nothing to change: the run made no changes, so no pull request was opened.

4. Quit with jobs running: "local factory took 10s"

Cause found: the 10 s is appLocalStopWait. The runner loop could not finish because a step stayed Running after Withdraw: the AF drain above (job 77 was in it at ⌘Q). Each job's letGo waits StopWait (5 s) and settleAccounting up to 5 s more, which is exactly 10 s. With the drain cancelled, AF steps release at once. AF runs keep going on the control plane. Native turns stop as before.
Not done here: an explicit lease hand-back at quit. Leases still expire into the queue, so restart re-takes them in about 1 min. That path is the "mac idle CPU" lane's held-job/lease area, and there is no worker done-state for "let go, still running". Conversation close (6.9–16.9 s in r8) is separate and not touched. Not measured on a mac in this PR.

5. Low

  • Readiness line: "Final review passed on commit 23ba8fc." (7 chars), and the log line reads "reviewed commit ".
  • revive no longer says "resumed" when the job only waits on an AgentField approval or has no step left.

Manual: factory-agentfield.md (restart after a finished run, how the outcome note is chosen, new "an AgentField run that changed nothing" section) and factory-stage-conversations.md.

🤖 Generated with Claude Code

… notes by meaning; nothing-to-change reads so

- An agentfield step whose run ended while the step was still running (quit
  seconds after the run finished) is no longer stamped machine_lost: the
  lease queues it, and the round a restart picks up (Job.Continuing) reads
  the run's end as the step's instead of dispatching a second run.
- The post-end drain is bounded by the reading's context, so a closing
  engine is not held for afStopDrain.
- The outcome note is chosen by what it says (no pull request / empty change
  > failure > progress), not by being newest.
- A run that changed nothing ends done with state_presentation
  "Nothing to change" and its detail sentence, not shipped silently.
- "resumed" is not said when a revived job only waits on an AgentField
  approval; the readiness line shows a 7-char commit.
@santoshkumarradha
santoshkumarradha merged commit 5a4402f into factory/general-intake Nov 8, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the fix/workaf-r8-engine branch November 8, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant