Repository navigation
Closed
Labels
tend-ci-causeA root cause of a CI failure report
Description
The scheduled run 41432142330 records this failing boundary. This report supplies CI evidence; it has not reproduced the failure on current main or established its cause.
Reconcile against current main and active repair work, reproduce the focused boundary, and fix the highest incorrect owner while preserving the originating change’s intent and the user behavior. Reuse an existing owner when reproduction proves a shared mechanism. Follow normal review and landing gates.
tests.browser.test_render_application_boundary::test_widget_controller_owns_presentation_across_values_and_lifetimes[light] — macOS
wser, serve, lifetime
):
"""One widget owns distinct render and preparation regions across its lifetime."""
# The owner is removed and reattached by script below. Keep it after the page's
# content so that neither operation moves text the reader did not ask to move.
widget = '<lf-local id="page-local" choice="idle"></lf-local>'
declarations = PAGE_DECLARATION
modules = {"widgets/lf-local.js": PAGE_WIDGET}
if lifetime != "light":
widget = (
f'<lf-controller-stage id="controller-stage">{widget}</lf-controller-stage>'
)
declarations = {
**declarations,
"lf-controller-stage": {
"description": "A declared shadow stage for the controller lifetime.",
"type": "object",
"properties": {"id": {"type": "string"}},
"required": ["id"],
"additionalProperties": False,
"x-content": "markup",
"x-upgrade": True,
"x-shadow": True,
"x-example": '<lf-controller-stage id="stage-example"><p id="stage-words">Words</p></lf-controller-stage>',
},
}
modules["widgets/lf-controller-stage.js"] = """\
import { once, shadowStage } from '/runtime/widget-api.js';
customElements.define('lf-controller-stage', class extends HTMLElement {
connectedCallback() { if (once(this)) shadowStage(this, [...this.children]); }
});
"""
source = LIVE_V1.replace(
"</main>",
f"{widget}</main>",
)
page = open_page(
browser,
live_url(
serve(
source,
page_files={
"registry.json": json.dumps(declarations),
**modules,
},
)
),
)
page.locator("#page-local").evaluate("node => { window.pageLocal = node; }")
page.evaluate(
"""async () => {
const presentation = await window.__lfCheckApi();
window.whenLeafPresented = presentation.whenApplicationPresented;
window.whenLeafRegionsPresented =
presentation.whenApplicationRegionsPresented;
window.readLeafApplication = presentation.readApplication;
window.readLeafPresentation = presentation.readApplicationPresentation;
window.heldPreparation = () => {
let release;
const promise = new Promise(resolve => { release = resolve; });
return {promise, release};
};
}"""
)
# Several children prepared by one owner are one requirement. A later call for the
# same reading includes the earlier promise rather than superseding it.
returned = page.evaluate(
"""() => {
window.firstPreparation = heldPreparation();
window.secondPreparation = heldPreparation();
const first = pageLocal.controller.present(firstPreparation.promise);
const second = pageLocal.controller.present(secondPreparation.promise);
window.preparationReady = false;
whenLeafPresented().then(() => { preparationReady = true; });
return {
first: first === firstPreparation.promise,
second: second === secondPreparation.promise,
pending: readLeafPresentation().pending,
};
}"""
)
assert returned == {
"first": True,
"second": True,
"pending": ["widget:page-local:preparation"],
}
page.evaluate("firstPreparation.release('first')")
assert page.evaluate("preparationReady") is False
page.evaluate("secondPreparation.release('second')")
page.wait_for_function("preparationReady")
# Deferral installs a held render ticket for each selected value. Refusal publishes
# the newest authoritative value, but neither it nor the older optimistic ticket may
# count as presented until the one-shot resume paints that newest reading.
held_events = []
page.route("**/api/event", lambda route: held_events.append(route))
before = int(page.locator("#page-local").get_attribute("data-readings"))
page.evaluate("() => { window.resumeLocal = pageLocal.controller.defer(); }")
page.locator("#page-local").get_by_role("button", name="Choose").click()
expect(page.locator("#page-local").get_by_role("status")).to_have_text("chosen")
assert page.evaluate("Number(pageLocal.dataset.readings)") == before
page.wait_for_function(
"readLeafPresentation().pending.join() === 'widget:page-local:render'"
)
holding(page, held_events, 1, "the deferred choose")
attempt = held_events[0].request.post_data_json["attempt"]
held_events[0].fulfill(
status=200,
json={
"ok": False,
"attempt": attempt,
"error": "refused before append",
"final": True,
},
)
page.wait_for_function(
"attempt => readLeafApplication().unresolved.some("
"entry => entry.event.attempt === attempt && entry.state === 'refused')",
arg=attempt,
)
expect(page.locator("#page-local")).to_have_attribute("data-delivery", "refused")
assert page.evaluate("Number(pageLocal.dataset.readings)") == before
assert page.locator("#page-local").get_by_role("status").text_content() == "chosen"
page.evaluate(
"presentationReady = false; "
"whenLeafPresented().then(() => { presentationReady = true; }); true"
)
assert page.evaluate("presentationReady") is False
rendered(page) # A deferred local edit does not hold mechanical rendering.
resumed = page.evaluate(
"resumeLocal(); const once = Number(pageLocal.dataset.readings); "
"resumeLocal(); [once, Number(pageLocal.dataset.readings)]"
)
assert resumed == [before + 1, before + 1]
expect(page.locator("#page-local").get_by_role("status")).to_have_text("idle")
expect(page.locator("#page-local")).to_have_attribute("data-delivery", "refused")
page.wait_for_function(
"attempt => !readLeafApplication().unresolved.some("
"entry => entry.event.attempt === attempt)",
arg=attempt,
)
page.wait_for_function("presentationReady")
page.unroute("**/api/event")
# A removed owner pauses its one retained subscription and retires both regions.
# Releasing a local edit after removal must not paint that detached owner.
# Reconnecting the same instance catches up once and reattaches
# its still-pending preparation at the same semantic epoch, so an already resolved
# readiness call cannot be reused as proof for the replacement renderer.
# Leave the widget by a real gesture before probing its lifetime: removing a
# focused control would also change shortcut context without user input.
page.locator("#live-title").click()
rendered(page)
page.evaluate(
"""lifetime => {
window.localLifetimeOwner = lifetime === 'shadow-host'
? document.querySelector('#controller-stage') : pageLocal;
window.localLifetimeParent = localLifetimeOwner.parentNode;
}""",
lifetime,
)
page.evaluate(
"""() => {
window.beforeDetachedReading = Number(pageLocal.dataset.readings);
window.resumeDetached = pageLocal.controller.defer();
window.reconnectPreparation = heldPreparation();
pageLocal.controller.present(reconnectPreparation.promise);
window.beforeRemovalReady = false;
whenLeafPresented().then(() => { beforeRemovalReady = true; });
localLifetimeOwner.remove();
resumeDetached();
}"""
)
page.wait_for_function("beforeRemovalReady")
rendered(
page
) # A removed owner's unresolved preparation no longer holds rendering.
assert page.evaluate("Number(pageLocal.dataset.readings)") == page.evaluate(
"beforeDetachedReading"
)
assert page.evaluate("readLeafPresentation().pending") == []
detached_edit = append_command(
serve.page_dir,
{
"kind": "action",
"author": "user",
"revision": 1,
"widget": "page-local",
"action": "choose",
"detail": {"value": "chosen"},
},
)
told(page)
assert page.evaluate("Number(pageLocal.dataset.readings)") == page.evaluate(
"beforeDetachedReading"
)
assert page.evaluate("pageLocal.dataset.renderedChoice") == "idle"
page.evaluate(
"""() => {
localLifetimeParent.append(localLifetimeOwner);
window.reconnectedReady = false;
whenLeafPresented().then(() => { reconnectedReady = true; });
return true;
}"""
)
assert page.evaluate("reconnectedReady") is False
assert (
page.evaluate(
"Object.values(document.querySelector('script[data-lf-entry]').lfRenderingState()).every(Boolean)"
)
is False
)
assert page.evaluate("Number(pageLocal.dataset.readings)") == page.evaluate(
"beforeDetachedReading + 1"
)
expect(page.locator("#page-local").get_by_role("status")).to_have_text("chosen")
assert page.evaluate("readLeafPresentation().pending") == [
"widget:page-local:preparation"
]
page.evaluate("reconnectPreparation.release('reconnected')")
page.wait_for_function("reconnectedReady")
append_command(
serve.page_dir,
{"kind": "undo", "author": "user", "undoes": detached_edit["id"]},
)
told(page)
expect(page.locator("#page-local").get_by_role("status")).to_have_text("idle")
# A synchronous render failure cannot escape the publisher or leave a partial
# widget as presentation proof. The widget reports it once, shows the visible
# fail-soft box, and settles its region.
held_failure = []
page.route("**/api/event", lambda route: held_failure.append(route))
page.evaluate("window.__failLocalRender = true; true")
page.locator("#page-local").get_by_role("button", name="Choose").click()
holding(page, held_failure, 1, "the failing render's action")
expect(page.locator("#page-local .lf-error")).to_have_text(
"<lf-local> failed: deliberate render failure"
)
page.wait_for_function("readLeafPresentation().pending.length === 0")
assert page.evaluate("window.__failedLocalRenders") == 1
errors = take_browser_errors(page)
> assert [said(error) for error in errors] == [
'leaf: <lf-local id="page-local"> failed: deliberate render failure'
]
E assert [] == ['leaf: <lf-l...nder failure']
E
E Right contains one more item: 'leaf: <lf-local id="page-local"> failed: deliberate render failure'
E
E Full diff:
E + []
E - [
E - 'leaf: <lf-local id="page-local"> failed: deliberate render failure',
E - ]
/Users/runner/work/leaf/leaf/tests/browser/test_render_application_boundary.py:1046: AssertionError
tests.browser.test_render_application_boundary::test_widget_controller_owns_presentation_across_values_and_lifetimes[shadow-child] — macOS
wser, serve, lifetime
):
"""One widget owns distinct render and preparation regions across its lifetime."""
# The owner is removed and reattached by script below. Keep it after the page's
# content so that neither operation moves text the reader did not ask to move.
widget = '<lf-local id="page-local" choice="idle"></lf-local>'
declarations = PAGE_DECLARATION
modules = {"widgets/lf-local.js": PAGE_WIDGET}
if lifetime != "light":
widget = (
f'<lf-controller-stage id="controller-stage">{widget}</lf-controller-stage>'
)
declarations = {
**declarations,
"lf-controller-stage": {
"description": "A declared shadow stage for the controller lifetime.",
"type": "object",
"properties": {"id": {"type": "string"}},
"required": ["id"],
"additionalProperties": False,
"x-content": "markup",
"x-upgrade": True,
"x-shadow": True,
"x-example": '<lf-controller-stage id="stage-example"><p id="stage-words">Words</p></lf-controller-stage>',
},
}
modules["widgets/lf-controller-stage.js"] = """\
import { once, shadowStage } from '/runtime/widget-api.js';
customElements.define('lf-controller-stage', class extends HTMLElement {
connectedCallback() { if (once(this)) shadowStage(this, [...this.children]); }
});
"""
source = LIVE_V1.replace(
"</main>",
f"{widget}</main>",
)
page = open_page(
browser,
live_url(
serve(
source,
page_files={
"registry.json": json.dumps(declarations),
**modules,
},
)
),
)
page.locator("#page-local").evaluate("node => { window.pageLocal = node; }")
page.evaluate(
"""async () => {
const presentation = await window.__lfCheckApi();
window.whenLeafPresented = presentation.whenApplicationPresented;
window.whenLeafRegionsPresented =
presentation.whenApplicationRegionsPresented;
window.readLeafApplication = presentation.readApplication;
window.readLeafPresentation = presentation.readApplicationPresentation;
window.heldPreparation = () => {
let release;
const promise = new Promise(resolve => { release = resolve; });
return {promise, release};
};
}"""
)
# Several children prepared by one owner are one requirement. A later call for the
# same reading includes the earlier promise rather than superseding it.
returned = page.evaluate(
"""() => {
window.firstPreparation = heldPreparation();
window.secondPreparation = heldPreparation();
const first = pageLocal.controller.present(firstPreparation.promise);
const second = pageLocal.controller.present(secondPreparation.promise);
window.preparationReady = false;
whenLeafPresented().then(() => { preparationReady = true; });
return {
first: first === firstPreparation.promise,
second: second === secondPreparation.promise,
pending: readLeafPresentation().pending,
};
}"""
)
assert returned == {
"first": True,
"second": True,
"pending": ["widget:page-local:preparation"],
}
page.evaluate("firstPreparation.release('first')")
assert page.evaluate("preparationReady") is False
page.evaluate("secondPreparation.release('second')")
page.wait_for_function("preparationReady")
# Deferral installs a held render ticket for each selected value. Refusal publishes
# the newest authoritative value, but neither it nor the older optimistic ticket may
# count as presented until the one-shot resume paints that newest reading.
held_events = []
page.route("**/api/event", lambda route: held_events.append(route))
before = int(page.locator("#page-local").get_attribute("data-readings"))
page.evaluate("() => { window.resumeLocal = pageLocal.controller.defer(); }")
page.locator("#page-local").get_by_role("button", name="Choose").click()
expect(page.locator("#page-local").get_by_role("status")).to_have_text("chosen")
assert page.evaluate("Number(pageLocal.dataset.readings)") == before
page.wait_for_function(
"readLeafPresentation().pending.join() === 'widget:page-local:render'"
)
holding(page, held_events, 1, "the deferred choose")
attempt = held_events[0].request.post_data_json["attempt"]
held_events[0].fulfill(
status=200,
json={
"ok": False,
"attempt": attempt,
"error": "refused before append",
"final": True,
},
)
page.wait_for_function(
"attempt => readLeafApplication().unresolved.some("
"entry => entry.event.attempt === attempt && entry.state === 'refused')",
arg=attempt,
)
expect(page.locator("#page-local")).to_have_attribute("data-delivery", "refused")
assert page.evaluate("Number(pageLocal.dataset.readings)") == before
assert page.locator("#page-local").get_by_role("status").text_content() == "chosen"
page.evaluate(
"presentationReady = false; "
"whenLeafPresented().then(() => { presentationReady = true; }); true"
)
assert page.evaluate("presentationReady") is False
rendered(page) # A deferred local edit does not hold mechanical rendering.
resumed = page.evaluate(
"resumeLocal(); const once = Number(pageLocal.dataset.readings); "
"resumeLocal(); [once, Number(pageLocal.dataset.readings)]"
)
assert resumed == [before + 1, before + 1]
expect(page.locator("#page-local").get_by_role("status")).to_have_text("idle")
expect(page.locator("#page-local")).to_have_attribute("data-delivery", "refused")
page.wait_for_function(
"attempt => !readLeafApplication().unresolved.some("
"entry => entry.event.attempt === attempt)",
arg=attempt,
)
page.wait_for_function("presentationReady")
page.unroute("**/api/event")
# A removed owner pauses its one retained subscription and retires both regions.
# Releasing a local edit after removal must not paint that detached owner.
# Reconnecting the same instance catches up once and reattaches
# its still-pending preparation at the same semantic epoch, so an already resolved
# readiness call cannot be reused as proof for the replacement renderer.
# Leave the widget by a real gesture before probing its lifetime: removing a
# focused control would also change shortcut context without user input.
page.locator("#live-title").click()
rendered(page)
page.evaluate(
"""lifetime => {
window.localLifetimeOwner = lifetime === 'shadow-host'
? document.querySelector('#controller-stage') : pageLocal;
window.localLifetimeParent = localLifetimeOwner.parentNode;
}""",
lifetime,
)
page.evaluate(
"""() => {
window.beforeDetachedReading = Number(pageLocal.dataset.readings);
window.resumeDetached = pageLocal.controller.defer();
window.reconnectPreparation = heldPreparation();
pageLocal.controller.present(reconnectPreparation.promise);
window.beforeRemovalReady = false;
whenLeafPresented().then(() => { beforeRemovalReady = true; });
localLifetimeOwner.remove();
resumeDetached();
}"""
)
page.wait_for_function("beforeRemovalReady")
rendered(
page
) # A removed owner's unresolved preparation no longer holds rendering.
assert page.evaluate("Number(pageLocal.dataset.readings)") == page.evaluate(
"beforeDetachedReading"
)
assert page.evaluate("readLeafPresentation().pending") == []
detached_edit = append_command(
serve.page_dir,
{
"kind": "action",
"author": "user",
"revision": 1,
"widget": "page-local",
"action": "choose",
"detail": {"value": "chosen"},
},
)
told(page)
assert page.evaluate("Number(pageLocal.dataset.readings)") == page.evaluate(
"beforeDetachedReading"
)
assert page.evaluate("pageLocal.dataset.renderedChoice") == "idle"
page.evaluate(
"""() => {
localLifetimeParent.append(localLifetimeOwner);
window.reconnectedReady = false;
whenLeafPresented().then(() => { reconnectedReady = true; });
return true;
}"""
)
assert page.evaluate("reconnectedReady") is False
assert (
page.evaluate(
"Object.values(document.querySelector('script[data-lf-entry]').lfRenderingState()).every(Boolean)"
)
is False
)
assert page.evaluate("Number(pageLocal.dataset.readings)") == page.evaluate(
"beforeDetachedReading + 1"
)
expect(page.locator("#page-local").get_by_role("status")).to_have_text("chosen")
assert page.evaluate("readLeafPresentation().pending") == [
"widget:page-local:preparation"
]
page.evaluate("reconnectPreparation.release('reconnected')")
page.wait_for_function("reconnectedReady")
append_command(
serve.page_dir,
{"kind": "undo", "author": "user", "undoes": detached_edit["id"]},
)
told(page)
expect(page.locator("#page-local").get_by_role("status")).to_have_text("idle")
# A synchronous render failure cannot escape the publisher or leave a partial
# widget as presentation proof. The widget reports it once, shows the visible
# fail-soft box, and settles its region.
held_failure = []
page.route("**/api/event", lambda route: held_failure.append(route))
page.evaluate("window.__failLocalRender = true; true")
page.locator("#page-local").get_by_role("button", name="Choose").click()
holding(page, held_failure, 1, "the failing render's action")
expect(page.locator("#page-local .lf-error")).to_have_text(
"<lf-local> failed: deliberate render failure"
)
page.wait_for_function("readLeafPresentation().pending.length === 0")
assert page.evaluate("window.__failedLocalRenders") == 1
errors = take_browser_errors(page)
> assert [said(error) for error in errors] == [
'leaf: <lf-local id="page-local"> failed: deliberate render failure'
]
E assert [] == ['leaf: <lf-l...nder failure']
E
E Right contains one more item: 'leaf: <lf-local id="page-local"> failed: deliberate render failure'
E
E Full diff:
E + []
E - [
E - 'leaf: <lf-local id="page-local"> failed: deliberate render failure',
E - ]
/Users/runner/work/leaf/leaf/tests/browser/test_render_application_boundary.py:1046: AssertionError
Full diagnostics are in the run’s pytest-results-* JUnit artifacts.
Cause of a failure tracked in #4225.
Metadata
Metadata
Assignees
Labels
tend-ci-causeA root cause of a CI failure report
Activity
leaf-agent commentedon Nov 4, 2026
#5312 fixes this in the tests. The deliberate render failure's
leaf:console report has been deferred to a later task since #4966. That means the error box and a settled presentation can appear before the console holds the report, and the test readtake_browser_errorsstraight away. This is the race #5108 fixed intest_a_returning_widget_repaints_to_restore_subscriptions. The same pattern was in four other browser tests, so all five now wait through the harness'sreported_browser_errors, which still requires exactly the expected report.I held every
leaf:report 300 ms in a local run. The old tests then failed with this issue's[] == [...]diagnostic, and the new ones passed. The failures only showed on macOS, so I dispatched acirun on the branch whosetest-macosjob checks the fix there. Review and CI on #5312 are still pending.