Skip to content

confirm → suggest fallback in resolver is unreachable from the engine #6

Description

@nimser

What happened?

src/resolver/action-resolver.ts:131-158 (resolveConfirm) attempts to fall back from confirm to suggest when ctx.replacement is set. But the engine never sets a replacement for confirm actions.

In src/engine/engine.ts:124-125, the engine reads:

const replacement =
  'replacement' in rule.defaultAction ? rule.defaultAction.replacement : undefined

A confirm action has no replacement field (see src/core/types.ts:19), so replacement is always undefined when the engine calls resolveAction. The check if (capabilities.suggest && ctx.replacement) at action-resolver.ts:146 is always false for confirm rules coming from the engine.

The unit test in src/resolver/action-resolver.test.ts:165-186 passes only because it constructs a custom ResolveContext with replacement: 'safe-cmd' — that branch is never reached in production.

Result: a confirm action with no fallback always ends up at fallbackBlock in real engine flow, never at suggest.

What did you expect to happen?

Either the engine should pass a meaningful replacement for confirm actions, or the unreachable confirm → suggest branch in the resolver should be removed to avoid misleading future maintainers.

Steps to reproduce

  1. Define a rule with action: { type: 'confirm' } and no fallback
  2. Call engine.evaluate({ ... }) with capabilities.confirm: true
  3. Observe the resolver enters resolveConfirm, the suggest branch is skipped, and the action becomes fallbackBlock

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions