Documentation
¶
Overview ¶
Package codexlaunch owns the per-launch secret that lets one codex process reach ccdad's local Codex proxy, and the evidence that says the launch is still running.
A launch is TWO files named after the same hash of the same secret:
<root>/codex/launches/<sha256hex>.lock 0 bytes, flocked for the launcher's life
<root>/codex/launches/<sha256hex>.json {"pin":…,"startedAt":…}
The lock is the liveness test, and AGE IS NEVER A CRITERION. A launcher that dies without cleaning up leaves both files behind; the next lookup takes the lock the dead process was holding, learns from that alone that nobody is there, and removes them. A codex session a user left open for a week keeps its lock and stays valid, which is exactly what an expiry would have broken.
The two lock modes are not interchangeable and the difference is measured rather than stylistic. The LAUNCHER takes an EXCLUSIVE lock and holds it for its child's whole life. Every PROBE takes a SHARED one, so that probes never contend with each other and a refused try-lock can only mean a launcher.
The secret is treated as public within the session: a same-uid process can read it out of the launcher's environment. What it authorises is one route on a loopback listener for one launch's pin or the serving account, and nothing else — no OAuth token is reachable through it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Lookup ¶
func Lookup(root, bearer string) (Record, LookupResult, error)
Lookup answers for one bearer.
It is safe to call from any number of goroutines at once, including about the same bearer, which is not a courtesy: the proxy calls it per request and the daemon's sweep calls it for every record on every tick.
Types ¶
type Launch ¶
type Launch struct {
// contains filtered or unexported fields
}
Launch is one live launch, held by the process that started codex.
func Create ¶
Create mints a secret, takes the lock and writes the record.
The returned Launch must be held for the child's whole life and closed after it exits: releasing the lock is what tells the proxy the launch is over.
type LookupResult ¶
type LookupResult int
LookupResult is what a bearer turned out to be.
const ( // Valid: the record exists and its launcher still holds the lock. Valid LookupResult = iota // Unknown: no record under this bearer's hash. Unknown // Dead: the record exists and nothing holds the lock, so the launcher is // gone. Lookup removes both files before returning it. Dead )
func (LookupResult) String ¶
func (r LookupResult) String() string
String names a result, so a failing test reads as a sentence rather than as an integer.
type Record ¶
type Record struct {
// Pin is the account uuid this launch is bound to, or "" for a launch that
// follows the serving pointer.
Pin string `json:"pin"`
// StartedAt is when the launcher created the record. It is informational:
// nothing reads it to decide whether a launch is alive.
StartedAt time.Time `json:"startedAt"`
}
Record is the document beside the lock.