ace-overseer 0.31.2 → 0.31.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 750fbdb5210c418c427622133e9ec63417b0f23524e741a89b5b6660831171c5
4
- data.tar.gz: b6d3ee6f1608460514d4553cb51389ddc4d90e455b74fde1d611a0e7b50c571e
3
+ metadata.gz: 872eb06e332d582a4bbbed22da951b8d59dc850d92c31dd7dc45889118a77baa
4
+ data.tar.gz: 0da0a500821be6201f7d3f125dd5f4388e7359e6e02108643712a35b8ac01062
5
5
  SHA512:
6
- metadata.gz: 9c3d85cea79fd0b413f23fd7739b6be28555a41e5c81502bf35fb71a5e1064ec5ade6b17169d3da0ea3de192a4b270298792f342ab9d35111783f1fa35c822f9
7
- data.tar.gz: a257b02d741809b4a10001089c993d032d154887d57798d40e1972e755dc5b5382a2564d1a56aee1edfd0da27f25b48020b62601e56dca9288dedf67d2fd1cf4
6
+ metadata.gz: 60e7d3c0051d3f22a0f96a1acafaf9bfe180a0dcd5cf51eeecd7361cc1772c830650077dcbfa8475bf9a121a277f7d5319d65246ff011866e4979d5fe48cd0df
7
+ data.tar.gz: 5f630cff41890f4ac02b81e5e5ed36bb828b833d4dd7f98704062868365f603e957e58a0fc9c0d081756d5b8da8047a3a31e87052e6c80cedc80ecdd3ba7f1af
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.31.3] - 2026-11-16
11
+
12
+ ### Fixed
13
+
14
+ - Managed recovery re-entry for an honestly-failed delegation leg whose blocker was resolved: a leg in the `failed` state whose assignment carries a pending linked retry is selected as an explicit recovery (verdict flag `recovery`) and routed through the launcher's recovery mode — same assignment, same start config, same manager binding, full seeded session environment, failed history preserved. Failed legs without a recorded retry keep the investigate refusal, no duplicate executor can start, and a recovery verdict on the window transport is refused (recovery requires the herdr launcher). A recovered aggregate (all terminal, every failed step holding a done linked retry) reports `completed` and re-enters the ordinary lifecycle. Requires ace-assign >= 0.73.4 and ace-coworker >= 0.10.1.
15
+
10
16
  ## [0.31.2] - 2026-11-15
11
17
 
12
18
  ### Fixed
@@ -12,33 +12,37 @@ module Ace
12
12
  # failed, is still in flight, or has an unreadable/unknown state is
13
13
  # never a finished predecessor: unknown state is not a free
14
14
  # resource and never permits starting (let alone overwriting) the
15
- # next executor.
15
+ # next executor. One managed exception keeps an honestly-failed leg
16
+ # re-enterable: when its blocker was resolved and the owner recorded
17
+ # a pending linked retry on the SAME assignment, the leg is selected
18
+ # as an explicit recovery (verdict flag `recovery`) routed through
19
+ # the launcher's recovery mode — same assignment, same binding,
20
+ # failed history preserved.
16
21
  module HandoffReadiness
17
22
  COMPLETED_STATE = "completed"
18
23
  # A next leg may START from these states: "paused" is an
19
24
  # untouched pending queue (fresh leg), "empty" has no steps yet.
20
25
  STARTABLE_STATES = %w[paused empty].freeze
26
+ # A failed leg is not startable — but an honestly-failed leg whose
27
+ # blocker was resolved carries a pending linked retry (recorded by
28
+ # `ace-assign retry` on the SAME assignment). The probe marks that
29
+ # assignment recovery-eligible; selecting it is an explicit
30
+ # managed recovery, never an aggregate reinterpretation: the
31
+ # failed history stays failed and no new assignment is created.
32
+ RECOVERY_STATE = "failed"
21
33
 
22
34
  # @param legs [Array<Hash>] ordered role-sequence legs, each
23
35
  # {"role" => String|nil, "assignment" => String,
24
- # "state" => String} (state "" = not present in the
25
- # assignment inventory = unknown)
36
+ # "state" => String, "recovery" => Boolean} (state "" = not
37
+ # present in the assignment inventory = unknown)
26
38
  # @param active_executor [Hash] ActiveExecutorRule verdict
27
39
  # ({active: bool, evidence: {...}|nil})
28
- # @return [Hash] {status: :ready, next: leg} |
40
+ # @return [Hash] {status: :ready, next: leg, recovery: Boolean} |
29
41
  # {status: :sequence_complete} |
30
42
  # {status: :refused, reasons: [String]}
31
43
  def self.evaluate(legs:, active_executor: {active: false})
32
44
  return {status: :refused, reasons: ["no role-sequence assignments for this task in the worktree"]} if legs.empty?
33
45
 
34
- if active_executor[:active]
35
- evidence = active_executor[:evidence] || {}
36
- return {status: :refused, reasons: [
37
- "an executor still holds the worktree: assignment #{evidence["assignment"] || "unknown"} " \
38
- "(state #{evidence["state"] || "unknown"}, source #{evidence["source"] || "config"})"
39
- ]}
40
- end
41
-
42
46
  incomplete = legs.reject { |leg| leg["state"] == COMPLETED_STATE }
43
47
  return {status: :sequence_complete} if incomplete.empty?
44
48
 
@@ -46,17 +50,46 @@ module Ace
46
50
  # it is completed by construction; the remaining gates are the
47
51
  # next leg's own state and start config.
48
52
  next_leg = incomplete.first
49
- reason = next_leg_reason(next_leg)
53
+ recovery = recovery_eligible?(next_leg)
54
+
55
+ if active_executor[:active]
56
+ evidence = active_executor[:evidence] || {}
57
+ # The coarse commission gate must not shadow an explicit
58
+ # recovery selection: when the only active evidence is the
59
+ # recovery-eligible leg itself (failed state + owner-recorded
60
+ # pending linked retry), its executor has already ended and
61
+ # the launcher's own receipt guards (retired / absent /
62
+ # running) govern the replacement launch. A live executor —
63
+ # or evidence on any other assignment — still refuses.
64
+ holds_recovery_leg = recovery && evidence["assignment"].to_s == next_leg["assignment"].to_s
65
+ unless holds_recovery_leg
66
+ return {status: :refused, reasons: [
67
+ "an executor still holds the worktree: assignment #{evidence["assignment"] || "unknown"} " \
68
+ "(state #{evidence["state"] || "unknown"}, source #{evidence["source"] || "config"})"
69
+ ]}
70
+ end
71
+ end
72
+
73
+ reason = next_leg_reason(next_leg, recovery: recovery)
50
74
  return {status: :refused, reasons: [reason]} if reason
51
75
 
52
- {status: :ready, next: next_leg}
76
+ {status: :ready, next: next_leg, recovery: recovery}
53
77
  end
54
78
 
55
79
  # Private class-method section (kept inline for atom simplicity).
56
80
 
57
- def self.next_leg_reason(leg)
81
+ # An explicit managed-recovery selection: the leg's assignment is
82
+ # in the failed state AND the assignment owner recorded a pending
83
+ # linked retry (probe-carried recovery eligibility). Anything else
84
+ # — notably a failed leg without that recorded retry — stays
85
+ # refused.
86
+ def self.recovery_eligible?(leg)
87
+ leg.is_a?(Hash) && leg["state"] == RECOVERY_STATE && leg["recovery"] == true
88
+ end
89
+
90
+ def self.next_leg_reason(leg, recovery: false)
58
91
  state = leg["state"]
59
- unless STARTABLE_STATES.include?(state)
92
+ unless STARTABLE_STATES.include?(state) || recovery
60
93
  return "next leg #{leg["role"] || "?"} (assignment #{leg["assignment"]}) state " \
61
94
  "#{state.empty? ? "unknown" : state} - not startable; investigate or resume, " \
62
95
  "never start a second executor"
@@ -68,7 +101,7 @@ module Ace
68
101
  "assignment #{leg["assignment"]} has no usable start config " \
69
102
  "(.ace-local/coworker/prepare/<role>.yml); re-run ace-coworker prepare (idempotent)"
70
103
  end
71
- private_class_method :next_leg_reason
104
+ private_class_method :next_leg_reason, :recovery_eligible?
72
105
  end
73
106
  end
74
107
  end
@@ -10,6 +10,14 @@ require_relative "eyes_readiness"
10
10
  module Ace::Overseer::Molecules
11
11
  # Start and retire a real executor using the existing commission document.
12
12
  # A recorded uncertain start is a blocker, never permission to duplicate it.
13
+ # Managed recovery (`recovery: true`) lets an honestly-failed assignment
14
+ # whose blocker was resolved re-enter on the SAME assignment with a
15
+ # replacement executor: eligibility is verified against the assignment
16
+ # snapshot's own recovery truth (failed state + pending linked retry
17
+ # recorded by the assignment owner), a retired prior receipt is cleared,
18
+ # and the launch goes through the same fully seeded session environment
19
+ # as any first launch. Failed history is never rewritten and no second
20
+ # executor is started while any receipt is live.
13
21
  class CoworkerLauncher
14
22
  def initialize(executor: Ace::Herdr::Molecules::HerdrExecutor.new, env: ENV,
15
23
  environment: nil, bindings: Ace::Coworker::Molecules::ExecutionBinding.new,
@@ -43,7 +51,7 @@ module Ace::Overseer::Molecules
43
51
  raise Ace::Overseer::Error, "coordinator eyes recipient is unavailable"
44
52
  end
45
53
 
46
- def call(worktree_path:, config_path:)
54
+ def call(worktree_path:, config_path:, recovery: false)
47
55
  ready!
48
56
  path = File.expand_path(config_path, worktree_path)
49
57
  brief = @brief_factory.call(worktree_path, path)
@@ -52,13 +60,19 @@ module Ace::Overseer::Molecules
52
60
  document["task"] == brief.config.task
53
61
  raise Ace::Overseer::Error, "executor commission changed during validation"
54
62
  end
63
+ snapshot = brief.assignment_snapshot
64
+ # Managed recovery: only an assignment the owner marked eligible
65
+ # (failed state + pending linked retry of a failed step) may
66
+ # re-enter with a replacement executor on the SAME assignment.
67
+ # The caller flag alone is never sufficient.
68
+ recovery_launch = recovery && recovery_eligible_snapshot?(snapshot)
55
69
  if document["execution"]
56
70
  execution = document.fetch("execution")
57
71
  if %w[resuming resumed].include?(execution["state"])
58
72
  next finish_resume(execution, brief, worktree_path, save)
59
73
  end
60
74
  if %w[launching started].include?(execution["state"])
61
- unless %w[paused empty].include?(brief.assignment_snapshot&.state.to_s)
75
+ unless %w[paused empty].include?(snapshot&.state.to_s)
62
76
  raise Ace::Overseer::Error, "unconfirmed executor already has assignment activity"
63
77
  end
64
78
  if recover_unprompted(execution, worktree_path, save)
@@ -66,11 +80,27 @@ module Ace::Overseer::Molecules
66
80
  end
67
81
  document.delete("execution")
68
82
  save.call
83
+ elsif execution["state"] == "retired"
84
+ # The recorded reconciliation requirement is satisfied by the
85
+ # owner's pending linked retry on this same assignment.
86
+ unless recovery_launch
87
+ raise Ace::Overseer::Error, "recorded executor is retired; reconcile the assignment before starting another"
88
+ end
89
+ document.delete("execution")
90
+ save.call
69
91
  else
92
+ # Managed recovery replaces an ENDED executor (retired or
93
+ # absent receipt). A still-running receipt means the prior
94
+ # executor is live: silently reusing it would no-op the
95
+ # recovery (the retry would never be dispatched), so the
96
+ # manager reconciles it first via process-reports/retire.
97
+ if recovery_launch && execution["state"] == "running"
98
+ raise Ace::Overseer::Error, "recorded executor is still running; retire it via process-reports before managed recovery"
99
+ end
70
100
  next reuse(execution, brief, worktree_path, save)
71
101
  end
72
102
  end
73
- unless %w[paused empty].include?(brief.assignment_snapshot&.state.to_s)
103
+ unless %w[paused empty].include?(snapshot&.state.to_s) || recovery_launch
74
104
  raise Ace::Overseer::Error, "unbound assignment is not ready for a new executor"
75
105
  end
76
106
  Dir.glob(File.join(File.dirname(path), "*.yml")).each do |other_path|
@@ -84,6 +114,7 @@ module Ace::Overseer::Molecules
84
114
  name = "coworker-#{brief.config.assignment}"
85
115
  execution = {"agent" => name, "assignment" => brief.config.assignment,
86
116
  "role" => brief.config.role, "state" => "launching"}
117
+ execution["recovery"] = true if recovery_launch
87
118
  @environment.with_environment(root: worktree_path, role: brief.config.role) do |file, directory, profile_args|
88
119
  document["execution"] = execution
89
120
  execution["credentials_directory"] = directory if directory
@@ -134,6 +165,17 @@ module Ace::Overseer::Molecules
134
165
 
135
166
  private
136
167
 
168
+ # The snapshot's own recovery truth (state failed + pending linked
169
+ # retry recorded by the assignment owner) — never the caller flag
170
+ # alone. Snapshots without recovery data (older payloads, test
171
+ # doubles) are simply not eligible.
172
+ def recovery_eligible_snapshot?(snapshot)
173
+ return false unless snapshot
174
+ return false unless snapshot.respond_to?(:recovery)
175
+
176
+ snapshot.recovery == true && snapshot.state.to_s == "failed"
177
+ end
178
+
137
179
  def submit_prompt(execution, brief, save)
138
180
  # A crash after input reaches Pi must never repeat the commission.
139
181
  execution["state"] = "prompting"
@@ -254,9 +296,6 @@ module Ace::Overseer::Molecules
254
296
  end
255
297
 
256
298
  def reuse(execution, brief, worktree_path, save)
257
- if execution["state"] == "retired"
258
- raise Ace::Overseer::Error, "recorded executor is retired; reconcile the assignment before starting another"
259
- end
260
299
  unless execution["state"] == "running"
261
300
  raise Ace::Overseer::Error, "executor start is unconfirmed; inspect the recorded assignment before retrying"
262
301
  end
@@ -36,6 +36,7 @@ module Ace
36
36
  def probe(worktree_path, task_id:)
37
37
  executor = executor_probe(worktree_path).probe(worktree_path)
38
38
  states = executor[:assignments].to_h { |a| [a["id"].to_s, a["state"].to_s] }
39
+ recoveries = executor[:assignments].to_h { |a| [a["id"].to_s, a["recovery"] == true] }
39
40
  roles = prepare_roles(worktree_path)
40
41
 
41
42
  legs = sequence_assignments(worktree_path, task_id).map do |record|
@@ -46,7 +47,8 @@ module Ace
46
47
  "execution" => mapping["execution"],
47
48
  "assignment" => record["id"],
48
49
  "name" => record["name"],
49
- "state" => states.fetch(record["id"], "")
50
+ "state" => states.fetch(record["id"], ""),
51
+ "recovery" => recoveries.fetch(record["id"], false)
50
52
  }
51
53
  end
52
54
  {legs: legs, executor: executor}
@@ -94,21 +94,30 @@ module Ace
94
94
  # Recover a launched leg through the launcher's existing identity
95
95
  # check, rather than treating a retry as a new handoff.
96
96
  next_leg = state[:legs].find { |leg| leg["state"] != "completed" }
97
- selected = Atoms::RuntimeSetting.normalize(runtime || @config["runtime"]) || ENV["ACE_RUNTIME"]
98
- native = selected == "herdr" || selected.to_s.empty? && Ace::Runtime::Atoms::Detector.detect == :herdr
97
+ native = native_transport?(runtime)
99
98
  if native && next_leg && %w[paused empty running].include?(next_leg["state"]) &&
100
99
  next_leg["execution"].is_a?(Hash) &&
101
100
  %w[launching started running resuming resumed].include?(next_leg["execution"]["state"]) &&
102
101
  (!active[:active] || active.dig(:evidence, "assignment") == next_leg["assignment"])
103
- verdict = {status: :ready, next: next_leg}
102
+ verdict = {status: :ready, next: next_leg, recovery: next_leg["recovery"] == true}
104
103
  end
105
104
  if verdict[:status] == :refused
106
105
  raise Error, "Handoff refused: #{verdict[:reasons].join("; ")}"
107
106
  end
108
107
 
108
+ # Outcome-relevant transport refusal, surfaced in dry-run
109
+ # too (readiness refusals raise there as well): managed
110
+ # recovery is a launcher mode, and the window transport has
111
+ # no commission binding, receipt or seeded session
112
+ # environment to carry it.
113
+ native = native_transport?(runtime)
114
+ if verdict[:recovery] == true && !native
115
+ raise Error, "managed recovery of assignment #{verdict[:next]["assignment"]} requires the herdr launcher transport"
116
+ end
117
+
109
118
  binding&.ready!(manager_ref: manager_ref, assignment: verdict[:next]["assignment"], allow_unbound: dry_run) if verdict[:next]
110
119
  outcome = ready_outcome(task: task, worktree_path: worktree_path, branch: found[:branch],
111
- verdict: verdict, dry_run: dry_run, runtime: runtime, progress: progress)
120
+ verdict: verdict, dry_run: dry_run, runtime: runtime, progress: progress, native: native)
112
121
  if binding && outcome[:execution]
113
122
  binding.record_execution(manager_ref: manager_ref,
114
123
  assignment: outcome.fetch(:next).fetch("assignment"), execution: outcome[:execution])
@@ -122,17 +131,18 @@ module Ace
122
131
 
123
132
  private
124
133
 
125
- def ready_outcome(task:, worktree_path:, branch:, verdict:, dry_run:, runtime:, progress:)
134
+ def ready_outcome(task:, worktree_path:, branch:, verdict:, dry_run:, runtime:, progress:, native: nil)
126
135
  next_leg = verdict[:next]
127
136
  execution = nil
128
137
 
129
138
  if next_leg
130
139
  progress.call("Next leg: role #{next_leg['role']} (assignment #{next_leg['assignment']})")
131
140
  unless dry_run
132
- selected = Atoms::RuntimeSetting.normalize(runtime || @config["runtime"]) || ENV["ACE_RUNTIME"]
133
- if selected == "herdr" || selected.to_s.empty? && Ace::Runtime::Atoms::Detector.detect == :herdr
141
+ native = native_transport?(runtime) if native.nil?
142
+ if native
134
143
  launcher = @coworker_launcher || Molecules::CoworkerLauncher.new
135
- execution = launcher.call(worktree_path: worktree_path, config_path: next_leg.fetch("start_config"))
144
+ execution = launcher.call(worktree_path: worktree_path, config_path: next_leg.fetch("start_config"),
145
+ recovery: verdict[:recovery] == true)
136
146
  else
137
147
  window_options = {worktree_path: worktree_path, preset: @config.dig("window_presets", "handoff")}
138
148
  window_options[:runtime] = runtime if runtime
@@ -152,7 +162,10 @@ module Ace
152
162
  "role" => next_leg["role"],
153
163
  "assignment" => next_leg["assignment"],
154
164
  # The actually-probed config path, never a rebuilt guess.
155
- "start_config" => next_leg["start_config"]
165
+ "start_config" => next_leg["start_config"],
166
+ # Explicit managed-recovery routing (pending linked retry on
167
+ # the same assignment); false for an ordinary leg start.
168
+ "recovery" => next_leg["recovery"] == true
156
169
  },
157
170
  dry_run: dry_run
158
171
  }.merge(execution ? {execution: execution} : {})
@@ -162,6 +175,15 @@ module Ace
162
175
  @worktree_finder || Ace::Git::Worktree::Organisms::WorktreeManager.new
163
176
  end
164
177
 
178
+ private
179
+
180
+ # The herdr launcher transport — the only carrier of managed
181
+ # recovery (commission binding, receipts, seeded session env).
182
+ def native_transport?(runtime)
183
+ selected = Atoms::RuntimeSetting.normalize(runtime || @config["runtime"]) || ENV["ACE_RUNTIME"]
184
+ selected == "herdr" || selected.to_s.empty? && Ace::Runtime::Atoms::Detector.detect == :herdr
185
+ end
186
+
165
187
  def probe
166
188
  @probe || Molecules::HandoffProbe.new
167
189
  end
@@ -169,13 +169,20 @@ module Ace
169
169
  state = Molecules::HandoffProbe.new.probe(root, task_id: task.id)
170
170
  leg = state.fetch(:legs).find { |candidate| candidate["state"] != "completed" }
171
171
  raise Error, "all prepared roles are complete; reconcile the task instead of starting again" unless leg
172
- unless %w[paused empty running].include?(leg["state"])
172
+ # Explicit managed recovery: an honestly-failed leg whose
173
+ # blocker was resolved carries a pending linked retry on the
174
+ # SAME assignment (probe-carried eligibility). The failed
175
+ # history stays failed; the re-entry reuses the existing
176
+ # assignment, start config and manager binding instead of
177
+ # creating a replacement or skipping to the next role.
178
+ recovery = leg["state"] == "failed" && leg["recovery"] == true
179
+ unless %w[paused empty running].include?(leg["state"]) || recovery
173
180
  raise Error, "assignment #{leg['assignment']} is #{leg['state']}; investigate before dispatch"
174
181
  end
175
182
  config = configs.find { |row| row["assignment"] == leg["assignment"] }
176
183
  raise Error, "prepared role has no start configuration" unless config
177
184
  binding&.ready!(manager_ref: manager_ref, assignment: leg["assignment"])
178
- execution = launcher.call(worktree_path: root, config_path: config.fetch("path"))
185
+ execution = launcher.call(worktree_path: root, config_path: config.fetch("path"), recovery: recovery)
179
186
  binding&.record_execution(manager_ref: manager_ref, assignment: leg["assignment"], execution: execution)
180
187
  progress.call("Executor #{execution['agent']} bound to assignment #{leg['assignment']}")
181
188
  {manager_ref: manager_ref, task_ref: task.id, task_refs: [task.id], worktree_path: root, branch: worktree[:branch],
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ace
4
4
  module Overseer
5
- VERSION = "0.31.2"
5
+ VERSION = "0.31.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ace-overseer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.2
4
+ version: 0.31.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Czyz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-11-15 00:00:00.000000000 Z
10
+ date: 2026-11-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ace-support-cli
@@ -80,7 +80,7 @@ dependencies:
80
80
  version: '0.70'
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 0.73.3
83
+ version: 0.73.4
84
84
  type: :runtime
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  version: '0.70'
91
91
  - - ">="
92
92
  - !ruby/object:Gem::Version
93
- version: 0.73.3
93
+ version: 0.73.4
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: ace-git
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -160,7 +160,7 @@ dependencies:
160
160
  version: '0.9'
161
161
  - - ">="
162
162
  - !ruby/object:Gem::Version
163
- version: 0.10.0
163
+ version: 0.10.1
164
164
  type: :runtime
165
165
  prerelease: false
166
166
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,7 +170,7 @@ dependencies:
170
170
  version: '0.9'
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: 0.10.0
173
+ version: 0.10.1
174
174
  - !ruby/object:Gem::Dependency
175
175
  name: ace-hitl
176
176
  requirement: !ruby/object:Gem::Requirement