Skip to content

best-practices: Server-side robustness (deps, event loop, load_sibling) - #10

Merged
topkoa merged 1 commit into
mainfrom
docs/best-practices-server-robustness
Jul 6, 2026
Merged

best-practices: Server-side robustness (deps, event loop, load_sibling)#10
topkoa merged 1 commit into
mainfrom
docs/best-practices-server-robustness

Conversation

@topkoa

@topkoa topkoa commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Second of four gap-closing PRs. Adds a "Server-side robustness" section for routes-shipping plugins — the server-side concerns that let one plugin stall the whole server or delay others. Ground-truthed against the loader.

Rules (34–37)

  • 34 — Declare Python deps in requirements.txt, keep them light. There's no manifest field; the Host pip installs them to a persistent, hash-keyed location. Installs are sequential and slow — they delay later plugins (yours shows "installing…"), so keep them minimal and pinned. A failed install is non-fatal (the Host still tries your routes), so guard heavy/optional imports and degrade if missing.
  • 35 — Don't block the event loop; keep setup() fast. setup() runs on the event-loop thread and is killed at a ~60s timeout — wire only, defer heavy work. A blocking async def handler freezes the whole server for every request; use non-blocking I/O or a plain def (the Host runs sync handlers in a threadpool).
  • 36 — Split routes.py with context["load_sibling"], not bare imports. The Host puts each plugin dir on sys.path, so two plugins shipping a top-level util.py collide in sys.modules (first wins). load_sibling namespaces per plugin and enables relative imports; don't mix bare import and load_sibling for the same file.
  • 37 — Log through context["log"], never print() (correlation + rotation); plus a route-namespacing reminder (silent + permanent collisions, rules 6/7).

Added a "Server-side robustness" checklist block; Shipping renumbered to 38–42 (contiguous 1–42).

Scope & stacking

Docs only. Stacked on #9. Full stack: … → #8#9#10 (two more coming: styling, diagnostics). mkdocs build --strict + 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: 6cc7e1d1-7bfe-4714-9ed9-05fc91e7b6f9

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-server-robustness

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

@topkoa
topkoa force-pushed the docs/best-practices-integration branch from e96f451 to f74c4c1 Compare July 6, 2026 04:30
Add server-side robustness rules found in the completeness sweep, ground-truthed
against the loader.

Rules (34-37):
- Declare Python deps in requirements.txt (no manifest field): installs are
  hash-keyed and persistent, but sequential and slow — they delay later plugins,
  so keep them minimal and pinned. A failed install is non-fatal (Host still
  loads routes), so guard heavy/optional imports and degrade if missing.
- Don't block the event loop: setup() runs on the loop thread and is killed at a
  ~60s timeout — wire only, defer heavy work. A blocking async def handler
  freezes the whole server; use non-blocking I/O or a plain def (threadpool).
- Split routes.py with context["load_sibling"], not bare imports — two plugins
  shipping a top-level util.py collide in sys.modules (first wins). load_sibling
  namespaces per plugin and enables relative imports; don't mix the two.
- Log through context["log"], never print(); namespace routes under
  /api/plugins/<id>/.

Renumber Shipping to 38-42 and add a checklist block. Docs only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: K. O. A. <topkoa@gmail.com>
@topkoa
topkoa force-pushed the docs/best-practices-server-robustness branch from 6999ed5 to b11d019 Compare July 6, 2026 04:32
Base automatically changed from docs/best-practices-integration to main July 6, 2026 04:45
@topkoa
topkoa merged commit 245b126 into main Jul 6, 2026
8 checks passed
@topkoa
topkoa deleted the docs/best-practices-server-robustness branch July 6, 2026 04:45
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