ace-hitl 0.25.0 → 0.26.0

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: f9115490bffe274fbc591fc0c0c3efb826c70fe549b17e7d57b5928e298ffe23
4
- data.tar.gz: e14fa6ef9c4251fcad792f2c8cbdd362fe642b9c66dc7060fa621e6785f65d0a
3
+ metadata.gz: 64cb514390029a16b5a139d1d0db8da63b36c8fc08b21df9525d2f84bb94c1c3
4
+ data.tar.gz: 20118ea180abf1437a63d32c48c72581ca6e0aa115b79422b83f77aabc9afc04
5
5
  SHA512:
6
- metadata.gz: b8f52aef4b90d868a62e1966523282ea1a74eabe20930034736e1a73a941c701df4c4580297659ea8c5255dc45676cf3f37b466c934faa5ce7d71e10cc2d4a5f
7
- data.tar.gz: 202ca6825f02dcaec4da9fce88aaeef2ca66c33f98ef6cf51daa6585ec552dc7eeff8cfb3556ad35881aa0ccfa3cb13fc7653b68077a0ffbfcddbbf5b6e6f686
6
+ metadata.gz: e096433ca99b4cbc9455f21494d42d2cb08bc4dcf305e8e14d1e4c516a470ab8aa6a6e3eb723c3cb142570dc661197695cc30bb088c6c0713698ea6eda390446
7
+ data.tar.gz: d23bcb8c437f671d91d3661e3f27041939b4b3007acf680e19bb0c2c3315dd13f8250197cc60501786d4f7f875d20913db58c43694a65009f1442341f4a7982b
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to `ace-hitl` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [0.26.0] - 2026-11-12
11
+
12
+ ### Added
13
+
14
+ - Expose canonical local case cancellation through `cancel --case --reason`, preserving audited reasons and idempotence without fabricating human answers or contacting relay services.
15
+
16
+ ## [0.25.1] - 2026-11-10
17
+
18
+ ### Fixed
19
+
20
+ - Share strict recipient selection between observation and report acceptance; preserve observation owner identity across worktrees.
21
+
8
22
  ## [0.25.0] - 2026-10-30
9
23
 
10
24
  ### Fixed (review rounds 3/3b + re-review R2)
@@ -165,3 +165,16 @@ Canonical lifecycle namespace: `hitl.event.*`
165
165
  - Blockers always produce canonical `HITL: <id> <path>` failure reason.
166
166
  - Human-required completion handoffs generate approval HITL events.
167
167
  - Resolved HITL events are archived only after successful resume dispatch.
168
+
169
+ ## Withdraw an obsolete local question
170
+
171
+ If the reason for an unanswered or unapplied question no longer exists, cancel
172
+ the exact local case with the evidence. Do not manufacture a human answer:
173
+
174
+ ```bash
175
+ ace-hitl cancel <case-id> --case --reason "Obsolete: verified new review commit and active next round"
176
+ ```
177
+
178
+ This records terminal cancellation in the canonical case. Repetition is a no-op;
179
+ an applied effect must be closed instead. Without `--case`, cancel addresses the
180
+ relay request owner; it never guesses a different owner on lookup failure.
@@ -14,16 +14,29 @@ module Ace
14
14
  include Ace::Support::Cli::Base
15
15
  include LifecycleCommand
16
16
 
17
- desc "Cancel one HITL relay request with an audited reason"
17
+ desc "Cancel a relay request or an explicit local case with an audited reason"
18
18
 
19
19
  argument :id, required: true, desc: "HITL relay request id"
20
20
 
21
+ option :case, type: :boolean, desc: "Cancel an exact local case instead of a relay request; requires --reason"
22
+
21
23
  option :reason, type: :string, desc: "Audited reason recorded in the public lifecycle record"
22
24
 
23
25
  option :quiet, type: :boolean, aliases: %w[-q], desc: "Suppress non-essential output"
24
26
 
25
27
  def call(id:, **options)
26
- emit(lifecycle_client.cancel(id, reason: options[:reason] || ""))
28
+ if options[:case]
29
+ reason = options[:reason].to_s.strip
30
+ raise Ace::Support::Cli::Error.new("local case cancellation requires --reason") if reason.empty?
31
+ state = Organisms::HitlManager.new.cancel_case(id, reason: reason)
32
+ emit({"case" => id, "state" => state.to_s})
33
+ else
34
+ emit(lifecycle_client.cancel(id, reason: options[:reason] || ""))
35
+ end
36
+ rescue Organisms::HitlManager::UnknownCaseError,
37
+ Organisms::HitlManager::AmbiguousReferenceError,
38
+ Organisms::HitlManager::LifecycleTransitionError => e
39
+ raise_lifecycle_error("not cancelled: #{e.message}")
27
40
  rescue Lifecycle::Error, Providers::ProviderUnavailableError => e
28
41
  raise_lifecycle_error(e.message)
29
42
  end
@@ -8,12 +8,13 @@ module Ace
8
8
  class Observe < Ace::Support::Cli::Command
9
9
  desc "Read bounded semantic event revisions without private message text"
10
10
  option :scope, type: :string, default: "current", desc: "current or all linked worktrees"
11
+ option :in, type: :string, default: "next", desc: "next for live events; all to verify archived publications"
11
12
  option :owner, type: :string, desc: "Configured recipient owning incoming events"
12
13
  option :limit, type: :integer, default: 500, desc: "Maximum event count (1..2000)"
13
14
  def call(**options)
14
15
  scope = options[:scope] || "current"
15
16
  raise Ace::Support::Cli::Error, "invalid scope" unless %w[current all].include?(scope)
16
- puts JSON.generate(Molecules::EventObservation.new.call(scope: scope, limit: options[:limit] || 500, owner: options[:owner]))
17
+ puts JSON.generate(Molecules::EventObservation.new.call(scope: scope, limit: options[:limit] || 500, owner: options[:owner], in_folder: options[:in] || "next"))
17
18
  rescue ArgumentError => e
18
19
  raise Ace::Support::Cli::Error, e.message
19
20
  end
data/lib/ace/hitl/cli.rb CHANGED
@@ -47,7 +47,7 @@ module Ace
47
47
  ["wait", "Wait for an answer on a specific HITL event"],
48
48
  ["deliver", "Deliver an answer (stdin) to a pending HITL relay request"],
49
49
  ["consume", "Wait for and consume the answer of one own HITL relay request"],
50
- ["cancel", "Cancel one HITL relay request with an audited reason"],
50
+ ["cancel", "Cancel a relay request or explicit local case (--case)"],
51
51
  ["pending", "List answerable HITL relay requests (transport)"],
52
52
  ["states", "List public HITL lifecycle projections (transport)"],
53
53
  ["duty", "Project pending and escalated HITL requests (transport)"],
@@ -13,12 +13,8 @@ module Ace
13
13
  @manager = manager
14
14
  end
15
15
 
16
- def call(scope: "current", limit: 500, owner: nil)
17
- raise ArgumentError, "invalid observation limit" unless (1..2000).cover?(limit)
18
- events = @manager.list(in_folder: "next", scope: scope, limit: limit, strict: true)
19
- raise ArgumentError, "observation exceeds configured event budget" if events.size > limit
20
- address = owner && Molecules::HitlAddressResolver.new(config: @manager.config).resolve(owner)
21
- events = events.select { |event| incoming?(event, address) } if address
16
+ def call(scope: "current", limit: 500, owner: nil, in_folder: "next")
17
+ events = incoming_events(scope: scope, limit: limit, owner: owner, in_folder: in_folder)
22
18
  rows = events.map do |event|
23
19
  semantic = [event.id, event.type, event.status, event.result, event.kind,
24
20
  event.title, event.content, event.answer, event.questions,
@@ -32,6 +28,18 @@ module Ace
32
28
  {"schema" => "ace.hitl.observation/v1", "events" => rows.sort_by { |row| row["key"] }}
33
29
  end
34
30
 
31
+ # Shared read boundary for observation and report consumers. Preserve
32
+ # strict enumeration and recipient ownership in both paths.
33
+ def incoming_events(scope: "current", limit: 500, owner: nil, in_folder: "next")
34
+ raise ArgumentError, "invalid observation limit" unless (1..2000).cover?(limit)
35
+ raise ArgumentError, "invalid observation folder" unless %w[next all].include?(in_folder)
36
+ events = @manager.list(in_folder: in_folder, scope: scope, limit: limit, strict: true)
37
+ raise ArgumentError, "observation exceeds configured event budget" if events.size > limit
38
+ address = owner && Molecules::HitlAddressResolver.new(config: @manager.config).resolve(owner)
39
+ events = events.select { |event| incoming?(event, address) } if address
40
+ events
41
+ end
42
+
35
43
  private
36
44
 
37
45
  # Questions created locally are outbound until actually answered. A
@@ -115,7 +115,7 @@ module Ace
115
115
 
116
116
  def list(status: nil, kind: nil, type: nil, delivery: nil, in_folder: "next", tags: [], scope: nil, limit: nil, strict: false)
117
117
  effective_scope = @scope_resolver.effective_scope(scope)
118
- scan_results = scan_results_for_scope(effective_scope, in_folder: in_folder)
118
+ scan_results = scan_results_for_scope(effective_scope, in_folder: in_folder, strict: strict)
119
119
  raise ArgumentError, "observation exceeds configured event budget" if limit && scan_results.size > limit
120
120
  events = load_events(scan_results)
121
121
  raise ArgumentError, "incomplete HITL observation" if strict && events.size != scan_results.size
@@ -267,7 +267,7 @@ module Ace
267
267
  # Only from the not-yet-applied states — an applied effect is
268
268
  # history and is closed, not cancelled.
269
269
  # @return [Symbol] :cancelled or :duplicate
270
- def cancel_case(ref, scope: nil)
270
+ def cancel_case(ref, scope: nil, reason: nil)
271
271
  event = exact_case(ref, scope: scope)
272
272
 
273
273
  transition(event.file_path) do |frontmatter, _body|
@@ -276,6 +276,7 @@ module Ace
276
276
  when "", "pending"
277
277
  frontmatter["application"] = {"state" => "cancelled",
278
278
  "cancelled_at" => timestamp}
279
+ frontmatter["application"]["reason"] = reason.to_s.strip unless reason.to_s.strip.empty?
279
280
  :cancelled
280
281
  when "cancelled"
281
282
  :duplicate
@@ -838,11 +839,12 @@ module Ace
838
839
  }
839
840
  end
840
841
 
841
- private def scan_results_for_scope(scope, in_folder:)
842
+ private def scan_results_for_scope(scope, in_folder:, strict:)
842
843
  total = 0
843
844
  folder_counts = Hash.new(0)
844
845
 
845
846
  results = hitl_roots_for_scope(scope).uniq.flat_map do |hitl_root|
847
+ verify_observation_root!(hitl_root) if strict
846
848
  scanner = Molecules::HitlScanner.new(hitl_root)
847
849
  scoped_results = scanner.scan_in_folder(in_folder)
848
850
  total += scanner.last_scan_total.to_i
@@ -855,6 +857,16 @@ module Ace
855
857
  results
856
858
  end
857
859
 
860
+ private def verify_observation_root!(path)
861
+ return if File.stat(path).directory?
862
+
863
+ raise Errno::ENOTDIR, path
864
+ rescue Errno::ENOENT
865
+ # A worktree can legitimately have no events and no store yet.
866
+ # A dangling symlink, however, explicitly points at a lost source.
867
+ raise if File.symlink?(path)
868
+ end
869
+
858
870
  private def load_events(scan_results)
859
871
  scan_results.filter_map { |scan_result| load_event(scan_result) }
860
872
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ace
4
4
  module Hitl
5
- VERSION = "0.25.0"
5
+ VERSION = "0.26.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ace-hitl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Czyz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-10-30 00:00:00.000000000 Z
10
+ date: 2026-11-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ace-hitl-contract