From 4088923a4542ba25be9057b29494206c892093f9 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sun, 6 Dec 2026 02:50:12 +0000 Subject: [PATCH] Keep required local inputs separate from committed source --- docs/roadmap/remediation.md | 5 +++++ internal/readiness/committed_test.go | 28 +++++++++++++++++++++++++++- internal/readiness/readiness.go | 9 --------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index 0a0970d..394f681 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -116,6 +116,11 @@ access-observation assertions use a complete rehearsal configuration. ## 2. Committed readiness turns local required files into committed inputs +**Completed:** Required local files use filesystem checks in both readers. +Regression coverage verifies ignored relative/absolute keys, missing local +copies despite committed blobs, and captured module/main-package inputs. +Readiness and rehearsal suites pass. + **Priority:** P2. **Stages:** 7, 12. **Relevant code:** [`Run`](../../internal/readiness/readiness.go), required-file diff --git a/internal/readiness/committed_test.go b/internal/readiness/committed_test.go index bd8433e..7a7eda1 100644 --- a/internal/readiness/committed_test.go +++ b/internal/readiness/committed_test.go @@ -26,6 +26,9 @@ func TestCommittedReadinessUsesCapturedModuleAndMainPackage(t *testing.T) { run("init", "--initial-branch=main") run("config", "user.name", "ReleaseKit Test") run("config", "user.email", "releasekit@example.test") + if err := os.WriteFile(filepath.Join(repo, ".gitignore"), []byte(".releasekit/\n"), 0600); err != nil { + t.Fatal(err) + } if err := os.WriteFile(filepath.Join(repo, "go.mod"), []byte("module example.com/fixture\n\ngo 1.25.0\n"), 0600); err != nil { t.Fatal(err) } @@ -38,16 +41,39 @@ func TestCommittedReadinessUsesCapturedModuleAndMainPackage(t *testing.T) { run("add", "--all") run("commit", "-m", "capture inputs") commit := run("rev-parse", "HEAD") + if err := os.Mkdir(filepath.Join(repo, ".releasekit"), 0700); err != nil { + t.Fatal(err) + } + key := filepath.Join(repo, ".releasekit", "ssh-key") + if err := os.WriteFile(key, []byte("local fixture key"), 0600); err != nil { + t.Fatal(err) + } os.Remove(filepath.Join(repo, "main.go")) - os.Remove(filepath.Join(repo, "required.txt")) os.WriteFile(filepath.Join(repo, "go.mod"), []byte("invalid working module"), 0600) request := Request{RepositoryDir: repo, Commit: commit, Product: "Example", Context: "local", Source: &releaseidentity.SourceSpec{GoEnabled: true}, Operations: []string{"build"}, Build: &artifact.Settings{MainPackage: ".", BinaryName: "fixture", Targets: []artifact.Target{{OS: "linux", Arch: "amd64"}}}, RequiredFiles: []string{"required.txt", filepath.Join(repo, "required.txt")}} + request.RequiredFiles = append(request.RequiredFiles, ".releasekit/ssh-key", key) report := Run(t.Context(), request) for _, check := range report.Checks { if check.Status == "failed" { t.Fatalf("captured readiness failed: %+v", check) } } + if err := os.Remove(filepath.Join(repo, "required.txt")); err != nil { + t.Fatal(err) + } + report = Run(t.Context(), request) + missing := 0 + for _, check := range report.Checks { + if check.ID == "required-file" && check.Status == "failed" { + missing++ + } + if check.ID == "build-inputs" && check.Status != "passed" { + t.Fatalf("captured build inputs changed: %+v", check) + } + } + if missing != 2 { + t.Fatalf("missing local inputs were supplied by Git: %+v", report.Checks) + } request.Commit = "" report = Run(t.Context(), request) failed := false diff --git a/internal/readiness/readiness.go b/internal/readiness/readiness.go index 234f309..c353d9f 100644 --- a/internal/readiness/readiness.go +++ b/internal/readiness/readiness.go @@ -137,13 +137,6 @@ func Run(ctx context.Context, request Request) Report { } for _, name := range request.RequiredFiles { path := name - committedName := name - committedInput := request.Commit != "" && !filepath.IsAbs(name) - if request.Commit != "" && filepath.IsAbs(name) && repoErr == nil { - if relative, relErr := filepath.Rel(repository, filepath.Clean(name)); relErr == nil && relative != ".." && !strings.HasPrefix(relative, ".."+string(filepath.Separator)) { - committedName, committedInput = relative, true - } - } if !filepath.IsAbs(path) { path = filepath.Join(repository, path) } @@ -154,8 +147,6 @@ func Run(ctx context.Context, request Request) Report { err = errors.New("relative required file path escapes the repository") } else if repoErr != nil && !filepath.IsAbs(name) { err = errors.New("repository unavailable for relative required file") - } else if committedInput { - _, err = committedFile(ctx, repository, request.Commit, filepath.ToSlash(committedName)) } else { var info os.FileInfo info, err = os.Stat(path)