Verify extension load behavior with and without MONGODB_URI #146

Closed
opened 2026-08-31 22:07:00 +00:00 by david · 2 comments
Owner

Summary

Manually verify the extension loads both ways: pi boots with zero mongo_* tools when MONGODB_URI is not configured, and with the three tools plus the confirmation line when it is.

Background

Depends on: #143

This is the end-to-end load gate for the extension — the unit tests prove the factory logic, but this step proves pi actually loads extensions/mongodb/index.ts in both configuration states. Because the client is lazy, a configured-but-unreachable URI is fine for this check: pi must not try to connect at load time.

Documentation Required

A separate process downloads these into the listed folder before this issue is implemented. Check the folder for the actual reference material before starting.

docs/reference/pi-coding-agent/ — for loading an extension with pi:

  • /home/david/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/README.md — pi main documentation (how to launch pi and load extensions).
  • /home/david/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md — extension loading, the -e/extension flag, and startup output.

Implementation Details

Run pi against the extension file using the repo's standard extension-load flow — the plan calls out pi -e ./extensions/mongodb/index.ts (confirm the exact flag in the pi docs or by checking how the sibling extensions are loaded in this repo; use whatever the repo's standard flow is).

  1. Unconfigured: ensure no MONGODB_URI (and no MONGODB_URI-shaped key) is set in the environment/.env, then load pi. Expected: pi boots cleanly (no errors, no warnings), and the tool list contains zero mongo_* tools.
  2. Configured: set MONGODB_URI (a real URI or an unreachable one like mongodb://127.0.0.1:1/test — lazy connect means it should not matter at load time), then load pi. Expected: the three tools mongo_find, mongo_count, mongo_list_collections appear, and startup output contains MongoDB extension loaded: connected to <host>:<port>/<db>.

Acceptance Criteria

  • Unconfigured load: pi boots with zero mongo_* tools and no error/warning about MongoDB.
  • Configured load: the three tools are present and the confirmation line MongoDB extension loaded: connected to <host>:<port>/<db> prints with the correct host/port/db parsed from the URI.
  • A configured-but-unreachable URI does not hang or crash pi at load (lazy client).

Test Plan

# Unconfigured
unset MONGODB_URI
pi -e ./extensions/mongodb/index.ts        # (or repo's standard flow) → zero mongo_* tools, clean boot

# Configured (unreachable host is fine)
MONGODB_URI='mongodb://127.0.0.1:1/test' pi -e ./extensions/mongodb/index.ts
# → three tools registered; "MongoDB extension loaded: connected to 127.0.0.1:1/test" in output

Record both runs' tool lists and the confirmation line in your notes/PR description.

## Summary Manually verify the extension loads both ways: pi boots with **zero** `mongo_*` tools when `MONGODB_URI` is not configured, and with the three tools plus the confirmation line when it is. ## Background **Depends on:** #143 This is the end-to-end load gate for the extension — the unit tests prove the factory logic, but this step proves pi actually loads `extensions/mongodb/index.ts` in both configuration states. Because the client is lazy, a configured-but-unreachable URI is fine for this check: pi must not try to connect at load time. ## Documentation Required A separate process downloads these into the listed folder before this issue is implemented. Check the folder for the actual reference material before starting. **`docs/reference/pi-coding-agent/`** — for loading an extension with pi: - `/home/david/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/README.md` — pi main documentation (how to launch pi and load extensions). - `/home/david/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md` — extension loading, the `-e`/extension flag, and startup output. ## Implementation Details Run pi against the extension file using the repo's standard extension-load flow — the plan calls out `pi -e ./extensions/mongodb/index.ts` (confirm the exact flag in the pi docs or by checking how the sibling extensions are loaded in this repo; use whatever the repo's standard flow is). 1. **Unconfigured:** ensure no `MONGODB_URI` (and no `MONGODB_URI`-shaped key) is set in the environment/`.env`, then load pi. Expected: pi boots cleanly (no errors, no warnings), and the tool list contains **zero** `mongo_*` tools. 2. **Configured:** set `MONGODB_URI` (a real URI or an unreachable one like `mongodb://127.0.0.1:1/test` — lazy connect means it should not matter at load time), then load pi. Expected: the three tools `mongo_find`, `mongo_count`, `mongo_list_collections` appear, and startup output contains `MongoDB extension loaded: connected to <host>:<port>/<db>`. ## Acceptance Criteria - [ ] Unconfigured load: pi boots with zero `mongo_*` tools and no error/warning about MongoDB. - [ ] Configured load: the three tools are present and the confirmation line `MongoDB extension loaded: connected to <host>:<port>/<db>` prints with the correct host/port/db parsed from the URI. - [ ] A configured-but-unreachable URI does not hang or crash pi at load (lazy client). ## Test Plan ```bash # Unconfigured unset MONGODB_URI pi -e ./extensions/mongodb/index.ts # (or repo's standard flow) → zero mongo_* tools, clean boot # Configured (unreachable host is fine) MONGODB_URI='mongodb://127.0.0.1:1/test' pi -e ./extensions/mongodb/index.ts # → three tools registered; "MongoDB extension loaded: connected to 127.0.0.1:1/test" in output ``` Record both runs' tool lists and the confirmation line in your notes/PR description.
Author
Owner

Verification note (issue 146 implementation): the test-plan form

MONGODB_URI='mongodb://127.0.0.1:1/test' pi -e ./extensions/mongodb/index.ts

does not configure the extension. The extension reads MONGODB_URI only from the project's .env file (never from process.env, mirroring the postgres extension), so the process-env form registers zero mongo_* tools (verified end-to-end). Use the corrected .env-based form instead:

# Configured (unreachable host is fine — the client stays lazy at load time)
cd <repo checkout>
printf 'MONGODB_URI=mongodb://127.0.0.1:1/test\n' > .env
pi -e ./extensions/mongodb/index.ts
rm -f .env
# → three tools registered; "MongoDB extension loaded: connected to 127.0.0.1:1/test" in output

Full verification results (unconfigured / configured / full-flow, with tool lists) are recorded in extensions/mongodb/docs/IMPLEMENTATION_PLAN.md → "Phase 5.2 load validation — results (issue #146, 2026-09-01)".

**Verification note (issue 146 implementation):** the test-plan form ```bash MONGODB_URI='mongodb://127.0.0.1:1/test' pi -e ./extensions/mongodb/index.ts ``` does **not** configure the extension. The extension reads `MONGODB_URI` **only from the project's `.env` file** (never from `process.env`, mirroring the `postgres` extension), so the process-env form registers **zero** `mongo_*` tools (verified end-to-end). Use the corrected `.env`-based form instead: ```bash # Configured (unreachable host is fine — the client stays lazy at load time) cd <repo checkout> printf 'MONGODB_URI=mongodb://127.0.0.1:1/test\n' > .env pi -e ./extensions/mongodb/index.ts rm -f .env # → three tools registered; "MongoDB extension loaded: connected to 127.0.0.1:1/test" in output ``` Full verification results (unconfigured / configured / full-flow, with tool lists) are recorded in `extensions/mongodb/docs/IMPLEMENTATION_PLAN.md` → "Phase 5.2 load validation — results (issue #146, 2026-09-01)".
david closed this issue 2026-09-01 01:03:33 +00:00
Author
Owner

pi-loop opened and merged a pull request for this issue: #163

pi-loop opened and merged a pull request for this issue: https://git.excelera.net/david/pi-extensions-and-skills/pulls/163
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-extensions-and-skills#146
No description provided.