Skip to content

feat(agent,cli): implement plan 007's autonomous flow repair loop - #550

Merged
HappyDevs1 merged 1 commit into
docs/plan-007-repair-loopfrom
feat/007-repair-loop-base
Sep 6, 2026
Merged

feat(agent,cli): implement plan 007's autonomous flow repair loop#550
HappyDevs1 merged 1 commit into
docs/plan-007-repair-loopfrom
feat/007-repair-loop-base

Conversation

@HappyDevs1

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #549 (plan 007's doc) — this is PR 2/4.

  • Adds flowproof-agent::repair: diagnoses a RecordError into plan 007's taxonomy, asks the configured authoring model for a minimal .flow.yaml patch, and applies it via a whole-document serde_yaml::Value round-trip.
  • Wires the loop into flowproof-cli's cmd_record: on failure, if an authoring model is configured (and not --reuse), run the bounded repair loop (default 3 attempts) instead of failing immediately. Stops early if the same diagnosis category recurs on the same step with no progress. --no-repair restores today's single-attempt behavior exactly.
  • The loop never touches anything but the target .flow.yaml and its <flow>.repair.json sidecar report — no source-code edits, ever, by construction.
  • Fixed a real bug found during live testing: a model's answer sometimes includes the leading - YAML list marker despite being told not to, which previously nested a list inside steps: instead of replacing the entry; apply_patch now unwraps that case (regression test included).

Verified live

Ran against a real Fiori tenant (--headed, real Anthropic key): a deliberately malformed step failed record, the model correctly diagnosed and rewrote it, and the rerun passed with zero manual edits to the flow file. Also verified: no key configured → original plain-failure behavior, zero repair attempts, file untouched.

Test plan

  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace — green except the pre-existing, environment-specific doctor_ai_e2e failure (a real API key configured on the dev machine; reproduces identically on unmodified main, confirmed via git stash)
  • Live record --headed against a real Fiori tenant, described above

record now diagnoses a live-recording failure, asks the configured
authoring model for a minimal .flow.yaml edit, applies it, and reruns
in a bounded loop (default 3 attempts) instead of just reporting the
first failure. Stops early as an engine gap when the same category
recurs on the same step with no progress, or when the model itself
says the failure isn't fixable by a flow edit. The loop never writes
anything but the target .flow.yaml and its trace/repair.json sidecar
report; --no-repair restores the original single-attempt behavior.

Verified live against a real Fiori tenant (config'd via `flowproof
config fiori`) with --headed and a real Anthropic key: a deliberately
malformed step failed record, the model correctly diagnosed and
rewrote it, and the rerun passed with zero manual edits to the flow
file. That run also caught a real bug fixed here: apply_patch now
unwraps an accidental leading `- ` list marker in a model's answer,
which previously nested a list inside steps: instead of replacing the
entry.
@HappyDevs1
HappyDevs1 merged commit 4b626f7 into main Sep 6, 2026
9 checks passed
@HappyDevs1
HappyDevs1 deleted the feat/007-repair-loop-base branch September 6, 2026 20:38
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