Skip to content

ui-server: reuse an immutable populated baseline for snapshot refusal tests #1857

Closed

Description

@schlessera

Out of scope

Sharing a mutable world/database object between cases, reusing a corrupt image, cloning open SQLite files unsafely, replacing restore/export proof with mocks, weakening checksum/schema/relation checks, or moving all snapshot lifecycle tests to one setup.

Context

Part of #1849. At source 5cf1d548f7bd3a314eb36394dc5db0268db97da6, world (packages/ui-server/tests/inbox-snapshot.test.ts:48-127) repeatedly builds a populated database with seven intake states, staging files, principals, budgets, activity, push/digest and hygiene data. The file ran48 tests in37.71s locally. In the twelve corruption-refusal cases (test.each, same file:216-244), each case calls world() and exports the same baseline before changing only one part; their measured bodies total7.63s. This is opportunity evidence, not phase attribution or a savings claim.

These cases intend to prove refusal of a particular corrupted snapshot before writing any restore target. They need a valid populated baseline with relevant nonempty relationships, not repeated verification of every intake/setup operation. A prepared immutable snapshot can be cloned into private per-case inputs, while fresh target paths preserve refusal-isolation assertions.

Scope

Amortize populated seed/export preparation for the corruption matrix using an immutable in-process baseline and independent per-test copies. Validate the shared baseline once through the real creation/export path. Keep fresh lifecycle scenarios where source writes, locks, sidecars, crash recovery, admission, app boot or retention are the intent; consider extending baseline reuse only to other clearly immutable refusal cases after an assertion mapping.

Acceptance criteria

  • Capture preparation/export cost separately from corruption/validation/target creation; show that shared preparation yields a measurable gain without test omissions.
  • Create the populated baseline via the real current-source path once per bounded fixture lifetime. Check required relationships/staging are nonempty once; retain a dedicated normal export/restore case with genuine assertions.
  • Each corruption case receives a deep independent copy of snapshot bytes/metadata/files and a unique fresh target. No mutable snapshot object, database connection, writable staging path or teardown callback is shared.
  • Preserve all twelve named corruptions, independently derived expected errors and exact no-target-write assertions. Baseline preparation must not use the restore operation under test to pre-satisfy those assertions.
  • Where database/files are cloned for additional cases, use consistent serialized/backup/checkpointed state and independent writable copies; do not copy an active SQLite main file without its committed state or share writable hardlinks.
  • Keep mutation, concurrency, pending gate, source-staging, sidecar and startup/cleanup tests on fresh appropriate environments. Choose fixture scope by each test's intent.
  • Repeat/permutate corruption cases and run each alone; deliberately corrupt one copy and prove the baseline/next case remain intact. A missing validation guard makes the named case fail before any unrelated assertion; restoration passes.
  • Preserve distinct test names/receipts, failure/cancellation cleanup and offline guards. Report before/after timings with source/runtime context.

Verification

Run focused corruption cases and the complete file via bun run test packages/ui-server/tests/inbox-snapshot.test.ts, with order/copy-isolation and mutation/restoration receipts. Then bun run check:pr --base origin/main and complete selected current-head hosted proof. Follow docs/process/testing.md, compatibility/backup semantics and docs/decisions/example-corpus.md.

Contract impact

None. Test fixture lifetime only; public backup format, schema/relationship validation and restore behavior stay unchanged.

Activity

  1. added
    type: test
    area: ui-server
    agent-ready
    on Oct 14, 2026
  2. self-assigned this
    on Oct 14, 2026
  3. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    Claim e1849-1857-f4e75e84: implementing #1857 on test/1857-snapshot-baseline-e1849-f4e75e84. Scope is the twelve corruption refusals only; fresh lifecycle tests and all independent expected-error/no-target-write assertions remain. I will measure preparation/export separately and retain copy-isolation, permutation, individual-case and mutation/restoration receipts.

  4. added this to the 0.44.0 milestone on Oct 14, 2026
  5. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    Implementation and local proof are in #1864. All 48 original tests remain, plus the new dirty-copy isolation control; the twelve refusals preserve their original expected errors and no-target-write assertions. All twelve pass individually, and three randomized runs of the refusals plus isolation control pass (39 tests).

    One comparable paired local measurement on the same production source/runtime reduced the fixed twelve-case matrix from 8.23s to 1.02s, and the full file from 38.08s/48 tests to 32.36s/49 tests. Preparation/export counts, CPU/RSS, shared-host limitations and the assertion mapping are recorded in the PR. Validation-guard and shared-object mutations fail at their intended assertions; restored proof passes. An injected preparation failure proves source cleanup and a successful subsequent rebuild/restore.

    Final full-file proof and bun run check:pr --base origin/main pass. Current-head hosted proof and merge reconciliation continue on #1864; this is not yet a completed/merged issue. Release milestone 0.44.0 is assigned and read back on both issue and PR.

  6. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    2026-10-14: merged #1864 as ca1facc1e7086bd2119c260150e9f091e16817f1. All 13 selected PR CI jobs passed; packaging was intentionally unselected. The PR records actual job checkout, tested base/tree, and the independent assessment of #1861's intervening Storybook-only advancement. Actual squash parent and tree match the independently computed combined tree, and the squash is an ancestor of fetched main. Issue and PR retain milestone 0.44.0.

    The complete local file improved from 38.08 to 32.36 seconds while retaining all 48 original cases and adding the private-copy isolation control. The same twelve refusal cases improved from 8.23 to 1.02 seconds; maximum RSS increased, so this is not a memory-saving claim. Each refusal passes alone, and the repeated/permuted control and both intended mutations/restoration passed. Automatic exact-squash main CI is running as 38587754901 and remains a separate receipt.

  7. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    Automatic main recurrence — 2026-10-14

    Automatic main CI run 38587754901, unit (1) job 115934452153, reproduced the same MAINTENANCE_CHILD_GONE_BEFORE_TRANSPORT assertion at packages/ui-server/tests/sync-mirror.test.ts:200: expected false, received true after the retained 1,100 ms observation. MIRROR_METADATA_IMMUTABLE passed. The named case took 2,622.80 ms; the shard completed with 913 passes and one failure across 80 files (216.49 seconds Bun elapsed).

    Actual job checkout is the immutable squash ca1facc1e7086bd2119c260150e9f091e16817f1. Its only change relative to its parent is packages/ui-server/tests/inbox-snapshot.test.ts; that test is not selected in this failing shard. The preceding #1861 change concerns central Storybook parity. This provides source/execution separation and another instance of the existing assertion, not a diagnosis of write timing, descendant liveness or transport admission.

    The original #1864 PR run passed all selected jobs; that receipt is not relabelled as this failed main run. No source, guard, deadline or rerun was changed in response. Continue the existing scoped teardown/settlement investigation and retain this additional failed receipt. This recurrence was found during #1849 verification; ownership remains with #1783 under #736, with no new release commitment.

  8. schlessera commented on Oct 14, 2026

    @schlessera
    OwnerAuthor

    Automatic exact-squash main verification is complete: run 38587754901 failed. All executed jobs checked out ca1facc1e7086bd2119c260150e9f091e16817f1. Eleven selected jobs passed; unit (1) failed the existing maintenance teardown assertion tracked in #1783, and the proof aggregate correctly rejected the failed unit domain. Packaging was intentionally unselected for this test-only change. No job was retried.

    The changed snapshot file was not executed in the failing shard. Its PR proof and actual matching-head squash remain as recorded; this separate main run is not green. The recurrence's diagnostics and unresolved teardown boundary are preserved in #1783 under #736. This does not establish a snapshot regression or repair the maintenance defect.

    Hosted timing is recorded separately from local gains: layout (2) took 1,324 seconds and was the longest job. Selection and source differ from other runs, so this is a run receipt, not a causal CI improvement estimate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-servertype: test

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions