Skip to content

fix(sidecar): adopt a non-empty non-git vault dir instead of failing to clone - #50

Merged
ExtraToast merged 1 commit into
mainfrom
feat/sidecar-adopt-nonempty-vault
Sep 10, 2026
Merged

ExtraToast merged 1 commit into
mainfrom
feat/sidecar-adopt-nonempty-vault

Conversation

@ExtraToast

Copy link
Copy Markdown
Contributor

fix(sidecar): adopt a non-empty non-git vault dir instead of failing to clone

On first boot the shared vault PVC is not empty: the Basic Memory app
initialises the vault tree into the PVC root before the git-sync sidecar
starts (they share one RWO volume, and Basic Memory owns the tree). The
sidecar's attach() used clone_from, which refuses a non-empty target with
"destination path '...' already exists and is not an empty directory",
crash-looping the pod.

Change attach() so that when the vault dir exists but is not a git repo, it
git init (which adopts an existing directory), adds the canonical origin,
fetches the branch and checks it out — mirroring a clone without requiring an
empty target, and without discarding anything already on the volume. This is
the correct behaviour for "Basic Memory owns the tree, the sidecar is its git
backstop", and matches the AC that a reschedule (fresh mount) must not lose
the notes.

New unit test reproduces the production shape (a secrets/ subdir already in
the vault root, as the vault-agent overlay or Basic Memory's own init leaves)
and asserts the sidecar attaches, keeps the existing dir, and has the origin.
13 tests pass (83% coverage), ruff + mypy clean.

…to clone

On first boot the shared vault PVC is not empty: the Basic Memory app
initialises the vault tree into the PVC root before the git-sync sidecar
starts (they share one RWO volume, and Basic Memory owns the tree). The
sidecar's attach() used clone_from, which refuses a non-empty target with
"destination path '...' already exists and is not an empty directory",
crash-looping the pod.

Change attach() so that when the vault dir exists but is not a git repo, it
`git init` (which adopts an existing directory), adds the canonical origin,
fetches the branch and checks it out — mirroring a clone without requiring an
empty target, and without discarding anything already on the volume. This is
the correct behaviour for "Basic Memory owns the tree, the sidecar is its git
backstop", and matches the AC that a reschedule (fresh mount) must not lose
the notes.

New unit test reproduces the production shape (a `secrets/` subdir already in
the vault root, as the vault-agent overlay or Basic Memory's own init leaves)
and asserts the sidecar attaches, keeps the existing dir, and has the origin.
13 tests pass (83% coverage), ruff + mypy clean.
@ExtraToast ExtraToast added type: bug Something is broken or behaving incorrectly. area: knowledge Knowledge base, recall, capture, or curation. component: api HTTP API, OpenAPI contract, or API client concern. priority: P1 High; important and should be handled in the current iteration. labels Sep 10, 2026
@ExtraToast
ExtraToast merged commit d933260 into main Sep 10, 2026
14 checks passed
@ExtraToast
ExtraToast deleted the feat/sidecar-adopt-nonempty-vault branch September 10, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: knowledge Knowledge base, recall, capture, or curation. component: api HTTP API, OpenAPI contract, or API client concern. priority: P1 High; important and should be handled in the current iteration. type: bug Something is broken or behaving incorrectly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant