dsh-plugin-safe-upgrade: Archiving, Controlled Upgrades, and Automatic Rollback for DSH Configurations

Introduction

DeepSeek Harness (dsh) releases rapidly and frequently publishes candidate versions; adding or removing even a single line in cordis.patch.yml can prevent an instance from starting. Manually editing settings.yaml, profile patches, agent presets, or AGENTS.md also makes it difficult to quickly return to the “last known-good” state when problems arise.

The community plugin dsh-plugin-safe-upgrade (maintained by devopsfortunato, categorized under admin-security) addresses this by: recording key configuration changes in Git, running pre-upgrade validation and idle checks, automatically rolling back installation and configuration on failure, and optionally tagging known-good configurations after each boot. This is an unofficial community project that uses only dsh’s public plugin interface and is not affiliated with, or endorsed by, DeepSeek / dsh. Report issues in this repository’s Issues section, not in the main dsh project.

What It Is

dsh-plugin-safe-upgrade targets Linux environments where:
- dsh is installed via npm
- dsh runs under systemd

It provides:
- Automatic versioned history of configuration files required for startup (with protection against committing secrets)
- Health checks after each boot and good-<time> markers
- Web UI commands /upgrade and /rollback, plus CLI dsh-safe-upgrade, for controlled upgrades and rollbacks

Current package version: 0.4.0 (MIT license). The plugin has no extra npm dependencies.

Core Features

Configuration History

Every modification to files that determine whether dsh can start (settings.yaml, profile patches and manifests, agent presets, AGENTS.md, etc.) is automatically committed to a Git repository under $DSH_HOME within seconds. Newly created profile and preset directories are also tracked. Sessions, credentials, caches, and node_modules are excluded. If a file contains a literal secret, the secret guard blocks it from being written to Git.

Configuration history and boot health checks that do not depend on systemd can be used independently of upgrades; upgrade and rollback require systemd.

Known-good Boot Markers

After each boot, the plugin checks for failed plugins, unfinished plugins, and broken presets. If startup is clean, it tags the current configuration and current dsh version with a good-<time> label (only one tag per configuration/version combination).

/upgrade: Side-load, Verify, Then Switch

The upgrade workflow does not touch the running service until the last moment:
1. The new version is installed into a side-by-side directory.
2. Every profile is validated with dsh --dump-config in a temporary copy of $DSH_HOME.
3. After confirming idleness again, dsh is stopped, the installation directories are swapped, and the new version is started.
4. If the new version cannot become healthy, the previous installation and configuration are automatically restored.

Downtime consists mainly of the directory swap plus one startup (on the order of seconds per the README).

Note: dsh --dump-config is not strictly read-only (for example, version 0.1.7 rewrites cordis.yml files inside profiles). Validation therefore always runs on a copy of the configuration; the live $DSH_HOME is never modified by dry runs or rejected upgrades.

Session Continuity Check

Before shutting down for an upgrade, the plugin opens copies of every stored session using both the current and new dsh versions. If a session that opens successfully today will not open under the new version, the upgrade is aborted. If a session references an agent preset that no longer exists in the new version, the plugin attempts to write a copy of the default preset under a legacy name so the conversation can continue. On rollback, a warning is issued if any session continued on the new version may disappear on the old version.

Web UI Check (optional Chromium)

After the new version starts, the plugin loads the real web application in headless Chromium. If the dsh “Failed to load plugins” screen appears, a rollback is triggered to catch browser-side plugin failures that the server might not detect. If Chromium/Chrome is not installed, this step is skipped and recorded as a warning.

Warnings and failOnWarnings

Upgrades, dry runs, and rollbacks report patches that no longer match in the new version, as well as recorded plugin errors that did not cause failure. Enabling failOnWarnings treats these as failures:
- Dry runs fail
- Upgrades halt before touching dsh (configuration warnings) or roll back after startup (startup warnings)
- Manual rollbacks can be overridden

Automatic recovery is never overridden because of warnings.

/rollback

You can return to any known-good boot marker or recent configuration snapshot. The target configuration is validated before dsh is stopped. If the marker corresponds to a different dsh version whose installation directory still exists, that installation is swapped back as well.

Boot Guard (optional)

A systemd drop-in validates configuration before every startup. If dsh fails three consecutive times, the latest locally recoverable known-good configuration is restored and startup is attempted again. The guard runs as the same user and is limited to one attempt per 15 minutes to avoid loops. It also catches corruption caused by manual changes unrelated to upgrades.

Optional Telegram Alerts

Telegram notifications can be configured for upgrade, rollback, and recovery events (see the repository documentation for details).

Environment Requirements

  • dsh version 0.1.5 or newer, installed via npm (with @deepseek-ai/dsh present in node_modules), running as a systemd service (system or user unit).
  • Linux with git, npm, cp, systemd-run; Node.js ≥ 22.
  • Session checks copy $DSH_HOME/sessions, so sufficient disk space next to $DSH_HOME is required.
  • Chromium/Chrome is optional for the Web UI check.

Installation & Activation

Follow the repository README for installation commands (do not manually construct dsh plugin add github:owner/repo):

git clone https://github.com/MovieMaker93/dsh-plugin-safe-upgrade ~/.dsh/plugins/safe-upgrade
dsh plugin --profile web add link:$HOME/.dsh/plugins/safe-upgrade
sudo systemctl restart dsh          # or whatever your unit is called

dsh plugin add registers the package as a profile bundle and inserts the safe-upgrade line. On first startup it begins configuration history and marks the boot as good.

Optional boot guard (run once as the user that owns the unit):

node ~/.dsh/plugins/safe-upgrade/bin/dsh-safe-upgrade.mjs install-guard --unit dsh

Security note: The plugin runs with the same privileges as the dsh process; it can read/write $DSH_HOME, perform upgrades, and execute Git operations. Review the source code and the MIT license before installing to ensure it meets your operational and compliance requirements.

Typical Usage

Web UI

Enter commands in the Web UI and press Enter:

Command Purpose
/upgrade Lists newer latest/next releases, performs dry runs, “check now,” and shows the last job; refuses while a turn is running.
/rollback Lists known-good boots and recent configuration snapshots.

Browser notifications (if authorized) or page toasts appear when jobs finish.

CLI

dsh-safe-upgrade status
dsh-safe-upgrade upgrade latest --dry-run
dsh-safe-upgrade upgrade 0.1.7-rc.2
dsh-safe-upgrade rollback good-20260928-190522
dsh-safe-upgrade check-ui        # does the web UI actually load right now?
dsh-safe-upgrade sessions        # which sessions fail to open, and which can't be continued
dsh-safe-upgrade sessions --fix-presets   # add legacy presets for sessions whose preset is gone
dsh-safe-upgrade install-guard --unit dsh [--remove]

sessions operates on a copy of $DSH_HOME/sessions and does not modify real sessions; --fix-presets synthesizes legacy presets with the running dsh, then writes them into the profile’s cordis.patch.yml (profiles with patchReload: live can hot-reload).

Upgrade Flow Overview

Summarized from the README: Web UI /upgrade first checks idle status and absence of running jobs inside dsh → starts a supervisor via systemd-run (survives a dsh restart) → acquires a lock and creates a pre-upgrade-* snapshot → copies the installation directory, pins @deepseek-ai/*, and runs npm install → validates each profile on a temporary $DSH_HOME with dump-config → performs dual-version session open checks → waits for idleness → stops dsh and swaps the install directory → writes legacy presets if needed → starts dsh → waits for HTTP and health markers → runs the headless browser Web UI check → collects journal warnings. If any step fails, the service is stopped, the previous install.prev and pre-upgrade configuration are restored, and startup is verified.

Use Cases & Caveats

Good fit: Operations or self-hosters who manage dsh under systemd long-term, need to track latest/next releases, worry about configuration or RCs breaking instances, and want Git-based configuration history with one-click rollback to known-good states.

Not suitable or needs extra preparation:
- Deployments without systemd (cannot use /upgrade//rollback; only history and health checks are available)
- Environments lacking disk space for session copies
- Settings where automatic Git and rollback operations on the installation directory and $DSH_HOME are unacceptable

The DSH ecosystem embraces a “everything is a plugin” philosophy; community catalog sites are independent of DeepSeek / High-Flyer, and this plugin is likewise independently maintained by the community.

Conclusion

dsh-plugin-safe-upgrade turns “traceable configuration, verifiable upgrades, rollback on failure” into a process tightly bound to dsh’s startup path, reducing downtime risks from frequent RCs and misconfigured patches. Learn more via the catalog page and GitHub repository (use the clone address in the README for installation).

  • Catalog page: https://www.skillhub.cn/plugins/devopsfortunato/dsh-plugin-safe-upgrade
  • GitHub: https://github.com/devopsfortunato/dsh-plugin-safe-upgrade
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye