Skip to content

best-practices: expand id/naming rule (collisions + namespacing) - #6

Merged
topkoa merged 2 commits into
mainfrom
docs/best-practices-id-naming
Jul 6, 2026
Merged

best-practices: expand id/naming rule (collisions + namespacing)#6
topkoa merged 2 commits into
mainfrom
docs/best-practices-id-naming

Conversation

@topkoa

@topkoa topkoa commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refines the id/naming best-practice (rule 2) with the real collision and namespacing gotchas, ground-truthed against the plugin loader — the "what should I name it and what will bite me?" guidance.

What it now covers

  • How far the id reaches. It's interpolated into the routes module (plugin_<id>_routes), the screen container (plugin-<id>), a visualization's factory global (window.feedBackViz_<id>), the diagnostics path (plugins/<id>/), and the localStorage prefix — so a collision or rename ripples through all of them.
  • Exact-case folder rule + why the charset matters. Folder name MUST equal id exactly including case (the Scaffold the feedBack plugin specification (v0.1.0 draft) #1 "why won't it load?"), and ^[a-z0-9][a-z0-9_-]*$ isn't cosmetic — the id becomes a Python module name and DOM/JS identifiers, so uppercase/dots/spaces break discovery or module loading. The validator rejects them.
  • Collision resolution (not "last wins"). A bundled id always wins — a user plugin reusing a bundled id is silently ignored (kept only as a fallback). Between two non-bundled plugins, the first discovered wins and the other silently doesn't load.
  • Reserved ids. capability_inspector and the app_tour_* prefix are always-enabled (can't be disabled) — don't collide with them.
  • Namespace what the id doesn't do for you. All plugins share one window and one document, so prefix localStorage keys, window globals, routes, and CSS by id — two plugins writing window.state or localStorage["theme"] clobber each other silently.

Cross-links the normative rules in spec §4.2 (id) and §5.2 (directory-name rule). Added matching checklist items.

Scope & stacking

Docs only (spec/best-practices.md + CHANGELOG.md). No version bump; rule enriched in place so numbering is unchanged (1–25). The normative id rules already live in the spec (§4.2 charset/stability, §5.3 bundled-wins precedence) — this is the actionable advice layer, so no spec change needed.

Stacked on #5 (base docs/best-practices-visualizations). Full stack: #2#4#3#5#6. mkdocs build --strict and check_versions.py pass.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: eef81817-3683-4b6c-a74d-7bcbd10ba388

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/best-practices-id-naming

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refines the non-normative best-practices guidance around plugin id selection, focusing on real-world collision behavior and the practical namespacing implications across Host-derived surfaces.

Changes:

  • Expanded best-practices rule 2 to document id scope/derivations, collision precedence, reserved ids, and shared-namespace namespacing guidance.
  • Added matching items to the pre-publish checklist.
  • Documented the update in the [Unreleased] changelog entry.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
spec/best-practices.md Expands rule 2 (id/naming) and updates the publish checklist accordingly.
CHANGELOG.md Adds an [Unreleased] entry summarizing the best-practices update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/best-practices.md Outdated
Comment thread spec/best-practices.md Outdated
@topkoa
topkoa force-pushed the docs/best-practices-visualizations branch from e792ad2 to b2040e8 Compare July 6, 2026 04:25
topkoa and others added 2 commits July 6, 2026 00:25
…tchas

Rule 2 was a short "treat the id as forever". Expand it, ground-truthed against
the plugin loader, into the real id/naming pitfalls:

- How far the id reaches: routes module (plugin_<id>_routes), screen container
  (plugin-<id>), viz global (window.feedBackViz_<id>), diagnostics path, and the
  localStorage prefix — so a collision or rename ripples everywhere.
- Folder name MUST equal id exactly incl. case (the #1 "won't load" cause), and
  the charset matters because id becomes a Python module name + DOM/JS identifier
  — uppercase/dots/spaces break discovery or module loading; the validator
  rejects them.
- Collision resolution: a bundled id ALWAYS wins (a user plugin reusing it is
  silently ignored, kept only as a fallback); between two non-bundled plugins the
  first discovered wins. Check your id isn't a bundled one.
- Reserved ids: capability_inspector and app_tour_* are always-enabled — don't
  collide with them.
- Namespace shared-space names (localStorage, window globals, routes, CSS) by id,
  since all plugins share one window and document.

Cross-link spec §4.2 / §5.2 for the normative rules. Add matching checklist
items. Numbering unchanged (enriched in place). Docs only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: K. O. A. <topkoa@gmail.com>
- Rule 2: drop 'snake_case is the house style' (examples use kebab-case; both
  '-' and '_' are valid and used). Say lowercase with -/_ separators.
- Checklist: limit the new namespacing item to localStorage/window globals;
  routes and CSS are already covered by the later item.

Signed-off-by: K. O. A. <topkoa@gmail.com>
@topkoa
topkoa force-pushed the docs/best-practices-id-naming branch from 3897901 to 675d076 Compare July 6, 2026 04:26
Base automatically changed from docs/best-practices-visualizations to docs/client-runtime-section July 6, 2026 04:43
Base automatically changed from docs/client-runtime-section to main July 6, 2026 04:43
@topkoa
topkoa merged commit b0523f3 into main Jul 6, 2026
8 checks passed
@topkoa
topkoa deleted the docs/best-practices-id-naming branch July 6, 2026 04:44
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.

2 participants