Precheck fs
precheck_fs
Filesystem-resolving prechecks over a batch_edit operation set.
This layer sits on top of the pure in-memory checks of
:mod:axm_edit.core.precheck and adds the only diagnostics that require
looking at the disk: a create aimed at an existing path, an anchor that
is absent from (or duplicated in) the real file, and a line that is wider
than the 88-char default batch_edit lints against yet still legal for
the project.
Strictly read-only: every path goes through :func:resolve_safe, and files
are only probed (is_file) and read (read_text). Nothing here creates,
mutates or removes anything on disk.
check_anchors_on_disk(root, operations)
Resolve every replace anchor against the file actually on disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Project root the batch would be applied to. |
required |
operations
|
Sequence[FsOperation]
|
Operations in batch order (models or raw payloads). |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
|
list[CheckDiagnostic]
|
|
list[CheckDiagnostic]
|
|
Source code in packages/axm-edit/src/axm_edit/core/precheck_fs.py
check_create_targets(root, operations)
Flag every create whose target already exists under root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Project root the batch would be applied to. |
required |
operations
|
Sequence[FsOperation]
|
Operations in batch order (models or raw payloads). |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
One |
Source code in packages/axm-edit/src/axm_edit/core/precheck_fs.py
check_line_length(op_index, file, new, limit)
Flag lines of new wider than 88 chars but within limit.
Pure function: no path is resolved and no file is read.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op_index
|
int
|
0-indexed position of the operation in the batch. |
required |
file
|
str
|
Relative path targeted by that operation. |
required |
new
|
str
|
Replacement (or created) text to measure, line by line. |
required |
limit
|
int
|
The project's configured |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
One |
list[CheckDiagnostic]
|
|
Source code in packages/axm-edit/src/axm_edit/core/precheck_fs.py
check_rewrite_targets(root, operations)
Classify every rewrite target against the file actually on disk.
The verdict is NOT decided here: the observed facts are handed to
:func:~axm_edit.core.rewrite.classify_rewrite_target — the single
predicate the apply path shares — and its returned code IS the diagnostic
code, so the dry run and the apply can never drift apart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Project root the batch would be applied to. |
required |
operations
|
Sequence[FsOperation]
|
Operations in batch order (models or raw payloads). |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
One blocking diagnostic per refused rewrite target |
list[CheckDiagnostic]
|
( |
list[CheckDiagnostic]
|
|
Source code in packages/axm-edit/src/axm_edit/core/precheck_fs.py
parse_rewrite_op(raw)
Normalise a raw rewrite payload into its canonical model.
Deliberately lenient — the payload-shape verdict belongs to
:func:~axm_edit.core.precheck.check_rewrite_keys, so a rewrite that
omits its checksum still surfaces that diagnostic instead of aborting
the whole read-only pass with a validation error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
Mapping[str, object]
|
Rewrite mapping as authored, before validation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
RewriteOp
|
class: |
RewriteOp
|
ill-typed members are normalised to the empty string. |
Source code in packages/axm-edit/src/axm_edit/core/precheck_fs.py
run_fs_checks(root, operations)
Aggregate every filesystem-resolving check plus the static ones.
The static checks of :func:run_static_checks are delegated with the
contents read from disk, so they see the real files instead of an
empty mapping. The whole pass is read-only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Project root the batch would be applied to. |
required |
operations
|
Sequence[FsOperation]
|
Operations in batch order (models or raw payloads). |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
Every diagnostic found, sorted by increasing |