build agent: language-agnostic rules against orphaned background processes #3
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
serious-devs/ai-factory#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #1 (finding 2). Three consecutive build runs were lost this way (test_factory_ai issue #3, runs 895 / 898 / 901) even though each implementation was correct.
Evidence
Every run followed the same pattern: the agent implemented the spec, its runtime smoke test PASSED (server answered
HTTP/1.1 200 OKwith{"test":true}), and then:Root cause (from the job logs):
npm start &—$!is the npm PID, not the node child;kill $SERVER_PIDkills npm; the node child survives, keeps listening and holds the shell's stdout/stderr pipes open;status null) → run failed, work lost.This is NOT node-specific: any wrapper toolchain (
mvn,gradle,cargo run,sbt,lein,uv run, …) spawns the real server as a grandchild with exactly the same result. The factory serves Java / Node.js / Rust / other projects, so the guard must be language-agnostic.Proposed change
glue/src/agents.ts— extend theBUILD_AGENToperating rules. That markdown block is where the agent's standing instructions live (buildBuildPromptinprompt.tsmerely says "Follow your operating rules"). Add, as hard rules:node --check,mvn -DskipTests compile,cargo check,python -m py_compile,go vet, …), linters, and in-process test harnesses (supertest, Spring Boot tests/MockMvc, axum::test, go httptest, pytest + httpx TestClient, …) — they cannot orphan anything.npm exec, the mvn-generated classpath, thecargo buildbinary undertarget/, …);>/tmp/srv.log 2>&1) — never leave them attached to the terminal pipes;curl/wget/nc);kill -9the exact PID, then confirm the port is released;timeoutguard so nothing can outlive the command.Keep the rules short and imperative — the agent demonstrably adopts explicit patterns (attempt 3 adopted the polling loop and
git check-ignorefrom a hint) but reverted on the one detail that mattered when the rule was left implicit.Deployment note
Same image-tag repin as the other glue issues (build a new tag, update the
agent-imagedefault in.forgejo/workflows/agent.yml); the image build runsnpm run checkitself.Acceptance criteria
BUILD_AGENTinglue/src/agents.tscontains the language-agnostic rule set (static/in-process first; direct executable + output redirection + exact-PIDkill -9+ timeout guard when a server is truly needed)mode=buildwith the new image → the run succeeds, the job log contains noshell tool terminated command after exceeding timeoutand noexited with status null, and the PR is opened/updated