Skip to content

feat(skills): SkillIndex seam with a uteke doc adapter, pinned core and top-K recall - #613

Merged
ajianaz merged 2 commits into
developfrom
feat/skill-index-seam
Nov 11, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/skill-index-seam

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 1 of #590: a new tole-core module, skill_index. It adds the SkillIndex seam, two adapters (LocalIndex and a uteke doc adapter), the selection of a pinned core plus the top K skills recalled by meaning, and a ReadOnly skill_search tool. Nothing uses the seam yet: the session wiring and tole skills come in part 2.

Why

Refs #590 (epic #589). Today skills::index_block lists every discovered skill in every prompt, so token cost grows and selection quality drops as the library grows. The owner decided on a pinned core of 3 to 5 skills, plus K = 5 (at most 10) skills recalled by meaning above a similarity floor, plus on-demand search, all through a seam whose first adapter is uteke doc. The design is in docs/skills-registry-design.md §4.1, §4.2, §4.3, §6.2 and §7.

The whole #590 change came to about 1,650 lines, so it is split in two:

  • This PR (about 1,080 lines): the core module.
  • Part 2 (about 600 lines, follows once this merges): sessions opt in with TOLE_SKILL_INDEX=uteke, run recalls for its prompt, the tole skills index|retire|search command, docs, and an end-to-end test with the real binary.

Changes

  • skill_index.rs (new):
    • SkillIndex trait: search(query, filter, k), upsert(entry), retire(name) and label(). SkillFilter holds the profile scope and the similarity floor. SkillEntry holds the name, description, profiles, status and a sha256: content hash; it never holds the body.
    • LocalIndex: uses the skills directories as the index. It matches the query's words against each skill's name and description. This is the fallback when uteke is not available, and its scores are not cosines, so the floor does not apply.
    • UtekeDocIndex (shell-tools builds only): each skill is a uteke document with slug skill-<name> and tag skill, and its metadata is set with doc update --metadata.
      • search calls doc search --mode semantic, because in semantic mode the score is a cosine and the floor means something; hybrid mode returns rank-fusion scores.
      • A hit is kept only if its slug is skill-<name>, its score is at or above the floor, and its stored document (read with doc get) has the skill tag, status approved, a matching name, and a profile scope that includes the session's profile (or no scope).
      • Malformed search output is an error, not an empty result.
      • upsert sends only # <name> and the description; the body stays local.
      • retire sets the status to retired and keeps the rest of the stored metadata.
      • A name that cannot form a slug ([a-z0-9-], not starting with a dash) is refused before any call.
    • select: returns a task's skills. It takes the pinned core first (at most 5, in order; a missing pin becomes a note), then up to K recalled skills (K is capped at 10; it asks for K plus the number of pins, so pinned and missing names do not use up the K). Fewer or zero skills is fine. If the index fails, select returns the pinned skills and a note instead of an error.
    • RecallQuery: built only from the owner-written brief and the profile role, so tool output cannot steer which skills are recalled. A dash-led brief is prefixed so it can never become a uteke flag, and the query is capped at 1,000 chars.
    • selection_block: the system-prompt section. It always mentions skill_search.
    • SkillSearchTool: the ReadOnly skill_search tool. It returns names, scores and descriptions taken from the local files.
    • Trust: the index only finds NAMES. Every description and body comes from the local skill files, and a name with no local skill is dropped, so an index entry can never put text into the prompt. Loading only owner-approved hashes is feat(skills): load only owner-approved skill content hashes #591.
  • skills.rs: new skill_file(workspace, name), the SKILL.md path that load_skill would read. Part 2 uses it to hash the raw bytes.
  • tole-core/Cargo.toml: adds sha2 = "0.11" for the content hash. It was already in the lock via rmcp, so no new crate is downloaded.
  • Docs: a CHANGELOG entry, and the status line of docs/skills-registry-design.md.

Testing

All run locally on head f2f47e0 (e96969d plus a merge of develop 06a599a, which brings in profiles #584; the only conflict was CHANGELOG.md, and both entries are kept):

  • cargo test --workspace passes: 1411 passed, 0 failed (78 suites).
  • cargo test -p tole-core --no-default-features passes: 481 passed, 0 failed. The module builds without shell-tools; only the uteke adapter is gated.
  • cargo fmt --all -- --check passes.
  • cargo clippy --workspace --all-targets -- -D warnings passes.
  • cora review --no-llm --base origin/develop (cora v0.20.0): "No issues found". The LLM review is CI Cora Review.
  • Manual smoke test against a real uteke store: not done; no uteke binary is installed here. The adapter is tested against a fake uteke script that answers doc search / doc get in the JSON shape of uteke's DocumentSearchResult and Document (read from codecoradev/uteke crates/uteke-core/src/memory/documents.rs) and logs its argv. Part 2 adds an end-to-end test with the real tole binary.

New tests (10):

  • skill_index::tests:
    • select_is_pinned_core_plus_top_k_from_local_files
    • select_bounds_pins_and_k_and_degrades_on_index_errors
    • recall_query_is_brief_and_role_only_and_never_flag_shaped
    • local_index_matches_words_of_name_and_description
    • skill_search_tool_returns_local_descriptions_only
    • content_hash_is_sha256_hex
  • skill_index::uteke_doc::tests:
    • search_filters_by_tag_status_scope_and_floor
    • malformed_search_output_is_an_error_not_an_empty_result
    • upsert_indexes_name_and_description_only_and_retire_keeps_metadata
  • skills::tests::skill_file_follows_the_load_order

Red/green: each behavior was broken on purpose, the named test was seen failing, the file was restored, and the test passed again. All 12 core mutants were killed:

Broken variant Test that failed
more than K recalled select_is_pinned_core…
pinned core not capped at 5 select_bounds_pins…
K not capped at 10 select_bounds_pins…
a pinned skill also counted as recalled select_is_pinned_core…
profile role dropped from the query recall_query_is…, select_is_pinned_core…
similarity floor ignored search_filters_by…
status ignored (retired recalled) search_filters_by…
profile scope ignored search_filters_by…
skill tag ignored search_filters_by…
hybrid instead of semantic search search_filters_by…
retire drops the stored metadata upsert_indexes…
skill_search trusts index text instead of the local file skill_search_tool…

Related Issues

Refs #590 (part 1 of 2; part 2 closes it). Epic #589. Next: #591 (approved-hash loading), which is not started here.

Checklist

  • Branch name follows convention (feat/skill-index-seam)
  • Branch is from develop
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR (part 1 of a split; the wiring follows separately)

…nd top-K recall

New tole-core module skill_index: the SkillIndex trait (search, upsert,
retire) with a LocalIndex fallback and a uteke doc adapter (tag skill,
slug skill-<name>, metadata with status, profile scope and a sha256
content hash; semantic search so the floor is a cosine). select() picks
a pinned core of at most 5 plus the top K (default 5, max 10) above the
floor; RecallQuery takes only the owner brief and profile role; the
ReadOnly skill_search tool searches on demand. The index only finds
names: descriptions and bodies come from the local skill files.

Part 1 of #590; the session wiring follows.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit ae21fc6 into develop Nov 11, 2026
19 of 20 checks passed
@ajianaz
ajianaz deleted the feat/skill-index-seam branch November 20, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants