Repository navigation
feat(skills): load only owner-approved skill content hashes - #617
Merged
Merged
Conversation
With TOLE_SKILL_APPROVAL=required a discovered skill loads only when its package (SKILL.md plus every other file of its directory, paths and bytes) hashes to the owner's approval in $CODECORA_HOME/tole/skill-approvals.json. Any other skill is listed by name only as unavailable; load_skill refuses it and skill_search returns no description for it. With TOLE_SKILL_INDEX=uteke the same gate covers the pinned core and the recalled skills. The body that loads is parsed from the exact bytes that were hashed; a symlink in a package makes it unloadable; a malformed approvals file or an unknown setting fails startup. New tole skills approve <name> [--hash], revoke and list, beside the index actions. New tole-core module skill_approval (Gate, Approvals, read_package); skill_index select and SkillSearchTool take a Gate. The default off keeps today's behavior; --skill files and profile skills are not gated. Closes #591.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
| } else if kind.is_dir() { | ||
| walk(&path, &rel, files, total)?; | ||
| } else if kind.is_file() { | ||
| let bytes = std::fs::read(&path).map_err(|e| format!("{}: {e}", path.display()))?; |
read_package read each file in full and only then compared the total with MAX_PACKAGE_BYTES, so a skill directory with one huge file (cheap to ship sparse in a cloned repo) was loaded into memory at every session start under TOLE_SKILL_APPROVAL=required. The walk now refuses on the file count and the length the directory entry reports before opening a file, opens it without following a symlink, and reads at most one byte past the remaining budget, so a file that grew after the check cannot allocate more either. The over-limit error text is unchanged.
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A session can now be set to load only skill content the owner approved. With
TOLE_SKILL_APPROVAL=required, a discovered skill loads only when its whole directory hashes to the owner's approval. Every other skill is listed by name only, as unavailable, and its text never reaches the model. Newtole skills approve|revoke|listcommands manage the approvals. The default (off) keeps today's behavior.Why
Closes #591 (epic #589). A skill is meant to be followed, so trusting "the file is there" or "the index returned it" lets anything that can write a skill steer the agent (SkillJack). Design §4.2 in
docs/skills-registry-design.mdmakes the owner's approval of exact bytes the trust anchor.Changes
tole-core/src/skill_approval.rs(new):read_package/package_hash: a skill package is every file of its directory (SKILL.md plusreferences/,scripts/,assets/, ...). The hash issha256:over each file's relative path, length and bytes, in path order, so editing, adding or renaming any file changes it.Approvals: one record per skill name (hash, approval time, file count) in$CODECORA_HOME/tole/skill-approvals.json, outside every workspace.Gate:Openis today's behavior.Approvedloads a skill only when its package hash matches, and parses the body from the exact bytes it hashed, so a file swapped after the check is never what loads. A refusal isLoadError::NotApproved { name, hash }.skills.rs:LoadSkillTool::with_gateandindex_block_gated. Under the gate, an unapproved skill is listed as- name (unavailable: not approved by the owner); its description is left out as well, since it is text from the same untrusted file.skill_namesandparse_loaded.index_blockis unchanged.skill_index.rs:selectandSkillSearchTool::newtake aGate.Selection::unavailable. It is named in the prompt block and does not use up the K.skill_searchhit comes back as{"name", "available": false}with no description.tole-cli/src/skill_approve.rs(new):TOLE_SKILL_APPROVALisoff(the default) orrequired. Any other value, or a malformed approvals file, fails startup.tole skills approve <name> [--hash sha256:…]: prints the hash and every file it covers.--hashpins the hash the owner reviewed, so a skill changed between review and approval is refused. A broken SKILL.md is never approved.tole skills revoke <name>: removes the approval; the skill stays on disk.tole skills list: shows each skill asapproved,changed since approvalornot approved, with its hash and approval time.index,retire,search) are flattened into the sametole skillscommand, renamed toskill_recall::IndexAction, and still need shell-tools.skill_recall.rs/main.rs:SkillRecall.gateis set from the setting. In local mode it gates the full listing andload_skill. WithTOLE_SKILL_INDEX=utekeit also gates the pinned core, the recalled skills andskill_search.--skill <file>, a profile'sskills), because naming the file is the approval.Testing
All run locally on head 4bdb804 (the feature commit, a merge of develop be9b2fc, and the size fix below):
cargo test --workspacepasses: 1457 passed, 0 failed (82 suites).cargo test -p tole-core --no-default-featurespasses: 488 passed, 0 failed.cargo test -p tole-cli --no-default-featurespasses: 426 passed, 0 failed (run on 8b4473e; the fix does not touch tole-cli).cargo fmt --all -- --checkpasses.cargo clippy --workspace --all-targets -- -D warningspasses, and so doescargo clippy -p tole-core --no-default-features --all-targets. The--no-default-featuresand shell-tools-only clippy builds of tole-cli were checked on 8b4473e.cora review --no-llm --base origin/develop(cora v0.20.0): "No issues found". The LLM review is CI Cora Review.tests/skill_approval_e2e.rsruns the realtolebinary withCODECORA_HOMEin a temp dir and a mock provider that records the system message. It coverslist,approve,runwith the settingrequired(approved skill listed, unapproved one by name only, its text absent), an edit after approval making the skill unavailable, the defaultofflisting everything,revoke, and the startup errors.Fix (4bdb804, from the CI Cora Review finding):
read_packageused to read each file in full before checking the package's byte cap, so one huge (sparse) file in a cloned repo's skill would be loaded into memory at every session start underrequired. The walk now refuses a file before opening it when the file count is at the limit or its reported (lstat) length is over the remaining budget. It opens files without following a symlink, and reads at most one byte past the remaining budget (take(remaining + 1)), so a file that grows after the check cannot allocate more either. The over-limit error text is unchanged. New testan_over_budget_file_is_refused_without_a_full_read: it was red against the old read-everything form (a reader that panics past the cap was read past it) and is green now.An earlier workspace run on 8b4473e hit 9
compaction::testsfailures withAlreadyExists: a leftovertole-compaction-<pid>-Ntemp directory from a reused pid on the shared machine. They are unrelated to this change and passed on the rerun above.New tests:
skill_approval::tests:an_over_budget_file_is_refused_without_a_full_readpackage_hash_covers_every_file_path_and_bytea_symlink_in_a_package_makes_it_unreadablethe_approved_gate_loads_only_the_approved_bytesapprovals_round_trip_replace_revoke_and_fail_closedskills::tests::gated_index_and_load_skill_show_unapproved_skills_as_unavailableskill_index::tests::the_gate_names_unapproved_skills_as_unavailableskill_approve::tests:the_setting_is_off_by_default_and_required_reads_the_approvalsapprove_pins_the_reviewed_hash_and_list_shows_each_statusskill_recall::tests::the_approval_gate_covers_local_and_uteke_sessionstests/skill_approval_e2e.rs:required_approval_lists_unapproved_skills_by_name_onlya_bad_setting_or_a_malformed_approvals_file_fails_startupRed/green: each behavior was broken on purpose, the named test was seen failing, the file was restored, and the test passed again. All 19 mutants were killed:
package_hash_covers…package_hash_covers…a_symlink_in_a_package…the_approved_gate_loads…approvals_round_trip…approvals_round_trip…gated_index_and_load_skill…load_skillignores the gategated_index_and_load_skill…the_gate_names_unapproved…skill_searchshows an unapproved descriptionthe_gate_names_unapproved…the_gate_names_unapproved…offthe_setting_is_off…approveignores the reviewed hashapprove_pins…approveaccepts a broken SKILL.mdapprove_pins…required_approval_lists…(e2e)the_approval_gate_covers…load_skillnot gatedthe_approval_gate_covers…selectnot gatedthe_approval_gate_covers…skill_searchnot gatedthe_approval_gate_covers…Related Issues
Closes #591. Epic #589. Builds on #613 and #616 (#590).
Checklist
feat/skill-approved-hashes)develop