Repository navigation
Description
Follow-up to #3162 (ws-087, decided by lex00). ws-087 settles that the factory's rules ship in chant as a reference Op and that an orchestrator supplies only execution. This issue covers building that Op. Each rule below now lives in studio's template/box/ops/factory/*.mjs on integration/next, and the issue names where.
Scope
A composite in core, declareFactory (or factoryOp; pick one name and use it everywhere), beside declareSteward in packages/core/src/op/. It reads the factory from the declaration (box.factory, ws-077) and the work kind (#3147). Its phases are pick, lease, tier, understand, build, check, record and keep. It ends with publish, which goes through box.publisher and chant workspace box publish (ws-088, #3165) when the factory publishes past the box. The reference workspace declares one with stub hooks, and a fountain steward runs it.
Rules the composite owns (declared, tested behaviour)
- Readiness, on top of the work kind's
ready(queue.mjs:1-60, ready.mjs). The box's intent must be decided (intent.mjs). The item's contract, when the work kind declares acontractlink, must be approved and in force with a check to run. The tier must be known. The number of failed attempts must be under the work kind'sattempts.max, or the item'smax_attempts, counted fromwork historywithoutcomeCountsAsAttempt. An item done on its branch and not yet applied is skipped. So is an item dropped on its branch, and an item whose slice-tier or understand question is open. A retry request (below) brings back an item whose last build failed. A contract that cites a driver's reference sections is held while the check runs no structural checks (queue.mjs, the "references" hold). - The tier comes from the
slice-tierpoint throughdecide, after the lease (studio#247). The contract's owntierand the size limits feed the table, and an escalated or unconfirmed answer stops the run waiting. - The understand point is asked about the leased item through
decide.proceedbuilds.refusedrops the item on its branch with the question, the answer and who gave it.redraftandaskcommit nothing and leave the item proposed. The question's id hashes its inputs, so a changed item is a new question (ready.mjschanged, studio#180). - Outcomes use the closed lease outcome vocabulary of work kind: contract link, tier, intent source, attempt limit, closed lease outcomes and kept-attempt refs, replacing studio's x-factory on work items #3147: done, not_done, abandoned, dropped, redraft, ask and waiting. Those that are not a build do not count as attempts.
- Done means the builder finished, the guard put nothing back, and the check passed with evidence for every criterion (WSP117). The item is amended done through chant with its evidence pinned, then committed on
chant/work/<id>withChant-Record,Chant-LeaseandChant-Run(ws-075). A criterion verified manually or at runtime is never ticked by the factory (record.mjs). - An unfinished attempt is committed aside at the kept-attempt ref work kind: contract link, tier, intent source, attempt limit, closed lease outcomes and kept-attempt refs, replacing studio's x-factory on work items #3147 names, and the branch goes back to where the run started (record.mjs).
- Retry follows studio#232. A failed build is never retried on its own. A person's retry is a field on the item written through
records amend, keyed by the failed build's lease token, so one request starts one run. The composite exposes the check that decides whether a retry is possible now, so hud's Try again can call chant instead ofHUD_RETRY_CMD(studio#343). - Implements proposals follow studio#243. A build recorded done proposes each decision in force that constrains, by path, a path it changed (
graph --intent <path>). The proposals go intoimplementsand under a proposed marker in the same amendment. - The ready step for the steward's operator (ready.mjs
--keys): one key per state, so a person's answer to either decision point is a state no run was started for (studio#302).
Hooks the orchestrator supplies (typed, nothing else)
builder: runs the builder for the item at the decided tier in the leased worktree, as Claude Code in the box,fountainRun, or a stub. It returns{ ok, note, agent, model, harness, session, spent }, and the composite starts and ends its run record (workspace: record what each agent run cost and which changes it made #3033).context: the prompt and context bundle for a build (studio's kit).check: stands the build up and runs the factory'scheck, or a plan or lint for the infra profile. It returns{ ran, ok, evidence }.publish: absent means ws-088'sbox.publisher.
The app and infra profiles from the 2026-10-01 update differ only in their hooks: the infra builder edits estate source, and the infra check is chant build, lint and a lifecycle or choudoufu plan. Gates asking decision points are #3170, and ops evidence is #3171. Both plug in through decide and workEvidence with no change to the rules.
Done when
- The composite and its rules ship in core with unit tests for each rule above, through stub hooks.
reference-workspace/declares a factory Op with stub hooks, and a harness test runs one item from pick to done, with one retry and one refusal.- Studio's dispatch Op is the composite plus studio's hooks (a studio issue to file when this one merges).
queue.mjsandready.mjskeep no readiness rule the composite lacks.
Depends on #3147 (merged), #3146 (merged) and #3165 (the publish call). It touches packages/core/src/op, packages/core/src/workspace and reference-workspace/.
Activity
feat(workspace): the factory Op's seams for an orchestrator: prepare …
feat(workspace): the factory Op reads a work kind named as a path fro…
fix(workspace): the factory Op maps a worktree's kind file once, and …
feat(workspace): the factory Op keeps an ask's item to its plan, comm…
fix(workspace): the factory Record proposes implements from the files…