@tayomi/deterministic-gates 0.0.0-stage → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +15 -0
- package/.claude-plugin/plugin.json +14 -0
- package/.codex-plugin/plugin.json +20 -0
- package/LICENSE +21 -0
- package/README.md +111 -2
- package/catalog/go.json +92 -0
- package/catalog/index.html +398 -0
- package/catalog/python.json +46 -0
- package/catalog/typescript.json +125 -0
- package/dist/src/cli.js +65 -0
- package/dist/src/core/check.js +157 -0
- package/dist/src/core/config.js +180 -0
- package/dist/src/core/json.js +32 -0
- package/dist/src/core/report-cache.js +35 -0
- package/dist/src/core/report.js +127 -0
- package/dist/src/core/run.js +172 -0
- package/dist/src/core/send-back.js +53 -0
- package/dist/src/core/snapshot.js +94 -0
- package/dist/src/core/turn-state.js +93 -0
- package/dist/src/core/waive-line.js +15 -0
- package/dist/src/helpers/new-clones.js +57 -0
- package/dist/src/helpers/new-suppressions.js +31 -0
- package/dist/src/helpers/related-tests.js +109 -0
- package/dist/src/helpers/test-reporter.js +57 -0
- package/dist/src/hook/display.js +22 -0
- package/dist/src/hook/hook.js +119 -0
- package/hooks/claude.json +17 -0
- package/hooks/hooks.json +38 -0
- package/hooks/register.ts +12 -0
- package/package.json +51 -4
- package/src/catalog/catalog.ts +168 -0
- package/src/cli.ts +61 -0
- package/src/core/check.ts +209 -0
- package/src/core/config.ts +225 -0
- package/src/core/json.ts +36 -0
- package/src/core/report-cache.ts +51 -0
- package/src/core/report.ts +159 -0
- package/src/core/run.ts +217 -0
- package/src/core/send-back.ts +87 -0
- package/src/core/snapshot.ts +105 -0
- package/src/core/turn-state.ts +153 -0
- package/src/core/waive-line.ts +19 -0
- package/src/helpers/new-clones.ts +58 -0
- package/src/helpers/new-suppressions.ts +44 -0
- package/src/helpers/related-tests.ts +119 -0
- package/src/helpers/test-reporter.ts +71 -0
- package/src/hook/display.ts +21 -0
- package/src/hook/hook.ts +144 -0
- package/src/testing.ts +39 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tayomi-deterministic-gates",
|
|
3
|
+
"owner": {
|
|
4
|
+
"name": "Pierre Moati",
|
|
5
|
+
"url": "https://github.com/mopi1402"
|
|
6
|
+
},
|
|
7
|
+
"plugins": [
|
|
8
|
+
{
|
|
9
|
+
"name": "deterministic-gates",
|
|
10
|
+
"source": "./",
|
|
11
|
+
"description": "Gates that run on what each turn changed and send the agent back until they pass.",
|
|
12
|
+
"version": "0.4.1"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
|
|
3
|
+
"name": "deterministic-gates",
|
|
4
|
+
"version": "0.4.1",
|
|
5
|
+
"description": "Deterministic backpressure for coding agents: gates that run on what each turn changed and send the agent back until they pass.",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Pierre Moati",
|
|
8
|
+
"url": "https://github.com/mopi1402"
|
|
9
|
+
},
|
|
10
|
+
"repository": "https://github.com/mopi1402/tayomi-deterministic-gates",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": ["coding-agents", "quality-gates", "backpressure", "hooks"],
|
|
13
|
+
"hooks": "./hooks/claude.json"
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deterministic-gates",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Deterministic backpressure for coding agents: gates that run on what each turn changed and send the agent back until they pass.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Pierre Moati",
|
|
7
|
+
"url": "https://github.com/mopi1402"
|
|
8
|
+
},
|
|
9
|
+
"repository": "https://github.com/mopi1402/tayomi-deterministic-gates",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": ["coding-agents", "quality-gates", "backpressure", "hooks"],
|
|
12
|
+
"interface": {
|
|
13
|
+
"displayName": "Deterministic Gates",
|
|
14
|
+
"shortDescription": "Runs the gates of the repo on what each turn changed, and sends the agent back until they pass.",
|
|
15
|
+
"longDescription": "Deterministic backpressure for coding agents. At the end of each turn, the gates of the repo run on the files the turn changed: a linter, a type checker, the related tests, a dead-code finder. A gate is a tool, never a model. If a gate fails, the agent is sent back with the report until it fixes the gate or says why it leaves it. The gates live in .gates.json; the catalog of the plugin lists the ones worth copying.",
|
|
16
|
+
"developerName": "Pierre Moati",
|
|
17
|
+
"category": "Developer Tools",
|
|
18
|
+
"websiteURL": "https://github.com/mopi1402/tayomi-deterministic-gates"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pierre Moati
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center"> <img src="docs/images/tayomi-deterministic-gates.png" alt="deterministic-gates" width="220"/> </p>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# deterministic-gates
|
|
4
|
+
|
|
5
|
+
Deterministic backpressure for coding agents. [At the end of each turn](docs/adr/0001-check-at-the-stop.md), the gates run on what the agent changed. A gate is a tool, never a model: a linter, a type checker, the related tests, a dead-code finder. If a gate fails, the agent is sent back with the report until it fixes the gate or says why it leaves it, while the context is fresh: it still holds what it just wrote, so the fix is cheap, where a review or a CI run finds the same problem once that context is gone.
|
|
6
|
+
|
|
7
|
+
CI stays the authority for slow and full checks. The gates catch what the agent just wrote, so the review sees what slipped through.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
The engine works with any agent that speaks the hook protocol Claude Code and Codex share: one hook runs as a session starts, one as a prompt arrives, another as the agent stops. It needs Node 24.2 or later, has no runtime dependency, and does nothing outside git or in a repo with no gates file.
|
|
12
|
+
|
|
13
|
+
### Claude Code
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
/plugin marketplace add mopi1402/tayomi-deterministic-gates
|
|
17
|
+
/plugin install deterministic-gates@tayomi-deterministic-gates
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
To enable it for one repo only, declare the marketplace and the plugin in that repo's `.claude/settings.json`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"extraKnownMarketplaces": {
|
|
25
|
+
"tayomi-deterministic-gates": {
|
|
26
|
+
"source": { "source": "github", "repo": "mopi1402/tayomi-deterministic-gates" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"enabledPlugins": { "deterministic-gates@tayomi-deterministic-gates": true }
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Codex
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
codex plugin marketplace add mopi1402/tayomi-deterministic-gates
|
|
37
|
+
codex plugin add deterministic-gates@tayomi-deterministic-gates
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Codex runs no hook you have not reviewed: in a session, open `/hooks` and trust the three hooks of the plugin. A plugin update that changes a script asks for a new review.
|
|
41
|
+
|
|
42
|
+
## Configure the gates
|
|
43
|
+
|
|
44
|
+
The gates of a repo live in `.gates.json` at its root, committed. The quickest start is `catalog/`: one file per technology, each gate with what it catches and the tools it requires, and `catalog/index.html` is the same content as a page. Copy a gate into `.gates.json`, install what it requires, and adapt its `files` to the layout of the repo.
|
|
45
|
+
|
|
46
|
+
A gate names a command, and the files that make it run:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"gates": [
|
|
51
|
+
{
|
|
52
|
+
"name": "lint",
|
|
53
|
+
"severity": "error",
|
|
54
|
+
"files": "\\.(ts|tsx)$",
|
|
55
|
+
"run": ["eslint", "--max-warnings", "0", "--no-warn-ignored", "{files}"]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `name`: lowercase words joined by hyphens.
|
|
62
|
+
- `severity`: `error` sends the agent back when the gate fails, `off` turns the gate off.
|
|
63
|
+
- `files`: a regular expression on the repo-relative paths. The gate runs when the turn changed a match.
|
|
64
|
+
- `run`: the command, then its arguments. `{files}` expands to the changed files the gate looks at.
|
|
65
|
+
|
|
66
|
+
A gate whose tool is not installed does not run: as the next prompt arrives, the agent is asked to install it.
|
|
67
|
+
|
|
68
|
+
[docs/configuration.md](docs/configuration.md) gives the rest: every field of a gate, how `run` finds its program, the settings of the whole check, and the overrides each developer keeps in `.gates.local.json`.
|
|
69
|
+
|
|
70
|
+
## How a turn is checked
|
|
71
|
+
|
|
72
|
+
1. When a prompt arrives, the engine records the working tree as a commit that no branch points to, without touching the index, the files or any branch.
|
|
73
|
+
2. When the agent stops, it records the tree again and lists the files the turn changed.
|
|
74
|
+
3. Each gate with a matching file runs, all of them in parallel, with the gates as the turn started.
|
|
75
|
+
4. If a gate fails, the agent is sent back with the reports, told to fix the code and never the check. Each stop is checked again from the turn start, so a fix that breaks another gate is caught, up to 5 times a turn by default ([`maxSendBacks`](docs/configuration.md#the-settings-of-the-whole-check)).
|
|
76
|
+
5. The agent may instead waive a red gate, with a reason you see in orange in the summary: for the turn only, and never in CI. [docs/turn.md](docs/turn.md#the-waivers) says when and how.
|
|
77
|
+
|
|
78
|
+
Each stop ends with a summary, such as:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
● gates 2/3 gates green in 5.1 s · the agent is sent back to fix it (1 of 5)
|
|
82
|
+
✗ tests 5.0 s
|
|
83
|
+
✓ clones 900 ms ✓ lint 300 ms
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
[docs/turn.md](docs/turn.md) draws the rest: where the start comes from, how a compared gate reads its report, what the engine keeps between turns, and what the lock covers.
|
|
87
|
+
|
|
88
|
+
To check the whole repo, as before adopting the gates, in a pre-push hook or in CI:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
npx @tayomi/deterministic-gates check
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Every gate runs on every file that matches, and the command exits with 1 when a gate fails.
|
|
95
|
+
|
|
96
|
+
## Develop
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
pnpm install --frozen-lockfile
|
|
100
|
+
pnpm check
|
|
101
|
+
pnpm integration
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This repo runs under its own gates, in its `.gates.json`, and no gate runs a whole test suite at the end of a turn: that is what `pnpm check`, `pnpm integration` and `node src/cli.ts check` are for.
|
|
105
|
+
|
|
106
|
+
`integration/` holds a sample project per catalog. The integration tests play an agent's turn on each, with no agent and no model: a clean change passes every gate, and each gate catches the fault written for it. A gate whose tool is not installed fails its test, with how to install it: every tool the catalogs require is needed. To add a gate to a catalog, edit its file, write its fault, and run `pnpm catalog` to regenerate the page.
|
|
107
|
+
|
|
108
|
+
CI runs `pnpm check` and `pnpm integration` on every push and pull request, with the tool of every catalog gate installed. A tool a new gate requires is added to `.github/workflows/ci.yml`.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
package/catalog/go.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Go",
|
|
3
|
+
"description": "Gates for a Go module. The toolchain comes from the PATH. The first build of a cold cache is slow, which is why these gates allow 60 seconds.",
|
|
4
|
+
"gates": [
|
|
5
|
+
{
|
|
6
|
+
"description": "Builds every package of the module.",
|
|
7
|
+
"requires": [
|
|
8
|
+
{
|
|
9
|
+
"tool": "go",
|
|
10
|
+
"install": "https://go.dev/doc/install"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"gate": {
|
|
14
|
+
"name": "build",
|
|
15
|
+
"severity": "error",
|
|
16
|
+
"files": "(\\.go|(^|/)go\\.(mod|sum))$",
|
|
17
|
+
"run": ["go", "build", "./..."]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"description": "Runs go vet on every package: the suspicious constructs the compiler accepts.",
|
|
22
|
+
"requires": [
|
|
23
|
+
{
|
|
24
|
+
"tool": "go",
|
|
25
|
+
"install": "https://go.dev/doc/install"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"gate": {
|
|
29
|
+
"name": "vet",
|
|
30
|
+
"severity": "error",
|
|
31
|
+
"files": "(\\.go|(^|/)go\\.(mod|sum))$",
|
|
32
|
+
"run": ["go", "vet", "./..."]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"description": "Fails on the files the turn left unformatted. gofmt -l lists them and exits with 0, so the gate compares its list with the one as the turn started.",
|
|
37
|
+
"requires": [
|
|
38
|
+
{
|
|
39
|
+
"tool": "gofmt",
|
|
40
|
+
"install": "comes with Go: https://go.dev/doc/install"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"gate": {
|
|
44
|
+
"name": "format",
|
|
45
|
+
"severity": "error",
|
|
46
|
+
"files": "\\.go$",
|
|
47
|
+
"run": ["gofmt", "-l", "."],
|
|
48
|
+
"compare": "turn-start"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"description": "Runs the tests of every package. Go caches the result of a package that did not change, so only the packages the turn touched run again.",
|
|
53
|
+
"requires": [
|
|
54
|
+
{
|
|
55
|
+
"tool": "go",
|
|
56
|
+
"install": "https://go.dev/doc/install"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"gate": {
|
|
60
|
+
"name": "test",
|
|
61
|
+
"severity": "error",
|
|
62
|
+
"files": "(\\.go|(^|/)go\\.(mod|sum))$",
|
|
63
|
+
"run": ["go", "test", "./..."]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"description": "Lints with golangci-lint, and reports only the issues created since the turn started (--new-from-rev).",
|
|
68
|
+
"requires": [
|
|
69
|
+
{
|
|
70
|
+
"tool": "golangci-lint",
|
|
71
|
+
"install": "https://golangci-lint.run/docs/welcome/install/"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"gate": {
|
|
75
|
+
"name": "lint",
|
|
76
|
+
"severity": "error",
|
|
77
|
+
"files": "\\.go$",
|
|
78
|
+
"run": ["golangci-lint", "run", "--new-from-rev", "{turn}"]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"description": "Fails on the rule suppressions the turn added, never on the ones already there: nolint and go:nolint. The cheapest green is to silence the rule, and this is the gate that refuses it.",
|
|
83
|
+
"requires": [],
|
|
84
|
+
"gate": {
|
|
85
|
+
"name": "no-new-suppressions",
|
|
86
|
+
"severity": "error",
|
|
87
|
+
"files": "\\.go$",
|
|
88
|
+
"run": ["{engine}/src/helpers/new-suppressions.ts", "{turn}", "{files}"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|