Skip to content

[AUTOMATION] fix: optimize build env assembly#289

Open
michiosw wants to merge 1 commit into
mainfrom
fix/optimize-build-env-assembly
Open

[AUTOMATION] fix: optimize build env assembly#289
michiosw wants to merge 1 commit into
mainfrom
fix/optimize-build-env-assembly

Conversation

@michiosw

Copy link
Copy Markdown
Contributor

Summary
This optimizes build env assembly by preallocating the final slice once.

Before this, resolved credential entries were appended onto a copied base slice in internal/credential/credential.go, which left the runtime env path doing extra growth work on every run.

Now one pre-sized slice is the canonical path:

env := make([]string, 0, len(base)+len(resolved))
env = append(env, base...)

Why
This gives kontext-cli a cheaper runtime path for env setup:

run startup
-> credential.BuildEnv
-> final agent env slice

This PR does not broaden behavior beyond the optimization scope.

What changed
Optimized env slice assembly in internal/credential/credential.go
Removed repeated slice growth while appending resolved credentials
Preserved env ordering and base-slice isolation
Updated tests for base-slice mutation and output order

Verification
go test ./internal/credential
go test ./internal/run
go test ./...
go vet ./...
git diff --check

Summary
This optimizes build env assembly by preallocating the final slice once.

Before this, resolved credential entries were appended onto a copied base slice in , which left the runtime env path doing extra growth work on every run.

Now one pre-sized slice is the canonical path:

Why
This gives kontext-cli a cheaper runtime path for env setup:

run startup
->
-> final agent env slice

This PR does not broaden behavior beyond the optimization scope.

What changed
Optimized env slice assembly in
Removed repeated slice growth while appending resolved credentials
Preserved env ordering and base-slice isolation
Updated tests for base-slice mutation and output order

Verification
go test ./internal/credential
go test ./internal/run
go test ./...
go vet ./...
git diff --check

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR optimizes credential environment assembly without changing the intended output order. The main changes are:

  • Preallocates the final environment slice in credential.BuildEnv.
  • Copies base environment entries with append(env, base...) before resolved credentials.
  • Adds coverage for output order and base-slice isolation.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (1): Last reviewed commit: "fix: optimize build env assembly" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant