Skip to content

fix(env): add host-local command resolution#34

Merged
roodboi merged 10 commits into
mainfrom
dimitri/web-local-dev-rough-edges
Mar 31, 2026
Merged

fix(env): add host-local command resolution#34
roodboi merged 10 commits into
mainfrom
dimitri/web-local-dev-rough-edges

Conversation

@roodboi

@roodboi roodboi commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • default hack env exec and hack env shell to a host-local env view, with --target compose to preserve the container view when needed
  • support an explicit host scope in modern env configs and stop warning on sibling service scopes during hack run
  • normalize legacy global encrypted-file secret paths and ignore local secret artifacts in the repo

Verification

  • bun test tests/env-exec-command.test.ts tests/project-run-command.test.ts tests/project-env-config.test.ts
  • bun test tests/env-backend-command.test.ts
  • bun run typecheck
  • bun x ultracite check src/commands/env.ts src/commands/project.ts src/lib/project-env-config.ts tests/env-exec-command.test.ts tests/project-run-command.test.ts
  • external repro against /Users/hack/dev/external/TeamSidewinder/event-agent using the in-repo CLI entrypoint
    • env exec rewrites DATABASE_URL and REDISHOST to host-local values
    • run core -- bun --version no longer warns on valid compose services

Follow-up

  • Remaining alias-style env scope warning tracked in T-NZ7FAS3NRY (example-native in event-agent)

@changeset-bot

changeset-bot Bot commented Mar 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cc5d833

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d54a6ed335

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/project-env-config.ts Outdated
return selected;
}

const hostOverrides = opts.resolved.serviceEnv[PROJECT_ENV_HOST_SCOPE];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Merge only host-scope values for host target

selectProjectEnvValuesForExecutionTarget pulls hostOverrides from resolved.serviceEnv["host"], but entries in serviceEnv already include all global keys. When hack env exec/shell is run with --service <name> (default --target host) and a host scope exists, spreading hostOverrides after the selected service env can overwrite service-specific overrides with global defaults for any shared key (for example, a service-specific PORT or DATABASE_URL gets reset even if host does not define it). This produces incorrect injected env values for host commands.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6aae1133d2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +124 to +128
const hostOverrides = opts.resolved.hostEnv;
if (!hostOverrides) {
return selected;
}
return {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent host scope from colliding with service scope

Merging resolved.hostEnv for every target: "host" execution makes values.host a global host-command override regardless of the requested service. In projects that already have a compose service named host, that service’s env scope now leaks into unrelated commands (for example, hack env exec --service api inherits values.host), which is a behavioral regression introduced by this commit. Please add collision handling (reserve host with validation/warning, or disambiguate service-vs-host scopes) so existing host services do not silently change env injection.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d1fe09e7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/project.ts Outdated
Comment on lines +5301 to +5305
const stackIsRunning =
(await readProjectRuntimeStateEntry({
projectDir: project.projectDir,
composeProject: composeProjectName ?? baseProjectName,
})) !== null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check live stack state before setting --no-deps

handleRun treats the presence of a runtime-state entry as proof the stack is currently running and then sets noDeps, which makes composeRuntimeBackend.run append --no-deps (so dependencies are not started). Because runtime-state is only keyed by compose project and is persisted by any prior up call, this can be stale or incomplete (for example after starting only some profiles/services), causing hack run to skip needed dependency startup and fail at runtime when the target service expects those deps. Please gate noDeps on actual running state (or at least matching active services/profiles), not just the cached state file entry.

Useful? React with 👍 / 👎.

@roodboi
roodboi merged commit fe6c409 into main Mar 31, 2026
3 checks passed
@roodboi
roodboi deleted the dimitri/web-local-dev-rough-edges branch March 31, 2026 21:33
roodboi pushed a commit that referenced this pull request Mar 31, 2026
## <small>2.0.1 (2026-03-31)</small>

* Merge branch 'main' into dimitri/web-local-dev-rough-edges ([a1419b2](a1419b2)), closes [dimitri/web-local-dev-rou#edges](https://github.com/dimitri/web-local-dev-rou/issues/edges)
* Merge pull request #34 from hack-dance/dimitri/web-local-dev-rough-edges ([fe6c409](fe6c409)), closes [#34](#34) [hack-dance/dimitri/web-local-dev-rou#edges](https://github.com/hack-dance/dimitri/web-local-dev-rou/issues/edges)
* fix(ci): stabilize secret scan and host env docs ([581ea34](581ea34))
* fix(env): add host-local command resolution ([d54a6ed](d54a6ed))
* fix(env): normalize encrypted backend key paths ([b65ee8e](b65ee8e))
* fix(env): preserve service overrides for host target ([6aae113](6aae113))
* fix(runtime): avoid run dependency collisions ([6d1fe09](6d1fe09))
* fix(runtime): gate run no-deps on live state ([94c9785](94c9785))
* fix(runtime): narrow run env selection type ([cc5d833](cc5d833))
* fix(web): allow routed local dev origins ([82e706f](82e706f))
* fix(web): stabilize local dev runtime ([28fe25b](28fe25b))

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc5d83393c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/project.ts
Comment on lines +5337 to +5339
opts.requestedEnvName !== null &&
runtimeState?.envName !== null &&
runtimeState?.envName !== opts.requestedEnvName

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat null runtime env as mismatch for hack run --env

resolveCanSkipRunDependencies only rejects env mismatches when runtimeState.envName is non-null, so hack run --env qa ... will still set noDeps if the currently running stack was recorded as base (envName: null) and the target service is up. That causes docker compose run --no-deps (documented as “Don’t start linked services”) to skip dependency startup even though the requested env differs, which can run against stale/missing dependencies. Compare the stored env and requested env directly (including null) before enabling --no-deps.

Useful? React with 👍 / 👎.

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