Skip to content

fix: resolve namespace-qualified references in step-level with parame…#317

Merged
eskenazit merged 2 commits intomainfrom
fix/step-with-namespace-resolution
Apr 14, 2026
Merged

fix: resolve namespace-qualified references in step-level with parame…#317
eskenazit merged 2 commits intomainfrom
fix/step-with-namespace-resolution

Conversation

@jlouvel
Copy link
Copy Markdown
Contributor

@jlouvel jlouvel commented Apr 13, 2026

Related Issue

Closes #290


What does this PR do?

Fixes namespace-qualified references (e.g. shipyard-tools.voyageId) in step-level with blocks not being resolved during orchestrated step execution.

Root cause: OperationStepExecutor.executeCallStep() passed null as the namespace to mergeWithParameters(), so the namespace.param resolution branch was never entered — values were treated as literal strings instead of being resolved to the caller's argument.

Fix (production — 6 files):

  • OperationStepExecutor — Added exposeNamespace field + setExposeNamespace() setter; pass it to mergeWithParameters in executeCallStep() and findClientRequestFor(ServerCallSpec, ...)
  • ToolHandler — Set exposeNamespace on the executor after construction
  • ResourceHandler — Set exposeNamespace on the executor after construction
  • ResourceRestlet — Set exposeNamespace on the executor after construction
  • AggregateFunction — Added namespace field to constructor; pass it to mergeWithParameters for function-level with; set stepExecutor.setExposeNamespace(namespace) before orchestrated execution
  • Aggregate — Pass parent namespace to AggregateFunction constructor

Tests

Unit tests (3):

  • OperationStepExecutorTest.mergeWithNullNamespaceShouldNotResolveQualifiedReference — documents that null namespace keeps literal strings
  • OperationStepExecutorBranchTest.executeStepsShouldResolveNamespaceQualifiedReferencesInStepWith — captures parameters via subclass to verify step-level resolution
  • AggregateFunctionTest.executeShouldResolveNamespaceQualifiedReferencesInFunctionWith — mock-mode function with namespace-qualified with resolves to caller's value

Integration tests (2):

  • StepWithNamespaceIntegrationTest — loads MCP capability YAML, verifies namespace-qualified reference in step with resolves through full executor chain
  • AggregateStepNamespaceIntegrationTest — loads aggregate capability YAML, executes function with orchestrated steps, verifies namespace resolution in HTTP URL

Test fixtures (2):

  • mcp-step-with-namespace-capability.yaml — MCP tool with namespace-qualified step with
  • aggregate-step-with-namespace.yaml — aggregate function with namespace-qualified step with

All 463 tests pass (0 failures, 5 skipped).


Checklist

  • CI is green (build, tests, schema validation, security scans)
  • Rebased on latest main
  • Small and focused — one concern per PR
  • Commit messages follow Conventional Commits

Agent Context (optional)

agent_name: GitHub Copilot
llm: Claude Opus 4.6
tool: VS Code Chat
confidence: high
source_event: issue_290
discovery_method: user_report
review_focus: AggregateFunction.java:43-119, OperationStepExecutor.java:64-72,283-288,371-376

@jlouvel jlouvel requested a review from eskenazit April 13, 2026 21:04
@jlouvel jlouvel self-assigned this Apr 13, 2026
@eskenazit eskenazit force-pushed the fix/step-with-namespace-resolution branch 2 times, most recently from 4e4e630 to a6ecc29 Compare April 14, 2026 08:42
Comment thread src/main/java/io/naftiko/engine/exposes/OperationStepExecutor.java
Comment thread src/main/java/io/naftiko/engine/aggregates/AggregateFunction.java Outdated
@jlouvel
Copy link
Copy Markdown
Contributor Author

jlouvel commented Apr 14, 2026

@eskenazit Comments addressed. Could you review again?

jlouvel added 2 commits April 14, 2026 08:56
…ters

OperationStepExecutor.executeCallStep() passed null as namespace to
mergeWithParameters(), so namespace-qualified references like
shipyard-tools.voyageId in step-level with blocks were treated as
literal strings instead of being resolved to the caller's argument.

Propagate the expose namespace from ToolHandler, ResourceHandler, and
ResourceRestlet into the step executor. Apply the same fix to
AggregateFunction, which also passed null for both function-level and
step-level with blocks.

Closes #290
Move setExposeNamespace before the orchestrated/simple-call branch so both paths receive the namespace. Add a constructor overload to OperationStepExecutor that accepts the namespace, and update handlers to use it instead of the two-step construct-then-set pattern. Refactor integration test to use a parameter-capturing executor for deterministic assertions.
@jlouvel jlouvel force-pushed the fix/step-with-namespace-resolution branch from 11fbf64 to 7f1ab55 Compare April 14, 2026 12:56
Copy link
Copy Markdown
Contributor

@eskenazit eskenazit left a comment

Choose a reason for hiding this comment

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

LGTM

@eskenazit eskenazit merged commit cbee308 into main Apr 14, 2026
4 checks passed
@eskenazit eskenazit deleted the fix/step-with-namespace-resolution branch April 14, 2026 13:30
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.

fix: OperationStepExecutor does not resolve namespace-qualified references in step-level WithInjector

2 participants