statedir

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 7 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 statedir is codex-router's state dir, $XDG_STATE_HOME/codex-router (else ~/.local/state/codex-router): where it is, the privacy rule for its dirs, the layout of a home's stage 2 dir in it, and atomic file writes. Setup writes a home's dir, the edge and the brain read it, and all three must agree on its layout and its check.

Index

Constants

View Source
const (
	PortFile  = "port"
	TokenFile = "token"
)

Files in a home's dir: setup writes the provider port and token, the edge reads them.

Variables

This section is empty.

Functions

func CheckHome

func CheckHome(app, dir string) error

CheckHome checks that the home dir at dir and its parents up to app are private (CheckPrivate): whoever can write there can swap the token or take the link socket.

func CheckPrivate

func CheckPrivate(dir string) error

CheckPrivate accepts a real directory (not a symlink) owned by this user with no group or other access.

func Dir

func Dir(getenv func(string) string) (string, error)

Dir returns codex-router's state dir, $XDG_STATE_HOME/codex-router, else ~/.local/state/codex-router. Relative values are ignored. It creates nothing.

func HomeDir

func HomeDir(app, homeID string) string

HomeDir is the stage 2 dir of a home, <app>/homes/<home id>/, where app is codex-router's state dir (Dir).

func ReadPort

func ReadPort(dir string) (int, error)

ReadPort reads the provider port setup stored in the home dir at dir.

func WriteAtomic

func WriteAtomic(dir, name string, data []byte) error

WriteAtomic replaces dir/name with data through a temp file (0600) and a rename, so a reader sees the old file or the new one, never a part. The temp file's name starts with a dot.

Types

This section is empty.

Jump to

Keyboard shortcuts

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