Repository navigation
fix(cli): preserve Amp MCP registration settings - #7995
Conversation
[Medium impact] The reviewed changes appear safe to merge. SummaryPreserves Amp registration environment values, checks settings, and retains private recovery backups.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Read Amp settings"] --> B{"Settings valid?"}
B -- No --> E["Return validation error"]
B -- Yes --> C["Keep private recovery copy if needed"]
C -- "Backup fails or rejects" --> E
C -- Ready --> D["Run Incur registration"]
D --> F["Check registration and restore environment"]
F -- Failed --> E
F -- Passed --> G["Report retained backup path"]
Reviews (5) · Last reviewed commit: "fix(cli): handle Amp backup cleanup fail..." · Reviewed by Greptile |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
Fixes #7536 and #7538. Preserve Amp MCP registration environment, normalize supported equals-form options, validate settings roots, and report malformed or unapplied registrations as failures.
Problem and expected behavior
Incur's Amp writer replaces the existing
reaentry and drops itsenvmap. It can also report success when settings prevent the expected registration. Incur 0.6.1 ignores equals-form agent options; an Amp-only request can therefore become a default registration. REA now preserves the environment, validates and verifies the registration, and retains secure recovery backups.Change and scope
The CLI validates Amp settings before invoking Incur, rejects non-object JSON roots, restores the prior environment if Incur omits it, and reports failure if the expected Amp entry is absent after registration. It retains the first original backup and creates a content-addressed recovery copy when the settings have since changed. Backups are restricted to owner-only permissions where POSIX permissions apply, and the selected recovery path is reported on stderr. Read, JSON parse, and backup failures have distinct messages. Backup failures retain their tagged kind, path, and detail through the CLI boundary.
PR #7979 addresses the separate
--no-globalproject-scope behavior for Amp. This PR addresses global registration environment preservation and value parsing.Contract and boundary impact
mcp add; Amp settings parsing and preservation remain at the registration boundary.--agent=valueand--command=valueto Incur's spaced syntax; invalid settings returnVALIDATION_ERROR.Expected effects:
Evidence and regression coverage
tests/boundary/cli/ampRegistrationPreservation.test.tscovers environment preservation, equals-form Amp selection, malformed JSON, null and array settings roots, backup write failures, private backup permissions, retained original backups, content-addressed recovery copies, reported backup paths, and tagged backup failures with path and kind.VALIDATION_ERRORresponses and the retained backup path on stderr.Validation performed
backupRejected.json.messagewhilejsonis typed asunknown. Removed the redundant direct access; the structured assertion still verifies the backup error message.npm run typecheck— passed on current heada4cf07a3.npm run test:focused -- tests/boundary/cli/ampRegistrationPreservation.test.ts— previously passed on6e5875cf; not rerun after the assertion cleanup ina4cf07a3.git diff --check— passed for the current update; staged-fileoxlintandoxfmthooks also passed.a4cf07a3reports no check runs at update time.check:fastpre-push hook — blocked locally by the unrelated untracked.worktrees/fix-7996-settings/.oxlintrc.json, whoseoptions.reportUnusedDisableDirectivessetting is rejected outside the root config. The changed files passed the commit hook's oxlint and formatting tasks.Compatibility, safety, and release
Author readiness
Human owner: @STDquantum
Before merge
type(scope): outcome.