Skip to content

WorkAF build_issue, native plan review and the fence; plain builds unchanged - #180

Merged
AbirAbbas merged 36 commits into
mainfrom
feat/workaf-build-issue
Nov 9, 2026
Merged

AbirAbbas merged 36 commits into
mainfrom
feat/workaf-build-issue

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Lands the WorkAF work (originally proto/workaf) in the Go port: a build_issue reasoner, plan review and questions that work without hax, a fence for codeaf runs, and stricter build rules. For a plain build with no new switch set, behaviour is the same as main, with two exceptions listed below.

What WorkAF gets (through build_issue, or on a node with the switches on, which go/deploy/workaf-proto/swe-node.sh sets):

  • build_issue: one GitHub issue turned into a reviewed build that ends in a PR, with plan review on and the plan carried on the control-plane pause.
  • SWE_FENCE=1: every codeaf run is fenced to its build's own folder, fail-closed.
  • SWE_STRICT_BUILD=1, or always under build_issue:
    • a zero-change run opens no PR;
    • the project's own build and tests gate the run;
    • finalize may remove only what the run created.
  • Under build_issue, a build that fails verification opens no PR.

What stays exactly as on main for plain builds:

  • no fence;
  • a zero-change run still reaches the PR step;
  • no project gate;
  • finalize unguarded;
  • a build that completed some work and failed verification still pushes and opens its PR with its debt;
  • a repo_url workspace is kept after an error, a cancel or unpushed work, so resume_build finds its checkpoint (it is removed after a published or no-change build; SWE_KEEP_WORKSPACES=1 keeps it always).

The two exceptions:

  • The SDK is the released github.com/Agent-Field/agentfield/sdk/go v0.1.146-rc.25, with no replace (the branch pointed at a local checkout). The SDK ref used by the Dockerfile, Makefile and CI moves with it.
  • A HAX-only plain build fails fast when HAX errors, which is main's behaviour. The branch's fallback to a control-plane pause runs only with plan review or SWE_HITL_NATIVE.

Also on for everyone, as pure fixes with no switch: acceptance-check repairs (a malformed go doc check, or a working-tree check judged against the base), and skipping empty --no-ff merges for branches with no diff.

Proposals: turn these on for everyone

Each is behind SWE_STRICT_BUILD today. Each would be a one-line default change in config.StrictBuildEnabled if we decide to make it the default.

  1. No PR for a zero-change run. A run whose branch changes no files against its base opens no pull request and says "No pull request: the run made no changes". On main it can open an empty PR made of empty commits, which is never useful.
  2. The project's own build and tests gate the run. After verification, the target repository's own build and test commands run. A failure that is not already on the base fails the build. Missing tools are skipped, and failures already on the base are exempt. On main, a build can pass verification while breaking the project's own tests.
  3. The repo-finalize guard. Finalize may remove only what the run created, and a pre-existing tracked file it deletes or edits is restored. On main, finalize can delete a repository's own dotfiles or configs.

Validation

  • cd go && go build ./... && go vet ./...
  • The plain-build default, one test per behaviour, written from that contract:
    • TestZeroChangePlainBuildReachesPRUnlessStrict, TestFastBuildZeroChangeGatedByStrictSwitch, TestGitHubPRZeroChangeGatedByStrictSwitch
    • TestProjectGateSkippedOnPlainBuildUnlessStrict, TestFastBuildProjectGateGatedByStrictSwitch
    • TestFinalizeGuardGatedByStrictSwitch
    • TestFenceSwitchIsOptInAndOffByDefault
  • The rest of the contract: TestApprovalHaxErrorFailsFastUnlessPlanReviewOrNative, TestPlainBuildPartialFailedVerificationPushesAndOpensPR, TestAFailedBuildOpensNoPullRequest, TestDerivedWorkspaceCleanup
  • CI: go test -race -count=1 ./...

Behavior Impact

  • Backward compatible behavior change

Plain builds keep main's behaviour except for the SDK bump and HAX-only failing fast. build_issue and the two switches are new.

Notes

  • Merging to main redeploys the Railway SWE-AF service, which runs the Python swe_af (python -m swe_af) from the root Dockerfile. This PR changes only go/ and CI, so that service's behaviour does not change; the redeploy restarts it.
  • build_issue's question-carrying pauses and the watched codeaf harness need AgentField v0.1.146-rc.25 or later on the control plane.

🤖 Generated with Claude Code

build_issue takes one GitHub issue as a WorkAF job holds it (title, body,
repo_url or repo_path, base_branch, issue_number, issue_url) and runs build
to a pull request that closes it, with plan review always on.

The plan gate no longer needs HAX_API_KEY: every round pauses on the
control plane with kind plan_review, a one-line question and the whole
plan as markdown (goal, deliverables, acceptance checks, design, every
planned change with its files and checks, and their order). Request
changes feeds the person's words to the architect, re-plans and asks
again with a fresh id; reject stops before any code. With hax configured
the same round also files hax's plan-review-v2 and carries its id.

ask_user forms pause the same way (kind question, fields in the body)
when SWE_HITL_NATIVE is on; the person's words come back as the answer.

go.mod points at the proto/harness-watch SDK checkout (prototype only).
deploy/workaf-proto/swe-node.sh runs the node link only on dumb with
SWE_PRO_ENGINE=0, SWE_DEFAULT_RUNTIME=aforge, AGENTFIELD_AFORGE_COMMAND=exec.
Live on 2026-11-07, issue #83 ended with no pull request: codeaf refuses
an unattended run's push of a branch it did not cut, and run_github_pr is
that run. The orchestrator now pushes the integration branch itself, and
opens the PR with gh when the role still reports none.

The same run built the FIRST plan after the person asked for changes:
the re-plan reran the architect, tech lead and sprint planner but kept
the first plan's levels and issue files, and the PRD the verifier checks
never heard the words. A revised plan now recomputes levels, sequence
numbers and file conflicts, rewrites its issue files, and carries the
person's words as a PRD acceptance check.

deploy/workaf-proto: the node script writes its own secrets; fire-issue.sh
dispatches an issue to build_issue; answer.sh reads and answers the pause.
The desk lane read run 1's revised plan and found it contradicting itself:
the design did what the person asked while Must have and the checks still
described the plan they sent back, because a revision kept the first PRD.
A revision now re-runs the product manager with the person's words as
context that overrides the goal (keeping the earlier PRD if that fails).

The plan body drops the planner's own rationale, which cites documents
the person never sees, and the answer list, which every door draws itself.
The plan body leads with the person's words and one line per request on
how the plan changed, then a Summary of at most twelve lines (what
changes, each file and why, the tests, what it will not change, risks),
then Details with the full substance. Planner text loses machine paths,
HTML comments and references to documents the person never sees, and
every revision number comes from the gate's one counter.

A revised plan is held to the person's words by a deterministic check:
a file they said to leave alone may not be touched or mentioned except
as left alone, and a thing they named must be in a planned change and in
the requirements. A revision that fails is re-planned once more, told
exactly what still contradicts; what remains is shown above the summary.

Every reasoner carries a short display label as a label:<text> tag
(Plan, Review plan, Set up repo, Code · <task>, Open PR …).
build_issue takes issue_number as 83 or "83", and drops HTML comments
from the issue body.
Run 3's first plan listed TestTotal and TestEntriesIsACopy under "Tests it
adds"; they already exist. The summary now leaves out every test function
already in the repository's _test.go files.
Run 3 flagged "README.md … and every other file untouched" and a
`git diff -- README.md` check as contradictions: the check now needs an
editing verb before the file and no left-alone wording on the line. The
gate's recheck notes reached the requirements; only the person's words do
now. Cleanup no longer touches code spans (it had made `go test./...`),
and an "AC6:" label leaves no stray colon.
The sprint planner now returns approver_summary: one or two plain sentences
of what changes, each file with its own purpose, the new tests, and short
complete phrases for what is left alone and what could go wrong. The plan
body's Summary renders from it, falls back to the plan's other parts when a
model skips it, still drops tests the repository already has, and never cuts
an entry mid-word: a long one shortens to its first sentence or clause or is
left for Details.
The architect names components "C1 — Ledger.Len (root package ledger)" and
then cites them as C1, C2, C3. Stripping the ids as references left
"implemented in order → →" and a bold component name of "— Ledger.Len" in
the live plan of 2026-11-07, so each id is now replaced by its component's
short name before references are stripped.
The live round-1 Summary of 2026-11-07 cut inside a code span ("`*…;"),
leaving an unclosed backtick that turned the rest of the Summary into code.
A shortened phrase must now close every span it opens, and every clause
boundary is tried, not only the first, so a separator inside code is passed
over.
From the live round 2 of 2026-11-07:
- "Also add a table test" was read as replace: two tests the person had
  seen were dropped. The gate now keeps the tests and files of the plan it
  sent back. An additive request (also, as well, in addition…) with no
  replace word is held to keeping those tests and is re-planned once more if
  it does not.
- "How the plan changed" lists tests and files gained and lost instead of
  saying only "sent to the planner".
- The build's own records (.artifacts/…) are no longer cited to the person;
  the approval file is said as "your review".
- Paths inside code are kept, because a command must still run ("> the
  repo" broke one); only a home directory is shortened to ~/.
- A decision written as a bullet no longer renders as "**- …**".
Workspaces outlived their builds, cancelled or finished. Live on 2026-11-07
a build for issue #184 read a cancelled build's plan for #83 in the next
directory and planned around it. A workspace the build derived from
repo_url is now removed on return; SWE_KEEP_WORKSPACES=1 keeps it.
Builds on one node sit side by side under one workspace root, and nothing
in codeaf 9b0b7d189 keeps an unattended run in its own: a chat run is
host-bound (no jail), the jail fences writes only, and the file tools take
any absolute or ../ path. Live on 2026-11-07 a build for issue #184 planned
around a plan for issue #83 that it read one directory over; across two
customers that is one customer's plan in the other's pull request.

The whole codeaf process now starts inside an operating-system fence that
hides the workspace root except the build's own folder: seatbelt on macOS,
bubblewrap on Linux. harnessx points the codeaf harness at the node binary,
which is its own launcher, and each call's environment names its build's
folder. It covers codeaf's file tools and its commands alike. A fence that
cannot apply refuses the run; SWE_FENCE=off is the explicit opt-out.

TestBuildACannotReadBuildB proves it through the real launcher: build A
reads and writes its own folder and cannot read, list or write build B's,
by absolute or relative path. It passes under seatbelt on macOS and skips
where bubblewrap cannot make a namespace.
The verifier runs before the pipeline opens the pull request, so a
criterion that a pull request exists fails every good build: live on
2026-11-07 a build reported failure on "no pull request exists" a minute
before its own pipeline opened PR #185. The issue goal now says the
pipeline opens it and that no acceptance criterion may require it.
From run 06 of 2026-11-07: a criterion cited by number is said as "a check"
(or by its name: "the allocation gate check") instead of leaving "mitigated
by and the explicit statement"; summary phrases join without ".;"; and a
colon is no longer a place to shorten a phrase, because what follows it is
usually the point.
Run 07 of 2026-11-07 still said "(.artifacts/, .agentfield-out-*/)" in its
checks, because the record pattern wanted a space before the path.
swe-node.sh clean left the three mode-600 key files and the shipped codeaf
binary on the node box.
Run 4 of 2026-11-07: asked to "also make the TestLen zero-allocation check
its own test named TestLenDoesNotAllocate", the planner added the new test,
KEPT TestLenNoAllocations, ruled removing either out of scope, and wrote a
risk telling maintainers not to delete the duplicate.

- The additive gate now holds only a sentence that ADDS (add, include,
  cover…) and reshapes nothing. "Also" alone is not additive, and a test
  that a reshaping sentence (its own, rename, move, split, replace…) names
  or stems from is never held in place.
- A revision is also checked for two new tests that check the same thing,
  and for Out of scope, Risk or Summary lines that exist only to protect
  such a leftover. Either sends it back to be re-planned once more.
- A revised plan is named by the note that produced it ("revised after your
  first note"), never "(revision 1)", which read as the first plan.
Run 4's Details were run-on blocks, each led by an ALL-CAPS phrase ("THE
DELTA IS THREE FILES…", "SCOPE BOUNDARIES."). The product manager and the
architect are now asked, in their task prompts, to write the description
and the design summary as two to five short sections under sentence-case
headings. A lead that is still shouted is rendered as a short sentence-case
heading over the text that followed it.
demoteHeadings prefixed five marks onto every planner heading, so the
"###" sections job 70's planner wrote inside a detail became "########",
which markdown does not read as a heading and the desk drew as literal
text. The shallowest heading in a block now lands at five marks, deeper
ones keep their offset below it, and nothing goes past six.
fenceCodeAF points the harness at this binary as the launcher, and the SDK
reads provider "aforge" with a bin path of its own as a pin on the legacy
aforge binary (its contract F1). That ran `codeaf exec --json -w`, which has
no --events or --steer, so in job 70 every fenced step lost its live chat,
its steer and its questions for the person; SWE_FENCE=off brought them back.

A fenced run is now named "codeaf": the SDK builds the codeaf provider with
the launcher as its binary, and a watched run is `chat --once --events
--steer --session` through the fence. A real binary that is itself the old
aforge keeps the old name. The SDK's pin stays as it is: it is a tested
contract for real aforge binaries, and only SWE-AF knows its launcher fronts
codeaf.
Three faults in job 70's plans (2026-11-07):

- The Summary was written one line after another, so "**Tests it adds:**"
  directly under the Files list was a lazy continuation of its last item,
  and "Will not change" and "Risks" ran on into the same paragraph. Each
  field is now its own paragraph; only list items follow the line above.
- "Name the test TestNegativesCountsRefunds", said of a plan that added one
  test, was planned as a second test beside TestNegatives and labelled
  "reviewer-requested". A name given to "the test" (or "rename A to B") is
  now read as a rename: the planners are told so before the first revision,
  a revision that still adds both is sent back once more, and a renamed test
  is not reported as dropped from an additive request. The person reading
  the plan is the reviewer, so "reviewer-requested" reads "requested" and
  "the reviewer asked" reads "you asked".
- The first "How the plan changed" bullet repeated the note quoted right
  above it. With one sentence the line is only the outcome; with several it
  leads with a short quoted handle on the sentence it answers.
Job 76 of the second 2026-11-07 live run asked "name the test
TestRefundsSumsAbsoluteValues" of a plan adding TestRefunds,
TestRefundsEmpty and TestRefundsNone. readRenames read a rename only when
the plan added exactly one test, so the gate read nothing, held the
revision to "add, not replace", and the plan grew a fourth test.

Of several tests, the name now renames the one it extends (the longest
test name it starts with). When it extends none, any one test may take
the name, and adding it beside all of them is sent back. A renamed test
is excused from the additive check by its exact name, not its stem, so
renaming TestRefunds does not excuse dropping TestRefundsEmpty.
Live r3 (2026-11-07, job 73) renamed TestRefunds to
TestRefundsSumsAbsoluteValues, and the revision said four times that no
TestRefunds may survive. With no look-alike pair among the planned tests,
protectsLeftover counted any line saying "duplicate", so each removal line
was listed under "Not reflected yet" as protecting a duplicate. A line that
names tests, none of which the plan adds, now cannot protect a leftover.

The revised plan also said "revised after your first note" in both the
question and the body heading the desk shows under it; it is now said once,
in the question.
Seatbelt's subpath deny covered the workspaces folder itself, so git's
path canonicalisation failed with 'stat …/workspaces: Operation not
permitted' and the coder for issue #221 could not commit (r4, S3). The
root is now stat'able but never listable, and when a worktree's gitdir
lives outside the build's folder the fence opens the shared git dir and
that worktree's own gitdir only, after checking git's back-link.
Issue #221's run ended 'OVERALL FAIL' and the PR phase still pushed the
integration branch and opened PR #227 carrying only .gitignore (r4, E9).
The push-and-PR phase now runs only when verification passed.
Job 77 (issue #265 -> PR #275, WorkAF r7): the cleanup agent read the
repository's own .codeaf/factory.yaml as a "pipeline leftover", deleted it
in "chore: finalize repo for handoff", and the app's Merge put the deletion
on main.

The finalize role now records HEAD and the run's base before the agent runs,
tells the agent which tracked files the run created (the only ones it may
remove) and that tracked dotfiles and config dirs are never leftovers, and
after it runs puts back in code every path it deleted that existed at the
base and every edit to a file other than .gitignore. The restoration is
committed, noted under repo_finalize/restored, and reported as
files_restored (not in the agent's schema). With no base_ref the guard uses
the merge base with origin's default branch, else HEAD itself, which
protects every tracked file.
Issue #269 -> PR #278 (WorkAF r7): after the person answered the planning
question the planner rewrote every acceptance criterion as a text match,
the verifier passed them, and a module that does not compile shipped. The
same request worded "checked by running the commands" (#279) failed
correctly, so whether the build ran depended on the issue's wording.

New package projectcheck detects the repository's own commands (go build
./... and go test ./... from go.mod; cargo build/test; npm run build and
npm test when node_modules is present) and runs them after the verifier, in
code, outside the plan. A failure sets verification passed=false, adds a
failed criterion with the command's output (so the fix cycle sees it) and
leads the summary, and the existing publish gate then opens no PR. A
failure the run's starting commit shares is noted, not blamed on the run;
a missing tool or an unchanged tree skips the check and says so. Wired into
both the full build (per repo for multi-repo) and the fast build.

Both builds also pass base_ref to run_repo_finalize so the finalize guard
compares against the commit the run started from.
… one

WorkAF r5-r7: the ask_user body closed with "Answer in your own words with
**request changes**, or **approve** ... **Reject** ..." under a card whose
controls are the choices, In my words... and Skip, and printed the default
as its raw value ("default: stdlib_crc32", "default: provide_module").

The closing line now reads "Pick one of the choices, or answer in your own
words. Without an answer it goes on with its own judgement." (or the
free-text form of it), and a default is the field's "  - suggested:" line
spelled as the label of the choice it names; a default naming none of the
choices is left out.
… rename is not a duplicate protected

Live r7 (job 267): after one note, "Name the test TestRefundsSumsAbsoluteValues",
the plan body said "The plan was revised twice" and listed under "Not
reflected yet" the assumption that confirmed the rename. The count was a
literal; it now counts the person's notes. protectsLeftover, with no
look-alike pair in the plan, no longer holds a line that names a test the
plan does not add (the removed name), nor one that says there is no
duplicate.
Issue #291 (WorkAF r8): the planner wrote `go doc ./ ledger.Ledger.Checksum`,
which the Go tool rejects for every implementation ("doc: too many periods in
symbol specification", exit 2). The verifier failed a change that built, passed
its tests and had the method; the fix cycle could only record it as debt, and
no pull request opened.

New package critcheck. After the verifier answers, every failed criterion that
names a check command (go doc/vet/build/test/list, cargo, npm test/run, grep,
rg, test, pytest; no redirection or substitution) is re-run in code. When the
tool's own output is a usage or syntax error rather than an assertion, the
criterion is malformed: a known deterministic repair is tried once (the Go
symbol form drops the package segment, `go doc ./ Ledger.Checksum`) and the
criterion is judged by the repaired command; otherwise it is marked not counted
with a note. A command that runs and fails stays failed, and verification
passes only when no failed criterion remains. The pass runs before the project
build/test gate, whose criterion now carries project_check and is never
reconsidered, so a red build still fails the run.

Before work starts, FixPlan respells the refused go doc form wherever a plan
carries acceptance_criteria (PRD, issues, fast tasks), without running
anything. The PM, sprint planner and fast planner prompts carry one shared
rule (critcheck.PlannerRule) spelling Go symbol checks `go doc <pkg>
<Type>.<Method>`; their goldens are updated for it.

Wired into both the full build and the fast build, with notes under
verify/criterion_check (repaired, not_counted) and plan/criterion_check
(respelled).
santoshkumarradha and others added 6 commits November 8, 2026 15:54
…udged against the base

Issue #309 (WorkAF r9): HasZero was already on main. The coder made an empty
"verify" commit and the level merge an empty --no-ff merge, so the integration
branch was two commits ahead of main with main's tree, GitHub's "No commits
between" never fired, and PR #315 opened with 0 files claiming to add HasZero.

New package nochange compares the branch with the base by what it changes
(three-dot diff against origin/<base>, <base>, then the run's starting commit).
A branch that changes no file is not pushed and opens no PR: the full build
(single and multi-repo), the fast build and the run_github_pr role itself all
check, and the run ends with the plain note "No pull request: the run made no
changes", which the factory reads as the outcome. Unknown (no branch, no base)
publishes as before. The fast merge no longer records a --no-ff merge for a
branch that changes nothing, and the coder prompt forbids empty commits.

Issue #306 (WorkAF r9): AC-6 expected `git status --porcelain` to list
ledger.go and ledger_test.go after they were committed, which fails for every
implementation; correct work failed verification and no PR opened.
critcheck.ReconcileFrom generalises f4d5b19's repair: when the tracked tree is
clean and the work is committed on top of the run's base, a failed check that
reads working-tree state (`git status`, a `git diff` with no base, --cached) is
rewritten to compare with the base (`git diff --name-only <base>...HEAD`). It
is judged by exit status when it asserts with one (pipe, --quiet, !), else by
the files the criterion names: required before a negation, forbidden after.
A criterion naming no file is not counted, with the committed file list as
evidence. A named file the work did not change, or a forbidden one it did,
still fails; uncommitted work and runs with no base are left to the verifier;
the project build/test gate is still never reconsidered. The shared planner
rule now forbids working-tree checks; goldens updated.
The branch built against a local SDK checkout through a replace directive,
so it built nowhere else. The harness-watch SDK (pauses that carry their
question, the watched codeaf harness) is now released as
sdk/go/v0.1.146-rc.25. go.mod requires it with no replace, and the SDK ref
the Dockerfile, the Makefile and CI sparse-clone moves with it, as the
go.mod comment asks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fence refuses a codeaf run it cannot set up: on Linux without bwrap,
in an unprivileged container (how cloud nodes run) and on Windows. On by
default, it broke plain builds that main runs fine. SWE_FENCE, which was
an opt-out, is now the one opt-in switch: truthy fences every codeaf run
fail-closed as before; unset or false runs as on main. WorkAF's node
script sets SWE_FENCE=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the hax request failed, every build fell back to a control-plane
pause, so a plain build with only HAX behind it waited on a question
nobody would answer instead of failing as on main. The fallback now runs
only when the caller asked for plan review or native pauses are on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A build that changed nothing still opens no pull request, for everyone.
Withholding the push and the pull request when verification fails is now
build_issue's rule (no_pr_on_failed_verification, which it sets): a plain
build that completed some work and failed verification pushes and opens
its PR with its debt reported, as on main.

A repo_url workspace is removed after a build that published its work or
had nothing to change, and kept when the build errored, was cancelled or
left unpushed work, so resume_build still finds its checkpoint.
SWE_KEEP_WORKSPACES=1 keeps it always.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pt-in

Three behaviours from the WorkAF work still reached every plain build: a
run that changed nothing opened no pull request, the project's own build
and tests gated every run, and finalize was held to removing only what the
run created. With them on by default, a plain build did not behave as on
main.

SWE_STRICT_BUILD (config.StrictBuildEnabled, the one reader) turns all
three on. Unset, a plain swe-planner.build, swe-fast.build,
run_github_pr or finalize behaves as on main. build_issue, WorkAF's new
entry point, sets strict on its own input and threads it to the PR and
finalize steps, so it always gets all three. WorkAF's node script sets
SWE_STRICT_BUILD=1 beside SWE_FENCE=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AbirAbbas AbirAbbas changed the title WorkAF build_issue, native plan review and the fence, safe for plain builds WorkAF build_issue, native plan review and the fence; plain builds unchanged Nov 9, 2026
@AbirAbbas
AbirAbbas merged commit 58cae11 into main Nov 9, 2026
4 checks passed
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.

2 participants