Documentation
¶
Overview ¶
Package occupancy records the checkout each running host session started in, so a verb that writes records can tell when the main working tree it is about to write into is shared with another live session (iss-2610240859590333).
On 2026-10-24 a session filed an issue, an intent, an ADR and two regenerated indexes into a main checkout another live session was working in, folding the peer's untracked draft into the indexes. The rule that a concurrent session works in its own worktree held only as prose. The session-start hook now writes one marker per session under abcd's home, naming the checkout and the host process; a record-writing verb counts the markers for its checkout whose host is still running.
A marker is keyed on the host process, not on a heartbeat, so a session that ended without a SessionEnd hook (a crash, a killed terminal, a hook the host cut short) stops counting the moment its process is gone. One host runs one session at a time, so a new marker replaces any other under the same host (a /clear or a resume whose SessionEnd never ran), and each Note prunes every marker whose host has ended.
The folder is reached through one walk from home and every file through that descriptor, with the guards the session-name register has: a symlinked ~/.abcd.noindex or folder is refused, and a marker another account owns or can write is not read.
Index ¶
- func Check(home, root string, readTable func() (sessionname.Table, error)) error
- func CheckPath(home, path string, readTable func() (sessionname.Table, error)) error
- func Forget(home, sessionID string) error
- func Note(home, sessionID, checkout string, host sessionname.Host, tab sessionname.Table) error
- func ReadSessionOn(home string, host sessionname.Host) (string, error)
- func SessionOn(home string, host sessionname.Host) string
- type SharedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(home, root string, readTable func() (sessionname.Table, error)) error
Check is the one judgement every record writer makes before it writes into root (iss-2610240859590333): a *SharedError when root is a main working tree two or more live sessions work in, nil when it is a linked worktree or one session or none works there, and another error when the count could not be made, which the caller reports and writes past: a count it cannot make is not evidence that the checkout is shared.
func CheckPath ¶
func CheckPath(home, path string, readTable func() (sessionname.Table, error)) error
CheckPath is Check on the working tree a file at path would be written into, for a writer that names a file rather than a checkout: the hook on the host's own file tools. A path in no checkout is nil, and so is one in that tree's local tier: it is ignored and kept for that checkout alone, so a file written there lands in no peer's index, and the SCRATCH rule sends a linked worktree's handovers and helper scripts to the main checkout's.
A path is judged twice when its spelling and the kernel can disagree: as cleaned before it is resolved (how a writer that normalizes the path first reads it) and as written (how the kernel resolves a ".." after a symlink). Either reading landing in a shared main checkout outside its tier refuses the write, so no spelling opens the exemption.
func Note ¶
func Note(home, sessionID, checkout string, host sessionname.Host, tab sessionname.Table) error
Note records that the session sessionID, run by host, started in checkout, an absolute working-tree top. It replaces any earlier marker for the session, removes every other marker under the same host, and prunes those whose host tab no longer shows running.
func ReadSessionOn ¶ added in v0.16.2
func ReadSessionOn(home string, host sessionname.Host) (string, error)
ReadSessionOn is SessionOn for a caller that must know the difference: an error says the markers cannot be read, and "" with none says no marker names host.
Types ¶
type SharedError ¶
SharedError is Check's refusal: the main working tree a record would be written into is one Sessions live sessions work in.
func (*SharedError) Error ¶
func (e *SharedError) Error() string