Repository navigation
Description
Out of scope
Blindly merging tests into a giant sequential scenario, losing named failures, shared mutable state without demonstrated reset, reusing an environment whose creation/destruction is the assertion under test, blanket concurrency increases, cross-input passing-test caches, or duplicating #1837's workspace-build investigation.
Context
Part of #1849. The maintainer's2026-10-14 direction is to reduce repeated initialize/setup/cleanup/destroy cost only when reliability is preserved. Evaluate three options: multiple independent tests sharing an environment, private clones of a prepared environment, and reusable environments with complete cleanup/reset. The deciding criterion is test intent: not every test must prove the integrity of the entire setup. Use the smallest environment that proves each actual assertion.
At source 5cf1d548f7bd3a314eb36394dc5db0268db97da6:
- Runtime suites already share workspace preparation, host and browser within a file (
beforeAll,packages/ui-react/tests/chat-focus-runtime.test.ts:29-84;afterAllat86-92). Each case opens an isolated context (async function open, same file:94-108). These are not full browser launches per case. - Small suites still pay their own complete lifecycle: Haiku has one test with0.49s of body time and58.36s local file elapsed (
beforeAll,packages/ui-react/tests/haiku-model-runtime.test.ts:13-29; test at32). The catalog's outside-body time includes compilation, imports and other setup; it is not a browser-startup measurement. ci: attribute and reduce repeated workspace builds in UI runtime tests #1837 owns build attribution; this task owns other lifecycle phases and safe environment grouping. - The earlier catalog reported2,151 navigation executions and about942s aggregate local body time. The verified current source owns605 navigation cases per pointer project (1,815 across fine/coarse/mixed), plus imported durable-Actions cases; the old aggregate does not define the current own-case inventory.
mount(packages/ui-react/tests/browser/navigation-reach.pointer.tsx:136-186) creates/disposes a fresh root and renderer, while styles/browser/viewport preparation are already shared. Its header explicitly selects one fresh scene per cell under ui-react: the phone navigation matrix tests time out in CI and leak into the next test #1077. Revisit only with proven intent/isolation equivalence, not by deleting those guards. - Safe existing practice: scrape browser-politeness shares Chrome/listeners, resets hit/rule state and creates/closes sessions per case (
packages/scrape/tests/browser-politeness.test.ts:30-63), checking page cleanup. Offline recovery scenes deliberately have separate contexts (packages/ui-react/tests/browser/offline/scene-commands.ts:63-99) because persistence/termination is the behavior under test. - Native app fixture acquisition has process-global spies/reference counting (
replaceNativeStartupAcquisitionForFixture,packages/ui-server/tests/helpers/fixture-native-startup.ts:18-30). Sharing across files/processes must account for mock restoration, resolver lifetime, namespaces, ownership and shutdown rather than introduce a global app singleton.
Scope
Produce an intent/lifecycle map and controlled fresh-versus-shared-versus-cloned-versus-reset comparisons for representative runtime/navigation fixtures. Recommend the smallest reliable reuse boundary and file bounded implementation children under #1849 where evidence supports changes. Coordinate build measurements with #1837 and prepared-snapshot/HTTP-mount opportunities with the linked lifecycle children; do not duplicate their implementation.
Acceptance criteria
- For each candidate, name test intent and the minimum collaborators/state that prove it. Separate setup validity checked once from lifecycle, isolation, cold-start, crash/recovery and cleanup behaviors that need dedicated fresh cases.
- Attribute imports/build, immutable preparation, app/broker/index/browser startup, context/page/root creation, execution, quiescence/reset and final teardown. Measure actual invocation counts/cost; no claim that elapsed-minus-body time is all setup of one type.
- Compare existing per-file browser sharing with a bounded compatible worker/group lifetime, keeping fresh storage contexts and unique mutable server state. Group only compatible launch flags, pointer modes, offline policy and resources. No sharing across deliberately isolated browser/font/media processes.
- For navigation matrix cells compare fresh root/renderer with a narrowly defined reset; retain individual case identity and meaningful coverage. Inspect ui-react: the phone navigation matrix tests time out in CI and leak into the next test #1077's isolation rationale and current cleanup before proposing to supersede it. A documented rejection of warm reuse is valid.
- Immutable baseline cloning never shares writable files, SQLite handles/sidecars, localStorage/IndexedDB, cookies, caches or active resources. Reset reuse explicitly inventories and clears/drains all state needed by the test's intent, including in-memory backend state, counters, observers, timers, sockets and pending work.
- Demonstrate each case alone, in repeated/permuted order and after a deliberately dirty or failed prior case. The same assertions must hold; sentinel state must not leak. Include cancellation/setup failure/teardown failure and actual resource cleanup. These controls validate the harness once; ordinary cases do not each repeat the entire harness-integrity suite.
- Do not require cross-test progression or combine separate named tests merely to amortize setup. Preserve standalone focused commands and trustworthy source/build identity.
- Report baseline/alternative elapsed, total consumption, peak memory/resource counts and flake/order evidence under equivalent resources; reject reuse that worsens reliability or masks startup/cleanup defects.
- Deliver a supported recommendation and separately scoped implementation issues. This spike does not implement production or harness changes.
Verification
Inspect actual fixtures and run bounded comparisons with temporary diagnostics outside the committed tree. Keep offline guards and native browser/process boundaries intact. Record tested source/lock/runtime/resource context, order/sentinel/failure-cleanup receipts and component phase times. Use existing bun run test and pinned browser runners. The recommendation must respect docs/process/testing.md, docs/decisions/ci-utility.md, default/built package consumers, workspace leases and example-corpus rules.
Contract impact
None selected. A lifecycle investigation and implementation recommendations only; no new public environment/reset seam is authorized.
2026-10-14 investigation correction at 5dc2595ca07042f2e2024c95bbc361f31637559f: reconciled navigation own-case counts with its loops and imported Actions registration; historical timing remains context, not a current comparison.
Investigation result — 2026-10-14
Measured lifecycle report and failure/restoration receipts.
Keep per-file browser ownership, private contexts and fresh navigation scenes. The explicitly loopback-bound grouped candidate passed all eight original cases but saved only 0.15–0.18 seconds of browser ownership work; whole-command time fell between the two fresh controls, while two unchanged workspace builds consumed about 111–114 seconds. No stable end-to-end gain supports a new shared owner. Visible-store reset failed the private-principal sentinel under all three native pointer modes; fresh construction restored 33/33 diagnostics. Browser ownership failure/cancellation controls and private-file cloning controls passed. Copying the tiny fixture was slower than regeneration.
No implementation child is justified. #1837 retains build attribution; #1857 and #1858 retain their separately scoped snapshot and HTTP opportunities. No production/harness change or reduced proof obligation is delivered. Temporary tracked diagnostics were restored and the worktree is clean. Milestone 0.44.0 records completion of this investigation, not a claimed runtime optimization.
Activity
schlessera commentedon Oct 14, 2026
Claiming #1856 for the authorized #1849 investigation. Claim token:
e1849-1856-f4e75e84; branch:spike/1856-fixture-lifetimes-e1849-f4e75e84. One dedicated GPT-6-Astra worker will compare lifecycle boundaries with measured controls, preserve named native guarantees and report supported recommendations separately from implementation. #1857/#1858 own snapshot/HTTP changes; #1859's completed map supplies overlap context.schlessera commentedon Oct 14, 2026
2026-10-14 fixture lifecycle investigation at source
5dc2595ca07042f2e2024c95bbc361f31637559f. This is a written spike result; no production or test-harness change is delivered.The recommendation is to keep existing per-file browser ownership, fresh navigation scenes and fresh browser storage contexts. The measured small runtime group does not justify introducing a process-wide browser owner. A visible-store reset is demonstrably incomplete. Private immutable-data cloning remains appropriate for the populated snapshot opportunity already owned by #1857, while #1858 owns its audited compatible HTTP mounts. Do not generalize either into a mutable app singleton. Repeated workspace compilation remains #1837's investigation.
Intent and minimum reliable lifetime
beforeAll,packages/ui-react/tests/haiku-model-runtime.test.ts:13–29; test at 32)beforeAll,packages/ui-react/tests/chat-focus-runtime.test.ts:29–84;openat 94–108)mount,packages/ui-react/tests/browser/navigation-reach.pointer.tsx:136–186)offlineScene,packages/ui-react/tests/browser/offline/scene-commands.ts:62–99)beforeAll,packages/scrape/tests/browser-politeness.test.ts:30–63)createNativeAppFixture,packages/ui-server/tests/helpers/native-app-fixture.ts:9–19;replaceNativeStartupAcquisitionForFixture, fixture-native-startup.ts:18–30)Startup, permission acquisition, cold-storage behavior, isolation, crashes and teardown must keep dedicated fresh lifecycle cases. They cannot be certified by this browser-sharing experiment or by a fixture reset unit test. No tests are merged into sequential progression and standalone
bun run test <file>remains unchanged.Measurement method
Bun 1.4.2 (
744846f84), Playwright 1.63.0, local Google Chrome 140.0.7339.127, Linux x86_64, 32 logical CPUs, approximately 48 GiB RAM; no dedicated resource reservation. Lockfile SHA-25692a734b4d010bb85631c9bc03b47102660afa722c3039db165ed9aa3c042c7c0. The dedicated worktree had its own frozen dependency install (0.933 s, excluded); no borrowed build/dependency directory. Every timed command acquired the epic-wide OS flock before GNU time; waiting is excluded. The host remained shared, so observations are not statistical or hosted-CI speedup claims.Temporary copies retained all original test assertions and source builds. Direct timers bracketed workspace build child/output completion, client bundle, fixture-brain creation, fixture broker, actual createApp, browser launch/connect, context/page/navigation, close and app drain. The grouped alternative launched one Chrome BrowserServer explicitly bound to
127.0.0.1, then ran each real test file in its own guarded Bun process, connecting to that browser with identical launch arguments. Each file retained its own static assets/server, brain/DB/backend/broker, and every case retained a fresh browser context. Tests continued to route pages only to their exact loopback app origin. Grouped child disconnect and final owner shutdown were separately timed.The original runtime files were not changed. Test-only diagnostic copies used absolute imports back to the same source. The initial fresh run's import marker is not a full import measurement and is excluded from import claims; the later runs add a preload-to-first-module-statement timer for import/collection, with runner/lease startup still outside that span. Nothing labels total-minus-body as browser startup. Body times reported by Bun include context/page work; those nested spans must not be added again. Real-app startup includes database initialization and its normal probe/recovery work; this small fixture does not run a standalone corpus indexing command, so index invocation count is zero rather than an invented index duration.
All 24 original-case executions in the table passed, with 39 original expectations per group. Chronologically, the runs were initial fresh, an exploratory grouped run, reversed fresh, then the final explicitly loopback-bound group. The exploratory group also passed eight cases in 130.17 s, but used Playwright's unspecified default listener host; it is excluded from the final isolation/cost comparison rather than relabeled as loopback-bound. The installed Playwright source audit prompted the explicit bind and complete candidate/ownership rerun. Each command still performed two complete workspace builds, two client bundles, eight context/page acquisitions and closes, one fixture-brain preparation, one fixture broker and real app lifetime, and two local HTTP server lifetimes. Browser process launch/close counts changed from two/two to one/one plus two connection/disconnection pairs. At most one browser and one case context were active at a time. The grouped browser additionally stayed alive through compilation; the experiment does not imply that keeping it idle has no resource cost.
The grouped browser operations saved only 0.15–0.18 s relative to the two fresh controls. Its whole-command time falls between them: 1.02 s slower than the initial fresh pair and 1.98 s faster than the reversed fresh pair. Build/body variation is larger than the measured browser-operation saving, so there is no demonstrated stable end-to-end improvement. Even deleting the baseline's entire browser launch/close interval could save less than half a second in this pair. This does not justify a new shared-process owner and additional failure coupling. No CPU or memory reduction is claimed.
Imports were measured separately with a guarded dynamic-import probe in a fresh Bun process: Playwright 151.188 ms; public ui-server 171.722 ms; native app helper 1.469 ms; SDK client 0.037 ms; core fixture 0.925 ms, in that order. It passed in 0.40 s whole command, 0.53 s CPU, 151,208 KiB maximum RSS. These are import-call intervals with their actual dependency cache overlap, not a decomposition of static loader startup from the runtime group. The later preload markers measured 218.225/240.537 ms to both first test-module statements; they omit earlier loader work and are not substituted for the import probe.
GNU time's maximum RSS is the reported maximum for the command/waited descendants, not a sum of concurrent browser/server memory. CPU totals include waited child work. No hosted queue, selected-job critical path or full-suite saving was measured. These local samples must not be combined with historical different-source CI totals.
Reset and cloning boundaries
A clone may contain immutable serialized fixture inputs only. Each mutable file/database/sidecar, browser storage partition, cookie/cache, observer, socket, timer, pending callback, backend counter and principal requires a private owner or a demonstrated complete reset. A live root/renderer, SQLite handle, process or browser context is not cloneable immutable data.
Navigation's root owns state outside Zustand store snapshots: answerStorage and manager maps/principal/epochs, authLock and connection closures, tab coordination, subscriptions, tracks/uploads/object URLs, activity/graph controllers, file reset and VPN callback ownership (
createRoot,packages/ui-react/src/root.ts:109–303). Component-local state, observers, handlers, focus/selection, animations and in-flight effect work also belong to the renderer. CallingsetState(getInitialState(), true)on each store and clearing request counters leaves an answer-storage principal sentinel behind. The timed diagnostic requires that sentinel to be null and fails that precise assertion; a subsequent fresh scene is clean. This is an intentionally rejected candidate, not a newly discovered product defect.D52's required full matrix is unchanged (
Verification the implementations owe,docs/decisions/design-kit/sessions-and-drafts.md:1032–1040). #1077/#1081 fixed actual timeout cross-contamination by making one test/scene per cell and fencing late work with each test's abort signal. Warm reuse would need to prove old callbacks cannot target a successor and reconstruct every closure/component lifetime. A small store-reset timing cannot establish that equivalence, and this spike does not supersede the ruling.The current navigation file owns 605 cases per pointer project, 1,815 across the three pointers, plus imported durable-Actions cases. The earlier 2,151 figure is not the current own-case inventory. The diagnostic below samples lifecycle behavior only and removes the imported suite only in the throwaway copy; it neither replaces nor measures the complete native matrix.
The bounded pinned diagnostic used the unchanged
scripts/visual.mjs --project=rail-fine --project=rail-coarse --project=rail-mixedentry point andmcr.microsoft.com/playwright:v1.63.0-noble. Only the throwaway selected test body/config changed; launch flags, native presses, guards, image and file parallelism stayed unchanged. To measure actual container CPU/RSS, the second rejection run and fresh restoration temporarily bound GNU time read-only into the image and timed the existing--insiderunner. Host Docker-client resources were not reported as browser resources.Its 33 named cases comprise four real routes (occupied→Graph, settings→Chat, graph→Settings, occupied→New chat), each alone as its own fresh-scene test and repeated in reversed order, plus three controls, in each of the three pointer projects. The route assertions retain real pointer premise, native walk, target state, drawn surface, exact D52 activation count, no unexpected writes and no horizontal overflow. The controls are the intentionally failed reset, fresh clean successor after that failure, and abort-fenced old scene followed by a fresh successor. This is a lifecycle sample, not the full matrix or a replacement proof obligation.
RESET_MUST_CLEAR_PRIVATE_PRINCIPAL: expected 'odysseus-dirty' to be null. It failed the intended assertion, not loading or a timeout. A second measured repetition produced the same three failures and all 30 passing neighbors.mountbefore the identical principal oracle. All 33 passed, including the route assertions, clean successor and abort fence. The fresh control changes construction, not the expected null oracle.The reset inventory above explains why adding one
setPrincipalKeyreset would not prove a complete warm root. The observed residual is sufficient to reject that candidate; no claim is made that every possible warm-reset design was exhausted. Existing settle frames account for more than root construction, but changing their temporal/geometry role belongs to #1855 and needs its own proof; this spike changes none.A separate guarded browser-owner control suite passed 11 cases: independent A/B contexts, repeated A/B and reversed B/A, a deliberately dirty failed prior case, a clean successor, setup failure after context acquisition, teardown failure while finally still closes ownership, and a SIGKILLed connected child. Each context starts with empty localStorage/sessionStorage/IndexedDB/cache/cookies, then dirties those stores and leaves an interval; closing it returns the owner to zero contexts. The killed child had a real page and dirty storage; a separate CDP observation verified its page target disappeared before the next clean context. Final owner close verified process exit. These are ownership-control receipts, not proof of every app's teardown-failure path or arbitrary host kill behavior. Apps are not shared by the proposed group.
The same command included a private-file-clone control for the actual minimal
createFixtureBraininput (scripts/captures/core-fixture.ts:7–14). It prepared the baseline once in 0.904 ms, then compared 20 fresh / 20 private copies / 20 private copies / 20 fresh, with exact note contents, expected file inventory, per-copy dirty mutation/removal and unchanged baseline checked every time. Each copy has separate writable note/config files; the existing dependency-resolution symlink points to the same installed immutable inputs, not to a live fixture database. No SQLite files, handles or active resources were present to clone. Full iteration blocks, including identical assertions, dirties and cleanup, took 17.857 / 45.102 / 44.544 / 17.352 ms respectively. Copying this tiny fixture is slower than regenerating it; no minimal-brain cloning child is justified. This does not contradict #1857's much more expensive populated export baseline.The initial combined ownership and clone control command passed 12 tests / 266 expectations in 1.76 s whole command, 2.18 s CPU, 191,108 KiB maximum RSS. After explicitly binding the browser owner to loopback, all 11 ownership controls were repeated: 11 pass / 0 fail / 26 expectations, 1.65 s whole command, 2.11 s CPU and 188,984 KiB maximum RSS. The clone measurements are independent of that listener and were not repeated. Isolation evidence is bounded: no arbitrary-order or long-running flake guarantee is claimed. The repeated/permuted cases, explicit dirty/failure/cancellation checks and retained independent names are the actual receipts.
All temporary tracked navigation/config/runner edits were restored, the expected-failure screenshot removed, and final
git status --shortis empty. Diagnostic scripts/logs remain local scratch evidence only; no harness code, fixture reduction or test-selection change is retained.Follow-through and scope
No additional implementation child is supported by these results. Duplicate/routing audit identified #1837 for build attribution, #1857 for exported immutable snapshot inputs, #1858 for audited HTTP lifetimes, #1855 for waits, and #1859/#1865 for the narrower proof-level race reduction. Existing lifecycle/isolation problems such as #995 are not solved by adding shared mutable ownership. The public behavior remains in brain-kit; no template or instance change is involved.
The spike's recommendation is a documented no for global browser sharing and warm navigation root reset at this time. It does not reject future evidence after #1837 isolates or reduces compilation. Any later proposal must preserve fresh source/default-export identity, existing workspace leases, all named tests/guards and compatible browser flags, and demonstrate benefit beyond variability plus failure/cancellation cleanup. No new public environment/reset seam, passing-result cache, concurrency increase, dropped assertion or deadline change is proposed.