Skip to content

workspace: the factory reference Op, its rules declared in core and execution through typed hooks (ws-087) #3406

Closed

Description

@lex00

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)

  1. 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 a contract link, 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's attempts.max, or the item's max_attempts, counted from work history with outcomeCountsAsAttempt. 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).
  2. The tier comes from the slice-tier point through decide, after the lease (studio#247). The contract's own tier and the size limits feed the table, and an escalated or unconfirmed answer stops the run waiting.
  3. The understand point is asked about the leased item through decide. proceed builds. refuse drops the item on its branch with the question, the answer and who gave it. redraft and ask commit nothing and leave the item proposed. The question's id hashes its inputs, so a changed item is a new question (ready.mjs changed, studio#180).
  4. 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.
  5. 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> with Chant-Record, Chant-Lease and Chant-Run (ws-075). A criterion verified manually or at runtime is never ticked by the factory (record.mjs).
  6. 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).
  7. 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 of HUD_RETRY_CMD (studio#343).
  8. 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 into implements and under a proposed marker in the same amendment.
  9. 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's check, or a plan or lint for the infra profile. It returns { ran, ok, evidence }.
  • publish: absent means ws-088's box.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.mjs and ready.mjs keep 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/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:opsarea:workspaceenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions