Verify S3 upload payloads and clarify recovery
This commit is contained in:
@@ -66,6 +66,9 @@ publication. In particular, CAT-02 remains unresolved by this sprint.
|
|||||||
|
|
||||||
## Stage 1: Protect upload payloads and correct recovery instructions
|
## Stage 1: Protect upload payloads and correct recovery instructions
|
||||||
|
|
||||||
|
**Complete:** SDK-boundary upload payload and reader-error coverage added; recovery
|
||||||
|
instructions now inspect before publication. Storage and documentation checks pass.
|
||||||
|
|
||||||
Read:
|
Read:
|
||||||
|
|
||||||
- `audit/08-testing.md`, lines 70–101 (TE-01).
|
- `audit/08-testing.md`, lines 70–101 (TE-01).
|
||||||
|
|||||||
@@ -688,11 +688,17 @@ Safe fix:
|
|||||||
pre-upgrade backup. Do not delete only the speaker fields by hand.
|
pre-upgrade backup. Do not delete only the speaker fields by hand.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
narratio run 2026-04-04
|
narratio run 2026-04-04 --through analyze
|
||||||
|
narratio session status 2026-04-04
|
||||||
|
```
|
||||||
|
|
||||||
|
Inspect the regenerated records and outputs, then publish explicitly:
|
||||||
|
|
||||||
|
```bash
|
||||||
narratio run 2026-04-04 --stage publish --force
|
narratio run 2026-04-04 --stage publish --force
|
||||||
```
|
```
|
||||||
|
|
||||||
After current records exist, inspect them and publish explicitly. Do not copy
|
Do not copy
|
||||||
old files into canonical paths merely to influence selection; availability is
|
old files into canonical paths merely to influence selection; availability is
|
||||||
manifest-owned.
|
manifest-owned.
|
||||||
|
|
||||||
@@ -886,7 +892,6 @@ Diagnostics:
|
|||||||
```bash
|
```bash
|
||||||
narratio session artifacts 2026-04-04 --remote
|
narratio session artifacts 2026-04-04 --remote
|
||||||
narratio session status 2026-04-04
|
narratio session status 2026-04-04
|
||||||
narratio run 2026-04-04 --stage publish --force
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Safe fix:
|
Safe fix:
|
||||||
@@ -895,6 +900,13 @@ Safe fix:
|
|||||||
- correct publish source/destination rules;
|
- correct publish source/destination rules;
|
||||||
- retry after storage failure is resolved.
|
- retry after storage failure is resolved.
|
||||||
|
|
||||||
|
To retry publication after inspection and repair, run the following mutating
|
||||||
|
command; it can update remote publication state:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
narratio run 2026-04-04 --stage publish --force
|
||||||
|
```
|
||||||
|
|
||||||
Relevant reference: [Publish configuration](./config.md#publish-configuration-summary).
|
Relevant reference: [Publish configuration](./config.md#publish-configuration-summary).
|
||||||
|
|
||||||
## Render markdown source missing
|
## Render markdown source missing
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"testing/iotest"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
@@ -32,6 +33,7 @@ type fakeS3API struct {
|
|||||||
|
|
||||||
putOut *s3.PutObjectOutput
|
putOut *s3.PutObjectOutput
|
||||||
putErr error
|
putErr error
|
||||||
|
putBody []byte
|
||||||
deleteErr error
|
deleteErr error
|
||||||
|
|
||||||
headErr error
|
headErr error
|
||||||
@@ -110,6 +112,11 @@ func (f *fakeS3API) GetObject(_ context.Context, params *s3.GetObjectInput, _ ..
|
|||||||
|
|
||||||
func (f *fakeS3API) PutObject(_ context.Context, params *s3.PutObjectInput, _ ...func(*s3.Options)) (*s3.PutObjectOutput, error) {
|
func (f *fakeS3API) PutObject(_ context.Context, params *s3.PutObjectInput, _ ...func(*s3.Options)) (*s3.PutObjectOutput, error) {
|
||||||
f.lastPut = params
|
f.lastPut = params
|
||||||
|
var err error
|
||||||
|
f.putBody, err = io.ReadAll(params.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if f.putErr != nil {
|
if f.putErr != nil {
|
||||||
return nil, f.putErr
|
return nil, f.putErr
|
||||||
}
|
}
|
||||||
@@ -236,6 +243,9 @@ func TestS3BackendUploadAndExists(t *testing.T) {
|
|||||||
if client.lastPut == nil || *client.lastPut.Key != "runs/id/artifact.txt" {
|
if client.lastPut == nil || *client.lastPut.Key != "runs/id/artifact.txt" {
|
||||||
t.Fatalf("PutObject key = %#v, want normalized key", client.lastPut)
|
t.Fatalf("PutObject key = %#v, want normalized key", client.lastPut)
|
||||||
}
|
}
|
||||||
|
if string(client.putBody) != "artifact" || client.lastPut.Metadata["kind"] != "artifact" {
|
||||||
|
t.Fatalf("PutObject body = %q, metadata = %#v", client.putBody, client.lastPut.Metadata)
|
||||||
|
}
|
||||||
|
|
||||||
ok, err := backend.Exists(context.Background(), "runs/id/artifact.txt")
|
ok, err := backend.Exists(context.Background(), "runs/id/artifact.txt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -255,11 +265,26 @@ func TestS3BackendConditionalUploadUsesProviderPrecondition(t *testing.T) {
|
|||||||
if client.lastPut == nil || client.lastPut.IfMatch == nil || *client.lastPut.IfMatch != "before" || client.lastPut.IfNoneMatch != nil {
|
if client.lastPut == nil || client.lastPut.IfMatch == nil || *client.lastPut.IfMatch != "before" || client.lastPut.IfNoneMatch != nil {
|
||||||
t.Fatalf("PutObject conditional input = %#v", client.lastPut)
|
t.Fatalf("PutObject conditional input = %#v", client.lastPut)
|
||||||
}
|
}
|
||||||
|
if string(client.putBody) != "payload" || *client.lastPut.Key != "control.json" {
|
||||||
|
t.Fatalf("PutObject body = %q, key = %q", client.putBody, *client.lastPut.Key)
|
||||||
|
}
|
||||||
client.putErr = &smithy.GenericAPIError{Code: "PreconditionFailed", Message: "changed"}
|
client.putErr = &smithy.GenericAPIError{Code: "PreconditionFailed", Message: "changed"}
|
||||||
_, err := backend.UploadConditional(context.Background(), strings.NewReader("payload"), "control.json", UploadOptions{}, WriteCondition{RequireAbsent: true})
|
_, err := backend.UploadConditional(context.Background(), strings.NewReader("payload"), "control.json", UploadOptions{}, WriteCondition{RequireAbsent: true})
|
||||||
if !errors.Is(err, ErrConditionNotMet) {
|
if !errors.Is(err, ErrConditionNotMet) {
|
||||||
t.Fatalf("UploadConditional() error = %v, want ErrConditionNotMet", err)
|
t.Fatalf("UploadConditional() error = %v, want ErrConditionNotMet", err)
|
||||||
}
|
}
|
||||||
|
if client.lastPut.IfNoneMatch == nil || *client.lastPut.IfNoneMatch != "*" {
|
||||||
|
t.Fatalf("PutObject IfNoneMatch = %v, want *", client.lastPut.IfNoneMatch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestS3BackendUploadPropagatesReaderFailure(t *testing.T) {
|
||||||
|
readErr := errors.New("synthetic reader failure")
|
||||||
|
backend := &S3Backend{bucket: "bucket-1", client: &fakeS3API{}}
|
||||||
|
_, err := backend.UploadConditional(context.Background(), iotest.ErrReader(readErr), "control.json", UploadOptions{}, WriteCondition{RequireAbsent: true})
|
||||||
|
if !errors.Is(err, readErr) {
|
||||||
|
t.Fatalf("UploadConditional() error = %v, want reader failure", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestS3BackendUploadMissingLocalFile(t *testing.T) {
|
func TestS3BackendUploadMissingLocalFile(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user