@cobusgreyling/loop-gate

中文文档
1.0.0发布于 2026/07/20MITTypeScriptES Module构建来源已验证近 30 天下载 2378

Mechanical enforcement of LOOP.md/docs/safety.md's path denylist and auto-merge allowlist — evaluate a proposed change against static policy and block or allow it.

原始使用文档
文档目录4 节
  1. Install & Run
  2. Usage
  3. Policy file
  4. What this does not do

loop-gate

Mechanical enforcement of static safety policy — the code behind docs/safety.md's Path Denylist and Auto-Merge Policy, and LOOP.md's "No auto-merge on main except trivial dependency patches" / "Denylist... without human review" rules. Nothing evaluated a proposed change against that prose before; loop-gate does.

Deliberately has no knowledge of run history. Stagnation, repeated failures, and token/daily budgets already belong to loop-context's circuit breaker — loop-gate only looks at what is being proposed (which paths, what action type), not how the run has behaved so far. Chain the two:

loop-context --check --ledger run.json ...            || exit 2   # run-history based
loop-gate check --action auto-merge --paths a.ts,b.ts  || exit 2   # policy based
do-the-merge

Install & Run

npx @cobusgreyling/loop-gate check --action auto-merge --paths docs/guide.md

From this repo:

cd tools/loop-gate
npm install
npm test

Usage

loop-gate check --action <commit|merge|auto-merge> --paths <f1,f2,...> [--gate-file gate.yaml] [--json]
FlagDefaultMeaning
--action <commit|merge|auto-merge>requiredWhat the loop is about to do
--paths <f1,f2,...>requiredComma-separated changed file paths
--gate-file <path>gate.yaml (cwd)Policy file to evaluate against
--jsonoffMachine-readable decision output

Exit codes: 0 allowed · 2 escalate · 1 error (bad flags, missing/invalid config).

Policy file

gate.yaml is the machine-readable twin of docs/safety.md — see templates/gate.yaml.template to scaffold your own, or this repo's own dogfood gate.yaml:

version: 1
denylist:
  - ".env"
  - "**/secrets/**"
  - "auth/**"
maxFiles: 10
autoMergeAllowlist:
  - "docs/**"
  - "**/*.md"

Checked in order (first match wins, same "most specific trigger first" convention loop-context's circuit breaker uses):

  1. denylist — any changed path matching a glob here escalates, regardless of --action.
  2. maxFiles — more changed paths than this escalates (matches docs/safety.md's "Changes touching >N files" human gate).
  3. autoMergeAllowlist — only checked when --action auto-merge; every changed path must match one of these globs, or it escalates.

Glob matching is via minimatch (the same semantics .gitignore-style globs use — ** matches across path segments).

What this does not do

  • Does not read a run ledger, and never will — that keeps it decoupled from loop-context at the source level, the same way loop-worktree and loop-context stay independent while still being paired by convention in a control script.
  • Does not produce its own escalation summary format — fold its JSON decision into whatever your control script already assembles from loop-context --inject when escalating to a human.
  • Does not enforce anything by itself — like loop-worktree's locks, this is advisory: a control script that skips calling loop-gate is not physically blocked. The mechanism is only as good as the scripts that call it.

See docs/safety.md for the policy this codifies, and docs/primitives.md for where safety gates fit in the Five Building Blocks + Memory model.

版本与发布记录

@cobusgreyling/loop-gate 共发布 1 个版本,首次发布于 2026/07/20;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0latest2026/07/203 个月前

关于 @cobusgreyling/loop-gate 的常见问题

@cobusgreyling/loop-gate 是什么?

Mechanical enforcement of LOOP.md/docs/safety.md's path denylist and auto-merge allowlist — evaluate a proposed change against static policy and block or allow it.

如何安装 @cobusgreyling/loop-gate?

在项目目录运行 npm install @cobusgreyling/loop-gate,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 loop-gate,可以用 npx loop-gate 直接运行。

@cobusgreyling/loop-gate 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cobusgreyling/loop-gate 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cobusgreyling/loop-gate 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cobusgreyling/loop-gate 可以商用吗?

@cobusgreyling/loop-gate 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cobusgreyling/loop-gate 的下载量有多少?

根据 npm 官方下载统计,@cobusgreyling/loop-gate 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,378 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cobusgreyling/loop-gate 还在维护吗?

最新版本 1.0.0 发布于 2026/07/20(3 个月前);至今共发布 1 个版本,其中过去 12 个月发布了 1 个;首次发布于 2026/07/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。