Skip to content

fix(runtime-host): defer conversation-copy discards to post-ready maintenance - #6022

Closed
BigDataDZ wants to merge 1 commit into
apache:mainfrom
BigDataDZ:fix/4027-defer-session-purge-post-ready
Closed

BigDataDZ wants to merge 1 commit into
apache:mainfrom
BigDataDZ:fix/4027-defer-session-purge-post-ready

Conversation

@BigDataDZ

Copy link
Copy Markdown
Contributor

Summary

Startup recovery used to await the physical sidecar purge of preparing conversation copies before the Host could publish Ready. The purge resolves artifact paths across the whole artifact store, so a workspace with a large accumulated store paid an O(all files) syscall sweep on every Host start and blocked readiness for minutes (profile and repro in #4027).

Recovery now only queues the copies it decided to discard:

  • The durable headers stay the authority. An entry that never drains (crash before Ready) is re-derived by the next recovery pass, and every reader already treats a preparing copy as inert (root turns reject it, retirement skips it), so a copy visibly preparing for a few extra seconds post-Ready is a state the system already supports.
  • Queued discards drain one admission-leased discard at a time through a new HostStorageMaintenance lane (deferred session discard), reusing the existing bounded-lane pattern (start after Ready, 100 ms active pacing, exponential backoff, drain/close shutdown semantics).
  • The drain re-reads the header under the Session admission lease, so a copy committed or discarded in the meantime wins over the stale recovery snapshot, and a revision that admitted its first turn in between is committed instead of discarded (same rule as recovery).

This is the readiness half of #4027. The O(store) guard scan inside preparePurgePathsUnlocked itself (the other half) is intentionally untouched and can follow separately.

Refs #4027

Verification

  • tsc --noEmit clean in @maka/runtime-host; biome check clean on the five touched files.
  • New lane test in storage-maintenance.test.ts: sweeps at the active pace while the queue reports work, idles once drained.
  • Updated execution-composition.test.ts "optional context Store cannot open": recovery no longer attempts the purge (no cleanup diagnostic), the maintenance lane takes the queued discard after Ready and reports retries while this environment cannot complete the purge, and the header stays preparing.
  • New composition test "deferred conversation-copy discards drain through post-ready maintenance": a preparing copy survives recover() untouched and is fully discarded by the lane after Ready.
  • session-revision-two-client-uds, execution-host-recovery, host-kernel, and the full execution-composition suite were run locally on Windows. Three host-kernel failures and two execution-composition failures (WorkHub does not record resume..., production executor admission discovers...) reproduce identically on a clean main build on this machine and appear unrelated to this change. The full-composition run also showed the node process not exiting after all 46 tests reported, which also predates this branch. The husky pre-commit hook was bypassed (--no-verify) because it fails to spawn biome.cmd under Node 24 on Windows (EINVAL, scripts/biome-staged-check.mjs); the touched files pass biome check directly.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: ZCode (GLM). Read the recovery/purge path and drafted the change and tests; the human contributor reviewed the approach, ran the verification locally, and owns the result. Commits carry Generated-by: ZCode.

…ntenance

Startup recovery used to await the physical sidecar purge of preparing
conversation copies before the Host could publish Ready. The purge
resolves artifact paths across the whole store, so a workspace with a
large accumulated artifact store paid an O(all files) syscall sweep on
every Host start and blocked readiness for minutes (apache#4027).

Recovery now only queues the copies it decided to discard. The durable
headers stay the authority: an entry that never drains is re-derived by
the next recovery pass, and readers already treat a preparing copy as
inert. Queued discards drain one admission-leased discard at a time
through a new HostStorageMaintenance lane, re-reading the header under
the lease so a copy committed or discarded in the meantime wins over
the stale recovery snapshot.

Refs apache#4027

Generated-by: ZCode
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

This pull request has had no new commits for 30 days and has been marked stale. It will be closed in 7 days unless a new commit is pushed.

Comments do not reset this timer: only a new commit does. If the pull request is intentionally long-lived, a maintainer can apply the pinned label.

@github-actions

Copy link
Copy Markdown

This pull request has been closed because it received no new commits during the 7-day grace period. This is not a judgement on the merit of the change; it only keeps the review queue aligned with work that is actively in flight.

The branch and review history are preserved. Push a new commit and reopen the pull request whenever the work is ready to continue.

@github-actions github-actions Bot closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines stale No qualifying activity within the lifecycle policy window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant