File bytes
file_bytes
Deterministic data layer for the on-disk byte report.
The MCP JSON transport decodes the payload once: an escape sequence written in a tool argument reaches the tool as the literal character it denotes. These models describe what a file actually contains on disk, so a write can be verified byte for byte. They carry data only -- detection logic and I/O live elsewhere.
Every model below carries # type: ignore[explicit-any] on its class line for
the same reason as :mod:axm_edit.models.check: the pydantic mypy plugin
synthesizes __init__(**data: Any), which strict disallow_any_explicit
rejects. The ignore is error-coded and local; no configuration is relaxed.
Verdict = Literal['ok', 'literal_where_escaped_expected', 'escaped_where_literal_expected', 'mismatch', 'decode_error']
module-attribute
Closed set of outcomes a byte-level inspection may report.
FileBytesReport
Bases: BaseModel
Byte-level verdict for one file.
The occurrence lists are deliberately bounded by the caller; the
*_total counters keep that truncation explicit instead of silent.
Attributes:
| Name | Type | Description |
|---|---|---|
sha256 |
str
|
Digest of the raw file bytes. |
size_bytes |
int
|
Size of the file on disk. |
encoding_ok |
bool
|
Whether the bytes decoded cleanly as UTF-8. |
verdict |
Verdict
|
Outcome of the inspection. |
non_ascii |
list[NonAsciiOccurrence]
|
Bounded sample of non-ASCII characters found. |
literal_escapes |
list[LiteralEscapeOccurrence]
|
Bounded sample of literal escape sequences found. |
non_ascii_total |
int
|
Untruncated count of non-ASCII characters. |
literal_escapes_total |
int
|
Untruncated count of literal escapes. |
mismatch |
MismatchReport | None
|
Populated when the bytes diverge from what was expected. |
hint |
str | None
|
Actionable remediation advice, when one applies. |
Source code in packages/axm-edit/src/axm_edit/models/file_bytes.py
LiteralEscapeOccurrence
Bases: BaseModel
A literal escape sequence found verbatim in the file content.
Attributes:
| Name | Type | Description |
|---|---|---|
line |
int
|
1-indexed line where the sequence starts. |
col |
int
|
0-indexed column within that line. |
sequence |
str
|
The raw characters as they exist on disk -- a backslash followed by its escape body -- never decoded. |
byte_offset |
int
|
Offset of the sequence in the raw file bytes. |
Source code in packages/axm-edit/src/axm_edit/models/file_bytes.py
MismatchReport
Bases: BaseModel
Where and how the on-disk bytes diverge from what was expected.
Attributes:
| Name | Type | Description |
|---|---|---|
first_diff_offset |
int
|
Byte offset of the first divergence. |
expected_repr |
str
|
Printable rendering of the expected bytes. |
actual_repr |
str
|
Printable rendering of the bytes actually on disk. |
Source code in packages/axm-edit/src/axm_edit/models/file_bytes.py
NonAsciiOccurrence
Bases: BaseModel
A single non-ASCII character found in the decoded file content.
Attributes:
| Name | Type | Description |
|---|---|---|
line |
int
|
1-indexed line where the character was found. |
col |
int
|
0-indexed column within that line. |
char |
str
|
The character itself, verbatim. |
codepoint |
str
|
Its |
byte_offset |
int
|
Offset of the character in the raw file bytes. |