From 44e83dc6f9fee1186477b213dbe6d0386016fd92 Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Tue, 29 Sep 2026 19:46:57 -0400 Subject: [PATCH 1/3] ci(#7751): declare a sandbox policy in every behaviour harness Since the move to OpenShell 0.1.2, every behaviour scenario that runs a custom harness fails: 15 to 16 of 33 on main and on every rebased PR. OpenShell 0.1.2 refuses both policy shapes those harnesses reached: - no policy: the sandbox ends in phase Error with ConfigurationInvalid ("Effective configuration could not be activated; replace the policy or repair attached providers"), whether or not providers are attached; - a policy file with no fields: create fails with "failed to decode sandbox policy fields". The steps committed "# Minimal policy for " for every relative policy a harness names. Reproduced on a local 0.1.2 gateway with a dummy-runtime harness and no providers: no policy and the comment-only placeholder both fail at create, and the base policy runs to exit 0. The fleet harnesses kept passing because they resolve a real policy from the agents repo. fullsend ships no default policy (#7266), so a harness must name one. The feature files now say so: every standalone and base harness heredoc declares policy: policies/base.yaml, and base-composed children inherit it from their base. The resource helpers commit the base policy that fullsend agent new writes (agentnew.BasePolicy, exported for this) for any relative policy a harness names, in the config repo or the hosting repo. It has no network section, so egress still comes only from the harness's providers. Assisted-by: Claude Signed-off-by: Wayne Sun --- .../features/dispatch/base-dispatch.feature | 3 ++ .../features/dispatch/dispatch.feature | 6 +++ .../features/dispatch/fork-dispatch.feature | 6 +++ .../features/dispatch/hooks-loaded.feature | 1 + .../dispatch/reaction-notifications.feature | 1 + .../features/dispatch/url-dispatch.feature | 7 +++ .../features/runtime/agent-settings.feature | 1 + e2e/behaviour/features/runtime/pi.feature | 1 + internal/agentnew/assets.go | 20 ++++++-- internal/agentnew/assets_test.go | 19 +++++++ pkg/behaviourtest/steps/dispatch.go | 5 +- pkg/behaviourtest/steps/dispatch_test.go | 2 +- .../steps/policy_resource_test.go | 50 +++++++++++++++++++ pkg/behaviourtest/steps/url_dispatch.go | 5 +- pkg/behaviourtest/steps/url_dispatch_test.go | 2 +- 15 files changed, 118 insertions(+), 11 deletions(-) create mode 100644 internal/agentnew/assets_test.go create mode 100644 pkg/behaviourtest/steps/policy_resource_test.go diff --git a/e2e/behaviour/features/dispatch/base-dispatch.feature b/e2e/behaviour/features/dispatch/base-dispatch.feature index 2a3dfa4582..6b6d5905b4 100644 --- a/e2e/behaviour/features/dispatch/base-dispatch.feature +++ b/e2e/behaviour/features/dispatch/base-dispatch.feature @@ -13,6 +13,7 @@ Feature: Base-composed harness dispatch slug: fullsend-ai-local-base model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml """ # Variant 1: local child with local base And a custom harness "local-child" with base "local-base" and: @@ -31,6 +32,7 @@ Feature: Base-composed harness dispatch slug: fullsend-ai-remote-base model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml """ # Variant 2: local child with remote (URL) base And a custom harness "remote-base-child" with URL base "remote-base" and: @@ -68,6 +70,7 @@ Feature: Base-composed harness dispatch slug: fullsend-ai-trigger-base model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: > event.entity.kind == "work_item" && event.transition.kind == "label_changed" diff --git a/e2e/behaviour/features/dispatch/dispatch.feature b/e2e/behaviour/features/dispatch/dispatch.feature index 16e7c93aee..afa3a33e31 100644 --- a/e2e/behaviour/features/dispatch/dispatch.feature +++ b/e2e/behaviour/features/dispatch/dispatch.feature @@ -11,6 +11,7 @@ Feature: Harness CEL dispatch slug: fullsend-ai-issue-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -40,6 +41,7 @@ Feature: Harness CEL dispatch slug: fullsend-ai-pr-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "change_proposal" && event.transition.kind == "label_changed" @@ -52,6 +54,7 @@ Feature: Harness CEL dispatch slug: fullsend-ai-issue-only-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -76,6 +79,7 @@ Feature: Harness CEL dispatch slug: fullsend-ai-enabled-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -88,6 +92,7 @@ Feature: Harness CEL dispatch slug: fullsend-ai-disabled-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -111,6 +116,7 @@ Feature: Harness CEL dispatch slug: fullsend-ai-review-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "change_proposal" && event.transition.kind == "review_submitted" diff --git a/e2e/behaviour/features/dispatch/fork-dispatch.feature b/e2e/behaviour/features/dispatch/fork-dispatch.feature index e5db9923df..2d57505b0a 100644 --- a/e2e/behaviour/features/dispatch/fork-dispatch.feature +++ b/e2e/behaviour/features/dispatch/fork-dispatch.feature @@ -12,6 +12,7 @@ Feature: Fork PR dispatch slug: fullsend-ai-fork-pr-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "change_proposal" && event.transition.kind == "label_changed" @@ -24,6 +25,7 @@ Feature: Fork PR dispatch slug: fullsend-ai-fork-issue-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -36,6 +38,7 @@ Feature: Fork PR dispatch slug: fullsend-ai-fork-pr-killed model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "change_proposal" && event.transition.kind == "label_changed" @@ -48,6 +51,7 @@ Feature: Fork PR dispatch slug: fullsend-ai-fork-pr-nofork model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "change_proposal" && event.transition.kind == "label_changed" @@ -75,6 +79,7 @@ Feature: Fork PR dispatch slug: fullsend-ai-fork-pr-killswitch model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "change_proposal" && event.transition.kind == "label_changed" @@ -93,6 +98,7 @@ Feature: Fork PR dispatch slug: fullsend-ai-fork-pr-sync model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "change_proposal" && event.transition.kind == "label_changed" diff --git a/e2e/behaviour/features/dispatch/hooks-loaded.feature b/e2e/behaviour/features/dispatch/hooks-loaded.feature index 47b961ddec..3ea9d65569 100644 --- a/e2e/behaviour/features/dispatch/hooks-loaded.feature +++ b/e2e/behaviour/features/dispatch/hooks-loaded.feature @@ -18,6 +18,7 @@ Feature: Sandbox security hooks are loaded via --settings slug: fullsend-ai-hooks-smoke model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" diff --git a/e2e/behaviour/features/dispatch/reaction-notifications.feature b/e2e/behaviour/features/dispatch/reaction-notifications.feature index bd1661a239..d1bde5eaff 100644 --- a/e2e/behaviour/features/dispatch/reaction-notifications.feature +++ b/e2e/behaviour/features/dispatch/reaction-notifications.feature @@ -16,6 +16,7 @@ Feature: Emoji reaction status notifications slug: fullsend-ai-reaction-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" diff --git a/e2e/behaviour/features/dispatch/url-dispatch.feature b/e2e/behaviour/features/dispatch/url-dispatch.feature index 60e994c396..d15a031a2b 100644 --- a/e2e/behaviour/features/dispatch/url-dispatch.feature +++ b/e2e/behaviour/features/dispatch/url-dispatch.feature @@ -12,6 +12,7 @@ Feature: URL-sourced harness dispatch slug: fullsend-ai-url-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -34,6 +35,7 @@ Feature: URL-sourced harness dispatch slug: fullsend-ai-local-ping model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -46,6 +48,7 @@ Feature: URL-sourced harness dispatch slug: fullsend-ai-url-mixed model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -67,6 +70,7 @@ Feature: URL-sourced harness dispatch slug: fullsend-ai-good-local model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -79,6 +83,7 @@ Feature: URL-sourced harness dispatch slug: fullsend-ai-bad-hash model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -105,6 +110,7 @@ Feature: URL-sourced harness dispatch slug: fullsend-ai-good-allowed model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" @@ -117,6 +123,7 @@ Feature: URL-sourced harness dispatch slug: fullsend-ai-no-allow model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" diff --git a/e2e/behaviour/features/runtime/agent-settings.feature b/e2e/behaviour/features/runtime/agent-settings.feature index 9d51a154ae..1252c6add5 100644 --- a/e2e/behaviour/features/runtime/agent-settings.feature +++ b/e2e/behaviour/features/runtime/agent-settings.feature @@ -46,6 +46,7 @@ Feature: Per-agent runtime and model on agents: entries in config.yaml slug: fullsend-ai-pi-override model: opus image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" diff --git a/e2e/behaviour/features/runtime/pi.feature b/e2e/behaviour/features/runtime/pi.feature index 9d4f83c038..35fcfe6086 100644 --- a/e2e/behaviour/features/runtime/pi.feature +++ b/e2e/behaviour/features/runtime/pi.feature @@ -24,6 +24,7 @@ Feature: pi runtime runs an agent unattended slug: fullsend-ai-pi-smoke model: haiku image: ghcr.io/fullsend-ai/fullsend-sandbox:latest + policy: policies/base.yaml trigger: | event.entity.kind == "work_item" && event.transition.kind == "label_changed" diff --git a/internal/agentnew/assets.go b/internal/agentnew/assets.go index 3847fbe392..65a106b831 100644 --- a/internal/agentnew/assets.go +++ b/internal/agentnew/assets.go @@ -1,11 +1,25 @@ package agentnew import ( + "bytes" + _ "embed" "fmt" "github.com/fullsend-ai/fullsend/internal/scaffold" ) +// BasePolicy returns the base sandbox policy a generated agent's harness +// names: filesystem, landlock and process rules with no network section, so +// egress comes only from the harness's providers (ADR 0065). The behaviour +// suite commits it for scenario harnesses, because OpenShell 0.1 refuses a +// sandbox with no policy and a policy file that declares no fields. +func BasePolicy() []byte { + return bytes.Clone(basePolicy) +} + +//go:embed templates/policies/base.yaml +var basePolicy []byte + // sharedAssets returns the scaffold files a generated agent depends on but // does not own: the sandbox policy, the role's providers and profiles, and // the schema validator when the validation loop is enabled. @@ -22,11 +36,7 @@ import ( func sharedAssets(role Role, validationLoop bool) ([]File, error) { files := []File{} - policy, err := templates.ReadFile("templates/policies/base.yaml") - if err != nil { - return nil, fmt.Errorf("reading base policy: %w", err) - } - files = append(files, File{Path: "policies/base.yaml", Data: policy, Mode: 0o644, Shared: true}) + files = append(files, File{Path: "policies/base.yaml", Data: BasePolicy(), Mode: 0o644, Shared: true}) // Providers and profiles are referenced by path rather than by bare // name. A bare name with no definition on disk does not fail loudly: the diff --git a/internal/agentnew/assets_test.go b/internal/agentnew/assets_test.go new file mode 100644 index 0000000000..5f5055d2d7 --- /dev/null +++ b/internal/agentnew/assets_test.go @@ -0,0 +1,19 @@ +package agentnew + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestBasePolicy_IsTheTemplateAndACopy(t *testing.T) { + want, err := templates.ReadFile("templates/policies/base.yaml") + require.NoError(t, err) + + got := BasePolicy() + assert.Equal(t, string(want), string(got)) + + got[0] = 'X' + assert.Equal(t, string(want), string(BasePolicy()), "a caller's edit must not change later results") +} diff --git a/pkg/behaviourtest/steps/dispatch.go b/pkg/behaviourtest/steps/dispatch.go index a73a5500b3..1b15694a61 100644 --- a/pkg/behaviourtest/steps/dispatch.go +++ b/pkg/behaviourtest/steps/dispatch.go @@ -11,6 +11,7 @@ import ( "github.com/cucumber/godog" "gopkg.in/yaml.v3" + "github.com/fullsend-ai/fullsend/internal/agentnew" "github.com/fullsend-ai/fullsend/internal/config" "github.com/fullsend-ai/fullsend/internal/scaffold" "github.com/fullsend-ai/fullsend/pkg/behaviourtest/world" @@ -253,10 +254,10 @@ func commitLocalHarnessResources(ctx context.Context, w *world.World, harnessNam if h.Policy != "" && !strings.HasPrefix(h.Policy, "/") && !strings.HasPrefix(h.Policy, "https://") { policyPath := filepath.Join(".fullsend", h.Policy) - minimalPolicy := fmt.Sprintf("# Minimal policy for %s\n", harnessName) + policy := agentnew.BasePolicy() if err := w.SCM.CommitFile(ctx, owner, repo, policyPath, fmt.Sprintf("behaviour: add policy resource for %s", harnessName), - []byte(minimalPolicy)); err != nil { + policy); err != nil { return fmt.Errorf("committing policy resource %s: %w", policyPath, err) } } diff --git a/pkg/behaviourtest/steps/dispatch_test.go b/pkg/behaviourtest/steps/dispatch_test.go index 32e78a2827..1909583343 100644 --- a/pkg/behaviourtest/steps/dispatch_test.go +++ b/pkg/behaviourtest/steps/dispatch_test.go @@ -364,7 +364,7 @@ func TestGivenCustomHarness_CommitsAgentAndPolicy(t *testing.T) { policyData := scm.files["test-org/test-repo/.fullsend/policies/test.md"] require.NotNil(t, policyData, "policy resource should be committed") - assert.Contains(t, string(policyData), "Minimal policy") + assertBasePolicy(t, policyData) } func TestGivenCustomHarness_SkipsAbsoluteAgentPath(t *testing.T) { diff --git a/pkg/behaviourtest/steps/policy_resource_test.go b/pkg/behaviourtest/steps/policy_resource_test.go new file mode 100644 index 0000000000..8fb5521543 --- /dev/null +++ b/pkg/behaviourtest/steps/policy_resource_test.go @@ -0,0 +1,50 @@ +package steps + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" + + "github.com/fullsend-ai/fullsend/internal/agentnew" + "github.com/fullsend-ai/fullsend/pkg/behaviourtest/world" +) + +// assertBasePolicy checks that a committed policy resource is the real base +// policy. OpenShell 0.1 rejects a policy file that declares no fields (a +// comment-only placeholder) at sandbox create. +func assertBasePolicy(t *testing.T, got []byte) { + t.Helper() + require.NotNil(t, got, "policy resource should be committed") + assert.Equal(t, string(agentnew.BasePolicy()), string(got)) + var p struct { + Version int `yaml:"version"` + FilesystemPolicy map[string]any `yaml:"filesystem_policy"` + } + require.NoError(t, yaml.Unmarshal(got, &p)) + assert.Equal(t, 1, p.Version) + assert.NotEmpty(t, p.FilesystemPolicy) +} + +// A URL-sourced base that names a relative policy gets the base policy +// committed next to it in the hosting repo, so a child that names no policy +// inherits a policy OpenShell can activate. +func TestGivenURLSourcedBaseHarness_CommitsBasePolicy(t *testing.T) { + stubRawHTTPClient(t) + scm := &fakeURLSCM{files: map[string][]byte{ + "org/repo/.fullsend/config.yaml": []byte("version: \"1\"\nagents: []\n"), + }} + w := &world.World{ + Org: "org", + RepoName: "repo", + SCM: scm, + URLHarnessRepoOwner: "org", + URLHarnessRepoName: "base-host", + } + + require.NoError(t, givenURLSourcedBaseHarness(w, "remote-base", + "agent: agents/triage.md\npolicy: policies/base.yaml\nrole: triage\nslug: fullsend-ai-base")) + + assertBasePolicy(t, scm.files["org/base-host/policies/base.yaml"]) +} diff --git a/pkg/behaviourtest/steps/url_dispatch.go b/pkg/behaviourtest/steps/url_dispatch.go index 1126823c5c..e124f0e621 100644 --- a/pkg/behaviourtest/steps/url_dispatch.go +++ b/pkg/behaviourtest/steps/url_dispatch.go @@ -13,6 +13,7 @@ import ( "github.com/cucumber/godog" "gopkg.in/yaml.v3" + "github.com/fullsend-ai/fullsend/internal/agentnew" "github.com/fullsend-ai/fullsend/internal/config" "github.com/fullsend-ai/fullsend/pkg/behaviourtest/world" ) @@ -398,10 +399,10 @@ func commitRelativeResources(ctx context.Context, w *world.World, owner, repo, h // Commit relative policy file if specified. if h.Policy != "" && !strings.HasPrefix(h.Policy, "/") && !strings.HasPrefix(h.Policy, "https://") { - minimalPolicy := fmt.Sprintf("# Minimal policy for %s\n", harnessName) + policy := agentnew.BasePolicy() if err := w.SCM.CommitFile(ctx, owner, repo, h.Policy, fmt.Sprintf("behaviour: add policy resource for %s", harnessName), - []byte(minimalPolicy)); err != nil { + policy); err != nil { return nil, fmt.Errorf("committing policy resource %s: %w", h.Policy, err) } committed = append(committed, h.Policy) diff --git a/pkg/behaviourtest/steps/url_dispatch_test.go b/pkg/behaviourtest/steps/url_dispatch_test.go index 1dc22d24e7..c2a27be4fc 100644 --- a/pkg/behaviourtest/steps/url_dispatch_test.go +++ b/pkg/behaviourtest/steps/url_dispatch_test.go @@ -650,7 +650,7 @@ func TestCommitRelativeResources_CommitsPolicyFile(t *testing.T) { "agent: agents/triage.md\npolicy: policies/base.yaml\nrole: triage") require.NoError(t, err) assert.Equal(t, minimalAgentContent, string(scm.files["org/repo/agents/triage.md"])) - assert.Contains(t, string(scm.files["org/repo/policies/base.yaml"]), "Minimal policy") + assertBasePolicy(t, scm.files["org/repo/policies/base.yaml"]) assert.Equal(t, []string{"agents/triage.md", "policies/base.yaml"}, paths) } From 24d5e1ae62baba4c1cdc2e54af461f601c931c28 Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Tue, 29 Sep 2026 16:26:13 -0400 Subject: [PATCH 2/3] fix(#7751): retry provider creation on OpenShell 0.1's profile-not-found error Parallel fullsend runs on one gateway reimport shared profiles, so a run can create a provider while another run has the profile deleted. The retry for that matched OpenShell 0.0.x's "unsupported provider type or profile". OpenShell 0.1 reports it as "provider profile '' not found; import a matching profile", so the run failed without retrying: three of four parallel functional-test cases hit it. Match the 0.1 wording too, across the CLI's line wrap. Assisted-by: Claude Signed-off-by: Wayne Sun --- internal/sandbox/sandbox.go | 13 ++++++++++--- internal/sandbox/sandbox_test.go | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/internal/sandbox/sandbox.go b/internal/sandbox/sandbox.go index 7d6820351c..b2cd6bbfa1 100644 --- a/internal/sandbox/sandbox.go +++ b/internal/sandbox/sandbox.go @@ -533,9 +533,10 @@ func ensureProviderArgs(ctx context.Context, name string, args, updateArgs, extr // isTransientProviderErr reports whether err is one of the openshell // errors produced by concurrent runs racing on the same gateway: a missing -// or not-yet-reimported profile, or an optimistic-concurrency rejection of -// a provider update ("provider was modified concurrently (current -// resource_version: N)"). +// or not-yet-reimported profile (OpenShell 0.0.x: "unsupported provider type +// or profile"; 0.1.x: "provider profile '' not found; import a matching +// profile"), or an optimistic-concurrency rejection of a provider update +// ("provider was modified concurrently (current resource_version: N)"). // // NOTE: This matches literal text from the openshell CLI's stderr output. // If openshell changes its error wording in a future version, this check @@ -547,9 +548,15 @@ func isTransientProviderErr(err error) bool { } msg := strings.ToLower(err.Error()) return strings.Contains(msg, "unsupported provider type or profile") || + providerProfileNotFoundRe.MatchString(msg) || providerModifiedConcurrentlyRe.MatchString(msg) } +// providerProfileNotFoundRe matches OpenShell 0.1.x's error for a provider +// whose profile is not (yet) registered, which a concurrent run's +// ImportProfile delete+reimport produces. \W+ spans the CLI's line wrap. +var providerProfileNotFoundRe = regexp.MustCompile(`provider\W+profile\W+'[^']+'\W+not\W+found`) + // providerModifiedConcurrentlyRe matches openshell's optimistic-concurrency // error. The CLI wraps the message across lines with a box-drawing gutter // (`"provider was modified` / `│ concurrently (current resource_version: 2)"`), diff --git a/internal/sandbox/sandbox_test.go b/internal/sandbox/sandbox_test.go index a022ad90e4..1aaf12a92d 100644 --- a/internal/sandbox/sandbox_test.go +++ b/internal/sandbox/sandbox_test.go @@ -2129,6 +2129,14 @@ func TestIsTransientProviderErr(t *testing.T) { assert.True(t, isTransientProviderErr(errors.New("provider was modified concurrently"))) assert.False(t, isTransientProviderErr(fmt.Errorf("status: PermissionDenied"))) assert.False(t, isTransientProviderErr(fmt.Errorf("provider was modified by an operator"))) + + // OpenShell 0.1.x wording for a profile a concurrent run is reimporting, + // as seen in functional-tests with four parallel eval cases. + notFound := `provider create "github-ro" failed: exit status 1 (output: Error: × provider profile 'fullsend-github-ro' not found; import a matching profile` + assert.True(t, isTransientProviderErr(errors.New(notFound))) + notFoundWrapped := "Error: × provider profile 'fullsend-vertex-ai' not\n │ found; import a matching profile" + assert.True(t, isTransientProviderErr(errors.New(notFoundWrapped)), "must match across the CLI's line wrap") + assert.False(t, isTransientProviderErr(errors.New("provider 'github-ro' not found")), "a missing provider is not a missing profile") } // TestEnsureProvider_NoRetryOnOtherErrors verifies that non-transient From 33bae11e62f999839365937063562eba7c05a053 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 30 Sep 2026 09:43:27 +0300 Subject: [PATCH 3/3] ci(e2e): retry enrollment merge after concurrent head update GitHub can return 422 expected-head-sha mismatches when the onboarding reconciler rewrites fullsend/onboard while MergeChangeProposal handles a 409. Retry only this specific concurrent-head error in TestAdminInstallUninstall so the merge-queue E2E run re-reads the PR state. This is merge-queue E2E resilience only; it does not change product behavior, reconciliation, or the shared forge API. Signed-off-by: Barak Korren Assisted-by: Codex (gpt-5.6-sol) --- e2e/admin/admin_test.go | 24 +++++++++++-- e2e/admin/admin_test_helpers_test.go | 52 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 e2e/admin/admin_test_helpers_test.go diff --git a/e2e/admin/admin_test.go b/e2e/admin/admin_test.go index 8b5751530c..4382b395c2 100644 --- a/e2e/admin/admin_test.go +++ b/e2e/admin/admin_test.go @@ -230,6 +230,18 @@ func TestAdminInstallUninstall(t *testing.T) { t.Log("=== E2E test complete ===") } +// isConcurrentHeadUpdate reports the GitHub 422 returned when another actor +// moves a PR head while update-branch is processing it. The onboarding +// reconciler legitimately rewrites fullsend/onboard, so the next merge +// attempt must re-read the PR state instead of failing the E2E run. +func isConcurrentHeadUpdate(err error) bool { + var apiErr *gh.APIError + return errors.As(err, &apiErr) && + apiErr.StatusCode == http.StatusUnprocessableEntity && + strings.Contains(strings.ToLower(apiErr.Message), "expected head sha") && + strings.Contains(strings.ToLower(apiErr.Message), "current head ref") +} + // mergeEnrollmentPR finds and merges the enrollment PR for test-repo so the // shim workflow is active on the default branch. // In PR-based install mode, enrollment is deferred: repo-maintenance triggers @@ -289,8 +301,16 @@ func mergeEnrollmentPR(t *testing.T, env *e2eEnv) { } var apiErr *gh.APIError - if !errors.As(mergeErr, &apiErr) || apiErr.StatusCode != http.StatusConflict { - break // not a 409, fail immediately + if !errors.As(mergeErr, &apiErr) { + break // not a retryable GitHub API error + } + if apiErr.StatusCode == http.StatusUnprocessableEntity && isConcurrentHeadUpdate(mergeErr) { + t.Logf("Merge attempt %d: PR head changed during update-branch (422), retrying", attempt+1) + time.Sleep(5 * time.Second) + continue + } + if apiErr.StatusCode != http.StatusConflict { + break // not a retryable merge conflict } t.Logf("Merge attempt %d: 409 conflict, updating PR branch and retrying", attempt+1) diff --git a/e2e/admin/admin_test_helpers_test.go b/e2e/admin/admin_test_helpers_test.go new file mode 100644 index 0000000000..3a05e54232 --- /dev/null +++ b/e2e/admin/admin_test_helpers_test.go @@ -0,0 +1,52 @@ +//go:build e2e + +package admin + +import ( + "fmt" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + gh "github.com/fullsend-ai/fullsend/internal/forge/github" +) + +func TestIsConcurrentHeadUpdate(t *testing.T) { + tests := []struct { + name string + err error + want bool + }{ + { + name: "wrapped update-branch head race", + err: fmt.Errorf("merge failed: %w", &gh.APIError{ + StatusCode: http.StatusUnprocessableEntity, + Message: "expected head sha didn’t match current head ref", + }), + want: true, + }, + { + name: "other unprocessable entity", + err: &gh.APIError{ + StatusCode: http.StatusUnprocessableEntity, + Message: "pull request is not mergeable", + }, + want: false, + }, + { + name: "merge conflict", + err: &gh.APIError{ + StatusCode: http.StatusConflict, + Message: "head branch is out of date", + }, + want: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equal(t, tt.want, isConcurrentHeadUpdate(tt.err)) + }) + } +}