Recover incomplete session exports through durable runtime jobs
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
)
|
||||
@@ -17,6 +18,10 @@ import (
|
||||
// repairSessionExport is runtime-owned and read-only to OpenCode. It never
|
||||
// resumes a session, runs a stage, changes a definition, or overwrites evidence.
|
||||
func (r *runner) repairSessionExport(ctx context.Context, id int64, sequence int) (*protocol.RunDetail, error) {
|
||||
return r.repairSessionExportOwned(ctx, id, sequence, nil)
|
||||
}
|
||||
|
||||
func (r *runner) repairSessionExportOwned(ctx context.Context, id int64, sequence int, expected *pipeline.SessionOwner) (*protocol.RunDetail, error) {
|
||||
r.exportRepairMu.Lock()
|
||||
defer r.exportRepairMu.Unlock()
|
||||
if id <= 0 || sequence <= 0 {
|
||||
@@ -52,6 +57,9 @@ func (r *runner) repairSessionExport(ctx context.Context, id int64, sequence int
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("exact original session ownership metadata unavailable: %w", err)
|
||||
}
|
||||
if expected != nil && (owner.ID != expected.ID || owner.Backend != expected.Backend || owner.Directory != expected.Directory || owner.Reference != expected.Reference) {
|
||||
return nil, fmt.Errorf("original session ownership differs from durable recovery snapshot; export refused")
|
||||
}
|
||||
active, err := r.store.ActiveSessionOwners(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user