Documentation
¶
Overview ¶
Package workspace implements the isolation protocol (ADR-0050): every eligible run carries a deterministic instruction telling the Provider to split its own workspace off with whatever version control the project uses, and to declare what it did.
This is the split protocol's shape reused (ADR-0023 / ADR-0028): the harness hands over material and writes down the answer; the judgment — whether to isolate, and how — belongs to the Provider, because it is a question about meaning (ADR-0011). tomobit holds no VCS vocabulary at all: the instruction never says "git", and Kind is a free string precisely so that closing it into an enum cannot smuggle one in.
What this package deliberately does NOT do is verify. tomobit cannot check that a path really is a worktree without learning git, so the ledger records that the Provider *said so*, never that it *is so* (ADR-0050 Decision 2, in the lineage of ADR-0010 Decision 2: 観測できないものを推測で埋めない).
Pure except for Dir's home lookup — recorded provider text pins the parsing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEcho = errors.New("workspace: the instruction's own example was echoed")
ErrEcho reports that the only candidate found was the instruction's own example quoted back. Callers treat it as "nothing was declared", not as a broken declaration — the run is ordinary and unremarkable.
Functions ¶
func Dir ¶
Dir is where this session's isolated workspace goes: ~/.tomobit/worktrees/<sid>. Under ~/.tomobit for the same reason facelock and presence live there — it is machine state beside the config, not something to grow inside somebody's repository (ADR-0050 Decision 4) — and keyed by sid so the ledger's `path` can be traced back to its session.
func Instruction ¶
Instruction appends the isolation protocol to prompt, naming dir as the place to build the workspace in.
tomobit picks the place rather than letting the Provider choose: a workspace made outside the run's permitted scope (ADR-0047 AddDirs) is one the Provider cannot write to. That is a constraint being mapped, not a judgment being made — the same distinction ADR-0028 Decision 4 drew when one terminal forced human subtasks to run sequentially.
The text says "version control this project uses", never "git". Which tool exists here is a fact about the project that the Provider can see and tomobit cannot.
Types ¶
type Declaration ¶
type Declaration struct {
Isolated bool
// Kind is free text ("git worktree", "jj workspace", …). Measured
// 2026-07-26: claude returned "git worktree" where the instruction's
// example showed a different spelling, which is exactly why this is not
// an enum.
Kind string
// Path is where the isolated workspace was made. Required when Isolated,
// since a declaration nobody can follow tells the human nothing about
// where their results are.
Path string
// Reason is why isolation was not possible. Only meaningful when the
// Provider declined.
Reason string
}
Declaration is what a Provider said about its workspace.
Isolated false is a normal answer, not a failure: a project with no version control, a submodule, an LFS checkout, or a run without permission to write outside its cwd genuinely cannot be split off. A protocol with no honest way to say so leaves a Provider two options — lie, or refuse the work (ADR-0050 Decision 2).
func Parse ¶
func Parse(text string) (*Declaration, error)
Parse reads text (a run's concatenated provider.output) for a declaration. Three outcomes keep "nothing was declared" apart from "something was declared but is broken" (ADR-0050 Decision 2 / ADR-0023 Decision 1's 警告して通常フロー続行 — never a silent fallback either way):
- (nil, nil): no marker anywhere, or only the example echoed back
- (nil, err): the marker is present but no legal declaration could be read
- (decl, nil): accepted
Both a fenced ```json block and bare JSON are read: providers are not guaranteed to fence their marker just because the instruction showed one.
func (Declaration) Payload ¶
func (d Declaration) Payload() map[string]any
Payload is the task.workspace event body (SCHEMA.md R4). Absent fields are omitted rather than written empty: the ledger says what was declared, and an empty `reason` on a successful isolation is not a fact about anything.