Skip to content

Factory: a job can wait on other jobs' merges - #2418

Merged
AbirAbbas merged 9 commits into
workstreams/mainfrom
workstreams/fx-sched-waits
Nov 5, 2026
Merged

AbirAbbas merged 9 commits into
workstreams/mainfrom
workstreams/fx-sched-waits

Conversation

@AbirAbbas

Copy link
Copy Markdown
Collaborator

A Factory job can wait on other jobs of the same factory: it stays in Backlog until every parent's pull request has merged, then becomes startable. A parent that fails or closes unmerged blocks it, with the reason on the job. The Workstreams plan, FX-SCHED step 2 (generic Factory terms only).

What changes

  • Job document (additive): WaitsOn, WaitingOn, WaitsReleased, Blocked {by, reason, since, job}. Job read: waits_on, waiting_on, blocked. The existing held boolean (a person's queue Hold), job state, can, and the needs-you kinds (contract 2) are unchanged: a blocked job stays in Backlog.
  • PUT /v1/jobs/{id}/waits_on sets or clears a Backlog job's waits (owner only, expect checked). Refuses unknown jobs, the job itself, cycles, parents that already ended unmerged, more than 20, and jobs that started or were released; nothing is written on a refusal.
  • Scheduler in the service (serve/waits.go): runs at start, after factory-folder changes (at most every 2 s) and every minute; persists waiting_on, sets or clears blocked, and releases a job once (activity line waits over: …). It never starts a job in this step. A person's Start on a waiting or blocked job starts it and its waits go inert.
  • Satisfied = PR merged, or shipped with nothing to merge. Blocked = parent failed (step, publish or merge failure) or ended unmerged (PR closed, dropped, closed locally, dismissed); a person's Stop on a parent is not a failure. Blocks clear when the parent is fixed.
  • Pick up issues skips jobs whose waits are pending (one condition).
  • /v1/about lists features: ["waits_on"].
  • App wire: factory.waits_set {factory, job, waits_on, expect?} (registered outside the job-action table: its list names parents, not jobs to act on) and factory.features {factory}; factory.capabilities.waits_on. A factory without the route answers conflict / factory_too_old.

Existing Factory files get only inserted lines: three Item/Job fields, one FromItem call, one intake condition, the scheduler's start/stop and route registration in serve.go, one about field, one capability field and two hello lines. No existing test edited.

Validation contract → tests

  • W1 ordering, partial waiting_on, release without a start → internal/factory/serve/waits_test.go
  • W2 refusals leave the job unchanged; merged parent accepted → serve/waits_test.go
  • W3 failed parent blocks, fixed parent clears, merge releases → internal/factory/waits_test.go, serve/waits_test.go
  • W4 closed unmerged / dropped / closed locally; brought back waits again → internal/factory/waits_test.go
  • W5 a person's Start through the run door overrides, waits stay inert after Stop → serve/waits_test.go
  • W6 replace, clear, cycles, started and released jobs → serve/waits_test.go
  • W7 restart keeps waits and releases later → serve/waits_test.go
  • W8 intake skips pending waits → internal/factory/intake/waits_test.go
  • W9 features, capability, older factory → cmd/codeaf/appfactory_waits_test.go, internal/appwire/factory_waits_test.go
  • W10 wire bounds before sending → internal/appwire/factory_waits_test.go
  • W11 read shape; held unchanged → internal/factory/api/waits_test.go

Next step (separate PR): group policies that start released jobs inside an allowance and hold runs past it.

🤖 Generated with Claude Code

AbirAbbas and others added 9 commits November 5, 2026 14:17
Jobs carry the jobs they wait on, the ones not yet satisfied, whether their
waits were released, and why a parent blocks them. A parent satisfies its
children when its pull request merges or it ships with nothing to merge; one
that fails or ends unmerged blocks them until it is fixed. The job read shows
waits_on, waiting_on and blocked; Pick up issues never starts a job that waits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PUT /v1/jobs/{id}/waits_on sets or clears a Backlog job's waits, refusing
unknown jobs, the job itself, cycles and parents that ended unmerged. A
scheduler in the service rechecks waiting jobs at start, after folder changes
(at most every two seconds) and every minute, and releases a job once every
parent is satisfied. It never starts a job; a person's Start ends its waits.
/v1/about lists the waits_on feature.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
factory.waits_set sets the jobs one job waits on, outside the job-action table
because its list names parents, not jobs to act on. factory.features reads what
a connected factory serves from its about answer. The engine's factory
capabilities say waits_on. An older factory answers factory_too_old.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts and resets

A closed issue ends its job unmerged; only a published no-change receipt
satisfies children without a merge. Intake re-checks pending waits under its
own admission lock. Parents the caller cannot read are refused as unknown,
and a parent in another repository is named only by its job number. A start
through the service retires pending waits at once, so a Drop and Bring back
before the next scan cannot revive them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…heck reads the plain queue

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas force-pushed the workstreams/fx-sched-waits branch from 19b227d to b5978ca Compare November 5, 2026 19:17
@AbirAbbas
AbirAbbas merged commit 28335c3 into workstreams/main Nov 5, 2026
7 checks passed
@AbirAbbas
AbirAbbas deleted the workstreams/fx-sched-waits branch November 5, 2026 19:46
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