perf(skills): discover installed skills once per workflow lookup - #5523
perf(skills): discover installed skills once per workflow lookup#5523mysma-9403 wants to merge 1 commit into
Conversation
`get_workflow_with_profile` — the resolution seam behind `run_workflow` / `describe_workflow` — walked the skill roots twice per call: once inside `load_workflows_with_profile` (which discovers, then parses every skill's definition) and again for the display-name fallback, which re-ran `discover_workflows_with_profile` from scratch only to map a frontmatter name back to its slug. Extract two helpers — `discover_all` (prune + a single discovery walk) and `definitions_from_discovered` (builtins + parse each discovered skill) — and have `get_workflow_with_profile` discover once, feeding both the parsed- definition lookup and the name fallback from the same list. `load_workflows_with_profile` now delegates to the same helpers, so its behavior is unchanged. This is a behavior-preserving refactor: the parsed workflow list is identical (same builtins, same discovery, same per-skill parse), and the name fallback reads the same discovery it did before — just computed once instead of twice. The prune still runs before discovery in both paths. Removes one full root walk per lookup (a third markdown read of every installed skill on the fallback path). Covered by the existing resolution suite, which exercises both extracted helpers: `get_workflow_with_profile_resolution_matrix`, `get_profile_workflow_resolves_distinct_display_name` (the reused name fallback), `profile_workflow_exact_id_overrides_builtin`, `skill_md_only_install_resolves_by_dir_slug_not_frontmatter_name`, and `prune_removes_legacy_bundled_only` (prune-before-discover ordering). Claude-Session: https://claude.ai/code/session_01ACB4Ugi5pJMQqoCbZnVo6f
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughWorkflow discovery now runs through a shared helper. The registry reuses discovered workflows for definition loading and profile display-name resolution, removing repeated root scans. ChangesWorkflow discovery and lookup
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Refactors the skills/workflow registry lookup path to avoid re-discovering installed skill roots multiple times during a single get_workflow_with_profile call (the core resolution seam behind run_workflow / describe_workflow). This reduces redundant filesystem walks while preserving the existing resolution order and outputs.
Changes:
- Extracts a shared discovery helper (
discover_all) that prunes legacy bundled skills and performs a single discovery walk. - Extracts
definitions_from_discoveredto parseWorkflowDefinitions from an already-discovered list, keeping built-ins prepended. - Updates
get_workflow_with_profileto reuse the single discovery result for both exact-id lookup and display-name fallback.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
CI note — the two red Rust lanes are pre-existing on
|
Summary
get_workflow_with_profile— the resolution seam behindrun_workflow/describe_workflow— walked the installed-skill roots twice per call: once insideload_workflows_with_profile, and again to resolve a display-name in the fallback branch.discover_all(prune + one discovery walk) anddefinitions_from_discovered(builtins + parse each discovered skill); discover once and feed both the id lookup and the name fallback from that single list.Problem
Resolving one skill by id parses the whole catalogue and, on the fallback path, re-walks the roots:
discover_workflows_with_profilealready reads every skill'sWORKFLOW.md/SKILL.mdfrontmatter;load_workflows_with_profilethen reads each one again to parse its definition; and the name-fallback discovers a second full time. So a singlerun_workflowpays O(N_installed_skills) filesystem reads, with the fallback path re-walking the roots it just walked.Solution
Split the work so discovery happens once and is reused:
discover_all(workspace_dir, profile_skills_root)— prune (before discovery, unchanged ordering) + onediscover_workflows_with_profilewalk, returning the lightweightWorkflowentries.definitions_from_discovered(&[Workflow])— builtins prepended + parse each discovered skill's definition.load_workflows_with_profilenow delegates to both (behavior identical).get_workflow_with_profilecallsdiscover_allonce, derives the parsed list from it, and — on the name-fallback — reuses that same discovery instead of walking the roots again.This is a pure refactor: the parsed workflow list is byte-identical (same builtins, same discovery, same per-skill parse), the exact-id then display-name resolution order is unchanged, and the fallback reads the same discovery it did before — computed once rather than twice. It removes one full root walk per lookup (a third markdown read of every installed skill on the fallback path).
Submission Checklist
get_workflow_with_profile_resolution_matrix(id resolution + precedence),get_profile_workflow_resolves_distinct_display_name(the reused name fallback),profile_workflow_exact_id_overrides_builtin(builtin vs discovered),skill_md_only_install_resolves_by_dir_slug_not_frontmatter_name(slug vs frontmatter name), andprune_removes_legacy_bundled_only(prune-before-discover ordering). All 15skills::registrytests pass.get_workflow*/load_workflows*test).N/A: behaviour-preserving performance refactor, no matrix row added/removed/renamed.## Related—N/A.N/A: internal resolution path, identical behavior.Closes #NNN—N/A: no tracking issue (self-identified hot-path redundancy).Impact
run_workflow/describe_workflow(and anyget_workflowcaller). Removes a redundant full discovery walk per lookup; the win scales with the number of installed skills.Related
workflow.tomlids can differ from the dir slug) and is intentionally out of scope here.AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
perf/skills-registry-single-discover