Files
HologramAgent-DSH-Memory-Port/test
jianf 7ad76167c5 fix(memory): separate "not enough blocks yet" from "no common direction" (C5)
MIN_SAMPLE (added in febf9f6) makes a one-vector space non-anisotropic: one
sample is not a direction. That verdict then fell straight into the `isotropic`
branch of `centroidStatus`, so a space holding a single block reported:

    reason = isotropic

Measured before this commit:

    1 block                reason=isotropic  available=false count=1 isAnomalous=false meanLength=1.0000
    2 blocks, orthogonal   reason=ok         available=true  count=2 isAnomalous=true  meanLength=0.7071

## Why the distinction is the whole point of C5

    isotropic        this space will never have a common direction — stop expecting centring
    too_few_samples  write a few more blocks and it starts working

Two diagnoses with opposite remedies. C5 exists so that an operator asking "why is
centring off?" gets an answer they can act on; reporting the first when the
second is true sends them to give up instead of to keep using the thing.

This is my own hole: I added MIN_SAMPLE, and the misclassification exists only
because of it. `zero_sample` (a Go branch) already covered count == 0; nothing
covered 0 < count < MIN_SAMPLE.

## Fix

A `too_few_samples` branch placed BEFORE the isotropic verdict — order is
load-bearing, because the isotropic check is what used to swallow this case.

    no_centroid → dim_mismatch → zero_sample → stale → too_few_samples → isotropic → ok

Stale still comes first: a centroid built from one block that has since seen
twelve is stale, and rebuild is the action, not "write more".

## Criterion

`test/phase-b-c5-reasons.test.js` gains case 11, asserting both sides of the
boundary: one vector reports `too_few_samples`, two vectors do not (MIN_SAMPLE is
2, so two samples must clear the branch).

Mutation — deleting the branch:

    not ok 11 - C5: a one-vector space reports too_few_samples, not isotropic
    error: C5: "not enough blocks yet" and "this space has no common direction" lead
           to opposite actions. ...   (actual: 'isotropic')

## Still HA-divergent, recorded not fixed

Two orthogonal blocks report `ok` / available with meanLength 0.7071 — i.e. the
0.6 threshold calls a two-sample space anisotropic and centring engages. That is
HA-consistent behaviour (HA has no minimum sample count), and it is now visible
rather than silent because the count and meanLength are in the reason's siblings.
Not changed here: raising the threshold would depart from the port.

Gates: npm test 302/302 (0 skipped), c5 11/11, npm run check 12/12.
2026-11-05 12:01:07 +08:00
..