Module-Boundary Recovery Should Be Willing to Abstain
Recovered bundles often lack original file boundaries. A structural system should use exact evidence where it exists, deterministic fallbacks where it does not, and refuse contradictory paths.
Bundling can erase the file boundaries engineers originally wrote.
A large recovered chunk may contain dozens of modules flattened into one scope, wrappers with partial identity, or code whose original grouping is permanently unavailable. Recreating files is therefore a structural inference problem—not a formatting task.
The system needs permission to abstain.
Start with atomic regions
Before proposing modules, the analyzer needs source-backed atomic regions that cannot be split casually. Boundaries can be informed by:
- source maps and preserved module paths;
- wrapper and loader units;
- export getters and namespace members;
- resolver-linked requests;
- anchored comments or build metadata;
- closure and dependency structure;
- top-level effects and state ownership.
Exact evidence should pin a boundary or path. Weaker semantic tokens can suggest a name only when they are structurally tied to the region.
Never invent certainty from a generic label
Words found in user-facing text, URLs, secrets, or minifier tokens are poor module names. A chunk mentioning “checkout” does not necessarily own checkout behavior.
When no reliable role survives, a deterministic structural hash is more honest than checkout-service.ts. The hash says “this unit is stable and distinct” without inventing business meaning.
Naming can improve later when source-backed context appears.
Contradictory paths should remain unresolved
One unit may receive path evidence from several sources. If two exact constraints imply different destinations, choosing one by score hides a real conflict.
The path-level result should abstain and retain both explanations. Unconstrained units can stay under a neutral recovered namespace.
This keeps the candidate runnable while avoiding a false statement about ownership.
Grouping and destination are separate claims
Evidence may prove that several regions are cohesive without proving where they belong.
A structural planner can report a pathless cohesive tail or a grouping-only certificate. It should not serialize that as permission to create a named module under a guessed owner.
Destination selection is stronger. It needs closure, ownership, routing, coupling, and a reviewed path binding.
Determinism is a safety property
The same source and evidence should produce the same plan. A boundary analysis can run twice and compare a digest over canonical output.
If the digests differ, the system abstains and discards its own plan. Timestamps, machine paths, and runtime IDs should not influence the result.
Determinism makes review and stale-plan checks possible. It also exposes hidden nondeterminism before mutation begins.
Benchmarks must withhold the answer
Source maps can provide ground truth for evaluating boundary recovery. They should be withheld from the recovery run being measured.
The benchmark can then compare predicted groups with dominant original sources, while excluding mixed or unmapped regions from recoverable recall. Metrics should remain separated by recoverability tier rather than averaged into one flattering number.
Abstention preserves future options
A guessed module boundary creates imports, paths, and ownership that later work must undo. An abstained region remains less elegant but stays connected to its evidence.
KodeProof’s structural work prefers a smaller set of defensible moves over a fully decomposed fiction. In recovered code, “we can prove these regions belong together, but not what the original file was called” is a successful result.