Skip to content

fix(adapters): review follow-ups from #131/#141 - #169

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
fix/review-adapters
Sep 1, 2026
Merged

fix(adapters): review follow-ups from #131/#141#169
ScriptedAlchemy merged 1 commit into
mainfrom
fix/review-adapters

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

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.json byte-for-byte against its provenance pin (cursor/plugins@070189284e702e8a4d2e3cc8913994b204c5337a, sha256 a393b758…f884ed): the official schema carries no maxLength on name, only minLength: 1 and the kebab-case pattern. So nothing was dropped from the schema, and restoring a maxLength there would have broken the immutable provenance pin.

What was actually inconsistent is the planner layer: isValidCursorPluginName() requires name.length <= 64, but only the unified plugin planner called it. planCursorArtifacts() relied on Ajv alone, so a 65-character lowercase kebab-case name validated and the standalone cursor target emitted the manifest, while the plugin target rejected the same name.

  • planCursorArtifacts() now emits a cursor.name error diagnostic for an invalid name, which build.ts already treats as a write gate.
  • Both planners share one exported 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 in adapters/capability-state.ts over the contract in core/capabilities.ts, and #157 did not touch it. Five default branches wrote const 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 made capabilityIsSupported() return a truthy object, so TargetRegistry.supports() reported support and could enable hooks or MCP. precedenceFor() was worse: it returned an object where 0 | 1 | 2 | 3 was expected, so an unknown state flowed through intersectCapabilityStates() and fabricated a truthy state.

  • core/capabilities.ts gains the four-state contract's runtime home: a typed CapabilityStateError (ERR_UNKNOWN_CAPABILITY_STATE), isCapabilityState() validating each state's own required fields, and unknownCapabilityStateError().
  • Every default branch now throws that typed error. The never assignment 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 reach supports() or intersection. The throw inside the switch remains as the invariant behind it.
  • Completeness is enforced structurally: capabilityStateNameFlags is a Record<CapabilityState['state'], true>, so adding a state without listing it fails to compile.
  • CapabilityStateError, capabilityStateNames, and isCapabilityState are exported from the public API, since TargetRegistry and TargetAdapter are 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 passed
  • pnpm test:unit — 144 files, 2003 passed
  • pnpm test:route-unit — 10 passed
  • pnpm typecheck
  • rslint on all changed files — 0 findings
  • pnpm --filter agent-bundle build

New 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); isCapabilityState accepts the four states and rejects misspellings, states missing their own fields, and non-records; an unknown state throws CapabilityStateError through capabilityIsSupported, capabilityBooleanView, and both intersectCapabilityStates argument positions; and a malformed adapter is rejected at register().

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-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 67b4f9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-bundle Patch

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T18:19:47.965879Z 67b4f9a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@169
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@169
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@169

commit: 67b4f9a

@ScriptedAlchemy
ScriptedAlchemy merged commit 9e98f4d into main Sep 1, 2026
5 of 10 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the fix/review-adapters branch September 3, 2026 05:27
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.

1 participant