Renamed all 11 task-type confidence threshold fields in AutomationProfile from phase-transition semantics to spec-defined task-type semantics. Updated all 8 built-in profiles, CLI formatting, YAML schema, services, and all Behave/Robot tests referencing the old field names. Post-review fixes: - Fixed 24 stale old field names in M6 fixture files (automation_profiles.json, autonomy_guardrails.json) - Added model_validator(mode='before') to detect legacy field names and raise actionable ValueError with rename mapping - Added semantic bridge comments in PlanLifecycleService mapping task-type thresholds to phase-transition gates - Added threshold_field to structured log messages for observability - Restored categorised CLI automation-profile show output to match spec (Phase Transitions / Decision Automation / Self-Repair / Execution Controls) instead of flat list - Added missing access_network field to spec show output examples (Rich, Plain, JSON, YAML variants) - Aligned ADR-017 profile fields table to all 11 fields with descriptions matching spec Automatable Tasks table - Aligned automation_profiles.md threshold descriptions with spec - Added spec section references in phase_reversion.md, error_recovery.md, and plan_execute.md for field naming context - Extended repository roundtrip test to assert all 11 threshold fields - Fixed benchmark _make_profile() passing safety fields as top-level kwargs instead of via SafetyProfile sub-model (incompatible with extra="forbid") - Aligned CLI JSON/YAML output structure for automation-profile show with the specification grouped format (phase_transitions, decision_automation, self_repair, execution_controls) - Moved safety boolean fields into the Execution Controls section of Rich output per spec examples - Reverted auto profile description to "Fully automatic except apply" per specification (line 16703, line 28406) - Improved bridge comments in test steps with semantic context for threshold-to-gate mappings ISSUES CLOSED: #902
2.7 KiB
Phase Reversion State Machine
Phase reversion allows plans to return to an earlier lifecycle phase when the current strategy proves unworkable. This enables adaptive re-planning without discarding accumulated context.
Reversion Paths
| Source Phase | Target Phase | Trigger |
|---|---|---|
| Execute | Strategize | Validation failures block apply; constraints too restrictive |
| Apply (constrained) | Strategize | Cannot proceed within current strategy constraints |
Automation Profile Thresholds
Automatic reversion is gated by the plan's resolved AutomationProfile:
| Threshold | Controls (see spec § Automatable Tasks for field naming) |
|---|---|
access_network |
Auto-revert when Apply is constrained. < 1.0 = automatic, 1.0 = manual only |
delete_content |
Auto-revert from Execute to Strategize. < 1.0 = automatic, 1.0 = manual only |
Built-in profile defaults:
| Profile | access_network |
delete_content |
|---|---|---|
manual |
1.0 (never auto) | 1.0 |
review |
1.0 | 1.0 |
trusted |
1.0 | 1.0 |
auto |
1.0 | 0.0 |
ci |
0.0 (always auto) | 0.0 |
full-auto |
0.0 | 0.0 |
Loop Guard
Every plan tracks a reversion_count field. Each reversion increments
this counter. The maximum number of reversions per plan execution is
3 (Plan.MAX_REVERSIONS). Once this limit is reached, both
automatic and manual reversions are blocked.
This prevents infinite strategize-execute-revert cycles when the underlying problem cannot be resolved through re-planning alone.
Decision Recording
Each reversion is recorded as a reversion decision in the plan's
decisions list with the following fields:
| Field | Type | Description |
|---|---|---|
type |
str |
Always "reversion" |
source_phase |
str |
Phase the plan was in before reversion |
target_phase |
str |
Phase the plan reverted to |
reason |
str |
Human-readable reason for the reversion |
timestamp |
str |
ISO 8601 timestamp |
reversion_number |
int |
1-based reversion counter |
Manual Reversion
Plans can be manually reverted via the CLI:
agents plan revert <plan_id> --to-phase strategize --reason "constraints too strict"
Manual reversion is subject to the same loop guard (max 3 reversions) but ignores automation profile thresholds.
State Reset on Reversion
When a plan is reverted:
- The
phaseis set to the target phase. - The
processing_stateis reset toQUEUED. - The
error_messageis cleared. - The
reversion_countis incremented. - The
updated_attimestamp is refreshed. - Context and sandbox state are preserved.