Skip to content

test: add regression test for exec store identity propagation (#391)#700

Merged
julianknutsen merged 3 commits intogastownhall:mainfrom
sjarmak:fix/391-exec-store-identity-regression-test
Apr 20, 2026
Merged

test: add regression test for exec store identity propagation (#391)#700
julianknutsen merged 3 commits intogastownhall:mainfrom
sjarmak:fix/391-exec-store-identity-regression-test

Conversation

@sjarmak
Copy link
Copy Markdown
Contributor

@sjarmak sjarmak commented Apr 14, 2026

Summary

The maintainer's investigation comment identified this as the remaining work to close #391:

The automated test suite does not currently cover this regression path — a multi-store exec regression test at the openRigStore/buildStores level is needed before this issue can be closed.

Closes #391

Test plan

  • go test -run TestBuildStores_ExecProviderSetsPerRigEnv -v ./cmd/gc/ — PASS
  • go test -race -run TestBuildStores_ExecProviderSetsPerRigEnv ./cmd/gc/ — PASS
  • go vet ./cmd/gc/ — clean
  • make build — PASS
  • make check — baseline-only failure (TestHandleProviderReadinessReturnsNotInstalledWhenBinaryMissing, env-dependent, fails identically on clean main)

🤖 Generated with Claude Code

@sjarmak sjarmak requested a review from julianknutsen as a code owner April 14, 2026 01:51
Copilot AI review requested due to automatic review settings April 14, 2026 01:51
@github-actions github-actions Bot added the status/needs-triage Inbox — we haven't looked at it yet label Apr 14, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Go regression test to prevent recurrence of #391 by asserting that buildStores correctly propagates per-rig identity environment variables to exec-based beads stores (GC_BEADS=exec:<script>), ensuring multi-prefix rigs don’t accidentally share the same exec-store identity.

Changes:

  • Add TestBuildStores_ExecProviderSetsPerRigEnv to validate per-rig GC_BEADS_PREFIX, BEADS_DIR, GC_RIG_ROOT, and GC_RIG propagation for exec beads providers.
  • Add strings import to support env-contents assertions in the new test.

Comment thread cmd/gc/api_state_test.go Outdated
Comment on lines +269 to +276
// Cross-rig assertion: the two rigs must have received different prefixes.
// This is the exact regression from #391 — before PR #421, both stores
// got identical env, so the last rig's prefix silently won.
alphaEnv, _ := os.ReadFile(filepath.Join(envDir, "alpha.env"))
bravoEnv, _ := os.ReadFile(filepath.Join(envDir, "bravo.env"))
if string(alphaEnv) == string(bravoEnv) {
t.Errorf("regression: alpha and bravo exec stores received identical env — "+
"store identity is not being propagated per rig:\n%s", string(alphaEnv))
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cross-rig assertion compares the entire captured env output as a raw string. env line ordering is not guaranteed, so two stores could have identical key/value pairs but different line order and this check would miss the regression (false negative). Consider parsing the file into a map (split lines on =) and comparing the relevant keys (or at least compare GC_BEADS_PREFIX values directly) instead of comparing the full string dump.

Copilot uses AI. Check for mistakes.
@sjarmak
Copy link
Copy Markdown
Contributor Author

sjarmak commented Apr 14, 2026

Addressed Copilot's inline feedback on the cross-rig assertion (606d753): now extracts and compares GC_BEADS_PREFIX values directly instead of comparing raw env output, avoiding the false-negative risk from non-deterministic line ordering (Go map iteration in exec.Store.run()).

@julianknutsen julianknutsen added priority/p2 Medium — real problem, workaround exists kind/chore Internal improvement (refactor, tests, CI, tooling) dolt and removed status/needs-triage Inbox — we haven't looked at it yet labels Apr 14, 2026
@julianknutsen julianknutsen added this to the 1.0 milestone Apr 14, 2026
@sjarmak sjarmak force-pushed the fix/391-exec-store-identity-regression-test branch from 606d753 to d98267d Compare April 18, 2026 15:46
sjarmak added 3 commits April 19, 2026 17:58
…nhall#391)

Add TestBuildStores_ExecProviderSetsPerRigEnv verifying that buildStores
passes distinct GC_BEADS_PREFIX, BEADS_DIR, GC_RIG_ROOT, and GC_RIG env
vars to each rig's exec store. Before PR gastownhall#421, all exec stores shared
identical env — the last rig's prefix silently won, causing a
create→orphan loop in K8s multi-prefix deployments.

Closes gastownhall#391
Address Copilot review feedback: env line ordering is non-deterministic
due to Go map iteration in exec.Store.run(), so comparing raw env output
could produce false negatives. Extract and compare GC_BEADS_PREFIX values
directly instead.
…moved, BEADS_DIR intentionally empty)

PR gastownhall#790 rewrote the exec store env contract:
- writeTempScript helper was removed (commit c6081e5) — inline the tempdir write
- exec stores now set BEADS_DIR="" by design (store_target_exec.go:55);
  scope is communicated via GC_RIG_ROOT / GC_STORE_ROOT

Update the regression test to match the new contract:
- inline t.TempDir + os.WriteFile for the provider script
- drop the BEADS_DIR=<rig>/.beads positive assertion
- add a negative assertion that BEADS_DIR does NOT get a rig-specific path
  (would indicate regression back to the pre-gastownhall#790 projection model)

The original gastownhall#391 regression (all exec stores sharing identical env) is still
covered by the per-rig GC_BEADS_PREFIX / GC_RIG_ROOT / GC_RIG assertions and
the cross-rig prefix-differ check.
@sjarmak sjarmak force-pushed the fix/391-exec-store-identity-regression-test branch from d98267d to 6e42099 Compare April 19, 2026 22:00
@julianknutsen julianknutsen merged commit 2ccb4d5 into gastownhall:main Apr 20, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dolt kind/chore Internal improvement (refactor, tests, CI, tooling) priority/p2 Medium — real problem, workaround exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: exec beads provider ignores store identity on CRUD operations, breaking K8s multi-prefix

3 participants