ai-test-loop 1.2.8__tar.gz → 1.4.0__tar.gz
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.
- {ai_test_loop-1.2.8/ai_test_loop.egg-info → ai_test_loop-1.4.0}/PKG-INFO +101 -2
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/README.md +100 -1
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop/__init__.py +1 -1
- ai_test_loop-1.4.0/ai_test_loop/probes/hygiene.py +86 -0
- ai_test_loop-1.4.0/ai_test_loop/probes/hygiene_guard.py +178 -0
- ai_test_loop-1.4.0/ai_test_loop/probes/jogo.py +133 -0
- ai_test_loop-1.4.0/ai_test_loop/scripts/action_guard.py +114 -0
- ai_test_loop-1.4.0/ai_test_loop/scripts/bakeoff.py +226 -0
- ai_test_loop-1.4.0/ai_test_loop/scripts/game_guard.py +356 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop/scripts/loop_runner.py +104 -1
- ai_test_loop-1.4.0/ai_test_loop/scripts/regression_ledger.py +166 -0
- ai_test_loop-1.4.0/ai_test_loop/scripts/release_critic.py +366 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop/scripts/repo_probe.py +243 -4
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop/scripts/sync_copies.py +21 -1
- ai_test_loop-1.4.0/ai_test_loop/scripts/vistoria.py +108 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0/ai_test_loop.egg-info}/PKG-INFO +101 -2
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop.egg-info/SOURCES.txt +10 -1
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/pyproject.toml +1 -1
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/LICENSE +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/MANIFEST.in +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop/__main__.py +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop/scripts/__init__.py +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop/scripts/gate_core.py +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop.egg-info/dependency_links.txt +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop.egg-info/entry_points.txt +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/ai_test_loop.egg-info/top_level.txt +0 -0
- {ai_test_loop-1.2.8 → ai_test_loop-1.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ai-test-loop
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Deterministic critic for AI agents: runs weighted checks for real, scores 0-100 and blocks the delivery when it should.
|
|
5
5
|
Author: Samuel Medeiros
|
|
6
6
|
License: MIT
|
|
@@ -290,6 +290,96 @@ Telemetry never blocks and never waits: if the network is down the CLI runs exac
|
|
|
290
290
|
Throwaway exploration, spike branches, and one-line answers where the cost of the loop exceeds the
|
|
291
291
|
cost of being wrong. It is for artifacts a human will rely on.
|
|
292
292
|
|
|
293
|
+
## Game projects (Unity, Godot, Unreal)
|
|
294
|
+
|
|
295
|
+
A game repo is the case this tool used to miss completely: no `package.json`, no
|
|
296
|
+
`pyproject.toml`, so the quick mode answered "nothing ran" — on the artifact where
|
|
297
|
+
quality breaks the most. Measured on the Super Hero Royale streams (Dec 2026).
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
npx ai-test-loop --repo . --vistoria
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
┌────────────────────────────────────────────────┐
|
|
305
|
+
NOTA 15/100 ( Precisa de 85 ) → REPROVADO
|
|
306
|
+
|
|
307
|
+
1. nenhum laço sem freio — Print.cs:4 captura em Update()
|
|
308
|
+
2. log com exceção/crash: Logs/Editor.log:1
|
|
309
|
+
3. .gitignore não ignora: Library, Temp, Logs
|
|
310
|
+
|
|
311
|
+
Não deu para verificar (1): compilação do jogo (dotnet)
|
|
312
|
+
└────────────────────────────────────────────────┘
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
What the game profile checks, without the engine installed:
|
|
316
|
+
|
|
317
|
+
| Check | Catches |
|
|
318
|
+
|---|---|
|
|
319
|
+
| `dotnet build` on the solution | the "remendo" that does not compile |
|
|
320
|
+
| EditMode tests (`dotnet test`) | only when a test project exists |
|
|
321
|
+
| `unity-project` | `ProjectVersion.txt` missing / unpinned |
|
|
322
|
+
| `unity-gitignore` | `Library/`, `Temp/`, `Logs/` about to be committed |
|
|
323
|
+
| `unity-untracked` | cache already committed (blows up every scan) |
|
|
324
|
+
| `elprint-guard` | `CaptureScreenshot`/`Debug.Log` inside `Update()` or `while(true)` without throttle — the tool that burned a monthly token budget live |
|
|
325
|
+
| `log-limpo` | exception or crash recorded in `Logs/` |
|
|
326
|
+
|
|
327
|
+
What it cannot judge (PlayMode tests, scene screenshots, in-engine profiling) is
|
|
328
|
+
reported as "could not check" with the reason — never as failure, never as pass.
|
|
329
|
+
|
|
330
|
+
## Regression ledger — the bug that comes back
|
|
331
|
+
|
|
332
|
+
The measured failure this fixes: the agent says "fixed it", the defect is back the
|
|
333
|
+
next day, and the report treats both runs the same. `--baseline` gives each
|
|
334
|
+
failure a stable signature (line numbers, timings and counts do NOT create a new
|
|
335
|
+
one) and a failure that returns becomes a **blocking gap**, not a score deduction:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
npx ai-test-loop --repo . --vistoria # round 1: novas=1 recorrentes=0
|
|
339
|
+
npx ai-test-loop --repo . --vistoria # round 2: GATE=blocked — regressão
|
|
340
|
+
npx ai-test-loop --repo . --reset-baseline # new cycle (not a lie: it resets)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
REGRESSOES: novas=0 recorrentes=1 corrigidas=0 em_aberto=1
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Budget and the action contract
|
|
348
|
+
|
|
349
|
+
- `--budget-s 300`: a round that runs out of time reports the unrun checks as
|
|
350
|
+
"could not check" and prints `PARTIAL=n`. It never converts a timeout into a
|
|
351
|
+
project failure, and it never spends the whole night without telling you.
|
|
352
|
+
- `ATL_ACTION_LOG=<file>`: every file changed in the repo must be cited in an
|
|
353
|
+
`AÇÃO:` line of the worker's report — the "closed the game without saying a word"
|
|
354
|
+
case. An action declared without any path also fails, listing the files.
|
|
355
|
+
|
|
356
|
+
`npx ai-test-loop --help` lists all flags. The full test suite (222 assertions:
|
|
357
|
+
game mode, ledger, budget, action contract, card, bake-off, parity) runs with
|
|
358
|
+
`python3 tests/ -q` in the repo.
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
## Automatic, and honest about what it cannot judge (02/12/2026)
|
|
362
|
+
|
|
363
|
+
Nothing to configure for the usual stacks — and when a stack is new, Roger says
|
|
364
|
+
what it can and cannot measure instead of guessing:
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
$ npx ai-test-loop --repo ./engine-nova
|
|
368
|
+
FAIL README presente w=15
|
|
369
|
+
FAIL nenhum segredo versionado w=25
|
|
370
|
+
...
|
|
371
|
+
Não deu para verificar: testes automáticos (nenhuma suíte detectada)
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Detect in three layers: project markers, then the CONTENT of the code, then a
|
|
375
|
+
command that actually exists on the machine. New stacks enter as a file in
|
|
376
|
+
`probes/` (`probes/jogo.py` for Unity/Godot/Unreal, `probes/hygiene.py` as the
|
|
377
|
+
floor that runs everywhere) — never as an edit to the runner, and never as a
|
|
378
|
+
config you have to write.
|
|
379
|
+
|
|
380
|
+
`tests/test_probes.py` proves the extension point: drop a file in `probes/` and
|
|
381
|
+
it shows up in the scan, and the Node mirror returns the same check list.
|
|
382
|
+
|
|
293
383
|
## Files
|
|
294
384
|
|
|
295
385
|
| Path | What |
|
|
@@ -297,13 +387,22 @@ cost of being wrong. It is for artifacts a human will rely on.
|
|
|
297
387
|
| `bin/cli.js` | the `npx` entry point (wrapper + telemetry) |
|
|
298
388
|
| `scripts/loop_runner.js` | the deterministic critic, Node port — zero dependencies |
|
|
299
389
|
| `scripts/loop_runner.py` | the same critic in Python (used by the pip package) |
|
|
390
|
+
| `probes/` | stack registry: `jogo` (Unity/Godot/Unreal) and `hygiene` (the floor for any stack) |
|
|
391
|
+
| `scripts/repo_probe.{py,js}` | quick mode: detects the project, builds the checks |
|
|
392
|
+
| `scripts/game_guard.{py,js}` | game-project guards (Unity cache, El Print, log) |
|
|
393
|
+
| `scripts/regression_ledger.{py,js}` | `--baseline` ledger of failures that return |
|
|
394
|
+
| `scripts/action_guard.{py,js}` | every change must be declared in an `AÇÃO:` line |
|
|
395
|
+
| `scripts/vistoria.{py,js}` | the 10-line card, pt-BR, no jargon |
|
|
396
|
+
| `scripts/bakeoff.py` | N builders, same ruler, comparative score (pip only) |
|
|
300
397
|
| `scripts/selftest.js` | 22 assertions covering every way a check can fail — `npm test` |
|
|
301
398
|
| `SKILL.md` | the loop, the scoring rules, the fail-closed gate — drop it in your agent's skills dir |
|
|
302
399
|
| `references/reviewer-prompt.md` | independent-review prompt, strict JSON output |
|
|
303
400
|
| `references/scoring-rubric.md` | starting weights |
|
|
304
401
|
| `templates/loop.example.json` | config with the usual check set |
|
|
305
402
|
|
|
306
|
-
`npm test` runs the selftest. It needs nothing but node.
|
|
403
|
+
`npm test` runs the selftest. It needs nothing but node. The repo suite
|
|
404
|
+
(`python3 tests/ -q`) adds the game mode, the regression ledger, the action
|
|
405
|
+
contract, the card and the Py/Node parity tests.
|
|
307
406
|
|
|
308
407
|
## Get the full pack
|
|
309
408
|
|
|
@@ -269,6 +269,96 @@ Telemetry never blocks and never waits: if the network is down the CLI runs exac
|
|
|
269
269
|
Throwaway exploration, spike branches, and one-line answers where the cost of the loop exceeds the
|
|
270
270
|
cost of being wrong. It is for artifacts a human will rely on.
|
|
271
271
|
|
|
272
|
+
## Game projects (Unity, Godot, Unreal)
|
|
273
|
+
|
|
274
|
+
A game repo is the case this tool used to miss completely: no `package.json`, no
|
|
275
|
+
`pyproject.toml`, so the quick mode answered "nothing ran" — on the artifact where
|
|
276
|
+
quality breaks the most. Measured on the Super Hero Royale streams (Dec 2026).
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
npx ai-test-loop --repo . --vistoria
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
┌────────────────────────────────────────────────┐
|
|
284
|
+
NOTA 15/100 ( Precisa de 85 ) → REPROVADO
|
|
285
|
+
|
|
286
|
+
1. nenhum laço sem freio — Print.cs:4 captura em Update()
|
|
287
|
+
2. log com exceção/crash: Logs/Editor.log:1
|
|
288
|
+
3. .gitignore não ignora: Library, Temp, Logs
|
|
289
|
+
|
|
290
|
+
Não deu para verificar (1): compilação do jogo (dotnet)
|
|
291
|
+
└────────────────────────────────────────────────┘
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
What the game profile checks, without the engine installed:
|
|
295
|
+
|
|
296
|
+
| Check | Catches |
|
|
297
|
+
|---|---|
|
|
298
|
+
| `dotnet build` on the solution | the "remendo" that does not compile |
|
|
299
|
+
| EditMode tests (`dotnet test`) | only when a test project exists |
|
|
300
|
+
| `unity-project` | `ProjectVersion.txt` missing / unpinned |
|
|
301
|
+
| `unity-gitignore` | `Library/`, `Temp/`, `Logs/` about to be committed |
|
|
302
|
+
| `unity-untracked` | cache already committed (blows up every scan) |
|
|
303
|
+
| `elprint-guard` | `CaptureScreenshot`/`Debug.Log` inside `Update()` or `while(true)` without throttle — the tool that burned a monthly token budget live |
|
|
304
|
+
| `log-limpo` | exception or crash recorded in `Logs/` |
|
|
305
|
+
|
|
306
|
+
What it cannot judge (PlayMode tests, scene screenshots, in-engine profiling) is
|
|
307
|
+
reported as "could not check" with the reason — never as failure, never as pass.
|
|
308
|
+
|
|
309
|
+
## Regression ledger — the bug that comes back
|
|
310
|
+
|
|
311
|
+
The measured failure this fixes: the agent says "fixed it", the defect is back the
|
|
312
|
+
next day, and the report treats both runs the same. `--baseline` gives each
|
|
313
|
+
failure a stable signature (line numbers, timings and counts do NOT create a new
|
|
314
|
+
one) and a failure that returns becomes a **blocking gap**, not a score deduction:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
npx ai-test-loop --repo . --vistoria # round 1: novas=1 recorrentes=0
|
|
318
|
+
npx ai-test-loop --repo . --vistoria # round 2: GATE=blocked — regressão
|
|
319
|
+
npx ai-test-loop --repo . --reset-baseline # new cycle (not a lie: it resets)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
REGRESSOES: novas=0 recorrentes=1 corrigidas=0 em_aberto=1
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Budget and the action contract
|
|
327
|
+
|
|
328
|
+
- `--budget-s 300`: a round that runs out of time reports the unrun checks as
|
|
329
|
+
"could not check" and prints `PARTIAL=n`. It never converts a timeout into a
|
|
330
|
+
project failure, and it never spends the whole night without telling you.
|
|
331
|
+
- `ATL_ACTION_LOG=<file>`: every file changed in the repo must be cited in an
|
|
332
|
+
`AÇÃO:` line of the worker's report — the "closed the game without saying a word"
|
|
333
|
+
case. An action declared without any path also fails, listing the files.
|
|
334
|
+
|
|
335
|
+
`npx ai-test-loop --help` lists all flags. The full test suite (222 assertions:
|
|
336
|
+
game mode, ledger, budget, action contract, card, bake-off, parity) runs with
|
|
337
|
+
`python3 tests/ -q` in the repo.
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
## Automatic, and honest about what it cannot judge (02/12/2026)
|
|
341
|
+
|
|
342
|
+
Nothing to configure for the usual stacks — and when a stack is new, Roger says
|
|
343
|
+
what it can and cannot measure instead of guessing:
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
$ npx ai-test-loop --repo ./engine-nova
|
|
347
|
+
FAIL README presente w=15
|
|
348
|
+
FAIL nenhum segredo versionado w=25
|
|
349
|
+
...
|
|
350
|
+
Não deu para verificar: testes automáticos (nenhuma suíte detectada)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Detect in three layers: project markers, then the CONTENT of the code, then a
|
|
354
|
+
command that actually exists on the machine. New stacks enter as a file in
|
|
355
|
+
`probes/` (`probes/jogo.py` for Unity/Godot/Unreal, `probes/hygiene.py` as the
|
|
356
|
+
floor that runs everywhere) — never as an edit to the runner, and never as a
|
|
357
|
+
config you have to write.
|
|
358
|
+
|
|
359
|
+
`tests/test_probes.py` proves the extension point: drop a file in `probes/` and
|
|
360
|
+
it shows up in the scan, and the Node mirror returns the same check list.
|
|
361
|
+
|
|
272
362
|
## Files
|
|
273
363
|
|
|
274
364
|
| Path | What |
|
|
@@ -276,13 +366,22 @@ cost of being wrong. It is for artifacts a human will rely on.
|
|
|
276
366
|
| `bin/cli.js` | the `npx` entry point (wrapper + telemetry) |
|
|
277
367
|
| `scripts/loop_runner.js` | the deterministic critic, Node port — zero dependencies |
|
|
278
368
|
| `scripts/loop_runner.py` | the same critic in Python (used by the pip package) |
|
|
369
|
+
| `probes/` | stack registry: `jogo` (Unity/Godot/Unreal) and `hygiene` (the floor for any stack) |
|
|
370
|
+
| `scripts/repo_probe.{py,js}` | quick mode: detects the project, builds the checks |
|
|
371
|
+
| `scripts/game_guard.{py,js}` | game-project guards (Unity cache, El Print, log) |
|
|
372
|
+
| `scripts/regression_ledger.{py,js}` | `--baseline` ledger of failures that return |
|
|
373
|
+
| `scripts/action_guard.{py,js}` | every change must be declared in an `AÇÃO:` line |
|
|
374
|
+
| `scripts/vistoria.{py,js}` | the 10-line card, pt-BR, no jargon |
|
|
375
|
+
| `scripts/bakeoff.py` | N builders, same ruler, comparative score (pip only) |
|
|
279
376
|
| `scripts/selftest.js` | 22 assertions covering every way a check can fail — `npm test` |
|
|
280
377
|
| `SKILL.md` | the loop, the scoring rules, the fail-closed gate — drop it in your agent's skills dir |
|
|
281
378
|
| `references/reviewer-prompt.md` | independent-review prompt, strict JSON output |
|
|
282
379
|
| `references/scoring-rubric.md` | starting weights |
|
|
283
380
|
| `templates/loop.example.json` | config with the usual check set |
|
|
284
381
|
|
|
285
|
-
`npm test` runs the selftest. It needs nothing but node.
|
|
382
|
+
`npm test` runs the selftest. It needs nothing but node. The repo suite
|
|
383
|
+
(`python3 tests/ -q`) adds the game mode, the regression ledger, the action
|
|
384
|
+
contract, the card and the Py/Node parity tests.
|
|
286
385
|
|
|
287
386
|
## Get the full pack
|
|
288
387
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Pacote honesto — o piso de nota para QUALQUER stack, inclusive desconhecida.
|
|
2
|
+
|
|
3
|
+
Medido 02/12/2026: repo de engine nova (ou de dados, ou de configuração) chegava
|
|
4
|
+
ao modo rápido e saía com "nenhum teste automático encontrado" + exit 2. Do lado
|
|
5
|
+
de quem usa, o produto dizia "não sirvo para você" — quando a verdade é "não sei
|
|
6
|
+
medir seus testes, mas sei medir seis coisas que valem para qualquer projeto".
|
|
7
|
+
|
|
8
|
+
Este probe garante o piso: nota parcial sempre, com o motivo do que falta. As
|
|
9
|
+
checagens são recomputadas em runtime por `hygiene_guard.py` (o probe decide o que
|
|
10
|
+
emitir; a guarda dá o veredito — se os dois divergirem, a guarda manda).
|
|
11
|
+
|
|
12
|
+
Pesos (total 100):
|
|
13
|
+
|
|
14
|
+
README presente 15
|
|
15
|
+
licença declarada 10
|
|
16
|
+
nenhum segredo versionado 25
|
|
17
|
+
nenhum .env versionado 20
|
|
18
|
+
nenhum caminho pessoal 15
|
|
19
|
+
.gitignore cobre o básico 15
|
|
20
|
+
|
|
21
|
+
Observação de desenho: os checks de segredo/`.env` têm peso alto mas **não são
|
|
22
|
+
`severity: block``** aqui de propósito — o gate de segurança do orquestrador cobre
|
|
23
|
+
isso com gitleaks/trufflehog e veto próprio. Duplicar o veto no modo rápido
|
|
24
|
+
mudaria o comportamento de todo projeto existente sem ninguém pedir.
|
|
25
|
+
"""
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import os
|
|
29
|
+
|
|
30
|
+
NOME = "hygiene"
|
|
31
|
+
PRIORIDADE = -100 # sempre por último: é o piso, não a identidade do projeto
|
|
32
|
+
|
|
33
|
+
_PESOS = {
|
|
34
|
+
"readme": 15,
|
|
35
|
+
"licenca": 10,
|
|
36
|
+
"segredo": 25,
|
|
37
|
+
"env-versionado": 20,
|
|
38
|
+
"caminho-pessoal": 15,
|
|
39
|
+
"gitignore": 15,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_GUARD = os.path.join(os.path.dirname(os.path.abspath(__file__)), "hygiene_guard.py")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _cmd(root: str, check: str) -> str:
|
|
46
|
+
import shlex
|
|
47
|
+
import sys
|
|
48
|
+
return (f"{shlex.quote(sys.executable)} {shlex.quote(_GUARD)} "
|
|
49
|
+
f"--check {check} --root {shlex.quote(root)}")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def detecta(raiz: str, ctx: dict | None = None) -> dict:
|
|
53
|
+
achados = (ctx or {}).get("achados") or {}
|
|
54
|
+
# Sem varredura (--config), `achados` vem vazio e o probe não emite nada:
|
|
55
|
+
# emitir check cego seria inventar veredito sobre um projeto que não olhamos.
|
|
56
|
+
if not achados:
|
|
57
|
+
return {"engine": "", "checks": [], "faltando": []}
|
|
58
|
+
|
|
59
|
+
checks: list[dict] = []
|
|
60
|
+
|
|
61
|
+
if not achados.get("readme"):
|
|
62
|
+
checks.append({"name": "README presente", "cmd": _cmd(raiz, "readme"),
|
|
63
|
+
"weight": _PESOS["readme"], "timeout_s": 60, "cwd": raiz})
|
|
64
|
+
|
|
65
|
+
if not achados.get("licenca"):
|
|
66
|
+
checks.append({"name": "licença declarada", "cmd": _cmd(raiz, "licenca"),
|
|
67
|
+
"weight": _PESOS["licenca"], "timeout_s": 60, "cwd": raiz})
|
|
68
|
+
|
|
69
|
+
if achados.get("segredos"):
|
|
70
|
+
checks.append({"name": "nenhum segredo versionado", "cmd": _cmd(raiz, "segredo"),
|
|
71
|
+
"weight": _PESOS["segredo"], "timeout_s": 60, "cwd": raiz})
|
|
72
|
+
|
|
73
|
+
if achados.get("env_versionado"):
|
|
74
|
+
checks.append({"name": "nenhum .env versionado", "cmd": _cmd(raiz, "env-versionado"),
|
|
75
|
+
"weight": _PESOS["env_versionado"], "timeout_s": 60, "cwd": raiz})
|
|
76
|
+
|
|
77
|
+
if achados.get("caminhos"):
|
|
78
|
+
checks.append({"name": "nenhum caminho pessoal vazado",
|
|
79
|
+
"cmd": _cmd(raiz, "caminho-pessoal"),
|
|
80
|
+
"weight": _PESOS["caminho_pessoal"], "timeout_s": 60, "cwd": raiz})
|
|
81
|
+
|
|
82
|
+
# .gitignore: julga em runtime (o inspect só olha a linha do .env).
|
|
83
|
+
checks.append({"name": ".gitignore cobre o básico", "cmd": _cmd(raiz, "gitignore"),
|
|
84
|
+
"weight": _PESOS["gitignore"], "timeout_s": 60, "cwd": raiz})
|
|
85
|
+
|
|
86
|
+
return {"engine": "", "checks": checks, "faltando": []}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""Guarda do pacote honesto — recomputa em runtime, não confia no que o probe viu.
|
|
2
|
+
|
|
3
|
+
Regra que define o valor disto: um check só vale se ele **medir de novo**. O probe
|
|
4
|
+
(`probes/hygiene.py`) decide *quais* checagens emitir olhando o projeto; a guarda
|
|
5
|
+
decide o *veredito* relendo o projeto no momento em que roda. Se os dois
|
|
6
|
+
divergirem, a guarda manda — é ela que produz a nota.
|
|
7
|
+
|
|
8
|
+
Saída: `PASS <detalhe>` (exit 0) ou `FAIL <detalhe>` (exit 1). Sem exit 2: quem
|
|
9
|
+
não pode julgar não é chamado (o probe só emite o que o projeto tem como julgar).
|
|
10
|
+
|
|
11
|
+
Uso: `python3 probes/hygiene_guard.py --check <nome> --root <pasta>`
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import re
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
SENSITIVE = (".env", ".env.local", ".env.production", "id_rsa", "credentials.json",
|
|
20
|
+
"secrets.yml", "secrets.yaml")
|
|
21
|
+
|
|
22
|
+
SECRET_PATTERNS = (
|
|
23
|
+
("chave OpenAI/Anthropic", r"\b(?:sk-[A-Za-z0-9]{20,}|sk-ant-[A-Za-z0-9\-_]{20,})"),
|
|
24
|
+
("chave AWS", r"\bAKIA[0-9A-Z]{16}\b"),
|
|
25
|
+
("token GitHub", r"\bgh[pousr]_[A-Za-z0-9]{20,}"),
|
|
26
|
+
("chave privada", r"-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----"),
|
|
27
|
+
("senha escrita à mão", r"""(?i)\b(?:password|passwd|senha)\s*[:=]\s*["'][^"'\s]{8,}["']"""),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
CODE_EXT = {".py", ".js", ".jsx", ".ts", ".tsx", ".go", ".rs", ".rb", ".php", ".java",
|
|
31
|
+
".cs", ".sh", ".yml", ".yaml", ".json", ".toml", ".env", ".md", ".cfg", ".ini"}
|
|
32
|
+
|
|
33
|
+
SKIP_DIRS = {".git", "node_modules", "venv", ".venv", "__pycache__", "dist", "build",
|
|
34
|
+
".next", "target", ".mypy_cache", ".pytest_cache", "coverage", ".tox",
|
|
35
|
+
"site-packages", ".ruff_cache", "vendor", "Library", "Temp", "Logs"}
|
|
36
|
+
|
|
37
|
+
_GITIGNORE_MINIMO = (".env", "__pycache__", "node_modules", "dist", "build", ".venv")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _nomes(root: str) -> list[str]:
|
|
41
|
+
try:
|
|
42
|
+
return os.listdir(root)
|
|
43
|
+
except OSError:
|
|
44
|
+
return []
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _walk(root: str, max_bytes: int = 400_000):
|
|
48
|
+
for dirpath, dirnames, filenames in os.walk(root):
|
|
49
|
+
dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS and not d.startswith(".venv")]
|
|
50
|
+
for fn in filenames:
|
|
51
|
+
ext = os.path.splitext(fn)[1].lower()
|
|
52
|
+
if ext and ext not in CODE_EXT:
|
|
53
|
+
continue
|
|
54
|
+
full = os.path.join(dirpath, fn)
|
|
55
|
+
try:
|
|
56
|
+
if os.path.getsize(full) > max_bytes:
|
|
57
|
+
continue
|
|
58
|
+
with open(full, "r", encoding="utf-8", errors="ignore") as fh:
|
|
59
|
+
yield os.path.relpath(full, root), fh.read()
|
|
60
|
+
except OSError:
|
|
61
|
+
continue
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _git_tracked(root: str) -> set[str] | None:
|
|
65
|
+
import shutil
|
|
66
|
+
import subprocess
|
|
67
|
+
if not shutil.which("git") or not os.path.isdir(os.path.join(root, ".git")):
|
|
68
|
+
return None
|
|
69
|
+
try:
|
|
70
|
+
out = subprocess.run(["git", "-C", root, "ls-files"], capture_output=True,
|
|
71
|
+
text=True, timeout=60)
|
|
72
|
+
except (OSError, subprocess.SubprocessError):
|
|
73
|
+
return None
|
|
74
|
+
if out.returncode != 0:
|
|
75
|
+
return None
|
|
76
|
+
return {ln.strip() for ln in out.stdout.splitlines() if ln.strip()}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def check_readme(root: str) -> tuple[bool, str]:
|
|
80
|
+
nomes = _nomes(root)
|
|
81
|
+
if any(n.lower().startswith("readme") for n in nomes):
|
|
82
|
+
return True, "README encontrado"
|
|
83
|
+
return False, "sem README — ninguém sabe o que rodar aqui"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def check_licenca(root: str) -> tuple[bool, str]:
|
|
87
|
+
nomes = _nomes(root)
|
|
88
|
+
if any(n.lower().startswith(("license", "licence", "copying")) for n in nomes):
|
|
89
|
+
return True, "licença declarada"
|
|
90
|
+
return False, "sem licença — uso externo fica indefinido"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def check_segredo(root: str) -> tuple[bool, str]:
|
|
94
|
+
achados = []
|
|
95
|
+
for rel, texto in _walk(root):
|
|
96
|
+
for rotulo, pat in SECRET_PATTERNS:
|
|
97
|
+
if re.search(pat, texto):
|
|
98
|
+
achados.append(f"{rel} ({rotulo})")
|
|
99
|
+
break
|
|
100
|
+
if achados:
|
|
101
|
+
return False, "segredo versionado: " + "; ".join(achados[:3])
|
|
102
|
+
return True, "nenhum segredo óbvio versionado"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def check_env_versionado(root: str) -> tuple[bool, str]:
|
|
106
|
+
tracked = _git_tracked(root)
|
|
107
|
+
if tracked is None:
|
|
108
|
+
# sem git não há versionamento: o probe não emite este check
|
|
109
|
+
return False, "não é repo git"
|
|
110
|
+
sujos = sorted(t for t in tracked if os.path.basename(t) in SENSITIVE)
|
|
111
|
+
if sujos:
|
|
112
|
+
return False, "arquivo de segredo versionado: " + ", ".join(sujos[:3])
|
|
113
|
+
return True, "nenhum arquivo de segredo versionado"
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def check_caminho(root: str) -> tuple[bool, str]:
|
|
117
|
+
pat = re.compile(r"(?:/home/[a-z0-9_.-]+/|/Users/[A-Za-z0-9_.-]+/|[A-Z]:\\\\Users\\\\[^\\\\]+)")
|
|
118
|
+
achados = []
|
|
119
|
+
for rel, texto in _walk(root):
|
|
120
|
+
if pat.search(texto):
|
|
121
|
+
achados.append(rel)
|
|
122
|
+
if achados:
|
|
123
|
+
return False, "caminho pessoal vazado em: " + ", ".join(achados[:3])
|
|
124
|
+
return True, "nenhum caminho pessoal vazado"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def check_gitignore(root: str) -> tuple[bool, str]:
|
|
128
|
+
arq = os.path.join(root, ".gitignore")
|
|
129
|
+
if not os.path.isfile(arq):
|
|
130
|
+
return False, "sem .gitignore"
|
|
131
|
+
with open(arq, "r", encoding="utf-8", errors="ignore") as fh:
|
|
132
|
+
corpo = fh.read()
|
|
133
|
+
faltando = [d for d in _GITIGNORE_MINIMO if not _ignora(corpo, d)]
|
|
134
|
+
if faltando:
|
|
135
|
+
return False, ".gitignore não cobre: " + ", ".join(faltando)
|
|
136
|
+
return True, ".gitignore cobre o básico"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _ignora(gitignore: str, nome: str) -> bool:
|
|
140
|
+
for linha in gitignore.splitlines():
|
|
141
|
+
limpa = linha.strip()
|
|
142
|
+
if not limpa or limpa.startswith("#"):
|
|
143
|
+
continue
|
|
144
|
+
sem = limpa.rstrip("/")
|
|
145
|
+
if sem == nome or limpa == f"{nome}/" or sem == f"/{nome}":
|
|
146
|
+
return True
|
|
147
|
+
return False
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
CHECKS = {
|
|
151
|
+
"readme": check_readme,
|
|
152
|
+
"licenca": check_licenca,
|
|
153
|
+
"segredo": check_segredo,
|
|
154
|
+
"env-versionado": check_env_versionado,
|
|
155
|
+
"caminho-pessoal": check_caminho,
|
|
156
|
+
"gitignore": check_gitignore,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def main() -> int:
|
|
161
|
+
args = sys.argv[1:]
|
|
162
|
+
try:
|
|
163
|
+
nome = args[args.index("--check") + 1]
|
|
164
|
+
root = os.path.abspath(args[args.index("--root") + 1])
|
|
165
|
+
except (ValueError, IndexError):
|
|
166
|
+
print("FAIL hygiene_guard exige --check <nome> e --root <pasta>")
|
|
167
|
+
return 1
|
|
168
|
+
fn = CHECKS.get(nome)
|
|
169
|
+
if fn is None:
|
|
170
|
+
print(f"FAIL check desconhecido: {nome}")
|
|
171
|
+
return 1
|
|
172
|
+
ok, detalhe = fn(root)
|
|
173
|
+
print(("PASS " if ok else "FAIL ") + detalhe)
|
|
174
|
+
return 0 if ok else 1
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
if __name__ == "__main__":
|
|
178
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Probe de jogo — Unity/Godot/Unreal/C#, como arquivo do registro.
|
|
2
|
+
|
|
3
|
+
Esta lógica morava dentro de `repo_probe` desde 02/12/2026. Ela sai para cá por
|
|
4
|
+
um motivo de desenho: stack nova entra como arquivo, não como edição do core.
|
|
5
|
+
Quem adicionar "Love2D amanhã" escreve um `probes/love2d.py`, não mexe no runner.
|
|
6
|
+
|
|
7
|
+
Contrato preservado: os guardas determinísticos (`game_guard.py`) continuam sendo
|
|
8
|
+
quem dá o veredito — este probe só decide o que emitir.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import shlex
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
NOME = "jogo"
|
|
17
|
+
PRIORIDADE = 50
|
|
18
|
+
|
|
19
|
+
_GUARD = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
|
20
|
+
"scripts", "game_guard.py")
|
|
21
|
+
|
|
22
|
+
# Marcadores de conteúdo: 2ª camada de detecção. Quando os marcadores de pasta
|
|
23
|
+
# faltam (repo que versiona só parte do projeto), o código ainda entrega a stack.
|
|
24
|
+
_MARCADORES_CONTEUDO = (
|
|
25
|
+
"using UnityEngine;",
|
|
26
|
+
"using Godot;",
|
|
27
|
+
"MonoBehaviour",
|
|
28
|
+
"ProjectSettings/ProjectVersion.txt",
|
|
29
|
+
"project.godot",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _tem_marcador_conteudo(raiz: str) -> bool:
|
|
34
|
+
for dirpath, dirnames, filenames in os.walk(raiz):
|
|
35
|
+
dirnames[:] = [d for d in dirnames
|
|
36
|
+
if d not in ("Library", "Temp", "Logs", "node_modules", ".git",
|
|
37
|
+
"__pycache__", "dist", "build")]
|
|
38
|
+
for fn in filenames:
|
|
39
|
+
if not fn.endswith((".cs", ".gd", ".tscn")):
|
|
40
|
+
continue
|
|
41
|
+
try:
|
|
42
|
+
with open(os.path.join(dirpath, fn), "r", encoding="utf-8",
|
|
43
|
+
errors="ignore") as fh:
|
|
44
|
+
texto = fh.read(20000)
|
|
45
|
+
except OSError:
|
|
46
|
+
continue
|
|
47
|
+
if any(m in texto for m in _MARCADORES_CONTEUDO):
|
|
48
|
+
return True
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _engine(raiz: str) -> str:
|
|
53
|
+
if os.path.isdir(os.path.join(raiz, "ProjectSettings")):
|
|
54
|
+
return "unity"
|
|
55
|
+
if os.path.isfile(os.path.join(raiz, "project.godot")):
|
|
56
|
+
return "godot"
|
|
57
|
+
for nome in os.listdir(raiz) if os.path.isdir(raiz) else []:
|
|
58
|
+
if nome.endswith(".uproject"):
|
|
59
|
+
return "unreal"
|
|
60
|
+
return ""
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _cmd(root: str, check: str) -> str:
|
|
64
|
+
return (f"{shlex.quote(sys.executable)} {shlex.quote(_GUARD)} "
|
|
65
|
+
f"--check {check} --root {shlex.quote(root)}")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def detecta(raiz: str, ctx: dict | None = None) -> dict | None:
|
|
69
|
+
ctx = ctx or {}
|
|
70
|
+
# 1ª camada: marcadores de pasta/arquivo (o que o core já sabia desde 1.3.0)
|
|
71
|
+
engine = _engine(raiz)
|
|
72
|
+
# 2ª camada: conteúdo — projeto Unity versionado pela metade ainda é Unity
|
|
73
|
+
if not engine and _tem_marcador_conteudo(raiz):
|
|
74
|
+
engine = "unity-parcial"
|
|
75
|
+
if not engine:
|
|
76
|
+
return None
|
|
77
|
+
|
|
78
|
+
checks: list[dict] = []
|
|
79
|
+
faltando: list[dict] = []
|
|
80
|
+
|
|
81
|
+
# 3ª camada: só emite o que a máquina consegue rodar de verdade
|
|
82
|
+
tem_dotnet = _which("dotnet")
|
|
83
|
+
tem_sln = _glob(raiz, ".sln")
|
|
84
|
+
if engine in ("unity", "godot", "unity-parcial") and tem_sln:
|
|
85
|
+
if tem_dotnet:
|
|
86
|
+
checks.append({"name": "compilação do jogo", "cmd": "dotnet build -nologo -v q",
|
|
87
|
+
"weight": 30, "timeout_s": 900, "cwd": raiz})
|
|
88
|
+
else:
|
|
89
|
+
faltando.append({"nome": "compilação do jogo",
|
|
90
|
+
"motivo": "dotnet não instalado (Unity e Godot com C# "
|
|
91
|
+
"compilam pelo .NET SDK)"})
|
|
92
|
+
|
|
93
|
+
guardas = [("unity-gitignore", "caches fora do git", 10),
|
|
94
|
+
("elprint-guard", "nenhum laço sem freio", 20)]
|
|
95
|
+
if engine.startswith("unity"):
|
|
96
|
+
guardas.append(("unity-project", "projeto Unity completo", 10))
|
|
97
|
+
if os.path.isdir(os.path.join(raiz, ".git")):
|
|
98
|
+
guardas.append(("unity-untracked", "nada de cache versionado", 10))
|
|
99
|
+
if _tem_log(raiz):
|
|
100
|
+
guardas.append(("log-limpo", "log sem exceção ou crash", 15))
|
|
101
|
+
for check, rotulo, peso in guardas:
|
|
102
|
+
checks.append({"name": rotulo, "cmd": _cmd(raiz, check),
|
|
103
|
+
"weight": peso, "timeout_s": 180, "cwd": raiz})
|
|
104
|
+
|
|
105
|
+
return {"engine": engine, "checks": checks, "faltando": faltando,
|
|
106
|
+
"dicas": [f"stack detectada por probe 'jogo' ({engine})"]}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _tem_log(raiz: str) -> bool:
|
|
110
|
+
pasta = os.path.join(raiz, "Logs")
|
|
111
|
+
for _dp, _dn, filenames in os.walk(pasta):
|
|
112
|
+
if any(f.lower().endswith((".log", ".txt")) for f in filenames):
|
|
113
|
+
return True
|
|
114
|
+
return False
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _glob(raiz: str, ext: str) -> list[str]:
|
|
118
|
+
achados = []
|
|
119
|
+
for dirpath, dirnames, filenames in os.walk(raiz):
|
|
120
|
+
if dirpath.count(os.sep) - os.path.abspath(raiz).count(os.sep) >= 2:
|
|
121
|
+
dirnames[:] = []
|
|
122
|
+
continue
|
|
123
|
+
dirnames[:] = [d for d in dirnames
|
|
124
|
+
if d not in ("Library", "Temp", "Logs", "node_modules", ".git")]
|
|
125
|
+
for fn in filenames:
|
|
126
|
+
if fn.lower().endswith(ext):
|
|
127
|
+
achados.append(os.path.relpath(os.path.join(dirpath, fn), raiz))
|
|
128
|
+
return achados
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _which(binario: str) -> bool:
|
|
132
|
+
import shutil
|
|
133
|
+
return bool(shutil.which(binario))
|