[PR #1607] [MERGED] fix(setup): preserve configured MCP server environment #3001

Closed
opened 2026-10-17 21:12:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1607
Author: @Adkid-Zephyr
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @morluto

Base: main ← Head: fix/setup-preserve-registration-environment


📝 Commits (3)

  • 4560e0d fix(setup): preserve configured MCP server environment
  • 0260b2a Merge remote-tracking branch 'origin/main' into fix/setup-preserve-registration-environment
  • bc90619 fix(setup): validate retained server environment before writes

📊 Changes

8 files changed (+479 additions, -32 deletions)

View changed files

📝 docs/installation.md (+6 -0)
📝 src/application/ClientConfigurationFiles.ts (+11 -1)
➕ src/application/ClientRegistrationEnvironment.ts (+54 -0)
📝 src/application/SetupClientConfiguration.ts (+24 -26)
📝 src/application/SetupPlan.ts (+2 -2)
📝 tests/acceptance/setup/piClientSetup.test.ts (+192 -0)
➕ tests/boundary/filesystem/clientConfigurationEnvironment.test.ts (+181 -0)
📝 tests/boundary/filesystem/clientLifecycle.test.ts (+9 -3)

📄 Description

Summary

Fixes #1606. Setup discarded existing REA server environment settings while migrating its launcher or updating provider paths. Keep valid overrides, and refuse malformed maps or invalid known environment settings before writing rather than dropping the whole map or reporting a server that cannot start as aligned.

Problem and expected behavior

setup --client pi --skill=false --yes --json removed REA_MCP_INPUT_SCHEMA_PROFILE=compact from an existing registration. Its next stdio tools/list contained four schemas above the compact budget. #1484/#1514 document whole-request failures caused by the full catalog in size-capped clients.

Likewise, one numeric/boolean/null environment value must not cause all string peers to disappear. An empty or invalid schema profile must produce a source-specific setup/doctor diagnostic, leaving the original configuration intact.

Change and scope

  • Read and validate REA's explicit string environment map once through a shared boundary. Reuse the runtime's environment parser for known settings; retain original string values and unknown keys without persisting defaults or ambient process variables.
  • Merge detected provider settings over matching keys, preserving the others across JSON, TOML, OpenCode environment, Hermes YAML and OpenCode V1-to-V2 migration.
  • Apply validation to setup preflight and doctor registration inspection. Uninstall can still remove a broken owned registration for recovery.
  • Explain retained overrides and detected-key precedence in the setup plan and installation guide.

Contract and boundary impact

  • Semantic owner and earliest changed stage: client registration environment, before setup plans or writes.
  • CLI/MCP/tool-catalog contract: existing schemas unchanged; configured runtime presentation survives.
  • Provider/bridge/platform compatibility: no provider protocol change; detected provider keys still win over old values.
  • Evidence/artifact/provenance/reconstruction contract: none.
  • Process execution/authorization/cleanup/containment impact: none; no ambient-environment persistence.
  • Generated metadata/package/installation impact: setup/doctor diagnostics and preservation only; no dependency or release metadata change.

Evidence and regression coverage

  • Before the initial fix: four filesystem cases and the actual CLI/stdio-MCP compact-budget regression failed. After it, valid environment settings survive migration, provider-key replacement and repeated setup.
  • Before validation: nine filesystem cases failed for malformed maps/members or invalid profile/budget; two public CLI cases incorrectly exited successfully with invalid profiles. They now pass and prove no configuration rewrite or backup creation on refusal.
  • CLI/MCP test launches the written command, checks all schemas within 13,312 bytes and a successful ping. Dry-run discloses preserved overrides; repeat setup has empty planned/applied actions.
  • Coverage includes sibling preservation, original backups, JSON/TOML/YAML, OpenCode migration, doctor invalid-state reporting and named remediation.
  • Remaining proof gaps: no paid model request, live client UI, Windows host or real analysis engine. The model-provider consequence relies on upstream #1514's executed evidence.

Evidence-bearing checklist: not applicable; no analysis Evidence changes.

Validation performed

Integrated upstream main bbd0192; Node 24.18.0 / npm 11.16.0 / macOS arm64:

  • 16 setup/client suites — 248 passed, zero failures. This includes the previously reported six uninstall failures, corrected upstream.
  • Final tests/acceptance/setup/piClientSetup.test.ts after the plan assertion — 6 passed.
  • All 17 suites containing failures in the original CI run — 212 passed, 26 skipped, 2 failed in the first broader local run. The two macOS process cases reported ambiguous_environment_boundary; that suite then passed 13/13 in an isolated run on this head and 13/13 on unmodified bbd0192. Process production/test code is identical to main; no assertion or timeout was relaxed here.
  • npm run check — passed, including typecheck, lint, format, knip, metadata and architecture guards (existing warnings remain).
  • npm run docs:check — passed.
  • npm run verify:test-discovery — passed, 775 files exactly once.
  • npm run verify:package — passed, including isolated installed CLI/MCP, setup/update and skill verification.
  • npm pack --dry-run, git diff --check, pre-commit and pre-push checks — passed.

Latest head bc90619 triggered CI run 38083744360, which explicitly awaits approval from a maintainer. No jobs have executed on this head yet; local validation is not a remote CI pass claim.

Compatibility, safety, and release

  • Breaking changes/migration: no schema change. Repair a named malformed environment value before setup; remove unwanted valid overrides explicitly in the client file.
  • Real provider/OS coverage: actual macOS filesystem, CLI and stdio MCP with synthetic inputs; no live model or analysis provider.
  • Package/release metadata: unchanged.
  • Security/privacy/process/containment review: ordinary configuration correctness only, synthetic files and owned local processes; no added authority.

Review checklist

  • Concrete problem, focused Conventional Commit title, linked issue.
  • Observable regressions, refusal before mutation, migration, precedence and repeat coverage.
  • Owning documentation and representative CLI/MCP output covered.
  • Final diff checked for unrelated changes and unsupported claims.

Disclosure: implementation and regression tests were prepared with OpenAI Codex assistance.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1607 **Author:** [@Adkid-Zephyr](https://github.com/Adkid-Zephyr) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/setup-preserve-registration-environment` --- ### 📝 Commits (3) - [`4560e0d`](https://github.com/morluto/rea/commit/4560e0ddc8fdcaba237dbdf35ef411cff50a6c32) fix(setup): preserve configured MCP server environment - [`0260b2a`](https://github.com/morluto/rea/commit/0260b2aba06bb69ac4756c923327b4b1ba02ab9b) Merge remote-tracking branch 'origin/main' into fix/setup-preserve-registration-environment - [`bc90619`](https://github.com/morluto/rea/commit/bc9061983c49c81f02b3a6a18db072f3928c8fc8) fix(setup): validate retained server environment before writes ### 📊 Changes **8 files changed** (+479 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `docs/installation.md` (+6 -0) 📝 `src/application/ClientConfigurationFiles.ts` (+11 -1) ➕ `src/application/ClientRegistrationEnvironment.ts` (+54 -0) 📝 `src/application/SetupClientConfiguration.ts` (+24 -26) 📝 `src/application/SetupPlan.ts` (+2 -2) 📝 `tests/acceptance/setup/piClientSetup.test.ts` (+192 -0) ➕ `tests/boundary/filesystem/clientConfigurationEnvironment.test.ts` (+181 -0) 📝 `tests/boundary/filesystem/clientLifecycle.test.ts` (+9 -3) </details> ### 📄 Description ## Summary Fixes #1606. Setup discarded existing REA server environment settings while migrating its launcher or updating provider paths. Keep valid overrides, and refuse malformed maps or invalid known environment settings before writing rather than dropping the whole map or reporting a server that cannot start as aligned. ## Problem and expected behavior `setup --client pi --skill=false --yes --json` removed `REA_MCP_INPUT_SCHEMA_PROFILE=compact` from an existing registration. Its next stdio `tools/list` contained four schemas above the compact budget. #1484/#1514 document whole-request failures caused by the full catalog in size-capped clients. Likewise, one numeric/boolean/null environment value must not cause all string peers to disappear. An empty or invalid schema profile must produce a source-specific setup/doctor diagnostic, leaving the original configuration intact. ## Change and scope - Read and validate REA's explicit string environment map once through a shared boundary. Reuse the runtime's environment parser for known settings; retain original string values and unknown keys without persisting defaults or ambient process variables. - Merge detected provider settings over matching keys, preserving the others across JSON, TOML, OpenCode `environment`, Hermes YAML and OpenCode V1-to-V2 migration. - Apply validation to setup preflight and doctor registration inspection. Uninstall can still remove a broken owned registration for recovery. - Explain retained overrides and detected-key precedence in the setup plan and installation guide. ## Contract and boundary impact - Semantic owner and earliest changed stage: client registration environment, before setup plans or writes. - CLI/MCP/tool-catalog contract: existing schemas unchanged; configured runtime presentation survives. - Provider/bridge/platform compatibility: no provider protocol change; detected provider keys still win over old values. - Evidence/artifact/provenance/reconstruction contract: none. - Process execution/authorization/cleanup/containment impact: none; no ambient-environment persistence. - Generated metadata/package/installation impact: setup/doctor diagnostics and preservation only; no dependency or release metadata change. ## Evidence and regression coverage - Before the initial fix: four filesystem cases and the actual CLI/stdio-MCP compact-budget regression failed. After it, valid environment settings survive migration, provider-key replacement and repeated setup. - Before validation: nine filesystem cases failed for malformed maps/members or invalid profile/budget; two public CLI cases incorrectly exited successfully with invalid profiles. They now pass and prove no configuration rewrite or backup creation on refusal. - CLI/MCP test launches the written command, checks all schemas within 13,312 bytes and a successful ping. Dry-run discloses preserved overrides; repeat setup has empty planned/applied actions. - Coverage includes sibling preservation, original backups, JSON/TOML/YAML, OpenCode migration, doctor invalid-state reporting and named remediation. - Remaining proof gaps: no paid model request, live client UI, Windows host or real analysis engine. The model-provider consequence relies on upstream #1514's executed evidence. Evidence-bearing checklist: not applicable; no analysis Evidence changes. ## Validation performed Integrated upstream main `bbd0192`; Node 24.18.0 / npm 11.16.0 / macOS arm64: - 16 setup/client suites — **248 passed, zero failures**. This includes the previously reported six uninstall failures, corrected upstream. - Final `tests/acceptance/setup/piClientSetup.test.ts` after the plan assertion — **6 passed**. - All 17 suites containing failures in the original CI run — **212 passed, 26 skipped, 2 failed** in the first broader local run. The two macOS process cases reported `ambiguous_environment_boundary`; that suite then passed **13/13** in an isolated run on this head and **13/13** on unmodified `bbd0192`. Process production/test code is identical to main; no assertion or timeout was relaxed here. - `npm run check` — passed, including typecheck, lint, format, knip, metadata and architecture guards (existing warnings remain). - `npm run docs:check` — passed. - `npm run verify:test-discovery` — passed, 775 files exactly once. - `npm run verify:package` — passed, including isolated installed CLI/MCP, setup/update and skill verification. - `npm pack --dry-run`, `git diff --check`, pre-commit and pre-push checks — passed. Latest head `bc90619` triggered [CI run 38083744360](https://github.com/morluto/rea/actions/runs/38083744360), which explicitly awaits approval from a maintainer. No jobs have executed on this head yet; local validation is not a remote CI pass claim. ## Compatibility, safety, and release - Breaking changes/migration: no schema change. Repair a named malformed environment value before setup; remove unwanted valid overrides explicitly in the client file. - Real provider/OS coverage: actual macOS filesystem, CLI and stdio MCP with synthetic inputs; no live model or analysis provider. - Package/release metadata: unchanged. - Security/privacy/process/containment review: ordinary configuration correctness only, synthetic files and owned local processes; no added authority. ## Review checklist - [x] Concrete problem, focused Conventional Commit title, linked issue. - [x] Observable regressions, refusal before mutation, migration, precedence and repeat coverage. - [x] Owning documentation and representative CLI/MCP output covered. - [x] Final diff checked for unrelated changes and unsupported claims. Disclosure: implementation and regression tests were prepared with OpenAI Codex assistance. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:12:46 +00:00
Sign in to join this conversation.
No milestone
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
morluto/rea#3001
No description provided.