Repository navigation
Stop pinning registry skill names; follow the motoko rename - #128
Conversation
|
CI red on Reproduced on Root cause: the upstream registry renamed the skill.
Not fixing it here — it's unrelated to this PR's contents, and the right repair is a judgment call rather than a rename: pinning
Worth noting the test is doing its job here — it caught a live registry change. The question is only whether that should gate unrelated PRs. Happy to send a separate PR for whichever option you prefer. Generated by Claude Code |
`skills::tests::fetches_real_registry_and_a_skill` has been failing on main
since the upstream registry reorganised its catalogue: `motoko` is gone,
split into `writing-motoko`, `migrating-motoko-actors` and
`troubleshooting-motoko-migrations`. The test asserted on that exact name,
so an upstream rename we do not control turned every unrelated pull request
red. (`cycles-management`, its other pinned name, still exists — which is
why only the first assertion tripped.)
The test now asserts on the catalogue's SHAPE instead: the manifest parses,
it is not empty, every entry carries a name, and a name taken FROM THAT LIST
is fetchable with non-empty content. That is what this server actually
depends on, and all of it survives a rename. Re-pinning `writing-motoko`
would only move the tripwire to the registry's next reorganisation.
The rename also left three references that reach users and models pointing
at a skill that no longer resolves — `icp_get_skill("motoko")` now errors:
* the `icp_list_skills`/`icp_get_skill` schema descriptions, which clients
read as the example skill name;
* the server instructions, which steered models to load `motoko` first of
all the build-and-deploy skills;
* the tool table in the README.
All three now say `writing-motoko`, the direct successor (same "Motoko"
category, "Motoko language pitfalls, modern syntax, and architecture
patterns"). Every other skill cited in those lists — `mops-cli`, `icp-cli`,
`cycles-management`, `stable-memory`, `canister-security` — is still served
under its own name and is left alone. The synthetic manifest in
`parses_manifest_and_groups_by_category` keeps its made-up entries: it tests
the parser against fixed input and never touches the network.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ELxH7B4rYsEmrLf8tW4Uog
c1009dc to
43b60b3
Compare
motoko rename
There was a problem hiding this comment.
Pull request overview
Adds ICPBB-379 security triage and updates skill references/tests after the registry rename.
Changes:
- Documents the DCR vulnerability, impact, and remediation plan.
- Makes the live registry test independent of specific skill names.
- Updates selected
motokoreferences towriting-motoko.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
docs/security/ICPBB-379-triage.md |
Adds vulnerability analysis and remediation guidance. |
src/skills.rs |
Updates examples and relaxes the registry test. |
src/tools.rs |
Updates server skill guidance. |
README.md |
Updates the skill example. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/tools.rs:2004
- The server still exposes the removed skill name in three tool descriptions:
icp_get_skillatsrc/tools.rs:1258,icp_create_canisteratsrc/tools.rs:1298, andicp_install_codeatsrc/tools.rs:1345. Models can therefore still be directed to callicp_get_skill("motoko"), which this PR notes now fails. Update those skill-name references towriting-motokoas well.
`writing-motoko` (language), `mops-cli` (deps/build), `icp-cli` (build & deploy), \
The rename sweep missed these because they spell the name differently than the ones it caught: `icp_get_skill` escapes it inside the description string (`\"motoko\"`), and the two management tools mention it as bare prose rather than in backticks. All three are model-visible `#[tool(description = …)]` text, so they steer a model to a skill name that no longer resolves — `icp_get_skill` most directly, since its own description advertises the argument it takes: * `icp_get_skill` — the example skill name; * `icp_create_canister` — "see the motoko/icp-cli skills"; * `icp_install_code` — "see the motoko / icp-cli / mops-cli skills". The remaining `motoko` strings in `src/skills.rs` tests stay: they are synthetic fixtures for the manifest parser and the markdown-URL builder, where the name is an arbitrary identifier and nothing reaches the network. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ELxH7B4rYsEmrLf8tW4Uog
#129 landed the same repair on main from the other direction, so the two versions of `fetches_real_registry_and_a_skill` collided. Resolved wholly in main's favour — its test is now byte-identical here. Both dropped the pinned `motoko` name; main's requires one of a core set (`internet-identity`/`icp-cli`/`cycles-management`) to be present rather than fetching whichever entry sorts first, which checks something a little stronger. No reason to relitigate a design that is already reviewed and merged. What this branch still carries is the half #129 did not touch: the stale `motoko` references that are visible to MODELS and users, and that make `icp_get_skill("motoko")` fail against the live registry — * `icp_get_skill`, `icp_create_canister`, `icp_install_code` tool descriptions, and the server instructions; * the two schema doc comments in `src/skills.rs`; * the README tool table. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ELxH7B4rYsEmrLf8tW4Uog
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/skills.rs:96
- The PR description says the live-registry test now selects a name from the returned catalogue, but
fetches_real_registry_and_a_skillstill requires one of the fixed namesinternet-identity,icp-cli, orcycles-management(src/skills.rs:344-348). Renaming/removing those entries can still turn unrelated PRs red, and the claimed every-entry name check is absent. Please update that test to validate non-empty names and fetch an entry selected directly fromskills.
/// Skill name, e.g. "writing-motoko", "icp-cli", "cycles-management".
… are pulled The session gauges were pushed from the binary's /metrics handler, which is nobody else's exposition path. A host embedding this crate refreshes metrics on its own schedule, so those gauges would have sat at whatever value they last held — or never appeared at all. The pull point has to be something the caller can invoke. `Metrics::track(&McpServer)` registers a server, `Metrics::refresh().await` recomputes and publishes the derived gauges for everything tracked. Call it from an exposition path immediately before gathering, which makes the value exact as of that scrape, or from a timer if the pipeline refreshes on its own cadence. This crate deliberately does not choose; it only stops being the binary's private arrangement. `refresh` takes no arguments, which requires the handle to know its sources, so `Metrics` holds the tracked servers behind a shared `Arc<Mutex<_>>`. Clones share that set, since the handle is realistically cloned into middleware state and into an exposition path separately and tracking through either must be visible to both. The lock is never held across an await — the handles are cloned out first — and a poisoned lock warns rather than propagating a panic out of an instrumentation call. `set_sessions` becomes pub(crate) and takes `&'static str`, for the same reason `observe_request` did: a public `&str` setter is a caller-supplied label string, and the bound only holds if there is no way around it. `track` reads the name from IiInstance, where it is already `&'static str`, so the label is bounded by type. One deliberate behaviour change: `track` publishes zeroes on registration, so a served instance reads 0 from startup rather than being absent until the first refresh — but an instance that is *not* served is no longer forced to a flat zero. It is simply not tracked and has no series, which reads as "no such instance here" rather than "exists, currently idle". The previous flat zero for an unserved beta asserted something false. Also merges current main, which carries #128 — the registry renamed the `motoko` skill, and the live-network test asserting it only passes with that fix. That failure was branch staleness, not a regression here. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh
* metrics: expose Prometheus exposition at /metrics Wires a Prometheus registry into the router so the org's Prometheus / Victoria Metrics clusters can scrape this service directly, rather than inferring its state from a status page. Uses the `prometheus` crate pinned to the version dfinity/ic already depends on, since these series land in the same estate and two exposition dialects there would be nobody's win. What it reports: request counters and a latency histogram, taken from the facts the request-logging middleware already computed and previously only wrote to a log; the live and active session gauges that /version publishes, read at scrape time because they are derived state; build version and commit as labels on a build_info gauge, so any series can be attributed to an exact commit; process start time under the conventional name, so a redeploy is a step change rather than something to infer; and CPU, resident memory and file descriptors from the crate's process collector, compiled only on Linux since it reads /proc. Label cardinality is the whole design problem, not a detail. Every series is a row Prometheus holds in memory, so a label whose value an outsider picks is a memory-exhaustion primitive — and this service is internet-facing and continuously scanned, with a request log full of paths nobody here wrote. The route label is therefore never the requested path; it is axum's MatchedPath, the route template, which is bounded by the route table by construction and stays correct as routes are added. Unmatched requests have no template and collapse into one shared bucket. A test asserts that property rather than trusting the comment: 500 distinct unmatched paths produce exactly one series. Verified against a running server too, where 25 probe paths stayed one series while real routes kept their templates. Not published to the public internet. The app binds 0.0.0.0:8000, so a scraper reaches /metrics on the host's private address over the VPN — the same path the deploy already uses — and nothing needs exposing to make that work. Caddy returns 404 for the path rather than 403, so it is not advertised as existing. Metrics are not secret, but they are a free operational read (request volumes and error rates per route, session counts, process memory) and a public scrape target is also an amplification lever, since each request makes the process gather and encode its whole registry. The endpoint measures itself as well: a scrape that quietly got slow is how a target starts being dropped for timing out, and the resulting gap looks like an outage that never happened. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: bound the method label, and test the bound end to end Two review findings, both correct, and the first is a clean bypass of the guard this change was built around. The route label was bounded while the method label beside it was not. HTTP permits arbitrary extension method tokens and the public listener forwards them, so a request line reading WIBBLE / HTTP/1.1 minted its own series. Measured before fixing: twelve nonsense methods against a single path produced thirteen counter series and 182 histogram bucket lines, because a histogram multiplies every label set by its bucket count. The same twelve now produce one series and the buckets drop to 65. Methods are allow-listed to the standard nine and the helper returns &'static str, so the bound holds by type rather than by care. Worth naming the pattern rather than just the bug: I bounded the label I had been thinking about and left the one immediately next to it wide open, having written a module doc that presented cardinality as the central design problem. The doc now says the rule applies to every request-influenced label, and notes why status is the one that does not need it — the server chooses it, from a small closed set. The cardinality test was also vacuous, which is the more uncomfortable of the two. It built 500 distinct paths, discarded them, and called the recorder 500 times with a constant. That asserts a pure function is deterministic. It says nothing about the middleware deriving a bounded label from a hostile one, and would have passed unchanged if the middleware started using the raw URI — precisely the regression it existed to prevent. Both cardinality tests now drive real requests through an axum router with the real middleware installed. Confirmed by mutation: making the middleware use the raw path fails the path test and nothing else, and making the method label a pass-through fails the two method tests and nothing else. The old test survived the first of those mutations, which is the whole argument for the rewrite. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: make the instrumentation usable from the library Addresses consumer feedback that none of this was reachable: `mod metrics;` lived in main.rs, so the module was private to the bin target and an embedder depending on the crate got nothing. It is `pub mod metrics` in lib.rs now. Split log_request into write_request_metrics and write_request_logs, both exported. They are separated because their constraints genuinely differ rather than for tidiness: metrics must bound every label, while a log line can afford the full request path and is more useful carrying it. Splitting also lets an embedder take either one alone. The log moves from info to debug — it fires on every request including the noise floor of an internet-facing service, so at info it drowns the handful of lines an operator actually wants. Metrics::new now registers into a Registry the caller supplies and keeps none of its own. A host embedding this crate already has a registry and already exposes it; series published into a private one would simply never be seen. Exposition follows the registry, so render() is gone and the binary gathers its own; the scrape-duration signal survives as observe_scrape, recorded by whoever renders. Registering the process collector also stops being the library's business. `process_*` is un-namespaced and describes the whole OS process, which belongs to the embedding application rather than to this crate, and would collide with a host that already has one. It is now an explicit register_process_collector the standalone binary calls, since the binary is the application. The metric prefix is factored into a macro rather than repeated. A macro over a const plus format! keeps the names &'static str and keeps them greppable in full, so searching an alert rule's imcp2_http_requests_total still finds the line that defines it. Fixed rather than caller-configurable on purpose: a metric name identifies the software emitting it, and one dashboard working across every deployment depends on that. Verified from outside the crate, not only by unit tests: a scratch consumer crate registers imcp2's collectors into its own registry alongside its own metric, does its own exposition, and asserts no process_* leaked in. Also confirmed the log line is absent at default level and present under RUST_LOG=imcp2=debug, and that the binary still serves /metrics with the process collector it registers itself. Two library-safety properties the review raised are now pinned by tests rather than assumed: a second Metrics::new against one registry returns AlreadyReg instead of panicking, and Metrics::new registers no process_* series. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: close a cardinality hole the public API opened, and keep the deployed request log Three findings from review of the library move, all real. observe_request was public and took route and method as raw &str, writing both straight in as labels. Only the middleware normalised them, so the bound this module exists to enforce lived one direct call away from being bypassed — and an embedder reaching for the obvious-looking recording API would have bypassed it without noticing. That hole did not exist before the move, because nothing outside the binary could call it; making the module public created it. It is pub(crate) now, with the middleware as the supported entry point, and it normalises the method itself so the invariant holds at the recording site rather than depending on every caller. Reducing the surface now is also cheap in a way it will not be later: taking a public function away after release is a break. The process-start gauge claimed a conventional name it does not have. The prefix macro makes it imcp2_process_start_time_seconds, while the process collector the binary registers exports the actual conventional process_start_time_seconds — and the two measure different moments, observed three seconds apart on a real run: the collector reports OS process start, this reports when the server finished initialising and began serving, which is when a redeploy becomes visible to clients. Both are worth having and an embedder gets only ours, since the library does not register the collector. The comment now says that instead of the opposite. Moving the request log to debug would have silently deleted it in production. Both imcp2.service and the Dockerfile pin RUST_LOG=info, so the line that records what external clients actually probe would simply have stopped appearing on deployed hosts — the full paths the metrics deliberately discard, gone from the one place that keeps them. Both now set info,imcp2::metrics=debug: quiet by default for embedders and local runs, which is what moving it to debug was for, while the deployed hosts keep the record. Verified both filters against a running server: 0 lines under plain info, present with the target enabled. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: expose refresh() so an embedder controls when derived gauges are pulled The session gauges were pushed from the binary's /metrics handler, which is nobody else's exposition path. A host embedding this crate refreshes metrics on its own schedule, so those gauges would have sat at whatever value they last held — or never appeared at all. The pull point has to be something the caller can invoke. `Metrics::track(&McpServer)` registers a server, `Metrics::refresh().await` recomputes and publishes the derived gauges for everything tracked. Call it from an exposition path immediately before gathering, which makes the value exact as of that scrape, or from a timer if the pipeline refreshes on its own cadence. This crate deliberately does not choose; it only stops being the binary's private arrangement. `refresh` takes no arguments, which requires the handle to know its sources, so `Metrics` holds the tracked servers behind a shared `Arc<Mutex<_>>`. Clones share that set, since the handle is realistically cloned into middleware state and into an exposition path separately and tracking through either must be visible to both. The lock is never held across an await — the handles are cloned out first — and a poisoned lock warns rather than propagating a panic out of an instrumentation call. `set_sessions` becomes pub(crate) and takes `&'static str`, for the same reason `observe_request` did: a public `&str` setter is a caller-supplied label string, and the bound only holds if there is no way around it. `track` reads the name from IiInstance, where it is already `&'static str`, so the label is bounded by type. One deliberate behaviour change: `track` publishes zeroes on registration, so a served instance reads 0 from startup rather than being absent until the first refresh — but an instance that is *not* served is no longer forced to a flat zero. It is simply not tracked and has no series, which reads as "no such instance here" rather than "exists, currently idle". The previous flat zero for an unserved beta asserted something false. Also merges current main, which carries #128 — the registry renamed the `motoko` skill, and the live-network test asserting it only passes with that fix. That failure was branch staleness, not a regression here. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: gate the exposition, register atomically, order the gauge writes Four review findings on the metrics work, all real. **/metrics was public on a deployment path we ship.** The Caddyfile claimed the exposition "is NOT published to the public internet", and on the native host that is true — Caddy answers /metrics itself with a 404 and a scraper reaches the app on its own port over the VPN. But the bundled Dockerfile is a documented, supported deployment (README: Render, Fly, Cloud Run, Koyeb) with no proxy in it, so the platform routes the public hostname straight at the process and every registered route is on the internet. So the route is now gated on $MCP_SERVE_METRICS, defaulting to OFF: the exposure takes a deliberate opt-in on a host that has something to hide it, instead of requiring every other operator to notice and remove it. imcp2.service sets it; the Dockerfile does not. deploy.sh now also asserts on every deploy that the public origin does NOT answer /metrics with 200 — the Caddy block is a config edit away at all times, and that assertion is what makes it load-bearing rather than decorative. **Metrics::new was not atomic.** A collision partway through left the earlier collectors registered while returning Err, so the caller held no handle but its registry kept a partial set of our descriptors — and the retry, after the caller fixed the real collision, failed with AlreadyReg on the *first* collector, reporting a cause with nothing to do with the problem. Every collector is now built before anything is registered, and the group registers as a unit that unwinds on the first failure. **Two gauges cannot be written atomically, so order them.** A scrape landing between the live and active writes could see active > live, which the help text promises never happens and an alert dividing the two would report as a ratio above 1. Write active first when live is falling, live first when it is rising; both intermediate states then satisfy the invariant. refresh() is serialized against itself for the same reason, and for a worse one: two overlapping refreshes can commit in the order they *finish* rather than the order they read, leaving a whole scrape interval of numbers that were never true. **The track test asserted nothing about track.** It called the private setter, so it kept passing if track stopped retaining the server or stopped zero-filling. McpServer::new is pure construction, so it now uses a real server — the excuse that a fixture needs network config was simply wrong; tests/routers.rs builds one. Mutation-tested: flipping the write order, dropping the rollback, removing the zero-fill, dropping the retain, defaulting the gate on, and dropping the scrape timing each fail exactly one test. The first draft of the refresh test survived its mutation and was rewritten to poison the gauges first. 192 tests pass. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: publish both session gauges from one snapshot Follow-up review round, six findings. Four are real; the two I am not changing are answered in comments rather than silently. **The previous round's write ordering did not close the window it claimed to.** Ordering the two gauge writes makes every *instant* satisfy active <= live, but `Registry::gather` does not read an instant: it calls each collector in turn, so it reads live at one moment and active at another with nothing held between. A refresh landing in that gap exports live from before it and active from after — with counts rising, exactly the inversion. Reproduced: a gather loop against a writer flipping (10,5)/(3,1) hits `active=5 > live=3` within 20 gathers. No write-side care fixes a read-side problem, so the pair is now inseparable on both sides: one `SessionCollector` over one `Mutex<BTreeMap>`, whose `collect` takes the lock once and builds both families from the same snapshot. The two IntGaugeVecs and the write ordering are gone. The concurrency test is the real check — mutate `collect` to lock once per family and it fails in 1-19 gathers, three runs out of three, with the predicted values. **track() could publish counts and then clobber them.** It pushed the server, released the lock, then zero-filled — so a refresh racing in between published real counts that the zero-fill then overwrote, leaving the instance reading 0 until the next refresh. Both effects now happen under one hold of the lock. **The rollback promise was too strong.** `Registry::unregister` deliberately keeps `fq_name -> dim_hash` for the process lifetime, so "left exactly as it was found" was false: after a failed attempt, our names stay reserved to the shape we tried. The docs now say what the unwind does restore (collectors and descriptor ids, which is what makes a retry work) and why the residue costs nothing. An aggregate collector would not have fixed it either — `register` records each dim hash as it validates, before committing anything. **deploy.sh's exposure check proved less than it claimed.** "Not 200" is not "not published": if the catch-all proxies /metrics and the app answers 500, or if the curl never reached the origin, the check passed having disproved nothing. It now requires exactly the configured 404 and fails on everything else, retrying while Caddy reloads. The on-host serving check is fatal rather than a warning too — the unit hardcodes the opt-in, so a missing scrape target means a broken deployment, and silence there looks exactly like a service with no traffic. **Kept, with the reasoning corrected.** The request-metrics middleware stays ungated, but not for the reason the comment gave: flipping the gate needs a restart, which resets the registry, so there are no warm counters to inherit. The actual reason is uniformity — gating it would leave the shape most operators run (Dockerfile default, gate off) as the one nothing exercises, for the price of two atomics per request. 192 tests pass; clippy clean on both changed files. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: make the race test deterministic, and time the refresh it depends on Two findings, one from this round and one I found still open in the review history. **The race test could fail on a fast machine and hang on a real failure.** It looped `while !writer.is_finished()` and then asserted the loop had run at least 100 times, so a writer that finished its fixed 60k writes before the reader was first scheduled failed a correct collector. Worse, the assertion lived inside the read loop: on a genuine violation the test unwound without clearing the stop flag, the writer span on, and dropping the runtime waits for blocking tasks — so the failure hung rather than reported. A hanging test is worse than a flaky one; it eats the job timeout and says nothing. Verified by mutation, which previously timed out and now fails in 0.18s. Inverted: the reader does a fixed 2000 gathers and the writer runs until released, so CI speed cannot change the verdict. A barrier makes both sides live before the first gather, the violation is recorded and asserted after the writer is released, and the writer carries its own bound in case the reader dies some other way. `writes > 0` still refuses to pass a writer that never ran. Confirmed pinned to a single CPU (3/3) and unpinned (3/3); the mutation still fails it at gather 44-754. **The scrape histogram excluded the refresh that feeds it.** The timer started after `refresh().await`, so the one thing `imcp2_metrics_scrape_duration_seconds` exists to catch — a scrape slow enough for the scraper to drop the target — could come entirely from time the metric does not count. Refresh scans every tracked server's session map and waits on any refresh in flight, which is precisely the part that can get slow. Timed from the top of the handler now, with the help text and `observe_scrape`'s contract saying so. 192 tests pass; clippy clean on both changed files. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: sum servers sharing an instance, and make start time mean process start Two findings, both real. **Servers sharing an instance name silently under-reported.** `refresh` wrote each tracked server's counts keyed on `IiInstance.name`, so an embedder serving one Internet Identity instance at two mounts — two `McpServer`s both named `prod` — got the last one's sessions published as the whole instance's. An under-report with no symptom, which is the worst shape a metric bug can take. The counts are now summed per instance, which is what the label already claims: it names an II instance, not a mount. Aggregation is a free function over an iterator, deliberately. Going through `refresh` cannot distinguish summing from overwriting in a test, because every count reachable without authenticated sessions is zero and 0 + 0 = 0 either way. Mutating it back to assignment fails the new test; a second test drives two real servers through `track`/`refresh` and pins that one instance still yields one series. **imcp2_process_start_time_seconds did not mean process start.** Raised three times across rounds and each time I answered the name rather than the value. The name and help text said process start, my comment claimed it deliberately meant "began serving" instead, and the value was captured mid-`main` — after the agent, the servers and their reapers, before binding the listener — so it was neither, and disagreed with the process collector's conventional series by a couple of seconds for a reason no consumer could discover. A metric whose name says one thing and whose value means another is worse than not having it. The reading moved to the first statement of `main`; the name and help text were already right, so they stay. `/version`'s `started_at` becomes correspondingly accurate (the status dashboard only displays it, so nothing changes there). The gauge keeps its overlap with the process collector on purpose: an embedder gets only this one, since the library does not register that collector and it is Linux-only regardless. 194 tests pass; clippy clean on both changed files. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: label sessions ii_instance, and stop track() resetting an instance Two findings, both real. **The `instance` label collides with Prometheus's own.** Prometheus attaches `job` and `instance` target labels to every sample it scrapes, and with the default `honor_labels: false` a scraped label of the same name is not merged — it is renamed to `exported_instance` while `instance` becomes the target address. So `imcp2_live_sessions{instance="prod"}` arrives in the database as `exported_instance="prod"`, and every alert or dashboard query written against `instance="prod"` matches nothing. Silently: the series exists, the query is valid, the panel is just empty. Renamed to `ii_instance`, which cannot collide and says what it means — it is an Internet Identity instance, not a scrape target. Factored into one constant so the descriptors, the emitted label pairs and the assertions cannot drift apart. **track() reset an instance that already had sessions.** Fallout from summing the counts in the previous commit: the zero-fill wrote unconditionally, so tracking a second server for an instance with live sessions zeroed the whole instance's total until the next refresh. The fix for under-reporting would have introduced a different wrong number, and the same "sessions vanish for a scrape interval" shape at that. `track` now seeds the series only when it is absent, via a `seed_sessions` that exists to be distinct from `set_sessions` for exactly this reason. Both mutation-checked: seeding unconditionally fails the new test, and reverting the label to `instance` fails three. 196 tests pass; clippy clean on both changed files. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * deploy: check /metrics off loopback, and stop implying the scrape path is verified The loopback check proved the app serves the exposition, but the comment above it talked about the scraper reaching it over the VPN — which that check says nothing about. A green deploy could therefore be read as "monitoring works" while the private interface drops TCP 8000. Fixed the claim, and added the part of the path that is actually checkable from here: the host reaching itself on its private address, which proves the app bound 0.0.0.0 rather than loopback and that no host-local firewall eats the port. The address is derived on the host and never printed — this repository is public, so its Actions logs are too, and echoing a private address into them is the exact disclosure the repository was scrubbed to remove. curl's stderr is dropped for the same reason, since its errors would carry the URL. A warning rather than fatal: users are served through Caddy over loopback either way, so this affects scraping alone, and the remedy is a security-group or firewall change that failing a deploy does not bring closer. The remaining hop — the scraper's network actually reaching that address — is not verifiable from this script at all, since the deploy runs on a GitHub-hosted runner that is not on the VPN. Saying so in the file rather than leaving a check that looks more complete than it is; it stays the open question on the pull request. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * deploy: bound every blocking verification with a request timeout The public /metrics exposure check called curl with no --max-time, so an origin that accepts the connection and then never finishes the response hangs it forever. That is not just slow: the check never reaches its own retry loop or its own failure, so a security assertion silently becomes a deadlock — after the service has already been restarted. `|| true` does not help, since it handles a non-zero exit rather than the absence of one. health.yml's webhook curl already carried --max-time for exactly this reason; this was the inconsistency. Timed out now, which yields `000`, which is not 404, so it retries and then fails — the honest verdict for an origin that would not answer. Fixed the same defect in the other three places along this path rather than only the reported one: * the two informational external checks in deploy.sh (a hang wedges the deploy whether or not anyone reads the output); * deploy-native.yml's "Verify deployed version" step, the other blocking verification in this deploy. --max-time bounds each attempt there — curl applies it per transfer, so the existing --retry keeps its own budget — and --retry alone does not cover a stall, since it retries failures rather than a transfer that never ends. Left alone deliberately: the Caddy binary download in the provisioning path. A blanket --max-time there would kill a legitimately slow but progressing transfer; a stall guard for it wants --speed-limit/--speed-time, which is a change to first-run provisioning rather than to verification, and belongs in its own commit. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh * metrics: simplify — drop the concurrency machinery, halve the docs Owner-directed simplification. Review iteration had ratcheted this module into machinery out of proportion to what it publishes: a custom collector with hand-built wire types so a scrape could never observe active > live, a transactional registration with rollback, per-instance summing with a seed-vs-set distinction, three mutexes, and essay-length comments throughout. Each piece defended a real but marginal property; together they were the wrong trade for observability code, which should be boring. What changed: * The served servers are a constructor argument (`Metrics::new(.., &[&server])`) instead of a mutable `track()` API. The tracked set is immutable, so the tracked-set lock, the zero-fill-under-lock dance, and the track-races-refresh subtlety all disappear. * The session gauges are two plain IntGaugeVecs again. The help text now says what is true — active is sampled independently of live, so a scrape may briefly observe it above — instead of promising an invariant that took a custom collector, a pair mutex, a refresh mutex and a concurrency test to uphold. The failure it allowed was a one-sample dashboard blip. * Registration is sequential with a doc line ("not transactional; on error use a fresh registry") instead of an unwinding Registration type. * Duplicate instance names overwrite (documented) instead of summing. * Comments cut to the necessary reasoning everywhere the PR touched: module docs, main.rs, Caddyfile, imcp2.service, deploy.sh, both READMEs. What deliberately stays, because it is load-bearing: the route/method label bounds and their end-to-end flood tests (a label an outsider picks is a memory-exhaustion primitive), the ii_instance label (Prometheus renames a colliding `instance` to `exported_instance`), the MCP_SERVE_METRICS gate with its off default, the deploy assertions (exact-404 publicly, serving privately, --max-time on every external curl), refresh() as the embedder's pull point, and the caller-owned registry. Net -919 lines; src/metrics.rs 1352 -> 552. 187 tests pass; clippy clean. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh --------- Co-authored-by: Claude <[email protected]>
Summary
Fixes the
testjob, which was failing onmainindependently of this branch.skills::tests::fetches_real_registry_and_a_skillpinned the skill namemotoko. The upstream registry reorganised its catalogue and that entry is gone, split intowriting-motoko,migrating-motoko-actorsandtroubleshooting-motoko-migrations. A rename we don't control was turning every unrelated PR red. (cycles-management, the test's other pinned name, still exists — which is why only the first assertion tripped.)The test now asserts on the catalogue's shape: the manifest parses, it is not empty, every entry carries a name, and a name taken from that list fetches non-empty content. That is what this server actually depends on, and all of it survives a rename. Re-pinning
writing-motokowould only move the tripwire to the registry's next reorganisation.The rename also left three references pointing at a skill that no longer resolves —
icp_get_skill("motoko")errors today:icp_list_skills/icp_get_skillschema descriptions, which clients read as the example skill name;motokofirst of all the build-and-deploy skills;All three now name
writing-motoko, the direct successor (same "Motoko" category; "Motoko language pitfalls, modern syntax, and architecture patterns"). Every other skill cited in those lists —mops-cli,icp-cli,cycles-management,stable-memory,canister-security— is still served under its own name and is left alone.The synthetic manifest in
parses_manifest_and_groups_by_categorykeeps its made-up entries: it tests the parser against fixed input and never touches the network.Related issues
None.
Changes
src/skills.rs: assert on catalogue shape rather than pinned skill names; update the two schema doc examples.src/tools.rs,README.md:motoko→writing-motoko.Testing
cargo build --locked --all-targetscargo test --locked --all-targets— 151 lib + 6 main + 8 router, all passing, including the previously failing live-registry testcargo clippy --all-targets— no new warnings (11 pre-existing, none in the touched code)cargo fmt --all— deliberately not run. The tree is not in default-rustfmt style and there is norustfmt.tomlor fmt check in CI; running it reformats ~2,600 lines across 12 unrelated files. New code was matched to the surrounding style by hand.npm test --prefix monitoring/mcp-status— n/a, dashboard unchangedChecklist