Skip to content

The §6 draws gate reports a MemoryError as malformed producer input (register C-124) #336

Open

Description

@Polichinel

Register entry: C-124 (reports/technical_risk_register.md), Tier 3.
Found by /code-review on fix/coverage-region-must-be-declared-113, 2026-11-18.

What the code does

views_postprocessing/delivery/draws.py:83-94 wraps the payload coercion in a bare except Exception:

try:
    arr = np.asarray(values)
except Exception as exc:
    raise DrawsCollapseError(
        f"{label}: the payload could not be read as an array at all "
        f"({type(exc).__name__}: {exc}) — this is malformed input, not a collapsed "
        f"forecast. Nothing about the draws has been checked."
    ) from exc

That message is a diagnosis, and it is correct only for the failure it was written for: ragged input, which np.asarray reports as a ValueError.

Why that is a problem

MemoryError is a subclass of Exception. An out-of-memory failure while materializing a large draws payload is therefore reported to the operator as the producer published a malformed artifact, and the reader is sent upstream to views-models or views-pipeline-core to look for a defect that is not there. The real fault — memory on the delivering host — is in the traceback that this raise ... from exc chain keeps but the message contradicts.

This repository has measured that exact failure on this path twice:

  • C-32 — run 0 was OOM-killed at 23.8 GB on the 31 GB host during the historical enrichment join.
  • C-101 — the streaming fix: downloading every shard of a target before decoding the first made peak memory 3.06x the delivered frame.

The streaming fix is what keeps this cheap today. A larger sample width is what makes it expensive again, which is why this is registered rather than dismissed: S_MIN is 2 for both products now, and both the FAO floor (128) and the CRAF'd floor (1,024) are open decisions.

Severity, stated honestly

Tier 3, not Tier 2. The gate still refuses and nothing ships, so there is no partner-facing correctness consequence. What is lost is the operator's time and the correct first move in a diagnosis.

The fix

Narrow the catch to the failures the message describes, and let everything else propagate with its own traceback:

except (ValueError, TypeError) as exc:

One line, plus one test asserting that an error which is neither of those is not relabelled. ValueError covers ragged input; TypeError covers an object np.asarray cannot interpret at all.

Why it was not fixed on sight

The branch that found it exists to fix C-113 in delivery/coverage.py and the two managers (#335). delivery/draws.py has two other open register entries about its own docstring (C-120, C-123) and was last touched by a separate pull request for exactly that reason. Mixing an unrelated narrowing into it would make each change harder to review than it is alone.

Trigger

When the first global forecast delivery is cut, or when either product's S_MIN rises — both enlarge the array this line materializes. Also whenever anyone diagnoses a failed delivery from this gate's message rather than from the run log.

Related

  • Register C-123 — the same function's other failure of discrimination: declared int arguments are unenforced, so a non-int s_min escapes as a TypeError from check 3.
  • Register C-32, C-101 — the measured OOMs this message would mislabel.
  • ADR-008 — log persistently and raise. The narrowed catch should keep that.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9

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