| 1 | package LibTmux::Workspace::X; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use v5.44; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use LibTmux::X; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use MIME::Base64 qw(encode_base64); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 12 | ▶ | sub _error_data ($error, $seen = {}) { | ||||||||||||||||||||||||||
|
Subroutine
_error_data: called CC=14 SCAR=29.9
| |||||||||||||||||||||||||||||
| 7 | 12 | ▶ | my $data = {class => ref($error) || undef, message => "$error"}; | ||||||||||||||||||||||||||
|
Condition50%1/2
ref $error || undef
MC/DC0%0/1
ref $error || undef
ref $error
Truth table50%1/2
A
A= ref $error
| |||||||||||||||||||||||||||||
| 8 | 12 | ▶ | return $data unless blessed($error) && $error->isa('LibTmux::X'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($error) and $error->isa("LibTmux::X")
MC/DC0%0/2
builtin::blessed($error) and $error->isa("LibTmux::X")
builtin::blessed($error)
$error->isa("LibTmux::X")
Truth table33%1/3
A and B
A= builtin::blessed($error)B= $error->isa("LibTmux::X")
| |||||||||||||||||||||||||||||
| 9 | 12 | $data->{message} = $error->message; | |||||||||||||||||||||||||||
| 10 | 12 | ▶ | if ($seen->{refaddr($error)}++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 11 | 0 | $data->{cycle} = true; | |||||||||||||||||||||||||||
| 12 | 0 | return $data; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | 12 | $data->{dispatched} = $error->dispatched; | |||||||||||||||||||||||||||
| 15 | 12 | ▶ | $data->{path} = $error->path if defined $error->path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 12 | my $result = $error->result; | |||||||||||||||||||||||||||
| 17 | 12 | ▶ | if (blessed($result) && $result->isa('LibTmux::CommandResult')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($result) and $result->isa("LibTmux::CommandResult")
MC/DC50%1/2
builtin::blessed($result) and $result->isa("LibTmux::CommandResult")
builtin::blessed($result)
$result->isa("LibTmux::CommandResult")
Truth table66%2/3
A and B
A= builtin::blessed($result)B= $result->isa("LibTmux::CommandResult")
| |||||||||||||||||||||||||||||
| 18 | $data->{result} = { | ||||||||||||||||||||||||||||
| 19 | 4 | ▶ | exit_code => $result->exit_code, | ||||||||||||||||||||||||||
|
Condition50%2/4
$result->stdout // ""
$result->stderr // ""
MC/DC0%0/1
$result->stdout // ""
$result->stdout
MC/DC0%0/1
$result->stderr // ""
$result->stderr
Truth table50%1/2
A
A= $result->stdout
Truth table50%1/2
A
A= $result->stderr
| |||||||||||||||||||||||||||||
| 20 | signal => $result->signal, | ||||||||||||||||||||||||||||
| 21 | raw_status => $result->raw_status, | ||||||||||||||||||||||||||||
| 22 | stdout_base64 => encode_base64($result->stdout // '', ''), | ||||||||||||||||||||||||||||
| 23 | stderr_base64 => encode_base64($result->stderr // '', ''), | ||||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | 12 | ▶ | if ( $error->isa('LibTmux::X::Creation') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$error->isa("LibTmux::X::Creation") or $error->isa("LibTmux::Workspace::X::Load")
MC/DC50%1/2
$error->isa("LibTmux::X::Creation") or $error->isa("LibTmux::Workspace::X::Load")
$error->isa("LibTmux::X::Creation")
$error->isa("LibTmux::Workspace::X::Load")
Truth table66%2/3
A or B
A= $error->isa("LibTmux::X::Creation")B= $error->isa("LibTmux::Workspace::X::Load")
| |||||||||||||||||||||||||||||
| 27 | || $error->isa('LibTmux::Workspace::X::Load')) | ||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 4 | ▶ | $data->{cause} = _error_data($error->cause, $seen) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | if defined $error->cause; | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 12 | return $data; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | package LibTmux::Workspace::X::Config { use parent -norequire, 'LibTmux::X' } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | package LibTmux::Workspace::X::Conflict { use parent -norequire, 'LibTmux::X' } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | package LibTmux::Workspace::X::Load { | |||||||||||||||||||||||||||
| 40 | 2 | ▶ | use parent -norequire, 'LibTmux::X'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 8 | ▶ | sub report ($self) { $self->{report} } | ||||||||||||||||||||||||||
|
Subroutine
report: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 8 | ▶ | sub cause ($self) { $self->{cause} } | ||||||||||||||||||||||||||
|
Subroutine
cause: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 4 | ▶ | sub report_data ($self) { | ||||||||||||||||||||||||||
|
Subroutine
report_data: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 4 | my $report = $self->report; | |||||||||||||||||||||||||||
| 46 | return { | ||||||||||||||||||||||||||||
| 47 | %$report, | ||||||||||||||||||||||||||||
| 48 | 12 | (map { $_ => [$report->{$_}->@*] } qw(created skipped steps)), | |||||||||||||||||||||||||||
| 49 | cause => LibTmux::Workspace::X::_error_data($self->cause), | ||||||||||||||||||||||||||||
| 50 | cleanup_errors => [ | ||||||||||||||||||||||||||||
| 51 | map { | ||||||||||||||||||||||||||||
| 52 | +{ | ||||||||||||||||||||||||||||
| 53 | %$_, | ||||||||||||||||||||||||||||
| 54 | error => LibTmux::Workspace::X::_error_data($_->{error}) | ||||||||||||||||||||||||||||
| 55 | 4 | } | |||||||||||||||||||||||||||
| 56 | } $report->{cleanup_errors}->@* | ||||||||||||||||||||||||||||
| 57 | 4 | ], | |||||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 NAME | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | LibTmux::Workspace::X - Workspace configuration and partial-load failures | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 EXCEPTIONS | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head2 Config | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Invalid versioned configuration. C<path> identifies the rejected input. | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head2 Conflict | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | An existing session conflicts with the selected repeat-application policy. | ||||||||||||||||||||||||||||
| 75 | No session is created until all names pass the conflict check. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head2 Load | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | C<cause> retains the original exception. C<report> records completed steps, | ||||||||||||||||||||||||||||
| 80 | the failed step, dispatch uncertainty, and typed cleanup outcomes. Rollback affects | ||||||||||||||||||||||||||||
| 81 | only sessions whose creation was proven by returned core handles. | ||||||||||||||||||||||||||||
| 82 | See L<LibTmux::Workspace/load> and L<LibTmux::X>. | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head1 METHODS | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head2 report | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | For Load exceptions, return the partial-load report. It contains created IDs, | ||||||||||||||||||||||||||||
| 89 | completed and failed steps, dispatch uncertainty, and cleanup failures. | ||||||||||||||||||||||||||||
| 90 | Each C<cleanup_errors> entry contains C<target> (the captured | ||||||||||||||||||||||||||||
| 91 | L<identity|LibTmux::Entity/identity>), C<action> (C<kill_session>), and C<error> | ||||||||||||||||||||||||||||
| 92 | (the original exception). Entries follow rollback attempt order, reversing | ||||||||||||||||||||||||||||
| 93 | creation order. An empty array means no cleanup failure was observed. | ||||||||||||||||||||||||||||
| 94 | The primary L</cause> and secondary exception objects retain their identity. | ||||||||||||||||||||||||||||
| 95 | Inspect their L<dispatched|LibTmux::X/dispatched> and | ||||||||||||||||||||||||||||
| 96 | L<result|LibTmux::X/result> fields without parsing prose. No I/O occurs. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head2 report_data | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | For Load exceptions, return a detached, JSON-safe report hashref. The primary | ||||||||||||||||||||||||||||
| 101 | cause and each cleanup error become records with C<class>, C<message>, known | ||||||||||||||||||||||||||||
| 102 | C<path>, and C<dispatched> (null means unknown). Core creation/load causes | ||||||||||||||||||||||||||||
| 103 | retain their cause chain; a repeated exception is marked C<cycle>. | ||||||||||||||||||||||||||||
| 104 | Process results retain exit code, signal, raw wait status, and bounded stdout | ||||||||||||||||||||||||||||
| 105 | and stderr as C<stdout_base64> and C<stderr_base64> using L<MIME::Base64>. | ||||||||||||||||||||||||||||
| 106 | This diagnostic encoding does not serialize entity graphs or arbitrary | ||||||||||||||||||||||||||||
| 107 | exception internals. Other exceptions retain their class and string message. | ||||||||||||||||||||||||||||
| 108 | No I/O occurs; editing the export cannot change L</report> or L</cause>. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | use JSON::PP (); | ||||||||||||||||||||||||||||
| 111 | my $data = $error->report_data; | ||||||||||||||||||||||||||||
| 112 | say JSON::PP->new->canonical->encode($data); | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | The packaged C<libtmux-workspace> CLI uses this export. Use L</report> when | ||||||||||||||||||||||||||||
| 115 | recovery needs the original typed exceptions rather than diagnostic data. | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head2 cause | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | For Load exceptions, return the original core or orchestration failure object. | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =cut | ||||||||||||||||||||||||||||