Module: ChronoForge::BranchProbe

Defined in:
lib/chrono_forge/branch_probe.rb

Overview

Single source of truth for “is this branch done?” — used by both merge_branches (boolean) and BranchMergeJob (which needs the sealed flag and pending count separately for its adaptive poll cadence). Option A: only :completed counts as done, so a failed/stalled child keeps the branch pending until recovered.

Class Method Summary collapse

Class Method Details

.done?(branch_log_id) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/chrono_forge/branch_probe.rb', line 22

def done?(branch_log_id)
  sealed?(branch_log_id) && !incomplete(branch_log_id).exists?
end

.incomplete(branch_log_id) ⇒ Object

Relation of this branch’s children that are not yet completed.



17
18
19
20
# File 'lib/chrono_forge/branch_probe.rb', line 17

def incomplete(branch_log_id)
  Workflow.where(parent_execution_log_id: branch_log_id)
    .where.not(state: Workflow.states[:completed])
end

.sealed?(branch_log_id) ⇒ Boolean

The branch’s coordination log is sealed (fully dispatched).

Returns:

  • (Boolean)


12
13
14
# File 'lib/chrono_forge/branch_probe.rb', line 12

def sealed?(branch_log_id)
  ExecutionLog.where(id: branch_log_id, state: ExecutionLog.states[:completed]).exists?
end