Repository navigation
feat(workspace): work in progress under refs/chant/wip/<branch>, replicated under a box's replicate policy - #3408
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work in progress on a box (uncommitted records, work branches under chant/work/, kept attempts under refs/chant/kept/) lived only on the box's disk until someone committed and pushed. This gives chant one ref namespace for it and a replication policy in the spec, as lex00 decided (E4): refs/chant/wip/, owned by chant, which hud's turn checkpoints (hud#137) and studio's checkpoints and push-work-off-the-box (studio#53, studio#289) use instead of refs/hud/checkpoints and refs/chaff/checkpoints.
The ref layout. refs/chant/wip/ is a chain of snapshot commits. Each snapshot's tree is the whole working tree (staged, unstaged and untracked; ignored files left out), written through a temporary index so the checkout's index, HEAD and branch never move. Its first parent is the previous snapshot and its last parent is HEAD, so pushing the ref carries the branch's commits. Chant-Wip-Branch, -Head, -Kind (save or pre-restore), -Label and -By trailers carry the metadata. The branch already separates worktrees and tabs, so there is no identity path segment; who took a snapshot is a trailer. What reached a remote is recorded under refs/chant/replica//, so reads report replication without fetching.
The policy. A box block takes replicate { remote, refs, on, every }: the git remote by name (origin by default; the host adds a mirror with its credential, since a box holds none), which refs go (work, kept, wip, ledger; all by default), when chant pushes on its own (after wip save, after a work lease release; both by default), and an interval for the host's own scheduler. At most one box block declares it. Pushes are per ref under the same name, never forced, with no pre-push hook and no prompt. A record write never pushes, because chant's record writes never run git (ws-074).
Commands. chant workspace wip [--branch] --json lists snapshots and replication state (new read-contract document wip.schema.json, added to READ_CONTRACT_COMMANDS). wip save [--label] [--by], wip restore [] [--by], wip push and wip fetch print wip-write.schema.json. restore takes a pre-restore snapshot first, so a restore is undoable, and resets the index to HEAD so everything restored reads as uncommitted. status --json prints the policy under each member's box and a top-level replication with replicated and ahead per ref. work release and an executor's lease release push when the policy says so. Seven new reason codes (wip-*). The writer conformance script gains wip save and wip restore steps, with readWip for facts and read-back.
Decision record ws-085 records the namespace and policy. Docs: a new cli/workspace-wip page, the declaration's Replicate section, the read contract, writer conformance, the status page and the boundary roster.
Shared files touched: declaration.ts and declaration.schema.json (box.replicate), status.ts and status.schema.json, reason-codes.ts, cli/main.ts and registry.ts, conformance/index.ts and writer.ts, op/work-lease-run.ts and work-cli.ts (push on release), docs/data/boundary.yaml and boundary.mdx, decisions README, the prose-lint baseline.
Verified with core tsc, targeted unit tests (wip.test.ts covers a box destroyed mid-work: a fresh clone runs wip fetch, checks out the work branch and wip restore brings back the uncommitted record, the edited file and the kept attempt), the boundary roster, reason-code and CLI parse tests, the docs prose lint and docs-check. The unit suite and the conformance e2e run in CI.
Closes #3172