Skip to content

fix(engram): recover Antigravity plugin migration#1643

Open
dnlrsls wants to merge 2 commits into
Gentleman-Programming:mainfrom
dnlrsls:fix/797-antigravity-plugin-transaction
Open

fix(engram): recover Antigravity plugin migration#1643
dnlrsls wants to merge 2 commits into
Gentleman-Programming:mainfrom
dnlrsls:fix/797-antigravity-plugin-transaction

Conversation

@dnlrsls

@dnlrsls dnlrsls commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked Issue

Closes #797


🏷️ PR Type

  • type:bug — Bug fix (non-breaking change that fixes an issue)
  • type:feature — New feature (non-breaking change that adds functionality)
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no functional changes)
  • type:chore — Build, CI, or tooling changes
  • type:breaking-change — Breaking change (fix or feature that changes existing behavior)

📝 Summary

  • Make the Antigravity Engram plugin the sole MCP registration owner.
  • Preserve unrelated configuration and valid absolute Engram commands, including Linuxbrew.
  • Recover deterministically from ambiguous atomic-write outcomes without losing the active registration.

📂 Changes

File / Area What Changed
internal/components/engram/inject.go Add transactional global-to-plugin migration, command resolution, settings isolation, rollback, and roll-forward recovery.
internal/components/engram/inject_test.go Cover convergence, idempotency, absolute paths, isolated settings, and five write-failure recovery states.
internal/components/golden_test.go Read Antigravity MCP configuration from the plugin-owned path.
testdata/golden/engram-antigravity-mcp.golden Require the --tools=agent profile.

🔗 Chain Context

main
└── PR 1 📍 — plugin ownership and transactional migration (this PR)
    └── PR 2 — configuration-input resilience (pending approval of #1635)

This PR supersedes the oversized #1602 without rewriting its published history.


🧪 Test Plan

Focused tests

go test -count=20 ./internal/components/engram -run '^TestInjectAntigravity'
go test -count=1 ./internal/components/engram ./internal/components
go test -count=1 ./... -run '^TestRunInstallAntigravityInitializesCLISettingsAfterEngramSetup$'

Go Format

go run ./internal/gofmtcheck
  • Focused unit and integration tests pass
  • Go format passes (go run ./internal/gofmtcheck)
  • Full go test -count=1 ./... completed locally — exceeded the local execution allowance with unrelated environment-dependent failures
  • E2E tests pass (cd e2e && ./docker-test.sh)
  • Manually tested locally

🤖 Automated Checks

Check Status Description
Check PR Cognitive Load 395 changed lines, within the 400-line budget
Check Issue Reference Links approved issue #797
Check Issue Has status:approved Issue #797 is approved
Check PR Has type:* Label Maintainer must apply type:bug
Unit Tests Runs in CI
Go Format Runs in CI
E2E Tests Runs in CI

✅ Contributor Checklist

  • PR is linked to an issue with status:approved
  • PR stays within 400 changed lines
  • Maintainer has applied the type:bug label
  • Focused tests pass
  • Go format passes
  • E2E tests pass
  • Documentation is not required for this internal behavior correction
  • Commit follows Conventional Commits format
  • Commit contains no Co-Authored-By trailers

💬 Notes for Reviewers

Please focus on the registration invariant across pre-replacement, post-replacement, rollback, and roll-forward outcomes. A pre-existing manifest counts as active only when it exactly matches the desired plugin manifest.

Summary by CodeRabbit

  • New Features
    • Added dedicated Antigravity plugin support for CLI and Desktop, with consistent MCP tool flags enabled via the plugin configuration.
  • Bug Fixes
    • Prevented unnecessary global Antigravity MCP config changes.
    • Improved installation/migration handling with safer reconciliation and automatic rollback on write failures.
    • Enhanced Engram command discovery, including absolute-path detection and Linuxbrew locations.
  • Reliability
    • Plugin configuration updates now converge consistently across CLI vs Desktop variants and preserve already-resolved absolute Engram look paths.

@dnlrsls

dnlrsls commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer action needed: please add the \ ype:bug\ label. This replacement slice is 395 changed lines and links approved issue #797; the follow-up input-resilience slice will wait for #1635 approval.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Antigravity Engram injection now installs configuration through a dedicated plugin, reconciles and migrates existing state with rollback support, preserves agent-tool arguments, recognizes Linuxbrew paths, and expands tests for convergence, path handling, failures, and golden configuration output.

Changes

Antigravity Engram integration

Layer / File(s) Summary
Plugin configuration reconciliation
internal/components/engram/inject.go
Antigravity installation reconciles plugin MCP configuration, hooks, manifests, and existing global state, with migration and rollback handling.
Command and overlay behavior
internal/components/engram/inject.go
Generic overlays use --tools=agent; Antigravity prefers absolute Engram paths and recognizes the Linuxbrew stable path.
Antigravity migration and golden validation
internal/components/engram/inject_test.go, internal/components/golden_test.go
Tests validate plugin-scoped configuration, convergence, idempotency, path preservation, write-failure recovery, global configuration absence, and updated golden input paths.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Injection
  participant EngramPluginInstaller
  participant AntigravityFiles
  Injection->>EngramPluginInstaller: install or reconcile Engram plugin
  EngramPluginInstaller->>AntigravityFiles: read global and plugin configuration
  EngramPluginInstaller->>AntigravityFiles: write MCP config, hooks, and manifest
  AntigravityFiles-->>EngramPluginInstaller: write or activation result
  EngramPluginInstaller-->>Injection: changed files or recovery error
Loading

Possibly related issues

Possibly related PRs

Suggested labels: type:bug

Suggested reviewers: alan-thegentleman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: Antigravity plugin migration recovery for Engram.
Linked Issues check ✅ Passed The PR addresses duplicate Antigravity MCP registration and Linuxbrew path detection, while preserving --tools=agent.
Out of Scope Changes check ✅ Passed The added rollback and recovery logic stays aligned with the stated transactional migration goals.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/components/engram/inject.go (1)

374-440: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Restore staged plugin files when activation fails.

Lines 376-392 write mcp_config.json, hooks.json, and possibly settings.json before migration/activation. If manifest activation fails pre-replacement, Lines 425-427 restore only the global config; the staged files remain modified. In particular, an existing hooks.json can be overwritten despite a failed install.

Capture and restore every staged before-image (deleting newly created files) on the rollback path, and add recovery assertions for those files. As per path instructions, “Any write to user config must have a backup/restore path.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/components/engram/inject.go` around lines 374 - 440, Update the
staging loop in the activation flow to retain each target’s before-image for
mcpPath, hooks.json, and settings.json. When manifest activation fails before
replacement, restore every staged file through the existing reconciliation
mechanism, deleting files that did not previously exist, and include recovery
results/assertions for those restores in the returned error alongside the global
rollback status. Ensure any restore failure reports manual recovery rather than
leaving staged user configuration modified.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/components/engram/inject.go`:
- Around line 374-440: Update the staging loop in the activation flow to retain
each target’s before-image for mcpPath, hooks.json, and settings.json. When
manifest activation fails before replacement, restore every staged file through
the existing reconciliation mechanism, deleting files that did not previously
exist, and include recovery results/assertions for those restores in the
returned error alongside the global rollback status. Ensure any restore failure
reports manual recovery rather than leaving staged user configuration modified.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 077610cc-fb47-4c4e-abaa-1967d72771b6

📥 Commits

Reviewing files that changed from the base of the PR and between 342abe3 and a1a5a04.

📒 Files selected for processing (2)
  • internal/components/engram/inject.go
  • internal/components/engram/inject_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(engram): prevent double MCP registration in Antigravity and support Linuxbrew path

1 participant