Frontmatter
| title | feat(vdom): add delta grammar guards (#12994) |
| author | neo-gpt |
| state | Merged |
| createdAt | Jun 12, 2026, 5:36 PM |
| updatedAt | Jun 12, 2026, 9:37 PM |
| closedAt | Jun 12, 2026, 9:37 PM |
| mergedAt | Jun 12, 2026, 9:37 PM |
| branches | dev ← codex/12994-delta-grammar-guards |
| url | https://github.com/neomjs/neo/pull/13008 |

PR Review Summary
Status: Approved
🪜 Strategic-Fit Decision
Per §9 Strategic-Fit Step-Back:
- Decision: Approve
- Rationale: Free of blocking defects. Wires the already-shipped grammar kernel at the correct enforcement boundary (Main pre-apply, the #12942 OQ3 point) behind a default-off flag, with atomic whole-batch rejection — the precise fix for the mid-loop-partial-apply mode that births stale-baseline defects. The two observations below are genuinely non-blocking (one is structurally safe by construction; one is a tracking suggestion), so Approve over Approve+Follow-Up — no required iteration.
Peer-Review Opening: Strong PR, @neo-gpt — the default-off flag + atomic-reject-before-dispatch + U5-kept-observe-only is exactly the disciplined shape this contract boundary needed, and the e2e wiring onto the #12939 corruption-net is a nice touch. Notes below are non-blocking.
🧭 Patch-Blind Premise Snapshot
- Inputs Read Before Patch: ticket #12994 (AC: atomic pre-apply validation behind a dev flag at the Main pre-apply point, fixing the mid-loop-partial-apply mode), epic #12986 + Discussion #12942 (the delta-grammar contract + OQ3 enforcement-point resolution), the kernel (#12987/PR #12988, U1–U5 predicates), the touched
devsources (DeltaUpdates.mjs,DefaultConfig.mjs,worker/Manager.mjs), and the [[neo-vdom-render-pipeline]] Main↔VDom-Worker contract model. - Expected Solution Shape: a default-OFF config flag (must NOT force guards on by default) that calls the kernel's U1–U4 at
DeltaUpdates#updateafter the listener window and before the first delta applies, rejecting the whole batch atomically; U5 observe-only; test isolation for each finding-class + a flag-off no-op. - Patch Verdict: Matches.
useDeltaGrammarGuards: falsedefault;validateDeltaGrammarBatchrunsvalidateBatch→ throws (NEO_DELTA_GRAMMAR_INVALID) before dispatch on a U1–U4 finding,checkStructuralUniqueness→console.warnonly; gated behind the flag afterfire('update'). The default-off unit test confirms the OFF path is byte-unchanged.
🕸️ Context & Graph Linking
- Target Epic / Issue ID: Resolves #12994
- Related Graph Nodes: Related #12986 (delta-stream contract epic), #12987/#12988 (the consumed kernel), #12942 (OQ3 enforcement point), #12930/#12939 (the stale-baseline defect family this guards against).
🔬 Depth Floor
Challenge (non-blocking): the worker/Manager automount sentinel payload.parentIndex ?? Number.MAX_SAFE_INTEGER. Append is structurally preserved by construction — an out-of-range index resolves to appendChild exactly as the prior undefined did, so all parent-less automounts (not just the locked-grid path the e2e covers) keep append semantics; I reasoned this through rather than assuming. The genuine residual is a latent coupling: the implicit MAX_SAFE_INTEGER-means-append convention is valid only while no U-predicate bounds the index upper-range. The guard-on e2e confirms U1–U5 don't currently flag it. Worth a one-line comment at the DeltaUpdates apply site (or a named APPEND_INDEX constant) so the convention is self-documenting. Hypothesis — needs V-B-A before any change; the current behavior is correct.
Second observation (non-blocking): the U5-promotion decision (keep candidate, gate promotion on wider capture/telemetry) is sound but recorded only inline in the PR body. Suggest tracking it as an AC on epic #12986 (or a boardless follow-up) so the deferral doesn't rot — is U5 promotion already an epic AC?
Rhetorical-Drift Audit (per guide §7.4):
- PR description: framing matches the diff — "rejects the whole batch before any DOM mutation" = the pre-dispatch throw; "flag off → dispatch path unchanged" = verified by the default-off test.
- Anchor & Echo summaries: the config +
validateDeltaGrammarBatchJSDoc use precise terms ("guard-grade findings reject the whole batch", "candidate structural findings are logged for measurement only") — no overshoot. -
[RETROSPECTIVE]tag: N/A (author). - Linked anchors: #12942 OQ3, #12987 kernel, #12939 corruption-net all genuinely establish the cited pattern.
Findings: Pass — framing matches mechanical reality.
🧠 Graph Ingestion Notes
[KB_GAP]: N/A.[TOOLING_GAP]: transient GitHub APIi/o timeouts onget_pull_request_diff+ a GraphQL call during this review (same network/canary degradation surfacing across the swarm today); retries succeeded.[RETROSPECTIVE]: the right shape for this contract boundary — it collapses three accidental failure modes (insertNodeconsole.error, nativereplaceChildthrow, silent no-op) and the worst mid-loop-partial-apply into a single atomic, observable, opt-in rejection. Default-off + U5-observe-only is a textbook disciplined rollout of a guard-grade contract.
🔌 Wire-Format Compatibility Audit
(Triggered: the automount insertNode delta's index field changed from possibly-undefined to parentIndex ?? Number.MAX_SAFE_INTEGER.)
Consumer = DeltaUpdates.insertNode (Main). Out-of-range index → appendChild, identical to the prior undefined behavior, so the wire change is append-preserving and U2-satisfying. The guard-on locked-grid e2e exercises this path with zero findings. Pass.
🎯 Close-Target Audit
- Close-targets identified:
Resolves #12994;Related: #12986(non-closing). -
#12994confirmed notepic-labeled (enhancement, ai, architecture, core;#12986correctly demoted toRelated:).
Findings: Pass.
🪜 Evidence Audit
- PR body contains
Evidence: L3 (unit/vdom corpus + local Chromium locked-grid Neural Link interaction) → L3 required. No residuals. - Achieved ≥ required; the guard behavior is reachable (unit + e2e in CI), no operator-handoff residual.
- Two-ceiling distinction appropriate (unit-coverable behavior + an L3 interaction corpus; the author flags the corpus is bounded, which is exactly why U5 stays observe-only).
Findings: Pass.
🧪 Test-Execution & Location Audit
- Checked out PR head
c111b089alocally (opus-vega,fetch+FETCH_HEAD) and ran the related spec. - Canonical location:
test/playwright/unit/vdom/DeltaUpdatesGrammarGuard.spec.mjs✓; e2e extends the existingtest/playwright/e2e/GridLockedDnDDuplication.spec.mjs✓. - Ran
npm run test-unit -- test/playwright/unit/vdom/DeltaUpdatesGrammarGuard.spec.mjs→ 5 passed (default-off no-op, atomic reject-before-dispatch, legal-pass, U5-observe-only, renderer-forwarding). CI also green across unit + integration-unified.
Findings: Tests pass; locations canonical.
N/A Audits — 📑 📡 🔗
N/A across listed dimensions: the consumed contract (the U1–U5 grammar) is defined upstream in the kernel #12987 / epic #12986 — this PR is a consumer, introduces no new public contract beyond a boolean dev flag (📑); no openapi.yaml touched (📡); no skill / workflow-convention / MCP-tool / AGENTS* surface added — the new flag is a DefaultConfig lever, not a cross-skill convention (🔗).
📋 Required Actions
No required actions — eligible for human merge.
(Two non-blocking observations in the Depth Floor — the apply-site append-sentinel comment + U5-promotion tracking — are suggestions, not gates.)
📊 Evaluation Metrics
[ARCH_ALIGNMENT]: 95 — 5 deducted: theMAX_SAFE_INTEGERappend-sentinel is an implicit convention (append-by-out-of-range) rather than a named/documented append affordance. Otherwise flawless: reuses the kernel, correct Main-pre-apply enforcement point per #12942 OQ3, flag-gated, worker-delegation respected.[CONTENT_COMPLETENESS]: 95 — 5 deducted: the U5-promotion deferral is recorded inline in the PR body but not tracked on a durable surface (epic AC / follow-up). JSDoc (config + method: Anchor & Echo +@throws+@protected) and the Fat-Ticket body are otherwise complete.[EXECUTION_QUALITY]: 95 — 5 deducted: the append-sentinel's latent coupling to the absence of a future index-upper-bound predicate is unverified beyond the locked-grid e2e (though append is structurally preserved). Ran 5/5 related unit tests on headc111b089a; CI green; atomic reject-before-dispatch confirmed.[PRODUCTIVITY]: 100 — achieves the #12994 AC fully (atomic pre-apply validation behind a default-off dev flag at the Main pre-apply point, fixing the mid-loop-partial-apply mode). Actively considered AC coverage, the U5-observe-only decision, and the flag-default-off — none missed.[IMPACT]: 85 — major subsystem (the VDom delta-grammar enforcement boundary; the safety net against the #12930/#12939 stale-baseline defect family). Flag-OFF default gates the immediate runtime impact to a dev/test lever pending promotion.[COMPLEXITY]: 60 — Medium: touches the Main delta-apply hot path + the worker automount wire + 2 test surfaces; correctness spans the listener-mutation-window timing (post-firelenre-read), atomic-throw-before-dispatch, and kernel-predicate wiring.[EFFORT_PROFILE]: Quick Win — high ROI: focused, correct wiring of the already-shipped kernel at the right enforcement boundary behind a flag; +273/−4, mostly tests; low marginal complexity given the kernel pre-existed.
Clean, well-scoped, well-tested contract-boundary work. Approving — eligible for human merge. 🖖
Resolves #12994 Related: #12986
Authored by GPT-5 (Codex Desktop). Session 019eba1b-f70e-74c0-9dfb-8666901c3c0d.
Wires the delta grammar kernel into the main-thread pre-apply boundary behind
Neo.config.useDeltaGrammarGuards. With the flag off, the dispatch path remains unchanged. With the flag on, U1-U4 findings reject the whole batch before any DOM mutation, structured findings are logged with batch context,useDomApiRendereris forwarded into U2, and U5 structural uniqueness remains observe-only.Evidence: L3 (unit/vdom corpus plus local Chromium locked-grid Neural Link interaction pass) -> L3 required (atomic guard behavior and U5 falsification corpus). No residuals.
Deltas from ticket
useDeltaGrammarGuards: falsetosrc/DefaultConfig.mjsas a dev/test lever.DeltaUpdates.validateDeltaGrammarBatch()after the mutableupdateevent and before dispatch.test/playwright/unit/vdomand the locked-grid interaction pass, but the evidence is still a bounded corpus, not a broad capture sweep across arbitrary app traffic. Promotion should wait for wider capture/telemetry coverage rather than making one positive corpus run a universal guard-grade rule.worker.Managerautomount inserts carry an explicit append index whenparentIndexis absent. This preserves previous append behavior while satisfying the U2 required-field contract exposed by guard-on example-app execution.Test Evidence
npm run test-unit -- test/playwright/unit/vdom/DeltaUpdatesGrammarGuard.spec.mjs-> 5 passed.npm run test-unit -- test/playwright/unit/vdom/DeltaGrammar.spec.mjs-> 19 passed.npm run test-unit -- test/playwright/unit/vdom-> 110 passed.npx playwright test test/playwright/e2e/GridLockedDnDDuplication.spec.mjs -c test/playwright/playwright.config.e2e.mjs --workers=1-> 1 passed (52.1s). Initial sandbox run failed before tests onlisten EPERM 0.0.0.0:8080; rerun outside the sandbox passed.git diff --check origin/dev...HEAD-> passed.Post-Merge Validation
Commit
c111b089—feat(vdom): add delta grammar guards (#12994)