Skip to content

Skills: browse the organization's library, and add skills on the agent - #802

Open
alex-clickhouse wants to merge 29 commits into
mainfrom
asoff/skills-p2-browse
Open

alex-clickhouse wants to merge 29 commits into
mainfrom
asoff/skills-p2-browse

Conversation

@alex-clickhouse

@alex-clickhouse alex-clickhouse commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

In external mode with an MCP gateway that offers a library, a person can now browse every skill that the organization offers, open its files, and add or remove a skill on this agent. The Skills page says how each library skill got on the agent. Standalone Nerve is unchanged.

What changes

  • Browse library, a new page at /library, reached from the Skills page: a search that runs after a short pause, a tag filter with the count of results for each tag, cards with tags, the release and "Used by N agents", pages, a read-only viewer of the files of an item, and Add or Remove.
  • Skills page: each library skill says "Installed by default", "Installed from the console" (with the link to the console) or "Added on this agent". An added item has Remove, also when another source gives the skill too; the page then says what stays. An item whose files Nerve could not get shows Failed; before, it was not shown. Added items that are not in the agent's set now have their own section.
  • API under /api/skills/library/: browse, items/{id}, and PUT and DELETE of added/{id} (the answer has added, installed_by and enabled). GET /api/skills has a library member.

How

  • Added items. The ids are rows of the new table library_added (migration v077), so the gateway process and a one-shot command such as nerve sync send the same list. Nerve sends them in the query parameter added of the document request: valid ids, in byte order, no repeat, at most 100.
  • The document. Nerve serves the availability values available, default and required, and the installedBy values required, default, console and agent. A document that breaks the contract is refused whole: the level not_available, an installedBy that does not go with its availability, a wrong withdrawn or tag list, more than 200 items. The last good document then stays and the report says refused. A value that Nerve does not know leaves only its item out. The report has the member pinned, false for every item.
  • One applied catalog. One method gives the items that Nerve applies, from the last good document and the lock state: at the start, at each read (also a failed one) and at each use. While the instance is locked, the skills that people added on the agent do not apply: Nerve sends no added and serves and reports no installedBy: agent item, also in a running instance while the gateway does not answer. The added ids stay stored and apply again when the lock ends.
  • Add and remove store the change, then force a new read of the document and one skill scan, under one lock. A read that started before the change does not count.
  • The on or off choice of an added skill. The read after the add or the remove decides it: the choice goes with the add only when no other source gives the skill. When the organization or a console install still gives it, the choice stays, so a skill that was off for everyone does not turn on. Only a read that took the list of added skills after the request was stored decides it, so a read that was already on the way cannot decide from an older document. A failed read leaves the decision to the next accepted document (table library_choice_settle), and a choice that a person made after the request always stays.
  • Rebuilds. Live clients build again at their next safe turn only when the library skills of the prompt change (id, version, digest, name, description, on or off). One check does this at the end of every skill scan, whoever started it (a read, Sync, a configuration reload), and after a person's toggle of a library skill. A change of tags, of withdrawn, or of the revision alone builds no client again.
  • Recovery. A read scans again when a release that Nerve serves is in the cache but not in the last scan: an archive that another process fetched, a scan that failed, or an index row that could not be written.
  • Browse checks the query with the rules of the gateway (raw query bound, each parameter name once, the page pattern), forwards it to GET <mcp_gateway_url>/library/browse, and checks the answer with the rules of the contract. An answer that contradicts itself is refused; a result with an unknown kind or availability is left out, as in the document.
  • The detail of an item that is not on the agent asks the gateway at each request whether the organization offers it now (browse?id=). Its files come from its archive, fetched by digest, with the size, digest, entry type and path checks of an installed item. The cache holds bytes, never an offer.
  • No library, no change. While Nerve has no current or last good library document, every library route answers 404 no_library, sends nothing and changes nothing.

Trust boundaries

  • The Nerve process parses all new input: the queries of the browser, the answers of the gateway, and archives. It holds the workspace and the agent's tools already. Each input is bounded and checked before use, no pattern is built from it, and library text is shown as text.
  • No error body of the gateway reaches the browser. Each gateway failure becomes an error code of Nerve (no_library, invalid_request, rate_limited, library_unavailable).
  • Known gap, as before this PR: the archive is unpacked in the Nerve process. A helper process without access to the workspace would limit a defect of the unpack code.

Limits

  • An archive of an item that is not in the agent's set stays in the cache for 24 hours, by the rule of the cache cleanup.
  • After a remove whose forced read failed, the on or off choice of the item is decided at the next accepted document, not at once.

Rollout

Active only in external mode with a gateway that offers /library. A gateway with no /library answers as "no library", and Nerve then shows no browser.

This PR changes the document contract in place: every item must have withdrawn, tags must be in order, and supersedes is gone. A gateway that still serves the earlier contract gets every document refused. Nerve then has no library skills, the required ones included, and it also refuses a catalog.json that an earlier Nerve stored. No deployment serves a library yet. Deploy the gateway of the same work before, or together with, a Nerve that has this change, and turn the library on only after that.

Verification

  • Five independent review rounds; the findings of each are fixed in the commits after the first two.
  • Cursor Bugbot found that a read already on the way could decide the on or off choice of a Remove from an older document. The last commit fixes it; an independent check ran that case on the commit before (the choice is lost) and on this one (it stays), with six variants.
  • An independent verification of the last 25 commits on a running engine with injected faults: a console install that arrives during a gateway outage, then Remove (the off choice stays, also after a restart); a failed forced read; a lock set by a configuration reload while the gateway answers 503; four documents that break the contract (each refused whole); a toggle followed by a change to Required in a conversation that is already open; an archive that another process fetched; a failed index write; 30 rounds of an add with a remove at the same time. Five rules were broken on purpose, and a test of this branch failed each time.
  • The full backend suite with a temporary home: 12,171 collected, 12,132 passed, 39 skipped, 0 failed. npm run build; npm test: 3,252 passed. The migration number check. ruff --select F: no new finding.
  • The contract fixtures (tests/fixtures/library/) are byte-for-byte copies of the examples of the gateway side.

Screenshots

The images are on the branch asoff/skills-p2-browse-screenshots (images only, never merge). All data in them is invented.

Light Dark
Library browser, desktop
Item detail, desktop
Skills page, desktop
Library browser, phone
Item detail, phone
Skills page, phone

🤖 Generated with Claude Code


Note

Medium Risk
Touches which skills are loaded into running agents, preference semantics, and external-gateway parsing in a large concurrency-sensitive path; scope is limited to external mode with an MCP library, but mistakes could change prompts or skill availability unexpectedly.

Overview
Adds end-to-end support for the organization’s MCP skills library in external mode: users can browse offered skills, inspect files, and add or remove items on this agent, with matching API routes under /api/skills/library/ and UI at /library plus richer Skills page state (library, installed_by, failed, remove/add flows).

Backend behavior changes materially: library document fetches now include an added query built from new DB tables (library_added, library_choice_settle via migration v077); the gateway document model grows console / agent install sources, stricter validation (withdrawn, tag order, availability pairing), and an applied catalog that respects lockdown (no agent-added skills served or reported while locked). Adds/removes force a fresh library read and skill scan under a lock; on/off preferences for added skills are settled on the next accepted document so org/console installs don’t resurrect a skill everyone turned off. Live client rebuilds only when prompt-relevant library skills change (signature check after each scan/toggle).

New LibraryBrowser proxies and validates GET …/library/browse, maps gateway errors to Nerve codes, and loads off-catalog item content from archives into the shared cache (with rescan when cached content catches up).

Reviewed by Cursor Bugbot for commit 771867d. Bugbot is set up for automated code reviews on this repo. Configure here.

…er API

In external mode with an MCP gateway that offers a library, a person can add
an item that the organization offers on this agent, remove it again, and
search the whole library.

- The document request names the added items in the query parameter
  `added` (valid `@nerve/<slug>` ids, byte order, no repeat, at most 100).
  The ids are rows of the new table `library_added` (migration v077), so the
  gateway process and a one-shot command such as `nerve sync` send the same
  list. The parameter is not part of `library_url`, so the report URL stays
  as it is.
- Nerve serves the availability values `available`, `default` and
  `required`, and the installedBy values `required`, `default`, `console`
  and `agent`. An item whose installedBy does not go with its availability
  is left out. Each item has `withdrawn` (at most 20 versions below
  `version`, highest first), which Nerve checks and keeps; `supersedes` is
  not read. Tags must be in byte order with no repeat.
- `GatewayLibrary.refresh(force=True)` reads again after a read in progress,
  because that read can have started before an add or a remove. The forced
  read and the skill scan of one change of the added items run under one
  lock (`AgentEngine.library_added_changed`), so the scan of the last change
  runs last.
- Live clients build again only when the library skills of the scan change
  (an item that comes or goes, or a new id, version, digest, name or
  description). A change of tags, of `withdrawn`, of installedBy or of the
  revision alone builds no client again.
- The report has the member `pinned` after `digest`, `false` for every item.
- `nerve/skills/library_browse.py` sends the search to
  `GET <mcp_gateway_url>/library/browse`, checks the answer strictly within
  bounds, and maps each failure to an error code of Nerve (`no_library`,
  `invalid_request`, `rate_limited`, `library_unavailable`): no body of the
  gateway reaches the browser. An answer that contradicts itself (counts
  while `agentCounts` is false, more results than `total`, items on a page
  above `pages`) is refused; a result with an unknown kind or availability
  is left out, as in the document.
- The detail of an item that is not on the agent asks
  `GET /library/browse?id=<item id>` at each request, which gives only that
  item when the organization offers it now. Its files come from its
  archive, fetched by digest with the checks of an item of the document,
  into the same cache. The cache holds bytes, never an offer: an item that
  the organization stops offering gets 404 also when its files are cached.
  The detail of an item of the set has no use count.
- Routes under `/api/skills/library/`: `browse`, `items/{id}`, and `PUT` and
  `DELETE` of `added/{id}`. A new add and a remove delete the on or off
  choice of the item, so an added item starts on; a repeated add of an item
  that is added changes nothing. An add and a remove are refused on a
  locked instance and for an id that is not `@nerve/<slug>`; an add is also
  refused above 100 items. The browse route refuses an empty `page` and a
  parameter given twice with its own `400 invalid_request`. While Nerve has
  no current or last good library document (the gateway answers 404, or no
  read succeeded), every library route answers 404 `no_library` and reads
  and changes nothing. `GET /api/skills` has a `library` member (offered,
  managed_by, changes_allowed, added), and a row with `failed: true` for an
  item whose archive Nerve could not get. `/api/skills/library` with no
  further segment stays the detail of a workspace skill with the id
  `library`.

The fixtures document.json, report.json and browse.json are the examples
of the wire contract of the control plane, byte for byte. Nerve reads a
browse answer of at most 4 MiB. docs/config.md, docs/api.md and
docs/architecture.md describe the protocol, the routes and the design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When `GET /api/skills` says that the MCP gateway offers a library, the
Skills page has **Browse library**, which opens the page `/library`. The
page is not below `/skills/`, so a workspace skill with the id `library`
keeps its detail page.

- The browser has a search field (the search runs 300 ms after the last key
  press), a tag filter with the count of results of each tag (at most 5
  tags), result cards with the tags, the release and "Used by N agents"
  (when the gateway has counts), and pages. A result says how it is on the
  agent ("Required", "Installed by default", "Installed from the console",
  "Added") or has **Add**, which is disabled on a locked instance with the
  reason. The name of a result opens a dialog with the files of the item in
  a read-only viewer, with **Add** or **Remove**, and the use count of the
  result. The page shows the results of the current query only: while a
  new search runs and after a failed one, no earlier result is shown.
- On the Skills page each library skill says how it got on the agent:
  "Installed by default", "Installed from the console" with the console
  link, or "Added on this agent". Every added item has **Remove**, also
  when a console install or the organization's setting supplies it now,
  and the text says that the install or the setting stays. An item whose
  files Nerve could not get shows the badge **Failed**, with no switch and
  no detail view; a required one still says who requires it. Added items
  that the organization does not offer now are listed under **Added, not
  offered now**, with **Remove**.
- Each error shows the `detail.message` of Nerve. A done add or remove
  shows on the page also when the reload of the list after it fails.

The specs assert roles, names and states. docs/web-ui.md describes the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

AI review gate — AI review passed

Clean review from: Cursor Bugbot.

alex-clickhouse and others added 26 commits December 3, 2026 21:13
…disagree

The contract requires that `installedBy` goes with `availability`:
`required` with `required`, `default` with `default`, `console` and `agent`
with `available`. When both values are ones that Nerve knows and they do
not go together, Nerve refuses the whole document: it keeps the last good
document and its skills, and the report says `refused` with the revision
of the new document. An item with a value that Nerve does not know is
still left out alone, and the rest of the document applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he agent

While the instance is locked, the choices that people made on the agent
do not apply: Nerve gets library skills only from the organization's
levels and console installs. `GatewayLibrary` takes `locked` (the engine
passes `is_locked`). While it is true, the document request has no
`added`, and the catalog that Nerve applies leaves out each item with
`installedBy: agent`, also in the document that it stored before the lock
and reads at start. So such an item is not served and not reported. Nerve
keeps the stored added ids; when the lock ends, they apply again. A read
whose items differ from the catalog in use counts as a change, also with
the same revision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in the prompt

The rule that decides when live clients build again compares, for each
library skill of the scan, its id, version, digest, name, description, and
now also whether it is on. The prompt lists only the skills that are on.
So when the organization makes an item `required` that a person turned
off, the next safe turn builds the client again and the prompt lists the
item; when the item is `default` again, the stored off choice applies and
the prompt drops it. A change of `installedBy` that leaves the prompt as
it is still builds no client again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…chive of the document

The detail of a library item can fetch an archive that the current
document uses and that the cache did not have, for example after a failed
fetch of a read. Then Nerve scans the skills at once, with the rule of a
read that fetches it (`AgentEngine.library_content_arrived`, under the lock
of a change of the added items): the Skills page no longer shows the item
as failed, new sessions get it, and live clients build again at the next
safe turn. Later reads of the same document need no change for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y contract

The browse route checks the raw query as the gateway does before it sends
the request: at most 16 KiB, form encoded (ASCII, no `;`, each `%` followed
by two hex digits), values valid UTF-8 after the decoding, and each of
`q`, `tags` and `page` at most once. `page` is decimal digits without a
sign or a leading zero, 1 to 1000, checked before the conversion. The
words of `q` are taken before the lowercase step, so a letter whose Python
lowercase has two characters stays one word, as in Go. A query that breaks
a rule gets Nerve's `400 invalid_request`.

A browse answer must follow the contract: `total` and `page` at most 1000,
`pages` the number of pages of `total`, the number of items that `total`
and `page` give (counted before Nerve leaves out a result of an unknown
kind or availability), no count while `agentCounts` is false, at most 5
tag counts for each result, each at most `total`, highest count first,
then by tag. JSON nested too deeply is not JSON for the decoder. Each
failure becomes Nerve's `502 library_unavailable`.

The detail of an item answers `agents: null` when the gateway has no
counts, not 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd no dead Remove

- The section of added items that are not in the agent's set now shows
  only while the gateway offers a library; without one a remove cannot
  work. Its heading is "Added, not in this agent's set now", and it says
  only what Nerve knows: the item is added and not in the set now (the
  organization does not offer it, or the set is full).
- After a successful remove, the page applies the answer before it loads
  the list again: an item that nothing else supplies leaves the list, and
  an item that a console install or the organization's setting supplies
  stays with that way and is on (the remove deleted the stored off
  choice). So a failed reload leaves no wrong switch.
- The add and the remove of the store give the answer of the change. The
  dialog of an item applies it at once, so a failed reload of the detail
  leaves no Add or Remove that no longer applies.
- The dialog shows no use count when the gateway has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/api.md, docs/config.md and docs/architecture.md say that a new add
starts the item on, and that a repeated `PUT` of an item that is added
already keeps the stored choice. docs/config.md also says that an added
item that is not in the document can be out of it because the
organization does not offer it or because the document is full: Nerve
knows only that the item is not in the agent's set now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The browser shows the results of the current query only, so the pages
control goes away while page 2 loads and comes back with its answer. The
spec waits for "Page 2 of 2" on the screen and then takes the new control,
instead of the control of page 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A browse answer must also follow two rules of the contract for its tag
counts: their sum is at most 5 for each result (`total * 5`), and each tag
of an item of the page is in the counts, with a count of at least the
number of items of the page that have it. Nerve checks them on the answer
as received, also for a result that it then leaves out for an unknown
kind or availability, and answers `502 library_unavailable` for an answer
that breaks one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A document never has an item with `availability: not_available`: the
gateway gives only the items that the organization offers. Nerve refuses a
whole document that has one, as it refuses two known values of
`installedBy` and `availability` that do not go together: it keeps the
last good document and its skills, and the report says `refused` with the
revision of the new document. A value that Nerve does not know still
leaves only its item out, and the rest of the document applies.

docs/config.md gives each case its own outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g instance

`GatewayLibrary.catalog` is now the view of the last good document that
Nerve applies at this moment: while the instance is locked, without each
item with `installedBy: agent`. Every user of the catalog (the skill
source, the report, the routes, the scan) reads this one view, so a change
of the lock setting in a running instance holds at once, also while the
gateway does not answer and no read succeeds. The next read, which also
runs before each new session, sees the changed lock state as a change: it
scans the skills, and live clients build again at their next safe turn.
When the lock ends, the added items come back in the same way. The cache
keeps the folders of the items that the lock leaves out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… off choice

One method of the engine, `_library_prompt_check`, compares what live
clients take from the library (each library skill's id, version, digest,
name, description, and whether it is on) with what they took, stores it,
and makes live clients build again at their next safe turn when it
changed. It runs after each scan (after a read, after an add or a remove,
after a change of the lock) and after a person turns a library skill on or
off on the Skills page. So when a person turns a default skill off, a new
conversation starts without it, and the organization then makes the same
release required, the next safe turn of that conversation lists the skill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… browser has

After the detail of a library item has its files in the cache, Nerve
checks whether an item of the current catalog has that digest and the
last skill scan does not hold that item with that digest. Then it runs the
retryable scan of the library (`GatewayLibrary.rescan`, under the lock of
a change of the added items). That covers an archive that the detail just
fetched, an archive that another process put in the shared cache, and a
scan that failed before. A scan that fails stays due until one succeeds,
so the next detail or the next read runs it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ameters in the API schema

The browse route answers `400 invalid_request` for any parameter name that
is in the query twice, known or not, as the gateway does. A parameter
other than `q`, `tags` and `page` given once is ignored and not sent to the
gateway. The route declares `q`, `tags` and `page` again, so the generated
API schema lists them; the check of the raw query stays the one that the
route applies. The test of the raw-query bound parses exactly 16 KiB,
refuses one byte more, and checks the bound of the search text apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…added library item

The stored on or off choice of a library item goes with its add only when
no other source gives the item: in the catalog in effect its `installedBy`
is `agent`, or the item is not in the catalog. Then a new add starts the
item on and a remove deletes the choice, as before. When the organization
(`required`, `default`) or a console install gives the item, an add and a
remove keep the choice, so a skill that a person turned off stays off.
`choice_goes_with_add(catalog, item_id)` in `nerve/skills/library.py`
decides it for both routes; `add_library_item` and `remove_library_item`
take `clear_choice`.

On the Skills page, a remove whose answer names another source keeps the
switch as it is (a required item is on), and the note says that the
console install or the organization's setting and the on or off choice
stay. docs/config.md, docs/api.md and docs/web-ui.md say the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t and how

docs/config.md says that `PUT /api/skills/library/added/{id}` stores the
add and forces a read, and that the document that comes back decides
whether the item is in the agent's set and by which source: a document has
at most 200 items, and the `required`, `default` and console items come
first. The answer gives the `installedBy` of that document, `null` when
the item is not in it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`GatewayLibrary._apply_added` gives `catalog`, the items that Nerve
applies, from the last good document as the gateway sent it and the lock
state: while the instance is locked, without each item with
`installedBy: agent`. It runs at the start, at each read (also a failed
one), and in `current_catalog()`, which the skill source, the report, the
routes and the engine read. So a change of the lock holds at once at each
of these points, also while no read succeeds. When the applied items
change, a skill scan is due, and the next read, which also runs before
each new session, runs it; live clients then build again at their next
safe turn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n a remove

`choice_goes_with_add` keeps the stored on or off choice of an added
library item only when the organization (`required`, `default`) or a
console install gives an item that Nerve serves. An item with an
`installedBy` or a kind that Nerve does not know counts as no other
source, as in the `installed_by` of the API answer, which is `null` for
it. So a remove of such an item takes its choice away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… that follows it

An add or a remove of a library item stores the change first and leaves
the item's on or off choice as it is. It records the request in the new
table `library_choice_settle` (in migration v077). After each read that
accepts a document, `AgentEngine._settle_library_choices` decides each
recorded request by the applied catalog of that read: when no other source
gives the item (`choice_goes_with_add`), the choice goes, else it stays. A
choice that a person made after the request stays in any case. So a
console install that came after the last read and before a remove counts,
and the stored off choice stays. When the forced read of the add or the
remove fails, the choice stays, and the next read that accepts a document
decides it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…em is not written

A skill scan records whether it wrote the index row of each skill of a
read-only source other than the platform (a library item):
`SkillManager.read_only_index_complete`. The scan of the library
(`AgentEngine._library_changed`) gives False when a write failed, and the
library keeps the scan due (`_scan_due`) after a read and after
`GatewayLibrary.rescan`, so the next read scans again. So a temporary
database error during the scan of a recovered item no longer leaves the
Skills page with a failed row after the database works again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot in the last scan

Each read of the library checks whether an item that Nerve serves has its
release in the cache while the last skill scan of the process does not
hold it with that digest (`GatewayLibrary.scan_lacks_cached`, with
`scanned` from the engine). Then the retryable scan runs. So an archive
that another process (a one-shot command) fetched after a failed fetch of
the gateway process reaches new sessions at the next read, with no detail
request. The detail of an item uses the same check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ill scan

`SkillManager` takes `on_scan`, which runs at the end of each scan,
whoever starts it. The engine passes `_library_prompt_check`, so the
comparison of what live clients take from the library runs after the scan
of a read, of an add or a remove, of Skills Sync, and of a configuration
reload, and still after a person's on or off choice. So after Skills Sync
picks up a release, or a reload turns the lock on, the next safe turn of
an existing conversation builds its client again with the changed library
skills.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gives its scan

`GatewayLibrary(scanned=...)` is optional: without it (a library that no
engine runs), a read does not compare the cache with a last scan that it
does not know, so it makes no scan due for it. The engine always gives
`scanned`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge shows it

The answer of `PUT` and `DELETE /api/skills/library/added/{id}` has
`enabled`: whether the item is on after the change (a required item is
on, else the stored choice), `null` when the item is not in the agent's
set. On the Skills page, a remove whose answer names another source keeps
the item with that source and the `enabled` of the answer, so a failed
reload of the list does not show a switch on for an item that is off (for
example a required item that became default while the page was open).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n be the last good document

docs/config.md and docs/api.md say that `added` in the answer of `PUT`
confirms the stored add, and that `installed_by` comes from the document
of the forced read, or from the last good document when that read failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/architecture.md says that an add or a remove stores the change,
leaves the on or off choice as it is and records the request in
`library_choice_settle`; after the next read that accepts a document,
`AgentEngine._settle_library_choices` decides it: the choice goes with the
add only when no other source gives the item, it stays when the
organization or a console install gives it, and a choice that a person
made after the request stays. Its table list names `library_added` and
`library_choice_settle`. Two long lines of docs/api.md and docs/web-ui.md
are wrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-clickhouse
alex-clickhouse marked this pull request as ready for review December 4, 2026 05:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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 a9b9cdf. Configure here.

Comment thread nerve/skills/library.py Resolved
pufit
pufit previously approved these changes Dec 4, 2026
@nerveai

nerveai commented Dec 4, 2026 •

Copy link
Copy Markdown

Nerve PR review · ✅ Ready to merge

Updated for 771867d: this commit fixes the stale-read settle. A read now takes the settle requests before the added list (library.py:938-943) and settles only those (:724). settle_library_choice skips a request that a newer one replaced (db/skills.py:167-172). There is one fetch path, under the read lock, so a periodic read that is already running can no longer decide a later Remove. The author kept the strict withdrawn/tag parsing on purpose, and the PR body's Rollout section now says to ship the gateway first. That settles my earlier blocker.

Brings the organization's skills library to external mode: a /library browser with a read-only file viewer, and Add/Remove, stored in library_added (v077) and sent with each read of the document. The Skills page now says how each library skill got there. Standalone Nerve is unchanged. #805 stacks on this branch.

Completeness: thorough backend and web tests (the new race tests included), docs, v077 above main's v076. CI green (8/8).

Worth considering:

  • The rule "gateway before Nerve" is only in the PR body. docs/config.md § The document (~:2660) doesn't say that an older gateway or an older stored catalog.json gets refused whole. A line there would reach operators.

Checked: full suite in an offline sandbox at 771867d (3 chunks): 12117 passed, 41 skipped; test_slack_integration.py excluded (hangs offline on main too). web/ is unchanged since a9b9cdf (web sandbox there: build OK, 3252 tests passed). Read the delta in library.py, engine.py, db/skills.py and the new tests · automated review by nerveai — mention @nerveai to ask a follow-up.

… list after the request

A settle request of an add or a remove is decided only by a read that
took the added list after the request was stored. When a read takes the
added list, it first takes the settle requests that exist at that moment
(`GatewayLibrary(requests=...)`, item id and time); after the document of
that read is accepted, `AgentEngine._settle_library_choices` decides
exactly those requests. A request stored later waits for a later read,
such as the forced read that the add or the remove starts. So a periodic
read whose document was built before a console install no longer deletes
the off choice of a remove or a first add of that item. A request that a
newer request of the same item replaced is not decided. A choice that a
person made after the request stays, a failed read decides nothing, and a
repeated add records nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-clickhouse

Copy link
Copy Markdown
Collaborator Author

Answer to the review above (the two points):

withdrawn as a required member, and tags in order. Correct: this PR changes the document contract in place, and a gateway that still serves the earlier contract with its library on gets every document refused. No deployment serves a library yet, so the answer is the order of the rollout, not a looser parser: the gateway of the same work goes out before, or together with, a Nerve that has this change, and the library is turned on only after that. The Rollout section of the description says this now, also that Nerve refuses a catalog.json that an earlier Nerve stored. I did not make a missing withdrawn mean []: the reader refuses a document that breaks the contract on purpose, so a gateway that does not follow it is seen at once.

The stale-read settle. Fixed in 771867d (details in the thread of that finding). A read decides only the requests that existed when it took the list of added skills. The case fails on the commit before and passes now.

@security-ai-gate-reviewer

Copy link
Copy Markdown

AI review gate — auto-approved

771867dd5f31 is approved by security-ai-gate-reviewer[bot], an automated identity, not a human. The approval stands on the required AI review: Cursor Bugbot concluded green on this commit and the AI review gate is SUCCESS (its own comment has the verdict), and the change touches no path that requires a human reviewer. It covers this diff only: after a push that changes it, the approver evaluates the new head and approves it only if it is green.

History (latest 5 heads, newest first)

  • 771867dd5f31 approved — green: Cursor Bugbot

@alex-clickhouse

Copy link
Copy Markdown
Collaborator Author

On the last point (the rule "gateway before Nerve" for operators): the sentences are in docs/config.md now, in the section of the document, but in #805 (commit 23330d0), not here. #805 changes the same file and lands with this PR, and this PR stays at the commit that was reviewed.

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.

3 participants