NAME

Langertha::Raider::FileTools::ReadState - Internal record of the files a run has read, for read-before-write in the file tools

VERSION

version 0.504

SYNOPSIS

# Internal to Langertha-Raider -- no API promise.
my $state = Langertha::Raider::FileTools::ReadState->new;
$state->record( '/abs/real/path', bytes => $raw );          # a whole read
$state->record( '/abs/real/path', partial => 1 );           # offset / limit
my $problem = $state->write_problem('/abs/real/path');      # undef: may write
$state->clear;                                              # a new run

DESCRIPTION

Internal module. Its interface may change without notice.

What the file tools (Langertha::Raider::FileTools) know about the files the model has seen in this run (ADR 0023): for each real absolute path the modification time and size it had when it was read or written, and for a whole read the SHA-256 of its bytes. write_file, edit_file and multi_edit ask "write_problem" before they change a file that exists: a file that was never read, or that changed on disk since, is refused with Claude Code's words. A read with offset / limit counts as read, as in Claude Code; a write or an edit by the tools counts as a whole read of what they wrote. The application empties the record at the start of every run ("begin_run" in Langertha::Raider::Application).

record

$state->record( $real_path, bytes => $raw );     # whole file, as read or written
$state->record( $real_path, partial => 1 );      # part of it

Notes that the file at $real_path (absolute, symbolic links resolved) is known as it is on disk now. bytes are the raw bytes the tool read or wrote; with them a later change of the modification time alone (touch, a save without change) is not taken for a change.

has_read

$state->has_read($real_path);

True when the file was read (or written by the tools) in this run.

write_problem

my $text = $state->write_problem($real_path);

Nothing when a tool may change the file at $real_path: it does not exist, or it was read in this run and is unchanged since. Otherwise Claude Code's error text: File has not been read yet. Read it first before writing to it. or File has been modified since read, either by the user or by a linter. Read it again before attempting to write it. A file read whole whose modification time or size changed but whose bytes did not still counts as unchanged.

forget

Drops what is known about one path.

clear

Forgets every file: the start of a new run.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-raider/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

https://raudssus.de/