Skip to content

[CTX-1185] feat(dynapi): registry-backed name arbitration for provided interfaces (#2003) - #2047

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

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

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Supports #2003 (dynapi 1/4): one-time Core rule for dynamic extension-API names.

  • Name grammar: short (calc.add) and owner-qualified (owner:iface, exactly one colon) references via shared parse_service_reference; the @Version position maps to the existing version-requirement channel (services.required / opts.version), never inline syntax.
  • Reservation: top-level bitty.* frozen Core-owned; extension provide/require of reserved shorts fails closed (manifest validate, TOML parse, activation gate, bridge host check).
  • Conflict resolution: same short from two owners stays usable only via qualified forms; unqualified use fails closed naming both owners (judged over grant-visible records only, so no ungranted-provider leak; fails even when optional).
  • Registry: allowlist itself stays with the package index (manager 11); Core holds no static list - owner identity pinned by manifest plugin id, provider key equals registry identity, rename/revoke follow dispose/reload record lifecycle. Rule lands with tests against manifest/directory fakes; enforcement wires up when the index lands.
  • Trust model ADR-0003 throughout: reservation authorizes participation only; gating/budgets/egress unchanged.

Acceptance: two-extension same-short test (qualified both work, short fails naming both), bitty.* claim fails closed, owner pinned by registry, just check-relevant gates green; docs sync noted for bitty-terminal-docs interface material + Plugins API surface (separate repo).

Gates: fmt clean, clippy -D warnings clean (workspace + dev-tools), nextest workspace 6635 passed 1 skipped, doctests clean, windows target check clean, verify_w147_small_core_graph 9/9. ci-local blocked by pre-existing sccache GHA-backend failure under act (log recording/ctx-1185/ci-local-pr1.log); scratch-paths fails pre-existing in untouched wsl.rs/component.rs.

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

Closes #2003

Summary by CodeRabbit

  • New Features
    • Required services can now use owner-qualified names (owner:interface) to select a specific provider.
  • Bug Fixes
    • Unqualified service lookups now report an error when multiple providers are visible, rather than selecting one ambiguously.
    • Invalid service references are rejected, and Core-reserved bitty.* interfaces cannot be provided or required.
    • Service provisions must use short interface names; owner-qualified provisions are rejected.

@Xuepoo Xuepoo added the feat Feature label Oct 13, 2026
@Xuepoo Xuepoo added this to the v0.1.0 milestone Oct 13, 2026
@Xuepoo Xuepoo added P1 Priority: high area:plugins labels Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 702db9cb-cedd-430f-a861-4b69ef166f02
📥 Commits

Reviewing files that changed from the base of the PR and between bc56c87 and 349c26a.

📒 Files selected for processing: 9
  • crates/bitty-lua/src/host.rs
  • crates/bitty-lua/tests/host_bridge.rs
  • crates/bitty-plugin-host/src/lib.rs
  • crates/bitty-plugin-host/src/manifest.rs
  • crates/bitty-plugin-host/src/registry.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

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Service references now support short and owner-qualified forms. Required services can name an owner, while provided services remain short-form. Runtime resolution pins qualified lookups to an owner and rejects ambiguous short lookups. The Core bitty namespace is reserved.

Changes: Service reference parsing and manifest rules

Layer / File(s) Summary
Reference parsing and manifest validation
crates/bitty-plugin-host/src/manifest.rs, crates/bitty-plugin-host/src/lib.rs, crates/bitty-runtime/src/plugin_runtime/manifest_toml.rs
The parser accepts short and owner-qualified references, enforces a 128-byte limit and reference validation, and rejects Core-reserved names. Provided services must use short names; required services may use either form. The crate root exports the new helpers. Tests cover parsing and manifest validation.
Registry owner matching
crates/bitty-plugin-host/src/registry.rs
Required references are parsed into an optional owner and short interface. Qualified requirements match providers from the named owner.
Runtime resolution and Lua bridge
crates/bitty-runtime/src/plugin_runtime/services.rs, crates/bitty-runtime/src/plugin_runtime/mod.rs, crates/bitty-runtime/tests/plugin_services.rs, crates/bitty-lua/src/host.rs, crates/bitty-lua/tests/host_bridge.rs
Qualified lookups select the named owner. Short lookups return E_SERVICE_RESOLUTION when multiple visible owners match, including for optional lookups. Runtime validation rejects qualified or Core-reserved provisions. Lua bridge tests cover qualified lookup and provision references.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Caller as Plugin caller
  participant Resolver as service_resolve
  participant Records as Active service records
  Caller->>Resolver: Request a short or owner-qualified reference
  Resolver->>Records: Scan active records by interface, owner, version, and backing-head grants
  Records-->>Resolver: Return matching records
  alt Qualified reference
    Resolver-->>Caller: Resolve from the named owner
  else Short reference
    Resolver-->>Caller: Resolve one visible owner or return E_SERVICE_RESOLUTION for ambiguity
  end
Loading
Merge Risk: ⚪ Minimal · up to 349c2

No actionable issue remains from this review; the PR is mergeable after normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: registry-backed arbitration for provided interfaces. It is specific and consistent with the service-reference, registry, and runtime changes.
Linked Issues check Passed Issue #2003 coding requirements are covered. Shared parsing accepts short and owner-qualified references. Manifest, TOML, activation, and bridge checks reject reserved bitty.* names. Runtime resolut…
Out of Scope Changes check Passed The changed source files implement service-reference parsing, reserved-name validation, registry resolution, activation checks, and host bridging for issue #2003. The added tests verify these paths. N…
Docstring Coverage Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 48 functions across 9 files.
✨ Finishing Touches: 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • 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: 349c26a82 (branch carryctx/ctx-1185-dynapi-arbitration, PR #2047)
Verdict: APPROVE (non-blocking nits only)

Checks run (read-only, against the PR checkout):

  1. git log --oneline -1 && git show --stat HEAD
  2. git show HEAD -- crates/bitty-plugin-host/src/registry.rs crates/bitty-runtime/src/plugin_runtime/services.rs crates/bitty-plugin-host/src/manifest.rs
  3. git show HEAD -- crates/bitty-lua/src/host.rs crates/bitty-runtime/src/plugin_runtime/manifest_toml.rs
  4. rg -n 'parse_service_reference|bitty\.|reserved|owner:' crates/bitty-plugin-host/src crates/bitty-runtime/src/plugin_runtime
  5. rg -in 'unmount|register_panel' crates/

Findings:

  • Grammar is centralized in manifest.rs::parse_service_reference (rejects >1 colon, empty owner/short, NUL/space, >128-byte) and reused by provide/require validation, the registry graph gate, and the broker; the Lua bridge (bitty-lua/src/host.rs ~5725) mirrors only the structural shape and defers owner-identity/reservation to the host — matches the PR intent.
  • Core bitty.* reservation fails closed on every claimed path: manifest.rs provide validate ~1396 and require ~2537, plus services.rs::service_provide ~2975 mapping to E_SERVICE_UNDECLARED; covered by manifest/manifest_toml tests.
  • Arbitration pins owner by the providing plugin id (registry.rs ~365/390, services.rs ~3085) with no static Core allowlist; ambiguity for an unqualified short is judged over grant-visible records only (services.rs ~3089-3120) and fails closed naming every owner even when optional.
  • Non-blocking nits: (1) visible_owners insert happens before Version::parse (~services.rs:3095), so an unparseable-version provider could trip the multi-owner error instead of being skipped; (2) the registry graph gate stays permissive on ambiguity while the runtime broker fails closed (intended graph-vs-runtime layering, but the two layers disagree); (3) could not compile to confirm BTreeSet is in scope in services.rs.

Merge gate: APPROVE + green CI. Prior Wayland red was a flake — 4 bitty-lua::colorscheme_bridge tests failed at a uniform ~1.02s timeout while X11 and macOS passed on the same commit; failed jobs rerun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugins feat Feature P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dynapi] Registry-backed name arbitration for provided interfaces (owner:iface@version)

1 participant