Skip to content

0.24.0: a workspace is a folder of repos; every other channel is a repo of its own - #59

Merged
samifouad merged 5 commits into
mainfrom
claude/workspace-repo-58
Nov 14, 2026
Merged

samifouad merged 5 commits into
mainfrom
claude/workspace-repo-58

Conversation

@samifouad

@samifouad samifouad commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

A workspace is now a folder of ordinary git repos that a person can open (issue #58, step 1 of the plan).

What changed

  • Folders. A new workspace's folder goes in ~/Gild/<name>/ by default. The create form has a "Change…" button for picking another place, and a taken name becomes " 2".
    • The folder is #general's repo, with a working tree. Every other channel is its own repo at channels/<name>/, and the main repo's .gitignore lists channels/.
    • gild.json at the root holds gild (format 1), id, name, org, and channels[]. Each channel entry has {id, name, topic, folder, remote: null}.
    • SQLite holds workspace_folders and channel_folders. Chat stays in SQLite only. (store/folders.rs)
  • Writes (records.rs): files go to disk, then gild makes one commit by the author, then writes git's index from the new tree. File stats come from disk for files gild just wrote; for unchanged files they're carried over from the old index. Proposals and rejections only touch refs. The product uses gix only (status and worktree-mutation features) and needs no git binary.
  • Changes made outside gild (watch.rs, records::check_outside):
    • A notify watcher on every workspace folder waits until things have been quiet for 400 ms (at most 3 s), then gild commits the changes as the person ("Edit outside gild: "), re-indexes, and emits gild://changed.
    • A scan at startup catches what changed while gild was closed. Gild also takes in outside edits before its own writes and approvals, so it never overwrites a person's unsaved change.
    • .git is ignored, and so is channels/ in the main repo.
    • A malformed .gild/*.json or gild.json is left uncommitted and shown as a plain error under the channel header. Symlinks are never followed.
  • Moving existing data (Store::ensure_folders, runs on every open):
    • Each <data>/channels/<id>.git is copied to <folder>/.git, set non-bare, and checked out.
    • Gild then checks that every ref matches, HEAD's tree matches, every reachable object is readable, and the folder is clean. Only then is the old repo moved into <data>/migrated-0.24/. It is kept, not deleted, in this release (after review). A channel that fails to move keeps its old repo where it is and shows the reason as a problem; gild still starts. Review fixes are listed in the PR comments.
    • Each step can run again, so an interrupted move finishes on the next launch. gild.json is committed on top of #general's history.
  • Show in Finder: clicking the workspace name in the sidebar opens a menu. The item is labelled "Show in Finder", "Show in Explorer" or "Show in file manager"; the label is picked by cfg, and the folder opens through the opener plugin's open_path.
  • Export/import:
    • Export drops history.git and adds workspace/: a copy of each repo's .git, with HEAD checked out. Uncommitted files on disk are never copied. export-viewer.html and the other files are unchanged.
    • Import takes an export with workspace/, an older export with history.git, or a workspace folder with gild.json. A workspace folder is opened where it is, keeping its ids unless they're already taken; missing channel folders start empty.
  • Version 0.24.0 in the same files as 0.23.0 (package.json, package-lock.json, Cargo.toml, Cargo.lock), and the README storage text is updated.
  • e2e smoke test:
    • It reads workspace_folder, then checks gild.json (channels and folders), that each channel has a .git, and that the doc saved in the app is on disk with the agent's edit.
    • It checks that the menu shows "Show in file manager". It doesn't click it, because CI has no file manager.
    • The export assertions now use workspace/…/.git.

Evidence (macOS, Intel iMac)

command result
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings (src-tauri) Finished dev profile, rc=0, no warnings
cargo clippy --locked --target wasm32-unknown-unknown --manifest-path src-tauri/addons/markdown/Cargo.toml -- -D warnings rc=0
cargo test --locked (src-tauri) test result: ok. 65 passed; 0 failed; 2 ignored
npm ci / npm run check / npm run build rc=0 / rc=0 / rc=0

Each command's output was logged to a file and its $? checked. The e2e test (ci/linux.sh app) needs a display and runs only in CI; I didn't run it here.

New tests, each of which checks the effect through gix and, when git is on PATH, also through git status --porcelain --untracked-files=all:

  • a_workspace_is_a_folder_of_repositories: layout, gild.json, .gitignore, "Front Desk 2", a picked parent folder.
  • every_write_leaves_the_folder_exactly_as_its_last_commit: after each kind of write (view, record add and update, doc, ACL, proposal, approve, reject, org rules, an add-on edit), the folder and index equal HEAD, and the file content on disk is checked.
  • files_changed_outside_gild_are_committed_as_the_person: changed, added and deleted files; author and message; a broken view.json stays uncommitted with a plain error; the startup scan; a pending edit is kept before gild writes; a symlink is refused.
  • a_file_saved_by_another_app_is_taken_in_while_gild_runs: the real watcher.
  • old_histories_move_into_the_workspace_folder_once:
    • The old-layout fixture has proposals, an approval, a rejected ref, and a channel with no history.
    • After the move, #student-intake's refs and HEAD tree are the same, and #general's history is unchanged with the gild.json commit on top.
    • Files are on disk, the folders are clean, the old repos are gone, and running it a second time changes nothing.
  • a_move_that_stopped_halfway_is_finished_next_time: the move is stopped after copy, after check, and after rename. The old repo is kept until it's checked, and the next open finishes the move.
  • a_workspace_folder_imports_where_it_is, an_export_from_before_0_24_still_imports, and the extended round-trip and link tests.

Revert proof

Each fix was reverted locally, the key tests re-run, and the fix restored:

  • No index sync after a commit: every_write_… fails with left: ["Added: .gild/view.json", "Not in the index: .gild/view.json"] right: [].
  • Import ignores gild.json: a_workspace_folder_imports_where_it_is fails with "This folder isn't a gild export or workspace…".
  • check_outside does nothing: files_changed_outside_… fails with assertion failed: store.check_outside(..), and the watcher test fails with the change was noticed: Timeout.
  • Migration doesn't copy: old_histories_… fails with left: [("HEAD", …)] right: [… refs/gild/rejected/p2 …, refs/heads/proposals/p3 …], and a_move_that_stopped_… fails as well.

Decisions to review

  • remote: null sits on each channel entry, as the issue's channel list has it, not at the top level. topic is in each entry too, so opening a cloned folder gets the topics back.
  • When import keeps gild.json's ids but the org differs, gild.json is rewritten in one "Update gild.json" commit. In the round-trip test, #general therefore gains exactly one commit on top of an otherwise identical history, and the test asserts exactly that.
  • gild.json is managed by gild: an outside edit to it is committed, then overwritten by gild's next update.
  • Repos that gild creates or moves get core.autocrlf=false, so files are written byte for byte on every OS. .DS_Store, Thumbs.db and desktop.ini go in .git/info/exclude, so no commit is needed. Folders opened in place keep their own config.
  • If a workspace's folder is gone, gild never recreates it empty: the channel shows "Put it back" and its index is kept.
  • The Files view hides root gild.json and .gitignore.
  • Windows device names (CON, nul, …) become "CON workspace" for a workspace folder and channels/_nul for a channel.

closes #58

-claude

…po of its own

The workspace's folder (~/Gild/<name> unless picked) is #general's repo, with
gild.json listing the workspace and channels; other channels are repos in
channels/<name>/, ignored by the main one. Every write is one commit and the
files and index match it. Files changed outside gild are committed as the
person (watcher with debounce, scan at startup); broken .gild/*.json is left
uncommitted with a plain error. Old bare repos move into folders on first
launch, checked before they are deleted, and an interrupted move finishes
next launch. Show in Finder/Explorer/file manager. Export copies the repos;
import also takes a workspace folder and opens it where it is.

closes #58
- Ids from gild.json and exports must have gild's own shape (22 hex
  digits), each once; an old history path only ever comes from such an id.
- No link on any path gild reads or writes in a folder; a channel folder is
  a real folder inside the workspace's, never a link, and not marked as
  another channel's. Repos gild makes or moves check links out as files.
- Two channels whose folders one file system would see as one (case,
  Unicode form) are never moved over each other; a folder already holding
  a repository that isn't this channel's own unfinished move is left alone.
- A channel that fails to move is its own visible problem; gild starts.
- Moved histories are checked object by object and the old ones are kept
  in migrated-0.24/, not deleted. Copy read errors are failures.
- A channel is placed and checked before its row is written, and forgotten
  if placing fails. A missing channel folder is a problem, never made
  again empty; only creating a channel makes a repository.
- gild doesn't write over a file changed on disk since it last looked, and
  a written file's details count only if it still holds gild's bytes.
- Files over 50 MB aren't taken in from outside; gild commits to its own
  branch (in .git/gild-branch and gild.json) and stops if another is
  checked out; an import is checked first and forgotten if it fails;
  COM¹-³/LPT¹-³ are reserved; read-only files are replaced on Windows.
@samifouad

Copy link
Copy Markdown
Member Author

I fixed everything the review found, in commit f4997ce on this branch. I didn't force-push. Each fix has a test that fails when the fix is reverted.

Fixes and their tests

  1. Ids become paths. Ids from gild.json and exports must have new_id's shape: 22 lower-case hex digits, each id used once. A legacy <id>.git path is only built for such an id. Gild also marks each repo with .git/gild-channel (the channel id) and refuses a folder marked for another channel.
    • Test: ids_from_a_file_never_become_paths. It covers ../, absolute and Windows paths, and uppercase hex in a gild.json, plus a '../decoy' row in SQLite whose target is left untouched.
  2. Writes follow symlinks. disk_path refuses any symlinked component, for reads and writes. safe_dir checks channels, channels/<name> and .git: none may be a link or a file, the canonicalized folder must be inside the canonicalized root, and the marker must match. repo(), in-place import and the export's workspace/ copy all go through it.
    • Repos gild makes or moves get core.symlinks=false, and checkout uses fs.symlink=false, so a committed link becomes a plain file holding its target.
    • Test: links_never_take_gild_out_of_the_folder (unix only). It covers a linked docs/, a linked channel folder, an in-place import with channels/quiet linked outside (refused, and the outside folder never gets a .git), and a linked channels/.
  3. Two channels map to one folder. Before any copy, gild compares channel folders by identity: NFC, lowercase, and ς→σ, ſ→s, ı→i, µ→μ (new dependency unicode-normalization, already in the lock). A move only writes into a missing or empty folder, or into this channel's own unfinished move (marker equals the id). New channels and imports go through the same check.
    • Test: two_channels_never_share_a_folder. It covers σ-notes and ς-notes, a folder already holding someone else's repo (left untouched, and the old history stays), and create_channel with ς-x.
  4. A migration failure stops gild starting. ensure_folders turns each channel's or workspace's failure into that channel's problem, and the app still starts. While a channel's old repo is still in data/channels/, repo() returns an error, so gild never reads, writes or re-indexes it.
    • Test: a_channel_that_fails_to_move_doesnt_stop_gild (an old repo with no objects).
  5. The old repo is deleted on too weak a check. I took the option you preferred: old bare repos are kept, renamed into <data>/migrated-0.24/<id>.git, and nothing is deleted in this release.
    • same_history now reads every object reachable from every ref, in both repos, and compares the counts. copy_dir treats a read error as a failure.
    • No fsync: with nothing deleted, losing a write can't lose history, because the old copy is still there.
    • Tests: a_copy_missing_an_object_is_never_taken_for_the_history, and assert_moved now checks the kept copies' refs.
  6. A failed channel create leaves a row behind. new_channel_folder checks the folder before the INSERT. If placing still fails, forget_channel removes the rows, and a failed workspace create forgets the workspace.
    • Test: a_channel_that_cant_be_made_leaves_nothing_behind. It also reopens the store and checks that the existing folder never became a repo.
  7. A missing channel folder is recreated empty. repo() now treats a missing or non-repo folder as a problem ("is gone. Put it back") for any channel, and catch_up skips it, so the index is kept. records::commit and propose only open existing repos. Only channel create, a first-time placement during migration, and import create a repo.
    • Test: a_missing_channel_folder_is_a_problem_not_a_fresh_start (the folder moved away and then back).
  8. Outside-edit races.
    • Before writing, unchanged_on_disk hashes each target on disk and compares it with its index entry. If they differ it refuses with "changed outside gild just now … Try again". approve checks the same way.
    • After writing, put_files keeps a file's stat only if the file still holds the bytes gild wrote.
    • Test: gild_never_writes_over_a_save_it_hasnt_seen. It calls records::commit directly over an unseen save, then checks that through the store the save goes in first as its own commit.
    • The stat check has no deterministic test: I can't reproduce that race without a hook inside the function.

Smaller ones:

  • Large files: files over 50 MB aren't taken in and show as a problem. Test: a_huge_file_isnt_taken_in (a sparse 50 MB + 1 byte file).
  • HEAD not pinned: gild now commits to the branch named in .git/gild-branch. That's the branch HEAD was on when gild first used the repo, refs/heads/main by default. It's also written to gild.json as branch, and import passes it through. All reads use that branch's tip. If HEAD is on another branch, writes, approvals and outside-edit scans stop with "Switch back (git checkout main)…". Test: gild_commits_to_its_branch_whatever_is_checked_out.
  • Partial import: ids, duplicate ids, branch names, folder identities and in-place folders are all checked before anything is written. A failure after that forgets every row written. Test: a_bad_import_leaves_nothing_behind (duplicate ids, and a damaged last history in an export).
  • Reserved names: COM¹–³ and LPT¹–³ are now covered. Test: folder_names.
  • Read-only files on Windows: copy_dir clears the read-only flag before replacing a file. This is behind cfg(windows), so no test runs here.

Revert proof

I reverted the fixes in two batches, re-ran the named tests, and restored the code.

  • Batch A: id shape, folder identity and marker, object walk, write guard, size cap, superscript reserved names.
    • ids_from…, two_channels…, a_copy_missing…, gild_never_writes…, a_huge_file… and folder_names all fail.
    • ids_from… fails with "holds another channel's history" because the marker caught it instead.
    • a_copy_missing… fails with unwrap_err() on Ok.
  • Batch B: symlink checks, per-channel move errors, the create-time folder check, no recreating, branch pin, import rollback.
    • links_never…, a_channel_that_fails_to_move…, a_channel_that_cant_be_made…, a_missing_channel_folder…, gild_commits_to_its_branch… and a_bad_import… all fail.
    • For example, a_channel_that_fails_to_move… fails with "gild starts: Moving #student-intake's history … didn't work", and a_bad_import… with "no half-imported workspace".

Gates (Intel iMac)

  • cargo clippy --locked --workspace --all-targets --all-features -- -D warnings: Finished, rc=0, no warnings.
  • wasm add-on clippy: rc=0.
  • cargo test --locked: 76 passed, 0 failed, 2 ignored.
  • npm ci, npm run check and npm run build: all rc=0.
  • clients::tests::codex_without_a_config_yet_gets_one failed once under heavy load. It's a client test unrelated to this PR, with a fixed timeout, and it passes when run alone.

-claude

…nges

- A copied history (migration, import, export) brings only objects, refs,
  packed-refs and HEAD; its config is written fresh by gild, so no
  core.worktree, filter driver, remote or credential comes along, and
  objects/info/alternates are dropped.
- Every repository is opened isolated (no global, system or environment
  git config) and refused, with a plain problem, when its own config sets
  core.worktree, filter.*, include/includeIf, hooks, fsmonitor, ssh, diff
  or merge drivers, when .git isn't a real folder, when it's a linked
  worktree, or when its files would be anywhere but its folder.
- A channel with no history starts with an empty repository only when its
  folder is first placed; a missing channel folder or workspace folder is
  never made again, however the migration of other channels is going.
- One channel gild can't read is that channel's problem at start, not a
  reason gild won't start.
- Commits, pulls and checkouts made with git are noticed (.git/HEAD and
  refs events, and the scan) and indexed; saving or approving over a
  history that moved since gild indexed it is refused: try again.
@samifouad

Copy link
Copy Markdown
Member Author

This fixes all five findings from the second review, in e6e7cec on this branch, with no force-push. Each fix has a test that fails without it.

Fixes and their tests

  1. CRITICAL: an imported or copied repo could write anywhere and run commands.

    • What I fixed:
      • copy_repo copies only objects/, refs/, packed-refs and a checked HEAD (a branch name or a commit id). It drops objects/info/alternates and http-alternates. It never copies the source config, config.worktree or hooks.
      • The copy gets a config gild writes from scratch (fresh_config), with the file system probed the way git init does. Migration, import and export all go through copy_repo.
      • Every repo gild opens goes through open, which:
        • uses gix::open::Options::isolated(), so no global, system or environment git config is read, and no includes are followed;
        • refuses a .git that isn't a real folder (a link or a gitdir: file), and refuses linked worktrees (commondir);
        • refuses the repo with a plain problem when its own config or config.worktree sets core.worktree, filter.*, include*, core.{fsmonitor,hooksPath,sshCommand,gitProxy,askPass}, diff.external, diff.*.textconv or merge.*.driver;
        • checks repo.workdir() against the expected folder after every open.
      • In-place import runs the same check on every channel before it writes anything.
    • Which keys gix 0.90 actually acts on: core.worktree (open/repository.rs) and filter.<driver>.{clean,smudge,process} (through gix-filter, chosen by .gitattributes). Includes would be acted on too, but isolated mode turns them off. The other keys are refused because git itself would run them later.
    • Test: a_hostile_history_writes_nothing_outside_and_runs_nothing. It uses an export whose repo has core.worktree=<victim>, a filter driver that runs touch <marker> (with required = true), a * filter=evil .gitattributes, a remote with a password, a credential helper and alternates.
      • Import, save and scan write nothing to the victim folder, the marker never appears, and the imported config has none of those keys.
      • Opening the same settings in place is refused with "…core.worktree, which could make git write outside the folder…". A folder gild already tracks stops with that problem.
      • With the fix reverted, gix really ran the command: /bin/sh -c "touch …/ran" with GIT_WORK_TREE=<victim>, and the marker file was created.
  2. HIGH: a missing folder was re-created while another channel's move was stuck. moving is gone.

    • A channel gets an empty repo only when all of these hold: its folder row is new in this run, it has no old repo in channels/ or migrated-0.24/, and the folder is checked first.
    • A missing workspace root is never re-created.
    • Test: a_missing_folder_stays_missing_while_another_move_is_stuck. One channel is stuck. A moved channel's folder, then the whole workspace folder, is removed. Both show "is gone. Put it back", the index is kept, and nothing is re-created.
  3. MEDIUM: one unreadable channel stopped gild from starting. catch_up handles each channel on its own, and a failure becomes that channel's problem.

    • Test: a_channel_gild_cant_read_doesnt_stop_gild. It commits a broken .gild/view.json with git directly. Gild still opens, the channel shows the problem, and the other channels work.
  4. MEDIUM: changes made with git weren't noticed while gild ran.

    • check_outside now re-indexes whenever HEAD differs from the indexed commit.
    • The watcher passes through .git/HEAD, .git/packed-refs and .git/refs/** events (debounced), and channel_at maps them to their repo.
    • Writes and approvals refuse when the history moved since it was indexed: "This channel changed outside gild just now… Try again." The index catches up at the same time.
    • The manifest write catches up first, because it's built from SQLite, not from what's on screen.
    • Tests:
      • changes_made_with_git_are_taken_in: a save over an unseen pull is refused, then the scan indexes the pull.
      • a_commit_made_with_git_is_taken_in_while_gild_runs: a commit written with gix that touches only .git is noticed by the watcher.
  5. LOW: an export copied .git/config as it was. Fix 1 covers this, since exports use copy_repo.

    • Test: an_export_carries_no_remote_or_credentials. The source repos have a remote with a password and a credential helper. The export's configs have neither.

Revert proof

I reverted all five fixes in one build (whole-dir copy and the old config handling, plain gix::open with no checks, the old moving and root re-creation, catch_up using ?, and no catch-up or .git events), then ran the six tests. All six failed:

  • a_hostile_history…: the filter process ran.
  • an_export_carries…: the config was copied as it was.
  • a_missing_folder…: there was no problem, and the folder was re-made.
  • a_channel_gild_cant_read…: gild failed to start with reading .gild/view.json: key must be a string.
  • changes_made_with_git…: the stale save went through.
  • The watcher test timed out.

Then I restored the fixes.

Gates (Intel iMac)

  • cargo clippy --locked --workspace --all-targets --all-features -- -D warnings: Finished, rc=0, no warnings.
  • cargo test --locked: 82 passed, 0 failed, 2 ignored.
  • npm ci, npm run check and npm run build: all rc=0.
  • The markdown add-on wasm clippy is unchanged since the last round (rc=0).

-claude

- A channel's folder must have files: core.bare = true is refused, and a
  repository with a .git but no work tree is never used (only the bare
  repositories from before 0.24 are opened without one, to move them).
- A folder opened in place that borrows objects (objects/info/alternates)
  or holds a hook git would run (anything in .git/hooks but *.sample and
  gitoxide's docs.url) is refused, naming the file.
- README lists exactly what is refused.
@samifouad

Copy link
Copy Markdown
Member Author

The two remaining items are fixed in 74abefa. Each has a test that fails without its fix.

  1. A folder set up bare.
    • For any repo with a .git (every channel folder), gild now refuses core.bare = true in unsafe_setting. gild also never uses the repo if gix opens it without a work tree.
    • Only the bare repos kept from before 0.24 open without one, so they can be moved.
    • Test: a_folder_set_up_bare_is_refused. In-place import is refused naming core.bare, and nothing is imported. A folder gild already tracks stops: the scan and saves fail with that problem.
  2. Alternates and hooks in a folder opened in place.
    • A folder is refused when it has .git/objects/info/alternates or http-alternates.
    • It is also refused when .git/hooks/ holds anything other than *.sample files or docs.url. docs.url is the file gitoxide's init writes, and git never runs it. The problem names the file and says to delete it and try again.
    • Test: a_folder_with_hooks_or_borrowed_history_is_refused. A post-checkout hook is refused by name, and the folder opens once only the samples are left. An alternates file is refused by name.
    • The README now lists exactly what is refused.

Revert proof: with the bare, alternates and hooks checks turned off, both tests fail with unwrap_err() on an Ok value. That means the folder was imported when it should have been refused.

Gates:

  • clippy with -D warnings: rc=0.
  • cargo test --locked: 84 passed, 0 failed, 2 ignored.
  • npm ci, npm run check and npm run build: all rc=0.

-claude

@samifouad
samifouad merged commit dd7b026 into main Nov 14, 2026
3 checks passed
@samifouad
samifouad deleted the claude/workspace-repo-58 branch November 14, 2026 06:08
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.

A workspace is a repo; every other channel is a repo of its own

1 participant