Expand description
The pairing contract on disk: identity resolution, the pair record, the claim_file primitive
and the liveness sentinels (spec “Pairing contract”; files are pair.<pair-id>.* in the ctl home).
Structs§
- Identity
- Who this server is paired with.
sourceisFileonly when a record was read and parsed. - Record
pair.<id>.json.
Enums§
Functions§
- apply_
identity - Write the resolved identity into the environment snapshot and, for a
Fileidentity, the record’sserver_urlinto the settings:settings.server_url = identity.server_url(a null record means the background service, exactly as an emptyOPENCODE_CTL_SERVERdoes) with the sourceEnv, overriding a user-file value.EnvandNoneidentities (a missing or unparsable record yieldsNone) leave the settings untouched. A record URL carrying userinfo is ignored: the settings keep their current value and source, andenv.serveris cleared. - apply_
record_ server resumetalks to the server its pair was made for: the record’sserver_urlis applied to the settings exactly asapply_identityapplies a File identity (a null value is the background service, a URL with userinfo is ignored). A missing or unreadable record changes nothing;resumeitself reports that.- claim_
file - Create
pathwithcontentonly if it does not exist, complete from the first moment it is visible (temp +hard_link).Ok(false)whenpathalready exists. - delete_
pair_ files - Remove every file of one pair (
pair.<id>.*, including temp files and the lock). - ensure_
dir 🔒 - has_
userinfo 🔒 - invalid_
pair 🔒 - list_
records - Every parsable
pair.<id>.json, keyed on the FILE NAME’s id (seeread_record); an unparsable one is logged and skipped. - lock_
path 🔒 - open_
new 🔒 - parse_
record 🔒 - read_
record Ok(None)for a missing or unparsable record (the latter logged);IO_ERRORfor other read errors.- read_
sentinel - An absent, empty or unparsable file reads as
None. - record_
ids - The valid pair ids named by
pair.<id>.jsonFILE NAMES, sorted (whatever the file holds). - record_
path - replace_
file 🔒 - Temp + rename over
path. - resolve_
identity - Env vars first; only
OPENCODE_CTL_PAIRset means the record supplies the rest. Returns the identity and the startup warnings (logged by the caller). An invalid id leaves the server unpaired. - rewrite_
record - Rewrite only
generationandtab, under the pair’s lock, never lowering the generation. - temp_
sibling 🔒 - valid_
pair_ id ^[0-9a-f]{12}$.- write_
record_ new - write_
sentinel - write_
temp 🔒