Expand description
Instant workspace provisioning (POST /api/workspace) — the D21
“productized provisioning” wedge feature.
A workspace is a copy-on-write clone of a per-repo template checkout
(APFS clonefile on macOS, --reflink=auto on Linux), so creation
cost is O(directory entries), not O(bytes). Each created workspace is
registered in the platform view with a node-signed operation, so
/api/view is the durable workspace inventory. Legacy requests use
SetWorkspaceHead; adapter-grade requests atomically create a stable
change binding at an exact revision.
The workspace’s origin is rewritten to the daemon’s own HTTP URL:
pushes from a workspace go through the sequenced smart-HTTP path,
never straight at the bare repo on disk.
§Why the template has maintenance switched off
The copy source is a real git repository, and git runs housekeeping
on its own initiative: a fetch or checkout can trigger auto-gc or
git maintenance run --auto, which creates and deletes files under
.git/objects — maintenance.lock and gc.pid among them. cp
walks a directory by stating entries and then opening them, so a file
that vanishes between those two steps is a hard error, and the caller
sees a 500 for a workspace that was never at fault. It was observed
once as a test flake (cp: …/.git/objects/maintenance.lock: No such file or directory) and is a real user-facing race, not a test
artifact.
So every git command this module runs against the template carries
gc.auto=0 and maintenance.auto=false, which turn both mechanisms
off (see the private TEMPLATE_CONFIG). The template is
a disposable internal artifact — re-fetched constantly, never served,
recreated by deleting it — so housekeeping buys nothing there and
costs a race. The alternative, tolerating ENOENT from cp, means
parsing a localized subprocess error to guess which vanished files
were harmless, and would leave the race in place.
Functions§
- archive_
workspace - Handles
POST /api/workspace/archive. The live checkout is moved to a recoverable same-filesystem archive before the durable view operation. A sequencing refusal restores the live path. - create_
workspace - Handles
POST /api/workspace; body{"repo": "owner/repo", "name": "<workspace>"}. Returns(status, json_body)like the rest of the platform API.base_urlis the daemon’s own address, used as the workspace’soriginso pushes stay on the sequenced path.