Monorepo for the nibling.run platform

Serve a project as a git remote #2

Open nibling.dev
targeting main from nmoo/git/remote
Open opened by and assigned to nibling.dev
targeting main from nmoo/git/remote

A nibling project becomes a git remote. Push sends a tree, fetch returns one commit, and history stays in the repo the project came from. This is the shared core; the SSH gateway's tab adapter and the api's HTTPS clone surface build on it next.

What's here #

  • Research on knotless.dev and Tangled as data models for projects, with the verdict to keep dev.nibling.project as a snapshot record (docs/research/project-data-model.md). The second half of that document is the spec for projects as git remotes and the git channel the SSH gateway hands an open tab.
  • Two optional record fields. #file.oid is the git blob id, so a remote can advertise the tree without downloading blobs; the SDK fills it on every save. source is { commit, tree?, ref?, remote? }, the commit the tree was last pushed from. files[] stays the complete tree.
  • @nibling/sdk/git-remote: snapshot derivation (a record as one deterministic commit), pack reading and writing, pkt-line, and servePack for git-receive-pack and git-upload-pack as explicit state machines over a byte channel. projectRemote() is the SDK's remote over the project store; a push uploads new blobs and saves with swapRecord, so a browser edit that lands mid-push is reported as ng refs/heads/main project changed, fetch first.
  • No Node-only imports in the core, so it runs in a tab and in a Worker.

Proof #

packages/sdk/tests/git-remote.test.ts drives real git 2.55.0 through a stand-in ssh script into servePack against the fake PDS: fresh clone, push, second push without a fetch, git pull fast-forwarding onto a browser edit, --depth 1 clone, a raced push, non-fast-forward, other branches and tags refused, ls-remote and dry-run. It also confirms git honors an advertised no-thin, with the counterfactual.

Decisions worth a look #

  • The pushed commit is served as main while source.tree still matches the record. A first draft stored the raw commit object in the record so a fresh SSH clone of a just-pushed project could succeed; that publishes the pusher's author email and message, so it was replaced with the tree oid. A fresh SSH clone in that state gets an ERR pointing at the HTTPS address, which is the documented clone path.
  • Git names its wants before its haves, so one advertisement serves every client. The record's commit is parented on source.commit; a fresh clone without that commit is told to --depth 1 or fetch the source, and git pull from the pushing clone fast-forwards.
  • A first push into a browser-made project needs a clone first. Git refuses on the client side otherwise.

Not in this PR #

The app adapter for the gateway's git channel (packages/app/src/ssh/attach.ts on nmoo/ssh/gateway), the api's dumb-HTTP clone surface, and publishing the changed lexicon.

examples/slopbox has one failing Playwright spec on main too (the catalog count); unrelated to this branch.

Commits 0