Repository navigation
fix: refuse challenge remove while a community's settings.challenges still uses the package - #177
Conversation
… uses The refusal test fails until challenge remove checks settings.challenges. The runtime test pins what that costs: every publication is rejected and the community cannot start again.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…still uses the package challenge remove now mirrors page-sort remove: it asks the daemon which communities name the package and refuses, listing each entry. A package that shadows a pkc-js built-in is refused too, with a note that removal falls back to the built-in. --force skips the check and warns instead. Both remove commands now confirm the package is installed before contacting the daemon, and share the usage scan through collectPackageUsages in package-registry.ts.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…sertions at pkc-js#429
Closes #176
bitsocial challenge removedeleted a package even while a community'ssettings.challengesstill named it. That's worse than an error on challenge requests. A running community keeps advertising the challenge but rejects every publication, and on its next start (including a daemon restart)start()throws and the community stays offline.Changes
challenge removerefuses an in-use package, the same waypage-sort removedoes. It asks the daemon at--pkcRpcUrlwhich communities name the package, running or stopped, and lists each one as<address> settings.challenges[i]. Onlynameentries count; an entry with apathloads that file instead.question) is refused too. The message says that removal would fall back to the built-in challenge of the same name.--forceskips the check without contacting the daemon, then warns about what happens to communities that still name the package.page-sort remove --forcenow prints its own warning too.collectPackageUsages,assertPackageInstalledandisBuiltInPackageNameinpackage-registry.ts, plusfindChallengeUsagesinchallenge-utils.ts.page-sort removenow uses the shared scan too.docs/challenges.mdanddocs/page-sorts.md, and the README command reference.Tests
challenge-integration.test.ts, real daemon): the refusal test that reproduced the bug now passes. A second test pins the runtime effect of a missing package (every publication rejected,start()throws) and links Unregistered challenge name: opaque Zod error, and start() throws instead of reporting pkcprotocol/pkc-js#428.challenge.test.ts, fake RPC client): lists usages and skipspathentries, removes when unused, refuses a built-in shadow with the fallback note, refuses when the daemon is unreachable,--forcewarns (plain and built-in wording), and "not installed" is reported before contacting the daemon.page-sort.test.ts: the new check order and the--forcewarning.command-completion-time.test.ts:challenge removeruns there with no daemon, so it now passes--force.The full
npm run test:clipasses: 409 passed, 1 skipped.Upstream
pkcprotocol/pkc-js#428 is fixed by pkcprotocol/pkc-js#429. That PR names the error (
ERR_CHALLENGE_NOT_REGISTERED, and the publisher's reason sayschallenge "x" is not registered on this node), but deliberately keepsstart()refusing: it throwsERR_COMMUNITY_CHALLENGES_FAILED_TO_LOADbefore touching the network. A removed in-use package still takes the community offline, so the refusal here stays necessary.When pkc-js is bumped to a release that includes #429, update the e2e test's
start()assertion (it currently matches the old Zod message) and optionally tighten thereasonassertion. The test already handles theerrorevent that #429 adds for a running community.Summary by CodeRabbit
New Features
--forcesupport to bypass usage checks, with warnings about affected communities.Documentation