Skip to content

fix(cli): preserve Amp MCP registration settings - #7995

Merged
morluto merged 10 commits into
morluto:mainfrom
STDquantum:fix/7538-amp-registration-preservation
Oct 29, 2026
Merged

morluto merged 10 commits into
morluto:mainfrom
STDquantum:fix/7538-amp-registration-preservation

Conversation

@STDquantum

@STDquantum STDquantum commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 rea entry and drops its env map. 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-global project-scope behavior for Amp. This PR addresses global registration environment preservation and value parsing.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI boundary around Incur's built-in mcp add; Amp settings parsing and preservation remain at the registration boundary.
  • Contribution scope fit and linked maintainer decision: Existing integration behavior; not applicable.
  • CLI and MCP/tool-catalog contract: Normalizes --agent=value and --command=value to Incur's spaced syntax; invalid settings return VALIDATION_ERROR.
  • Provider, bridge, target-format, or platform compatibility: Amp registration only; no analysis provider change.
  • Evidence, artifact, provenance, or reconstruction contract: Not applicable.
  • Target selection, authority, upstream behavior, and cleanup details: Targets only the selected Amp registration; no analysis target is launched.
  • Generated metadata, package, or installation impact: None expected.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/ampRegistrationPreservation.test.ts covers 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.
  • Base reproduction or other evidence: Source-derived from Incur 0.6.1: Amp registration replaces the entry; its parser recognizes spaced options. Regression assertions exercise these paths.
  • User-visible CLI output: The boundary test checks VALIDATION_ERROR responses and the retained backup path on stderr.
  • Remaining proof gaps: Real Amp client behavior is not verified outside the isolated CLI fixture.
  • Boundary/lifecycle regressions: Covers CLI registration and settings failure cases. No process lifecycle change.

Validation performed

  • CI failure diagnosis: Static checks failed because the test accessed backupRejected.json.message while json is typed as unknown. Removed the redundant direct access; the structured assertion still verifies the backup error message.
  • npm run typecheck — passed on current head a4cf07a3.
  • npm run test:focused -- tests/boundary/cli/ampRegistrationPreservation.test.ts — previously passed on 6e5875cf; not rerun after the assertion cleanup in a4cf07a3.
  • git diff --check — passed for the current update; staged-file oxlint and oxfmt hooks also passed.
  • GitHub commit status for current head a4cf07a3 reports no check runs at update time.
  • Full check:fast pre-push hook — blocked locally by the unrelated untracked .worktrees/fix-7996-settings/.oxlintrc.json, whose options.reportUnusedDisableDirectives setting is rejected outside the root config. The changed files passed the commit hook's oxlint and formatting tasks.

Compatibility, safety, and release

  • Breaking changes or migration steps: None intended; preserves existing environment values.
  • Real Hopper/Ghidra, browser, or OS coverage: Not applicable.
  • Package or release metadata impact: None expected.
  • Security, privacy, process, or containment review: The first backup and later content-addressed recovery copies are retained and restricted to owner-only permissions where POSIX permissions apply. No analysis target is contacted.

Author readiness

Human owner: @STDquantum

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved; no new capability is added.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issues are linked.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs and generated metadata need no updates for this CLI fix.
  • User-visible CLI output has not been captured in this task.
  • I checked the reviewed diff for secrets, unrelated cleanup, and unsupported claims.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The reviewed changes appear safe to merge.

Summary

Preserves Amp registration environment values, checks settings, and retains private recovery backups.

  • Amp registration keeps its settings intact and confirms the entry was saved.

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"]
Loading

Reviews (5) · Last reviewed commit: "fix(cli): handle Amp backup cleanup fail..." · Reviewed by Greptile

Comment thread src/cli.ts Resolved
Comment thread src/cli.ts Resolved
Comment thread src/cli.ts Resolved
Comment thread src/cli.ts Resolved
Comment thread src/cli/ampRegistrationBackup.ts Resolved
Comment thread src/cli.ts Resolved
@STDquantum
STDquantum marked this pull request as ready for review October 29, 2026 06:39
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T06:40:01.049123Z
We couldn’t complete this review. Comment @codex review to try again.
a4cf07a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto
morluto merged commit f25d1e3 into morluto:main Oct 29, 2026
45 of 50 checks passed
@STDquantum
STDquantum deleted the fix/7538-amp-registration-preservation branch October 29, 2026 07:26
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Amp registration reports success when existing settings prevent saving REA

2 participants