Skip to content

fort14_io: reader collapses present-but-empty and absent boundary sections (empty ≡ absent) — expose presence or ratify the contract #259

Description

@t-step

Summary

  • Reader collapses present-but-empty and absent

    ↪ Both fort.14 read paths reduce "the NOPE/NBOU boundary section was physically in the file but declared zero segments" and "the file had no boundary section at all" to the same empty result, so a downstream consumer cannot tell a genuinely boundaryless mesh from one whose boundary topology was stripped in its lineage.

    ▸ Call sites

      a. `src/chilmesh/CHILmesh.py:2722` catches `IndexError` on a truncated file and leaves `boundary_segments` empty.
    
          ↪ The comment reads *"Boundary section absent (legacy mesh) — leave segments empty"*, but a present `0`/`0` NOPE-NBOU block reaches the same `boundary_segments == []` state, and nothing records which happened.
    
      b. `src/chilmesh/fort14_io.py` `read_fort14_raw()` returns empty `open_boundaries` / `flow_boundaries` with no presence signal on `Fort14Raw`.
    
          ↪ The docstring states *"A legacy mesh with no boundary block is accepted"*, so both absent and present-empty yield empty lists and there is no `boundaries_present`-style field to disambiguate.
    

Why it matters

  • Empty vs absent is semantically load-bearing

    ▸ Downstream symptom

      ↪ Valence #13 documented that `WNAT_Test.14` / `WNAT_Onur.14` carry `0` declared boundaries because the section was discarded in their ADmesh-regenerated lineage, indistinguishable via the parser from a legitimately boundaryless mesh, which lost Bermuda plus 112 other land segments on round-trip.
    

    ▸ Current workaround is a heuristic

      ↪ That issue proposed a `topologically_complete` classifier (detect an island-shaped elevation cluster with no boundary ring) precisely because the parser gives no authoritative present-vs-absent signal to key off.
    

    ▸ Writer half is already resolved

      ↪ The mirror concern on the write side was fixed upstream in v1.3.0 (commit `8ed8758`, cited by Valence #216): `write_fort14` now always emits the trailing NOPE/NBOU block (`0/0/0/0` when empty), so only the *reader* still conflates the two states.
    

Proposed resolution (pick one)

  • Two viable contracts

    I. Expose presence

      ↪ Add a `boundaries_present: bool` (or equivalent) to `Fort14Raw` and mirror it on `CHILmesh.boundary_segments` provenance, set `True` only when a NOPE/NBOU block was physically parsed, so present-empty and absent are distinguishable.
    

    II. Ratify empty equals absent

      ↪ Explicitly document that the reader treats an empty and an absent boundary section as identical by contract, closing the ambiguity as a deliberate decision rather than an accident of `IndexError` handling.
    

References


Filed via Claude Code at operator request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions