Forward Notarius cache controls during extraction

This commit is contained in:
2026-09-16 17:44:28 +00:00
parent 5086596f94
commit 5202f16972
7 changed files with 156 additions and 2 deletions

View File

@@ -146,10 +146,16 @@ func (extractStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (re
if err != nil {
return nil, fmt.Errorf("extract: build configuration fingerprint: %w", err)
}
resume := notariusConfig.Resume
chunkCache := notariusConfig.ChunkCache
if env.Force {
resume = false
chunkCache = "refresh"
}
request := notarius.RunRequest{
Binary: resolvedBinary, LLMAPIKey: notariusConfig.LLMAPIKey, ConfigPath: configPath, PipelineID: notariusConfig.PipelineID,
InputPath: inputPath, OutputRoot: outputRoot, WorkingDirectory: workingDirectory,
ReceiptPath: receiptPath, LogPath: logPath, Timeout: timeout, References: referenceBindings,
ReceiptPath: receiptPath, LogPath: logPath, Timeout: timeout, Resume: resume, ChunkCache: chunkCache, References: referenceBindings,
}
stageSucceeded := false
bundleMoved := false

View File

@@ -96,6 +96,9 @@ notarius:
if len(req.References) != 0 {
t.Fatalf("references = %#v, want none", req.References)
}
if req.Resume || req.ChunkCache != "" {
t.Fatalf("default cache controls = resume %v, mode %q", req.Resume, req.ChunkCache)
}
if req.LLMAPIKey != loadedPipeline.Notarius.LLMAPIKey || req.LLMAPIKey.EnvName() != credentialName || !req.LLMAPIKey.IsResolved() {
t.Fatal("request did not retain the loaded Notarius credential reference")
}
@@ -114,6 +117,41 @@ notarius:
}
}
func TestExtractStageAppliesNotariusCacheControlsAndForcePrecedence(t *testing.T) {
tests := []struct {
name string
configuredResume bool
configuredMode string
force bool
wantResume bool
wantMode string
}{
{name: "ordinary defaults"},
{name: "ordinary configured", configuredResume: true, configuredMode: "bypass", wantResume: true, wantMode: "bypass"},
{name: "force overrides configured", configuredResume: true, configuredMode: "bypass", force: true, wantMode: "refresh"},
{name: "force overrides defaults", force: true, wantMode: "refresh"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
env, m, fake := setupExtractEnv(t)
env.Config.Pipeline.Notarius.Resume = test.configuredResume
env.Config.Pipeline.Notarius.ChunkCache = test.configuredMode
env.Force = test.force
if _, err := (extractStage{}).Run(context.Background(), env, m); err != nil {
t.Fatalf("Run() error = %v", err)
}
if len(fake.Requests) != 1 {
t.Fatalf("requests = %d, want 1", len(fake.Requests))
}
request := fake.Requests[0]
if request.Resume != test.wantResume || request.ChunkCache != test.wantMode {
t.Fatalf("cache controls = resume %v, mode %q; want resume %v, mode %q", request.Resume, request.ChunkCache, test.wantResume, test.wantMode)
}
})
}
}
func TestExtractStageResolvesAllPreparedReferencesInSelectorOrder(t *testing.T) {
env, m, fake := setupExtractEnv(t)
configured := []struct {

View File

@@ -76,6 +76,26 @@ func TestExtractSemanticConfigSensitivityAndOperationalExclusions(t *testing.T)
if !want.Equal(got) {
t.Fatalf("operational settings changed fingerprint: got %#v want %#v", got, want)
}
for _, test := range []struct {
name string
mutate func(*config.NotariusConfig)
}{
{name: "resume", mutate: func(cfg *config.NotariusConfig) { cfg.Resume = true }},
{name: "chunk cache", mutate: func(cfg *config.NotariusConfig) { cfg.ChunkCache = "refresh" }},
} {
t.Run("operational "+test.name, func(t *testing.T) {
env := downstreamSemanticEnv()
test.mutate(env.Config.Pipeline.Notarius)
got, err := (extractStage{}).SemanticConfigFingerprint(env)
if err != nil {
t.Fatal(err)
}
if !want.Equal(got) {
t.Fatalf("%s changed semantic fingerprint: got %#v want %#v", test.name, got, want)
}
})
}
}
func TestExtractResumeValidationExcludesOperationalSettings(t *testing.T) {
@@ -85,6 +105,8 @@ func TestExtractResumeValidationExcludesOperationalSettings(t *testing.T) {
env.Config.Pipeline.Notarius.ConfigPath = "/not/present/private.yml"
env.Config.Pipeline.Notarius.Timeout = "not-a-duration"
env.Config.Pipeline.Notarius.WorkingDirectory = "/not/present/work"
env.Config.Pipeline.Notarius.Resume = true
env.Config.Pipeline.Notarius.ChunkCache = "bypass"
validation, err := (extractStage{}).ValidateResume(context.Background(), env, m)
if err != nil {