ui-server: an in-memory database gets a quarantine temp directory that nothing removes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- bun, typescript
Research direction
Start in packages/ui-server/src/brain/host-execution.ts, following quarantineDirFor, createHostExecution, and release() to see how in-memory and file-backed paths differ. Add the requested cleanup coverage to the tests named in the acceptance criteria, including close and boot-failure cases. Done means only the in-memory directory is removed on release, while a file-backed quarantine directory remains; also add the required changeset.
Written by the indexing model from the issue text.
Description
Context
Quarantined files go to a host-private directory beside the database. For a database path of ":memory:"
there is no "beside", so quarantineDirFor (packages/ui-server/src/brain/host-execution.ts:27-30) creates a
fresh directory with mkdtempSync(join(tmpdir(), "brain-ui-quarantine-")).
createHostExecution creates it the first time manifests are opened (open,
packages/ui-server/src/brain/host-execution.ts:84-85), which happens on every boot through attach
(:115-129), and exposes it as quarantinePath() (:99). release() (:130-133) closes an early database
handle and nothing else. The app calls release() on boot failure and on close
(packages/ui-server/src/app.ts:511, :1574), so the directory has no owner that removes it: the file
contains no rmSync or rm call at all.
The in-memory path is a supported configuration, not an accident of tests: it has its own layout test
("an in-memory database refuses private quarantine storage inside the brain",
packages/ui-server/tests/operational-state-layout.test.ts:112-121). 27 test files boot an app or a host
execution with DB_PATH or dbPath set to ":memory:", and each boot leaves one empty directory in the
shared temp root. On a machine that runs the suite repeatedly these accumulate without bound; the audit
counted several hundred left behind within three days on one development machine.
Related: #4467 (the test app's teardown leaves the journal database behind) is the same kind of leak in a
test helper; this one is in production code that tests run.
Scope
- A quarantine directory that
createHostExecutioncreated for an in-memory database is removed,
recursively and best-effort, whenrelease()runs. - A file-backed database's
<dir>/brain-ui-quarantineis never removed byrelease().
Out of scope
- Creating the directory lazily on first quarantine. The path is handed to the manifest store when it opens
andquarantinePath()is reported to storage accounting (packages/ui-server/src/app.ts:1280-1281);
removing what was created is the smaller change. - The journal database a test app leaves behind (#4467) and other temp directories tests create.
- The two cleanup lists of
createApp(#2514). - Requiring callers that pass
":memory:"to supply their own quarantine directory. That changes a
published option's meaning.
Acceptance criteria
- A test boots an app with
DB_PATH: ":memory:", readsquarantinePath()(or the "Quarantined changes"
store path the app reports), closes the app and asserts the directory no longer exists. It fails on
the tree before the change. Mutation: remove the cleanup fromrelease()and the directory is still
there. - A test asserts the same for a boot that fails after the host execution was created (the boot-failure
path also callsrelease()). - A test with a file-backed
DB_PATHplaces a file under<dir>/brain-ui-quarantine, closes the app and
asserts the file is still there. Mutation: remove the directory unconditionally inrelease()and
this test fails. -
packages/ui-server/tests/operational-state-layout.test.tsand
packages/ui-server/tests/host-execution-boundary.test.tspass with no expected value changed.
Verification
bun run test packages/ui-server/tests/operational-state-layout.test.ts
bun run test packages/ui-server/tests/host-execution-boundary.test.ts
NODE_OPTIONS=--max-old-space-size=6144 bun run typecheck
bun run lint
bun run check:pr --base origin/main
Contract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
An embedder that boots @schlessera/brain-ui-server on an in-memory database no longer finds the temporary
quarantine directory after close().
Found by a repository audit on 2026-11-26 (main 87b96b10c); independently reviewed before filing.
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 0
- Avg merge
- 8h 3m
- Merged PRs (30d)
- 606
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from schlessera/brain-kit
-
agent-ready area: ui-server priority: p3 type: refactor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
schlessera/brain-kit#4833 ·
Maintainers usually reply within 1 day
-
ui-sdk: the turnId doc comment tells client authors echoing is optional, which a rev 3 host refusesOpenagent-ready area: ui-sdk priority: p3 type: docs
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
schlessera/brain-kit#4824 ·
Maintainers usually reply within 1 day
-
agent-ready area: ui-react blocked priority: p3 type: refactor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
schlessera/brain-kit#4819 ·
Maintainers usually reply within 1 day
-
jobs: every command writes on open, so a read fails with "database is locked" during a long writeOpenagent-ready area: modules priority: p2 type: fix
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
schlessera/brain-kit#4809 ·
Maintainers usually reply within 1 day
-
agent-ready area: ui-server priority: p2 type: refactor
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
schlessera/brain-kit#4806 ·
Maintainers usually reply within 1 day
All issues in schlessera/brain-kit
Similar issues
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
backend enhancement priority:P3
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
geolens-io/geolens#4161 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
xdelmo/Portfolio-minimal#667 ·
Maintainers usually reply within 1 day
-
external-issue to-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
supabase/supabase#54162 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
CyberTimon/RapidRAW#2303 ·
Maintainers usually reply within 1 day