Skip to content

fix(software-factory): run 3's operator follow-ups (approval already given, adopt's stale comment, up survives SIGHUP) - #1113

Merged
blove merged 1 commit into
mainfrom
blove/factory-run3-followups
Oct 27, 2026
Merged

blove merged 1 commit into
mainfrom
blove/factory-run3-followups

Conversation

@blove

@blove blove commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Three small items from the software factory's live runs, all in examples/software-factory/controller. No changeset: this is an example package.

1. review --approve answers "Nothing to review" after a successful intake approval

The journal for wo-9409eea3d48a98ab (2026-10-21) holds one approve_intake command, and the following run dispatched 250 ms later. A review --approve --digest sent while that approval was in flight already prints the route's outcome; a new CLI test (dispatching the moment the row reads received) passes on main too. The refusal comes from the other order: the approval lands, the row moves on to running, and then review --approve --digest <same digest> reads a row that is no longer parked.

reviewOutcome now checks the journal before refusing. If an approve_intake transition for exactly that digest is there, it answers with that approval: ok: true, state: received, message: "Intake approved", exit 0, and the row as it reads now goes under row. A stderr line says when the approval landed. Any other digest still gets "Nothing to review". Tests cover both orders.

2. adopt leaves a stale comment above the rewritten import

promoteCheck now also matches a contiguous run of // lines directly above the await import(join(process.cwd(), "<pkg>/dist/…")) statement. When the run mentions dist, built or process.cwd, it is dropped with the statement; any other comment stays where it was. The test covers the comment #1066 kept, a multi-line run, and a comment that stays.

3. up dies when its terminal is reset

pnpm relays only SIGINT and SIGTERM to its child. Its signal-exit re-raises SIGHUP on itself and relays nothing, so up gets SIGHUP only from the terminal's foreground process group. stopOnSignals now registers a SIGHUP listener that only logs "ignored" and how to stop up. The children were already detached, and up's output already survives a dead terminal (lineWriter, <state>/logs/up.log).

New factory down: it reads <state>/up.lock (the lock already records up's pid and command line), sends one SIGTERM (up's ordered stop), and waits up to 90 s for up to exit. It acts only on a held lock: the pid must be alive and still show up's command. It never kills.

Tests: unit tests for the handlers and for down (held, stale, reused pid, not a lock, outlasting the wait), and a real-process test where the group gets SIGHUP, the process survives, and SIGTERM then exits 0. A CLI test covers down with no lock and with no state directory. The README documents both. The rung-4 spec's §14 gets a "landed after" note.

The --detach/setsid variant was not needed for SIGHUP. If a host ever kills the terminal's group with SIGTERM or SIGKILL instead, that, or the restarting supervisor, is still the follow-up.

Verification

  • pnpm --filter @b4-example/software-factory-controller typecheck: passes
  • pnpm lint: 31/31
  • pnpm --filter @b4-example/software-factory-controller test: 1420/1421. The one failure was test/runtime.test.ts › "dispatches to the one builder on its route…" (dispatch refused on the cli-flags image under full-suite load). That file isn't touched here, and it passed 4/4 rerun on its own.

Also filed from the same hunt, not fixed here: #1112 (load-env.ts).

🤖 Generated with Claude Code

…dy given, adopt's stale comment, up survives SIGHUP

- review --approve --digest that finds the row past the gate answers with the
  intake approval the journal holds for that digest (ok, received, "Intake
  approved", the row as it reads now) instead of "Nothing to review"; a
  `run` following the work order dispatches the moment the approval lands
  (wo-9409eea3d48a98ab, 2026-10-21).
- adopt drops a contiguous `//` run directly above the rewritten built-module
  import when it mentions dist, built or process.cwd (#1066 kept one).
- up ignores SIGHUP, so a terminal that goes away no longer stops the
  factory; `factory down` stops it by the pid <state>/up.lock records (one
  SIGTERM, up's ordered stop) and waits for it to exit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
b4-run Ignored Ignored Preview Oct 27, 2026 2:40am UTC
navlog-web Ignored Ignored Preview Oct 27, 2026 2:40am UTC

Request Review

@blove
blove enabled auto-merge (squash) October 27, 2026 02:41

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for repository bookkeeping. The maintainer reviews and merges this PR.

@blove
blove merged commit 88adb1b into main Oct 27, 2026
31 of 32 checks passed
@blove
blove deleted the blove/factory-run3-followups branch October 27, 2026 03:11

This branch had an error being deployed

1 failed deployment
vercel-preview — 4e3f6d6a Deployed Oct 27, 2026 by blove via vercel-native #3244
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