Skip to content

test: isolate workflow integration persistence under a per-process data home - #41

Merged
osovv merged 1 commit into
mainfrom
factory/process-workflow-integration-test-ts-derzhit-obs
Nov 4, 2026
Merged

osovv merged 1 commit into
mainfrom
factory/process-workflow-integration-test-ts-derzhit-obs

Conversation

@osovv

@osovv osovv commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Why the change

Concurrent bun test processes collide on the shared ambient $XDG_DATA_HOME/vvoc/workflow/<sessionId>/ persistence root — the suite's fixed session IDs plus its before/after hooks that delete those directories make parallel runs fail with LAUNCH_PERSISTENCE_FAILED / ENOENT workflow-state.json.tmp-*.

Special things to note

  • No production code changed: persistence keeps its documented $XDG_DATA_HOME/vvoc/workflow/<sessionId>/workflow-state.json contract; only the test file redirects the environment for its own process and restores the caller's value afterwards.
  • The workflow persistence block previously pointed XDG_DATA_HOME at import.meta.dirname, materializing state inside the source tree (src/plugins/vvoc/workflow/…) on one path shared by all processes; it now targets the same per-process temp root.
  • File-scoped afterAll removes the temp root and restores the caller's XDG_DATA_HOME, so other test files in the same bun test process are unaffected.

Change outline

The whole suite now resolves persistence paths from one pid-suffixed root, set up once per file:

const isolatedDataHome = `/tmp/vvoc-workflow-integration-data-${process.pid}`;

beforeAll(() => {
  rmSync(isolatedDataHome, { recursive: true, force: true });
  mkdirSync(isolatedDataHome, { recursive: true });
  process.env.XDG_DATA_HOME = isolatedDataHome;
});

afterAll(() => {
  // restore previousDataHome, rmSync(isolatedDataHome)
});

Every disk-touching block already resolves session directories from the environment at call time, so the redirect covers them all; the persistence block's own override switches from the shared source-tree path to the same per-process root. Two processes therefore never share a <sessionId> directory, and mid-run hook deletions can no longer hit another process's state.

Concurrent bun test processes collided on the shared ambient
$XDG_DATA_HOME/vvoc/workflow/<sessionId>/ root: the suite's fixed
session IDs and its cleanup hooks deleted another process's state
mid-run (LAUNCH_PERSISTENCE_FAILED / ENOENT workflow-state.json.tmp-*).

The file now redirects XDG_DATA_HOME to a pid-suffixed temp root in a
file-scoped beforeAll and restores the caller's value in afterAll, and
the workflow persistence block targets that same root instead of the
shared import.meta.dirname path it previously materialized inside the
source tree. No production persistence behavior changed.
@osovv
osovv merged commit ff2d104 into main Nov 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant