LearnNewsExamplesConnect
Frontmatter
assigneesneo-gpt-emmy
createdAtSep 1, 2026, 5:45 AM
updatedAtSep 1, 2026, 3:42 PM
githubUrlhttps://github.com/neomjs/neo/issues/18006
authorneo-opus-grace
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[x] 18004 The dock shape gate fails open on a malformed zone descriptor, returning a result identical to no-change
blocking[]
closedAtSep 1, 2026, 3:42 PM

The dock shape gate fails open on a malformed zones container, not only its descriptors

Closed v13.2.0/archive-v13-2-0-chunk-17 bugaitestingarchitecturecore
neo-opus-grace
neo-opus-grace commented on Sep 1, 2026, 5:45 AM

Context

Sibling of #18004, found while reviewing its fix (PR #18005). #18004 closed the descriptor arm of Document.computeShapeFingerprint()'s edge-zone walk: a present zone key whose descriptor cannot resolve to a node id now pushes an error instead of collapsing into the absent case. That fix is correct and I am not asking for it to be widened.

The identical fail-open survives one level up, at the zones container itself, and it is untouched by that fix. #18004's ACs are scoped to descriptor forms, so this is genuinely a separate input class rather than an incomplete fix.

Live latest-open sweep at 2026-09-01T03:45Z: read the latest 20 open issues, plus targeted searches over computeShapeFingerprint, edge-zone container, and fingerprint zones container fail open across open and closed. No equivalent exists. Nearest neighbour is #18004 itself (the descriptor arm) and #18000 (a failure reporting shape, not a gate).

The Problem

TopologyDiff.diffDockDocuments() documents a fail-closed contract at src/dashboard/dock/model/TopologyDiff.mjs:93:

a malformed or cyclic document yields {…empty categories, errors: […]} — no partial categories, no throw

When an edge-zone node's zones is present but is not a JSON record, the gate accepts it silently. Reproduced by execution against origin/dev@68efc42bb2 via npm run test-unit:

zones = "main-split"  -> validate: 1 error | gate.errors: 0, shape "e{}" | diff.errors: 0
zones = []            -> validate: 1 error | gate.errors: 0, shape "e{}" | diff.errors: 0
zones = null          -> validate: 1 error | gate.errors: 0, shape "e{}" | diff.errors: 0
zones = 42            -> validate: 1 error | gate.errors: 0, shape "e{}" | diff.errors: 0

Document.validate() rejects all four at src/dashboard/dock/model/Document.mjs:786 (edge-zone "<id>" zones must be a JSON object). The shape gate accepts all four and emits a success fingerprint.

The downstream result is worse than #18004's symptom. #18004's malformed document produced all-empty categories with errors: [] — indistinguishable from "these two documents are identical". Here the malformed root's entire subtree is erased rather than emptied, so the differ reports every item as a remove, still with errors: []. A consumer asserting "no unexpected topology change" does not get a false pass; it gets a false, confident, error-free report that the whole layout was torn down. Both are fail-open; this one also fabricates content.

The Architectural Reality

Both openings are the same pattern, and #18004's fix moved one of them without changing the other. In the edge-zone branch of the walk:

const zones = node.zones || {};                    // <- container: no record check
…
if (!Object.hasOwn(zones, zone)) { return '' }     // <- #18004's fix, correct at the descriptor layer

Object.hasOwn on a non-record returns false for every canonical key in dockZoneEdgeKeys (top, right, bottom, left, center) — verified directly for a string, an array, null and a number. So every zone is classified as legitimately absent, the walk emits a clean e{}, and errors stays empty. The pre-#18004 form (node.zones?.[zone]) behaves identically here, which is why this is pre-existing on dev rather than introduced by PR #18005.

The generalizable shape: a fail-closed walk fails open wherever it reads a subtree through an optional chain or a || {} default. Every node-type read in this walk already has an error arm (missing node, cycle, unsupported type). Every container read does not.

TopologyDiff never calls validate() — it consumes Document.computeShapeFingerprint(document || {}) and reads only gate.errors (TopologyDiff.mjs:110). So the gate is the sole door, exactly as #18004 established for the descriptor case, and the same provenance bound applies: documents arriving via createSavedLayout / restoreSavedLayout have already passed validate; the exposure is hand-authored fixtures, foreign or older-schema payloads, and Neural Link callers passing a constructed document.

The Fix

Give the container read the same error arm every node-type read already has, before the per-zone loop:

case 'edge-zone': {
    if (!Document.isJsonRecord(node.zones)) {
        errors.push(`fingerprint walk found a non-record zones container for edge-zone "${nodeId}"`);
        return '?'
    }
    …

'?' matches what the other error arms in this walk already return, and errors.length is what drives the {fingerprint: null} return, so no separate polarity plumbing is needed.

Open design question, same one #18004 left: whether the message should align word-for-word with validate()'s zones must be a JSON object so the two gates read as one contract, or stay in the walk's own diagnostic voice.

Acceptance Criteria

  • Document.computeShapeFingerprint() returns a non-empty errors array and a null fingerprint for an edge-zone whose zones is present but not a JSON record — covering at minimum a bare string, an array, null, and a number.
  • An edge-zone with a well-formed empty zones record ({}) still fingerprints clean as e{} with errors: []. This is the legitimate case and the line must not be drawn on truthiness.
  • TopologyDiff.diffDockDocuments() surfaces the error through its existing ${side} document failed the shape gate: prefix for both the before and the after position.
  • An arm pins the property that failed here rather than a per-specimen assertion: for each malformed container form, Document.validate() non-empty ⟺ computeShapeFingerprint().errors non-empty. #18004's arm asserts this per specimen, which is why the container drift was invisible to it.
  • The arm asserts the categories too, not only errors — the current fail-open reports fabricated removes, so an arm checking only "the gate complained" would miss the more dangerous half.
  • Mutation-checked: reverting the fix reds at least one arm, and the revert is stated. An arm that passes against the unfixed source does not count.
  • npm run test-unit stays green — in particular no existing fixture that currently fingerprints clean starts erroring.

Out of Scope

  • Re-opening #18004 or PR #18005. The descriptor fix is correct, in-scope for its ticket, and this is a different input class. Nothing here asks for that diff to change.
  • Changing Document.validate(). As in #18004, it already behaves correctly; the gate is what disagrees with it.
  • Unifying validate and computeShapeFingerprint into one traversal. Still the right eventual answer, still a contract-level refactor with blast radius across persistence and the render boundary. Two tickets have now deferred it; if a third arrives, that is the signal to stop deferring and scope it properly.
  • Auditing every container read across the dock model for the same pattern. This ticket closes the one demonstrated instance in this walk. A pattern census is separate work and should be justified by more than two data points.
  • prune()'s behaviour on a non-record zones (Document.mjs:892 iterates Object.entries(node.zones || {}) and then deletes from it). Adjacent, plausibly also wrong, not reproduced here, and not on this gate's path.

Avoided Traps

  • Folding this into PR #18005. #18004's Out of Scope explicitly forbids exactly this creep, and its author correctly filed rather than fixed when the same situation arose in PR #18002. Same discipline applies to me.
  • Treating zones: {} as malformed. An edge-zone with no occupied zones is legitimate and common — the same trap #18004 named for absent keys. A fix keying on truthiness rather than on isJsonRecord would red real fixtures and get reverted rather than corrected.
  • Asserting only errors.length > 0. The distinguishing symptom here is the fabricated removes, which an errors-only arm cannot see.
  • Calling this an incomplete fix of #18004. It is not: #18004's ACs enumerate descriptor forms, and the PR satisfies them. Framing it as a miss would misattribute a pre-existing dev defect to a correct patch.
  • Trusting a log grep as a coverage instrument. Noted because it bit the sibling lane: Playwright's CI reporters print no path for passing files, so "the filename does not appear" is an instrument limit, not evidence of absence.

Decision Record impact

none — restores the documented fail-closed behavior of an existing contract; no ADR authority is touched and no public signature changes.

Related

  • Sibling of: #18004 (the descriptor arm) — found while reviewing its fix, PR #18005.
  • Surfaced by: PR #18005 review, PRR_kwDODSospM8AAAABLmvb7w.
  • Upstream lineage: #17968 / PR #18002, whose spec restoration surfaced the original asymmetry.
  • Subject: src/dashboard/dock/model/Document.mjs, src/dashboard/dock/model/TopologyDiff.mjs.

Origin Session ID: 27f4a820-3b66-4dc1-91ba-940b7413fa47

Retrieval Hint: "dock shape gate fails open on a non-record zones container" · computeShapeFingerprint emits e{} with errors: [] while validate rejects · the container half of the #18004 pair · Object.hasOwn on a non-record is false for every key