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