Honor remote session authoring updates after publication
This commit is contained in:
@@ -43,12 +43,15 @@ When `--session` is omitted, local search order is:
|
|||||||
2. `/etc/narratio/session.yml`
|
2. `/etc/narratio/session.yml`
|
||||||
|
|
||||||
If no local session exists and a `session_id` is known, Narratio loads the
|
If no local session exists and a `session_id` is known, Narratio loads the
|
||||||
session from configured object storage. It selects the prepared session in the
|
session from configured object storage. Downloaded session bytes are contextless
|
||||||
current committed run when available; if no current pointer exists or an older
|
snapshots, with remote object
|
||||||
commit has no prepared session, it falls back to the session-init `session.yml`
|
|
||||||
object. Downloaded session bytes are contextless snapshots, with remote object
|
|
||||||
provenance retained independently of locally materialized checksums.
|
provenance retained independently of locally materialized checksums.
|
||||||
|
|
||||||
|
Remote loading prefers an authored session-root `session.yml`, including updates
|
||||||
|
from `session init --remote --force`. When that object is absent, loading falls
|
||||||
|
back to the current commit's standalone prepared session. Published snapshots
|
||||||
|
remain immutable; restore validates the pointer-selected committed state.
|
||||||
|
|
||||||
### Read-only effective pipeline inspection
|
### Read-only effective pipeline inspection
|
||||||
|
|
||||||
`narratio config validate`, `narratio config show`, `narratio config sources`,
|
`narratio config validate`, `narratio config show`, `narratio config sources`,
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ remote verification live in `publish_transfer.go`; committed-manifest,
|
|||||||
immutable-commit, and current-pointer encoding and writes live in
|
immutable-commit, and current-pointer encoding and writes live in
|
||||||
`publish_commit.go`. `publish_output_plan.go` owns the deterministic, I/O-free
|
`publish_commit.go`. `publish_output_plan.go` owns the deterministic, I/O-free
|
||||||
five-outcome model and its secret-free metadata projection. Prepared input
|
five-outcome model and its secret-free metadata projection. Prepared input
|
||||||
objects are committed under the immutable run; remote session loading selects
|
objects are committed under the immutable run; the committed standalone session
|
||||||
the committed standalone session through the current pointer.
|
supports remote loading when no authored session override is available. The
|
||||||
|
[configuration reference](../config.md#sessionyml) owns input selection.
|
||||||
|
|
||||||
- when publishing or run upload is disabled, completes successfully with no
|
- when publishing or run upload is disabled, completes successfully with no
|
||||||
outputs and records explanatory metadata. This is not an explicit self-skip:
|
outputs and records explanatory metadata. This is not an explicit self-skip:
|
||||||
|
|||||||
@@ -189,6 +189,10 @@ configuration owner without adding remote companion retrieval.
|
|||||||
|
|
||||||
## 6. P2: Reconcile remote session updates with committed-session selection
|
## 6. P2: Reconcile remote session updates with committed-session selection
|
||||||
|
|
||||||
|
Status: Complete. Authored remote input takes precedence for later commands;
|
||||||
|
committed snapshots remain immutable fallback input and restore authority.
|
||||||
|
Publication/update regression coverage checks changed title and audio selection.
|
||||||
|
|
||||||
Stage: 7, interacting with the existing initializer and shared command loader
|
Stage: 7, interacting with the existing initializer and shared command loader
|
||||||
from Stages 2 and 4.
|
from Stages 2 and 4.
|
||||||
|
|
||||||
|
|||||||
@@ -192,23 +192,29 @@ func loadPipelineConfigWithDependencies(pipelineFlag string, opts config.Pipelin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func findRemoteSessionConfig(ctx context.Context, store storage.ObjectStore, sessionPrefix, remoteKey, campaign, sessionID string) (storage.ObjectInfo, string, error) {
|
func findRemoteSessionConfig(ctx context.Context, store storage.ObjectStore, sessionPrefix, remoteKey, campaign, sessionID string) (storage.ObjectInfo, string, error) {
|
||||||
current, err := artifacts.LoadCurrentState(ctx, store, sessionPrefix, artifacts.CurrentStateValidation{ExpectedCampaign: campaign, ExpectedSessionID: sessionID, ValidateRunID: true})
|
authored, err := store.Exists(ctx, remoteKey)
|
||||||
|
if err != nil {
|
||||||
|
return storage.ObjectInfo{}, "", fmt.Errorf("check authored session %q: %w", remoteKey, err)
|
||||||
|
}
|
||||||
var selected *artifacts.RemoteArtifact
|
var selected *artifacts.RemoteArtifact
|
||||||
if err == nil {
|
if !authored {
|
||||||
for _, item := range current.Commit.Artifacts {
|
current, err := artifacts.LoadCurrentState(ctx, store, sessionPrefix, artifacts.CurrentStateValidation{ExpectedCampaign: campaign, ExpectedSessionID: sessionID, ValidateRunID: true})
|
||||||
if item.Type == artifacts.RemoteArtifactTypeRunFile && item.Source == "run:prepare/inputs/session.yml" {
|
if err == nil {
|
||||||
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, item.DestinationKey)
|
for _, item := range current.Commit.Artifacts {
|
||||||
if err != nil || "run:"+identity.RelativePath != item.Source {
|
if item.Type == artifacts.RemoteArtifactTypeRunFile && item.Source == "run:prepare/inputs/session.yml" {
|
||||||
return storage.ObjectInfo{}, "", fmt.Errorf("committed session source does not match its object key")
|
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, item.DestinationKey)
|
||||||
|
if err != nil || "run:"+identity.RelativePath != item.Source {
|
||||||
|
return storage.ObjectInfo{}, "", fmt.Errorf("committed session source does not match its object key")
|
||||||
|
}
|
||||||
|
copy := item
|
||||||
|
selected = ©
|
||||||
|
remoteKey = item.DestinationKey
|
||||||
|
break
|
||||||
}
|
}
|
||||||
copy := item
|
|
||||||
selected = ©
|
|
||||||
remoteKey = item.DestinationKey
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
} else if !errors.Is(err, artifacts.ErrCurrentCommitPointerMissing) {
|
||||||
|
return storage.ObjectInfo{}, "", fmt.Errorf("load remote session selection: %w", err)
|
||||||
}
|
}
|
||||||
} else if !errors.Is(err, artifacts.ErrCurrentCommitPointerMissing) {
|
|
||||||
return storage.ObjectInfo{}, "", fmt.Errorf("load remote session selection: %w", err)
|
|
||||||
}
|
}
|
||||||
objects, err := store.List(ctx, sessionPrefix)
|
objects, err := store.List(ctx, sessionPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -120,6 +120,29 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
|||||||
if err != nil || string(restored) != string(fake.Objects[key].Data) {
|
if err != nil || string(restored) != string(fake.Objects[key].Data) {
|
||||||
t.Fatalf("restored session = %q, %v", restored, err)
|
t.Fatalf("restored session = %q, %v", restored, err)
|
||||||
}
|
}
|
||||||
|
committedBytes := string(fake.Objects[key].Data)
|
||||||
|
if err := sessionInitWithDependencies(ctx, []string{m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--remote", "--force", "--title", "Updated title", "--audio-s3-prefix", "replacement/"}, &output, deps); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
updated, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer func() { _ = updated.Close() }()
|
||||||
|
if updated.Config.Session.Title != "Updated title" || updated.Config.Session.Inputs.AudioS3 == nil || updated.Config.Session.Inputs.AudioS3.Prefix != "replacement/" {
|
||||||
|
t.Fatalf("remote edit ignored: %#v", updated.Config.Session)
|
||||||
|
}
|
||||||
|
if string(fake.Objects[key].Data) != committedBytes {
|
||||||
|
t.Fatal("authoring update changed committed input")
|
||||||
|
}
|
||||||
|
if _, err := discoverRemoteCurrentState(ctx, updated.Config, fake); err != nil {
|
||||||
|
t.Fatalf("committed state after authoring update: %v", err)
|
||||||
|
}
|
||||||
|
// Remove the authored override to exercise committed-snapshot integrity below.
|
||||||
|
rootKey := artifacts.S3SessionConfigKey(prefix)
|
||||||
|
if err := fake.Delete(ctx, rootKey); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
object := fake.Objects[key]
|
object := fake.Objects[key]
|
||||||
modified := append([]byte(nil), object.Data...)
|
modified := append([]byte(nil), object.Data...)
|
||||||
modified[0] ^= 1
|
modified[0] ^= 1
|
||||||
|
|||||||
Reference in New Issue
Block a user