diffbroker 0.12.0 → 0.12.1

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: 5b3251c8cf1dc34ca4cfda98157ac33e2cdd3181d2b7464b6732a73b6731de43
4
- data.tar.gz: cf1c80fb6862c480b58442d6432ef38d05e7817a44f5813642b402d2b1450a7e
3
+ metadata.gz: 93366baf36d2624668bda7070960557ef337a5699c80be427798638386adcdda
4
+ data.tar.gz: 0013377ed45686039a4f4eeeae00c995844fdea592a885dfae774d6c1ba9812c
5
5
  SHA512:
6
- metadata.gz: 4561d11449c3387cd2f97b44bb60b2f4bf0f3259ae5d5bc97fb7c13764c00c68a60f787fec09f45a876dccb1c861edd4d7f8acf24448fec0d2f16b3878e0e336
7
- data.tar.gz: 79116f0dff8028b473d6c526606cca711c091e1b71bdf7fdc304482d41e2ca9d171e3d0aa01b1396c0c4e22870abf1300b8aa2360ed2a66ccbf566ea6e8cfab5
6
+ metadata.gz: 78525e73d46c72bc944a63181b1e86bf774d12d7273d81010a1024b0ea17012f601ff208d3bbbd7d34b3992dd8ddfbeff1d0471abaadf691f047e9411fe5f54f
7
+ data.tar.gz: 3e74c23e1d5091235d00482aa790af5a9b40af3263ff7caf9b5c03e8f9cccee2f1e0c65a5b66ddd15a91353ebfc589e0bf768db9210a2d481a7c1426dc998c7b
@@ -149,6 +149,7 @@ module Diffbroker
149
149
  end
150
150
  ensure
151
151
  if @owner
152
+ @task_runner.interrupt_all! if @task_runner.respond_to?(:interrupt_all!)
152
153
  @relay&.stop
153
154
  @lifecycle&.clear_pid
154
155
  @state&.clear(pid: Process.pid) unless @rejected # a rejected daemon leaves its reason for `status`
@@ -220,7 +221,9 @@ module Diffbroker
220
221
  rescan(client)
221
222
  @usage_at = nil
222
223
  client.perform("hello", "version" => VERSION, "platform" => Diffbroker.platform,
223
- "service" => @lifecycle ? @lifecycle.service_installed? : false, "agent" => @agent)
224
+ "service" => @lifecycle ? @lifecycle.service_installed? : false, "agent" => @agent,
225
+ # What this daemon is running: a run of this device that is missing here was lost with a restart.
226
+ "running" => @running_lock.synchronize { @running.to_a })
224
227
  @out.puts "Connected. #{@repositories.size} repositories reported."
225
228
  end
226
229
  client.on_tick do
@@ -89,6 +89,16 @@ module Diffbroker
89
89
  finished(id, "failed", 0, "agent_failed", e.message)
90
90
  end
91
91
 
92
+ # The daemon is ending (stop, restart, upgrade). Its agents end with it, so none keeps working on a session the next companion
93
+ # continues, and nothing is reported as failed: the server hands the lost runs back when the next companion says hello.
94
+ def interrupt_all!
95
+ handles = @lock.synchronize do
96
+ @interrupted = true
97
+ @handles.values
98
+ end
99
+ handles.each { signal("TERM", _1.pid) }
100
+ end
101
+
92
102
  # Spec §4.2 step 9: SIGINT to the agent's process group, SIGTERM after the grace period if it is still running.
93
103
  def cancel(task_id)
94
104
  # A cancel that lands between a verified run's two processes has no handle; remember it so the verifier never starts.
@@ -288,6 +298,8 @@ module Diffbroker
288
298
  end
289
299
 
290
300
  def finished(id, status, cost_usd, error_code, last_output)
301
+ return if @lock.synchronize { @interrupted }
302
+
291
303
  last = last_output.to_s.lines.last.to_s.strip
292
304
  @report.call("finished", { "task_id" => id, "status" => status, "cost_usd" => cost_usd, "error_code" => error_code,
293
305
  "last_output" => last[0, MAX_OUTPUT] })
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Diffbroker
4
- VERSION = "0.12.0"
4
+ VERSION = "0.12.1"
5
5
  end
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "diffbroker",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Skills for working on Diff Broker agent tasks: the diffbroker MCP tools, write rules and report_task."
5
5
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffbroker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Sidorov (@newstler)