Repository navigation
Conversation
installRemoteService (src/host/remote.ts) replaces the three mount-once copies in src/lifecycle.ts for the usage, purge and store-inspection services. It keeps one service per root while some live activation holds it, reads the options of the most recently applied activation that is still live, and disposes the service with the last activation. Every outcome is reported through the activation's own ctx.logger once the mount has settled. This fixes what the old copies got wrong on a real cordis Context: a healthy boot logged a false "did not register" warning because the check ran before the service loaded; a changed usageBaseURL or a disabled usage service was ignored until a restart; disabling the plugin left all three services answering; and a refused mount or a synchronous throw was reported through cordis's own line or console.warn instead of the activation's logger. The provide arm, which could never publish anything, is dropped, which flips the case labelled KNOWN_DEFECT P5. The phase also adds L1's warn-once: the stream hook warns once on a decorated turn when globalThis.fetch is no longer the patched function, and stays silent while any live activation's patch is in the chain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0141fKp5k6hiaJcP5ovhGtSD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase P5 of docs/improvement-plan.md, stacked on #175.
What changed
src/host/remote.ts(new)installRemoteService(ctx, Service, contract, options), the one installer for the usage, purge and store-inspection services. It keeps one service per root while some live activation holds it, the service reads the options of the most recently applied activation that is still live, and the last activation to go disposes it. Every outcome is reported through the activation's ownctx.logger, after the mount has settled. Its promises never reject, becausescripts/check.ts's consumer probe does not awaitapply. Held at 100% coverage.src/lifecycle.tsctx.providearm (mountByProvide), which could never publish anything, is dropped, and the case labelledKNOWN_DEFECT P5flips.src/stream-hook.tsglobalThis.fetchoutside the plugin's live patches warns once.installFetchPatchreturns the predicate, so two live activations' nested patches raise no warning.src/usage.ts,src/usage-contract.tstest/remote-service.test.ts(new),test/lifecycle.test.ts,test/stream-hook.test.ts,test/opencode-store-service.test.ts,test/support/composition.ts,test/support/src.tsContext(latest live options, last-holder dispose, settled reports, a refused mount said by name, the fiber-less and failed-mount release), L1's guards, and aKNOWN_DEFECT P6case for three overlapping activations, which P6 flips.vite.config.tssrc/host/remote.ts, and uncovered branches named by expression instead of stale line numbers.README.md,README.zh-CN.mdAGENTS.md,CONTRIBUTING.md,docs/testing.md,docs/improvement-plan.mdDefects on the base this fixes, reproduced on a real cordis
Context(4.0.6-alpha.2):the usage service did not registerwarning, because the check ran beforeroot.plugin(GoUsageService, …)had loaded.usageBaseURL,read()still went to the first activation's base; turningusageEnabledoff left the usage service present.console.warninstead of the activation's logger.Behaviour changes
installRemoteServiceinsrc/host/remote.tsreplaces the three mount-once copies (usage, purge, opencodeStore). Each service reads the latest live activation's settings, reports throughctx.logger, and disposes cleanly on reload and disable.globalThis.fetchis no longer the patched function. It stays silent while any live activation's patch is still in the chain.On the title. The workflow landed this as
refactor:, but the plan's P5 row retitles the phasefix:(review finding rules-1-P5-DOC-1), because the README pair announces user-visible changes and arefactoris hidden from the changelog. The plan leaves the choice to the owner at landing: either squash asfix: the remote services follow the plugin's latest activation and go with its last, or keeprefactor:and drop the README pair.Review
Three rounds, each with a correctness lens and a test lens (and a rules lens in round 1), each followed by a fix and a verify pass.
Round 3's three were plan bookkeeping (which pins guard L1's predicate, and that the three-activation
KNOWN_DEFECT P6case is red on the base on its warning assertion and lands in the change commit); they were fixed with no code or test change, and the whole gate was re-run afterwards.These reviews ran on the general model instead of the dedicated reviewer, because the dedicated reviewer was unavailable: spec:P5, review:P5:correctness#1, review:P5:rules#1, verify:P5#1.1, review:P5:correctness#2, verify:P5#2.1, review:P5:correctness#3, verify:P5#3.1.
Verification
pnpm run checkvp test run(alpha channel)vp test run --coveragesrc/host/remote.tsat 100); global statements 98.56%, branches 96.03%, functions 98.71%, lines 98.56% against a ratchet of 98 / 95.4 / 97.9 / 98pnpm run buildlib/index.mjs370.00 kBscripts/check.tslib/current; packed tarball installed with plain npm (19 entries), host and client halves loaded;lib/client.js136211 bytes, under the 139264 tripwire; check passeddsh-llm-pi-ai0.2.2-rc.2, cordis 4.1.0): unit; mockpackage.jsonor lockfile residuenpmcell and rcnpmcell (fresh build each)[HOST_LIMITATION]cases (the Go Gemini thinking budget, and the config-editor save that throws in host code)scripts/check.tscatalog:shim,limits:shimandcli:versionall answerreport, so no freshness check gates this pull requestThe remote base had not moved since this branch was cut, so nothing was merged in.
Generated by Claude Code