Skip to content

The generated-mesh directory has no namespace separation: 93 .meshes trees separated only by accident of cwd #724

Description

@lmoresi

The concern

Maintainer ruling (2026-09-10): .meshes is a choice that would not be made
now. It is a flat directory of generated meshes with no proper namespace
separation — an accident waiting to happen.

What is actually there

src/underworld3/meshing/_mesh_files.py is candid about the mechanism:

It is not a cache: every construction regenerates both, and nothing checks
whether they already exist.

The name is derived from the mesh PARAMETERS, so two processes building the
same geometry in one working directory choose the same name.

Two things follow that the module does not claim to solve.

1. The only separation is the working directory. DEFAULT_MESH_FILE_DIR
is the relative path ".meshes", so a tree appears wherever a process happens
to be run from. The 2026-09 audit found 93 of them — one per worktree plus
the main checkout — holding 4.4 GB between them, 544 files in the main one
alone. UW_MESH_CACHE_DIR exists to give a job somewhere of its own but is set
nowhere in the repository, the pixi tasks, or scripts/test.sh. Nothing is
choosing that separation; it is falling out of cwd.

2. Identical parameters, different code, same filename. The name carries
the mesh parameters and nothing about the code that generated it. Two worktrees
on different meshing branches building the same geometry agree on the filename
and disagree about the contents. Atomic writes (#563) make sure a reader sees a
complete file rather than a half-written one; they do not make it the right
file. #618 was the same class narrowed to one generator — elementRes missing
from the StructuredQuadBox name — and was fixed by adding the missing
parameter, which does not generalise to "the code changed".

3. Nothing reclaims. Files are regenerated every construction and never
deleted, so each directory grows without bound for the lifetime of its
worktree.

Worth considering

  • Give the directory a namespace that includes what generated it, not only what
    it geometrically is.
  • Or drop the shared location: since every construction regenerates anyway,
    per-process scratch under a temporary directory costs nothing and removes the
    collision surface entirely.
  • Either way, set UW_MESH_CACHE_DIR for the test suite so a parallel run is
    not sharing a namespace with whatever else is running from that cwd.

Real outputs that need keeping live in ~/+Simulations, not here, so nothing
in these directories is worth preserving; the audit cleared all 93.

Underworld development team with AI support from Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions