harnex 0.30.1 → 0.30.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: e3869562568a9927b6a413b5536ee9c489940ce0a8cf9ac6c001072b005ae760
4
- data.tar.gz: 1203d0e9e327d56ccb63a119bc27489c417dce551e6be530772b2477e6f592b2
3
+ metadata.gz: 38738d3ea2a827981f361ce460a949d293e6bc5be34d7870882c1685e63f7b12
4
+ data.tar.gz: 801ca5db8c1fa304896fee3319addfd6bc128e0f7fde9a211c3080d5ca20ce8c
5
5
  SHA512:
6
- metadata.gz: 5f445333438f47be5c9f8f8eef6a90c3ce4844d6d4c398ae9f9a1568d4750de3313f741266b325b07d01fb941599473b6b143c827b34aa8608cab47a7f2bd1db
7
- data.tar.gz: f5bc3dde8e4ab3b666989418293ce304d53dbcbd4752baf7d17ad1afad86e39af2d8b56bcf28ace274caf5440892ac7111e4fb8dfd02581e9de38757a6659d7e
6
+ metadata.gz: 9a2fa5a34de8bdf079ca3aa573b6d16c2b5b99158eb59c924b692315b70bf38e31605705284f3a7f3ae2f00ed599f4ce4b1caa7a195447301fe9957f71628fd5
7
+ data.tar.gz: a9c5d7265af2f3dff3043c6c8da743a78dca434388a63575f1766fec216d9bb486b8ce1263348b000d4c641086686edec0fede1e2dd95de37cfcaa19dfd5081b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.30.2] - 2026-11-21 | 02:00 AM | +0800
4
+
5
+ First run on a Mac (Holm's M4 host): #99.
6
+
7
+ ### Fixed
8
+
9
+ - **On macOS, `ask` and `wait --timeout` no longer fail with "Operation not
10
+ permitted"** (#99). When every member of a process group has exited but is
11
+ not yet reaped, Darwin answers `kill(-pgid)` with `EPERM` (Linux succeeds).
12
+ The observer reap in `wait`, and `OwnedProcessGroup`, which stops Pi worker
13
+ groups, now treat `EPERM` as gone. Linux behaviour is unchanged. The other
14
+ 19 macOS test failures are test portability: #100.
15
+
3
16
  ## [0.30.1] - 2026-10-28 | 11:16 AM | +04
4
17
 
5
18
  Holm Queue 174 lost a night to dead lanes reading `running` and refusals
@@ -258,7 +258,10 @@ module Harnex
258
258
  def reap_observer(pid)
259
259
  begin
260
260
  Process.kill("KILL", -pid)
261
- rescue Errno::ESRCH
261
+ rescue Errno::ESRCH, Errno::EPERM
262
+ # Darwin's killpg answers EPERM, not ESRCH, when every member of the
263
+ # group has exited but is not yet reaped (#99). The direct KILL and
264
+ # waitpid below still reap the observer.
262
265
  nil
263
266
  end
264
267
  begin
@@ -29,7 +29,11 @@ module Harnex
29
29
  def signal(name)
30
30
  Process.kill(name, -@pgid)
31
31
  true
32
- rescue Errno::ESRCH
32
+ rescue Errno::ESRCH, Errno::EPERM
33
+ # EPERM: no member could be signalled. On Darwin that is how killpg
34
+ # reports a group whose members have all exited but are not yet reaped
35
+ # (#99); anywhere else it means members we have no right to signal, which
36
+ # no later signal could reach either.
33
37
  # Do not later signal a recycled group ID after observing it gone.
34
38
  @pgid = nil
35
39
  false
@@ -115,7 +115,7 @@ module Harnex
115
115
 
116
116
  def writable?(state) = state[:fatal].empty? && state[:conflict_rows].empty? && state[:missing_rows].any?
117
117
 
118
- def load_canonical(path, locked: false)
118
+ def load_canonical(path, locked: false, appended: [])
119
119
  rows = []
120
120
  fatal = []
121
121
  families = FAMILY_KEYS.to_h { |key| [key, 0] }
@@ -135,6 +135,9 @@ module Harnex
135
135
  }
136
136
  end
137
137
 
138
+ appended.each do |row|
139
+ entries << { record: row.record, line: entries.length + 1, path: path }
140
+ end
138
141
  entries.each do |entry|
139
142
  if entry[:error]
140
143
  fatal << "malformed canonical JSON at #{path}:#{entry[:line]}"
@@ -152,6 +155,7 @@ module Harnex
152
155
  families["v2_start"] += 1
153
156
  validate_v2(record, path, entry[:line], fatal) do |identity|
154
157
  add_unique(starts, identity, record, path, entry[:line], fatal, "v2 start")
158
+ recoverable << build_row(record, path, entry[:line], :v2_start)
155
159
  end
156
160
  when :v2_end
157
161
  families["v2_end"] += 1
@@ -225,8 +229,12 @@ module Harnex
225
229
  conflicts = source_conflicts(rows)
226
230
  conflicts.each { |left, right| diagnostic("identity conflict #{identity_label(left)} at #{left.path}:#{left.line} vs #{right.path}:#{right.line}") }
227
231
 
232
+ selected = dedupe_source_rows(rows)
233
+ selected.reject! do |row|
234
+ row.family == :v2_start && !selected.any? { |terminal| terminal.family == :v2 && terminal.identity == row.identity.take(4) }
235
+ end
228
236
  {
229
- rows: dedupe_source_rows(rows),
237
+ rows: selected,
230
238
  fatal: fatal,
231
239
  summary: {
232
240
  "paths" => unique.length,
@@ -264,13 +272,19 @@ module Harnex
264
272
  parsed = parse_whole_json(path)
265
273
  entries = parsed ? json_entries(parsed, path) : read_jsonl(path)
266
274
  errors = entries.select { |entry| entry[:error] }
275
+ fatal = []
276
+ entries.each do |entry|
277
+ record = entry[:record]
278
+ next unless record.is_a?(Hash) && record["record_type"] == "dispatch_start"
279
+
280
+ validate_v2(record, path, entry[:line], fatal) { |_identity| }
281
+ end
267
282
  rows = entries.filter_map do |entry|
268
283
  next if entry[:error]
269
284
 
270
285
  source_candidate(entry[:record], path, entry[:line])
271
286
  end
272
287
 
273
- fatal = []
274
288
  if explicit && errors.any?
275
289
  fatal << "malformed source telemetry at #{path}:#{errors.first[:line]}"
276
290
  elsif !explicit && rows.any? && errors.any?
@@ -331,7 +345,10 @@ module Harnex
331
345
  end
332
346
 
333
347
  def source_candidate(record, path, line)
334
- if v2_rich_end?(record)
348
+ if record.is_a?(Hash) && canonical_family(record) == :v2_start &&
349
+ !record["id"].to_s.empty? && !record["session_id"].to_s.empty? && normalized_time(record["started_at"])
350
+ build_row(record, path, line, :v2_start)
351
+ elsif v2_rich_end?(record)
335
352
  build_row(record, path, line, :v2)
336
353
  elsif legacy_rich?(record)
337
354
  build_row(record, path, line, :legacy)
@@ -361,10 +378,12 @@ module Harnex
361
378
  end
362
379
 
363
380
  def build_row(record, path, line, family)
364
- id = family == :v2 ? record["id"].to_s : record.dig("meta", "id").to_s
365
- started_at = normalized_time(family == :v2 ? record["started_at"] : record.dig("meta", "started_at"))
366
- session_id = family == :v2 ? record["session_id"].to_s : nil
367
- identity = family == :v2 ? ["v2", session_id, id, started_at] : ["legacy", id, started_at]
381
+ v2 = family != :legacy
382
+ id = v2 ? record["id"].to_s : record.dig("meta", "id").to_s
383
+ started_at = normalized_time(v2 ? record["started_at"] : record.dig("meta", "started_at"))
384
+ session_id = v2 ? record["session_id"].to_s : nil
385
+ identity = v2 ? ["v2", session_id, id, started_at] : ["legacy", id, started_at]
386
+ identity += ["start"] if family == :v2_start
368
387
  Row.new(
369
388
  record: record,
370
389
  path: path,
@@ -380,7 +399,9 @@ module Harnex
380
399
  same_family = canonical_rows.find { |candidate| candidate.identity == row.identity }
381
400
  return same_family if same_family
382
401
 
383
- canonical_rows.find { |candidate| candidate.match_identity == row.match_identity }
402
+ return nil if row.family == :v2_start
403
+
404
+ canonical_rows.find { |candidate| candidate.family != :v2_start && candidate.match_identity == row.match_identity }
384
405
  end
385
406
 
386
407
  def source_conflicts(rows)
@@ -389,7 +410,7 @@ module Harnex
389
410
  first = group.first
390
411
  group.drop(1).each { |row| conflicts << [first, row] unless payload_equal?(first.record, row.record) }
391
412
  end
392
- rows.group_by(&:match_identity).each_value do |group|
413
+ rows.reject { |row| row.family == :v2_start }.group_by(&:match_identity).each_value do |group|
393
414
  next unless group.map(&:family).uniq.length > 1
394
415
 
395
416
  group.combination(2) do |left, right|
@@ -406,7 +427,10 @@ module Harnex
406
427
  rows.sort_by { |row| [row.sort_key[0], row.match_identity, family_preference(row), row.path, row.line] }.each do |row|
407
428
  next if selected.any? { |candidate| candidate.identity == row.identity }
408
429
 
409
- match = selected.find { |candidate| candidate.family != row.family && candidate.match_identity == row.match_identity }
430
+ match = selected.find do |candidate|
431
+ row.family != :v2_start && candidate.family != :v2_start &&
432
+ candidate.family != row.family && candidate.match_identity == row.match_identity
433
+ end
410
434
  next if match && rows_payload_equal?(match, row)
411
435
 
412
436
  selected << row
@@ -416,7 +440,7 @@ module Harnex
416
440
 
417
441
  def dedupe_rows(rows)
418
442
  seen = Set.new
419
- rows.sort_by(&:sort_key).select do |row|
443
+ rows.sort_by { |row| [row.sort_key[0], row.family == :v2_start ? 0 : 1, row.path, row.line] }.select do |row|
420
444
  key = row.identity
421
445
  next false if seen.include?(key)
422
446
 
@@ -436,6 +460,9 @@ module Harnex
436
460
  return [0, locked] unless writable?(locked)
437
461
 
438
462
  still_missing = locked[:missing_rows].select { |row| rows.any? { |wanted| wanted.identity == row.identity } }
463
+ proposed = load_canonical(@canonical, locked: true, appended: still_missing)
464
+ return [0, locked.merge(fatal: locked[:fatal] + proposed[:fatal])] unless proposed[:fatal].empty?
465
+
439
466
  payload = still_missing.map { |row| JSON.generate(DispatchHistory.portable_record(row.record)) }.join("\n")
440
467
  existing = File.file?(@canonical) ? File.binread(@canonical) : ""
441
468
  payload = "\n#{payload}" unless existing.empty? || existing.end_with?("\n")
@@ -1,4 +1,4 @@
1
1
  module Harnex
2
- VERSION = "0.30.1"
3
- RELEASE_DATE = "2026-10-25"
2
+ VERSION = "0.30.2"
3
+ RELEASE_DATE = "2026-11-21"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harnex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.1
4
+ version: 0.30.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jikku Jose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-28 00:00:00.000000000 Z
11
+ date: 2026-11-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Hand questions and tasks to Pi workers in visible tmux windows and get
14
14
  the result back in one call: lanes in git worktrees, follow-ups that keep context,