Skip to content

perf(test): reduce unnecessary storage test amplification #2388

Closed

Description

@Astro-Han

Part of #2382.

Status

  • Keep one deterministic fresh-WAL race in the default suite and move additional rounds behind MAKA_STORAGE_STRESS=1. Completed in perf(test): keep one deterministic WAL race in the default suite #2459.
  • Investigate repeated writes in the execution-boundary capacity test. No change needed: the repetitions are required by the 64 KiB per-request limit and 1 MiB cumulative limit.
  • Reduce oversized legacy Plan fixtures used to test bounded projection.

Remaining problem

The legacy Plan projection tests use oversized fixtures to cross bounded-projection limits. Determine the smallest fixtures that still prove truncation and lifecycle behavior.

Relevant tests are in packages/storage/src/__tests__/sqlite-workflow-store.test.ts, including:

  • projects a pre-bound legacy Plan ledger into the bounded Host contract
  • requires a projected legacy proposal to be revised or abandoned

Outcome

  • Use the smallest legacy Plan fixture that reliably crosses each asserted projection boundary.
  • Preserve truncation and projected-legacy lifecycle assertions.
  • Include comparable timing for any fixture reduction.

Disposition

The execution-boundary capacity test should remain unchanged. Reaching the 1 MiB cumulative boundary requires multiple requests because each request is independently capped at 64 KiB; avoiding that would require an unjustified test-only production seam.

Activity

  1. added
    enhancement
    on Aug 7, 2026
  2. jackwener commented on Aug 7, 2026

    @jackwener
    Member

    Partial disposition, and one bullet in this issue turns out to rest on a wrong premise.

    Done: the WAL race rounds (bullet 3)

    allows concurrent operational owners to initialize the same fresh WAL database ran its two-process race 12 times. One round already asserts the contract — two owners racing to initialize the same fresh database both succeed, and the result is a WAL database at the current schema version. The extra rounds re-roll the scheduler hoping for a rarer interleaving, which is stress coverage, not contract coverage.

    They now sit behind MAKA_STORAGE_STRESS=1, the gate root-authority.test.ts and git-workspace-service.test.ts already use, so there is one stress route rather than a flag per file.

    Measured with node --test dist/__tests__/sqlite-recovery-concurrency.test.js:

    that test whole file
    default, after 139ms 1.67s
    default, before 1686ms 3.22s
    MAKA_STORAGE_STRESS=1 1665ms (12 rounds) 3.18s

    Landed in #2459.

    Not done, and I do not think it should be: capacity amplification (bullet 1)

    Repeated writes to reach a capacity limit points at rejects an expansion atomically before the complete boundary exceeds capacity — the slowest single test in the suite at 4201ms. Its repetition is forced by the contract, not excess:

    • MAX_SANDBOX_BOUNDARY_FILESYSTEM_ENTRIES = 32 — entries per request
    • MAX_SANDBOX_BOUNDARY_PATH_CHARS = 4096 — chars per path
    • MAX_SANDBOX_BOUNDARY_SERIALIZED_BYTES = 64 KiB — serialized bytes per request
    • MAX_EXECUTION_BOUNDARY_SERIALIZED_BYTES = 1 MiB — cumulative boundary

    1 MiB ÷ 64 KiB means at least 16 settles are required to reach the shared cap, and the existing fixture (32 × 1800 chars ≈ 60 KiB per request) is already sitting just under the per-request ceiling. I tried collapsing it into two large requests and was rejected first by the 32-entry limit and then by the 64 KiB per-request limit.

    The only way to shorten it is to give the store a test-only injectable cap. That is a test backdoor in production code, added to satisfy a premise that is itself incorrect, so I have not done it. Happy to be overruled if the maintainers weigh it differently.

    The cost is also inherent rather than wasteful: each settle re-serializes the whole accumulated boundary, so reaching a 1 MiB cap is quadratic by construction.

    Not investigated yet

    Oversized legacy Plan fixtures used to test bounded projection — I have not located the specific test. Not claiming it.

    Also checked and not worth a change on performance grounds: foreign-session-store.test.ts seeds 120 threads to cross a LIMIT boundary, and the whole test costs 39.9ms. There is a separate, non-performance argument for deriving that count from FOREIGN_SESSION_SCAN_MAX_SESSIONS (hardcoding it means the test silently stops proving anything if the constant rises), but that is test-correctness, not amplification, and does not belong to this issue.

  3. GabrielDrapor commented on Aug 8, 2026

    @GabrielDrapor
    Contributor

    I'll take this one. Plan per the issue's outcome list:

    1. Fixture-reduction PR: shrink the capacity-limit writes and the legacy Plan fixtures to the smallest size that still crosses each asserted boundary, keeping the atomic-rejection, persisted-state, truncation, and recovery assertions intact.
    2. Stress-policy PR: keep one deterministic fresh-WAL race in the default suite and move the repeated race rounds to explicit stress coverage.

    Will include before/after timing for each PR.

  4. GabrielDrapor commented on Aug 8, 2026

    @GabrielDrapor
    Contributor

    Both PRs are up:

    Two findings from sizing the capacity tests, for the record:

    • The catalog capacity test is already minimal: each connection sits at CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS × CONNECTION_MODEL_ID_MAX_LENGTH, so ~16 commits is the floor for the 4 MiB document cap.
    • The vault capacity test is likewise minimal: secrets are at MAX_SECRET_LENGTH (64 KiB) and the provider auth contract requires one connection per stored secret, so 32 commits is the floor for the 2 MiB cap. Its per-iteration connection creation is required, not amplification.

    All three capacity loops break on first rejection, so their loop caps were never a cost driver — the wins came from entry-count reduction (boundary scans) and the Plan fixture.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions