repair-galaxy-draft-topology
Topology is settled upstream by the *-summary-to-galaxy-template Mold, and the per-step loop doesn’t edit it. This Mold makes the structural edits a settled draft still needs. It runs on an open blocking entry in the open-requirements-ledger: the settled draft can’t give a correct run, and a structural edit closes it. A missing wrapper is this case only when the discover-or-author branch is exhausted: no stock, shed or authored wrapper can produce the step’s declared output from its wired inputs, or the ledger already records the wrapper as confirmed absent. A tool version missing from a local cache is not absence. When the ledger records absence, don’t search again. A chosen wrapper that can’t produce one of the step’s declared outputs is this case too, whatever other wrappers might do: an add-step carries that output, and the loop resolves its wrapper later.
Decide the edit from the entry, the surrounding data-flow design (galaxy-data-flow-draft-contract), IWC structure, and the pattern pages.
Edit. Close each open blocking entry you have evidence for, not only the one that triggered the call, with the smallest set of edits, named by change-set kind: remove-step, rewire, change-parameter, add-input, remove-input, add-output / expose-output, remove-output, add-step, replace-tool. Apply all but the last two in place. add-step and replace-tool land at draft tier (galaxy-workflow-draft-format): concrete topology and edges, wrapper-tier TODO for tool_id and ports, _plan_* carrying intent. The discover-or-author → summarize-galaxy-tool → implement-galaxy-tool-step machinery realizes them on later loop iterations. A step duplicated from a realized step keeps its pin and state, and changes only the key that distinguishes it. Everything the entries don’t name stays as it is.
Interface. Change the workflow interface only when an entry names that as the remedy or a narrowing requires it. Promote an input with a default equal to the literal it replaces, and remove the literal from state. Expose an output by removing its hide, unless the design wants it hidden. Removing an input or output is a narrowing: append a kind: dropped entry with its units and a cited because.
Claims. A claim about a step with no resolved wrapper is not a fact. Attach it to that step as a plain ledger entry with step: set, and keep it out of doc:. “Computable” means the tool’s semantics give what the output declares, including element count and identifiers for collections. Reading a pinned wrapper’s command block or a consumer’s parser is allowed. Picking a wrapper is not.
Removal. When nothing can close an entry against a drafty step, narrow the step if it isn’t fully redundant, and rewrite its _plan_* to the reduced job. Otherwise remove it, append the kind: dropped entry, and resolve the blocking entry with a note naming the drop. A removal’s because quotes the primary artifact it rests on: the search run, the wrapper’s ports or command block, the semantics rule. The quoted artifacts must carry the removal alone: strike everything uncited, and the removal must still follow. Naming the blocking entry is not a citation, and a tool search says nothing about stock tools. Don’t remove a realized step.
After every edit:
- Remove what existed only to feed a removed step: compute it by walking every step’s
in:, the workflow outputs, and ${label} in out: rename, not from the entry’s wording.
- Rewrite or remove mentions of removed ids and labels in
doc, _plan_* and comment frames, and any doc promising what a removed step supplied.
- Move a removed step’s
rename or change_datatype to the step that inherits its consumers.
- If an edit touched a step with a twin, a step duplicated from the same tool and plan, make the same edit there.
- Run draft-validate, with
--concrete --strict-state when an edit touched a realized step, and fix what it reports.
Ledger. Mark each entry you close resolved, with a note naming the kinds you applied. A repair must leave fewer open blocking entries than it found, or say it could close none, which ends escalation. Never insert a producer whose own output is uncomputable from what feeds it. Leave an entry open, with a note saying what’s unproven, when a consumer truly needs the removed output, when no other edit closes an entry on a realized step, or when the removal doesn’t follow from what you can quote. An entry on a realized step reaches the final artifact as a labelled gap. A drafty step stays drafty, and the call reports it.