Skip to content

Preserve presentation failure provenance - #683

Merged
max-sixty merged 3 commits into
mainfrom
codex/presentation-failure-provenance
Sep 13, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/presentation-failure-provenance

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

The reactive page runtime retained presentation and fail-soft errors, but Leaf's installed error reporter reduced each aggregate to its generic outer message. This change expands nested failures at the reporting boundary, preserves distinct AggregateError members, treats a fail-soft helper rethrowing the original error as one failure rather than duplicating it, and keeps candidate and retention failures together in the Threads renderer.

The data-readiness regression test now also accounts for the synchronous subscriber failure it deliberately triggers and already asserts occurs exactly once.

Verified with the browser bundle reproducibility check, all 35 browser unit tests, the five affected browser integration tests, and the touched-file pre-commit hooks.

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

describeFailure runs only where the coordinator builds the aggregate, so the provenance it adds reaches the reporter on one branch, and on that branch the reported string names the same failure twice. The two points below are one change: the first needs the second, or fixing it gives the provenance back up.

A fail-soft that declines by rethrowing is counted as a second failure. Both shipped fail-soft helpers decline that way — failSoftAfterRetention in skills/leaf/assets/runtime/semantic-state.js (if (reason instanceof PresentationRetentionError) throw reason;) and retainedThreadListProof in skills/leaf/assets/runtime/conversation/thread-list.js (if (!(reason instanceof RetainedThreadListError)) throw reason;). fallbackError is then the same object as reason, so reported.errors holds it twice and the new message describes it twice. Driving the coordinator with that shape:

errors identical: true
message: presentation and fail-soft failed: Leaves presentation and retention failed: deliberate leaves failure; deliberate leaves failure; Leaves presentation and retention failed: deliberate leaves failure; deliberate leaves failure

All three updated Python expectations are exactly that doubling — one description repeated verbatim. Nothing failed in fail-soft on those paths; it declined to supply proof, which is the one failure already named.

The flattening this fixes lives at the reporter, and that path is untouched. setPresentationFailureReporter in skills/leaf/assets/runtime/semantic-state.js still renders every reported failure as Presentation failed: ${reason?.message ?? reason}. So the widget aggregate — new AggregateError(failures, "widget presentation failed") in skills/leaf/assets/runtime/widget-controller.js, built when a renderState throw and a settlement or subscriber throw land on the same reading — still reports as bare leaf: Presentation failed: widget presentation failed with its members hidden. That is the module-level cause the description names, and it does not need fail-soft to throw to reach the reporter: failSoft from widget-upgrade.js returns undefined, so the region recovers and the raw aggregate is what gets reported.

Describing at the reporter covers both. Export describeFailure through scripts/browser/index.ts and call it in setPresentationFailureReporter; the coordinator then keeps its constant "presentation and fail-soft failed" message and can report reason unchanged when fail-soft declines, which drops the duplication without a second message string. The three Python expectations become one description rather than two, and the widget path gains the provenance it is missing today.

The separate test_render_startup.py fragment is a real repair — the synchronous subscriber and its == 1 assertion landed in #666 without the matching consume_browser_errors allowance, so consume_browser_errors was rejecting an error the test deliberately raises.

I can push the reporter-side version if you'd like it on this branch.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The reporter is the right boundary and the widget aggregate gains its members there. One gap remains on the same subject, in the case this PR re-records.

retainCommitted in skills/leaf/assets/runtime/conversation/thread-list.js builds new AggregateError([retaining], "Thread list presentation and retention failed") — the candidate error its caller already holds is dropped, so the expanded message names the retention failure alone. The two sibling retention sites keep both members: live-leaves-list.js throws PresentationRetentionError([error, restoreError], "Leaves presentation and retention failed") and banner-controls.js throws AggregateError([error, retaining], "Ask banner presentation and retention failed"). That is why the leaves expectation in this PR names two failures for a two-throw arrangement and the narrowing one names a single failure for the same arrangement.

Passing the caught error through — retainCommitted(current, model, error) in presentList, and reason === undefined ? [retaining] : [reason, retaining] in the aggregate — makes the narrowing case report Thread list presentation and retention failed: deliberate narrowing failure; deliberate narrowing failure, which is what the test throws. The retry path has the same hole from the other side: its await retainCommitted(current, model) runs before new AggregateError([error, retrying], "Thread list presentation retry failed") is constructed, so a retention failure there discards both members instead of one.

Happy to push that change on this branch if you want it here rather than separately.

Checks run

node --test scripts/browser/presentation.test.mjs (17 pass), and the four affected browser cases in tests/test_render_controls.py, tests/test_render_conversations.py, and tests/test_render_startup.py (4 pass). The thread-list.js change above was applied locally to produce the message quoted, then reverted.

Comment thread tests/test_render_conversations.py Outdated
expected = [
(
"leaf: Presentation failed: Thread list presentation and retention failed: "
"deliberate narrowing failure"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This arrangement throws deliberate narrowing failure twice — once from the candidate render and once from the retention render inside threadsBox.retainCommitted — but the message names it once, because retainCommitted in thread-list.js wraps [retaining] alone and drops the error its caller caught. Carrying that error into the aggregate (as live-leaves-list.js and banner-controls.js already do) makes this expectation read deliberate narrowing failure; deliberate narrowing failure, matching the leaves expectation for the same two-throw shape.

@max-sixty
max-sixty merged commit f14fd6d into main Sep 13, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the codex/presentation-failure-provenance branch September 13, 2026 20:44
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.

2 participants