You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SONA trajectories persist but are not consumed by hooks_route or indexed when steps are present #3662
In Ruflo 3.51.1, a successful hooks_intelligence_trajectory-end reports that SONA learned a pattern and persists it to .swarm/sona-patterns.json, but the normal hooks_route path does not consult that persisted SONA optimizer. In addition, trajectory feedback is only promoted to the semantic pattern store when the trajectory has no steps. The common start → step → end path therefore records SONA state without making the feedback searchable through hooks_intelligence_pattern-search.
This was reproduced against the installed 3.51.1 package before applying a local compatibility shim. The shim is not part of this report; this issue describes the vendor behavior and the integration test expected upstream.
Environment
Ruflo / bundled @claude-flow/cli: 3.51.1
Node.js: 26.10.0
OS: macOS on Apple Silicon
Embeddings status: ONNX, semanticGrounded: true
Reproduction
Call hooks_intelligence_trajectory-start with a task and agent.
Record at least one step with hooks_intelligence_trajectory-step.
Call hooks_intelligence_trajectory-end with success: true and non-empty feedback.
In a fresh process, inspect SONA state / query the same task through the public routing path, and search feedback with hooks_intelligence_pattern-search.
Actual behavior
trajectory-end returned sonaUpdate: true and a SONA pattern key; the pattern was written to .swarm/sona-patterns.json and reloaded by a fresh SONAOptimizer process.
hooks_route returned its AgentDB or local semantic/keyword route instead of a SONA-pattern route. The hooksRoute implementation tries bridgeRouteTask and then routeTaskLocal; it does not call SONAOptimizer.getRoutingSuggestion().
hooks_intelligence_pattern-search did not find the trajectory feedback. In hooksTrajectoryEnd, feedback promotion is gated on !hasSteps, so feedback from a trajectory that recorded steps is not indexed in the pattern namespace.
A single success increases SONA confidence from 0.50 to 0.55, below getRoutingSuggestion()'s 0.60 threshold. The response can therefore say “learned” even though one successful outcome is not yet eligible to affect routing; please clarify/document this evidence threshold or make the response explicit.
Relevant implementation areas in the published package:
A qualifying persisted SONA routing pattern is considered by the normal hooks_route inference path, with an explicit confidence/valid-agent gate and an identifiable result source; otherwise, trajectory-end should not imply that routing was improved.
Non-empty feedback is promoted to a durable, searchable pattern whether or not trajectory steps were recorded, with trajectory metadata and outcome confidence preserved.
Add a fresh-process regression test proving both that an eligible persisted SONA pattern affects hooks_route and that feedback from a stepful trajectory is found by semantic pattern search.
Keep process-local counters distinct from persisted counters in telemetry; hooks_intelligence_unified-stats already documents their different scopes.
Status: fixed tonight (partial): draft PR #4051; remainder needs human input
Verified both claims directly in v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts on current main (3.52.1). (1) hooksRoute/routeTaskLocal never call SONAOptimizer.getRoutingSuggestion() — confirmed getSuggestion/getRoutingSuggestion (src/memory/sona-optimizer.ts) have zero callers anywhere outside that file, so persisted SONA patterns never reach routing. This is real but architectural (precedence vs. the AgentDB pre-route and local semantic/keyword router, the confidence threshold the reporter also flags as ambiguous, and new response fields distinguishing "persisted" from "eligible for inference") — needs a human design call, not a guess from an unattended run. (2) hooksTrajectoryEnd's feedback promotion was gated on !hasSteps (line 3469), exactly as reported — #2351 only covered step-less trajectories. That half was small and mechanical, so I fixed it: removed the !hasSteps restriction and added __tests__/trajectory-feedback-indexing-3662.test.ts, which drives trajectory-start → trajectory-step → trajectory-end(feedback) → pattern-search end-to-end; confirmed it fails on current main (feedbackDistilled undefined) and passes with the fix, with no regressions in the related trajectory-recovery-3199/self-learning-2245/round-b-wiring-2245/hooks-intelligence-learning suites (25 tests). No duplicate or dream-cycle-labeled issue/PR covers this; #2222 and #1243 are related but closed and don't touch this gap.
The stepful-feedback half is fixed in #4051 (merged, 19c59a2): trajectory-end now promotes non-empty feedback to the pattern namespace even when steps were recorded, with an end-to-end regression test (start, step, end, pattern-search). It ships in the next release. The other half of this issue (hooks_route consulting persisted SONA patterns) is not covered by that PR, so I am leaving this open.
Activity
ruvnet commentedon Oct 11, 2026
Nightly triage — 2026-10-11
Status: fixed tonight (partial): draft PR #4051; remainder needs human input
Verified both claims directly in
v3/@claude-flow/cli/src/mcp-tools/hooks-tools.tson currentmain(3.52.1). (1)hooksRoute/routeTaskLocalnever callSONAOptimizer.getRoutingSuggestion()— confirmedgetSuggestion/getRoutingSuggestion(src/memory/sona-optimizer.ts) have zero callers anywhere outside that file, so persisted SONA patterns never reach routing. This is real but architectural (precedence vs. the AgentDB pre-route and local semantic/keyword router, the confidence threshold the reporter also flags as ambiguous, and new response fields distinguishing "persisted" from "eligible for inference") — needs a human design call, not a guess from an unattended run. (2)hooksTrajectoryEnd's feedback promotion was gated on!hasSteps(line 3469), exactly as reported —#2351only covered step-less trajectories. That half was small and mechanical, so I fixed it: removed the!hasStepsrestriction and added__tests__/trajectory-feedback-indexing-3662.test.ts, which drives trajectory-start → trajectory-step → trajectory-end(feedback) → pattern-search end-to-end; confirmed it fails on currentmain(feedbackDistilledundefined) and passes with the fix, with no regressions in the relatedtrajectory-recovery-3199/self-learning-2245/round-b-wiring-2245/hooks-intelligence-learningsuites (25 tests). No duplicate ordream-cycle-labeled issue/PR covers this; #2222 and #1243 are related but closed and don't touch this gap.Generated by Claude Code
Merge pull request #4051 from ruvnet/fix/3662-stepful-trajectory-feed…
fix(hooks): index trajectory-end feedback even when steps were record…
ruvnet commentedon Oct 11, 2026
The stepful-feedback half is fixed in #4051 (merged, 19c59a2): trajectory-end now promotes non-empty feedback to the pattern namespace even when steps were recorded, with an end-to-end regression test (start, step, end, pattern-search). It ships in the next release. The other half of this issue (hooks_route consulting persisted SONA patterns) is not covered by that PR, so I am leaving this open.