feat: add step handler registry for library embedding#395
Conversation
|
@eskenazit This is a dependency for Polychro built-in MCP server |
c093ac4 to
8630f8b
Compare
8630f8b to
9015388
Compare
eskenazit
left a comment
There was a problem hiding this comment.
Review from Claude Sonnet 4.6
9015388 to
cc1173b
Compare
|
@eskenazit Should be good now |
eskenazit
left a comment
There was a problem hiding this comment.
Good progress — 4 of 5 threads are resolved. One non-blocking item remains before merge.
Still open: ConcurrentHashMap on local variables in OperationStepExecutor\nThe resolved copy-for-with was fixed, but params, runtimeParameters (top of executeSteps) and stepParams (in mergeStepParameters) are still ConcurrentHashMap. All three are single-threaded stack variables; HashMap is the right type.
New nit: Javadoc @code example in Capability.Builder still shows .capabilityFromClasspath(...) — should be .loadFromClasspath(...) to match the actual API.
Everything else looks clean: the blocking error-message fix, the registry hoisting, the encoding, the test assertions, and the test deduplication are all good.
|
@eskenazit Should be good now |
Provide a programmatic embedding API that allows Java applications to use the Naftiko Framework as a library. Embedders register StepHandler implementations by step name; when the engine encounters a registered step during execution, it delegates to the handler instead of the normal call/script/lookup path. Key components: - StepHandler interface (receives context, returns JsonNode) - StepHandlerContext (immutable view of execution context) - StepHandlerRegistry (maps step names to handlers) - NaftikoEngine.builder() (fluent API to load YAML and register handlers) - Integration into OperationStepExecutor (registry check before dispatch) The Naftiko Specification (naftiko-schema.json) remains unchanged. Closes #394
Add enabled guard to TelemetryBootstrap span factories and EngineMetrics recording methods. When disabled, span methods return Span.getInvalid() immediately — no string concatenation, no SpanBuilder allocation, no Attributes construction. In embedded library mode (NaftikoEngine), telemetry is off by default. Embedders can opt in via .telemetry(true) on the builder.
Move the Builder inner class and builder() factory method directly into Capability, eliminating the NaftikoEngine wrapper. The embedding API is now Capability.builder()...build() returning a Capability directly. Rename NaftikoEngineBuilderTest to CapabilityBuilderTest and update EngineStepHandlerOverrideTest to use Capability.builder().
4ab52e5 to
5b0882e
Compare
Related Issue
Closes #394
What does this PR do?
Adds a programmatic embedding API that allows Java applications to use the Naftiko Framework as a library. Embedders register
StepHandlerimplementations by step name viaStepHandlerRegistry; when the engine encounters a registered step during orchestration, it delegates to the handler instead of the normal call/script/lookup path.Key components:
StepHandlerinterface — receivesStepHandlerContext, returnsJsonNodeStepHandlerContext— immutable view of execution context (input parameters, prior step outputs, with values)StepHandlerRegistry— maps step names to handlers, executes them with contextNaftikoEngine.builder()— fluent API to load YAML from classpath/file and register handlersOperationStepExecutor— registry check before normal dispatch (singlecontinuepath)The Naftiko Specification (
naftiko-schema.json) remains unchanged. This is the prerequisite for Polychro Phase 12 (MCP Server Mode).Tests
StepHandlerRegistryTest— 10 tests covering register/get/has/unregister/execute/null guardsStepHandlerContextTest— 8 tests covering accessibility, convenience methods, immutability, null safetyNaftikoEngineBuilderTest— 5 tests covering classpath loading, missing resource, handler registration, registry propagationEngineStepHandlerOverrideTest— 5 integration tests verifying handler override, normal path fallback, null output, multi-handler, and step chainingChecklist
mainAgent Context (optional)