| 1 | package Langertha::Holmgang::Report; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: The JSON report of a Holmgang invocation, format holmgang_report 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 27 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 27 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 27 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 27 | ▶ | use Digest::SHA qw( sha256_hex ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 27 | ▶ | use JSON::MaybeXS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 27 | ▶ | use Langertha (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 27 | ▶ | use Langertha::Holmgang (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 27 | ▶ | use Path::Tiny qw( path ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 27 | ▶ | use POSIX qw( strftime ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 27 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 27 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 27 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #### Format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # The format version this module writes and the highest it reads (ADR 0006). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 105 | ▶ | sub format_version { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # The shape of format 1. A field spec is a primitive name (int num str bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # time url any), the name of an entry of this table, or a hash with `type` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # and optional `null => 0` (never null), `min`, `max`, `of` (array element) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # or `values` (enum). Every field may be null unless it says `null => 0`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # array elements are never null. `optional => 1` marks a field added after | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # version 1 came out: a reader takes it as null where an older report lacks it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 27 | my %SPEC = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | report => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | holmgang_report => { type => 'int', null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | generator => 'generator', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | started_at => 'time', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | finished_at => 'time', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | runs => { type => 'array', of => 'run', null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | generator => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | holmgang => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | langertha => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | run => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | target => 'target', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | variant => 'variant', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | suite => 'suite', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | repeat => { type => 'int', min => 1, null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | status => { type => 'enum', values => [qw( complete cancelled aborted )], null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | error => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | cases => { type => 'array', of => 'case', null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | target => { type => 'object', null => 0, fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | label => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | engine => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | model => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | url => 'url', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | variant => { type => 'object', null => 0, fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | name => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | settings => 'any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | suite => { type => 'object', null => 0, fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | id => { type => 'str', null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | version => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | topic => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | digest => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | case => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | case_id => { type => 'str', null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | title => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | tags => { type => 'array', of => 'str' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | tier => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | difficulty => { type => 'str', optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | weight => { type => 'num', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | hard => 'bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | untrusted => 'bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | repetitions => { type => 'array', of => 'repetition', null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | repetition => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | repetition => { type => 'int', min => 1, null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | seed => 'int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | status => { type => 'enum', values => [qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | no_vision context_exceeded error turn_limit passed uncertain failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | )], null => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | score => { type => 'num', min => 0, max => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | error => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | finish_reason => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | duration_ms => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | rules => { type => 'array', of => 'rule' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | diff => { type => 'array', of => 'change' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | turns => { type => 'array', of => 'turn' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | tokens => 'tokens', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | calls => { type => 'array', of => 'call' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sim_gaps => { type => 'array', of => 'gap' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | forbidden_calls => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | injection_held => 'bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | transcript => { type => 'array', of => 'any' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | rule => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | title => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | kind => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | required => 'bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | passed => 'bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | reason => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | sim_gap => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | change => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | path => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | before => 'any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | after => 'any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | turn => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | input_tokens => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | output_tokens => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | reasoning_tokens => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | duration_ms => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | finish_reason => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | calls => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | tokens => { type => 'object', null => 0, fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | input => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | output => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | reasoning => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | input_max => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | call => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | tool => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | args => 'any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | succeeded => 'bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | sim_gap => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | gap => { type => 'object', fields => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | call => { type => 'int', min => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | tool => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | gap => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # Query parameters of a target url that carry credentials. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 27 | my $SECRET_PARAM = qr/key|token|secret|pass|auth|sig|cred/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Image content in any form a provider takes it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 27 | my $DATA_URL = qr{\bdata:(?:image/|[^,\s]*;base64,)}i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 27 | my $BASE64_RUN = qr{\A[A-Za-z0-9+/]{1024,}={0,2}\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | #### Attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 27 | has generator => ( is => 'ro', lazy_build => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 159 | ▶ | sub _build_generator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_generator: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 159 | holmgang => $Langertha::Holmgang::VERSION, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | langertha => $Langertha::VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 27 | has started_at => ( is => 'ro', lazy_build => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 81 | ▶ | sub _build_started_at { shift->now } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_started_at: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 27 | has finished_at => ( is => 'ro', writer => '_set_finished_at' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 27 | has with_transcript => ( is => 'ro', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 164 | ▶ | has runs => ( is => 'ro', default => sub { [] } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 318 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 318 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 318 | $self->generator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 318 | $self->started_at; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 318 | my $runs = $self->runs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 318 | ▶ | croak __PACKAGE__.'->new runs must be an array' unless ref $runs eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 318 | @$runs = map { $self->_shape( 'run', $runs->[$_], 'runs['.$_.']', 0 ) } 0 .. $#$runs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 318 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | #### Building | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 131 | ▶ | sub now { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
now: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 131 | my ( $self, $epoch ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 131 | ▶ | return strftime( '%Y-%m-%dT%H:%M:%SZ', gmtime( defined $epoch ? $epoch : time ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 201 | ▶ | sub add_run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_run: called CC=19 SCAR=30.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 201 | my ( $self, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 201 | my $where = 'runs['.scalar( @{ $self->runs } ).']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 201 | my $repeat = $arg{repeat}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 201 | ▶ | my @cases = @{ $arg{cases} || croak __PACKAGE__.'->add_run needs cases' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arg{'cases'} || croak('Langertha::Holmgang::Report->add_run needs cases')
MC/DC0%0/1
$arg{'cases'} || croak('Langertha::Holmgang::Report->add_run needs cases')
$arg{'cases'}
Truth table50%1/2
A
A= $arg{'cases'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 201 | my ( %case, @order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 201 | for my $i ( 0 .. $#cases ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 366 | my $c = $cases[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | croak __PACKAGE__.'->add_run '.$where.'.cases['.$i.'] has no case_id' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 366 | ▶ | unless ref $c eq 'HASH' && defined $c->{case_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $c eq "HASH" and defined $c->{"case_id"}
MC/DC0%0/2
ref $c eq "HASH" and defined $c->{"case_id"}
ref $c eq "HASH"
defined $c->{"case_id"}
Truth table33%1/3
A and B
A= ref $c eq "HASH"B= defined $c->{"case_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | croak __PACKAGE__.'->add_run '.$where.': case '.$c->{case_id}.' listed twice' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 366 | ▶ | if $case{ $c->{case_id} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 366 | $case{ $c->{case_id} } = { ( map { $_ => $c->{$_} } qw( case_id title tags tier difficulty weight hard untrusted ) ), repetitions => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 366 | push @order, $c->{case_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 201 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 201 | ▶ | for my $r ( @{ $arg{results} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg{'results'} || []
MC/DC100%1/1
$arg{'results'} || []
$arg{'results'}
Truth table100%2/2
A
A= $arg{'results'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 483 | ▶ | croak __PACKAGE__.'->add_run '.$where.': a result is not a hash' unless ref $r eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 483 | my $id = $r->{case_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | croak __PACKAGE__.'->add_run '.$where.': result for unknown case '.( defined $id ? $id : '(none)' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 483 | ▶ | unless defined $id && $case{$id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $id and $case{$id}
MC/DC50%1/2
defined $id and $case{$id}
defined $id
$case{$id}
Truth table66%2/3
A and B
A= defined $idB= $case{$id}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 482 | my $n = $r->{repetition}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 482 | ▶ | croak __PACKAGE__.'->add_run '.$where.': case '.$id.' result without a repetition number' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $n and $n =~ /\A[1-9][0-9]*\z/
MC/DC0%0/2
defined $n and $n =~ /\A[1-9][0-9]*\z/
defined $n
$n =~ /\A[1-9][0-9]*\z/
Truth table33%1/3
A and B
A= defined $nB= $n =~ /\A[1-9][0-9]*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | unless defined $n && $n =~ /\A[1-9][0-9]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 482 | ▶ | croak __PACKAGE__.'->add_run '.$where.': case '.$id.' repetition '.$n.' beyond repeat '.$repeat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $repeat and $repeat =~ /\A[0-9]+\z/ and $n > $repeat
defined $repeat and $repeat =~ /\A[0-9]+\z/
MC/DC33%1/3
defined $repeat and $repeat =~ /\A[0-9]+\z/ and $n > $repeat
defined $repeat
$repeat =~ /\A[0-9]+\z/
$n > $repeat
Truth table50%2/4
A and B and C
A= defined $repeatB= $repeat =~ /\A[0-9]+\z/C= $n > $repeat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | if defined $repeat && $repeat =~ /\A[0-9]+\z/ && $n > $repeat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | croak __PACKAGE__.'->add_run '.$where.': case '.$id.' repetition '.$n.' given twice' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 481 | ▶ | if $seen{$id}{$n}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 480 | push @{ $case{$id}{repetitions} }, $self->_repetition( $r, $where.' case '.$id.' repetition '.$n ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 196 | for my $c ( values %case ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 356 | @{ $c->{repetitions} } = sort { $a->{repetition} <=> $b->{repetition} } @{ $c->{repetitions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | my $run = $self->_shape( 'run', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1176 | ( map { $_ => $arg{$_} } qw( target variant suite repeat status error ) ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 196 | cases => [ map { $case{$_} } @order ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | }, $where, 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 186 | push @{ $self->runs }, $run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 186 | return $run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 480 | ▶ | sub _repetition { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_repetition: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 480 | my ( $self, $r, $where ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 480 | my $turns = $self->_shape( { type => 'array', of => 'turn' }, $r->{turns}, $where.'.turns', 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 479 | my $calls = $self->_shape( { type => 'array', of => 'call' }, $r->{calls}, $where.'.calls', 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 478 | my %tokens = map { $_ => undef } qw( input output reasoning input_max ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 478 | my ( $duration, $finish ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 478 | ▶ | if ( $turns ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 472 | $duration = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 472 | for my $t ( @$turns ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 356 | ▶ | $duration += $t->{duration_ms} if defined $t->{duration_ms}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 356 | for my $f (qw( input output reasoning )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1068 | my $v = $t->{ $f.'_tokens' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1068 | ▶ | next unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 94 | ▶ | $tokens{$f} = ( $tokens{$f} || 0 ) + $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$tokens{$f} || 0
MC/DC100%1/1
$tokens{$f} || 0
$tokens{$f}
Truth table100%2/2
A
A= $tokens{$f}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $tokens{input_max} = $t->{input_tokens} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 356 | ▶ | if defined $t->{input_tokens} && ( !defined $tokens{input_max} || $t->{input_tokens} > $tokens{input_max} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $t->{"input_tokens"} and !defined($tokens{"input_max"}) || $t->{"input_tokens"} > $tokens{"input_max"}
not defined $tokens{"input_max"} or $t->{"input_tokens"} > $tokens{"input_max"}
MC/DC33%1/3
defined $t->{"input_tokens"} and !defined($tokens{"input_max"}) || $t->{"input_tokens"} > $tokens{"input_max"}
defined $t->{"input_tokens"}
not defined $tokens{"input_max"}
$t->{"input_tokens"} > $tokens{"input_max"}
Truth table75%3/4
A and not(B) or C
A= defined $t->{"input_tokens"}B= not defined $tokens{"input_max"}C= $t->{"input_tokens"} > $tokens{"input_max"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 472 | ▶ | $finish = $turns->[-1]{finish_reason} if @$turns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 478 | my $gaps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 478 | ▶ | if ( $calls ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 18 | $gaps = [ map { +{ call => $_, tool => $calls->[$_]{tool}, gap => $calls->[$_]{sim_gap} } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 204 | grep { defined $calls->[$_]{sim_gap} } 0 .. $#$calls ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4302 | ( map { $_ => $r->{$_} } qw( repetition seed status score error rules diff forbidden_calls injection_held ) ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | finish_reason => $finish, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | duration_ms => $duration, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | turns => $turns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | tokens => \%tokens, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | calls => $calls, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | sim_gaps => $gaps, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 478 | transcript => scalar $self->_transcript( $r->{transcript}, $where ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 478 | ▶ | sub _transcript { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_transcript: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 478 | my ( $self, $messages, $where ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 478 | ▶ | return unless $self->with_transcript && defined $messages; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->with_transcript and defined $messages
MC/DC100%2/2
$self->with_transcript and defined $messages
$self->with_transcript
defined $messages
Truth table100%3/3
A and B
A= $self->with_transcriptB= defined $messages
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 9 | ▶ | croak __PACKAGE__.' '.$where.'.transcript must be an array' unless ref $messages eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 9 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 9 | for my $m ( @$messages ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 14 | ▶ | if ( ref $m eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 14 | ▶ | next if defined $m->{role} && $m->{role} eq 'system'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $m->{"role"} and $m->{"role"} eq "system"
MC/DC100%2/2
defined $m->{"role"} and $m->{"role"} eq "system"
defined $m->{"role"}
$m->{"role"} eq "system"
Truth table100%3/3
A and B
A= defined $m->{"role"}B= $m->{"role"} eq "system"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 12 | my %copy = %$m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 12 | delete $copy{untrusted}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 12 | push @out, \%copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 12 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | push @out, $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 9 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 128 | ▶ | sub finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 128 | my ( $self, $at ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 128 | ▶ | $self->_set_finished_at( defined $at ? $at : $self->now ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 128 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | ▶ | sub image_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
image_entry: called CC=5 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | my ( $self, $name, $bytes ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | croak __PACKAGE__.'->image_entry needs a name and the image bytes' unless defined $name && defined $bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and defined $bytes
MC/DC0%0/2
defined $name and defined $bytes
defined $name
defined $bytes
Truth table33%1/3
A and B
A= defined $nameB= defined $bytes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | croak __PACKAGE__.'->image_entry wants bytes, got characters' if utf8::is_utf8($bytes) && $bytes =~ /[^\x00-\xff]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
utf8::is_utf8($bytes) and $bytes =~ /[^\x00-\xff]/
MC/DC0%0/2
utf8::is_utf8($bytes) and $bytes =~ /[^\x00-\xff]/
utf8::is_utf8($bytes)
$bytes =~ /[^\x00-\xff]/
Truth table33%1/3
A and B
A= utf8::is_utf8($bytes)B= $bytes =~ /[^\x00-\xff]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | return { image => ''.$name, sha256 => sha256_hex($bytes), bytes => length $bytes }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | #### Writing and reading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 52 | ▶ | sub as_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_data: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 52 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 52 | holmgang_report => $self->format_version, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | generator => $self->_shape( 'generator', $self->generator, 'generator', 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | started_at => $self->_shape( 'time', $self->started_at, 'started_at', 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | finished_at => $self->_shape( 'time', $self->finished_at, 'finished_at', 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | runs => $self->runs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 222 | ▶ | sub _json { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_json: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 222 | return JSON::MaybeXS->new( utf8 => 1, canonical => 1, pretty => 1, convert_blessed => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 52 | ▶ | sub to_json { my ( $self ) = @_; return $self->_json->encode( $self->as_data ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_json: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 23 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 23 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 23 | ▶ | croak __PACKAGE__.'->write needs a file' unless defined $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 23 | path($file)->spew_raw( $self->to_json ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 22 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 58 | ▶ | sub from_json { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_json: called CC=9 SCAR=22.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 58 | my ( $class, $bytes, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 58 | ▶ | my $from = defined $arg{source} ? $arg{source} : 'report'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 58 | my $data = eval { $class->_json->decode($bytes) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 58 | ▶ | croak __PACKAGE__.' '.$from.' is not JSON: '.( $@ =~ s/\s+\z//r ) unless defined $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 56 | ▶ | croak __PACKAGE__.' '.$from.' is not a Holmgang report' unless ref $data eq 'HASH' && exists $data->{holmgang_report}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $data eq "HASH" and exists $data->{"holmgang_report"}
MC/DC50%1/2
ref $data eq "HASH" and exists $data->{"holmgang_report"}
ref $data eq "HASH"
exists $data->{"holmgang_report"}
Truth table66%2/3
A and B
A= ref $data eq "HASH"B= exists $data->{"holmgang_report"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 53 | my $v = $data->{holmgang_report}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 53 | ▶ | croak __PACKAGE__.' '.$from.': holmgang_report must be a positive integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $v and not ref $v and $v =~ /\A[1-9][0-9]*\z/
defined $v and not ref $v
MC/DC33%1/3
defined $v and not ref $v and $v =~ /\A[1-9][0-9]*\z/
defined $v
not ref $v
$v =~ /\A[1-9][0-9]*\z/
Truth table50%2/4
A and not(B) and C
A= defined $vB= not ref $vC= $v =~ /\A[1-9][0-9]*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | unless defined $v && !ref $v && $v =~ /\A[1-9][0-9]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 52 | ▶ | croak __PACKAGE__.' '.$from.': unknown report version '.$v.' (this reader knows up to '.$class->format_version.')' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | if $v > $class->format_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 51 | my $doc = $class->_shape( 'report', $data, $from, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | return $class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | generator => $doc->{generator}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | started_at => $doc->{started_at}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | finished_at => $doc->{finished_at}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | runs => $doc->{runs}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 45 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 43 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 43 | my ( $class, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 43 | ▶ | croak __PACKAGE__.'->read needs a file' unless defined $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 43 | return $class->from_json( path($file)->slurp_raw, source => ''.$file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | #### Merging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 112 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=17 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 112 | my ( $class, @reports ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 112 | ▶ | croak __PACKAGE__.'->merge needs at least one report' unless @reports; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 112 | my ( %run, @order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 112 | my $json = $class->_json; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 112 | for my $rep ( @reports ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 127 | for my $run ( @{ $rep->runs } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 160 | my $key = $json->encode( { map { $_ => $run->{$_} } qw( target variant suite ) } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 160 | ▶ | unless ( $run{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 149 | push @order, $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 149 | $run{$key} = { %$run, cases => [] , _case => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 160 | my $m = $run{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | croak __PACKAGE__.'->merge: run of suite '.$run->{suite}{id}.' has repeat '.$m->{repeat}.' and '.$run->{repeat} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 160 | ▶ | unless $m->{repeat} == $run->{repeat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 159 | $m->{status} = $class->_worse_status( $m->{status}, $run->{status} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 159 | ▶ | $m->{error} = $run->{error} unless defined $m->{error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 159 | for my $c ( @{ $run->{cases} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 258 | my $mc = $m->{_case}{ $c->{case_id} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 258 | ▶ | unless ( $mc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 249 | $mc = $m->{_case}{ $c->{case_id} } = { %$c, repetitions => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 249 | push @{ $m->{cases} }, $mc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # a field added after version 1 is null in an older report: the other's value holds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 258 | for my $f ( $class->_optional_case_fields ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 258 | ▶ | $mc->{$f} = $c->{$f} unless defined $mc->{$f}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 258 | my %meta_a = %$mc; delete $meta_a{repetitions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 258 | my %meta_b = %$c; delete $meta_b{repetitions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 258 | ▶ | defined $meta_b{$_} or $meta_b{$_} = $meta_a{$_} for $class->_optional_case_fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 258 | ▶ | croak __PACKAGE__.'->merge: case '.$c->{case_id}.' of suite '.$run->{suite}{id}.' differs between reports' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | unless $json->encode( \%meta_a ) eq $json->encode( \%meta_b ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 256 | for my $r ( @{ $c->{repetitions} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 382 | my ($have) = grep { $_->{repetition} == $r->{repetition} } @{ $mc->{repetitions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 382 | ▶ | unless ( $have ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 376 | push @{ $mc->{repetitions} }, $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 376 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | croak __PACKAGE__.'->merge: case '.$c->{case_id}.' repetition '.$r->{repetition}.' of suite ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 6 | ▶ | .$run->{suite}{id}.' is in two reports with different results' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | unless $json->encode( $class->_stable($have) ) eq $json->encode( $class->_stable($r) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 255 | @{ $mc->{repetitions} } = sort { $a->{repetition} <=> $b->{repetition} } @{ $mc->{repetitions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 108 | my @runs = map { my $r = $run{$_}; delete $r->{_case}; $r } @order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 108 | my @start = sort grep { defined } map { $_->started_at } @reports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 108 | my @finish = sort grep { defined } map { $_->finished_at } @reports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 108 | return $class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | generator => $reports[0]->generator, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | started_at => $start[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | finished_at => $finish[-1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | runs => \@runs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 516 | ▶ | sub _optional_case_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_optional_case_fields: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 516 | my $f = $SPEC{case}{fields}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 516 | ▶ | return grep { ref $f->{$_} && $f->{$_}{optional} } sort keys %$f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
ref $f->{$_} && $f->{$_}{'optional'}
MC/DC100%2/2
ref $f->{$_} && $f->{$_}{'optional'}
ref $f->{$_}
$f->{$_}{'optional'}
Truth table100%3/3
A && B
A= ref $f->{$_}B= $f->{$_}{'optional'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 163 | ▶ | sub _worse_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_worse_status: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 163 | my ( $self, $x, $y ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 163 | my %rank = ( complete => 0, cancelled => 1, aborted => 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 163 | ▶ | return $rank{$y} > $rank{$x} ? $y : $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # A repetition without its volatile fields, for comparison. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 14 | ▶ | sub _stable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stable: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 14 | my ( $self, $r ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 14 | my %copy = %$r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 14 | delete $copy{duration_ms}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 14 | ▶ | $copy{turns} = [ map { my %t = %$_; delete $t{duration_ms}; \%t } @{ $r->{turns} } ] if $r->{turns}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 14 | return \%copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | #### Shape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 56962 | ▶ | sub _shape { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shape: called CC=41 SCAR=37.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 56962 | my ( $self, $spec, $value, $where, $strict ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 56962 | ▶ | $spec = $SPEC{$spec} || { type => $spec } unless ref $spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$SPEC{$spec} || {'type', $spec}
MC/DC100%1/1
$SPEC{$spec} || {'type', $spec}
$SPEC{$spec}
Truth table100%2/2
A
A= $SPEC{$spec}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 56962 | my $type = $spec->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 56962 | ▶ | unless ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 19639 | ▶ | croak __PACKAGE__.' '.$where.' must not be null' if defined $spec->{null} && !$spec->{null}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $spec->{"null"} and not $spec->{"null"}
MC/DC50%1/2
defined $spec->{"null"} and not $spec->{"null"}
defined $spec->{"null"}
not $spec->{"null"}
Truth table66%2/3
A and not(B)
A= defined $spec->{"null"}B= not $spec->{"null"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 19638 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 37323 | ▶ | if ( $type eq 'object' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 7653 | ▶ | croak __PACKAGE__.' '.$where.' must be an object' unless ref $value eq 'HASH' && !blessed $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value eq "HASH" and not builtin::blessed($value)
MC/DC0%0/2
ref $value eq "HASH" and not builtin::blessed($value)
ref $value eq "HASH"
not builtin::blessed($value)
Truth table33%1/3
A and not(B)
A= ref $value eq "HASH"B= not builtin::blessed($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 7653 | my %out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 7653 | for my $f ( sort keys %{ $spec->{fields} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 50510 | my $fs = $spec->{fields}{$f}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | croak __PACKAGE__.' '.$where.'.'.$f.' is missing' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 50510 | ▶ | if $strict && !exists $value->{$f} && !( ref $fs && $fs->{optional} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$strict and not exists $value->{$f} and not ref $fs && $fs->{"optional"}
$strict and not exists $value->{$f}
ref $fs && $fs->{'optional'}
MC/DC100%4/4
$strict and not exists $value->{$f} and not ref $fs && $fs->{"optional"}
$strict
not exists $value->{$f}
ref $fs
$fs->{'optional'}
Truth table100%5/5
A and not(B) and not(C && D)
A= $strictB= not exists $value->{$f}C= ref $fsD= $fs->{'optional'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 50507 | $out{$f} = $self->_shape( $fs, $value->{$f}, $where.'.'.$f, $strict ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 7601 | return \%out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 29670 | ▶ | if ( $type eq 'array' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 5186 | ▶ | croak __PACKAGE__.' '.$where.' must be an array' unless ref $value eq 'ARRAY' && !blessed $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value eq "ARRAY" and not builtin::blessed($value)
MC/DC0%0/2
ref $value eq "ARRAY" and not builtin::blessed($value)
ref $value eq "ARRAY"
not builtin::blessed($value)
Truth table33%1/3
A and not(B)
A= ref $value eq "ARRAY"B= not builtin::blessed($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 5186 | my $of = $spec->{of}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 5186 | ▶ | my $el = ref $of ? { %$of, null => 0 } : $SPEC{$of} ? { %{ $SPEC{$of} }, null => 0 } : { type => $of, null => 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 5186 | return [ map { $self->_shape( $el, $value->[$_], $where.'['.$_.']', $strict ) } 0 .. $#$value ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 24484 | ▶ | return $self->_any( $value, $where, $strict ) if $type eq 'any'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 22934 | ▶ | if ( $type eq 'bool' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 3465 | ▶ | if ( JSON::MaybeXS::is_bool($value) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 2033 | ▶ | return $value ? JSON::MaybeXS::true() : JSON::MaybeXS::false(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1432 | ▶ | croak __PACKAGE__.' '.$where.' must be a JSON boolean' if $strict || ref $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$strict or ref $value
MC/DC50%1/2
$strict or ref $value
$strict
ref $value
Truth table66%2/3
A or B
A= $strictB= ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 1431 | ▶ | return $value ? JSON::MaybeXS::true() : JSON::MaybeXS::false(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 19469 | ▶ | croak __PACKAGE__.' '.$where.' must be a scalar' if ref $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 19469 | ▶ | if ( $type eq 'int' || $type eq 'num' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type eq "int" or $type eq "num"
MC/DC100%2/2
$type eq "int" or $type eq "num"
$type eq "int"
$type eq "num"
Truth table100%3/3
A or B
A= $type eq "int"B= $type eq "num"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 7462 | ▶ | my $re = $type eq 'int' ? qr/\A-?[0-9]+\z/ : qr/\A-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 7462 | ▶ | croak __PACKAGE__.' '.$where.' must be '.( $type eq 'int' ? 'an integer' : 'a number' ).", got '".$value."'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | unless $value =~ $re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 7461 | my $n = 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 7461 | ▶ | croak __PACKAGE__.' '.$where.' must be at least '.$spec->{min} if defined $spec->{min} && $n < $spec->{min}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $spec->{"min"} and $n < $spec->{"min"}
MC/DC0%0/2
defined $spec->{"min"} and $n < $spec->{"min"}
defined $spec->{"min"}
$n < $spec->{"min"}
Truth table66%2/3
A and B
A= defined $spec->{"min"}B= $n < $spec->{"min"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 7461 | ▶ | croak __PACKAGE__.' '.$where.' must be at most '.$spec->{max} if defined $spec->{max} && $n > $spec->{max}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $spec->{"max"} and $n > $spec->{"max"}
MC/DC100%2/2
defined $spec->{"max"} and $n > $spec->{"max"}
defined $spec->{"max"}
$n > $spec->{"max"}
Truth table100%3/3
A and B
A= defined $spec->{"max"}B= $n > $spec->{"max"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 7460 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 12007 | my $text = ''.$value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 12007 | $self->_check_text( $text, $where ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 12006 | ▶ | if ( $type eq 'enum' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1457 | ▶ | croak __PACKAGE__.' '.$where.": unknown value '".$text."'" unless grep { $_ eq $text } @{ $spec->{values} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | elsif ( $type eq 'time' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 179 | ▶ | croak __PACKAGE__.' '.$where.": not an ISO-8601 time '".$text."'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | unless $text =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:\.[0-9]+)?)?(?:Z|[-+][0-9]{2}:?[0-9]{2})\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | elsif ( $type eq 'url' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 103 | return $self->_clean_url($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 11900 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # Deep copy of free data (arguments, diff values, settings, transcript): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # booleans normalised, objects and image content refused. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 2356 | ▶ | sub _any { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_any: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 2356 | my ( $self, $value, $where, $strict ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 2356 | ▶ | return undef unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 2355 | ▶ | return $value ? JSON::MaybeXS::true() : JSON::MaybeXS::false() if JSON::MaybeXS::is_bool($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2333 | ▶ | croak __PACKAGE__.' '.$where.' holds an object ('.ref($value).'); only plain data goes into a report' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | if blessed $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2332 | ▶ | if ( ref $value eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | croak __PACKAGE__.' '.$where.' holds base64 image content' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | if ( ref $value->{source} eq 'HASH' && ( $value->{source}{type} // '' ) eq 'base64' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 979 | ▶ | || grep { exists $value->{$_} } qw( inline_data inlineData b64_json ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%6/8
ref $value->{"source"} eq "HASH" and ($value->{"source"}{"type"} // "") eq "base64" or grep {exists $value->{$_};} "inline_data", "inlineData", "b64_json"
ref $value->{"source"} eq "HASH" and ($value->{"source"}{"type"} // "") eq "base64"
$value->{"source"}{"type"} // ""
MC/DC66%2/3
ref $value->{"source"} eq "HASH" and ($value->{"source"}{"type"} // "") eq "base64" or grep {exists $value->{$_};} "inline_data", "inlineData", "b64_json"
ref $value->{"source"} eq "HASH"
$value->{"source"}{"type"}
grep {exists $value->{$_};} "inline_data", "inlineData", "b64_json"
Truth table60%3/5
A and B or C
A= ref $value->{"source"} eq "HASH"B= $value->{"source"}{"type"}C= grep {exists $value->{$_};} "inline_data", "inlineData", "b64_json"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 977 | return { map { $_ => $self->_any( $value->{$_}, $where.'.'.$_, $strict ) } keys %$value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 1353 | ▶ | if ( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 38 | return [ map { $self->_any( $value->[$_], $where.'['.$_.']', $strict ) } 0 .. $#$value ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 1315 | ▶ | croak __PACKAGE__.' '.$where.' holds a '.ref($value).' reference' if ref $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 1315 | $self->_check_text( $value, $where ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1311 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 13322 | ▶ | sub _check_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_text: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 13322 | my ( $self, $text, $where ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 13322 | ▶ | croak __PACKAGE__.' '.$where.' holds a data: URL; images go into a report only as { image, sha256, bytes }' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | if $text =~ $DATA_URL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 13318 | ▶ | croak __PACKAGE__.' '.$where.' holds base64 content; images go into a report only as { image, sha256, bytes }' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $text >= 1024 and $text =~ /$BASE64_RUN/
MC/DC100%2/2
length $text >= 1024 and $text =~ /$BASE64_RUN/
length $text >= 1024
$text =~ /$BASE64_RUN/
Truth table100%3/3
A and B
A= length $text >= 1024B= $text =~ /$BASE64_RUN/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | if length $text >= 1024 && $text =~ $BASE64_RUN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 13317 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 103 | ▶ | sub _clean_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_url: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 103 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 103 | my $uri = URI->new($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 103 | ▶ | return $text unless $uri->scheme; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 103 | $uri->fragment(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 103 | ▶ | $uri->userinfo(undef) if $uri->can('userinfo'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 103 | ▶ | if ( $uri->can('query_form') && defined $uri->query ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$uri->can("query_form") and defined $uri->query
MC/DC50%1/2
$uri->can("query_form") and defined $uri->query
$uri->can("query_form")
defined $uri->query
Truth table66%2/3
A and B
A= $uri->can("query_form")B= defined $uri->query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 24 | my @q = $uri->query_form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 24 | my @keep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 24 | ▶ | while ( my ( $k, $v ) = splice @q, 0, 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 37 | ▶ | push @keep, $k, $v unless $k =~ $SECRET_PARAM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 24 | $uri->query_form( \@keep ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 24 | ▶ | $uri->query(undef) unless @keep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 103 | return $uri->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | #### cai-platform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 5 | ▶ | sub from_cai_platform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_cai_platform: called CC=29 SCAR=34.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 5 | my ( $class, $data, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | croak __PACKAGE__.'->from_cai_platform needs the decoded --report hash' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 5 | ▶ | unless ref $data eq 'HASH' && ref $data->{runs} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $data eq "HASH" and ref $data->{"runs"} eq "ARRAY"
MC/DC50%1/2
ref $data eq "HASH" and ref $data->{"runs"} eq "ARRAY"
ref $data eq "HASH"
ref $data->{"runs"} eq "ARRAY"
Truth table66%2/3
A and B
A= ref $data eq "HASH"B= ref $data->{"runs"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 4 | ▶ | my $grading = $arg{grading} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg{'grading'} || {}
MC/DC100%1/1
$arg{'grading'} || {}
$arg{'grading'}
Truth table100%2/2
A
A= $arg{'grading'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 4 | ▶ | my $suites = $arg{suites} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg{'suites'} || {}
MC/DC100%1/1
$arg{'suites'} || {}
$arg{'suites'}
Truth table100%2/2
A
A= $arg{'suites'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 4 | ▶ | my %model = map { $_ => 1 } @{ $data->{models} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{'models'} || []
MC/DC0%0/1
$data->{'models'} || []
$data->{'models'}
Truth table50%1/2
A
A= $data->{'models'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 4 | my ( %group, @order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 4 | for my $row ( @{ $data->{runs} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 8 | ▶ | my $key = join "\0", map { defined $_ ? $_ : '' } $row->{target}, $row->{suite_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 8 | ▶ | push @order, $key unless $group{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 8 | push @{ $group{$key} }, $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 4 | my %run_status = ( done => 'complete', cancelled => 'cancelled', failed => 'aborted' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 4 | my @runs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 4 | for my $key ( @order ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 4 | my @rows = @{ $group{$key} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 4 | my $first = $rows[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 4 | my $sid = $first->{suite_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 4 | ▶ | my $meta = $suites->{$sid} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$suites->{$sid} || {}
MC/DC100%1/1
$suites->{$sid} || {}
$suites->{$sid}
Truth table100%2/2
A
A= $suites->{$sid}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 4 | ▶ | my $repeat = ( $data->{repeat_by_suite} || {} )->{$sid}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{'repeat_by_suite'} || {}
MC/DC0%0/1
$data->{'repeat_by_suite'} || {}
$data->{'repeat_by_suite'}
Truth table50%1/2
A
A= $data->{'repeat_by_suite'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 4 | ▶ | $repeat = @rows unless defined $repeat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 4 | ▶ | croak __PACKAGE__.'->from_cai_platform: '.scalar(@rows).' runs of '.$first->{target}.'/'.$sid.' for repeat '.$repeat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | if @rows > $repeat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 3 | my $status = 'complete'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 3 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 3 | my ( %case, @case_order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 3 | for my $i ( 0 .. $#rows ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 5 | my $row = $rows[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | my $s = $run_status{ $row->{status} // '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 5 | ▶ | or croak __PACKAGE__.'->from_cai_platform: unknown run status '.( $row->{status} // '(none)' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$row->{"status"} // ""
$row->{"status"} // "(none)"
MC/DC0%0/1
$row->{"status"} // ""
$row->{"status"}
MC/DC0%0/1
$row->{"status"} // "(none)"
$row->{"status"}
Truth table50%1/2
A
A= $row->{"status"}
Truth table50%1/2
A
A= $row->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 4 | $status = $class->_worse_status( $status, $s ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 4 | ▶ | $error = $row->{error} unless defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 4 | ▶ | for my $c ( @{ $row->{cases} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$row->{'cases'} || []
MC/DC0%0/1
$row->{'cases'} || []
$row->{'cases'}
Truth table50%1/2
A
A= $row->{'cases'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 7 | my $id = $c->{case_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 7 | ▶ | unless ( $case{$id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 5 | ▶ | my $cm = ( $meta->{cases} || {} )->{$id} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
+($meta->{'cases'} || {})->{$id} || {}
$meta->{'cases'} || {}
MC/DC100%1/1
+($meta->{'cases'} || {})->{$id} || {}
$meta->{'cases'}
Truth table100%2/2
A
A= $meta->{'cases'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | $case{$id} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | case_id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | title => $c->{title}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | difficulty => defined $c->{difficulty} ? $c->{difficulty} : $cm->{difficulty}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 5 | ▶ | ( map { $_ => $cm->{$_} } qw( tags tier weight hard untrusted ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | repetitions => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 5 | push @case_order, $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 7 | ▶ | my $g = defined $row->{id} ? ( $grading->{ $row->{id} } || {} )->{$id} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$$grading{$row->{'id'}} || {}
MC/DC100%1/1
$$grading{$row->{'id'}} || {}
$$grading{$row->{'id'}}
Truth table100%2/2
A
A= $$grading{$row->{'id'}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 7 | push @{ $case{$id}{repetitions} }, $class->_cai_repetition( $c, $g, $i + 1, $repeat ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | push @runs, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | target => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | label => $first->{target}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | engine => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | model => $model{ $first->{target} // '' } ? $first->{target} : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | url => $data->{base_url}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | variant => { name => undef, settings => undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | suite => { id => $sid, version => $meta->{version}, topic => $first->{topic}, digest => $meta->{digest} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | repeat => $repeat, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | status => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | error => $error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 1 | ▶ | cases => [ map { $case{$_} } @case_order ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$first->{"target"} // ""
MC/DC0%0/1
$first->{"target"} // ""
$first->{"target"}
Truth table50%1/2
A
A= $first->{"target"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 1 | return $class->new( started_at => undef, runs => \@runs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 7 | ▶ | sub _cai_repetition { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cai_repetition: called CC=25 SCAR=33.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 7 | my ( $self, $c, $g, $n, $repeat ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 7 | ▶ | my $exceeded = $c->{exceeded} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 7 | ▶ | my $st = $c->{status} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->{"status"} // ""
MC/DC0%0/1
$c->{"status"} // ""
$c->{"status"}
Truth table50%1/2
A
A= $c->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | my $status = ( $exceeded && ( $st eq 'failed' || $st eq 'ungraded' ) ) ? 'turn_limit' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | : $st eq 'ungraded' ? 'uncertain' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 12 | ▶ | : ( grep { $_ eq $st } qw( passed failed error context_exceeded ) ) ? $st | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 7 | ▶ | : croak __PACKAGE__.'->from_cai_platform: unknown case status '.( length $st ? $st : '(none)' ).' for '.$c->{case_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%4/6
$exceeded and $st eq "failed" || $st eq "ungraded"
$st eq "failed" or $st eq "ungraded"
MC/DC33%1/3
$exceeded and $st eq "failed" || $st eq "ungraded"
$exceeded
$st eq "failed"
$st eq "ungraded"
Truth table75%3/4
A and B or C
A= $exceededB= $st eq "failed"C= $st eq "ungraded"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 6 | my ( $rules, $diff, $score ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 6 | ▶ | my @calls = map { +{ tool => undef, args => undef, succeeded => undef, sim_gap => undef } } 1 .. ( $c->{tool_calls} || 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->{'tool_calls'} || 0
MC/DC0%0/1
$c->{'tool_calls'} || 0
$c->{'tool_calls'}
Truth table50%1/2
A
A= $c->{'tool_calls'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 6 | my $gaps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 6 | ▶ | if ( ref $g eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | $rules = [ map { +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | title => $_->{title}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | kind => $_->{kind}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | required => $_->{required} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | passed => $_->{passed} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | reason => $_->{detail}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | sim_gap => $_->{sim_gap}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | ▶ | } } grep { ( $_->{kind} // '' ) ne 'turns' } @{ $g->{rules} || [] } ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%2/4
$_->{"kind"} // ""
$g->{'rules'} || []
MC/DC0%0/1
$_->{"kind"} // ""
$_->{"kind"}
MC/DC0%0/1
$g->{'rules'} || []
$g->{'rules'}
Truth table50%1/2
A
A= $_->{"kind"}
Truth table50%1/2
A
A= $g->{'rules'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 1 | my $passed = grep { $_->{passed} } @$rules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | ▶ | $score = @$rules ? 0 + sprintf( '%.4f', $passed / @$rules ) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 1 | ▶ | $diff = [ map { +{ path => $_->{path}, before => $_->{before}, after => $_->{after} } } @{ $g->{diff} || [] } ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$g->{'diff'} || []
MC/DC0%0/1
$g->{'diff'} || []
$g->{'diff'}
Truth table50%1/2
A
A= $g->{'diff'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 1 | ▶ | $gaps = [ map { +{ call => $_->{index}, tool => $_->{tool}, gap => $_->{gap} } } @{ $g->{sim_gaps} || [] } ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$g->{'sim_gaps'} || []
MC/DC0%0/1
$g->{'sim_gaps'} || []
$g->{'sim_gaps'}
Truth table50%1/2
A
A= $g->{'sim_gaps'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 1 | for my $gap ( @$gaps ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 1 | ▶ | my $call = defined $gap->{call} ? $calls[ $gap->{call} ] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 1 | ▶ | next unless $call; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 1 | $call->{tool} = $gap->{tool}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | $call->{sim_gap} = $gap->{gap}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 5 | ▶ | $score = $exceeded ? undef : $c->{score}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 5 | ▶ | $gaps = [ map { +{ call => undef, tool => undef, gap => $_ } } @{ $c->{sim_gaps} || [] } ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->{'sim_gaps'} || []
MC/DC0%0/1
$c->{'sim_gaps'} || []
$c->{'sim_gaps'}
Truth table50%1/2
A
A= $c->{'sim_gaps'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 6 | ▶ | my $tok = sub { my ( $v ) = @_; return $v ? $v : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | repetition => $n, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | seed => $repeat > 1 ? $n : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | status => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | score => $score, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | error => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | finish_reason => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | duration_ms => $c->{duration_ms}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | rules => $rules, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | diff => $diff, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 14 | ▶ | turns => [ map { +{ map { $_ => undef } qw( input_tokens output_tokens reasoning_tokens duration_ms finish_reason calls ) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->{'turns'} || 0
MC/DC0%0/1
$c->{'turns'} || 0
$c->{'turns'}
Truth table50%1/2
A
A= $c->{'turns'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 .. ( $c->{turns} || 0 ) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | tokens => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | input => $tok->( $c->{prompt_tokens} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | output => $tok->( $c->{completion_tokens} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | reasoning => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | input_max => $tok->( $c->{prompt_tokens_max} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | calls => \@calls, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | sim_gaps => $gaps, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | forbidden_calls => $c->{forbidden_calls}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | injection_held => $c->{injection_held}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 6 | ▶ | transcript => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 27 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 27 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||