Documentation
¶
Overview ¶
Package sessionpark stores a complete, durable checkpoint for a parked WB session. It deliberately contains no Git mutation or transport logic.
Index ¶
- Constants
- func EncodeBundle(bundle Bundle) ([]byte, error)
- func EncodeEnvelope(envelope Envelope) ([]byte, error)
- func EncodeReceipt(receipt Receipt) ([]byte, error)
- func EqualBundle(a, b Bundle) bool
- func LaunchAuthority(request RemoteRequest, digest sessionmove.Digest, continuationPath string, ...) (sessionauthority.Launch, error)
- func LocalLaunchAuthority(bundle Bundle, digest sessionmove.Digest, continuationPath string, ...) (sessionauthority.Launch, error)
- func MemberPin(resumeID, memberID string) string
- func NewID() (string, error)
- func ReceiptSession(receipt Receipt) session.Record
- func RequestedRuntimeModel(request RemoteRequest) (string, string)
- func TargetWorkLogClaimID(digest sessionmove.Digest, ...) (string, error)
- func TargetWorkLogReference(request RemoteRequest, digest sessionmove.Digest, member RemoteMember) (string, error)
- func ValidateReceipt(receipt Receipt, request RemoteRequest, digest sessionmove.Digest) error
- type Bundle
- type Envelope
- type Event
- type Receipt
- type ReceiptMember
- type RemoteAdmission
- type RemoteMember
- type RemoteRequest
- type ResumeRoute
- type SourceLock
- type State
- type Status
- type Store
- func (s Store) Acquire(ctx context.Context, id string) (*SourceLock, error)
- func (s Store) ContinuationPathUnderLock(lock *SourceLock) (string, error)
- func (s Store) Create(bundle Bundle) (Bundle, error)
- func (s Store) EnsureLocalSuccessorContextUnderLock(lock *SourceLock) (string, []byte, error)
- func (s Store) ExistingLocalLaunchRootUnderLock(lock *SourceLock) (string, bool, error)
- func (s Store) FinalizeRemoteUnderLock(lock *SourceLock, admission RemoteAdmission, now time.Time) (State, error)
- func (s Store) FindBySource(wbSessionID string) (Bundle, bool, error)
- func (s Store) Load(id string) (State, error)
- func (s Store) LoadLocalSuccessorContextUnderLock(lock *SourceLock) (string, []byte, bool, error)
- func (s Store) LoadRemoteReceiptUnderLock(lock *SourceLock, admission RemoteAdmission) (*Receipt, error)
- func (s Store) LoadUnderLock(lock *SourceLock) (State, error)
- func (s Store) LocalLaunchRootUnderLock(lock *SourceLock) (string, error)
- func (s Store) PrepareLocalUnderLock(lock *SourceLock, now time.Time) (ResumeRoute, bool, error)
- func (s Store) PrepareRemoteUnderLock(lock *SourceLock, target, requestedHarness, courier string, ...) (RemoteAdmission, error)
- func (s Store) Resume(id string, successor session.Record, now time.Time) (State, error)
- func (s Store) ResumeUnderLock(lock *SourceLock, successor session.Record, now time.Time) (State, error)
- func (s Store) SaveRemoteReceiptUnderLock(lock *SourceLock, admission RemoteAdmission, receipt Receipt) error
- type TargetAdmission
- type TargetEvent
- type TargetLock
- type TargetStore
- func (store TargetStore) Acquire(ctx context.Context, resumeID string, digest sessionmove.Digest) (*TargetLock, error)
- func (store TargetStore) Admit(raw []byte) (TargetAdmission, error)
- func (store TargetStore) AppendEventUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest, ...) (TargetEvent, error)
- func (store TargetStore) EnsureSuccessorContextUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest, ...) (string, []byte, error)
- func (store TargetStore) EventsUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest) ([]TargetEvent, error)
- func (store TargetStore) LoadReceiptUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest) (*Receipt, error)
- func (store TargetStore) SaveReceiptUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest, ...) (Receipt, bool, error)
- type Worktree
Constants ¶
const ( EnvelopeSchemaVersion = 1 RequestSchemaVersion = 1 ReceiptSchemaVersion = 1 EnvelopeKind = "session_park_resume" MaxEnvelopeBytes = 1 << 20 MaxMembers = 32 MaxFieldBytes = 4096 TargetDirName = "park-resumes" EnvelopeFileName = "envelope.json" ContinuationFileName = "continuation.md" SuccessorContextFileName = "successor-context.md" MaxSuccessorContextBytes = 256 << 10 )
const ( SchemaVersion = 1 MaxContinuationBytes = 64 << 10 MaxBundleBytes = 4 << 20 SourceDirName = "parked-sessions" BundleFileName = "bundle.json" LocalNeutralDirName = "local-resume-root" )
const ( ResumeRouteLocal = "local" ResumeRouteRemote = "remote" )
Variables ¶
This section is empty.
Functions ¶
func EncodeBundle ¶
func EncodeEnvelope ¶
func EncodeReceipt ¶
func EqualBundle ¶
func LaunchAuthority ¶
func LaunchAuthority(request RemoteRequest, digest sessionmove.Digest, continuationPath string, continuation []byte) (sessionauthority.Launch, error)
func LocalLaunchAuthority ¶
func LocalLaunchAuthority(bundle Bundle, digest sessionmove.Digest, continuationPath string, continuation []byte) (sessionauthority.Launch, error)
func ReceiptSession ¶
func RequestedRuntimeModel ¶
func RequestedRuntimeModel(request RemoteRequest) (string, string)
func TargetWorkLogClaimID ¶
func TargetWorkLogClaimID(digest sessionmove.Digest, successorID, memberID, repository, sourceClaimID string) (string, error)
TargetWorkLogClaimID binds one member's target claim to the exact parked envelope, successor, repository, and source claim. It is shared with the Work Log corroborator so the prepared claim is independently reproducible.
func TargetWorkLogReference ¶
func TargetWorkLogReference(request RemoteRequest, digest sessionmove.Digest, member RemoteMember) (string, error)
func ValidateReceipt ¶
func ValidateReceipt(receipt Receipt, request RemoteRequest, digest sessionmove.Digest) error
Types ¶
type Bundle ¶
type Bundle struct {
SchemaVersion int `json:"schema_version"`
ParkedSessionID string `json:"parked_session_id"`
Source session.Record `json:"source"`
Continuation string `json:"continuation"`
Worktrees []Worktree `json:"worktrees"`
ParkedAt time.Time `json:"parked_at"`
}
func DecodeBundle ¶
type Envelope ¶
type Envelope struct {
SchemaVersion int `json:"schema_version"`
Kind string `json:"kind"`
Request RemoteRequest `json:"request"`
}
func DecodeEnvelope ¶
type Event ¶
type Event struct {
SchemaVersion int `json:"schema_version"`
Sequence uint64 `json:"sequence"`
Type string `json:"type"`
At time.Time `json:"at"`
Successor *session.Record `json:"successor,omitempty"`
RemoteResumeID string `json:"remote_resume_id,omitempty"`
RequestDigest sessionmove.Digest `json:"request_digest,omitempty"`
TargetMachine string `json:"target_machine,omitempty"`
}
type Receipt ¶
type Receipt struct {
SchemaVersion int `json:"schema_version"`
ResumeID string `json:"resume_id"`
RequestDigest sessionmove.Digest `json:"request_digest"`
ParkedSessionID string `json:"parked_session_id"`
SuccessorWBSessionID string `json:"successor_wb_session_id"`
PredecessorWBSessionID string `json:"predecessor_wb_session_id"`
TargetMachine string `json:"target_machine"`
TmuxName string `json:"tmux_name"`
Runtime string `json:"runtime"`
Model string `json:"model,omitempty"`
NativeHarnessID string `json:"native_harness_id,omitempty"`
AttemptID string `json:"attempt_id"`
AttemptIndex uint64 `json:"attempt_index"`
PID int `json:"pid"`
StartedAt time.Time `json:"started_at"`
Members []ReceiptMember `json:"members"`
}
func DecodeReceipt ¶
type ReceiptMember ¶
type RemoteAdmission ¶
type RemoteAdmission struct {
Envelope Envelope
Raw []byte
Digest sessionmove.Digest
Route ResumeRoute
Replay bool
}
type RemoteMember ¶
type RemoteRequest ¶
type RemoteRequest struct {
SchemaVersion int `json:"schema_version"`
ResumeID string `json:"resume_id"`
ParkedSessionID string `json:"parked_session_id"`
SuccessorWBSessionID string `json:"successor_wb_session_id"`
PredecessorWBSessionID string `json:"predecessor_wb_session_id"`
SourceMachine string `json:"source_machine"`
TargetMachine string `json:"target_machine"`
SourceRuntime string `json:"source_runtime"`
SourceModel string `json:"source_model,omitempty"`
RequestedHarness string `json:"requested_harness,omitempty"`
Continuation string `json:"continuation"`
Members []RemoteMember `json:"members"`
CreatedAt time.Time `json:"created_at"`
}
RemoteRequest is independent of sessionmove.Request schema v1. It carries one parked aggregate and every exact member needed for an atomic target reconstruction.
func BuildRemoteRequest ¶
func BuildRemoteRequest(bundle Bundle, target, requestedHarness string, now time.Time) RemoteRequest
type ResumeRoute ¶
type ResumeRoute struct {
SchemaVersion int `json:"schema_version"`
ParkedSessionID string `json:"parked_session_id"`
Mode string `json:"mode"`
TargetMachine string `json:"target_machine,omitempty"`
Courier string `json:"courier,omitempty"`
SSHHost string `json:"ssh_host,omitempty"`
SSHUser string `json:"ssh_user,omitempty"`
ClaimedAt time.Time `json:"claimed_at"`
}
func (ResumeRoute) SSHConfig ¶
func (route ResumeRoute) SSHConfig() (sessionmove.SSHConfig, error)
type SourceLock ¶
type SourceLock struct {
// contains filtered or unexported fields
}
func (*SourceLock) Bundle ¶
func (lock *SourceLock) Bundle() Bundle
func (*SourceLock) Close ¶
func (lock *SourceLock) Close() error
func (*SourceLock) HeldForSession ¶
func (lock *SourceLock) HeldForSession(storeRoot, parkID, digest string) bool
func (*SourceLock) RetainSessionDir ¶
func (lock *SourceLock) RetainSessionDir(storeRoot, parkID, digest string) (*os.File, error)
type Store ¶
type Store struct{ Root string }
func (Store) ContinuationPathUnderLock ¶
func (s Store) ContinuationPathUnderLock(lock *SourceLock) (string, error)
ContinuationPathUnderLock returns the deterministic private local-resume artifact only after re-reading it through the retained aggregate descriptor. Callers must pass it through WB_SESSION_CONTINUATION_FILE, never stdout or harness argv.
func (Store) EnsureLocalSuccessorContextUnderLock ¶
func (s Store) EnsureLocalSuccessorContextUnderLock(lock *SourceLock) (string, []byte, error)
EnsureLocalSuccessorContextUnderLock publishes the single private file read by a local successor. It binds the original continuation to every retained member path without copying or modifying worktree bytes.
func (Store) ExistingLocalLaunchRootUnderLock ¶
func (s Store) ExistingLocalLaunchRootUnderLock(lock *SourceLock) (string, bool, error)
func (Store) FinalizeRemoteUnderLock ¶
func (s Store) FinalizeRemoteUnderLock(lock *SourceLock, admission RemoteAdmission, now time.Time) (State, error)
func (Store) FindBySource ¶
FindBySource returns the existing aggregate for a source declaration. It is used to repair a crash between aggregate publication and lifecycle marking, so retry never allocates a second parked identity.
func (Store) LoadLocalSuccessorContextUnderLock ¶
func (Store) LoadRemoteReceiptUnderLock ¶
func (s Store) LoadRemoteReceiptUnderLock(lock *SourceLock, admission RemoteAdmission) (*Receipt, error)
func (Store) LoadUnderLock ¶
func (s Store) LoadUnderLock(lock *SourceLock) (State, error)
func (Store) LocalLaunchRootUnderLock ¶
func (s Store) LocalLaunchRootUnderLock(lock *SourceLock) (string, error)
LocalLaunchRootUnderLock returns the first exact retained member, or creates the deterministic aggregate-bound 0700 neutral root for a zero-member park.
func (Store) PrepareLocalUnderLock ¶
func (s Store) PrepareLocalUnderLock(lock *SourceLock, now time.Time) (ResumeRoute, bool, error)
PrepareLocalUnderLock durably selects the only permitted resume route before any local context, launch plan, or successor process can be created.
func (Store) PrepareRemoteUnderLock ¶
func (s Store) PrepareRemoteUnderLock(lock *SourceLock, target, requestedHarness, courier string, ssh sessionmove.SSHConfig, now time.Time) (RemoteAdmission, error)
func (Store) ResumeUnderLock ¶
func (Store) SaveRemoteReceiptUnderLock ¶
func (s Store) SaveRemoteReceiptUnderLock(lock *SourceLock, admission RemoteAdmission, receipt Receipt) error
SaveRemoteReceiptUnderLock is the source acknowledgement durability boundary. A crash after this write is repaired without courier redelivery.
type TargetAdmission ¶
type TargetAdmission struct {
Envelope Envelope
Digest sessionmove.Digest
Replay bool
Receipt *Receipt
}
type TargetEvent ¶
type TargetLock ¶
type TargetLock struct {
// contains filtered or unexported fields
}
func (*TargetLock) Close ¶
func (lock *TargetLock) Close() error
func (*TargetLock) Envelope ¶
func (lock *TargetLock) Envelope() Envelope
func (*TargetLock) HeldForSession ¶
func (lock *TargetLock) HeldForSession(expectedRoot, aggregateID, digest string) bool
func (*TargetLock) RetainSessionDir ¶
func (lock *TargetLock) RetainSessionDir(expectedRoot, aggregateID, digest string) (*os.File, error)
type TargetStore ¶
type TargetStore struct{ Root string }
func NewTargetStore ¶
func NewTargetStore(root string) TargetStore
func (TargetStore) Acquire ¶
func (store TargetStore) Acquire(ctx context.Context, resumeID string, digest sessionmove.Digest) (*TargetLock, error)
func (TargetStore) Admit ¶
func (store TargetStore) Admit(raw []byte) (TargetAdmission, error)
func (TargetStore) AppendEventUnderLock ¶
func (store TargetStore) AppendEventUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest, phase string, at time.Time) (TargetEvent, error)
func (TargetStore) EnsureSuccessorContextUnderLock ¶
func (store TargetStore) EnsureSuccessorContextUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest, members []ReceiptMember) (string, []byte, error)
EnsureSuccessorContextUnderLock publishes the one private continuation read by the launched harness. It contains the bounded source continuation plus every deterministic target member path, pin, and target Work Log reference; neither the bytes nor the path are returned by the public receiver result.
func (TargetStore) EventsUnderLock ¶
func (store TargetStore) EventsUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest) ([]TargetEvent, error)
func (TargetStore) LoadReceiptUnderLock ¶
func (store TargetStore) LoadReceiptUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest) (*Receipt, error)
func (TargetStore) SaveReceiptUnderLock ¶
func (store TargetStore) SaveReceiptUnderLock(lock *TargetLock, request RemoteRequest, digest sessionmove.Digest, receipt Receipt) (Receipt, bool, error)
type Worktree ¶
type Worktree struct {
Repository string `json:"repository"`
// RepositoryRemote is the credential-free canonical fetch URL captured at
// park time. Remote resume never rediscovers this mutable local setting.
RepositoryRemote string `json:"repository_remote,omitempty"`
CanonicalDir string `json:"canonical_dir,omitempty"`
WorktreeDir string `json:"worktree_dir"`
WorktreesRoot string `json:"worktrees_root,omitempty"`
Branch string `json:"branch"`
Head string `json:"head"`
Dirty bool `json:"dirty"`
Status string `json:"status,omitempty"`
RemoteHead string `json:"remote_head,omitempty"`
// WorkLogReference binds this member to the source session's exact active
// claim. OwnerEventID binds it to the precise source custody record, so a
// later sequential session cannot be mistaken for the parked owner.
WorkLogReference string `json:"work_log_reference,omitempty"`
OwnerEventID string `json:"owner_event_id,omitempty"`
}
Worktree is exact local evidence at park time. Dirty content is intentionally not captured; it remains in place for local resume and fails closed remotely.