Skip to content

Clean up the hocuspocus bunfig.toml #657

Done

Description

@HMarzban

Part of #649. It also takes the test coverage line from #656, which closed.

Benchmark

Field Value
Metric (1) Exact: literal ~ folders under apps/hocuspocus.server, and their size in KiB, after the Step 2 probe. (2) bun test wall time in apps/hocuspocus.server, in seconds, coverage on vs off. (3) Exact: bunfig.toml line count.
Before (1) 1 folder, 156,644 KiB (du -sk 'apps/hocuspocus.server/~', maintainer laptop, read 2026-11-11). The Step 2 probe creates ./~. (2) Not measured yet (agent in the repo, Step 4). (3) 39 lines (wc -l, HEAD 0b302b222, 2026-11-11). Offline image probe: not measured yet (agent in the repo, before Step 5).
After From the 2026-11-12 Measured comment, 45edac16a: (1) the probe creates 0 folders. The old laptop folder is still there, because Step 1 is the maintainer's. (2) 16.21 s with coverage off, against 16.93 s, median of 5, 1209 pass and 0 fail both sides. (3) 11 lines. dist/ sha256 list identical. Offline image probe passes.
Condition Named laptop (model, cores, RAM, OS), Bun 1.4.4, HEAD SHA, warm runs, no other load. Backend image built from the same commit.
How to run (1) du -sk 'apps/hocuspocus.server/~', then the Step 2 probe and find . -maxdepth 1 -name '~'. (2) From apps/hocuspocus.server, bun test 5 times; median and min–max, pass and fail counts. (3) wc -l apps/hocuspocus.server/bunfig.toml. Image: docker run --rm --network none --entrypoint sh <image> -c 'cd /app/apps/hocuspocus.server && bunx [email protected] --version'.
Pass rule 0 folders, 0 B, and the probe creates none. bun test: same pass count, 0 fails. Offline image probe passes. dist/ sha256 list identical. Stop rule: any Guard item fails, then revert the one commit and redeploy the backend.
Guard 🩺 Verify Deployment passes on the (build): back deploy, and the migrate step logs no download.
Owner Agent in the repo: Step 0 and Steps 2 to 7, the image and build checks, the Measured comment. Maintainer: Step 1 on the laptop that holds the folder, and the deploy.
Claim Internal, not marketing: "Turning off default coverage cut the backend unit suite from s to s (median of 5, )."

Problems

Verified 2026-10-31.

  1. [install.cache] dir = "~/.bun/install/cache" makes a literal ~ folder. The runtime (bun <file>) reads this file and auto-installs a bare import. With HOME unset, Bun keeps ~ literal and writes ./~/.bun/install/cache. Any machine that ran the backend with HOME unset may hold this folder. It is gitignored (.gitignore:177), holds no tracked files, and took writes up to 2026-10-21. Step 1 removes it. The size goes only in Measured.
  2. The [install] and [install.cache] keys never apply to installs. In a workspace, bun install and bun add read only the root bunfig.toml, even when run from this folder. Measured: a member exact = true left bun add writing ^3.0.1; a root exact = true wrote 1.0.0.
  3. The [run] bun = true comment is wrong. It says "Automatically install missing dependencies when running". The option puts a node link to bun first on PATH. Keep the setting, because the Prisma CLI has a node shebang and the entrypoint runs it. Write the comment as: "Puts a node link to bun first on PATH, so the Prisma CLI in the entrypoint runs on Bun."
  4. [test] coverage = true (:21) makes every bun test pay for coverage. No CI job reads it: backend-ci.yml:41-42 uses only the exit code. test:coverage already exists.
  5. Lines that restate defaults: the top comment, [run] silent = false, the six image [loader] lines (28-33), the "Optimize runtime performance" comment, and the empty [macros] and [alias] sections. Keep .node = "napi", because the build script runs bun build, where .node defaults to file. The build check in Verification proves the [loader] lines are defaults.

This file ships in the production image

The backend Dockerfile (apps/hocuspocus.server/docker/Dockerfile.bun:31) copies apps/hocuspocus.server into the image. The entrypoint runs an offline bunx [email protected] migrate deploy from that folder, from a cache warmed at build time (Dockerfile.bun:113). rest-api, hocuspocus-server and the worker read this file. So a removed [install.cache] dir, [run] or [loader] line can break boot or the save path. The image check and the production-safety checks below cover that.

Steps

  • 0. Before. Record du -sk 'apps/hocuspocus.server/~' and wc -l apps/hocuspocus.server/bunfig.toml. Build the backend image and run the offline image probe from Benchmark. It must pass. Run bun run build in apps/hocuspocus.server, then shasum -a 256 dist/*, and save the list.
  • 1. Remove the old folder first. If apps/hocuspocus.server/~ exists, remove it. If not, skip and say so. From the repo root, check that git ls-files 'apps/hocuspocus.server/~' prints nothing. Then run rm -rf -- 'apps/hocuspocus.server/~'. Always quote the tilde. An unquoted ~ expands to your home folder, and rm -rf ~ deletes it.
  • 2. Probe before the change. From apps/hocuspocus.server, run T=$(mktemp -d). Write $T/x.ts with an import of a package that is not in the repo, such as is-odd. Run env -u HOME bun "$T/x.ts". It creates ./~.
  • 3. Remove that probe folder the same way, with the path in quotes.
  • 4. From apps/hocuspocus.server, run bun test 5 times. Record median and min–max wall time, and pass and fail counts.
  • 5. Delete the [install] and [install.cache] blocks, the coverage = true line, and the lines in Problem 5. Fix the [run] comment.
  • 6. Probe after the change. Run the step 2 command again. Then find . -maxdepth 1 -name '~' must print nothing.
  • 7. From apps/hocuspocus.server, run bun test 5 times again. Record median and min–max wall time, and pass and fail counts. Expect the same pass count and 0 fails. Post both sets on this issue.

Verification

  • cd apps/hocuspocus.server && bun test passes; it reads this file's [test] preload. The step 6 probe leaves no ~ folder.
  • Build check: bun run build, then shasum -a 256 dist/*. The list matches the Step 0 list. If it differs, restore the [loader] lines.
  • Image check: rebuild the backend image from the change. The offline image probe passes.

Production safety, on the (build): back deploy

  • 🩺 Verify Deployment passes, and the migrate step logs no download. Met on 06f61ee44 ((build): front back, run 43876524495, 2026-11-16), which holds 45edac16a. The migrate log shows "No pending migrations to apply." and no download.

Status 2026-11-16: one step is left. The maintainer does Step 1 on the laptop, with the tilde in quotes. Then close.

Rollback

Run #554 SP1, then git revert the commit. Push a (build): back commit. Then re-run the Guard and the offline image probe.

Activity

  1. added this to the v2.4.0 milestone on Oct 31, 2026
  2. modified the milestones: v2.4.0, v2.3.6 on Nov 9, 2026
  3. HMarzban commented on Nov 12, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-12

    Condition: MacBook Mac17,6, 18 cores, 48 GiB RAM, macOS 27.0.1 (26A434). Bun 1.4.4. Docker 29.8.2. HEAD cfac48d87 plus the change now committed in 45edac16a (not pushed yet). Date 2026-11-12. Other agent tracks ran on the same laptop, so load average was 6 to 14 during the test runs; each run line records it.

    Metric Before After
    (1) Literal ~ folders the Step 2 probe creates 1 (./~, 48 KiB, in a scratch folder holding only the HEAD bunfig). In the real folder it wrote 6 entries into the old ./~. 0. The probe writes to Bun's default node_modules/.bun-cache instead.
    (1) The old apps/hocuspocus.server/~ folder 156,644 KiB (du -sk) Still there: Step 1 is the maintainer's. The probe added 0 entries to it.
    (2) bun test wall time, median of 5 (min to max) 16.93 s (16.57 to 18.72), coverage on 16.21 s (16.18 to 16.21), coverage off
    (2) Same-session control, bun test --coverage on the new file 16.67 s (16.56 to 16.80)
    (2) Pass / skip / fail, every run 1209 / 7 / 0 1209 / 7 / 0
    (3) wc -l apps/hocuspocus.server/bunfig.toml 39 11
    dist/ sha256 list, same build args 5 files; two HEAD builds identical identical to HEAD
    Offline image probe (--network none, bunx [email protected] --version) pass, rc 0 pass, rc 0
    Offline bunx [email protected] migrate deploy, fake DB URL reaches P1001, no download reaches P1001, no download

    How to run:

    • (1) env -u HOME bun "$T/x.ts" from apps/hocuspocus.server, where $T/x.ts imports is-odd. Then find . -maxdepth 1 -name '~'.
    • (2) /usr/bin/time -p bun test in apps/hocuspocus.server, after one warm-up run, 5 times. The control adds --coverage.
    • Build: bun build src/index.ts src/hocuspocus.server.ts src/hocuspocus.worker.ts --outdir=<empty scratch dir> --target=bun, then shasum -a 256 *. These are the build script's arguments. A clean outdir avoids stale files in dist/.
    • Image: docker build -f apps/hocuspocus.server/docker/Dockerfile.bun -t <tag> ., then docker run --rm --network none --entrypoint sh <tag> -c 'cd /app/apps/hocuspocus.server && bunx [email protected] --version'.

    Reading:

    • Coverage off saves about 0.5 to 0.7 s of about 16.5 s, 3 to 4 percent. The suite's wall time is not CPU-bound (user CPU is about 3 s), so the gain is small.
    • The .node = "napi" line is still needed. A build with --loader .node:file changed index.js.
    • Finding: a laptop-built image holds an empty /app/apps/hocuspocus.server/~ folder, in both the before and the after image. Root .dockerignore drops its .bun contents but not the folder. A CI checkout has no such folder. Step 1 on the laptop removes it from laptop builds.

    Claim: "Turning off default coverage cut the backend unit suite from 16.93 s to 16.21 s (median of 5, Mac17,6, Bun 1.4.4)." A same-session control puts the coverage cost at 0.46 s.

    Not measured: Step 1 (maintainer). Production guard: 🩺 Verify Deployment, the migrate log, #554 SP6 with a fast tab close, store gauges at +1 h and +24 h, and the docker exec check for ~ in each backend container (maintainer).

    Evidence: Notes/local-docs/2026-11-11-v236-evidence/batch-a/t7-653-657/657-*.

  4. HMarzban commented on Nov 14, 2026

    @HMarzban
    CollaboratorAuthor

    Moved to v2.3.7 at the v2.3.6 release audit. Before and after are posted. Step 1 and the production guard checks are not done yet.

  5. modified the milestones: v2.3.6, v2.3.7 on Nov 14, 2026
  6. HMarzban commented on Nov 16, 2026

    @HMarzban
    CollaboratorAuthor

    Review, 2026-11-16 (maintainer approved).

    • The change is deployed. 06f61ee44 (run 43876524495) holds 45edac16a and passed 🩺 Verify Deployment. The migrate log shows no download. That box is ticked.
    • The [Tracking] Faster, change-aware CI/CD pipeline #554 SP6 scratch-pad check is cut. SP6 covers M5, healthcheck, stop-timing and roll-order changes only. This bunfig cleanup has identical dist/ hashes.
    • The +1 h and +24 h store reads are cut. A shared deploy cannot show the effect of Clean up the hocuspocus bunfig.toml #657.
    • The docker exec check for ~ is cut. A CI checkout never has that folder, so the check cannot fail.
    • The After row and the Step and Verification boxes now match the 2026-11-12 Measured comment.
    • One step is left: the maintainer does Step 1 on the laptop, with the tilde in quotes. Then close.
  7. HMarzban commented on Nov 24, 2026

    @HMarzban
    CollaboratorAuthor

    Measured, 2026-11-24: Step 1 completed

    Question: Does the stray literal ~ folder remain in apps/hocuspocus.server?

    Verdict: Removed and verified clean; closing #657.

    • git ls-files 'apps/hocuspocus.server/~' printed nothing.
    • du -sk 'apps/hocuspocus.server/~' measured 156,644 KiB before removal.
    • Removed apps/hocuspocus.server/~ (rm -rf -- 'apps/hocuspocus.server/~'); test ! -e 'apps/hocuspocus.server/~' passes.
    • Combined with the 2026-11-12 Measured checks and 2026-11-16 06f61ee44 deploy (🩺 Verify Deployment pass), all acceptance items are complete (156,644 -> 0 KiB, 100 % removed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions