Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .agent_history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Agent history

## 2026-10-24 — V22-CAVEMAN-HG-1 — cycle 1

- phase: policy
- decision: continuar
- risk_tier: standard
- topology: pipeline
- require: knowledge_grounding, tests
- budget.max_spawns: 8
- summary: Caveman voice skill v4.0.1 vendored at `d262ab3882952a59312ff3537cd86d894523c5ab`. Output hard gate default ON. Opt-out `EVOLVELOOP_BREVITY_CAVEMAN=off`. Exceptions stay verbatim. `caveman-compress` stays out. GOAL-009 briefing compressor is not the default worker path. PDA critic/test gates run after the patch.
6 changes: 6 additions & 0 deletions .ai/log.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# Session log

## 2026-10-24 — V22-CAVEMAN-HG-1

- knowledge_grounding: applied, with gap. Vault fixture `fixtures/evolveloop-wiki-vault` has no Caveman page. Sources used: `docs/research/evolveloop-v2.2/03-repositories-and-tools.md`, `docs/research/evolveloop-v2.2/06-token-optimization.md`, upstream `skills/caveman/SKILL.md` at `d262ab3882952a59312ff3537cd86d894523c5ab`.
- Decision: vendor the v4.0.1 voice skill only. Output hard gate default ON. Opt-out `EVOLVELOOP_BREVITY_CAVEMAN=off`. `caveman-compress` stays out.
- Exceptions stay verbatim: code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content.
2 changes: 2 additions & 0 deletions .cursor/commands/evolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ Invocação **`/evolve`**.

**HARD-GATE — Grill-me (design/planning):** após `/prd` aprovado, antes de `/planejar` quando Policy exige → `~/.agents/skills/grill-me/SKILL.md` + `grill-me-gate.md` (fail-closed)

**HARD-GATE — Caveman (saída):** default ON em todo agente/worker. Skill vendorizada `vendor/juliusbrussee-caveman/skills/caveman/SKILL.md`. Opt-out `EVOLVELOOP_BREVITY_CAVEMAN=off`. Exceções verbatim. → `~/.cursor/skills/orquestrar/references/caveman-hard-gate.md`

**Legacy:** o nome interno histórico *EvolveLoop* e o comando `/EvolveLoop` são aliases legados — não são a marca pública. O nome interno histórico *MegaBrain* e `/MegaBrain` são aliases legados. Use `/evolve`.
6 changes: 6 additions & 0 deletions .cursor/hooks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"version": 1,
"hooks": {
"sessionStart": [
{
"command": "./hooks/caveman-hard-gate.sh",
"timeout": 15
}
],
"stop": [
{
"command": "./hooks/orchestrator-job-pickup.sh",
Expand Down
24 changes: 24 additions & 0 deletions .cursor/hooks/caveman-hard-gate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# sessionStart — Caveman output hard gate. Default ON.
# Opt-out: EVOLVELOOP_BREVITY_CAVEMAN=off (also 0, false, no).
# Does not rewrite the vendored skill. Does not print secrets.
set -euo pipefail

mode="$(printf '%s' "${EVOLVELOOP_BREVITY_CAVEMAN:-}" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]')"
case "$mode" in
0|false|off|no)
printf '%s\n' '{}'
exit 0
;;
esac

python3 - <<'PY'
import json

text = """Caveman output hard gate: ON.
Follow vendor/juliusbrussee-caveman/skills/caveman/SKILL.md (upstream v4.0.1, d262ab3882952a59312ff3537cd86d894523c5ab). Do not rewrite it. Do not switch to ultracave, megacave, or caveman-compress.
Opt-out: EVOLVELOOP_BREVITY_CAVEMAN=off
Exceptions — never compress or alter: code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content.
"""
print(json.dumps({"additional_context": text}))
PY
20 changes: 20 additions & 0 deletions .cursor/rules/caveman-hard-gate.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
description: Caveman output hard gate for every EvolveLoop agent and worker
alwaysApply: true
---

# Caveman output hard gate

Default ON for every agent and worker in `/evolve`.

Follow the vendored skill. Do not rewrite it. Do not switch to ultracave, megacave, or caveman-compress.

- Skill: `vendor/juliusbrussee-caveman/skills/caveman/SKILL.md`
- Upstream: `https://github.com/juliusbrussee/caveman` tag `v4.0.1` commit `d262ab3882952a59312ff3537cd86d894523c5ab`
- Opt-out: `EVOLVELOOP_BREVITY_CAVEMAN=off` (`0`, `false`, and `no` also disable). Unset means ON.

Exceptions — never compress or alter:

code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content

Security warnings and irreversible confirmations stay full sentences. Structured task-report fields keep their labels and their verbatim values.
11 changes: 11 additions & 0 deletions .cursor/skills/orquestrar/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ Sem excepções por provider/subagente (salvo `skipped_trivial` documentado). Ru

Sem excepções por fase, provider ou subagente.

## HARD-GATE — Caveman (saída)

**Regra:** todo agente e worker do `/evolve` responde no modo **caveman** (voz oficial vendorizada). Default **ON**.

1. Seguir `vendor/juliusbrussee-caveman/skills/caveman/SKILL.md` (bytes upstream, SHA em `PIN.json`). Não reescrever a skill. Não mudar para `ultracave`, `megacave` ou `caveman-compress`.
2. Opt-out do processo: `EVOLVELOOP_BREVITY_CAVEMAN=off` (`0`, `false`, `no` também desligam). Variável ausente = ON.
3. Exceções, verbatim, sem compressão nem alteração: code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content.
4. O bloco entra no prompt de pickup e no `GATE_BUNDLE` (`caveman_output`). O compressor GOAL-009 do briefing **não** é este gate.

Contrato: [references/caveman-hard-gate.md](references/caveman-hard-gate.md).

**Contratos v2.1:** [references/ARCHITECTURAL-PRINCIPLES.md](references/ARCHITECTURAL-PRINCIPLES.md) · [references/contracts/README.md](references/contracts/README.md)

## Ponte Execution Engine (quando `ORCHESTRATOR_ROOT` definido)
Expand Down
40 changes: 40 additions & 0 deletions .cursor/skills/orquestrar/references/caveman-hard-gate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Caveman output hard gate

**Task:** `V22-CAVEMAN-HG-1`
**Default:** ON para todo agente e worker do `/evolve`.
**Opt-out:** `EVOLVELOOP_BREVITY_CAVEMAN=off` (`0`, `false` e `no` também desligam). Variável ausente significa ON.

## O que está ligado

A voz é a skill oficial vendorizada, sem reescrita:

`vendor/juliusbrussee-caveman/skills/caveman/SKILL.md`

Upstream: `https://github.com/juliusbrussee/caveman` tag `v4.0.1`, commit `d262ab3882952a59312ff3537cd86d894523c5ab`. Licença Apache-2.0. `NOTICE` e `LICENSE-MIT` ficam no mesmo diretório porque o `NOTICE` regista contribuições anteriores a 3.0.0 sob MIT. O pin de SHA-256 está em `vendor/juliusbrussee-caveman/PIN.json`.

O modo é `caveman`. `ultracave`, `megacave` e `caveman-compress` não entram neste gate. `caveman-compress` continua fora de contratos, skills de produto e código do orquestrador.

## Onde o gate entra

| Mecanismo | Onde |
|-----------|------|
| Rule `alwaysApply` | `.cursor/rules/caveman-hard-gate.mdc` e, no profile `standard`, `~/.cursor/rules/caveman-hard-gate.mdc` |
| Hook `sessionStart` | `.cursor/hooks/caveman-hard-gate.sh` e o mesmo script no merge de `~/.cursor/hooks.json` |
| Skill link | `agent-setup` faz symlink de `vendor/juliusbrussee-caveman/skills/caveman` para `~/.cursor/skills/caveman` |
| Contrato de prompt | `buildPickupPrompt` insere o bloco antes de `## Briefing`. `GATE_BUNDLE` ganha `caveman_output` |

`EVOLVELOOP_BREVITY_CAVEMAN=on` (explícito) continua a anexar o bench histórico GOAL-009/010 no `run-engine`. A variável ausente liga só o gate de saída. Não liga esse bench, para o JSON do engine não mudar em toda a corrida.

O compressor de briefing (`brevity-caveman.ts`) só corre no braço explícito `{ caveman: true }` do bench GOAL-009, ou quando a variável está explicitamente `on` e o caller é a função de compressão. O pickup por omissão não reescreve o briefing.

## Exceções

Estas classes ficam verbatim. Não se comprimem e não se alteram:

code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content

Avisos de segurança e confirmações irreversíveis ficam em frases completas. Campos estruturados de relatório de task mantêm o rótulo e o valor.

## Medição

A corrida live é fora do CI. O comando está em `docs/v22/CAVEMAN-HARD-GATE.md`.
4 changes: 4 additions & 0 deletions .cursor/skills/orquestrar/references/gate-bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ context_budget:
max_paths: <opcional — default engine 15; PENDING_BASELINE até B1 oficial>
max_pages: <opcional — default 5>
max_tokens: <opcional — default 128000; tokenizer tiktoken:cl100k_base ou PROXY>
caveman_output: on | off
caveman_skill: vendor/juliusbrussee-caveman/skills/caveman/SKILL.md
caveman_opt_out: EVOLVELOOP_BREVITY_CAVEMAN=off
```

### Campos — regras
Expand All @@ -49,6 +52,7 @@ context_budget:
| `image_attachment: true` | Filho visual **obrigado** a `image-to-code` |
| `grill_me_required: true` | Filho `role: plan` **obrigado** a evidência `gate.grill-me.json` `satisfied|exempt` — senão `bloqueado: grill_me_gate` |
| `wiki_register` | Qualquer edit de código no filho → registo wiki (ou handoff explícito ao raiz com lista de paths). **Executor:** `librarian` se spawnado; senão `exec` / raiz. Ver [pda-roles.md](pda-roles.md) |
| `caveman_output` | `on` por omissão. O filho segue a skill vendorizada na prosa e não comprime as exceções. `off` só com `EVOLVELOOP_BREVITY_CAVEMAN=off`. Ver [caveman-hard-gate.md](caveman-hard-gate.md) |

---

Expand Down
2 changes: 2 additions & 0 deletions agent-setup/cursor/commands/evolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ Invocação **`/evolve`**.

**HARD-GATE — Grill-me (design/planning):** após `/prd` aprovado, antes de `/planejar` quando Policy exige → `~/.agents/skills/grill-me/SKILL.md` + `grill-me-gate.md` (fail-closed)

**HARD-GATE — Caveman (saída):** default ON em todo agente/worker. Skill vendorizada `vendor/juliusbrussee-caveman/skills/caveman/SKILL.md`. Opt-out `EVOLVELOOP_BREVITY_CAVEMAN=off`. Exceções verbatim. → `~/.cursor/skills/orquestrar/references/caveman-hard-gate.md`

**Legacy:** o nome interno histórico *EvolveLoop* e o comando `/EvolveLoop` são aliases legados — não são a marca pública. O nome interno histórico *MegaBrain* e `/MegaBrain` são aliases legados. Use `/evolve`.
24 changes: 24 additions & 0 deletions agent-setup/cursor/hooks/caveman-hard-gate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# sessionStart — Caveman output hard gate. Default ON.
# Opt-out: EVOLVELOOP_BREVITY_CAVEMAN=off (also 0, false, no).
# Does not rewrite the vendored skill. Does not print secrets.
set -euo pipefail

mode="$(printf '%s' "${EVOLVELOOP_BREVITY_CAVEMAN:-}" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]')"
case "$mode" in
0|false|off|no)
printf '%s\n' '{}'
exit 0
;;
esac

python3 - <<'PY'
import json

text = """Caveman output hard gate: ON.
Follow vendor/juliusbrussee-caveman/skills/caveman/SKILL.md (upstream v4.0.1, d262ab3882952a59312ff3537cd86d894523c5ab). Do not rewrite it. Do not switch to ultracave, megacave, or caveman-compress.
Opt-out: EVOLVELOOP_BREVITY_CAVEMAN=off
Exceptions — never compress or alter: code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content.
"""
print(json.dumps({"additional_context": text}))
PY
20 changes: 20 additions & 0 deletions agent-setup/cursor/rules/caveman-hard-gate.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
description: Caveman output hard gate for every EvolveLoop agent and worker
alwaysApply: true
---

# Caveman output hard gate

Default ON for every agent and worker in `/evolve`.

Follow the vendored skill. Do not rewrite it. Do not switch to ultracave, megacave, or caveman-compress.

- Skill: `vendor/juliusbrussee-caveman/skills/caveman/SKILL.md`
- Upstream: `https://github.com/juliusbrussee/caveman` tag `v4.0.1` commit `d262ab3882952a59312ff3537cd86d894523c5ab`
- Opt-out: `EVOLVELOOP_BREVITY_CAVEMAN=off` (`0`, `false`, and `no` also disable). Unset means ON.

Exceptions — never compress or alter:

code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content

Security warnings and irreversible confirmations stay full sentences. Structured task-report fields keep their labels and their verbatim values.
4 changes: 2 additions & 2 deletions agent-setup/docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Managed components are listed explicitly in `manifest/components.yaml`.

## Standard

- Skills: `wiki-mem`, `orquestrar` (symlink)
- Hooks: merge into `hooks.json` (wiki-mem only)
- Skills: `wiki-mem`, `orquestrar`, `caveman` (symlink to the vendored voice skill)
- Hooks: merge into `hooks.json` (wiki-mem and the caveman output hard gate)
- Worker skills: PDA roles from CursorSKILLS

## Full
Expand Down
18 changes: 18 additions & 0 deletions agent-setup/manifest/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ rules:
managed_by: agent-setup
profiles: [minimal, standard, full]

- name: caveman-hard-gate
source: bundled:cursor/rules/caveman-hard-gate.mdc
destination: "~/.cursor/rules/caveman-hard-gate.mdc"
scope: global
managed_by: agent-setup
profiles: [minimal, standard, full]

commands:
- name: wiki
source: bundled:cursor/commands/wiki.md
Expand Down Expand Up @@ -71,6 +78,13 @@ skills:
install: symlink
profiles: [standard, full]

- name: caveman
source: repo:${AGENTS_ROOT}/vendor/juliusbrussee-caveman/skills/caveman
destination: "~/.cursor/skills/caveman"
install: symlink
profiles: [standard, full]
also_link: "~/.agents/skills/caveman"

worker_skills:
repo_base: "${AGENTS_ROOT}/.cursor/skills"
names:
Expand All @@ -85,6 +99,9 @@ worker_skills:
- prd
- security
- testing
- agent-authoring
- code-reviewer
- validator
global_skills_base: "${AGENTS_ROOT}/global-skills"
global_names:
- brainstorming
Expand All @@ -99,6 +116,7 @@ hooks:
managed_keys:
sessionStart:
- ./hooks/wiki-mem/session-start.sh
- ./hooks/caveman-hard-gate.sh
afterFileEdit:
- ./hooks/wiki-mem/after-edit.sh
stop:
Expand Down
2 changes: 1 addition & 1 deletion agent-setup/manifest/profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ profiles:
description: minimal + MegaBrain, Wiki memory, hooks
extends: minimal
components:
skills: [wiki, wiki-mem, orquestrar, skill-authoring]
skills: [wiki, wiki-mem, orquestrar, skill-authoring, caveman]
commands: [mem, planejar, testes, validar, seguranca, documentar]
hooks: true
megabrain: true
Expand Down
98 changes: 98 additions & 0 deletions agent-setup/tests/test_caveman_hard_gate_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""Caveman hard gate installs by symlink and a second run does not duplicate it."""

import json
import os
import subprocess
from pathlib import Path

from agent_setup.install import install

REPO = Path(__file__).resolve().parents[2]
HOOK = "caveman-hard-gate.sh"
EXCEPTION_LINE = (
"code, commands, paths, evidence, SHAs, commit messages, user docs, "
"task reports (structured fields), security content"
)


def _isolate_home(monkeypatch, home: Path) -> None:
home.mkdir(parents=True, exist_ok=True)
monkeypatch.setenv("HOME", str(home))
monkeypatch.setenv("AGENTS_ROOT", str(REPO))
for key in ("WIKI_ROOT", "VAULT_ROOT", "RAG_REPO_ROOT"):
monkeypatch.delenv(key, raising=False)


def _run_hook(value: str | None) -> dict:
env = os.environ.copy()
script = REPO / "agent-setup" / "cursor" / "hooks" / HOOK
if value is None:
env.pop("EVOLVELOOP_BREVITY_CAVEMAN", None)
else:
env["EVOLVELOOP_BREVITY_CAVEMAN"] = value
proc = subprocess.run(
["bash", str(script)],
check=True,
capture_output=True,
text=True,
env=env,
)
return json.loads(proc.stdout)


def test_hook_default_on_and_opt_out():
on = _run_hook(None)
assert EXCEPTION_LINE in on["additional_context"]
assert "EVOLVELOOP_BREVITY_CAVEMAN=off" in on["additional_context"]
assert _run_hook("off") == {}
assert _run_hook("OFF") == {}
assert _run_hook("0") == {}
explicit = _run_hook("on")
assert "additional_context" in explicit


def test_repo_copies_match():
for rel in (
Path("hooks") / HOOK,
Path("rules") / "caveman-hard-gate.mdc",
):
project = (REPO / ".cursor" / rel).read_bytes()
bundled = (REPO / "agent-setup" / "cursor" / rel).read_bytes()
assert project == bundled
assert EXCEPTION_LINE.encode() in (REPO / ".cursor" / "rules" / "caveman-hard-gate.mdc").read_bytes()


def test_install_caveman_gate_is_idempotent(tmp_path: Path, monkeypatch):
home = tmp_path / "home"
_isolate_home(monkeypatch, home)

first = install(profile="standard")
assert first.errors == []
assert first.conflicts == []

skill = home / ".cursor" / "skills" / "caveman"
assert skill.is_symlink()
assert skill.resolve() == (REPO / "vendor" / "juliusbrussee-caveman" / "skills" / "caveman").resolve()
assert (skill / "SKILL.md").is_file()

rule = home / ".cursor" / "rules" / "caveman-hard-gate.mdc"
assert rule.is_file()
assert "EVOLVELOOP_BREVITY_CAVEMAN=off" in rule.read_text(encoding="utf-8")

for name in ("agent-authoring", "code-reviewer", "validator", "testing", "orquestrar"):
link = home / ".cursor" / "skills" / name
assert link.is_symlink(), name

hooks = json.loads((home / ".cursor" / "hooks.json").read_text(encoding="utf-8"))
commands = [entry.get("command") for entry in hooks["hooks"]["sessionStart"]]
assert commands.count(f"./hooks/{HOOK}") == 1
assert (home / ".cursor" / "hooks" / HOOK).is_file()

second = install(profile="standard")
assert second.errors == []
assert second.conflicts == []
assert "skill:caveman (already configured)" in second.skipped
assert "rule:caveman-hard-gate (already configured)" in second.skipped
hooks_again = json.loads((home / ".cursor" / "hooks.json").read_text(encoding="utf-8"))
commands_again = [entry.get("command") for entry in hooks_again["hooks"]["sessionStart"]]
assert commands_again.count(f"./hooks/{HOOK}") == 1
Loading
Loading