Repository navigation
skill.usage reports which revisions of a namespace's skills were fetched and which skills are stale - #2368
Conversation
`skill.usage` is a new experimental read that needs viewer on the namespace it names. It folds the acts of the namespace's skills and one grouped statement over the request ledger's answered `skill.get` rows. For each skill the caller can list it answers the published revision, one entry for each fetched revision (sessions, principals, the last fetch, and the looks of the dashboard, the assistant and a command that shows a skill), the stale codes `draft_waiting` and `unknown_operation`, and a statement in words. Every count is a lower bound, and the report's statement says what the ledger cannot show. `by_subject` names who fetched each revision and needs admin on the namespace. `loom skill usage <namespace>[/<name>]` prints the report. A skill's page gains a Fetches tab, and the Skills list and a skill's page label a stale skill. The five generated SDKs carry the op. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Both sides add operations, so four generated files conflicted: the operations index, the status page and the Ruby and TypeScript SDK bindings. Each was regenerated from the merged registry, not merged by hand. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit caada5e. Configure here.
| ), | ||
| skills=[ | ||
| _usage(input, name, *reported[name], groups, writer=writer, window=window, now=now) | ||
| for name in sorted(reported) |
There was a problem hiding this comment.
Shared hashes inflate fetch counts
Medium Severity
Fetches are tied to skills only by content hash. since |= hash_times(...) keeps one publish time per hash, from whichever skill is folded last, and counts then assigns those same groups to every skill that published the hash. A skill can include fetches from before it was published, so a count is no longer only a lower bound.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit caada5e. Configure here.
A skill with no fetch among the groups of a cut ledger read is said to have none among the rows read, and that an older fetch in the window may exist. The read keeps the 10,000 most recent groups, so a skill whose groups are all older got the sentence of a skill that was not fetched. A skill that never published keeps that sentence: the read asked for no hash of it. - A fetch whose request sent a blank `session_id` counts its principal only, as one that named no session does. The ledger stores a blank id as the empty string, which counted as one session. - The report reads the registry once, over the operation names of every served revision. It built the registry's facts once for each skill. - `skills.reach` is public and answers the `by_subject` admin check from the gate that answers the reader and writer checks. The report built a second gate through a copy of the helper. - `loom skill usage --by-subject` prints `no sign-in` for a read with no subject, the dashboard's words. - The ledger statement's test holds the guard against a read with no hash. The assertion ran the in-memory ledger, so removing the guard failed no test. - `DAYS_MAX` had no caller and is removed. The comment on the masked ledger rows names the mark that masks a row, and the architecture page says which stale code depends on the answering build. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Both sides change the operation registry and the command tree, so two generated files conflicted: the operations index and the command help snapshot. Each was regenerated from the merged tree, not merged by hand. Every other generator reports no change on the merged tree. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ched In a report whose ledger read was cut, `skill.usage` says "no fetch is among the rows read" only for a skill with a revision that is or was published. A skill with no such revision, as one that never published, is answered as not fetched in the window: the read looked for no fetch of it, so the cut hides none. The features page, the architecture page and the comment on the `statement` field of a skill's usage stated the cut sentence for every skill with no fetch. Each now names the condition. No behaviour and no wire field changes. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
|


Part of: #1143
Related: #1769
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
skill.usagereports which revisions of a namespace's skills were fetched from the server and which skills are stale, with every count given as a lower bound and a statement of what Loom cannot see.loom skill usage <namespace>prints the report, and a skill's page shows it on a Fetches tab.Why
A team that publishes skills could not tell whether any session asked for one, or for which revision. Loom holds one record of that: the request ledger's row of each answered
skill.get, with the content hash the read answered. This change reads it and reports it.The report says "fetched" and nothing more, because that is all the ledger proves. A listing line shown to a session is not recorded, a copy pulled to a folder is read without a request, and no row says what a session did with the text. So every count is a lower bound, and the sentences that say what the numbers mean are built in one place on the server. The command and the dashboard print them.
Criteria of the linked issue that are met with this change:
Criteria that stay open: a fork of a skill with its lineage, the evidence a draft was built from, and a draft written by the curator.
Design calls made here:
draft_waitingandunknown_operation. Each is proven by rows the skill holds. A skill that was not fetched has no code, since a pulled copy is read without a fetch.publishrow keeps its time in whole seconds, so a fetch counts from the second after it. A writer's read of the draft in that second is not counted, which keeps every count a lower bound.session_id, counts its principal only, sosessionsis a lower bound as every other count is.tests/unit/test_skill_usage.pyfails when the two differ.Scope and risk
loom skillcommand, the Skills page and the skills docs.skill.listandskill.getanswer.skill.listnow calls the one rule of who lists which skill throughlisted_row, which the report shares.skill.listandskill.getread the caller's roles throughreach, which the report shares too: one gate answers the reader, writer andby_subjectadmin checks of a request.loom.skills, the request ledger and the namespace's registry row, and writes nothing.vieweron the namespace it names. A caller is reported the skillsskill.listlists to it, so a reader belowwritersees served skills only and nodraft_waiting. The hashes of a skill the caller is not reported are not parameters of the ledger statement. A name the caller cannot list answers no skill, as a name that does not exist does.by_subjectnames principals, needsadmin, and is refused with 403 to anyone else.tests/integration/test_cross_principal_leakage.pyholds the case.(org, namespace), over at most 90 days and never more than the namespace keeps. The measurement is under Tests.Compatibility, rollout and rollback
skill.usage(experimental,viewer, a read, idempotent, not audited, not in the MCP tool listing and reachable throughloom_op).org,namespace,name(default empty: every skill the caller can list),days(1 to 90, default 30),by_subject(default false, needsadmin).window_days,statement,skills. Each skill:namespace,name,published_revision,published_at,fetches(revision,content_sha256,sessions,subjects,last_at,inspector_fetches),stale,statement,subjects(subject,revision,transport,consumer,first_at,last_at).loom skill usage <namespace>[/<name>] [--days N] [--by-subject] [--json].docs/reference/errors.mdand the SDK error tables are unchanged.OP_BUDGETS_P99_MSgainsskill.usageat 1000 ms.Tests
Unit, run locally:
pytest tests/unit/test_skill_usage.py: 13 passed. One of them runs the ledger statement onclickhouse localagainst the ledger's table definitions. It ran with theclickhousebinary of a private container, and skips where the binary is absent.pytest tests/unit/test_sdk_skill_usage_command.py: 5 passed.tests/analyzer: 284 passed, 5 skipped.python -m tests.analyzer.corpus --checkon a migrated private ClickHouse: 2,523 shapes checked, 0 rejected.main: 1,119 passed, 2 skipped.tests/analyzer: 625 passed, 2 skipped.Integration, against a server started from source on a private ClickHouse:
pytest tests/integration/test_skill_independent_review.py: 5 passed. The new case counts a fetch once the ledger holds it, shows a look apart, prints the server's sentences throughloom skill usage, and refusesby_subjectbelowadmin.pytest tests/integration/test_cross_principal_leakage.pywith sign-in required, as CI's isolation step runs it: 51 passed, 17 skipped. With sign-in off: the same result in a serial run.by_subjectto a reader and a writer and answers it to an administrator through the shared gate.loom skill usagerun by hand with an emptyHOME, the server and the token given by environment: it printed the report, exited 1 with the refusal for a reader's--by-subject, printed who fetched for an administrator, and wrote nothing underHOME.Dashboard:
npx vitest run src/views/skills src/views/Skills.test.tsx src/callBudget.test.tsx src/lib --maxWorkers=2: 82 files, 984 tests passed.FetchesTab.test.tsxholds "says fetched, never installed" and "shows who fetched only to an administrator".npm --prefix frontend run buildandnode scripts/bundle_budget.mjs: the index chunk is within its budget. The Fetches tab is its own chunk, loaded when the tab is opened: 4.40 kB (1.84 kB gzip).e2e/route-budget.spec.tsande2e/skills.spec.tsrun in CI only. Two tab lists ine2e/skills.spec.tsnow name the Fetches tab. With the default fixtures the Skills route makes no new request, because its list holds built-in skills only.Checks:
make lint,make typecheck,ruff format --check ., the Biome format check and the Prettier check ondocs/pass.make format-checkitself needsshfmt, which this machine lacks; no shell or TOML file changed. The Go and Rust SDKs were generated withgofmtfrom thegolang:1.27.4image andrustfmtfrom therust:1.85.1-slimimage, and every generator's--checkpasses.sdk/rust/src/wire_models.rsis 2,404,271 bytes. After the review fixes,make typecheck,ruff checkandruff format --checkon the changed files and the Prettier check on the two edited docs pages pass. The fixes change no wire field, and every generator reports no change for them.mainwas merged again after the fixes: the operations index and the command help snapshot conflicted and were regenerated from the merged tree, every other generator (Go and Rust with the samegofmtandrustfmtimages) reports no change, andpytest tests/unit/test_docs_reference.py tests/unit/test_cli_surface_snapshot.pygives 17 passed.Measurement of the ledger statement, on a local ClickHouse and not a production figure. One namespace holds 3,000,000 ledger rows spread over 30 days: 150,000 of them answered
skill.getcalls over 40 hashes, 5,000 sessions and 300 principals. Twenty hashes are passed as published. Fromsystem.query_log, five runs each:read_rowsread_bytesquery_duration_msTo reproduce, insert the rows, run
FETCHESfromserver/identity/store/skill_fetches.pywith alog_comment, and read the log:The parameters of the runs:
org = 'bench',ns = 'usage-busy',since30 days or 1 day back,hashesthe SHA-256 of'0'to'19'in hex,publishedten days back for each,limit = 10001.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. I ran the tests and checks listed above, read the whole diff, and ran the command and both integration files against a server started from this branch.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code