Skip to content

feat(automation): Arc D phase 3b — content-gen + orchestrator + triage CLI#46

Merged
saagpatel merged 3 commits into
mainfrom
feat/automation-workflow-3b
Jun 6, 2026
Merged

feat(automation): Arc D phase 3b — content-gen + orchestrator + triage CLI#46
saagpatel merged 3 commits into
mainfrom
feat/automation-workflow-3b

Conversation

@saagpatel

Copy link
Copy Markdown
Owner

Arc D phase 3b — the last rung of Safe Automation

Wires the gated executor (3a, #45) to the recovery content primitives and exposes the full lifecycle on the CLI. Built library-first, CLI last, so nothing dangerous landed half-wired.

Library: src/automation_workflow.py

  • build_context_pr_plan — an ExecutionPlan whose apply_change refreshes the managed context block via the shared write_managed_context_block (extracted in portfolio_context_recovery, so the auto-PR content is byte-identical to the direct-apply recovery path — enforced by reuse, not a comment).
  • build_catalog_seeds_for — reuses _suggested_catalog_seed, keyed by catalog repo key.
  • execute_approved_proposalsload → filter-approved → plan → execute → mark-executed → save. Routes by action_type; only a real apply transitions to EXECUTED + persists. Each proposal's execution is isolated: a safety-rail violation or catalog I/O error becomes a failed result, never aborting the batch.
  • Slug policy: a context-PR with empty repo_full_name is skipped (no fabricated head/base ref); resolution is by GitHub slug then display name (mirrors risk keying for spaced names).

CLI: src/cli.py

--propose-automation, --list-proposals, --approve-proposal <id>, --reject-proposal <id>, --execute-proposals [--apply] (dry-run unless --apply). Execute short-circuits before building the expensive portfolio snapshot when nothing is approved.

Safety

  • Approval gate + every git/gh rail live in the executor/proposal layers (3a/3b prior PRs); this PR only builds the plan and routes.
  • authority_cap unchanged; the operator approval workflow remains the gate.

Tests / verification

  • 13 workflow + 6 CLI tests, FakeRunner-injected (no real git/network). Full suite 2413 passed, 2 skipped, ruff clean.
  • /code-review run; fixes applied (per-proposal exception isolation, shared managed-block helper, derived save condition). Deferred findings documented in commit/PR thread (default-branch=main is a documented param; branch-orphan + empty execution_ref live in the untouched 3a executor).

Known limitation: default_branch defaults to main (canonical + portfolio convention); per-repo default-branch detection is a follow-up.

saagpatel added 3 commits June 6, 2026 03:36
…ibrary)

Wire the gated executor (3a) to the recovery content primitives and drive the
load -> filter-approved -> plan -> execute -> mark-executed -> save loop.

- build_context_pr_plan: ExecutionPlan whose apply_change regenerates the
  managed context block via recovery's _build_context_sections +
  render/upsert_managed_context_block (byte-identical to the direct-apply path).
- build_catalog_seeds_for: reuses _suggested_catalog_seed, keyed by catalog key.
- execute_approved_proposals: routes only APPROVED proposals by action_type;
  real apply transitions to EXECUTED + persists; skips context-PR with empty
  repo_full_name (no fabricated slug); resolves by slug then display_name.

13 tests, FakeRunner-injected (no real git/network).
Wire the bounded-automation lifecycle into the triage/report CLI:
--propose-automation, --list-proposals, --approve-proposal <id>,
--reject-proposal <id>, --execute-proposals [--apply] (dry-run unless --apply).

- _add_automation_proposal_flags shared helper on both report subparser + legacy
  parser; mode inference + legacy-argv rewrite updated to route the flags.
- _run_automation_proposals_mode handler; execute short-circuits before building
  the (expensive) portfolio snapshot when nothing is approved.
- Output uses 'status: id' form (no [brackets]) so Rich markup never eats it.

5 CLI integration tests (drive main() through list/approve/reject); report
flag-count guardrail raised 35->41 for the 6 new flags.
- execute_approved_proposals: isolate each proposal's execution (extract
  _dispatch_proposal); an AutomationExecutionError or catalog OSError now becomes
  a 'failed' result for that proposal instead of aborting the whole batch and
  silently dropping the rest. New test pins the guarantee.
- Extract write_managed_context_block in portfolio_context_recovery and reuse it
  from both apply_context_recovery_plan and the context-PR plan, so the two
  render paths share one source of truth (kills the byte-identical-by-hope dup).
- Derive the save condition from results instead of a parallel applied_any flag.
@saagpatel
saagpatel merged commit 75cbcbd into main Jun 6, 2026
2 checks passed
@saagpatel
saagpatel deleted the feat/automation-workflow-3b branch June 6, 2026 10:57
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