Khorsheed/dsh-ankh-guard 预览 preview

Khorsheed/dsh-ankh-guard

插件Plugin ⭐ 6 MIT coding

防止 Agent 自我修改把服务改崩的守护插件(dsh 插件):绿色构建凭证绑定 git HEAD,改坏不许重启;watchdog 无感重启 + canary 自动回滚

编辑导读Editor's Brief

## 核心特性
- 为代理发起的重启设置凭据门槛;该凭据仅在构建和测试检查通过后记录,并绑定到 git commit,且受 maxAgeMinutes 限制。
- 在停止正在运行的实例之前,在子进程中对目标 profile 组合运行 preflight 模拟启动;如果组合失败,则拒绝重启。
- 通过 supervise 提供 watchdog,在实例退出后重启实例、运行 canary 检查,并在多次启动失败后回滚到最近已知可用版本。
- 使用基于 git 的检查点和重置,为被丢弃的 HEAD 和未提交更改创建 guard-backup-* 分支锚点,使恢复不依赖 reflog。
- 在计划重启后恢复被中断的 root 会话,并通过注入后续上下文向发起会话发送重启报告。

## 使用场景
- 修改 DSH 部署并需要在构建、测试和组合检查全部通过后才重启主机的编码代理。
- 需要受监督重启,并在自修改尝试失败后自动恢复的长期运行 DSH web 实例。
- 需要在批量代码更改前创建基于 git 的回滚点,并在重启后进行验证的开发工作流。

## 技术细节
- 该包是一个 DSH 插件,标识为 @khorsheed/dsh-ankh-guard,可通过 dsh plugin --profile web add 从 npm 或 GitHub 镜像安装。
- CLI 命令包括 verifyrecordstatusclearcheckpointresetcanarypreflightrestartschedule-exitsupervise
- Preflight 使用相同引擎启动完整插件树,将 webserver 端口固定为 0,检查客户端 bundle 产物,然后销毁此次模拟运行。
- 重启报告和被中断会话恢复会作为来自插件的快照用户消息注入,配置选项包括 reportRestartContextresumeInterruptedresumeDelayMs

## 注意事项
- 必须安装 Git,因为凭据、检查点和回滚都基于 commit,并且部署目录必须是一个 git 仓库。
- 重启链需要完全访问权限,因为它会生成分离进程、终止进程并绑定端口;沙箱化工具运行器可能会阻止这些操作。
- 安装后,首次重启必须由 CLI 或外部监督器驱动,因为正在运行的实例尚未加载该插件,且还没有 watchdog。

## Core Features
- Gates agent-initiated restarts behind a credential recorded only after build and test checks pass, with the credential bound to the git commit and limited by maxAgeMinutes.
- Runs a preflight dry boot of the target profile composition in a subprocess before stopping the running instance, refusing restart when the composition fails.
- Provides a watchdog through supervise that restarts the instance after exit, runs canary checks, and rolls back to the last known good version after repeated startup failures.
- Uses git-based checkpoints and resets, creating guard-backup-* branch anchors for discarded HEAD and uncommitted changes so recovery does not depend on reflog.
- Restores interrupted root sessions after a planned restart and delivers a restart report to the initiating session through injected followup context.

## Use Cases
- Coding agents that modify a DSH deployment and need to restart the host only after build, test, and composition checks pass.
- Long-running DSH web instances that require supervised restarts with automatic recovery after failed self-modification attempts.
- Development workflows that need git-based rollback points before batches of code changes and verification after restart.

## Technical Details
- The package is a DSH plugin identified as @khorsheed/dsh-ankh-guard and installed through dsh plugin --profile web add from npm or a GitHub mirror.
- CLI commands include verify, record, status, clear, checkpoint, reset, canary, preflight, restart, schedule-exit, and supervise.
- Preflight boots the full plugin tree with the same engine, pins the webserver port to 0, checks client bundle artifacts, then disposes the dry run.
- Restart reporting and interrupted-session resume are injected as plugin-sourced snapshot user messages, with configuration options such as reportRestartContext, resumeInterrupted, and resumeDelayMs.

## Notes
- Git is required because credentials, checkpoints, and rollback are based on commits, and the deployment directory must be a git repository.
- The restart chain requires full-access permissions because it spawns detached processes, kills processes, and binds ports; sandboxed tool runners can block these operations.
- After installation, the first restart must be driven by the CLI or an external supervisor because the running instance has not loaded the plugin and no watchdog exists yet.

安装Install

dsh plugin --profile web add @khorsheed/dsh-ankh-guard

Khorsheed/dsh-ankh-guard 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

上一个 Prev dsh-navigation-bar 下一个 Next dsh-multi-tenant-projects