Skip to content

doxBench: no outline verdict row for a buffer the state does not hold (#291) - #326

Merged
brettheap merged 5 commits into
mainfrom
change/fix-phantom-outline-verdict-row
Aug 25, 2026
Merged

brettheap merged 5 commits into
mainfrom
change/fix-phantom-outline-verdict-row

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

Fixes #291 — filed as a nit; turned out user-visible.

What was wrong

saveBufferOrder([]) unconditionally prepended OUTLINE_BUFFER_KEY, so runSave emitted outline=unchanged for a buffer the state did not hold. The issue called this inert in the editor. It was not: the editor sends the seam only the buffers that changed (changed.map(bufferRequestRow)), so on every tile Save with a clean outline the phantom row was the first row back, and holdsBufferKey (which asks the canvas, which does hold the outline) applied it into the outline's aria-live sr-only region — Outline: nothing to save in this buffer -- no unsaved changes, a Save verdict about an act the outline wasn't part of. Independently reproduced on pristine main by the reviewer (Node probe + DOM scenario). Transport calls, refusals and commits are byte-identical before/after.

The fix

saveBufferOrder emits the outline only when the key set contains it; runSave's row loop skips a key whose buffer is == null (the second spelling of absence validatedState/saveOrder already tolerated). A clean outline now reads its own standing text, Outline: no unsaved changes — the same string two untouched test_outline_tab.py pins already assert for a never-saved clean outline.

#81 pins — disclosed in full (commit 76562efa body has before/after asserts)

Three existing pins were built on the phantom and moved to the new truth: test_an_unchanged_row_never_takes_the_one_visible_save_line (→ renamed test_a_clean_outline_gets_no_row_and_the_refusal_leads, asserts the row's absence), test_a_save_with_nothing_withheld_leaves_the_visible_line_alone (shape assert inverted), test_an_absent_outline_buffer_no_longer_blocks_the_document_save. Two scripted-seam tests carry the #81 rule "an unchanged row never takes the visible line" now that the real orchestrator can't produce one: test_a_vacuous_unchanged_row_never_takes_the_visible_line and — added at review — test_a_vacuous_row_beside_a_success_still_takes_no_line, which restores the exact conjunction ruled in #81 (a wholly successful Save carrying a vacuous row shows NO line); the widen-the-lead mutation is caught by 3 tests again (main: 4, pre-review: 2).

Evidence

RED-first (3 of 5 new save pins red on main; saveBufferOrder([]) == [] pinned literally). Mutations on the final merged tree: unconditional prepend → 1F; never prepend → 23F; drop the not-held guard → 1F; widen the #81 lead → 3F. Adversarial review: 14 findings, 0 blockers, 2 SHOULD-FIX fixed. Merges of main are git's own auto-resolution (verified byte-identical via merge-tree); all #313 pins and mutations still hold. Full ideation-dashboard suite on the reviewed tree: 4148 passed / 13 skipped.

For Brett's ruling (from the reviewer, verbatim in substance)

The reshaping does not overturn #81 — all three limbs (lead with the first refused/not_attempted row; clean success shows no line; an unchanged row never takes the line) are still enforced and mutation-caught. What changed is where limbs two and three live: the ruled pin test_a_save_with_nothing_withheld_leaves_the_visible_line_alone can no longer catch the widen-the-lead regression because the real orchestrator no longer produces the vacuous row — a genuine improvement, not a weakening — and the scripted-seam tests now carry that duty.

Follow-ups (not widened here)

  • doxbench-save.js tolerates a present-but-null outline key that doxbench-state.js refuses (validatedBuffer throws on null) — two differently strict judges of one value, the pattern doxBench: tileSaveVerdict reports ok:true over a commit the canvas could not adopt #290 called a gap. A stricter validatedState would delete the row-loop guard.
  • The !row → unchanged branch in runSave is now unreachable from every shipped caller (editor and staging-workbench send only dirty buffers); kept as seam contract, docstring should say so.

🤖 Generated with Claude Code

brettheap and others added 5 commits August 24, 2026 23:09
… gets none (#291)

`saveBufferOrder` prepended OUTLINE_BUFFER_KEY unconditionally, so the
legitimate absent-outline state -- the T100 P1-3 real-corpus shape this module
documents and skips everywhere else -- still carried the reserved key into
`runSave`'s row loop, where the not-planned branch reported it `unchanged`.
That is a verdict about a buffer the state does not hold, which is exactly what
the module's own reporting discipline forbids, and `savePlanState` is an
EXPORTED seam: a caller reading `outcome.buffers` directly read the phantom row.

Two guards, one rule, each independently pinned:

  * `saveBufferOrder` names the outline only when the key set contains it --
    membership read the way doxbench-state.js reads it. The ordering contract is
    untouched: an outline in the set still leads, documents still follow in
    SAVE_DOCUMENT_ORDER_RULE order.
  * `runSave`'s row loop skips a key the state does not actually hold
    (`state.buffers[key] == null`), the same not-held rule `validatedState` and
    `saveOrder` already read, so the second spelling of the absence -- a present
    key holding nothing -- cannot produce a verdict either.

BLAST RADIUS, larger than the issue estimated. The issue called the phantom
inert in the editor because `!holdsBufferKey` skips it; that is true for a key
the canvas does not hold, but the canvas DOES hold the outline. The editor hands
the seam only the buffers that CHANGED, so a tile Save's clean outline was never
in the reshaped state and its `unchanged` row was the phantom -- applied, and
leading the row list. It now gets no row, and its own region states the fact
that is true of it (`Outline: no unsaved changes`) instead of a Save verdict
about an act it was not part of. Nothing is sent, refused or committed
differently; the transport call sequence is byte-identical.

RED (before the fix, three of five new pins failing):

  FAILED test_doxbench_save.py::test_the_save_order_prepends_the_outline_only_when_the_state_holds_one
    AssertionError: saveBufferOrder named a buffer the key set does not contain
    assert ['outline', ...] == ['ideation/.../alpha.md', 'ideation/.../zulu.md']
  FAILED test_doxbench_save.py::test_an_absent_outline_produces_no_outline_verdict_row
    AssertionError: runSave stated a verdict about an outline buffer the state
    does not hold: [{'key': 'outline', 'status': 'unchanged'}, ...]
  FAILED test_doxbench_save.py::test_an_outline_key_holding_nothing_is_not_a_buffer_to_report_on
    AssertionError: a null-valued outline key was reported on:
    [{'key': 'outline', 'status': 'unchanged'}, ...]
  3 failed, 2 passed, 50 deselected

The two that passed RED are the companions, and they are the point: they fail if
the fix over-reaches and drops or demotes a real outline row.

MUTATION ROUND (doxbench-save.js; suite = test_doxbench_save.py +
test_doxbench_view.py + test_doxbench_mutation_boundary.py, 266 tests):

  | # | mutation                                        | caught | by                                                        |
  |---|-------------------------------------------------|--------|-----------------------------------------------------------|
  | 1 | restore the unconditional prepend               | YES 1F | test_the_save_order_prepends_the_outline_only_when_...     |
  | 2 | never prepend (drop the outline even when held) | YES 21F| test_the_outline_still_leads_the_order_whenever_...,       |
  |   |                                                 |        | test_a_held_outline_is_still_reported_first_dirty_or_clean,|
  |   |                                                 |        | + 19 ordering/ancestry pins incl. two in the view suite    |
  | 3 | drop the row loop's not-held guard              | YES 1F | test_an_outline_key_holding_nothing_is_not_a_buffer_to_... |

Mutation 1 is caught by one test and not by the runSave-facing one, because the
row-loop guard masks it -- which is what defence in depth looks like from the
inside, and why each guard carries its own pin.

Test counts, before -> after: test_doxbench_save.py 50 -> 55,
test_doxbench_view.py 130 -> 131, test_doxbench_mutation_boundary.py 80 -> 80.
Whole tests/ideation-dashboard suite green: 4143 passed, 13 skipped.

The #81 companion rule -- an `unchanged` row must never take the one visible
Save line -- lost its scenario when the phantom row went away, so it is re-pinned
next door on scripted rows (test_a_vacuous_unchanged_row_never_takes_the_visible_line):
`unchanged` remains a status a seam may state, and the canvas must still lead
from the withheld set. Without it, narrowing the lead back to "everything not
committed" would have gone undetected.

Co-Authored-By: Claude Fable 5 <[email protected]>
The comment amended in b4f5e9f stated the withheld-set rule one sentence
before the paragraph that states it properly, so it read as two answers to one
question. It now says only the part that is its own: #291 removed the row, and
the guard stands anyway because the rows this loop reads are the SEAM's.
Comment only -- no behaviour, no test expectation.

Co-Authored-By: Claude Fable 5 <[email protected]>
…e the pins this branch moved

Adversarial review of the #291 fix found a real coverage regression and asked
for the changed pins to be stated rather than left to a diff reader.

THE REGRESSION. Brett's #81 ruling of 2026-08-24 is a CONJUNCTION -- a vacuous
row AND nothing withheld -- and the mutation that violates it is offering the
one visible line to every row that is not `committed`. On main that mutation was
caught by four tests, the ruled pin
`test_a_save_with_nothing_withheld_leaves_the_visible_line_alone` among them.
On this branch it was caught by two, and the ruled pin was no longer one of
them: `nothingToSay` drives the REAL orchestrator, which since #291 hands it no
vacuous row to offer, and `vacuousRowNeverLeads` scripts a refusal beside the
vacuous row, so it catches the lead being WRONG rather than the line appearing
at all. Neither covers the ruled case any more.

`test_a_vacuous_row_beside_a_success_still_takes_no_line` restores it: a
scripted seam answers `status: 'committed'` with rows [outline `unchanged`,
DOC_A `committed`] over a real edit + `saveDocument(DOC_A)`, and the assertions
are the ruling itself -- `eventNoteText == ""` and `eventNoteHidden is True`.
Nothing failed, so the only wrong answer available is the line appearing, which
is exactly what the ruling forbids. Measured, with the lead mutation applied:

  caught by 2 before this commit; caught by 3 with it --
    test_a_vacuous_unchanged_row_never_takes_the_visible_line
    test_a_vacuous_row_beside_a_success_still_takes_no_line   <- new
    test_a_commit_the_canvas_cannot_adopt_never_reads_as_a_tile_success (#290)

The ruled pin itself still does not catch it, and cannot while the real
orchestrator is the thing driving it; the scripted scenario is where that shape
now lives, and it says so in its own docstring.

DISCLOSURE -- the three existing pins whose assertions this branch changed:

  1. test_doxbench_view.py::test_an_unchanged_row_never_takes_the_one_visible_save_line
     RENAMED to test_a_clean_outline_gets_no_row_and_the_refusal_leads, because
     the #81 name belongs to the scripted vacuous-row tests and this scenario
     now pins the row's ABSENCE.
       before: assert statuses[0][1] == "unchanged"
               assert len(refused) == 1
       after:  assert statuses == [("ideation/staging/topic-x/detail.md", "refused")]
               assert result["statusOutline"] == "Outline: no unsaved changes"

  2. test_doxbench_view.py::test_a_save_with_nothing_withheld_leaves_the_visible_line_alone
     Shape assertion inverted; every assertion carrying the RULING is untouched.
       before: assert ("outline", "unchanged") in statuses
       after:  assert not [row for row in rows if row["status"] == "unchanged"]
               assert result["statuses"]["outline"] == "Outline: no unsaved changes"

  3. test_doxbench_save.py::test_an_absent_outline_buffer_no_longer_blocks_the_document_save
       before: assert outcome == {"outline": "unchanged", "document": "committed"}
       after:  assert outcome == {"document": "committed"}

CORRECTION to b4f5e9f's body. It quoted the outline region's post-fix text but
not the full pre-fix string, which was
`Outline: nothing to save in this buffer -- no unsaved changes` -- the Save
verdict AND the dirty fact, per `bufferStatusText`. It now reads
`Outline: no unsaved changes`: the dirty fact alone, which is all that is true
of a buffer the act neither sent nor was asked about.

Also pinned: `saveBufferOrder([]) == []`, the issue's own literal case, spelled
the way #291 reported it.

Counts. Before this commit, save 56 / view 135 / boundary 80 (271); after,
save 56 / view 136 / boundary 80 (272) -- item 4 adds an assertion to an
existing test, item 1 adds a test. test_renderer.py 50, unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings August 25, 2026 03:52

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a user-visible doxBench Save/UI inconsistency where the Save pipeline could emit an outline=unchanged verdict row even when the client state did not hold an outline buffer (phantom row). The change ensures verdict rows are only produced for buffers that actually exist in the validated state, preventing the editor from rendering misleading outline-related Save messaging.

Changes:

  • Update saveBufferOrder to include the outline key only when it is actually present in the key set (no unconditional prepend).
  • Update runSave to skip emitting an unchanged verdict row when the corresponding buffer is not held (state.buffers[key] == null).
  • Add/reshape tests to pin both the real orchestrator behavior (no phantom outline row) and the still-supported seam behavior (a scripted vacuous unchanged row never takes the visible Save line).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
scripts/ideation_dashboard/web/views/doxbench-save.js Prevents phantom outline rows by conditioning outline ordering on key presence and skipping verdict emission for not-held buffers.
scripts/ideation_dashboard/web/views/doxbench-editor.js Updates inline rationale/comments to reflect the post-#291 shape while preserving the seam-level rule about unchanged rows not taking the visible line.
tests/ideation-dashboard/test_doxbench_save.py Adds targeted Node-harness pins for issue #291 across absent/null/held outline cases, including ordering and row emission behavior.
tests/ideation-dashboard/test_doxbench_view.py Reshapes view-level pins: real-orchestrator scenario now asserts “no outline row”, and scripted scenarios keep the #81 “vacuous row never leads / takes no line” rules enforced.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 1b181b1586

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@brettheap
brettheap merged commit bcfc26a into main Aug 25, 2026
3 checks passed
@brettheap
brettheap deleted the change/fix-phantom-outline-verdict-row branch September 2, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doxBench nit: runSave emits an outline verdict row for a state with no outline buffer

2 participants