Skip to content

fix(pi): enable cloud autosync for the plugin-launched server - #1587

Merged
Alan-TheGentleman merged 1 commit into
mainfrom
fix/pi-plugin-autosync
Oct 1, 2026
Merged

Alan-TheGentleman merged 1 commit into
mainfrom
fix/pi-plugin-autosync

Conversation

@Alan-TheGentleman

@Alan-TheGentleman Alan-TheGentleman commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

🔗 Linked Issue

Closes #1586


🏷️ PR Type

  • type:bug — Bug fix
  • type:feature — New feature
  • type:question — Question requiring tracked work
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no behavior change)
  • type:chore — Maintenance, dependencies, tooling
  • type:breaking-change — Breaking change

📝 Summary

  • The Pi plugin now launches engram serve with ENGRAM_CLOUD_AUTOSYNC=1, matching the Claude Code and Codex launchers (fix(plugin): enable autosync for SessionStart daemon #852).
  • Without it, the server never started the autosync manager, so enrolled projects silently stopped syncing (no failures, no errors) whenever Pi was the process that launched the server.

📂 Changes

File Change
plugin/pi/index.ts Spawn serve with { ...process.env, ENGRAM_CLOUD_AUTOSYNC: "1" }. The server still skips autosync on its own when no cloud server or token is configured.
plugin/pi/test/startup-lifecycle.test.mjs The fake binary records the autosync value it receives; new test asserts a plugin-launched server gets ENGRAM_CLOUD_AUTOSYNC=1 even when the parent environment does not set it.

🧪 Test Plan

  • Focused regression (behavior change): node --test --test-name-pattern="autosync" test/startup-lifecycle.test.mjs (in plugin/pi) — failed before the fix with the expected assertion, passes after (1/1).
  • Affected package tests (behavior change): npm test in plugin/pi — 238 tests, 238 pass, 0 fail.
  • Other applicable local checks: manual check on macOS. Restarting the server with ENGRAM_CLOUD_AUTOSYNC=1 engram serve logged [autosync] started and drained three enrolled projects (~8.7k pending mutations) to healthy. The same patch is applied to the locally loaded Pi plugin.

No Go code changed, so go test ./... was not run locally; CI covers it.


🤖 Automated Checks

Check What it verifies Status
Check Issue Reference PR body contains Closes #N / Fixes #N / Resolves #N ⏳
Check Issue Has status:approved Linked issue has status:approved label ⏳
Check PR Has type: Label* Canonical labels, applicability, and cardinality ⏳
Check PR Has No Transient Artifacts PR files comply with the Transient Artifact Policy ⏳
Unit Tests go test ./... passes ⏳
E2E Tests go test -tags e2e ./internal/server/... passes ⏳
Plugin Tests npm test passes in plugin/pi ⏳
Lint golangci-lint reports no new findings ⏳
Windows Setup Test Windows setup preserves absolute paths and MCP job-object parent-lifetime tests pass ⏳
Cloud Sync Wrapper Tests (Windows) Cloud sync wrapper and missing-PowerShell-Engram tests pass on Windows ⏳

✅ Contributor Checklist

  • I linked an approved issue above (Closes #N)
  • I added exactly one type:* label to this PR
  • I recorded actual focused regression and affected package test commands/outcomes for behavior changes, or N/A for docs-only changes
  • I recorded additional applicable local checks for an unpushed/no-PR or high-risk change, and identified any missing CI evidence
  • Docs updated (if behavior changed) — N/A: no docs describe which launcher enables autosync
  • Commits follow conventional commits format
  • No Co-Authored-By trailers in commits
  • I checked every changed path against the Transient Artifact Policy

💬 Notes for Reviewers

Setting the variable unconditionally mirrors plugin/claude-code/scripts/session-start.sh and plugin/codex/scripts/session-start.sh; tryStartAutosync already logs and skips when cloud config is missing.

Summary by CodeRabbit

  • New Features
    • Engram servers started through the Pi plugin now enable cloud autosync by default, so changes can sync to the cloud automatically. This setting applies only when the plugin launches the server; setups using an externally configured Engram URL continue to use that server without starting a new one.

The Pi plugin spawned engram serve without ENGRAM_CLOUD_AUTOSYNC=1, so the
server never started the autosync manager and enrolled projects silently
stopped syncing. Pass it like the Claude Code and Codex launchers do.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 09:14
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 99b3d83c-ca41-4133-8614-02d4af06af86

📥 Commits

Reviewing files that changed from the base of the PR and between 76feaee and 1a7f53b.

📒 Files selected for processing (2)
  • plugin/pi/index.ts
  • plugin/pi/test/startup-lifecycle.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The Pi plugin now launches engram serve with ENGRAM_CLOUD_AUTOSYNC=1 while retaining the inherited environment. A startup test checks that the launched server receives this value.

Changes

Pi cloud autosync startup

Layer / File(s) Summary
Set autosync on server launch
plugin/pi/index.ts, plugin/pi/test/startup-lifecycle.test.mjs
The plugin passes ENGRAM_CLOUD_AUTOSYNC=1 to the spawned server. The test logs the variable and checks that it is set to 1 during plugin-launched startup.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: gentleman-programming, dnlrsls

Merge Risk: ⚪ Minimal · up to 1a7f5

Pi-launched servers can now start autosync when cloud configuration is valid, while unconfigured servers remain protected by the existing checks. No actionable merge risk remains.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 1a7f5

Cloud synchronization becomes automatic for newly Pi-launched servers with cloud configuration. Existing configuration and project-enrollment controls remain, but the launcher overrides an inherited autosync disable setting, and already-running servers require a restart to change their launch-time setting.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly activated outbound scope includes eligible mutations across the local store's enrolled projects, not merely the current Pi working project. Authority and destination come from existing cloud configuration; non-enrolled project rows and empty-project rows are not transmitted by the inspected push path.

Trust Boundaries and Controls

  • observed — Local server adoption remains identity-gated: foreign, legacy, and identity-missing servers are rejected before spawning. Failed startup paths cancel readiness polling and terminate the abandoned child. The autosync override does not change these ownership controls.

Resilience and Maintainability Implications

  • observed — The activated manager retains single-run registration, synchronization leases, cancellation, deferred lease release, and persisted failure backoff. Graceful server shutdown stops autosync; abrupt termination relies on lease expiry and durable pending state for recovery.

Hardening Proposals

  • proposed — If operators need a temporary offline mode independent of cloud configuration and enrollment, consider preserving an explicit inherited disable value while defaulting an unset value to enabled. This is an optional control-policy improvement, not an established authorization vulnerability.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: enabling cloud autosync for the server launched by the Pi plugin.
Linked Issues check ✅ Passed Issue #1586 requires the Pi-launched server to start cloud autosync. The PR adds ENGRAM_CLOUD_AUTOSYNC=1 to the Pi plugin launch environment and preserves the inherited environment. The new startup …
Out of Scope Changes check ✅ Passed The changes are limited to plugin/pi/index.ts and its startup lifecycle test. The implementation directly addresses issue #1586. The test provides regression coverage for the required launch setting…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The focused change matches existing launcher behavior and includes adequate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes #1586 by enabling cloud autosync when the Pi plugin launches the local Engram server.

Changes:

  • Passes ENGRAM_CLOUD_AUTOSYNC=1 to the spawned server.
  • Adds regression coverage verifying the child environment.
File Description
plugin/​pi/​index.ts Enables autosync for plugin-launched servers.
plugin/​pi/​test/​startup-lifecycle.test.mjs Verifies autosync is enabled during startup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Alan-TheGentleman
Alan-TheGentleman added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 2f1e545 Oct 1, 2026
25 of 26 checks passed
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(pi): plugin-launched server never starts cloud autosync

2 participants