Skip to content

factory: AgentField run_on fixes from the live trigger test - #2533

Merged
santoshkumarradha merged 2 commits into
factory/general-intakefrom
factory/af-runon-fixes
Nov 9, 2026
Merged

santoshkumarradha merged 2 commits into
factory/general-intakefrom
factory/af-runon-fixes

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Fixes from the live AgentField trigger test of b726d4b (~/factory-e2e/af-triggers-live/SUMMARY.md). Three bugs are fixed. Bug 4 is documented, not changed. Bug 5 is not local to the engine.

1. A run_on job logged "waiting for a repository" — fixed

The inbox files the job and writes the waiting line before the routing table is read. Routing (intake.applyRoute) now removes that line (withdrawWaiting) once a rule gives the job a repository or a reasoner. Other activity rows are kept. A job filed with run_on already skipped the line.
Test: TestARuleThatRunsOnAReasonerWithdrawsTheWaitingLine.

2. A rule or step could run on this organization's own node — fixed

  • routeReasonersKnown (factory.routes_set) refuses run_on on the own node. The message reads: routing rule "<name>": that agent is this organization itself; pick another.
  • factory.pipeline_copy_set and factory.pipeline_pr refuse an agentfield step on the own node. The message reads: step "<name>": that agent is this organization itself; pick another. This check runs only on this machine's factory, which is the one that knows its node id. Node ids are compared without regard to case.
  • factory.agentfield_reasoners no longer lists the own node, so no picker offers it.

Test: TestTheOrganizationsOwnNodeIsNeverAnAgentToRunOn.

3. Waiting jobs were not routed when the runner started or the rules changed — fixed

appFactoryHost.routeSoon runs one intake pass in the background as a host chore. Close waits for it, and the store's intake lock stops it from overlapping another pass. It runs:

  • when the runner starts (startLocalRunner, which covers factory.local_run and its automatic start);
  • after factory.routes_set saves on this machine's factory.

Locks are released with defer. routeNow had no callers before this change; it is used now.
Test: TestWaitingJobsAreRoutedWhenTheTableIsSavedAndWhenTheRunnerStarts. It uses a poll source that never arrives, which is the no-watched-repo case. The test fails with routeSoon disabled and passes with it.

4. factory.local_run needs GitHub — NOT changed

This refusal comes from identity, not from publishing. The runner is a worker that attaches to the factory. serve.attachWorker refuses a worker with no handle: worker attach requires name and handle. On loopback it fills the handle from seam.PersonHandle, which is the GitHub login. That handle is used as:

  • the lease owner;
  • the owner a start rule gives a job (factoryIntakeOwned);
  • the person that "mine" matches against (e417c12).

FactoryLocalRun reads /v1/me first and refuses early, so the runner does not retry silently forever.

Starting without GitHub would take two things:

  1. a stable non-GitHub operator identity (a local person handle) that the worker attach, lease, job ownership and "mine" all accept;
  2. a refusal in words at publish and merge for a job owned by that identity.

That touches the worker and identity model, so it is out of scope for a fix lane. The manual now says plainly that the runner still needs GitHub, and that AgentField entries are filed while the runner is off and routed once it is on.

5. A furrow helper outlived shutdown — not fixed, cause not in the engine

Every furrow call the engine makes is a short-lived exec.CommandContext with WaitDelay (internal/furrow/furrow.go:540). The attach runs watch --no-daemon, and the engine starts no long-lived furrow child. A furrow with ppid 1 that survives the engine is a process furrow detached itself, for example a sealer or daemon started by one of its subcommands. The engine has no handle on that process. The evidence does not record its command line. Next step: capture ps -o pid,ppid,command for the leftover process on the next live run, then file the issue in furrow or fix the flag that leaves it running.

Manual

internal/manual/chat/factory-agentfield.md changes:

  • the own-node refusal for rules and steps;
  • an immediate routing pass on save and when the runner starts;
  • the waiting line is removed when a job is routed;
  • the runner still needs GitHub.

One probe was added to internal/manual/chat_test.go.

Proof

make pr-ready BASE=origin/factory/general-intake exited 0. TestMemoryPausedJobLifecycle/stop_tail failed once on a timing check (memory accounting differs) and passed on its retry. The classifier marked it flaky. It also passed -count=2 focused. The new runner-start pass returns at once in that test, because it has no rules.

2026/11/09 09:39:49 {"event":"memory_admission","stage":"assembly","total_runes":0,"pinned_runes":0,"budgeted_runes":0,"budget_runes":4800,"runes_by_semantic_type":{},"share_by_semantic_type":{},"budgeted_runes_by_semantic_type":{}}
2026/11/09 09:39:49 {"event":"memory_admission","stage":"conversation","total_runes":0,"pinned_runes":0,"budgeted_runes":0,"budget_runes":4800,"runes_by_semantic_type":{},"share_by_semantic_type":{},"budgeted_runes_by_semantic_type":{}}
--- PASS: TestMemoryPausedJobLifecycle (9.05s)
    --- PASS: TestMemoryPausedJobLifecycle/stop_tail (9.05s)
PASS
ok  	github.com/Agent-Field/codeaf/cmd/codeaf	9.091s
::warning::github.com/Agent-Field/codeaf/cmd/codeaf: TestMemoryPausedJobLifecycle/stop_tail: flaky
touched rest: ./internal/factory/intake ./internal/manual
+ make --no-print-directory -s test PKGS=./internal/factory/intake ./internal/manual KNOWN_RED= TEST_SKIP= TEST_FLAGS=-count=1 -p 2 SHARDS=8 TEST_TIMEOUT=15m
ok  	github.com/Agent-Field/codeaf/internal/factory/intake	3.652s
ok  	github.com/Agent-Field/codeaf/internal/manual	5.957s
Every selected test passed on its first run.

🤖 Generated with Claude Code

…ever an agent, waiting jobs route at once

A rule that routes a job withdraws the inbox's 'waiting for a repository'
line; a rule or an agentfield step on this organization's own node is
refused when saved and left out of factory.agentfield_reasoners; saving the
routing table and turning the runner on each run one routing pass.
@santoshkumarradha
santoshkumarradha merged commit 90acc68 into factory/general-intake Nov 9, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the factory/af-runon-fixes branch November 9, 2026 14:42
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