Skip to content

Match Fish completions against the full command path - #6959

Merged
tim-smart merged 2 commits into
mainfrom
audit/repro-unstable-cli-fish-command-path
Aug 4, 2026
Merged

Match Fish completions against the full command path#6959
tim-smart merged 2 commits into
mainfrom
audit/repro-unstable-cli-fish-command-path

Conversation

@fubhy

@fubhy fubhy commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

Match nested Fish completion rules against every command in the active parent path. This prevents commands that reuse a nested subcommand name under different parents from activating completions from unrelated branches.

The regression test remains in the main completion test file and asserts the generated Fish predicates directly, so it does not require the fish binary in CI.

Closes EFF-405

Validation

pnpm test --run packages/effect/test/unstable/cli/completions/completions.test.ts
pnpm lint-fix
pnpm check

Audit provenance

  • Audit ID: unstable-ai-cli-fish-nested-command-path
  • Audit base: c9b56ab507f224426ee8388dc450da447ec4715f
  • Severity / confidence: medium / high

@fubhy fubhy added the audit Findings originating from the Effect runtime correctness audit label Aug 4, 2026
@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4825ff4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

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

@effect-slopcop effect-slopcop Bot added 4.0 bug Something isn't working labels Aug 4, 2026
@fubhy
fubhy requested a review from IMax153 August 4, 2026 10:15

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

This PR currently ships only the failing regression test. Before merging, the implementation fix and a way to run the Fish test in CI must be included.

Reviewed changes

The PR adds a single Fish integration test to packages/effect/test/unstable/cli/completions/completions.test.ts that reproduces a bug where nested completions are gated only by the immediate parent subcommand name, so a child subcommand reused under different parents leaks completions from the wrong branch.

  • Added a test that shells out to fish to assert tool alpha common -- only offers --alpha-only.
  • Added an execFileSync import from node:child_process.

⚠️ Implementation fix is required before merge

The PR title and description say the implementation fix should land in this branch. In packages/effect/src/unstable/cli/internal/completions/fish.ts, subcommandCondition currently only checks parentPath[parentPath.length - 1]. For branches that share a child subcommand name, completion conditions need to match the full command path (all ancestors) rather than only the direct parent. Without that fix, this PR leaves CI intentionally red.

🚨 The test depends on the fish binary, which is not installed in CI

The new test calls execFileSync("fish", ...). On this runner — and in the current GHA setup, where .github/actions/setup/action.yaml only installs Node/pnpm/deno/bun — the binary is absent, so the test fails with spawnSync fish ENOENT before it can exercise the intended bug.

Suggested options:

  • Convert this to a generated-script assertion (for example, assert that the generated -n condition for the duplicated common path includes all ancestors). This keeps the regression deterministic and avoids a new runtime dependency.
  • If runtime Fish verification is intentional, install fish in CI and/or guard the test so it is skipped when the binary is unavailable.

ℹ️ Nitpicks

  • Description/file mismatch: the PR body references packages/effect/test/unstable/cli/FishCommandPath.audit.test.ts, but the diff edits packages/effect/test/unstable/cli/completions/completions.test.ts.
  • Formatting: pnpm dprint check flags the new import order and the long inline alpha subcommand object; run pnpm dprint fmt.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/effect/test/unstable/cli/completions/completions.test.ts Outdated
Comment thread packages/effect/test/unstable/cli/completions/completions.test.ts Outdated

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Since the prior review, the PR added the missing implementation fix and reworked the regression test to avoid a CI runtime dependency.

  • Fixed subcommandCondition in fish.ts to match the full parent path (parentPath.map(...).join("; and ")) instead of only the immediate parent, so duplicate nested subcommand names under different ancestors no longer share completion conditions.
  • Replaced the runtime Fish test with generated-script assertions in completions.test.ts, verifying that flags under alpha common and beta common are gated by __fish_seen_subcommand_from alpha; and __fish_seen_subcommand_from common and __fish_seen_subcommand_from beta; and __fish_seen_subcommand_from common respectively.
  • Added .changeset/fix-fish-command-path.md as a patch changeset for effect.
  • Removed the execFileSync import and the dependency on the fish binary; pnpm dprint check now passes.

Both prior Pullfrog review threads are resolved by 4825ff4.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 7.06 KB 7.06 KB 0.00 KB (0.00%)
batching.ts 9.86 KB 9.86 KB 0.00 KB (0.00%)
brand.ts 6.34 KB 6.34 KB 0.00 KB (0.00%)
cache.ts 10.62 KB 10.71 KB -0.09 KB (-0.81%)
config.ts 20.60 KB 20.60 KB 0.00 KB (0.00%)
differ.ts 20.20 KB 20.20 KB 0.00 KB (0.00%)
http-client.ts 21.49 KB 21.58 KB -0.09 KB (-0.41%)
logger.ts 10.76 KB 10.84 KB -0.08 KB (-0.76%)
metric.ts 8.98 KB 8.98 KB 0.00 KB (0.00%)
optic.ts 7.18 KB 7.18 KB 0.00 KB (0.00%)
pubsub.ts 14.90 KB 14.99 KB -0.09 KB (-0.57%)
queue.ts 11.58 KB 11.66 KB -0.08 KB (-0.68%)
schedule.ts 10.74 KB 10.83 KB -0.09 KB (-0.80%)
schema-class.ts 19.14 KB 19.14 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.96 KB 28.96 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.29 KB 25.29 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.30 KB 13.38 KB -0.09 KB (-0.64%)
schema-string.ts 10.94 KB 10.94 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.17 KB 15.17 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.94 KB 21.94 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.34 KB 24.34 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.18 KB 19.18 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.01 KB 19.01 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.87 KB 18.87 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.60 KB 22.60 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.52 KB 19.52 KB 0.00 KB (0.00%)
schema.ts 18.41 KB 18.41 KB 0.00 KB (0.00%)
stm.ts 12.54 KB 12.63 KB -0.09 KB (-0.74%)
stream.ts 9.80 KB 9.80 KB 0.00 KB (0.00%)

@tim-smart
tim-smart merged commit 6bde7f2 into main Aug 4, 2026
20 checks passed
@tim-smart
tim-smart deleted the audit/repro-unstable-cli-fish-command-path branch August 4, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 audit Findings originating from the Effect runtime correctness audit bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants