occupancy

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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 Forget

func Forget(home, sessionID string) error

Forget removes the session's marker. A missing marker or folder is not an error.

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.

func SessionOn added in v0.16.2

func SessionOn(home string, host sessionname.Host) string

SessionOn is the session whose marker names host, "" when none does or the markers cannot be read: one host runs one session at a time.

Types

type PassedOver added in v0.17.0

type PassedOver struct {
	Count int
	First string
}

PassedOver is what a counted reading of the markers' folder passed over: how many files named as markers (ending in .json) it could not read as one, and the first of their names in byte order, cleaned for a terminal and bounded, "" where none was.

func ReadSessionOnCounted added in v0.17.0

func ReadSessionOnCounted(home string, host sessionname.Host) (session string, passed PassedOver, err error)

ReadSessionOnCounted is ReadSessionOn, saying also what marker files it passed over: a file in the markers' folder named as a marker that is not a regular file, fails a guard or its read, or does not parse as the marker its name says. Any of them may be the marker of the session on host, so a caller that must not take a marker it could not read for no session takes a count above zero as unsure. The count is of the whole folder, the session found or not, and First names one of them for the person to remove or repair.

type Session added in v0.17.0

type Session struct {
	ID       string
	Checkout string
}

Session is one running session as its marker names it: its id and the checkout it started in, symlinks resolved.

func Live added in v0.17.0

func Live(home string, readTable func() (sessionname.Table, error)) ([]Session, error)

Live is every session whose marker names a host still running, sorted by id: what a reader telling one session's work from another's needs (the away mode's stop check). The process table is read, through readTable, only when a marker is found, and nothing is written: a marker whose host has ended is left for the next Note to prune. An absent folder is none; markers that cannot be read, or a table that cannot, are an error.

type SharedError

type SharedError struct{ Sessions int }

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL