Ruflo
Ruflo router source analysis: word boundaries, rule order and stale snapshots
Reproduce how generated routing differs from the root snapshot, why first-match order matters and why a heuristic confidence must not be sold as model accuracy.
What you will learn
- Find the generator before testing the helper
- Understand both the improvement and the limit
- Reproduce a small independent model
Before you start
- Basic Node.js, Git and command-line knowledge
- An owned repository and an explicit task/permission boundary
Explain the chapter’s implementation and reproduce its bounded check without mistaking a helper for a complete runtime.
Key takeaways
- Test generated output and active workspace files separately.
- Word boundaries remove some substring errors, not first-match ambiguity.
- Fixed heuristic priors are not measured model accuracy.
Find the generator before testing the helper
The reviewed smoke test points to generateAgentRouter in helpers-generator.ts as its source of truth. That function returns a complete JavaScript helper; generateHelpers includes it when the helpers component is selected. Our probe selected that exact function from the TypeScript syntax tree, verified the source hash and evaluated its output with fake process arguments and no filesystem writes.
The root snapshot was tested separately. For “review latest issues,” its unbounded test substring can match inside latest and select tester before reaching review. The current generated helper selects reviewer. This is not evidence that every installed project has already been upgraded: an existing workspace may still execute an old helper.
Understand both the improvement and the limit
Single tokens in the generated helper receive word-boundary anchors; phrases containing whitespace or a slash are escaped and matched literally. Patterns are precompiled, then traversed in table order. A mixed request such as “review and add tests” selects coder because the earlier coder entry matches add. The helper does not rank all matching agents or infer which clause is most important.
Matched and fallback priors are fixed at 0.6 and 0.3. They are not calibrated from this task or measured against user outcomes. English keyword rules also do not establish multilingual routing quality. If a product needs reliable language-aware selection or multi-label routing, evaluate that requirement separately rather than extrapolating from the helper’s simple table.
Reproduce a small independent model
The example below keeps only three roles to expose boundary and ordering behavior. It returns reviewer for the first task, coder for the mixed task, and fallback for a word that only contains ci internally. It is an independent teaching model, not the complete eight-role generator, and its outputs are tested in all three article editions.
For an upgrade check, retain both positive requests and near-miss words such as decision and specifications. Compare the actual active helper’s output before and after the change, along with its revision and reason string. A routing regression can be detected without starting agents, but correct routing alone still cannot establish that the selected agent completed the task.
Implementation steps
- 1
Locate generateAgentRouter and the active helper.
- 2
Compare positive and near-miss phrases.
- 3
Test a request containing multiple role keywords.
- 4
Record routing separately from downstream task acceptance.
Copy-ready example
function chooseRole(task) {
const rules = [[/\b(?:add|build)\b/i,"coder"],[/\btest\b/i,"tester"],[/\breview\b/i,"reviewer"]];
return rules.find(([pattern]) => pattern.test(task))?.[1] ?? "fallback";
}
console.log(["review latest issues","review and add tests","make a decision"].map(chooseRole));Frequently asked questions
Was a real agent launched by the router probe?
No. It evaluated the generated helper with fake process arguments and tested its returned suggestion only.
Why not report 0.6 as a 60% success rate?
The source labels that number a heuristic prior. No outcome dataset calibrated it into a probability.
Sources
- v3/@claude-flow/cli/src/init/helpers-generator.tsSource checked 2026-09-08
- .claude/helpers/router.cjsSource checked 2026-09-08
- scripts/smoke-router-regex.mjsSource checked 2026-09-08