Chore/remove old const behavior and refactor mocking#287
Merged
Conversation
46a7f71 to
21a7bbf
Compare
eskenazit
requested changes
Apr 9, 2026
.agents/skills/naftiko-capability/references/mock-capability.md
Outdated
Show resolved
Hide resolved
Contributor
Author
|
@eskenazit Should be good now :) |
Contributor
|
I cannot rebase the branch "due to conflicts" =/ |
Replace runtime const injection with a dedicated value field on MappedOutputParameter. The const field is now schema-only (validation and linting); value handles static and Mustache-templated output at runtime. - Add value field to OutputParameterSpec with serializer/deserializer - Resolver.resolveOutputMappings resolves Mustache templates in value - ResourceRestlet mock responses use value with template resolution - ToolHandler supports mock mode (no call/steps) via value fields - HttpClientAdapter headers use getValue instead of getConstant - Update naftiko-schema.json: add value, update oneOf constraints - Update wiki: FAQ, Use Cases, Schema specification
…consistency Extract buildMockData and buildMockValue from ResourceRestlet into Resolver as shared static methods. Both REST (sendMockResponse) and MCP (buildMockToolResult) now delegate to the same mock builder, ensuring consistent Mustache resolution and structure handling.
Add mock-capability.md reference story covering static and dynamic (Mustache) mock output parameters for both MCP and REST adapters. Update SKILL.md decision table, add Mock workflow section, and add hard constraints 17-18 for const vs value and Mustache scope rules.
Replace runtime const injection with a dedicated value field on MappedOutputParameter. The const field is now schema-only (validation and linting); value handles static and Mustache-templated output at runtime. - Add value field to OutputParameterSpec with serializer/deserializer - Resolver.resolveOutputMappings resolves Mustache templates in value - ResourceRestlet mock responses use value with template resolution - ToolHandler supports mock mode (no call/steps) via value fields - HttpClientAdapter headers use getValue instead of getConstant - Update naftiko-schema.json: add value, update oneOf constraints - Update wiki: FAQ, Use Cases, Schema specification
…consistency Extract buildMockData and buildMockValue from ResourceRestlet into Resolver as shared static methods. Both REST (sendMockResponse) and MCP (buildMockToolResult) now delegate to the same mock builder, ensuring consistent Mustache resolution and structure handling.
Nested object properties with 'value' (mock mode) were misrouted to setMapping() because the property key was injected as 'name' into the JSON node before the recursive dispatch, triggering the (value && name) branch. Fix: set name on the spec after deserialization so the dispatch logic sees the original node content. Also fixes duplicate properties caused by processing the 'properties' block twice. Adds 3 regression tests covering nested value, nested mapping, and consumed output parameter backward compatibility.
100ca02 to
6145eca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Closes #189
What does this PR do?
Adds mock mode to MCP tools (and strengthens the existing REST mock mode) via a new
valuefield onMappedOutputParameter.Design choice vs the issue proposal: The issue proposed a
mock.outputblock. This PR usesvaluedirectly on output parameters instead — consistent with howConsumedOutputParameteralready usesvaluefor JSONPath, and usable on both MCP and REST adapters without a separate mock-only key. Theconstfield is preserved for JSON Schema validation and linting (Spectral) but no longer has any runtime effect.Changes:
OutputParameterSpec— newvaluefield; serializer/deserializer updatedResolver.resolveOutputMappings—valuetakes precedence overmapping; Mustache templates invalueresolved against input parametersResolver.buildMockData/buildMockValue— shared mock builder extracted intoResolverso REST and MCP use identical logicToolHandler— mock mode: when a tool has nocalland nosteps, output parameters withvaluefields are served directly (noconsumesblock needed)ResourceRestlet— mock path delegates to sharedResolver.buildMockData; input parameters threaded through for Mustache resolutionHttpClientAdapter— headers usegetValue()instead ofgetConstant()naftiko-schema.json—valueadded toMappedOutputParameterBase;constdescription updated to schema-only;oneOfconstraints updated tomapping | valuevalueand dynamic mock examplesnaftiko-capability) — newmock-capability.mdreference story; decision table and hard constraints updatedTests
ResolverTest— 2 new tests:resolveOutputMappingsShouldResolveMustacheTemplatesInValue,resolveOutputMappingsShouldReturnRawValueWhenNoParametersResourceRestletTest—buildMockValueShouldHandleObjectArrayAndPrimitiveFallback,buildMockValueShouldResolveMustacheTemplatesInValue; existing mock tests updated to new signaturesToolHandlerTest— 2 tests updated: no-call/no-steps tools now return mock response instead of throwingAuthenticationIntegrationTest— inline YAML updated fromconst: "ok"tovalue: "ok"OutputMappingExtensionTest—setConstant→setValueChecklist
mainAgent Context (optional)