Skip to content

Stores: Compact, a job with its steps and what it freed - #38

Merged
yifanxuaaa merged 1 commit into
layerfs_v2_0_0from
claude/store-compact
Nov 18, 2026
Merged

yifanxuaaa merged 1 commit into
layerfs_v2_0_0from
claude/store-compact

Conversation

@yifanxuaaa

Copy link
Copy Markdown
Contributor

Adds Compact to a Store's menu on the Stores tab, as a job that shows its steps and what it freed.

Depends on Ephemeral-AI-Lab/layerfs#735 for the step-by-step progress. Without it the plugin still works:

  • A runtime with no store.compact (the one installed today, 2.0.0-cc7be6ab0f70): the menu item is hidden, and the route refuses with Unsupported.
  • A runtime with store.compact but no on_progress: the job runs and shows its result, without steps.

What changes

  • Host: POST /api/stores/:name/compact starts a compact job. The host reads the pinned CLI's call table to learn whether store.compact exists and whether it declares on_progress, and passes the option only when declared. The job carries its named steps: mark, build, verify, install for SQLite and mark, build, swap, cleanup for PostgreSQL.
  • Client: the Store menu gains Compact (SQLite and PostgreSQL), behind a plain confirm dialog. It is disabled with a reason when a SQLite Store is outside the home or the Store is not idle. The job row reads "Compacting · Step 2 of 4 · building", then "Compacted · freed 121 MB" or "nothing to reclaim". English and Chinese strings added.
  • Spec: docs/specs/homes.md names compact jobs.

17 files, +257 −25.

Checks

  • New tests: a compact job over a fake SDK in test/routes.test.mjs, the job wording and steps in test/storage-jobs-model.test.mjs, a gate rule for store.compact in test/call-table.test.mjs, and the four GC calls classified as writes in test/logs-classify.test.mjs.
  • In the browser, on a private side server (its own DSH_LAYERFS_DEV_DIR, a LayerFS CLI built from the branch in the pull request above): a 526 MB SQLite Store with one deleted project showed "Step 1 of 4 · marking", "Step 2 of 4 · building", then "Compacted · freed 121 MB". A second run showed "nothing to reclaim".

Not checked

  • A PostgreSQL Store, a failed run and the disabled "not idle" menu row were not seen in the browser (the tests cover the wording).
  • Not run on 3080. That needs a runtime rebuilt from LayerFS with the pull request above, this branch in the linked checkout, and a restart coordinated with running agents.
  • logs-classify "every pinned CLI call is classified as its kind" fails on home.init. It fails the same way on layerfs_v2_0_0 without this change and is left alone here.

🤖 Generated with Claude Code

A Store's ⋯ menu gets Compact… (SQLite and PostgreSQL). It asks first, then
runs LayerFS store.compact as a storage job, like push and backup: the job
panel shows "Compacting <store> · Step 2 of 4 · building" from the call's
on_progress events and ends with "freed 121 MB" or "nothing to reclaim".

Host
- POST /api/stores/:name/compact starts the job (storage.compact). One
  attempt: nothing here runs it again; Retry is a new run the person starts.
- The job names its steps before the run, by Store family (mark, build,
  verify, install; PostgreSQL: mark, build, swap, cleanup), so the step
  count is right from the first event.
- A runtime without store.compact: the view says compact: false, the menu
  row is not drawn and the route refuses Unsupported before any call. A
  runtime whose store.compact takes no on_progress runs the job without
  steps.
- A compaction's failure keeps the SDK's own code; the transfer rule
  "stopped in install means unknown" does not apply to it.

Client
- The row is disabled with its reason for a SQLite Store on another machine
  (LayerFS compacts a file only where it is) and for a Store that is not
  idle.
- The confirm dialog can be plain: Compact removes nothing, so its button
  is not the danger one.
- stepsOf keeps a job's named steps in order; jobs that name none (push,
  pull, move, backup, restore) are unchanged.

Tests: routes.test.mjs (the job over a fake SDK: steps, phases, report,
PostgreSQL steps, a refusal, no on_progress, no store.compact), the new
storage-jobs-model.test.mjs (steps, words, where it may start),
call-table.test.mjs (store.compact is gated), logs-classify.test.mjs (the
four GC calls are writes).

Checked on a side server (port 3097, private home, LayerFS built from
d74c015894): a 526 MB Store with one deleted project went marking,
building, then "freed 121 MB" and 405 MB; a second run said "nothing to
reclaim". Not checked in the browser: a PostgreSQL Store, a failed run and
the disabled row. Not on 3080: its runtime has no store.compact yet.

node --test test/*.test.mjs: 693 tests, 691 pass, 1 fail, 1 skipped. The
failure, "every pinned CLI call is classified as its kind" (home.init),
also fails on layerfs_v2_0_0 at dd444cf.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yifanxuaaa
yifanxuaaa merged commit a9aaaea into layerfs_v2_0_0 Nov 18, 2026
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