App-FuguBench

 view release on metacpan or  search on metacpan

lib/App/FuguBench/Traces.pm  view on Meta::CPAN

#
# The verb derives that name from the checkout root, it matches the
# trace directories of the checkout, and it prints one line for each
# session in them that holds a request.
#
# The derivation cuts the root at the last .claude/worktrees/ marker,
# because a nested checkout holds the marker more than one time
# (TRACE-NAME-1). Three name forms belong to one checkout: the
# checkout itself, a worktree of it, and a project clone in either of
# them. The match takes the exact forms, so a sibling checkout, such
# as a backup, stays out (TRACE-NAME-2).
#
# The option --root names a trace root in place of the one under the
# home of the operator. The option --name replaces the derived name
# (TRACE-NAME-3).
#
# The columns are:
#
#     session  the first eight characters of the session identifier
#     start    the time of the first record of the session, in UTC
#     reqs     the requests of the main session

lib/App/FuguBench/Traces.pm  view on Meta::CPAN


	return [ $in, $u->{output_tokens} // 0 ];
}

# _repo_edit($block, $checkout):
#	True when one edit block changes a repository file. The target
#	is file_path, or notebook_path for a notebook.
#
#	An absolute target must sit inside the checkout, on a
#	directory boundary, so a write to the home of the operator, or
#	to a sibling such as <checkout>-backup, is no repository file.
#	A relative target sits inside it, because the path resolves
#	against the working directory of the session. A block with no
#	target counts as an edit, which is the safe direction
#	(TRACE-PANEL-3).
#
#	A target in scratch space is no repository file: a path under
#	scratch/, or a SCRATCHPAD*.md file.
sub _repo_edit ( $block, $checkout )
{
	my $input = $block->{input}     // {};

lib/App/FuguBench/Traces.pod  view on Meta::CPAN

first marker names the wrong checkout.

A worktree holds a F<.toolingrc> of its own, so the walk stops in the
worktree and the cut reaches the checkout. The sessions of a worktree
then join the sessions of the checkout that holds it.

=head2 THE MATCH

Three name forms belong to one checkout: the checkout itself, a
worktree of it, and a project clone in either of them. The match takes
the exact forms, so a sibling checkout, such as a backup, stays out.

=head2 THE OPTIONS

C<--root E<lt>dirE<gt>> names a trace root in place of the directory
under the home of the operator. A trace root that is no directory is a
failure, and the message holds the path.

C<--name E<lt>nameE<gt>> replaces the derived name. The verb then
derives no name. It still reads the checkout, because the edits column
takes its boundary from the checkout path.

t/fugubench/traces.t  view on Meta::CPAN

			    . '/-x-Work-FuguBSD/memory/session-rules.md'
		)
	    )
);
_write(
	"$main/dddddddd-dddd.jsonl",
	_record( 'req_d1', [ 1, 2, 3 ], 4,
		_tool( 'Agent', description => 'Panel review member 1' ) )
	    . _record( 'req_d2', [ 1, 2, 3 ], 4,
		_tool( 'Write',
			file_path => "$checkout-backup/spec/workspace.md" ) )
);

# One session of the panel of an early campaign, before the org pack
# shipped a reviewer agent. The launch carries a catch-all type, which
# names no role, so the description decides and the launch is a round.
_write(
	"$main/aaaaaaaa-aaaa.jsonl",
	_record( 'req_c1', [ 1, 2, 3 ], 4,
		_tool(
			'Agent',
			subagent_type => 'general-purpose',
			description   => 'Panel review member 1'
		) )
);

# One worktree of the checkout, one project clone in it, and one
# sibling checkout that the match must reject.
_write( "$root/fixture--claude-worktrees-w1/22222222-2222.jsonl",
	_session('w') );
_write( "$root/fixture-backup/33333333-3333.jsonl",           _session('b') );
_write( "$root/fixture-Projects-Tooling/44444444-4444.jsonl", _session('p') );

my ( $code, $out ) = _traces( $cwd, $root, 'fixture' );
is( $code, 0, 'traces exits zero' );

my ($row) = grep { /^11111111\b/ } split /\n/, $out;
ok( $row, 'the main session gets a row' ) or diag $out;
my @field = split q{ }, $row // q{};

is( $field[1], '2026-09-09T09:59', 'the start time is the first record' );



( run in 1.279 second using v1.01-cache-2.11-cpan-5e09290becf )