ace-overseer 0.31.0 → 0.31.2

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: 66a8676da2ce6fa2dac349814b9e31ecf272bf69592d30144c0f51b5affc0f37
4
- data.tar.gz: c16d235da8c75fd77afbf788278bf720315c09aa77c9b6a74d14c85eb54e9d8b
3
+ metadata.gz: 750fbdb5210c418c427622133e9ec63417b0f23524e741a89b5b6660831171c5
4
+ data.tar.gz: b6d3ee6f1608460514d4553cb51389ddc4d90e455b74fde1d611a0e7b50c571e
5
5
  SHA512:
6
- metadata.gz: c2f7496b967aa4a8b1436eddc7535a84a348aff25527be213ac65938f228e818afb5dcd4326bf5e730eda194ea135c88366e177fe5b80a5a73c3726dd9fd8200
7
- data.tar.gz: 6919f93fe0ba5c7a33e422cd840c8f6287ea4cc30adb3c89922276b429df9afd94e5f7fa0aa8ccd241fd827c10adb8ca8cd4d52ddd71e0bc9519a91f808a8aed
6
+ metadata.gz: 9c3d85cea79fd0b413f23fd7739b6be28555a41e5c81502bf35fb71a5e1064ec5ade6b17169d3da0ea3de192a4b270298792f342ab9d35111783f1fa35c822f9
7
+ data.tar.gz: a257b02d741809b4a10001089c993d032d154887d57798d40e1972e755dc5b5382a2564d1a56aee1edfd0da27f25b48020b62601e56dca9288dedf67d2fd1cf4
data/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.31.2] - 2026-11-15
11
+
12
+ ### Fixed
13
+
14
+ - Recover a refused executor launch through the same assignment after closing its exact orphan shell and confirming the OS session ended. Preserve uncertainty and existing session evidence.
15
+
16
+ ## [0.31.1] - 2026-11-15
17
+
18
+ ### Fixed
19
+
20
+ - Read long-lived Pi sessions incrementally and retain only readiness evidence instead of rejecting histories above 64 MiB.
21
+
10
22
  ## [0.31.0] - 2026-11-12
11
23
 
12
24
  ### Changed
@@ -14,9 +14,11 @@ module Ace::Overseer::Molecules
14
14
  def initialize(executor: Ace::Herdr::Molecules::HerdrExecutor.new, env: ENV,
15
15
  environment: nil, bindings: Ace::Coworker::Molecules::ExecutionBinding.new,
16
16
  brief_factory: nil, readiness: nil, eyes: nil, root_resolver: nil,
17
+ process_identity: Ace::Runtime::Molecules::ProcessIdentity.new,
17
18
  identity_timeout: 10, clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }, sleeper: ->(seconds) { sleep(seconds) })
18
19
  @identity_timeout, @clock, @sleeper = identity_timeout, clock, sleeper
19
20
  @executor, @env, @bindings = executor, env, bindings
21
+ @process_identity = process_identity
20
22
  @environment = environment || SessionEnvironment.new(env: env)
21
23
  @brief_factory = brief_factory || ->(root, path) { Ace::Coworker::Organisms::StartOrchestrator.new(project_root: root).call(config_path: path) }
22
24
  @readiness = readiness || method(:check_eyes!)
@@ -59,10 +61,14 @@ module Ace::Overseer::Molecules
59
61
  unless %w[paused empty].include?(brief.assignment_snapshot&.state.to_s)
60
62
  raise Ace::Overseer::Error, "unconfirmed executor already has assignment activity"
61
63
  end
62
- recover_unprompted(execution, worktree_path, save)
63
- next submit_prompt(execution, brief, save)
64
+ if recover_unprompted(execution, worktree_path, save)
65
+ next submit_prompt(execution, brief, save)
66
+ end
67
+ document.delete("execution")
68
+ save.call
69
+ else
70
+ next reuse(execution, brief, worktree_path, save)
64
71
  end
65
- next reuse(execution, brief, worktree_path, save)
66
72
  end
67
73
  unless %w[paused empty].include?(brief.assignment_snapshot&.state.to_s)
68
74
  raise Ace::Overseer::Error, "unbound assignment is not ready for a new executor"
@@ -185,6 +191,66 @@ module Ace::Overseer::Molecules
185
191
  raw = row["agent_session"]
186
192
  execution["session_path"] = raw["value"] if raw.is_a?(Hash) && raw["kind"] == "path"
187
193
  save.call
194
+ true
195
+ rescue Ace::Herdr::AgentNotFoundError
196
+ retire_unstarted(execution, worktree_path, save)
197
+ false
198
+ end
199
+
200
+ # A refused launch can leave only an allocated shell. Close that exact
201
+ # native terminal before retrying the same assignment, so queued input
202
+ # cannot later start a second worker. Unknown/active evidence stays blocked.
203
+ def retire_unstarted(execution, worktree_path, save)
204
+ raise Ace::Overseer::Error, "started executor cannot be discarded" unless execution["state"] == "launching" && !execution["agent_session"]
205
+ directory = execution["credentials_directory"]
206
+ unless directory && File.directory?(directory) && !File.symlink?(directory) && Dir.glob(File.join(directory, "sessions", "**", "*.jsonl")).empty?
207
+ raise Ace::Overseer::Error, "unconfirmed launch has session evidence; inspect before retrying"
208
+ end
209
+ target = execution["unstarted_retirement"]
210
+ unless target
211
+ tabs = @executor.tab_list.parsed_json&.dig("result", "tabs")
212
+ panes = @executor.pane_list.parsed_json&.dig("result", "panes")
213
+ unless tabs.is_a?(Array) && panes.is_a?(Array) && (tabs + panes).all? { |row| row.is_a?(Hash) }
214
+ raise Ace::Overseer::Error, "unstarted executor inventory is unavailable"
215
+ end
216
+ matching_tabs = tabs.select { |row| row["label"] == execution["agent"] }
217
+ matching = matching_tabs.one? ? panes.select { |row| row["tab_id"] == matching_tabs.first["tab_id"] } : []
218
+ row = matching.one? && matching.first
219
+ unless row && row["cwd"] == worktree_path && row["pane_id"] && row["terminal_id"] && !row["agent"] && !row["agent_session"]
220
+ raise Ace::Overseer::Error, "unstarted executor shell is missing or ambiguous"
221
+ end
222
+ target = row.slice("pane_id", "terminal_id")
223
+ execution["unstarted_retirement"] = target
224
+ save.call
225
+ end
226
+ begin
227
+ row = pane_identity(target.fetch("pane_id"))
228
+ info = @executor.pane_process_info(target.fetch("pane_id")).parsed_json&.dig("result", "process_info")
229
+ unless row["terminal_id"] == target["terminal_id"] && row["cwd"] == worktree_path &&
230
+ !row["agent"] && !row["agent_session"] && shell_only?(info, target["pane_id"])
231
+ raise Ace::Overseer::Error, "unstarted executor terminal changed or is active"
232
+ end
233
+ identity = @process_identity.capture(info.fetch("shell_pid"))
234
+ unless identity && (!target["process_identity"] || target["process_identity"] == identity)
235
+ raise Ace::Overseer::Error, "unstarted executor process identity is unavailable or changed"
236
+ end
237
+ members = @process_identity.session_members(info.fetch("shell_pid"))
238
+ unless members.is_a?(Array) && members.include?(info.fetch("shell_pid"))
239
+ raise Ace::Overseer::Error, "unstarted executor OS session is unavailable"
240
+ end
241
+ target["process_identity"] = identity
242
+ save.call
243
+ @executor.pane_close(target.fetch("pane_id"))
244
+ pane_identity(target.fetch("pane_id"))
245
+ raise Ace::Overseer::Error, "unstarted executor closure is unconfirmed"
246
+ rescue Ace::Herdr::PaneNotFoundError
247
+ # The native owner confirms destruction of the recorded terminal.
248
+ end
249
+ unless @process_identity.generation_status(target["process_identity"])["liveness"] == "ended" &&
250
+ @process_identity.session_members(target.dig("process_identity", "pid")) == []
251
+ raise Ace::Overseer::Error, "unstarted executor process termination is unconfirmed"
252
+ end
253
+ SessionEnvironment.cleanup(directory)
188
254
  end
189
255
 
190
256
  def reuse(execution, brief, worktree_path, save)
@@ -12,7 +12,7 @@ module Ace
12
12
  # Reconstruct Pi's current persisted branch and bind its eyes evidence
13
13
  # to the live Herdr pane and process, without persisting another copy.
14
14
  class EyesSessionEvidence
15
- MAX_BYTES = 64 * 1024 * 1024
15
+ MAX_ENTRY_BYTES = 64 * 1024 * 1024
16
16
  MAX_ENTRIES = 200_000
17
17
  SESSION_PATH = %r{\A/[^\0]*_([0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})\.jsonl\z}
18
18
 
@@ -54,12 +54,11 @@ module Ace
54
54
  path = before.fetch("path")
55
55
  file = @file_opener.call(path)
56
56
  stat = file.stat
57
- return false unless stat.file? && stat.size.between?(1, MAX_BYTES)
58
- content = file.read(MAX_BYTES + 1)
59
- return false unless content && content.bytesize == stat.size && content.end_with?("\n")
57
+ return false unless stat.file? && stat.size.positive?
58
+ header, branch = branch_for(file, prompt)
60
59
  again = file.stat
61
- return false unless [stat.dev, stat.ino, stat.size, stat.mtime] == [again.dev, again.ino, again.size, again.mtime]
62
- header, branch = branch_for(content)
60
+ return false unless file.pos == stat.size &&
61
+ [stat.dev, stat.ino, stat.size, stat.mtime] == [again.dev, again.ino, again.size, again.mtime]
63
62
  return false unless header["cwd"] == root && header["id"].to_s.downcase == before.fetch("session_id").downcase
64
63
 
65
64
  eye = branch.reverse.find { |entry| entry["type"] == "custom" && entry["customType"] == EyesEvidence::ENTRY }
@@ -104,18 +103,51 @@ module Ace
104
103
  list.is_a?(Array) && list.any? { |row| row.is_a?(Hash) && row["pid"] == pid }
105
104
  end
106
105
 
107
- def branch_for(content)
108
- lines = content.lines
109
- raise ArgumentError, "session entry limit" unless lines.size.between?(2, MAX_ENTRIES + 1)
110
- header = JSON.parse(lines.shift, create_additions: false, max_nesting: 64, allow_duplicate_key: false)
106
+ # Bound individual records, not the lifetime of an otherwise healthy
107
+ # session. Retain only evidence fields; tool output and acknowledged
108
+ # event maps can dwarf the readiness proof in long-running sessions.
109
+ def read_entry(file)
110
+ line = file.gets(MAX_ENTRY_BYTES + 1)
111
+ return unless line
112
+ raise ArgumentError, "invalid session record size or terminator" unless
113
+ line.bytesize <= MAX_ENTRY_BYTES && line.end_with?("\n")
114
+ entry = JSON.parse(line, create_additions: false, max_nesting: 64, allow_duplicate_key: false)
115
+ raise ArgumentError, "session record must be an object" unless entry.is_a?(Hash)
116
+ entry
117
+ end
118
+
119
+ def readiness_entry(entry, prompt)
120
+ result = entry.slice("id", "parentId", "type", "timestamp", "customType")
121
+ if entry["type"] == "message" && entry["message"].is_a?(Hash)
122
+ message = entry["message"]
123
+ result["message"] = message.slice("role", "stopReason")
124
+ content = message["content"]
125
+ matched = content == prompt || content.is_a?(Array) && content.any? do |part|
126
+ part.is_a?(Hash) && part["type"] == "text" && part["text"] == prompt
127
+ end
128
+ result["message"]["content"] = prompt if matched
129
+ elsif entry["type"] == "custom" && entry["data"].is_a?(Hash)
130
+ keys = case entry["customType"]
131
+ when EyesEvidence::BINDING then %w[ownerCwd process]
132
+ when EyesEvidence::ENTRY then %w[ownerCwd enabled retired breaker errors config observerEvidence]
133
+ else []
134
+ end
135
+ result["data"] = entry["data"].slice(*keys)
136
+ end
137
+ result
138
+ end
139
+
140
+ def branch_for(file, prompt)
141
+ header = read_entry(file)
111
142
  raise ArgumentError, "invalid Pi session" unless header.is_a?(Hash) && header["type"] == "session" && header["version"] == 3
112
143
  entries = {}
113
144
  last = nil
114
- lines.each do |line|
115
- entry = JSON.parse(line, create_additions: false, max_nesting: 64, allow_duplicate_key: false)
145
+ while (entry = read_entry(file))
146
+ raise ArgumentError, "session entry limit" if entries.size >= MAX_ENTRIES
116
147
  raise ArgumentError, "invalid session entry" unless entry.is_a?(Hash) && entry["id"].is_a?(String) &&
117
148
  !entry["id"].empty? && !entries.key?(entry["id"]) &&
118
149
  (entry["parentId"].nil? || entries.key?(entry["parentId"]))
150
+ entry = readiness_entry(entry, prompt)
119
151
  entries[entry["id"]] = entry
120
152
  last = entry
121
153
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ace
4
4
  module Overseer
5
- VERSION = "0.31.0"
5
+ VERSION = "0.31.2"
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.0
4
+ version: 0.31.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Czyz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-11-12 00:00:00.000000000 Z
10
+ date: 2026-11-15 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ace-support-cli
@@ -200,7 +200,7 @@ dependencies:
200
200
  version: '0.3'
201
201
  - - ">="
202
202
  - !ruby/object:Gem::Version
203
- version: 0.4.2
203
+ version: 0.4.3
204
204
  type: :runtime
205
205
  prerelease: false
206
206
  version_requirements: !ruby/object:Gem::Requirement
@@ -210,7 +210,7 @@ dependencies:
210
210
  version: '0.3'
211
211
  - - ">="
212
212
  - !ruby/object:Gem::Version
213
- version: 0.4.2
213
+ version: 0.4.3
214
214
  - !ruby/object:Gem::Dependency
215
215
  name: ace-tmux
216
216
  requirement: !ruby/object:Gem::Requirement
@@ -234,7 +234,7 @@ dependencies:
234
234
  version: '0.11'
235
235
  - - ">="
236
236
  - !ruby/object:Gem::Version
237
- version: 0.11.2
237
+ version: 0.11.3
238
238
  type: :runtime
239
239
  prerelease: false
240
240
  version_requirements: !ruby/object:Gem::Requirement
@@ -244,7 +244,7 @@ dependencies:
244
244
  version: '0.11'
245
245
  - - ">="
246
246
  - !ruby/object:Gem::Version
247
- version: 0.11.2
247
+ version: 0.11.3
248
248
  - !ruby/object:Gem::Dependency
249
249
  name: ace-lab
250
250
  requirement: !ruby/object:Gem::Requirement