Skip to content

feat(selfhost): host-companion redeploy trigger via MCP admin tool#8209

Merged
JSONbored merged 3 commits into
mainfrom
feat/redeploy-companion
Jul 23, 2026
Merged

feat(selfhost): host-companion redeploy trigger via MCP admin tool#8209
JSONbored merged 3 commits into
mainfrom
feat/redeploy-companion

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Closes #7723 (sub-issue of #7720, sibling to #7721's config admin tools). A new admin-category MCP tool, loopover_admin_trigger_redeploy, lets an operator trigger a real self-redeploy (pull the published image, restart, wait for health) through an MCP client — without ever mounting /var/run/docker.sock into an app-facing container.

Design decision (this issue's own explicit requirement — proxy-mediated vs. host-companion): host companion. Investigated extending the existing docker-proxy sidecar first: tecnativa/docker-socket-proxy's ACL model has no way to scope a restart to one named container (only "any container reachable through the socket," broader than intended), and has no concept of "pull a new image" at all — the real desired behavior is docker compose pull && up -d-level orchestration, not a single Docker Engine API call a raw proxy could cleanly allowlist. A host companion sidesteps both problems by calling through the exact existing, already-tested scripts/deploy-selfhost-image.sh instead of reimplementing its pull+recreate+health-wait sequence.

How it works: scripts/redeploy-companion.ts runs entirely outside Docker as a systemd service (systemd/loopover-redeploy-companion.service.example), listens on a Unix domain socket (never a TCP port, never the Docker socket), and authenticates with its own separate REDEPLOY_COMPANION_TOKEN — a distinct credential from LOOPOVER_MCP_ADMIN_TOKEN, so a single leaked token can't trigger a redeploy on its own. The loopover container reaches it via a narrow, purpose-built socket bind-mount.

Entirely opt-in: no companion installed means the tool reports configured: false; every other admin tool (#7721) is completely unaffected. Docs include a full "why this needs a whole extra moving part" security-tradeoffs section (self-hosting-configuration.mdx), matching this issue's own explicit deliverable.

Test plan

  • npm run typecheck clean (repo-wide)
  • 74 tests across the new surface: redeploy-companion.ts's handleConnection/runDeploy (13), the socket client against a real Unix socket server (12), the Workers-safe registry (3), the MCP tool's registration-gating/auth-boundary/not-configured/success/failure/protocol-failure paths (11) — plus the pre-existing admin-tools/tool-categories/tool-rename-alias suites (48) confirmed unaffected
  • npm run docs:drift-check, selfhost:env-reference:check, test:miner-deployment-docs-audit, manifest:drift-check, branding-drift:check all clean
  • docker compose config validates the compose changes
  • npm run ui:lint / npm run ui:typecheck clean
  • ~90-100% branch coverage on the two new src/** files; the couple of remaining gaps are proven-exercised-by-passing-tests defensive races (a timer callback firing after clearTimeout, a socket error after an already-settled promise) that a real-timer/coverage-instrumentation interaction doesn't attribute correctly — documented inline

Closes #7723. A new admin-category MCP tool, loopover_admin_trigger_redeploy,
lets an operator trigger a real self-redeploy (pull the published image,
restart, wait for health) through an MCP client -- without ever mounting
/var/run/docker.sock into an app-facing container.

Design decision (proxy-mediated vs. host-companion, per #7720's own framing):
host companion. Investigated extending the existing docker-proxy sidecar
first -- tecnativa/docker-socket-proxy's ACL model has no way to scope a
restart to one named container (only "any container reachable through the
socket"), and has no concept of "pull a new image" at all, since the real
desired behavior is docker-compose-level orchestration, not a single Docker
Engine API call a raw proxy could cleanly allowlist.

The companion (scripts/redeploy-companion.ts) runs entirely outside Docker as
a systemd service, listens on a Unix domain socket (never a TCP port),
authenticates with its own separate REDEPLOY_COMPANION_TOKEN (distinct from
LOOPOVER_MCP_ADMIN_TOKEN -- two independent credentials, not one), and shells
out to the existing, already-tested scripts/deploy-selfhost-image.sh rather
than reimplementing its pull+recreate+health-wait sequence.

Entirely opt-in: no companion installed means the tool reports
configured: false, every other admin tool is unaffected.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 96c1eef Commit Preview URL

Branch Preview URL
Jul 23 2026, 12:55 PM

@superagent-security superagent-security Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Superagent found 1 security concern(s).

Comment thread scripts/redeploy-companion.ts
@superagent-security superagent-security Bot added the pr:flagged PR flagged for review by security analysis. label Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 10.13kB (0.14%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
loopover-ui 7.41MB 10.13kB (0.14%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: loopover-ui

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/add-scalar-classes-C5zV5UC-.js (New) 2.17MB 2.17MB 100.0% 🚀
assets/tanstack-vendor-CsEjGgVo.js (New) 739.41kB 739.41kB 100.0% 🚀
assets/docs.fumadocs-spike-api-reference-JnHJ5q09.js (New) 442.92kB 442.92kB 100.0% 🚀
assets/AgentScalarChatInterface.vue-DZ5HrbRx.js (New) 201.71kB 201.71kB 100.0% 🚀
assets/modal-Bnppusdz.js (New) 184.38kB 184.38kB 100.0% 🚀
assets/client-D2PzhIkT.js (New) 146.06kB 146.06kB 100.0% 🚀
assets/self-hosting-configuration-Bj3rAeJY.js (New) 100.04kB 100.04kB 100.0% 🚀
assets/maintainer-panel-zuIwuCF7.js (New) 78.99kB 78.99kB 100.0% 🚀
assets/ui-vendor-D2DjrcMG.js (New) 57.04kB 57.04kB 100.0% 🚀
assets/self-hosting-security-0gzCPOp4.js (New) 44.97kB 44.97kB 100.0% 🚀
assets/routes-D2c_f7YO.js (New) 34.98kB 34.98kB 100.0% 🚀
assets/owner-panel-B6r5NBlF.js (New) 27.36kB 27.36kB 100.0% 🚀
assets/app-7iwrvWC5.js (New) 25.7kB 25.7kB 100.0% 🚀
assets/app.runs-DTZ6T2o7.js (New) 23.56kB 23.56kB 100.0% 🚀
assets/miner-panel-BP-wWeOq.js (New) 20.28kB 20.28kB 100.0% 🚀
assets/api._op-qPU6iN_j.js (New) 17.57kB 17.57kB 100.0% 🚀
assets/self-hosting-docs-audit-BSCjxCVH.js (New) 16.61kB 16.61kB 100.0% 🚀
assets/app.index-CCLLoOrX.js (New) 15.62kB 15.62kB 100.0% 🚀
assets/docs._slug-CI8OZ1I1.js (New) 15.22kB 15.22kB 100.0% 🚀
assets/playground-panel-vgD9pxkr.js (New) 14.49kB 14.49kB 100.0% 🚀
assets/app.audit-Bvwz4s7U.js (New) 10.11kB 10.11kB 100.0% 🚀
assets/app.config-generator-CYE1m4TM.js (New) 10.09kB 10.09kB 100.0% 🚀
assets/extension-DuUFVEqP.js (New) 10.04kB 10.04kB 100.0% 🚀
assets/fairness-BgvIO8pL.js (New) 8.34kB 8.34kB 100.0% 🚀
assets/maintainers-CWWRF1Dx.js (New) 8.09kB 8.09kB 100.0% 🚀
assets/miners-9sH3Zd_J.js (New) 7.91kB 7.91kB 100.0% 🚀
assets/agents-DIZbtQG3.js (New) 7.8kB 7.8kB 100.0% 🚀
assets/commands-panel-Cqos7snC.js (New) 6.65kB 6.65kB 100.0% 🚀
assets/maintainer-workflow-DxhHlp5d.js (New) 6.52kB 6.52kB 100.0% 🚀
assets/roadmap-3E14fqGh.js (New) 6.33kB 6.33kB 100.0% 🚀
assets/digest-panel-BWqb_0AR.js (New) 6.18kB 6.18kB 100.0% 🚀
assets/repos._owner._repo.quality-wyOG5fOM.js (New) 6.14kB 6.14kB 100.0% 🚀
assets/docs.index-B_2vXxru.js (New) 5.73kB 5.73kB 100.0% 🚀
assets/docs-nav-CRX_x6YI.js (New) 5.53kB 5.53kB 100.0% 🚀
assets/api.index-B6kcBEGx.js (New) 4.7kB 4.7kB 100.0% 🚀
assets/docs-uuY8VoyS.js (New) 2.7kB 2.7kB 100.0% 🚀
assets/api-Badj86eT.js (New) 2.69kB 2.69kB 100.0% 🚀
assets/docs-page-CiazbRfJ.js (New) 2.1kB 2.1kB 100.0% 🚀
assets/table-BqPbGP5S.js (New) 1.75kB 1.75kB 100.0% 🚀
assets/app.workbench-CfW3ABRv.js (New) 1.58kB 1.58kB 100.0% 🚀
assets/session-DvrOiUnr.js (New) 1.45kB 1.45kB 100.0% 🚀
assets/tooltip-DldcOGiI.js (New) 1.45kB 1.45kB 100.0% 🚀
assets/tabs-CaXA-E1u.js (New) 1.39kB 1.39kB 100.0% 🚀
assets/app.repos-DUATOUGU.js (New) 1.07kB 1.07kB 100.0% 🚀
assets/input-DJ8mIl3L.js (New) 796 bytes 796 bytes 100.0% 🚀
assets/file-cog-Bq8Fj2F4.js (New) 758 bytes 758 bytes 100.0% 🚀
assets/app.maintainer-3J98eYaG.js (New) 502 bytes 502 bytes 100.0% 🚀
assets/sparkles-BJMm7CcR.js (New) 494 bytes 494 bytes 100.0% 🚀
assets/app.owner-_gU9Qoqj.js (New) 474 bytes 474 bytes 100.0% 🚀
assets/app.commands-1Rmf02N3.js (New) 455 bytes 455 bytes 100.0% 🚀
assets/app.playground-Su4yEI2w.js (New) 442 bytes 442 bytes 100.0% 🚀
assets/reveal-BRdN6EBa.js (New) 442 bytes 442 bytes 100.0% 🚀
assets/index-jvK2OXd4.js (New) 438 bytes 438 bytes 100.0% 🚀
assets/app.digest-bsgg5cVb.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/eye-off-B2ankfso.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/app.miner-Ccm_sXsh.js (New) 422 bytes 422 bytes 100.0% 🚀
assets/key-round-D6TCgczn.js (New) 355 bytes 355 bytes 100.0% 🚀
assets/bot-gBHz_e7s.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/trash-2-8pdfiZAc.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/save-6PkpwgdM.js (New) 327 bytes 327 bytes 100.0% 🚀
assets/git-pull-request-arrow-B6ZVDtcJ.js (New) 321 bytes 321 bytes 100.0% 🚀
assets/wrench-DGHjIwYe.js (New) 303 bytes 303 bytes 100.0% 🚀
assets/list-checks-CWpi_jAo.js (New) 279 bytes 279 bytes 100.0% 🚀
assets/shield-D8VSsR7X.js (New) 272 bytes 272 bytes 100.0% 🚀
assets/workflow-BnKi0Nqm.js (New) 265 bytes 265 bytes 100.0% 🚀
assets/compass-wE_4slfA.js (New) 251 bytes 251 bytes 100.0% 🚀
assets/history-DGx7LY1S.js (New) 237 bytes 237 bytes 100.0% 🚀
assets/activity-BOrO0w1b.js (New) 234 bytes 234 bytes 100.0% 🚀
assets/message-square-Bzh4TK9c.js (New) 233 bytes 233 bytes 100.0% 🚀
assets/lock-DVhn4oup.js (New) 206 bytes 206 bytes 100.0% 🚀
assets/rotate-cw-Be7mvyuG.js (New) 201 bytes 201 bytes 100.0% 🚀
assets/play-T8wmg2wY.js (New) 190 bytes 190 bytes 100.0% 🚀
assets/circle-check-lJ8BGv6F.js (New) 178 bytes 178 bytes 100.0% 🚀
assets/search-BRnkSThU.js (New) 174 bytes 174 bytes 100.0% 🚀
assets/circle-DEuh-3NF.js (New) 130 bytes 130 bytes 100.0% 🚀
assets/add-scalar-classes-CUwZRI42.js (Deleted) -2.17MB 0 bytes -100.0% 🗑️
assets/tanstack-vendor-rHye1WtI.js (Deleted) -739.41kB 0 bytes -100.0% 🗑️
assets/docs.fumadocs-spike-api-reference-C8O5_BCz.js (Deleted) -442.92kB 0 bytes -100.0% 🗑️
assets/AgentScalarChatInterface.vue-BlSmaNF1.js (Deleted) -201.71kB 0 bytes -100.0% 🗑️
assets/modal-gRWkuE-h.js (Deleted) -184.38kB 0 bytes -100.0% 🗑️
assets/client-DJ1NUbsg.js (Deleted) -146.06kB 0 bytes -100.0% 🗑️
assets/self-hosting-configuration-DlhYWHji.js (Deleted) -90.27kB 0 bytes -100.0% 🗑️
assets/maintainer-panel-s89Iz4YE.js (Deleted) -78.99kB 0 bytes -100.0% 🗑️
assets/ui-vendor-BX5d-0G0.js (Deleted) -57.04kB 0 bytes -100.0% 🗑️
assets/self-hosting-security-Cgb62yHW.js (Deleted) -44.61kB 0 bytes -100.0% 🗑️
assets/routes-HXzcVt96.js (Deleted) -34.98kB 0 bytes -100.0% 🗑️
assets/owner-panel-kuUn8fBX.js (Deleted) -27.36kB 0 bytes -100.0% 🗑️
assets/app-BTBkOGmS.js (Deleted) -25.7kB 0 bytes -100.0% 🗑️
assets/app.runs-CMCkGcKN.js (Deleted) -23.56kB 0 bytes -100.0% 🗑️
assets/miner-panel-CuOi4XDw.js (Deleted) -20.28kB 0 bytes -100.0% 🗑️
assets/api._op-DdX5J5p9.js (Deleted) -17.57kB 0 bytes -100.0% 🗑️
assets/self-hosting-docs-audit-CGVWj4SV.js (Deleted) -16.61kB 0 bytes -100.0% 🗑️
assets/app.index-wJSoGJ_u.js (Deleted) -15.62kB 0 bytes -100.0% 🗑️
assets/docs._slug-uiu02G2W.js (Deleted) -15.22kB 0 bytes -100.0% 🗑️
assets/playground-panel-BSew79_F.js (Deleted) -14.49kB 0 bytes -100.0% 🗑️
assets/app.audit-DKBdngLd.js (Deleted) -10.11kB 0 bytes -100.0% 🗑️
assets/app.config-generator-SlNBGqmF.js (Deleted) -10.09kB 0 bytes -100.0% 🗑️
assets/extension-Coz4ULRY.js (Deleted) -10.04kB 0 bytes -100.0% 🗑️
assets/fairness-66DgQvcp.js (Deleted) -8.34kB 0 bytes -100.0% 🗑️
assets/maintainers-CnOZ_rF0.js (Deleted) -8.09kB 0 bytes -100.0% 🗑️
assets/miners-BItGEFJh.js (Deleted) -7.91kB 0 bytes -100.0% 🗑️
assets/agents-DOxGx25T.js (Deleted) -7.8kB 0 bytes -100.0% 🗑️
assets/commands-panel-D44PYTnk.js (Deleted) -6.65kB 0 bytes -100.0% 🗑️
assets/maintainer-workflow-N8k8jLB_.js (Deleted) -6.52kB 0 bytes -100.0% 🗑️
assets/roadmap-CpXEY4VC.js (Deleted) -6.33kB 0 bytes -100.0% 🗑️
assets/digest-panel-Dtdllm1f.js (Deleted) -6.18kB 0 bytes -100.0% 🗑️
assets/repos._owner._repo.quality-Biwgafa2.js (Deleted) -6.14kB 0 bytes -100.0% 🗑️
assets/docs.index-BQs82p7K.js (Deleted) -5.73kB 0 bytes -100.0% 🗑️
assets/docs-nav-20t1uBpA.js (Deleted) -5.53kB 0 bytes -100.0% 🗑️
assets/api.index-DLuuzv0c.js (Deleted) -4.7kB 0 bytes -100.0% 🗑️
assets/docs-CbsYYPTE.js (Deleted) -2.7kB 0 bytes -100.0% 🗑️
assets/api-CZiywIAU.js (Deleted) -2.69kB 0 bytes -100.0% 🗑️
assets/docs-page-Bk6g5XeI.js (Deleted) -2.1kB 0 bytes -100.0% 🗑️
assets/table-D1h9xiCe.js (Deleted) -1.75kB 0 bytes -100.0% 🗑️
assets/app.workbench-BqnROlz_.js (Deleted) -1.58kB 0 bytes -100.0% 🗑️
assets/session-BanTRQzj.js (Deleted) -1.45kB 0 bytes -100.0% 🗑️
assets/tooltip-pWpq8IdG.js (Deleted) -1.45kB 0 bytes -100.0% 🗑️
assets/tabs-Bgyv-hrK.js (Deleted) -1.39kB 0 bytes -100.0% 🗑️
assets/app.repos-DSqbcf8l.js (Deleted) -1.07kB 0 bytes -100.0% 🗑️
assets/input-CGaEJxDA.js (Deleted) -796 bytes 0 bytes -100.0% 🗑️
assets/file-cog-CqpfT4bF.js (Deleted) -758 bytes 0 bytes -100.0% 🗑️
assets/app.maintainer-B2-9-WIK.js (Deleted) -502 bytes 0 bytes -100.0% 🗑️
assets/sparkles-Cwm3F3CC.js (Deleted) -494 bytes 0 bytes -100.0% 🗑️
assets/app.owner-C0sRRdYM.js (Deleted) -474 bytes 0 bytes -100.0% 🗑️
assets/app.commands-BXjFHbqV.js (Deleted) -455 bytes 0 bytes -100.0% 🗑️
assets/app.playground-DMFTsalI.js (Deleted) -442 bytes 0 bytes -100.0% 🗑️
assets/reveal-C2AGnJ4_.js (Deleted) -442 bytes 0 bytes -100.0% 🗑️
assets/index-BV6upkgf.js (Deleted) -438 bytes 0 bytes -100.0% 🗑️
assets/app.digest-CEmJ-Jh0.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/eye-off-3Fxay1dM.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/app.miner-K4OYkchR.js (Deleted) -422 bytes 0 bytes -100.0% 🗑️
assets/key-round-BqdM25HW.js (Deleted) -355 bytes 0 bytes -100.0% 🗑️
assets/bot-DwAMZLhg.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/trash-2-ycEtGrzl.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/save-D_q3lC7m.js (Deleted) -327 bytes 0 bytes -100.0% 🗑️
assets/git-pull-request-arrow-BsYgJeTs.js (Deleted) -321 bytes 0 bytes -100.0% 🗑️
assets/wrench-BHnlQdcm.js (Deleted) -303 bytes 0 bytes -100.0% 🗑️
assets/list-checks-BEFBESQr.js (Deleted) -279 bytes 0 bytes -100.0% 🗑️
assets/shield-D-aidBKQ.js (Deleted) -272 bytes 0 bytes -100.0% 🗑️
assets/workflow-Pvz3cFN1.js (Deleted) -265 bytes 0 bytes -100.0% 🗑️
assets/compass-Dk97DbjI.js (Deleted) -251 bytes 0 bytes -100.0% 🗑️
assets/history-Cwl-gtDp.js (Deleted) -237 bytes 0 bytes -100.0% 🗑️
assets/activity-Do_NhAFL.js (Deleted) -234 bytes 0 bytes -100.0% 🗑️
assets/message-square-DkWUeHFc.js (Deleted) -233 bytes 0 bytes -100.0% 🗑️
assets/lock-78iC1_JU.js (Deleted) -206 bytes 0 bytes -100.0% 🗑️
assets/rotate-cw-CiU5YcOp.js (Deleted) -201 bytes 0 bytes -100.0% 🗑️
assets/play-em7ojTCc.js (Deleted) -190 bytes 0 bytes -100.0% 🗑️
assets/circle-check-BAHzPqPD.js (Deleted) -178 bytes 0 bytes -100.0% 🗑️
assets/search-BTMYG1IZ.js (Deleted) -174 bytes 0 bytes -100.0% 🗑️
assets/circle-D1S3UC--.js (Deleted) -130 bytes 0 bytes -100.0% 🗑️

@JSONbored JSONbored self-assigned this Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.11%. Comparing base (80455e1) to head (5075e97).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/selfhost/redeploy-companion-client.ts 93.33% 0 Missing and 3 partials ⚠️
src/mcp/server.ts 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8209   +/-   ##
=======================================
  Coverage   92.10%   92.11%           
=======================================
  Files         776      778    +2     
  Lines       78328    78394   +66     
  Branches    23667    23686   +19     
=======================================
+ Hits        72147    72209   +62     
  Misses       5062     5062           
- Partials     1119     1123    +4     
Flag Coverage Δ
shard-1 57.40% <6.06%> (+2.46%) ⬆️
shard-2 47.65% <93.93%> (-4.95%) ⬇️
shard-3 56.99% <7.57%> (+2.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/mcp/redeploy-companion-registry.ts 100.00% <100.00%> (ø)
src/mcp/server.ts 96.60% <94.44%> (-0.04%) ⬇️
src/selfhost/redeploy-companion-client.ts 93.33% <93.33%> (ø)

…ploy image override

Security scanner flagged isSafeImageOverride for not rejecting backticks,
which can trigger bash command substitution. Verified empirically (not just
by inspection) that this isn't currently exploitable: redeploy-companion.ts's
spawn() never sets shell: true, so the image string always reaches
deploy-selfhost-image.sh as a single literal argv element, and that script
only ever references it through properly quoted expansions ("$1", "$IMAGE") --
confirmed with a standalone repro that a backtick payload passed as real argv
data stays inert literal text through resolve_image, the generated compose
override YAML, and would reach docker compose unexecuted.

Fixed anyway as defense-in-depth: no legitimate Docker image reference ever
needs backticks, semicolons, pipes, ampersands, or angle brackets, so
rejecting them costs nothing, and it removes a fragile invariant (the
"nothing here is ever unquoted" guarantee) that a future change to either
side of this call could silently break. Applied consistently across all
three places that share this character class: deploy-selfhost-image.sh's
authoritative validate_inputs, redeploy-companion.ts's own pre-check, and the
MCP tool's zod schema.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@superagent-security superagent-security Bot removed the pr:flagged PR flagged for review by security analysis. label Jul 23, 2026
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 23, 2026
@loopover-orb

loopover-orb Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-23 13:42:45 UTC

20 files · 1 AI reviewer · no blockers · CI failing · unstable

🛑 Suggested Action - Manual Review

Review summary
This PR adds an opt-in, well-isolated host-companion redeploy mechanism for #7723: a systemd-run Unix-socket listener (scripts/redeploy-companion.ts) that shells out to the existing deploy-selfhost-image.sh, a Node-only client (redeploy-companion-client.ts) wired through a nullable-registry pattern (redeploy-companion-registry.ts) that mirrors the existing #7721 config-admin registry so the node:net import never reaches the Workers bundle, and a new admin-category MCP tool gated by the existing LOOPOVER_MCP_ADMIN_ENABLED flag plus its own separate REDEPLOY_COMPANION_TOKEN. The design correctly avoids mounting /var/run/docker.sock, uses timingSafeEqual for the token compare, never sets shell:true on spawn, and validates the image override redundantly at three layers (MCP zod regex, companion isSafeImageOverride, and the underlying deploy script's own validate_inputs, which is also hardened here to reject more shell metacharacters). Tests are extensive and exercise the real client/server protocol over an actual Unix socket rather than mocking node:net, and registration/auth/not-configured/validation paths are all covered for the MCP tool itself.

Nits — 6 non-blocking
  • scripts/redeploy-companion.ts:161 — unlinkSync(SOCKET_PATH) on a stale entry assumes it's a regular file/socket; if the docker-compose bind mount created it as a directory (Docker's default when the host source path didn't exist yet, e.g. companion started for the first time after the container already ran), unlinkSync throws EISDIR and the companion crash-loops instead of the graceful degradation the docs describe — worth an existsSync + isSocket check or rmSync with recursive.
  • docker-compose.yml comment (`connection-refused` when companion absent) may not match reality: a missing host socket path bind-mounted as an empty directory yields ENOTDIR/EISDIR on connect, not ECONNREFUSED — harmless either way since triggerRedeploy still rejects, but worth correcting the comment.
  • codecov/patch is reported at 93.93% against the repo's 99% target — worth identifying which changed branches (e.g. the `result.error` ternary in handleConnection, or the `isBusy`/`setBusy` interactions) are undercovered before merging.
  • apps/loopover-ui/content/docs/self-hosting-security.mdx:29 — pre-existing use of 'master' for the encryption key; consider 'primary'/'root' terminology if you're touching this file anyway.
  • scripts/redeploy-companion.ts — the in-memory `busy` boolean is scoped to a single companion process instance, which is correct for the single-systemd-service design, but worth a one-line doc note that a companion restart mid-redeploy silently clears the lock (acceptable given deploy-selfhost-image.sh's own idempotent pull+up -d, but non-obvious).
  • Possible secret-shaped assignment in the diff (generic_secret_assignment) — Verify the value is not a real credential.

CI checks failing

  • codecov/patch — 93.93% of diff hit (target 99.00%)

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7723
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 14 registered-repo PR(s), 14 merged, 242 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 242 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The PR explicitly records the required proxy-mediated vs. host-companion design decision with rationale, implements a host companion that authenticates independently and calls through the existing deploy-selfhost-image.sh script without reimplementing it, adds the gated admin MCP tool, and includes tests plus a security-tradeoffs-oriented docs/comment trail matching the issue's deliverables.

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 14 PR(s), 242 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before /
before /
after /
after /
/ mobile before / (mobile)
before / (mobile)
after / (mobile)
after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

Scroll preview
Route Before (production) After (this PR's preview)
/ before / (scroll)
before / (scroll)
after / (scroll)
after / (scroll)

A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 23, 2026
test/unit/docker-compose-env-example-parity.test.ts failed CI: docker-compose.yml
interpolates this var twice but it was never documented in .env.example
(REDEPLOY_COMPANION_TOKEN_FILE was already covered via secrets/README.md).
@JSONbored
JSONbored merged commit 8017db1 into main Jul 23, 2026
16 of 17 checks passed
@JSONbored
JSONbored deleted the feat/redeploy-companion branch July 23, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design + implement a redeploy trigger for self-hosted instances (no raw docker.sock)

1 participant