Skip to content

iterate: run every recorded transition under duct - #154

Draft
asmacdo wants to merge 3 commits into
con:mainfrom
asmacdo:duct-iterate
Draft

asmacdo wants to merge 3 commits into
con:mainfrom
asmacdo:duct-iterate

Conversation

@asmacdo

@asmacdo asmacdo commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

tldr Open Question remains before this is out of draft: what happens when iterate determines the next action and starts it (with datalad run duct), but the inner-command has some guard that fails?

Option 1: Remove the duct logs (via fail-time, or by cleaning up in mechababs)
Option 2: we leave the study dirty with the fail logs.
Option 3: we commit the failed logs to the study/superstudy.

Currently, my thinking is that this is not "regular operation" and the logs should be preserved, but not committed, its on the user to clean up. Because the study is left dirty, iterate will not deploy future mechababs inner-commands.

Closes #53

Claude details

iterate wraps its scaffold and merge transitions in con/duct itself, inside each transition's datalad run, so every campaign collects orchestration resource records for free instead of the operator hand-wrapping ticks (which nobody does when the tick is the easy background thing).

  • The recorded command becomes duct --fail-time 0 -p <prefix> mechababs-inner <verb> …. The wrap lives in dispatch(), the one datalad run helper, so a recorded verb cannot forget it. Submit stays unwrapped, for the reason it stays unrecorded.
  • Records land in the study's campaign dir at .mechababs/campaigns/<label>/duct/<sourcedata>_<app>/<verb>_<datetime>_{info.json,usage.jsonl,stdout,stderr}, one directory per cell keyed like its inclusion pin, and are outputs of the same run, so they travel with the study.
  • The prefix is study-relative and keeps duct's {datetime} template (escaped once, since datalad format-expands the command it records), so a datalad rerun or a retire-and-redo adds a second timestamped set beside the first instead of clobbering it.
  • A refused or failed transition keeps its records; the run does not save them, so they sit untracked and the next iterate refuses until the operator keeps them with a path-scoped datalad save or deletes them. interventions.md carries both forms of that save (study and superstudy).
  • Docs: output_structure.md, spec.md, reference.md, overview.md, interventions.md; the CLAUDE.md convention bullet no longer says the wiring is unbuilt.

Verified: unit suite 422 passed (two new tests really run datalad run + datalad rerun and assert the records land and accumulate); e2e 4 passed in podman against babs main, with every refused-dispatch site asserting the refusal left exactly its four records and performing the documented recovery.

Design notes
  • Verified before building: the run record stores the command unformatted ({{datetime}}), datalad rerun expands it afresh; --explicit --output <dir> accepts a directory that does not exist yet; datalad run and duct both propagate the child's exit code.
  • --fail-time 0 rather than duct's 3 s default: a refusal (already scaffolded, producer not merged, member lock behind) takes 0.3 s in the e2e, a real scaffold clones a raw dataset, so the default would drop refusals' records and keep failures', but on a timing margin. Keeping everything and making the operator's save the recovery is the same rule the tool applies everywhere else: failures stop, recovery is a human act, the act is recorded.
  • The refusal path matters because a member whose lock copy is behind is refused by design during normal operation, so its leftover records cannot simply be dropped.
  • iterate committing the leftovers itself is the follow-up if the hand step bites on a real wave.
  • The derivative was ruled out as the home: babs gitignores logs at any depth, merge would need a post-merge commit inside the subdataset, and retire-derivative would carry the orchestration evidence away.

🤖 Generated with Claude Code

asmacdo and others added 3 commits September 9, 2026 10:54
The pin's filename rule (<sourcedata>_<app>, slashes mapped to dashes) is the
key for everything the campaign dir keeps per cell, so it becomes cell_key()
and the pin derives from it. No behavior change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
con#53. The recorded command becomes
`duct --fail-time 0 -p <prefix> mechababs-inner <verb> ...`, so the usage and
resource records of each scaffold and merge are outputs of the same datalad run
and travel with the study, at
.mechababs/campaigns/<label>/duct/<sourcedata>_<app>/<verb>_<datetime>_*.

The wrap lives in dispatch(), the one datalad-run helper, so a recorded verb
cannot forget it. The prefix is study-relative and keeps duct's {datetime}
template, doubled because datalad format-expands the command it records; the
record holds the template, so a rerun or a retire-and-redo adds a second
timestamped set beside the first instead of clobbering it. Each verb declares
the cell's duct directory as an output since the filenames are not known until
the run starts. --fail-time 0 keeps a failed transition's records; the run does
not save them, so the next iterate refuses until a human has looked.

Submit stays unwrapped, for the reason it stays unrecorded.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ps them

A refused verb (already scaffolded, producer not merged, member lock behind)
runs under duct like any other and --fail-time 0 keeps its records; the run
saves nothing on a non-zero exit, so they sit untracked and the next iterate
refuses. The scenario now asserts a refusal left exactly those records and
performs the documented recovery, a path-scoped save from the study or the
superstudy, before continuing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

Duct-wrap each iterate step

1 participant