Skip to content

fix(skills): checkpoint the skill ledger in the approvals file; add skills adopt and recheckpoint (#879) - #886

Merged
ajianaz merged 5 commits into
developfrom
fix/879-skill-ledger-checkpoint
Nov 17, 2026
Merged

ajianaz merged 5 commits into
developfrom
fix/879-skill-ledger-checkpoint

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Hardens the skill ledger of #880 (the gaps listed in #879): a checkpoint in skill-approvals.json so that deleting, truncating or rewriting skill-ledger.jsonl alone is caught, an owner-only tole skills adopt and tole skills recheckpoint, the embedder caveat on the public API, and a one-line tole plugin list text output.

Closes #879

Why

  • With no ledger, every approval became "unrecorded" and loaded, so deleting the ledger forgot every revoke.
  • Approvals made before the ledger stayed "unrecorded" forever.
  • Embedders calling Approvals::approve / save skip the ledger, undocumented.
  • plugin list did not flatten a newline in a lock key (plugin audit does).

Changes

  1. Checkpoint (item 1). Every owner write (approve, revoke, adopt, draft promote, revoke-by-source) appends the ledger line first, then writes the approvals file with ledger_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 one ERROR: note (what is wrong and the remedy); tole doctor shows it; plugin audit and the owner write commands refuse with the same message instead of quietly re-recording; a cron run records the note in the skill_not_approved detail. A ledger that only grew is valid.
    • Recovery: 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.
    • Missing-checkpoint rule: a missing field is the legacy format and keeps loading, with one note per startup while a ledger exists, until the first owner write adds a checkpoint. It cannot be told from an old install, and stripping it from the approvals file alone gains nothing because the ledger still applies in full. Approvals::save never strips an existing checkpoint.
  2. tole skills adopt NAME...|--all (item 2). Owner-only (refused under an agent session; in owner_only_e2e). Appends approve lines noted adopted (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.
  3. Embedders (item 3). Documented on Approvals::save and in docs/third-party-plugins-design.md: approve/save write no ledger line. Additive helper Approvals::save_checkpointed (append a ledger_line, then call it). No public signature changed.
  4. plugin list (item 4). Text output flattens \n and \t in every field and note; --json is 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

  • A process able to rewrite BOTH the ledger and the approvals file forges a matching checkpoint (same as the plugin ledger). The checkpoint only catches the ledger being deleted, truncated or rewritten alone.
  • Lines appended after the last checkpoint write exist only after a crash between the two writes and are unprotected until the next owner write.
  • Across a process crash a checkpoint ahead of the ledger cannot happen. On power loss with reordered, unsynced writes (the approvals temp file and rename are not fsynced) the result is still a fail-closed fault, never a silent pass.
  • A ledger over 16 MiB blocks everything, recheckpoint included: trim or rotate by hand (only old lines of skills that no longer exist, since revokes in the removed part are forgotten), then run recheckpoint.
  • An older tole ignores ledger_checkpoint and its next save drops it (legacy format, with the note).
  • The owner-only guard is environment-marker defense in depth. The real boundary for a script is that the command sandbox keeps the data dir out of its write grants.

Testing

  • Fail-first (neuter, see fail, restore):
    • Neutering LedgerCheckpoint::verify fails 3 core tests, 2 CLI unit tests (ledger-lost-history, drafts promote/revoke) and 3 of 6 skill_approval_e2e tests.
    • Disabling the ledger append in adopt fails its e2e test.
    • Removing the owner-only guard from adopt fails owner_only_subcommands_refuse_under_a_session_and_write_nothing.
    • The old plugin list code fails list_text_puts_a_lock_key_with_a_newline_on_one_line.
  • Real-binary e2e (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.
  • Unit tests cover non-UTF-8 bytes, the 16 MiB cap, malformed checkpoint field, save keeping the checkpoint, accept_ledger refusing a changed ledger, and the cron detail.
  • Local gates green: cargo fmt --all --check; clippy --workspace --all-targets --all-features -D warnings; clippy --no-default-features and shell-tools-only for core and cli; cargo check -p tole-core --no-default-features --tests; TOLE_REQUIRE_BWRAP=1 cargo test --no-fail-fast in the default, --no-default-features and shell-tools-only profiles; attribution grep over origin/develop..HEAD prints nothing.
  • A pre-PR independent review reported NO BLOCKER and ran the skill, e2e and no-default-features checks. CI: all 19 checks green and Cora Review "No issues found" on the final head (updated after the last push).
  • 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.

@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 bc6282a into develop Nov 17, 2026
23 checks passed
@ajianaz
ajianaz deleted the fix/879-skill-ledger-checkpoint branch November 20, 2026 08:38
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.

hardening(skills): skill ledger gaps — deleting the ledger forgets revokes, adopt pre-ledger approvals, embedders skip the ledger

2 participants