Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/architecture/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,30 @@ A published skill reaches a session unasked as one line of the `skills` section
- **Tenant isolation.** The read scopes by `org` and by the namespaces the fan-out resolved for the caller's token, so it holds no namespace the caller may not read. `tests/integration/test_cross_principal_leakage.py` holds the case of a namespace granted and never opened.
- **Rolling upgrade.** [Rolling upgrades](rolling-upgrades.md), rule 98.

### The usage report

`skill.usage` answers which revisions of a namespace's skills were fetched, and which skills are stale. It is a read of two things Loom already holds, and stores nothing.

| Loom knows | Loom does not know |
| --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| Which revision is published and when: the `publish` rows of `loom.skills` | Which sessions were shown a [listing line](#the-session-listing): a line is no row |
| Each answered `skill.get`: a request ledger row with the content hash it answered | Whether a copy pulled to a folder is read: the pull is one fetch, a later read none |
| Who asked, in which session, over which transport and under which consumer: the same row | What a session did with the text it asked for |
| That the dashboard, the assistant and a command that shows a skill looked: the row's consumer | A request whose ledger row was dropped |

So the report says "fetched", gives every count as a lower bound, and never says a skill is installed, active or adopted.

- **Two reads and a row.** One read of `loom.skills` by `(org, namespace)` for the acts of every skill, without `content` or `files` (`usage_acts`); one statement over the request ledger (`FETCHES` in `server/identity/store/skill_fetches.py`); and the namespace's registry row, for the days it keeps its ledger. The acts are read with sequential consistency ([what that covers](clickhouse.md#read-your-writes)), so no reader is reported a skill an archive on another replica stopped.
- **What counts as a fetch.** A ledger row of a successful `skill.get`, not a worker's, whose `out_content_sha256` is the hash of a revision that the fold calls published, superseded or withdrawn, and whose time is past the second of that revision's first `publish` row. A `publish` row keeps whole seconds, so a read in that second may be a writer's read of the draft and is not counted. The ledger keeps the hash a read answered and never the number: of two published revisions with one hash, the higher is named. A draft's hash, a rejected revision's and a void one's are not in the statement's parameters, so no row of theirs is read.
- **The statement.** It filters by `org`, `namespace`, the window and the operation, keeps the rows whose hash is one of the published hashes from that hash's time on (two bound arrays), and groups by hash, session, principal, consumer and transport with a count and the first and the last time. It returns the most recent 10,000 groups and one more (`FETCH_GROUPS_MAX`): the extra group tells a cut read from a whole one, and the report's statement says when the read was cut. The ledger is sorted by `(org, namespace, agent, ts)` and partitioned by month, so the read prunes to the namespace's rows of the window's months. The window is at most 90 days, and never longer than the days the namespace keeps its ledger.
- **The counts.** `server/identity/domain/skill_usage.py` makes one entry a revision of the groups: the distinct sessions (a row with no session, `-` or blank, counts its principal only), the distinct principals, and the last fetch. A group whose consumer is an inspector's (`INSPECTOR_CONSUMERS`) counts in neither and is summed as `inspector_fetches`. `loom skill pull` names no consumer, so a pull is a fetch.
- **The sentences.** The report's `statement` and each skill's are built in that one module from the counts: that counts are lower bounds, that a listing shown to a session is not recorded, how many of the namespace's skills a listing can carry and in what order, whether the window or the ledger read was cut, and for each skill the revisions fetched or that none was. A skill with a published hash in the statement's parameters and no fetch among the groups of a cut read is said to have none among them, and that an older one may exist. A skill with no such hash, as one that never published, is said to be not fetched: the read asked for no row of it, so the cut hides none. The command and the dashboard print them and write none of their own for a count.
- **Stale codes.** A closed set of strings, each proven by rows the skill holds: `draft_waiting` (the open draft's `save` row is more than 14 days old, `DRAFT_WAITING_DAYS`) and `unknown_operation` (a stored `op_names` entry of the served revision that the answering build's registry does not hold). The 14 days are a constant, so `draft_waiting` means the same on every deployment; `unknown_operation` is the answering build's. No fetch is no code: a pulled copy is read without one.
- **Tenant isolation.** The op needs `viewer` on the namespace it names. The caller is reported the skills `skill.list` lists to it (`listed_row`): a writer every skill, any other reader the ones that serve a revision, and `draft_waiting` is a writer's as the draft is. The published hashes of a skill the caller is not reported are not in the ledger statement's parameters. A name the caller cannot list answers no skill, as a name that does not exist does. `by_subject` names principals, so it needs `admin` on the namespace and is refused with 403 to anyone else: the refusal confirms nothing, since the namespace is the one the caller named. `tests/integration/test_cross_principal_leakage.py` holds the case.
- **A failed read fails the op.** An error of the ledger statement is the op's error. A skill is never answered as not fetched because the ledger could not be read.
- **Rolling upgrade.** The op adds no table, column or stored value. A replica one release behind answers 404 for it: the command exits 2 and says the server does not serve it, and the dashboard shows no stale label and one line on the **Fetches** tab.
- **Cost.** `OP_BUDGETS_P99_MS` holds the op's budget. The acts read is the one `skill.list` makes for one namespace. The ledger statement reads the namespace's ledger rows of the window; the dashboard's list asks a one-day window, because it shows the codes and no count.

### Erasure and retention

`loom.skills` holds memory content. A namespace erasure deletes the namespace's rows in the step `skills.delete`, and its census counts what is left (`server/erasure/store/census.py`). A user erasure has no step for the table: every row's `user_id` is `-`, and a skill names no end user. The table has no TTL, so a revision is kept until an administrator deletes it or its namespace is erased.
Expand Down Expand Up @@ -399,6 +423,7 @@ These hold for `skill.check`. The ones of a save are [above](#invariants-of-a-sa
- Tests of a decision and the published reads: `tests/unit/test_skill_decide.py`, `tests/unit/test_skill_reads_published.py`, `tests/unit/test_inspector_consumers.py`, `tests/unit/test_sdk_skill_review_commands.py`, `tests/integration/test_skill_independent_review.py`, `tests/integration/test_skill_decide.py`, and the published case of `tests/integration/test_cross_principal_leakage.py`.
- Tests of the namespace token: `tests/unit/test_skill_binding.py`, `tests/unit/test_skill_literal_namespace_finding.py`, `tests/integration/test_skill_binding.py`, and the token cases of `tests/unit/test_sdk_skill_commands.py` and `frontend/src/views/Skills.test.tsx`.
- The session listing: `server/identity/domain/skill_format.py` (`listing_line`, `listing`), `server/identity/app/skills.py` (`session_listing`), `server/memory/app/context_pack.py` (`_pack_skills`), `server/transport/mcp_primer.py` (the sentence). Tests: `tests/unit/test_skill_listing.py`, `tests/unit/test_context_pack_skills.py`, `tests/unit/test_mcp_primer_order.py`, and the listing cases of `tests/unit/test_sdk_skill_commands.py`, `tests/integration/test_cross_principal_leakage.py` and `frontend/src/views/Skills.test.tsx`.
- The usage report: `server/identity/app/skill_usage.py` (`handle_skill_usage`), `server/identity/domain/skill_usage.py` (`published`, `hash_times`, `counts`, `subjects`, `stale_codes`, `skill_statement`, `report_statement`), `server/identity/store/skill_fetches.py` (`FETCHES`, `fetch_groups`), `sdk/python/loom/cli_skill_usage.py` (the command), `frontend/src/views/skills/FetchesTab.tsx`. Tests: `tests/unit/test_skill_usage.py`, `tests/unit/test_sdk_skill_usage_command.py`, `frontend/src/views/skills/FetchesTab.test.tsx`, and the usage cases of `tests/integration/test_skill_independent_review.py`, `tests/integration/test_cross_principal_leakage.py` and `frontend/src/views/Skills.test.tsx`.
- Tests of a delete: `tests/unit/test_skill_delete.py`, `tests/unit/test_skill_delete_statement.py`, `tests/unit/test_hidden_op_says_why.py`, and the delete cases of `tests/unit/test_sdk_skill_save_command.py`, `tests/integration/test_skill_drafts.py` and `tests/integration/test_cross_principal_leakage.py`.

## Related
Expand Down
22 changes: 21 additions & 1 deletion docs/features/dashboard.md

Large diffs are not rendered by default.

45 changes: 43 additions & 2 deletions docs/features/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ A session with a token narrowed to one user or one session is listed nothing. [S
| [`skill.save`](../reference/operations/skill.md#skillsave) | Saves a folder as a namespace's next draft | `POST /v1/skill.save` | `loom_op` with `op: "skill.save"` | `skill.save` method | `loom skill save <dir>` | The editor, the import |
| [`skill.delete`](../reference/operations/skill.md#skilldelete) | Deletes a revision or a whole skill | `POST /v1/skill.delete` | Not served | `skill.delete` method | `loom skill delete <namespace>/<name>` | **Delete…** |
| [`skill.decide`](../reference/operations/skill.md#skilldecide) | Publishes, rejects or archives | `POST /v1/skill.decide` | Not served | `skill.decide` method | `loom skill publish`, `reject`, `archive` | A skill page's review |
| [`skill.usage`](../reference/operations/skill.md#skillusage) | Reports which revisions were fetched | `POST /v1/skill.usage` | `loom_op` with `op: "skill.usage"` | `skill.usage` method | `loom skill usage <namespace>` | The **Fetches** tab |

The three reads need `viewer` on the namespace the call names, also for a built-in skill, `skill.save` needs `writer`, and `skill.delete` and `skill.decide` need `admin`: a caller outside the namespace is refused as on any op. A token bounded below its namespace, to one user or one session, is refused. No MCP toolset lists the reads and the save as tools; `loom_op` calls them by name. MCP does not serve `skill.delete` or `skill.decide`: a session must not remove a team's reviewed text, and a session that read a draft must not publish it, so `loom_op` refuses both and names no other operation. Every generated SDK carries the six, at the same names. The [status page](../reference/status.md) gives their maturity.
The four reads need `viewer` on the namespace the call names, also for a built-in skill, `skill.save` needs `writer`, and `skill.delete` and `skill.decide` need `admin`: a caller outside the namespace is refused as on any op. `skill.usage` with `by_subject` also needs `admin`. A token bounded below its namespace, to one user or one session, is refused. No MCP toolset lists the reads and the save as tools; `loom_op` calls them by name. MCP does not serve `skill.delete` or `skill.decide`: a session must not remove a team's reviewed text, and a session that read a draft must not publish it, so `loom_op` refuses both and names no other operation. Every generated SDK carries the seven, at the same names. The [status page](../reference/status.md) gives their maturity.

The dashboard's [Skills page](dashboard.md#skills) lists the built-in skills and the skills of your namespaces: to a writer with their drafts, to any other reader the published ones. It opens each skill on its own page, checks a folder picked in the browser, saves a draft from its editor or from a picked folder, and deletes a revision or a whole skill for an administrator. A writer's page of a skill is its review: what changed against the published revision, what a check finds, and the skill's history. On it an administrator publishes a draft, sends it back with a note, or archives the skill. The [Review queue](dashboard.md#the-admin-drawer) lists the drafts that wait in the namespace picked in the header on its **Skills** tab, for an administrator, and counts them in its badge; a row there, and a row of the Skills page whose draft waits, opens the draft on what it changes.
The dashboard's [Skills page](dashboard.md#skills) lists the built-in skills and the skills of your namespaces: to a writer with their drafts, to any other reader the published ones. It opens each skill on its own page, checks a folder picked in the browser, saves a draft from its editor or from a picked folder, and deletes a revision or a whole skill for an administrator. A writer's page of a skill is its review: what changed against the published revision, what a check finds, and the skill's history. On it an administrator publishes a draft, sends it back with a note, or archives the skill. A skill's **Fetches** tab shows [which revisions were fetched](#see-which-revisions-were-fetched), and the list and the page label a skill that is stale. The [Review queue](dashboard.md#the-admin-drawer) lists the drafts that wait in the namespace picked in the header on its **Skills** tab, for an administrator, and counts them in its badge; a row there, and a row of the Skills page whose draft waits, opens the draft on what it changes.

## List the skills

Expand Down Expand Up @@ -418,6 +419,46 @@ The command sends one `skill.list` for each namespace the locks name, for that n

An archive or a delete on the server does not reach a pulled folder. Pulled copies stay where they are, and `status` reports them as no longer served.

## See which revisions were fetched

`skill.usage` reports which revisions of a namespace's skills were fetched from the server, and which skills are stale. `loom skill usage` prints the report, and a skill's page shows it on its **Fetches** tab.

```bash
loom skill usage team # every skill of the namespace you can list
loom skill usage team/deploy-notes --days 90 # one skill, over 90 days
loom skill usage team --by-subject --json # who fetched each revision: admin
```

```text
Counts cover the last 30 days and are lower bounds: the request ledger can drop a row, so each number reads as at least that many. Loom does not record which sessions were shown the listing: a fetch counts a session that asked for the skill's text. A session's listing can carry 2 skills of this namespace: it takes one skill of each namespace in turn, each namespace's by name.

team/deploy-notes revision 2 is published
Revision 2 was fetched by at least 3 sessions of at least 2 principals in the last 30 days.
revision 2 sessions >= 3 principals >= 2 last fetched 2026-01-05T10:00:00 looks 4
```

Every sentence is the server's (`statement` of the report and of each skill), so the command, the dashboard and an SDK caller read the same words. `--days` takes 1 to 90 and defaults to 30. The command exits 0 when the report was printed and 2 when the server does not serve `skill.usage`.

| What Loom records | What the report says of it |
| --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| Which revision is published, and when | `published_revision`, `published_at` |
| Each answered `skill.get` of a revision that is or was published, in the request ledger | `fetches`: the sessions and principals that fetched each revision, and the last one |
| The reads the dashboard, the assistant and a command that shows a skill made | `inspector_fetches`: looks, shown beside the counts and never counted in them |
| A draft that waits, and the operations a published revision names | `stale` |

| What Loom does not record | What follows |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Which sessions were shown a listing line | The report counts fetches, and says how many skills of the namespace a listing can carry |
| A read of a copy pulled to a folder | The pull is one fetch, over HTTP. Later reads of the folder are none, so a skill with no fetch may still be read |
| What a session did with the text it asked | No count says a session followed a skill |
| A ledger row the server dropped | Every count is a lower bound |

- **A fetch.** An answered `skill.get` whose content hash is that of a revision that is or was published, made from the second after that revision was published. A read of a draft, of a rejected revision and of a revision that was never published is no fetch. A session is counted once a revision, whatever the transport; a request that named no session counts its principal only.
- **The window.** `window_days` is `days`, or the days the namespace keeps its request ledger when that is fewer; the statement says when the window was cut. One report folds at most 10,000 ledger groups, the most recent, and the statement says when the read stopped there. A skill with a revision that is or was published and no fetch among those groups is then said to have none among the rows read, not none in the window. A skill with no such revision, as one that never published, is said to be not fetched: the read looked for no fetch of it.
- **Stale codes.** `stale` holds codes from a closed set, each proven by rows the skill holds. `draft_waiting`: the skill's draft has waited for review for more than 14 days; answered to a caller who may write to the namespace, as the draft is. `unknown_operation`: the published revision names an operation the answering build does not serve. A skill nobody fetched has no code for that. A client shows a code it does not know by its name.
- **Who sees what.** The caller is reported the skills `skill.list` lists to it: a writer every skill of the namespace, any other reader the ones that serve a revision. A name the caller cannot list answers no skill, as a name that does not exist does. `by_subject` adds `subjects`, one entry a principal, revision, transport and consumer with the first and the last read; it needs `admin` on the namespace and is refused with 403 to anyone else.
- **A failed read.** When the ledger cannot be read the op fails. It never answers a skill as not fetched in place of an error.

## Delete a revision or a skill

```bash
Expand Down
Loading
Loading