Class: Carson::Runtime

Inherits:
Object
  • Object
show all
Includes:
Audit, Deliver, Govern, Housekeep, Local, Repos, Review, Setup, Status
Defined in:
lib/carson/runtime.rb,
lib/carson/runtime.rb,
lib/carson/runtime/audit.rb,
lib/carson/runtime/local.rb,
lib/carson/runtime/repos.rb,
lib/carson/runtime/setup.rb,
lib/carson/runtime/govern.rb,
lib/carson/runtime/review.rb,
lib/carson/runtime/status.rb,
lib/carson/runtime/deliver.rb,
lib/carson/runtime/housekeep.rb,
lib/carson/runtime/local/sync.rb,
lib/carson/runtime/local/hooks.rb,
lib/carson/runtime/local/prune.rb,
lib/carson/runtime/local/onboard.rb,
lib/carson/runtime/local/template.rb,
lib/carson/runtime/local/worktree.rb,
lib/carson/runtime/review/utility.rb,
lib/carson/runtime/review/query_text.rb,
lib/carson/runtime/review/data_access.rb,
lib/carson/runtime/review/gate_support.rb,
lib/carson/runtime/review/sweep_support.rb

Defined Under Namespace

Modules: Audit, Deliver, Govern, Housekeep, Local, Repos, Review, Setup, Status

Constant Summary collapse

EXIT_OK =

Shared exit-code contract used by all commands and CI smoke assertions.

0
EXIT_ERROR =
1
EXIT_BLOCK =
2
REPORT_MD =
"pr_report_latest.md".freeze
REPORT_JSON =
"pr_report_latest.json".freeze
REVIEW_GATE_REPORT_MD =
"review_gate_latest.md".freeze
REVIEW_GATE_REPORT_JSON =
"review_gate_latest.json".freeze
REVIEW_SWEEP_REPORT_MD =
"review_sweep_latest.md".freeze
REVIEW_SWEEP_REPORT_JSON =
"review_sweep_latest.json".freeze
DISPOSITION_TOKENS =
%w[accepted rejected deferred].freeze

Constants included from Govern

Govern::GOVERN_REPORT_JSON, Govern::GOVERN_REPORT_MD

Constants included from Setup

Setup::WELL_KNOWN_REMOTES

Constants included from Local

Local::SUPERSEDED, Local::TEMPLATE_SYNC_BRANCH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Housekeep

#housekeep!, #housekeep_all!, #housekeep_one_dry_run, #housekeep_target!, #reap_dead_worktrees!, #reap_dead_worktrees_plan

Methods included from Deliver

#deliver!

Methods included from Status

#status!, #status_all!

Methods included from Review

#review_gate!, #review_sweep!

Methods included from Govern

#govern!, #govern_cycle!, #govern_loop!

Methods included from Setup

#setup!

Methods included from Repos

#repos!

Methods included from Local

#cwd_worktree_branch, #main_worktree_root, #offboard!, #onboard!, #prune!, #prune_all!, #prune_plan, #realpath_safe, #refresh!, #refresh_all!, #sweep_stale_worktrees!, #sync!, #sync_all!, #template_apply!, #template_check!, #template_check_all!, #worktree_create!, #worktree_list, #worktree_remove!

Methods included from Audit

#audit!, #audit_all!

Constructor Details

#initialize(repo_root:, tool_root:, output:, error:, in_stream: $stdin, verbose: false) ⇒ Runtime

Runtime wiring for repository context, tool paths, and output streams.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/carson/runtime.rb', line 26

def initialize( repo_root:, tool_root:, output:, error:, in_stream: $stdin, verbose: false )
	@repo_root = repo_root
	@tool_root = tool_root
	@output = output
	@error = error
	@in = in_stream
	@verbose = verbose
	@config = Config.load( repo_root: repo_root )
	@git_adapter = Adapters::Git.new( repo_root: repo_root )
	@github_adapter = Adapters::GitHub.new( repo_root: repo_root )
	@ledger = Ledger.new( path: @config.govern_state_path )
	@template_sync_result = nil
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



44
45
46
# File 'lib/carson/runtime.rb', line 44

def config
  @config
end

#ledgerObject (readonly)

Returns the value of attribute ledger.



40
41
42
# File 'lib/carson/runtime.rb', line 40

def ledger
  @ledger
end

#outputObject (readonly)

Returns the value of attribute output.



44
45
46
# File 'lib/carson/runtime.rb', line 44

def output
  @output
end

#template_sync_resultObject (readonly)

Returns the value of attribute template_sync_result.



40
41
42
# File 'lib/carson/runtime.rb', line 40

def template_sync_result
  @template_sync_result
end

Instance Method Details

#branch_record(name: current_branch) ⇒ Object

Passive branch record for the current checkout.



95
96
97
# File 'lib/carson/runtime.rb', line 95

def branch_record( name: current_branch )
	repository_record.branch( name ).reload
end

#current_headObject

Current branch head SHA for delivery identity.



85
86
87
# File 'lib/carson/runtime.rb', line 85

def current_head
	git_capture!( "rev-parse", "HEAD" ).strip
end

#git_capture!(*args) ⇒ Object

Captures git stdout and raises on non-zero exit.



227
228
229
230
231
232
233
234
# File 'lib/carson/runtime.rb', line 227

def git_capture!( *args )
	stdout_text, stderr_text, success, = git_run( *args )
	unless success
		error.print stderr_text unless stderr_text.empty?
		raise "git #{args.join( ' ' )} failed"
	end
	stdout_text
end

#git_run(*args) ⇒ Object

Low-level git invocation wrapper.



243
244
245
# File 'lib/carson/runtime.rb', line 243

def git_run( *args )
	git_adapter.run( *args )
end

#puts_line(message) ⇒ Object

Single output funnel to keep messaging style consistent. Prefixes non-empty lines with the Carson badge (⧓).



118
119
120
121
122
123
124
# File 'lib/carson/runtime.rb', line 118

def puts_line( message )
	if message.to_s.strip.empty?
		output.puts ""
	else
		output.puts "#{BADGE} #{message}"
	end
end

#puts_verbose(message) ⇒ Object

Prints a line only when verbose mode is active.



58
59
60
# File 'lib/carson/runtime.rb', line 58

def puts_verbose( message )
	puts_line( message ) if verbose?
end

#repository_recordObject

Passive repository record for the current runtime context.



90
91
92
# File 'lib/carson/runtime.rb', line 90

def repository_record
	Repository.new( path: repo_root, authority: config.govern_authority, runtime: self )
end

#verbose?Boolean

Returns true when full diagnostic output is enabled via –verbose.

Returns:

  • (Boolean)


53
54
55
# File 'lib/carson/runtime.rb', line 53

def verbose?
	@verbose
end