Workspace/X.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 66.6% 8 / 12 Conditioncond 53.3% 8 / 15 MC/DCmcdc 22.2% 2 / 9 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 77.0% 67 / 87 CC 14 SCAR 25.2
CC
14
Cov
81%
_error_data
19.8
BEGIN
1.0
BEGIN
1.0
CRAP 12.5
« Workspace.pm ↑ Summary
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
l!l
120
MC/DC0%0/1
ref $error || undef
ref $error
Truth table50%1/2
A
A= ref $error
Aresult
11
00
8 12 ▶ return $data unless blessed($error) && $error->isa('LibTmux::X');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($error) and $error->isa("LibTmux::X") 0 12 12
Condition33%1/3
builtin::blessed($error) and $error->isa("LibTmux::X")
!ll&&!rl&&r
0012
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")
ABresult
0X0
100
111
9 12 $data->{message} = $error->message;
10 12 ▶ if ($seen->{refaddr($error)}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$seen{builtin::refaddr($error)}++) 0 12 12
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
BranchTrueFalseTotal
if defined $error->path 0 12 12
16 12 my $result = $error->result;
17 12 ▶ if (blessed($result) && $result->isa('LibTmux::CommandResult')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($result) and $result->isa("LibTmux::CommandResult")) 4 8 12
Condition66%2/3
builtin::blessed($result) and $result->isa("LibTmux::CommandResult")
!ll&&!rl&&r
804
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")
ABresult
0X0
100
111
18 $data->{result} = {
19 4 ▶ exit_code => $result->exit_code,
Condition50%2/4
$result->stdout // ""
l!l
40
$result->stderr // ""
l!l
40
MC/DC0%0/1
$result->stdout // ""
$result->stdout
MC/DC0%0/1
$result->stderr // ""
$result->stderr
Truth table50%1/2
A
A= $result->stdout
Aresult
11
00
Truth table50%1/2
A
A= $result->stderr
Aresult
11
00
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
BranchTrueFalseTotal
if ($error->isa("LibTmux::X::Creation") or $error->isa("LibTmux::Workspace::X::Load")) 4 8 12
Condition66%2/3
$error->isa("LibTmux::X::Creation") or $error->isa("LibTmux::Workspace::X::Load")
l!l&&r!l&&!r
408
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")
ABresult
1X1
011
000
27 || $error->isa('LibTmux::Workspace::X::Load'))
28 {
29 4 ▶ $data->{cause} = _error_data($error->cause, $seen)
Branch: 1 branch
BranchTrueFalseTotal
if defined $error->cause 4 0 4
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
« Workspace.pm ↑ Summary