Skip to content

Hunt for values that were never computed but are returned as measurements (hardcoded constants, pinned fixture counts, name-prefix censuses) #726

Description

@gsdali

The class

A value that was never computed, returned through an API whose shape says it was measured. The
caller cannot tell the difference, because a fabricated answer and a real one have the same type,
the same plausible magnitude, and no error channel between them.

This keeps recurring, has been found by accident every time, and nothing in the tree looks for it.
Opening this to make it something we hunt rather than something we stumble into.

Confirmed instances

Production code returning a constant that reads as a measurement:

Tests pinning a hardcoded number that encodes the bug rather than the answer:

Censuses reporting a count nobody measured: #558 said 14, measured 28. #571 said 3, measured 6.
#583 said five, measured six. #595 said six, measured nine. #640 said 13, measured 20. The pattern
is a count derived from a name prefix rather than from the behaviour.

Why it survives review

All three sub-kinds pass every gate we have. The value has the right type, so it compiles. It has a
plausible magnitude, so it does not look wrong. The test asserting it is green, so CI is green. A
--self-test over it can be 6/6 while proving nothing, which is the exact failure
okf/policies/prove-the-test-fails.md was written about after it happened twice in one script.

The common root is that absence and zero are spelled the same way. 0 self-intersections, 0
concave edges, 0.0 error, an empty array: each is both the "nothing here" answer and the "never
looked" answer, and the API offers no way to distinguish them. #583, #595 and #609 all resolved the
same way, by making the not-measured case representable (nil, a sentinel that cannot collide) so
the two stop sharing a spelling.

Proposed work

  1. Sweep for the production form. Start from the 14 sites where a comment already admits it
    (grep -rniE "would require|not implemented|placeholder|hardcod" over Sources/), then the
    harder set: any bridge field assigned a literal on a path that reads like a computation. For each,
    decide: compute it, make the absence representable, or remove the field. selfIntersectionCount
    is the obvious first one, and removal looks right, since Shape.isSelfIntersecting(timeout:)
    already answers it properly.
  2. Sweep the test form. Any #expect(x.count == <literal>) on a fixture whose geometry nobody
    re-derived. The check that works is the OCCTEdgeGetConvexity depends on face argument order, so detectPocketsAAG() reports a pocket on a plain convex box #703 one: assert the fixture does what its name says
    (volume actually removed, faces actually shared) before asserting the count. A pinned count with
    no accompanying assertion about the fixture is the smell.
  3. Consider a gate script. Detecting "this literal was never derived" is not decidable in
    general, but the narrow form is: a struct field assigned only a literal across every path in its
    own constructor. Worth a spike before committing to it.

Scope 1 and 2 for v2.0.0 if they stay tractable; the gate script is a follow-up.

Related: #605, #609, #583, #595, #522, #640, #703, #725. Policy:
okf/policies/prove-the-test-fails.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cluster:kernelOCCTSwift core geometry/meshing/IO librariesphase:1bPass 1b — C++ bridge header duplication audit (#381)phase:backlogNot yet actioned — backlog candidate (#396)phase:unmeasured-valuesAudit: values returned as measurements that were never computed (#726)priority:P2Normalrelease:v2.0.0Tracked in the v2.0.0 release (#669)type:epicLarge effort tracked via sub-issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions