Repository navigation
fix(skills): checkpoint the skill ledger in the approvals file; add skills adopt and recheckpoint (#879) - #886
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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
Hardens the skill ledger of #880 (the gaps listed in #879): a checkpoint in
skill-approvals.jsonso that deleting, truncating or rewritingskill-ledger.jsonlalone is caught, an owner-onlytole skills adoptandtole skills recheckpoint, the embedder caveat on the public API, and a one-linetole plugin listtext output.Closes #879
Why
Approvals::approve/saveskip the ledger, undocumented.plugin listdid not flatten a newline in a lock key (plugin auditdoes).Changes
approve,revoke,adopt, draft promote, revoke-by-source) appends the ledger line first, then writes the approvals file withledger_checkpoint: {bytes, sha256}of the ledger as read after the append. At load the ledger is read once (capped at 16 MiB) and the same bytes are verified and parsed. A missing, shorter or differently-hashing prefix blocks every approval with oneERROR:note (what is wrong and the remedy);tole doctorshows it;plugin auditand the owner write commands refuse with the same message instead of quietly re-recording; a cron run records the note in theskill_not_approveddetail. A ledger that only grew is valid.tole skills recheckpoint [--sha256 <digest>](owner-only) shows the ledger and records it as the new checkpoint after confirmation. It changes no approval and restores no lost revoke.Approvals::savenever strips an existing checkpoint.tole skills adopt NAME...|--all(item 2). Owner-only (refused under an agent session; inowner_only_e2e). Appendsapprovelines notedadopted(hash and source as stored) for approvals the ledger does not name, refreshes the checkpoint, shows what it adopts, leaves recorded skills alone, refuses an unknown name. It adds no trust.Approvals::saveand indocs/third-party-plugins-design.md:approve/savewrite no ledger line. Additive helperApprovals::save_checkpointed(append aledger_line, then call it). No public signature changed.plugin list(item 4). Text output flattens\nand\tin every field and note;--jsonis unchanged.API note (additive,
tole_core::skill_approval):LedgerCheckpoint,CHECKPOINT_KEY,Approvals::{load_with_checkpoint, save_checkpointed, accept_ledger},read_ledger_bytes,ledger_path,adopted_ledger_line,verify_checkpoint_at,fault_message.Residuals, stated plainly
recheckpointincluded: trim or rotate by hand (only old lines of skills that no longer exist, since revokes in the removed part are forgotten), then runrecheckpoint.ledger_checkpointand its next save drops it (legacy format, with the note).Testing
LedgerCheckpoint::verifyfails 3 core tests, 2 CLI unit tests (ledger-lost-history, drafts promote/revoke) and 3 of 6skill_approval_e2etests.adoptfails its e2e test.adoptfailsowner_only_subcommands_refuse_under_a_session_and_write_nothing.plugin listcode failslist_text_puts_a_lock_key_with_a_newline_on_one_line.skill_approval_e2e): delete, truncate, same-length rewrite and append the ledger, crash-order restore, adopt (noise gone, checkpoint armed), recheckpoint (digest required, wrong digest refused), owner commands refusing to write after a fault.savekeeping the checkpoint,accept_ledgerrefusing a changed ledger, and the cron detail.cargo fmt --all --check;clippy --workspace --all-targets --all-features -D warnings; clippy--no-default-featuresand shell-tools-only for core and cli;cargo check -p tole-core --no-default-features --tests;TOLE_REQUIRE_BWRAP=1 cargo test --no-fail-fastin the default,--no-default-featuresand shell-tools-only profiles; attribution grep overorigin/develop..HEADprints nothing.cora review --staged --no-llm(deterministic checks) was clean before each commit. cora is not installed in the author's PATH, so the CI Cora review is the merge gate.