Class: Harnex::TelemetryReconciler

Inherits:
Object
  • Object
show all
Defined in:
lib/harnex/telemetry_reconciler.rb

Defined Under Namespace

Classes: Result, Row

Constant Summary collapse

SCHEMA =
"harnex.telemetry_reconcile.v1"
FAMILY_KEYS =
%w[v2_start v2_end v1_end legacy_rich legacy_unknown].freeze
RICH_KEYS =
%w[predicted agent usage context attribution outcome attempt reliability].freeze
MAX_DIAGNOSTICS =
50

Instance Method Summary collapse

Constructor Details

#initialize(command:, canonical:, sources:, apply: false) ⇒ TelemetryReconciler

Returns a new instance of TelemetryReconciler.



16
17
18
19
20
21
22
23
# File 'lib/harnex/telemetry_reconciler.rb', line 16

def initialize(command:, canonical:, sources:, apply: false)
  @command = command
  @canonical = canonical
  @sources = sources
  @apply = apply
  @diagnostics = []
  @diagnostics_truncated = 0
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/harnex/telemetry_reconciler.rb', line 25

def run
  base = analyze
  return finish(base) unless @apply && writable?(base)

  appended, locked = append_missing_under_lock(base[:missing_rows])
  locked[:appended] = appended
  return finish(locked) unless locked[:fatal].empty? && locked[:conflict_rows].empty?

  post = analyze
  post[:appended] = appended
  finish(post)
end