fix(adapters): review follow-ups from #131/#141 - #169
Merged
Conversation
Cursor's 64-character plugin-name bound was only enforced by the unified `plugin` planner, so the standalone `cursor` target accepted and emitted a manifest for an over-long name. The pinned official schema (cursor/plugins@0701892) constrains the name's charset but carries no maxLength, so both planners now assert the bound through one shared message. The capability-state exhaustive `default` branches returned the capability object itself, so an untyped adapter's misspelled state read as truthy support and could enable hooks or MCP. They now raise a typed CapabilityStateError, and the registry rejects a malformed declaration at registration so a bad state never reaches `supports()` or capability intersection.
🦋 Changeset detectedLatest commit: 67b4f9a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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. |
commit: |
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.
Resolves the two unresolved Codex P2 findings on merged PRs #131 and #141.
#131 — Cursor plugin-name length check (partially confirmed, fixed)
The finding is real, but not in the way a missing schema constraint would suggest. I verified the vendored
plugin.schema.jsonbyte-for-byte against its provenance pin (cursor/plugins@070189284e702e8a4d2e3cc8913994b204c5337a, sha256a393b758…f884ed): the official schema carries nomaxLengthonname, onlyminLength: 1and the kebab-casepattern. So nothing was dropped from the schema, and restoring amaxLengththere would have broken the immutable provenance pin.What was actually inconsistent is the planner layer:
isValidCursorPluginName()requiresname.length <= 64, but only the unifiedpluginplanner called it.planCursorArtifacts()relied on Ajv alone, so a 65-character lowercase kebab-case name validated and the standalonecursortarget emitted the manifest, while theplugintarget rejected the same name.planCursorArtifacts()now emits acursor.nameerror diagnostic for an invalid name, whichbuild.tsalready treats as a write gate.cursorPluginNameError()message so they cannot drift again, and the message now names the 64-character bound instead of only saying "lowercase kebab-case".#141 — Unknown capability states (confirmed, fixed)
Confirmed still present on current
main; the logic lives inadapters/capability-state.tsover the contract incore/capabilities.ts, and #157 did not touch it. Fivedefaultbranches wroteconst exhaustive: never = capability; return exhaustive;— a correct compile-time exhaustiveness check that at runtime returns the capability object. A malformed declaration such as{ state: 'suported' }from a JavaScript or third-party adapter therefore madecapabilityIsSupported()return a truthy object, soTargetRegistry.supports()reported support and could enable hooks or MCP.precedenceFor()was worse: it returned an object where0 | 1 | 2 | 3was expected, so an unknown state flowed throughintersectCapabilityStates()and fabricated a truthy state.core/capabilities.tsgains the four-state contract's runtime home: a typedCapabilityStateError(ERR_UNKNOWN_CAPABILITY_STATE),isCapabilityState()validating each state's own required fields, andunknownCapabilityStateError().defaultbranch now throws that typed error. Theneverassignment is retained, so a fifth state still fails the build — the exhaustive-switch convention is preserved, it just no longer lies at runtime.TargetRegistry.register()validates every declared capability up front, so a malformed state is rejected at the third-party boundary and can never reachsupports()or intersection. The throw inside the switch remains as the invariant behind it.capabilityStateNameFlagsis aRecord<CapabilityState['state'], true>, so adding a state without listing it fails to compile.CapabilityStateError,capabilityStateNames, andisCapabilityStateare exported from the public API, sinceTargetRegistryandTargetAdapterare public and adapter authors are exactly who this guards.Test plan
Both new tests were confirmed non-vacuous: with the source fixes stashed and the tests kept, 4 tests fail.
rstest run packages/agent-bundle/tests/adapter-capability-states.test.ts packages/agent-bundle/tests/cursor-adapter.test.ts --config rstest.unit.config.ts— 19 passedpnpm test:unit— 144 files, 2003 passedpnpm test:route-unit— 10 passedpnpm typecheckrslinton all changed files — 0 findingspnpm --filter agent-bundle buildNew coverage: an over-long name is rejected by both Cursor-producing planners with the identical shared message while a 64-character name is accepted (and the test asserts the pinned schema itself accepts the over-long name, documenting why the planner must hold the bound);
isCapabilityStateaccepts the four states and rejects misspellings, states missing their own fields, and non-records; an unknown state throwsCapabilityStateErrorthroughcapabilityIsSupported,capabilityBooleanView, and bothintersectCapabilityStatesargument positions; and a malformed adapter is rejected atregister().