Skip to content

factory: a runner notices a provider key that arrives after it started - #2596

Merged
AbirAbbas merged 1 commit into
devfrom
fix/2594-runner-sees-late-provider
Nov 11, 2026
Merged

AbirAbbas merged 1 commit into
devfrom
fix/2594-runner-sees-late-provider

Conversation

@AbirAbbas

Copy link
Copy Markdown
Collaborator

What this fixes

Fixes #2594. A desktop engine whose factory runner started before any provider key existed kept reporting needs_provider after a key was set, and queued work was never leased until the engine restarted. The worker read "what this machine lacks" once, when it attached.

The worker now asks before each lease poll and re-attaches when the answer changes, between jobs. There is still one place that decides the word (appFactoryHost.needs); no new lock, timer or goroutine.

Validation contract

  • B1. A runner that reported needs_provider stops within one lease poll of a key being set, with no restart, and work queued meanwhile is leased.
  • B2. When the only usable key is removed, the runner reports needs_provider within one poll instead of leasing a step that would refuse.
  • B3. Replacing a key while idle neither drops nor duplicates a lease, and a running step is not interrupted.
  • B4. A host with an injected parent never reports needs_provider.
  • B5. Close still joins everything it started.

cmd/codeaf/app_factory_provider_test.go has one test per B1–B4 through the real app wire, backend, local factory and worker, with an approval-only pipeline and a model endpoint that fails the test on any generation request. B1 fails on the unchanged code with runner state="needs_provider" … job state="queued".

What was driven by hand

The issue's replication on the built binary, over the app wire with a fresh home: the runner went from needs_provider to busy with the job leased 0.93 s after keys.set, in the same process. Found and reproduced three times in the live WorkAF loop before the fix.

Locally make test-laws is red only on internal/tui3 TestEveryPlaceTakesExactlyTheWholeFrameAtEveryWidth/AI_teams, which fails the same way on unchanged dev on the development laptop; this change touches no TUI code.

🤖 Generated with Claude Code

The worker attached with the word for what its machine lacks read once, so a
runner started before any provider key existed kept saying needs_provider
after keys.set, and queued work was never leased until the engine restarted.
The worker now asks before each lease poll and re-attaches when the word
changes, between jobs; a running lease is left alone. Removing the only key
brings needs_provider back the same way.

Fixes #2594

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@AbirAbbas
AbirAbbas merged commit 86a2069 into dev Nov 11, 2026
8 checks passed
@AbirAbbas
AbirAbbas deleted the fix/2594-runner-sees-late-provider branch November 11, 2026 16:18
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.

app: a provider key added after the factory is running leaves its runner at needs_provider until the engine restarts

1 participant