Skip to content

[CTX-1185] feat(dynapi): version negotiation for broker services.get (#2006) - #2049

Merged
Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-1185-dynapi-negotiation
Oct 13, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-1185-dynapi-negotiation

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Implements #2006 (dynapi 3/4): semver-range matching with empty-intersection fail-closed, side-by-side coexistence, and no silent downgrade.

  • Matching reuses the canonical package evaluator (caret/tilde expansion plus comparator intersection, same as the policy registry gate); new matrix test pins >=, ^, ~, exact, multi-comparator, and fail-closed rows (unparseable, empty req, stable-only vs prerelease).
  • Highest-compatible-wins is the only strategy: the broker always serves the highest satisfying version, never a lower pick; removing the only compatible version flips consume from OK to fail-closed (negative test), never a silent downgrade.
  • Empty intersection fails closed with a diagnostic naming the interface, the requested range, and the grant-visible available versions (capped at 8 + remainder count; ungranted providers stay invisible, same posture as bitty.env).
  • Side-by-side: directory keys records by (provider, version); manifests may declare one interface at distinct versions (exact (iface, version) dupes still rejected); TOML table-form version accepts a string or capped non-empty string array sharing schemas/heads; bridge captures repeated provisions and the commit gate binds each occurrence to its declared version in order (shared helper, unit-pinned); live handles pin the negotiated version end to end (bridge closure through service_call/find_active), so sibling records never serve through each other's handles.
  • Negotiation result recorded per call for 4/4: ServiceCallRecord gains the negotiated version (ledger assertions added).
  • Provider upgrade path: dispose + re-activate keeps an exact pin on its release (integration test); dropping the pinned release fails closed listing the survivors.

Gates: fmt clean, clippy -D warnings clean (workspace + dev-tools), runtime lib 278 plugin_runtime passed, plugin-host lib 406 passed, bitty-lua all suites green, plugin_services 11 passed (+ related plugin suites), windows target check clean, verify_w147_small_core_graph 9/9. ci-local blocked by the same pre-existing sccache GHA-backend failure under act as #2047/#2048; scratch-paths fails pre-existing in untouched wsl.rs/component.rs. No manifest changes (cargo-deny N/A), no TODO, no new production edges or authority paths.

Stacking note: branched from main per quartet rule; converges with #2047 arbitration (ambiguity over visible owners composes with highest-wins; qualified pins select before negotiation). Docs sync noted for bitty-terminal-docs interface material + Plugins API surface (separate repo).

Priority: P2 | Area: plugins | Labels: feat,P2,area:plugins | Milestone: v0.1.0 | Task: CTX-1185

Closes #2006

@Xuepoo Xuepoo added feat Feature P2 Priority: medium labels Oct 13, 2026
@Xuepoo Xuepoo added this to the v0.1.0 milestone Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a7fdf02-ea00-4483-a532-81322db3a191
📥 Commits

Reviewing files that changed from the base of the PR and between b38db1b and 0266ab4.

📒 Files selected for processing: 7
  • crates/bitty-lua/src/host.rs
  • crates/bitty-lua/tests/host_bridge.rs
  • crates/bitty-plugin-host/src/manifest.rs
  • crates/bitty-runtime/src/plugin_runtime/manifest_toml.rs
  • crates/bitty-runtime/src/plugin_runtime/mod.rs
  • crates/bitty-runtime/src/plugin_runtime/services.rs
  • crates/bitty-runtime/tests/plugin_services.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review verdict (guard cron / separate agent reviewer)

Commit reviewed: c05863aee22623044bb0d8b204c57ecce637d04e (branch carryctx/ctx-1185-dynapi-negotiation, PR #2049)
Verdict: APPROVE (minor non-blocking notes only)

Findings:

  1. Fail-closed negotiation is genuinely implemented. services.get pins an exact negotiated version into the consumer handle: HostServices::service_call takes a version param (crates/bitty-lua/src/host.rs:1433) and the runtime resolves the exact record via find_active(iface, provider, version) (crates/bitty-runtime/src/plugin_runtime/services.rs:3158; find_active at :1016 with version + !suspended predicate at :1021) — a handle resolved at one version can never drive a same-provider sibling record.
  2. Side-by-side coexistence enforced. ServiceDirectory::publish retains by (provider, version) instead of provider-only (services.rs:960-963); resolution still fails closed with E_SERVICE_RESOLUTION when the requirement intersects no visible version (services.rs:3122-3129).
  3. Grant-safe diagnostic. The resolve loop checks heads-covered before recording visible_versions, so an ungranted provider's versions never leak into the available: listing; the listing is capped at MAX_RESOLUTION_LISTED_VERSIONS = 8 with a remainder count (services.rs:3060-3091, list_visible_versions :1053-1082).
  4. Manifest multi-version expansion. [services.provided] version accepts a non-empty string array capped at MAX_PROVIDED_SERVICES, each expanding to its own ProvidedService sharing schemas/heads (manifest_toml.rs:420, parse_provided_entry :758-835); duplicate (iface, version) pairs rejected, distinct versions allowed (crates/bitty-plugin-host/src/manifest.rs:2409-2420).
  5. Bind-by-occurrence shared between gate and publisher. declared_provision_slot binds the nth provision to the nth declared (interface, version); both validate_capture (mod.rs:2849-2892) and publish_services (mod.rs:2251-2266) use the same helper, so they cannot disagree.
  6. Tests exercise the negotiation. Unit tests cover highest-compatible pick, exact pin, empty-intersection fail-closed, removal flipping to fail-closed, version-pin driving the exact record, listing cap / hide-ungranted, and directory coexistence (services.rs:5643-5890); an end-to-end integration test activates a provider declaring version=["1.0.0","2.0.0"] proving range→v2, pin→v1, empty-range→E_SERVICE_RESOLUTION, per-call ledger version, and pin survival across dispose+re-activate (crates/bitty-runtime/tests/plugin_services.rs:870-952).

Non-blocking notes: the duplicate (iface, version) guard at mod.rs:2895 is effectively unreachable (harmless defense-in-depth); the services.rs:3081 comment reads more absolute than the occurrence/pin behavior (a fresh get after the top version is revoked can return a lower compatible version — a new resolution, not a rebind); debug.rs:28-29 names "fail-closed version negotiation" in pre-existing text not part of this diff.

Read-only review of the 7 files in the diff; signature-change blast radius checked exhaustively via rg (service_call has exactly two impls + the runtime host→bridge call site, all updated in lockstep). just ci-local not run per lane lock.

@Xuepoo
Xuepoo force-pushed the carryctx/ctx-1185-dynapi-negotiation branch from c05863a to 0266ab4 Compare October 13, 2026 21:58

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commander pre-merge check: rebased onto post-2047/2048 main with keep-both resolution (verified: lib 845, host_bridge 47, w147 9/9, fmt, clippy). Full CI green, no CodeRabbit findings. Merging.

@Xuepoo
Xuepoo merged commit 703e9d5 into main Oct 13, 2026
17 checks passed
@Xuepoo
Xuepoo deleted the carryctx/ctx-1185-dynapi-negotiation branch October 13, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugins feat Feature P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dynapi] Version negotiation for broker services.get (fail-closed)

1 participant