#+TITLE: cell decisions * why "cell" A cell is both bounded and generative: a self-contained sandbox an agent can't escape, and a unit of a larger organism that grows by accumulating them. Each cell buds off =main=, works in isolation, and pushes back, so the whole evolves. * the convention: one shared bare repo, per-cell checkouts A =.cell= directory holds a single bare git repo, =default.git=, and each cell is its own colocated jj checkout of it (=jj git clone --colocate=). The tool just encodes this convention; how the checkouts are used is a higher-level concern and out of scope. * discover the cell dir as the nearest ancestor holding =.cell= =cell= takes only a name and walks up from the current directory to the nearest ancestor that holds a =.cell= directory, creating =.jj= inside it. Nothing is hard-coded and no source argument is needed. ** why a hidden =.cell=, not a visible sibling A plain visible sibling would risk colliding with directories projects already keep (this repo has =default.jj/cells=), forcing a =default.git= guard and self-or-child matching to disambiguate. A hidden, distinctive =.cell= has no such collision, so detection collapses to a plain containment check and works from anywhere in the tree below it (e.g. =~/lab/default.jj/src= finds =~/lab/.cell=). * each cell is its own colocated clone Cloning =default.git= gives each cell its own git+jj store with =default.git= wired as =origin=. A shared workspace would couple the cells to one store; independent clones keep them isolated and give each its own changesets, exchanged through the one bare repo. * subcommands: =init= seeds the bare repo, =new= starts a cell =cell init = bare-clones =src= into the shared =.cell/default.git=; =cell new = clones that bare repo into a per-cell checkout. Splitting them keeps =new= a walk-up-and-clone with no source argument while giving a first command to lay down =.cell= in the first place. Usage errors exit 64. * =init= severs the clone from its source A clone records its source as =origin=. =init= removes it so the bare repo has no remaining relationship to the repo it was seeded from: that is the whole point, a repo the jail modifies that is disconnected from the real checkout. Cells then wire =origin= to this bare repo, not to the original. * =init= clones only the source's default branch =--single-branch= keeps =default.git= to the source's default branch alone. A full bare clone would copy every branch the source holds, and fetching from =default.git= would then duplicate those unrelated branches into each cell and back into the primary workspace, drowning the cell branches that matter. With single-branch the only other refs =default.git= ever gains are the ones cells push. * a cell pushes its work as one branch A cell never commits to =main=: it branches off =main=, commits on top, and pushes a branch named for the cell, ==, pointing at its head. * =new= rejects a name that collides with a =default.git= branch The cell name has to be unique among the branches in =default.git=, not just among local =.jj= checkouts. The checkouts alone do not enforce this: a cell can be pushed and its checkout removed, leaving the branch behind, after which the on-disk check would happily reuse the name. =new= thus checks =refs/heads/= in =default.git= before cloning. * =resume= is a separate subcommand, not a flag on =new= A pushed cell can lose its checkout, leaving only its branch in =default.git=; getting back to it is a distinct operation from budding a fresh cell, so it gets its own verb. Folding it into =new= as a flag or a collision fallback would make one command silently attach to existing work, so a mistyped name would land on another cell's branch instead of erroring. Separate verbs each carry one precondition — =new= needs the branch absent, =resume= needs it present — and fail loudly pointing at the other. * deferred: a =cell bookmark= command Setting the == bookmark is left to the in-cell workflow for now. A =cell bookmark= command might help, but its interface is unsettled; rather than guess, use the tool as-is and let real usage settle the design before building it.