diff --git a/.agent_history.md b/.agent_history.md new file mode 100644 index 00000000..a50e5ab4 --- /dev/null +++ b/.agent_history.md @@ -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. diff --git a/.ai/log.md b/.ai/log.md index 35735b4a..ee0b620e 100644 --- a/.ai/log.md +++ b/.ai/log.md @@ -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. diff --git a/.cursor/commands/evolve.md b/.cursor/commands/evolve.md index eeb3a4ac..67900b1f 100644 --- a/.cursor/commands/evolve.md +++ b/.cursor/commands/evolve.md @@ -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`. diff --git a/.cursor/hooks.json b/.cursor/hooks.json index bf32a93f..dee4f7dc 100644 --- a/.cursor/hooks.json +++ b/.cursor/hooks.json @@ -1,6 +1,12 @@ { "version": 1, "hooks": { + "sessionStart": [ + { + "command": "./hooks/caveman-hard-gate.sh", + "timeout": 15 + } + ], "stop": [ { "command": "./hooks/orchestrator-job-pickup.sh", diff --git a/.cursor/hooks/caveman-hard-gate.sh b/.cursor/hooks/caveman-hard-gate.sh new file mode 100755 index 00000000..1ad50580 --- /dev/null +++ b/.cursor/hooks/caveman-hard-gate.sh @@ -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 diff --git a/.cursor/rules/caveman-hard-gate.mdc b/.cursor/rules/caveman-hard-gate.mdc new file mode 100644 index 00000000..34747514 --- /dev/null +++ b/.cursor/rules/caveman-hard-gate.mdc @@ -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. diff --git a/.cursor/skills/orquestrar/SKILL.md b/.cursor/skills/orquestrar/SKILL.md index 6e1779c0..8a2f615e 100644 --- a/.cursor/skills/orquestrar/SKILL.md +++ b/.cursor/skills/orquestrar/SKILL.md @@ -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) diff --git a/.cursor/skills/orquestrar/references/caveman-hard-gate.md b/.cursor/skills/orquestrar/references/caveman-hard-gate.md new file mode 100644 index 00000000..d068fbfd --- /dev/null +++ b/.cursor/skills/orquestrar/references/caveman-hard-gate.md @@ -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`. diff --git a/.cursor/skills/orquestrar/references/gate-bundle.md b/.cursor/skills/orquestrar/references/gate-bundle.md index 632c8503..51d1309b 100644 --- a/.cursor/skills/orquestrar/references/gate-bundle.md +++ b/.cursor/skills/orquestrar/references/gate-bundle.md @@ -37,6 +37,9 @@ context_budget: max_paths: max_pages: max_tokens: +caveman_output: on | off +caveman_skill: vendor/juliusbrussee-caveman/skills/caveman/SKILL.md +caveman_opt_out: EVOLVELOOP_BREVITY_CAVEMAN=off ``` ### Campos — regras @@ -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) | --- diff --git a/agent-setup/cursor/commands/evolve.md b/agent-setup/cursor/commands/evolve.md index eeb3a4ac..67900b1f 100644 --- a/agent-setup/cursor/commands/evolve.md +++ b/agent-setup/cursor/commands/evolve.md @@ -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`. diff --git a/agent-setup/cursor/hooks/caveman-hard-gate.sh b/agent-setup/cursor/hooks/caveman-hard-gate.sh new file mode 100755 index 00000000..1ad50580 --- /dev/null +++ b/agent-setup/cursor/hooks/caveman-hard-gate.sh @@ -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 diff --git a/agent-setup/cursor/rules/caveman-hard-gate.mdc b/agent-setup/cursor/rules/caveman-hard-gate.mdc new file mode 100644 index 00000000..34747514 --- /dev/null +++ b/agent-setup/cursor/rules/caveman-hard-gate.mdc @@ -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. diff --git a/agent-setup/docs/components.md b/agent-setup/docs/components.md index 0b107f5c..a2757f12 100644 --- a/agent-setup/docs/components.md +++ b/agent-setup/docs/components.md @@ -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 diff --git a/agent-setup/manifest/components.yaml b/agent-setup/manifest/components.yaml index 563cbb42..17e059ff 100644 --- a/agent-setup/manifest/components.yaml +++ b/agent-setup/manifest/components.yaml @@ -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 @@ -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: @@ -85,6 +99,9 @@ worker_skills: - prd - security - testing + - agent-authoring + - code-reviewer + - validator global_skills_base: "${AGENTS_ROOT}/global-skills" global_names: - brainstorming @@ -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: diff --git a/agent-setup/manifest/profiles.yaml b/agent-setup/manifest/profiles.yaml index 05827253..4fa22fec 100644 --- a/agent-setup/manifest/profiles.yaml +++ b/agent-setup/manifest/profiles.yaml @@ -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 diff --git a/agent-setup/tests/test_caveman_hard_gate_install.py b/agent-setup/tests/test_caveman_hard_gate_install.py new file mode 100644 index 00000000..23ecb656 --- /dev/null +++ b/agent-setup/tests/test_caveman_hard_gate_install.py @@ -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 diff --git a/docs/v22/CAVEMAN-HARD-GATE.md b/docs/v22/CAVEMAN-HARD-GATE.md new file mode 100644 index 00000000..6ceb49da --- /dev/null +++ b/docs/v22/CAVEMAN-HARD-GATE.md @@ -0,0 +1,52 @@ +# V22-CAVEMAN-HG-1 — Caveman como hard gate de saída + +A voz oficial do Caveman passa a ser o default de todo agente e worker do `/evolve`. A skill vendorizada não foi reescrita. + +| Campo | Valor | +|-------|--------| +| Upstream | https://github.com/juliusbrussee/caveman | +| Tag | `v4.0.1` | +| Commit | `d262ab3882952a59312ff3537cd86d894523c5ab` | +| Licença | Apache-2.0 (`vendor/juliusbrussee-caveman/LICENSE`) | +| Skill | `vendor/juliusbrussee-caveman/skills/caveman/SKILL.md` | +| Pin | `vendor/juliusbrussee-caveman/PIN.json` | + +`NOTICE` e `LICENSE-MIT` acompanham a cópia. O `NOTICE` upstream regista que contribuições anteriores a 3.0.0, fora do runtime Engine, entraram sob MIT. Esse `NOTICE` contém a palavra `truncated`. O `rg` da tarefa congelada `curta` (padrão `truncate`) passa a ver o ficheiro. Os relatórios P0 de baseline, handoff e compactação foram regenerados por isso e pelo bloco de gate no prompt de pickup. + +O modo ligado é `caveman` (a voz). Não se instala `ultracave`, `megacave` nem `caveman-compress`. Compressão de ficheiro continua fora de contrato. + +## Opt-out + +```bash +EVOLVELOOP_BREVITY_CAVEMAN=off +``` + +`0`, `false` e `no` também desligam. Variável ausente, vazia, ou `on` / `true` / `1` / `yes` ligam o gate de saída. + +Com o gate ligado, o prompt de pickup inclui a skill upstream antes do briefing. Código, comandos, paths, evidência, SHAs, mensagens de commit, docs de usuário, campos estruturados de relatório de task e conteúdo de segurança não são reescritos por esse gate. + +`EVOLVELOOP_BREVITY_CAVEMAN=on` explícito também pede ao `run-engine` o bench histórico GOAL-009/010. A variável ausente não pede esse bench. O compressor de briefing desse bench não é o hard gate. + +## Medição (corre fora desta VM) + +Seis tarefas congeladas (`curta`, `projeto_grande`, `retomada`, `delegada`, `fontes_conflitantes`, `restricoes_compactacao_handoff`), dois braços (caveman OFF e ON), `N=5`. São 60 chamadas. O provider é `cursor-agent`. O tamanho da saída é tiktoken `cl100k_base` sobre o texto `result`. A latência é `duration_ms`. A qualidade é a fração de âncoras e restrições do cartão presentes na resposta. Tokens e custo do provider ficam `NOT_MEASURED`: o schema oficial do CLI não os publica. A chave não entra no argv nem no relatório. + +Dry-run, sem chave e sem gasto: + +```bash +cd orchestrator && npm ci && npm run v22:caveman-measure -- --provider cursor-agent --dry-run --n 5 +``` + +Corrida real: + +```bash +cd orchestrator && npm ci && CURSOR_API_KEY="$CURSOR_API_KEY" npm run v22:caveman-measure -- --provider cursor-agent --n 5 +``` + +Se o binário local se chama `agent`: + +```bash +cd orchestrator && npm ci && CURSOR_API_KEY="$CURSOR_API_KEY" CURSOR_AGENT_BIN=agent npm run v22:caveman-measure -- --provider cursor-agent --n 5 +``` + +O relatório fica em `docs/v22/baseline/raw/caveman-hg-report.json`. diff --git a/docs/v22/baseline/raw/p0-baseline-report.json b/docs/v22/baseline/raw/p0-baseline-report.json index fee293b0..b0297bb3 100644 --- a/docs/v22/baseline/raw/p0-baseline-report.json +++ b/docs/v22/baseline/raw/p0-baseline-report.json @@ -8,7 +8,7 @@ "ollama_hybrid": "NOT_MEASURED", "model_id": "deterministic-provider", "tokenizer": "tiktoken:cl100k_base", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "n": 3, "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tasks_sha256": "eaff6a1b2a3af5b6e8c03cbb778e19840dec4b54c7b25e31763b26326f13f8c1", @@ -20,7 +20,7 @@ "canonical_max_input_tokens": 22000, "dispersion_declaration": "zero_expected_deterministic_for_input_tokens", "path_normalization": "stable_relative", - "measured_at": "2026-10-24T00:47:42.899Z", + "measured_at": "2026-10-24T01:37:14.065Z", "compaction_contract": { "status": "UNAVAILABLE", "fidelity": "UNAVAILABLE", @@ -47,7 +47,7 @@ "quality_b0": 1, "quality_v22": 1, "quality_v22_gte_b0": true, - "raw_input_delta": -114746, + "raw_input_delta": -114875, "savings_counted": true, "deterministic_context_savings_status": "PASS", "deterministic_context_evidence_class": "MEASURED_DETERMINISTIC_CONTEXT", @@ -57,9 +57,9 @@ "arm": "B0", "role": "V2", "evidence_class": "OFFICIAL_BASELINE", - "input_tokens": 136657, + "input_tokens": 138217, "input_tokens_status": "PASS", - "retrieval_input_tokens": 136657, + "retrieval_input_tokens": 138217, "output_tokens": "NOT_MEASURED", "output_tokens_status": "NOT_MEASURED", "cache_read_tokens": "NOT_MEASURED", @@ -68,7 +68,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 274.38210399999997, + "latency_ms": 381.24091566666635, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -91,7 +91,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 5.174744816849222, + "value": 32.53166142395323, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -106,7 +106,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, @@ -128,6 +128,7 @@ "docs/research/targets/external/aider/MECHANISMS.yaml", "docs/research/targets/external/aider/REPORT.md", "docs/research/targets/external/codex/REPORT.md", + "docs/v22/CAVEMAN-HARD-GATE.md", "fixtures/evolveloop-wiki-vault/projects/evolveloop/pages/knowledge-hit-excerpt-cap.md", "global-skills/subagent-driven-development/SKILL.md", "global-skills/ui-ux-pro-max/SKILL.md", @@ -143,14 +144,15 @@ "orchestrator/src/providers/deterministic/git.ts", "orchestrator/src/providers/deterministic/shell.ts", "orchestrator/src/providers/deterministic/system.ts", - "orchestrator/tests/unit/checkpoint-integrity.test.ts" + "orchestrator/tests/unit/checkpoint-integrity.test.ts", + "vendor/juliusbrussee-caveman/NOTICE" ], "runs": [ { "repetition": 1, - "input_tokens": 136657, - "retrieval_input_tokens": 136657, - "latency_ms": 268.95166600000005, + "input_tokens": 138217, + "retrieval_input_tokens": 138217, + "latency_ms": 418.06854899999985, "reread_count": 0, "paths_read": [ "docs/architecture/v2.2/EVOLVELOOP_V2.2_GOALS.md", @@ -168,6 +170,7 @@ "docs/research/targets/external/aider/MECHANISMS.yaml", "docs/research/targets/external/aider/REPORT.md", "docs/research/targets/external/codex/REPORT.md", + "docs/v22/CAVEMAN-HARD-GATE.md", "fixtures/evolveloop-wiki-vault/projects/evolveloop/pages/knowledge-hit-excerpt-cap.md", "global-skills/subagent-driven-development/SKILL.md", "global-skills/ui-ux-pro-max/SKILL.md", @@ -183,7 +186,8 @@ "orchestrator/src/providers/deterministic/git.ts", "orchestrator/src/providers/deterministic/shell.ts", "orchestrator/src/providers/deterministic/system.ts", - "orchestrator/tests/unit/checkpoint-integrity.test.ts" + "orchestrator/tests/unit/checkpoint-integrity.test.ts", + "vendor/juliusbrussee-caveman/NOTICE" ], "quality": 1, "quality_checks": [ @@ -197,9 +201,9 @@ }, { "repetition": 2, - "input_tokens": 136657, - "retrieval_input_tokens": 136657, - "latency_ms": 274.9384479999999, + "input_tokens": 138217, + "retrieval_input_tokens": 138217, + "latency_ms": 356.4159319999999, "reread_count": 0, "paths_read": [ "docs/architecture/v2.2/EVOLVELOOP_V2.2_GOALS.md", @@ -217,6 +221,7 @@ "docs/research/targets/external/aider/MECHANISMS.yaml", "docs/research/targets/external/aider/REPORT.md", "docs/research/targets/external/codex/REPORT.md", + "docs/v22/CAVEMAN-HARD-GATE.md", "fixtures/evolveloop-wiki-vault/projects/evolveloop/pages/knowledge-hit-excerpt-cap.md", "global-skills/subagent-driven-development/SKILL.md", "global-skills/ui-ux-pro-max/SKILL.md", @@ -232,7 +237,8 @@ "orchestrator/src/providers/deterministic/git.ts", "orchestrator/src/providers/deterministic/shell.ts", "orchestrator/src/providers/deterministic/system.ts", - "orchestrator/tests/unit/checkpoint-integrity.test.ts" + "orchestrator/tests/unit/checkpoint-integrity.test.ts", + "vendor/juliusbrussee-caveman/NOTICE" ], "quality": 1, "quality_checks": [ @@ -246,9 +252,9 @@ }, { "repetition": 3, - "input_tokens": 136657, - "retrieval_input_tokens": 136657, - "latency_ms": 279.25619800000004, + "input_tokens": 138217, + "retrieval_input_tokens": 138217, + "latency_ms": 369.2382659999994, "reread_count": 0, "paths_read": [ "docs/architecture/v2.2/EVOLVELOOP_V2.2_GOALS.md", @@ -266,6 +272,7 @@ "docs/research/targets/external/aider/MECHANISMS.yaml", "docs/research/targets/external/aider/REPORT.md", "docs/research/targets/external/codex/REPORT.md", + "docs/v22/CAVEMAN-HARD-GATE.md", "fixtures/evolveloop-wiki-vault/projects/evolveloop/pages/knowledge-hit-excerpt-cap.md", "global-skills/subagent-driven-development/SKILL.md", "global-skills/ui-ux-pro-max/SKILL.md", @@ -281,7 +288,8 @@ "orchestrator/src/providers/deterministic/git.ts", "orchestrator/src/providers/deterministic/shell.ts", "orchestrator/src/providers/deterministic/system.ts", - "orchestrator/tests/unit/checkpoint-integrity.test.ts" + "orchestrator/tests/unit/checkpoint-integrity.test.ts", + "vendor/juliusbrussee-caveman/NOTICE" ], "quality": 1, "quality_checks": [ @@ -299,9 +307,9 @@ "arm": "V2.2", "role": "V2.2", "evidence_class": "PROJECT_WIKI_PICKUP_BUDGET", - "input_tokens": 21911, + "input_tokens": 23342, "input_tokens_status": "PASS", - "retrieval_input_tokens": 21293, + "retrieval_input_tokens": 21299, "output_tokens": "NOT_MEASURED", "output_tokens_status": "NOT_MEASURED", "cache_read_tokens": "NOT_MEASURED", @@ -310,7 +318,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 1419.9934396666667, + "latency_ms": 1421.4936670000004, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -333,7 +341,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 92.95347521488921, + "value": 245.99346009251832, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -348,7 +356,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, @@ -375,9 +383,9 @@ "runs": [ { "repetition": 1, - "input_tokens": 21911, - "retrieval_input_tokens": 21293, - "latency_ms": 1510.370903, + "input_tokens": 23342, + "retrieval_input_tokens": 21299, + "latency_ms": 1703.9809819999998, "reread_count": 0, "paths_read": [ "orchestrator/src/providers/deterministic/paths.ts", @@ -409,9 +417,9 @@ }, { "repetition": 2, - "input_tokens": 21911, - "retrieval_input_tokens": 21293, - "latency_ms": 1424.947346, + "input_tokens": 23342, + "retrieval_input_tokens": 21299, + "latency_ms": 1254.4920970000003, "reread_count": 0, "paths_read": [ "orchestrator/src/providers/deterministic/paths.ts", @@ -443,9 +451,9 @@ }, { "repetition": 3, - "input_tokens": 21911, - "retrieval_input_tokens": 21293, - "latency_ms": 1324.6620700000003, + "input_tokens": 23342, + "retrieval_input_tokens": 21299, + "latency_ms": 1306.0079220000007, "reread_count": 0, "paths_read": [ "orchestrator/src/providers/deterministic/paths.ts", @@ -492,7 +500,7 @@ "quality_b0": 0, "quality_v22": 1, "quality_v22_gte_b0": true, - "raw_input_delta": -59429, + "raw_input_delta": -58004, "savings_counted": true, "deterministic_context_savings_status": "PASS", "deterministic_context_evidence_class": "MEASURED_DETERMINISTIC_CONTEXT", @@ -513,7 +521,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 258.1391909999996, + "latency_ms": 359.4575509999989, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -536,7 +544,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 4.4700228731685705, + "value": 42.125957537841906, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -551,7 +559,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 0, @@ -609,7 +617,7 @@ "repetition": 1, "input_tokens": 81430, "retrieval_input_tokens": 81430, - "latency_ms": 263.27845200000047, + "latency_ms": 403.65905199999906, "reread_count": 0, "paths_read": [ "CHANGELOG.md", @@ -673,7 +681,7 @@ "repetition": 2, "input_tokens": 81430, "retrieval_input_tokens": 81430, - "latency_ms": 255.9844119999998, + "latency_ms": 354.9427829999986, "reread_count": 0, "paths_read": [ "CHANGELOG.md", @@ -737,7 +745,7 @@ "repetition": 3, "input_tokens": 81430, "retrieval_input_tokens": 81430, - "latency_ms": 255.15470899999855, + "latency_ms": 319.77081799999905, "reread_count": 0, "paths_read": [ "CHANGELOG.md", @@ -803,7 +811,7 @@ "arm": "V2.2", "role": "V2.2", "evidence_class": "PROJECT_WIKI_PICKUP_BUDGET", - "input_tokens": 22001, + "input_tokens": 23426, "input_tokens_status": "PASS", "retrieval_input_tokens": 21342, "output_tokens": "NOT_MEASURED", @@ -814,7 +822,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 1291.3701389999994, + "latency_ms": 1387.7495516666659, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -837,7 +845,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 15.493626537089742, + "value": 151.54299082981973, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -852,7 +860,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, @@ -875,9 +883,9 @@ "runs": [ { "repetition": 1, - "input_tokens": 22001, + "input_tokens": 23426, "retrieval_input_tokens": 21342, - "latency_ms": 1288.8005009999997, + "latency_ms": 1432.1934459999993, "reread_count": 0, "paths_read": [ "docs/reconciliation/runtime-sync/backup/jobs.AG.reference/checkpoint.ts", @@ -905,9 +913,9 @@ }, { "repetition": 2, - "input_tokens": 22001, + "input_tokens": 23426, "retrieval_input_tokens": 21342, - "latency_ms": 1277.3219809999991, + "latency_ms": 1218.953959999999, "reread_count": 0, "paths_read": [ "docs/reconciliation/runtime-sync/backup/jobs.AG.reference/checkpoint.ts", @@ -935,9 +943,9 @@ }, { "repetition": 3, - "input_tokens": 22001, + "input_tokens": 23426, "retrieval_input_tokens": 21342, - "latency_ms": 1307.9879349999992, + "latency_ms": 1512.1012489999994, "reread_count": 0, "paths_read": [ "docs/reconciliation/runtime-sync/backup/jobs.AG.reference/checkpoint.ts", @@ -980,7 +988,7 @@ "quality_b0": 1, "quality_v22": 1, "quality_v22_gte_b0": true, - "raw_input_delta": -8495, + "raw_input_delta": -6962, "savings_counted": true, "deterministic_context_savings_status": "PASS", "deterministic_context_evidence_class": "MEASURED_DETERMINISTIC_CONTEXT", @@ -1001,7 +1009,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 254.57402566666556, + "latency_ms": 395.0101503333329, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -1024,7 +1032,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 15.231159210772347, + "value": 139.25987414539733, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -1039,7 +1047,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, @@ -1060,7 +1068,7 @@ "repetition": 1, "input_tokens": 30414, "retrieval_input_tokens": 30414, - "latency_ms": 237.40686499999902, + "latency_ms": 555.7813229999992, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -1090,7 +1098,7 @@ "repetition": 2, "input_tokens": 30414, "retrieval_input_tokens": 30414, - "latency_ms": 266.46738800000094, + "latency_ms": 311.83438899999965, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -1120,7 +1128,7 @@ "repetition": 3, "input_tokens": 30414, "retrieval_input_tokens": 30414, - "latency_ms": 259.84782399999676, + "latency_ms": 317.4147389999998, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -1152,9 +1160,9 @@ "arm": "V2.2", "role": "V2.2", "evidence_class": "PROJECT_WIKI_PICKUP_BUDGET", - "input_tokens": 21919, + "input_tokens": 23452, "input_tokens_status": "PASS", - "retrieval_input_tokens": 21288, + "retrieval_input_tokens": 21396, "output_tokens": "NOT_MEASURED", "output_tokens_status": "NOT_MEASURED", "cache_read_tokens": "NOT_MEASURED", @@ -1163,7 +1171,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 1256.346773, + "latency_ms": 1386.4189146666674, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -1186,7 +1194,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 29.043519601788198, + "value": 167.84049252082022, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -1201,7 +1209,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, @@ -1234,9 +1242,9 @@ "runs": [ { "repetition": 1, - "input_tokens": 21919, - "retrieval_input_tokens": 21288, - "latency_ms": 1288.315466, + "input_tokens": 23452, + "retrieval_input_tokens": 21396, + "latency_ms": 1444.5901540000013, "reread_count": 0, "paths_read": [ "orchestrator/contracts/context-grounding.yaml", @@ -1278,9 +1286,9 @@ }, { "repetition": 2, - "input_tokens": 21919, - "retrieval_input_tokens": 21288, - "latency_ms": 1231.585865000001, + "input_tokens": 23452, + "retrieval_input_tokens": 21396, + "latency_ms": 1517.4348600000012, "reread_count": 0, "paths_read": [ "orchestrator/contracts/context-grounding.yaml", @@ -1322,9 +1330,9 @@ }, { "repetition": 3, - "input_tokens": 21919, - "retrieval_input_tokens": 21288, - "latency_ms": 1249.1389879999988, + "input_tokens": 23452, + "retrieval_input_tokens": 21396, + "latency_ms": 1197.2317299999995, "reread_count": 0, "paths_read": [ "orchestrator/contracts/context-grounding.yaml", @@ -1381,7 +1389,7 @@ "quality_b0": 0, "quality_v22": 1, "quality_v22_gte_b0": true, - "raw_input_delta": -65478, + "raw_input_delta": -64356, "savings_counted": true, "deterministic_context_savings_status": "PASS", "deterministic_context_evidence_class": "MEASURED_DETERMINISTIC_CONTEXT", @@ -1391,9 +1399,9 @@ "arm": "B0", "role": "V2", "evidence_class": "OFFICIAL_BASELINE", - "input_tokens": 87474, + "input_tokens": 87671, "input_tokens_status": "PASS", - "retrieval_input_tokens": 87474, + "retrieval_input_tokens": 87671, "output_tokens": "NOT_MEASURED", "output_tokens_status": "NOT_MEASURED", "cache_read_tokens": "NOT_MEASURED", @@ -1402,7 +1410,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 265.65313400000014, + "latency_ms": 344.0621943333329, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -1425,7 +1433,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 5.876737034233525, + "value": 8.082855530600497, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -1440,7 +1448,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 0, @@ -1482,9 +1490,9 @@ "runs": [ { "repetition": 1, - "input_tokens": 87474, - "retrieval_input_tokens": 87474, - "latency_ms": 265.9147950000006, + "input_tokens": 87671, + "retrieval_input_tokens": 87671, + "latency_ms": 349.6583759999994, "reread_count": 0, "paths_read": [ "agent-setup/cursor/commands/evolve.md", @@ -1537,9 +1545,9 @@ }, { "repetition": 2, - "input_tokens": 87474, - "retrieval_input_tokens": 87474, - "latency_ms": 271.3946700000015, + "input_tokens": 87671, + "retrieval_input_tokens": 87671, + "latency_ms": 334.79536200000075, "reread_count": 0, "paths_read": [ "agent-setup/cursor/commands/evolve.md", @@ -1592,9 +1600,9 @@ }, { "repetition": 3, - "input_tokens": 87474, - "retrieval_input_tokens": 87474, - "latency_ms": 259.6499369999983, + "input_tokens": 87671, + "retrieval_input_tokens": 87671, + "latency_ms": 347.73284499999863, "reread_count": 0, "paths_read": [ "agent-setup/cursor/commands/evolve.md", @@ -1651,9 +1659,9 @@ "arm": "V2.2", "role": "V2.2", "evidence_class": "PROJECT_WIKI_PICKUP_BUDGET", - "input_tokens": 21996, + "input_tokens": 23315, "input_tokens_status": "PASS", - "retrieval_input_tokens": 21354, + "retrieval_input_tokens": 21248, "output_tokens": "NOT_MEASURED", "output_tokens_status": "NOT_MEASURED", "cache_read_tokens": "NOT_MEASURED", @@ -1662,7 +1670,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 1239.8909350000006, + "latency_ms": 1298.2702853333321, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -1685,7 +1693,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 29.82995859093273, + "value": 158.9944991912447, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -1700,14 +1708,13 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, "quality_status": "PASS", "verifier_pass": true, "paths_read": [ - "Agents/Adr.md", "docs/internal/historical/evals/docs-evals/experiments/E-001/raw/enablement/catalog-inventory.json", "orchestrator/src/v22/bench-r-tasks.ts", "docs/research/targets/local/agency-agents/REPORT.md", @@ -1728,12 +1735,11 @@ "runs": [ { "repetition": 1, - "input_tokens": 21996, - "retrieval_input_tokens": 21354, - "latency_ms": 1210.0989120000013, + "input_tokens": 23315, + "retrieval_input_tokens": 21248, + "latency_ms": 1186.4731809999976, "reread_count": 0, "paths_read": [ - "Agents/Adr.md", "docs/internal/historical/evals/docs-evals/experiments/E-001/raw/enablement/catalog-inventory.json", "orchestrator/src/v22/bench-r-tasks.ts", "docs/research/targets/local/agency-agents/REPORT.md", @@ -1767,12 +1773,11 @@ }, { "repetition": 2, - "input_tokens": 21996, - "retrieval_input_tokens": 21354, - "latency_ms": 1269.7586850000007, + "input_tokens": 23315, + "retrieval_input_tokens": 21248, + "latency_ms": 1228.0525960000014, "reread_count": 0, "paths_read": [ - "Agents/Adr.md", "docs/internal/historical/evals/docs-evals/experiments/E-001/raw/enablement/catalog-inventory.json", "orchestrator/src/v22/bench-r-tasks.ts", "docs/research/targets/local/agency-agents/REPORT.md", @@ -1806,12 +1811,11 @@ }, { "repetition": 3, - "input_tokens": 21996, - "retrieval_input_tokens": 21354, - "latency_ms": 1239.815208, + "input_tokens": 23315, + "retrieval_input_tokens": 21248, + "latency_ms": 1480.2850789999975, "reread_count": 0, "paths_read": [ - "Agents/Adr.md", "docs/internal/historical/evals/docs-evals/experiments/E-001/raw/enablement/catalog-inventory.json", "orchestrator/src/v22/bench-r-tasks.ts", "docs/research/targets/local/agency-agents/REPORT.md", @@ -1860,7 +1864,7 @@ "quality_b0": 0.6666666666666666, "quality_v22": 1, "quality_v22_gte_b0": true, - "raw_input_delta": -25935, + "raw_input_delta": -24510, "savings_counted": true, "deterministic_context_savings_status": "PASS", "deterministic_context_evidence_class": "MEASURED_DETERMINISTIC_CONTEXT", @@ -1881,7 +1885,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 240.87307433333385, + "latency_ms": 335.35745099999986, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -1904,7 +1908,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 10.859714549530388, + "value": 18.870982441359995, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -1919,7 +1923,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 0.6666666666666666, @@ -1977,7 +1981,7 @@ "repetition": 1, "input_tokens": 48021, "retrieval_input_tokens": 48021, - "latency_ms": 242.78598799999963, + "latency_ms": 349.3426440000003, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -2049,7 +2053,7 @@ "repetition": 2, "input_tokens": 48021, "retrieval_input_tokens": 48021, - "latency_ms": 229.18400499999916, + "latency_ms": 313.893339000002, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -2121,7 +2125,7 @@ "repetition": 3, "input_tokens": 48021, "retrieval_input_tokens": 48021, - "latency_ms": 250.64923000000272, + "latency_ms": 342.83636999999726, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -2195,7 +2199,7 @@ "arm": "V2.2", "role": "V2.2", "evidence_class": "PROJECT_WIKI_PICKUP_BUDGET", - "input_tokens": 22086, + "input_tokens": 23511, "input_tokens_status": "PASS", "retrieval_input_tokens": 21415, "output_tokens": "NOT_MEASURED", @@ -2206,7 +2210,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 1437.1242563333337, + "latency_ms": 1590.5675536666665, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -2229,7 +2233,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 18.532108494304833, + "value": 156.9345411983516, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -2244,7 +2248,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, @@ -2280,9 +2284,9 @@ "runs": [ { "repetition": 1, - "input_tokens": 22086, + "input_tokens": 23511, "retrieval_input_tokens": 21415, - "latency_ms": 1418.8906380000008, + "latency_ms": 1762.5953859999972, "reread_count": 0, "paths_read": [ "docs/architecture/finalization/PROTOTYPE-HARDENING-REPORT.md", @@ -2333,9 +2337,9 @@ }, { "repetition": 2, - "input_tokens": 22086, + "input_tokens": 23511, "retrieval_input_tokens": 21415, - "latency_ms": 1436.5410440000014, + "latency_ms": 1455.2254620000022, "reread_count": 0, "paths_read": [ "docs/architecture/finalization/PROTOTYPE-HARDENING-REPORT.md", @@ -2386,9 +2390,9 @@ }, { "repetition": 3, - "input_tokens": 22086, + "input_tokens": 23511, "retrieval_input_tokens": 21415, - "latency_ms": 1455.9410869999992, + "latency_ms": 1553.881813, "reread_count": 0, "paths_read": [ "docs/architecture/finalization/PROTOTYPE-HARDENING-REPORT.md", @@ -2454,7 +2458,7 @@ "quality_b0": 0.6666666666666666, "quality_v22": 1, "quality_v22_gte_b0": true, - "raw_input_delta": -27843, + "raw_input_delta": -26418, "savings_counted": true, "deterministic_context_savings_status": "PASS", "deterministic_context_evidence_class": "MEASURED_DETERMINISTIC_CONTEXT", @@ -2487,7 +2491,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 252.78726766666418, + "latency_ms": 339.39198399999924, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -2510,7 +2514,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 7.3004327964856595, + "value": 30.328100964816247, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -2525,7 +2529,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 0.6666666666666666, @@ -2583,7 +2587,7 @@ "repetition": 1, "input_tokens": 49897, "retrieval_input_tokens": 49897, - "latency_ms": 249.3047829999996, + "latency_ms": 323.6793980000002, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -2655,7 +2659,7 @@ "repetition": 2, "input_tokens": 49897, "retrieval_input_tokens": 49897, - "latency_ms": 247.88016099999368, + "latency_ms": 320.1442240000033, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -2727,7 +2731,7 @@ "repetition": 3, "input_tokens": 49897, "retrieval_input_tokens": 49897, - "latency_ms": 261.17685899999924, + "latency_ms": 374.35232999999425, "reread_count": 0, "paths_read": [ "docs/adr/0013-context-ownership-working-context.md", @@ -2801,7 +2805,7 @@ "arm": "V2.2", "role": "V2.2", "evidence_class": "PROJECT_WIKI_PICKUP_BUDGET", - "input_tokens": 22054, + "input_tokens": 23479, "input_tokens_status": "PASS", "retrieval_input_tokens": 21333, "output_tokens": "NOT_MEASURED", @@ -2812,7 +2816,7 @@ "cache_write_tokens_status": "NOT_MEASURED", "cost": "NOT_MEASURED", "cost_status": "NOT_MEASURED", - "latency_ms": 1274.9434766666661, + "latency_ms": 1096.4895683333307, "latency_ms_status": "LIMITED", "latency_kind": "retrieval", "model_latency_ms": "NOT_MEASURED", @@ -2835,7 +2839,7 @@ "cost": "NOT_MEASURED", "latency_ms": { "statistic": "sample_stddev", - "value": 58.79586357040899, + "value": 43.774725087774286, "n": 3, "expectation": "retrieval_io_jitter", "status": "PASS" @@ -2850,7 +2854,7 @@ "model": "NOT_MEASURED" }, "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "ec587c559d19794966f54d5e1fc516eb24806338", "limitation": "input_tokens é o pacote montado no corpus oficial. B0 lê os hits de rg até 45 paths. V2.2 é o pickup/handoff real com retrieval e budget canónico de 22000 tokens. O caminho absoluto do diretório de jobs e a raiz do orchestrator no prompt são normalizados para jobs/v22-p0-baseline//V2.2 e orchestrator. Tokenizer obrigatório: tiktoken:cl100k_base. output_tokens, cache e cost são NOT_MEASURED. Híbrido Ollama é NOT_MEASURED. Latência medida é a de retrieval, não de modelo. Dispersão 0 de input_tokens é a esperada nesta corrida determinística. Economia de input só conta quando a qualidade V2.2 >= B0 (GOALS-OFFICIAL seção 5.3). Compactação é UNAVAILABLE. tree_sha é o HEAD no momento da corrida.", "tokenizer": "tiktoken:cl100k_base", "quality": 1, @@ -2871,9 +2875,9 @@ "runs": [ { "repetition": 1, - "input_tokens": 22054, + "input_tokens": 23479, "retrieval_input_tokens": 21333, - "latency_ms": 1212.485463000001, + "latency_ms": 1047.7006469999978, "reread_count": 0, "paths_read": [ "docs/architecture/v2.2/V22-VENDOR-CACHE.md", @@ -2907,9 +2911,9 @@ }, { "repetition": 2, - "input_tokens": 22054, + "input_tokens": 23479, "retrieval_input_tokens": 21333, - "latency_ms": 1329.2202810000017, + "latency_ms": 1109.4403659999953, "reread_count": 0, "paths_read": [ "docs/architecture/v2.2/V22-VENDOR-CACHE.md", @@ -2943,9 +2947,9 @@ }, { "repetition": 3, - "input_tokens": 22054, + "input_tokens": 23479, "retrieval_input_tokens": 21333, - "latency_ms": 1283.1246859999956, + "latency_ms": 1132.327691999999, "reread_count": 0, "paths_read": [ "docs/architecture/v2.2/V22-VENDOR-CACHE.md", diff --git a/docs/v22/baseline/raw/p0-compaction-report.json b/docs/v22/baseline/raw/p0-compaction-report.json index 4dc8e47d..966ba650 100644 --- a/docs/v22/baseline/raw/p0-compaction-report.json +++ b/docs/v22/baseline/raw/p0-compaction-report.json @@ -10,16 +10,16 @@ "tokenizer": "tiktoken:cl100k_base", "path_normalization": "stable_relative", "model_id": "deterministic-provider", - "tree_sha": "76636adf6077cb956b748b5af4c1125269833be2", + "tree_sha": "daba8dcbde817c76b5cf5aa64781cf49b54e9f35", "n": 3, "n_status": "PASS", - "tokens_before": 22054, - "tokens_after": 11251, - "token_delta": -10803, + "tokens_before": 23479, + "tokens_after": 11690, + "token_delta": -11789, "fidelity_before": 1, "fidelity": 1, "fidelity_status": "PASS", - "lines_dropped": 1430, + "lines_dropped": 1526, "savings_status": "PASS", "savings_rule": "docs/v22/GOALS-OFFICIAL.md#5.3", "tradeoff": null, @@ -31,7 +31,7 @@ "cache_write_tokens": "NOT_MEASURED", "cost": "NOT_MEASURED", "model_latency_ms": "NOT_MEASURED", - "latency_ms": 1474.7311996666667, + "latency_ms": 1156.873768, "latency_ms_status": "LIMITED", "dispersion": { "tokens_after": { @@ -45,33 +45,33 @@ }, "product_percent_gate": "NOT_MEASURED", "limitation": "Uma tarefa, n=3, condenser extrativo com a flag ligada só nesta corrida. O default do produto continua OFF e o contrato de reinject continua NOT_IMPLEMENTED. Fidelidade é a fração de âncoras e restrições do cartão presentes depois. Prosa fora dessas classes, de paths, de negações e de comandos é perda não pontuada. Saída, cache, custo e latência de modelo são NOT_MEASURED. Dispersão 0 é a esperada no determinístico. tree_sha é o HEAD no momento da corrida.", - "measured_at": "2026-10-24T00:47:11.183Z", + "measured_at": "2026-10-24T01:27:47.916Z", "runs": [ { "repetition": 1, - "tokens_before": 22054, - "tokens_after": 11251, + "tokens_before": 23479, + "tokens_after": 11690, "fidelity": 1, - "lines_dropped": 1430, - "latency_ms": 1471.518603, + "lines_dropped": 1526, + "latency_ms": 1136.6900749999998, "missing": [] }, { "repetition": 2, - "tokens_before": 22054, - "tokens_after": 11251, + "tokens_before": 23479, + "tokens_after": 11690, "fidelity": 1, - "lines_dropped": 1430, - "latency_ms": 1504.369409, + "lines_dropped": 1526, + "latency_ms": 1180.556474, "missing": [] }, { "repetition": 3, - "tokens_before": 22054, - "tokens_after": 11251, + "tokens_before": 23479, + "tokens_after": 11690, "fidelity": 1, - "lines_dropped": 1430, - "latency_ms": 1448.3055870000003, + "lines_dropped": 1526, + "latency_ms": 1153.3747550000003, "missing": [] } ] diff --git a/docs/v22/baseline/raw/p0-handoff-report.json b/docs/v22/baseline/raw/p0-handoff-report.json index 9d4ccd5c..a4b4242e 100644 --- a/docs/v22/baseline/raw/p0-handoff-report.json +++ b/docs/v22/baseline/raw/p0-handoff-report.json @@ -7,15 +7,15 @@ "tokenizer": "tiktoken:cl100k_base", "path_normalization": "stable_relative", "model_id": "deterministic-provider", - "tree_sha": "76cc11e6cf4eed30f6c6be68cc599eff8a7df88a", + "tree_sha": "daba8dcbde817c76b5cf5aa64781cf49b54e9f35", "n": 3, "n_status": "PASS", "reference_tokens": 1773, "reference_tokens_status": "PASS", "fidelity_checklist_tokens": 81, - "transferred_tokens": 2180, + "transferred_tokens": 3605, "transferred_tokens_status": "PASS", - "volume_ratio": 1.2295544275239707, + "volume_ratio": 2.0332769317540893, "volume_ratio_status": "LIMITED", "receiver_resume_ok": true, "receiver_resume_status": "PASS", @@ -25,7 +25,7 @@ "cache_write_tokens": "NOT_MEASURED", "cost": "NOT_MEASURED", "model_latency_ms": "NOT_MEASURED", - "latency_ms": 873.1666866666666, + "latency_ms": 528.2894873333332, "latency_ms_status": "LIMITED", "latency_kind": "handoff_assembly", "dispersion": { @@ -43,15 +43,15 @@ "compaction_fidelity": "UNAVAILABLE", "product_percent_gate": "NOT_MEASURED", "limitation": "Uma corrida de handoff com a flag EVOLVELOOP_COMPACTION ausente. reference_tokens é o contexto completo do agente emissor (briefing, DoD, restrições, decisões, próximo passo, grafo, conhecimento recuperado e evidência), sem saved_at. O checklist required_resume_payload fica em fidelity_checklist_tokens e não é o denominador: no P0-5 esse checklist (81 tokens) produziu o rácio 26,91 contra o pickup. transferred_tokens é o pickup normalizado. O rácio é observação, não gate de produto. Saída, cache, custo e latência de modelo são NOT_MEASURED. Dispersão 0 de transferred_tokens é a esperada no determinístico. Compactação desta corrida é UNAVAILABLE; a medição com a flag ligada está no relatório P0-6. tree_sha é o HEAD no momento da corrida.", - "measured_at": "2026-10-23T02:14:55.015Z", + "measured_at": "2026-10-24T01:27:46.714Z", "runs": [ { "repetition": 1, "reference_tokens": 1773, "fidelity_checklist_tokens": 81, - "transferred_tokens": 2180, - "volume_ratio": 1.2295544275239707, - "latency_ms": 995.8513109999999, + "transferred_tokens": 3605, + "volume_ratio": 2.0332769317540893, + "latency_ms": 661.344745, "receiver_resume_ok": true, "payload_present": true, "missing": [] @@ -60,9 +60,9 @@ "repetition": 2, "reference_tokens": 1773, "fidelity_checklist_tokens": 81, - "transferred_tokens": 2180, - "volume_ratio": 1.2295544275239707, - "latency_ms": 815.6357029999999, + "transferred_tokens": 3605, + "volume_ratio": 2.0332769317540893, + "latency_ms": 448.41257399999995, "receiver_resume_ok": true, "payload_present": true, "missing": [] @@ -71,9 +71,9 @@ "repetition": 3, "reference_tokens": 1773, "fidelity_checklist_tokens": 81, - "transferred_tokens": 2180, - "volume_ratio": 1.2295544275239707, - "latency_ms": 808.013046, + "transferred_tokens": 3605, + "volume_ratio": 2.0332769317540893, + "latency_ms": 475.11114299999986, "receiver_resume_ok": true, "payload_present": true, "missing": [] diff --git a/orchestrator/README.md b/orchestrator/README.md index 4067371a..ac046334 100644 --- a/orchestrator/README.md +++ b/orchestrator/README.md @@ -68,6 +68,14 @@ npm run run-engine -- --ir path/to/ir.yaml --jobs-dir ./jobs --discovery --wait- npm run run-engine -- --ir tests/fixtures/login-dashboard.ir.yaml --discovery --jobs-dir ./jobs --policy rapid-prototype ``` +## Caveman output hard gate + +Default ON. Opt-out: `EVOLVELOOP_BREVITY_CAVEMAN=off`. Contrato e comando de medição: `docs/v22/CAVEMAN-HARD-GATE.md`. + +```bash +npm run v22:caveman-measure -- --provider cursor-agent --dry-run --n 5 +``` + ## Testes ```bash diff --git a/orchestrator/package.json b/orchestrator/package.json index 0e7d7d6a..3f4978fb 100644 --- a/orchestrator/package.json +++ b/orchestrator/package.json @@ -20,7 +20,8 @@ "registry-builder": "node dist/cli/registry-builder.js", "registry-builder:ci": "bash scripts/registry-builder-ci.sh", "run-jobs": "node dist/cli/run-jobs.js", - "v22:vendor-measure": "vite-node src/v22/vendor-measure-cli.ts" + "v22:vendor-measure": "vite-node src/v22/vendor-measure-cli.ts", + "v22:caveman-measure": "vite-node src/v22/caveman-output-measure-cli.ts" }, "bin": { "run-engine": "./dist/cli/run-engine.js", diff --git a/orchestrator/src/cli/run-engine-env.ts b/orchestrator/src/cli/run-engine-env.ts index 72be25dd..b056de89 100644 --- a/orchestrator/src/cli/run-engine-env.ts +++ b/orchestrator/src/cli/run-engine-env.ts @@ -25,6 +25,9 @@ export function loadAgentsEnvFile(path?: string): void { ) { value = value.slice(1, -1); } + // The install template keeps shell defaults (`${VAR:-fallback}`). This loader + // does not expand them. Assigning the literal creates a junk jobs directory. + if (value.includes("${")) continue; if (process.env[key] === undefined) { process.env[key] = value; } diff --git a/orchestrator/src/cli/run-engine.ts b/orchestrator/src/cli/run-engine.ts index c1971477..c260eb40 100644 --- a/orchestrator/src/cli/run-engine.ts +++ b/orchestrator/src/cli/run-engine.ts @@ -32,7 +32,7 @@ import { loadAgentsEnvFile, resolveOrchestratorCliPaths } from "./run-engine-env import { serializeForPublish } from "../evidence/publish-sanitize.js"; import { isGraphifyExperimentEnabled, - isCavemanBrevityEnabled, + isCavemanBrevityExplicitlyOn, isPromptCacheEnabled, } from "../v22/feature-flags.js"; import { queryGraphifyCodeStructure, formatGraphifyContext } from "../v22/graphify-adapter.js"; @@ -306,7 +306,7 @@ async function main() { }; const anyP2 = - isGraphifyExperimentEnabled() || isCavemanBrevityEnabled() || isPromptCacheEnabled(); + isGraphifyExperimentEnabled() || isCavemanBrevityExplicitlyOn() || isPromptCacheEnabled(); if (anyP2) { const graph = isGraphifyExperimentEnabled() ? queryGraphifyCodeStructure({ @@ -325,7 +325,7 @@ async function main() { } : undefined, bench: - isCavemanBrevityEnabled() || isPromptCacheEnabled() + isCavemanBrevityExplicitlyOn() || isPromptCacheEnabled() ? measureV22Goals009010({ jobsDir: jobsDir ? resolve(jobsDir) : join(orchestratorRoot, "jobs"), orchestratorRoot, diff --git a/orchestrator/src/index.ts b/orchestrator/src/index.ts index 2927c187..929ccff3 100644 --- a/orchestrator/src/index.ts +++ b/orchestrator/src/index.ts @@ -287,6 +287,8 @@ export { export { isGraphifyExperimentEnabled, isCavemanBrevityEnabled, + isCavemanBrevityExplicitlyOn, + isCavemanOutputGateEnabled, isPromptCacheEnabled, } from "./v22/feature-flags.js"; export { diff --git a/orchestrator/src/jobs/job-pickup.ts b/orchestrator/src/jobs/job-pickup.ts index 8fa1d594..356a0336 100644 --- a/orchestrator/src/jobs/job-pickup.ts +++ b/orchestrator/src/jobs/job-pickup.ts @@ -4,6 +4,8 @@ import { resolveOrchestratorRoot } from "../cli/run-engine-env.js"; import { writeSanitizedJsonFile, writeSanitizedTextFile } from "../evidence/evidence-bus.js"; import { redactSecrets } from "../evidence/secret-redaction.js"; import { applyCavemanToBriefingSection } from "../v22/brevity-caveman.js"; +import { injectCavemanHardGate } from "../v22/caveman-hard-gate.js"; +import { isCavemanOutputGateEnabled } from "../v22/feature-flags.js"; import { JobStore, type SkillJob } from "./job-store.js"; import { preparePickupSpawnContext, type PickupContextPrepareResult } from "./spawn-pickup-context.js"; import type { EventBus } from "../events/event-bus.js"; @@ -31,7 +33,11 @@ export function resolvePendingJob( } export interface BuildPickupPromptOptions { - /** When set, overrides EVOLVELOOP_BREVITY_CAVEMAN for this build. */ + /** + * GOAL-009 bench arm. `true` compresses the briefing section only. + * The output hard gate follows `EVOLVELOOP_BREVITY_CAVEMAN` (default ON) + * and is not toggled by this field. + */ caveman?: boolean; /** Precomputed spawn context (invoke path); omitted → computed per call. */ spawnContext?: PickupContextPrepareResult; @@ -95,10 +101,9 @@ ${JSON.stringify(job.inputs, null, 2)} --- *Gerado por @agents/orchestrator run-jobs invoke* `; - return applyCavemanToBriefingSection( - raw, - options?.caveman !== undefined ? { enabled: options.caveman } : undefined, - ).text; + const gated = injectCavemanHardGate(raw, isCavemanOutputGateEnabled()); + if (options?.caveman !== true) return gated; + return applyCavemanToBriefingSection(gated, { enabled: true }).text; } export function writePickupArtifacts( diff --git a/orchestrator/src/jobs/spawn-pickup-context.ts b/orchestrator/src/jobs/spawn-pickup-context.ts index 8149a783..1915f4d3 100644 --- a/orchestrator/src/jobs/spawn-pickup-context.ts +++ b/orchestrator/src/jobs/spawn-pickup-context.ts @@ -17,6 +17,8 @@ import { export type { ContextRetrievalEntry }; import type { EventBus } from "../events/event-bus.js"; import { emitContextBudgetTelemetry } from "../context/telemetry.js"; +import { CAVEMAN_OPT_OUT, CAVEMAN_SKILL_REL } from "../v22/caveman-hard-gate.js"; +import { isCavemanOutputGateEnabled } from "../v22/feature-flags.js"; export interface PickupContextPrepareResult { validation_ok: boolean; @@ -118,6 +120,7 @@ export function protectedSlicesFromJob(job: SkillJob): ContextSlice[] { } export function formatGateBundleBlock(bundle: GateBundleFields): string { + const caveman = isCavemanOutputGateEnabled() ? "on" : "off"; return `### GATE_BUNDLE parent_cycle_id: ${bundle.parent_cycle_id} spawn_depth: ${bundle.spawn_depth} @@ -125,6 +128,9 @@ max_spawn_depth: ${bundle.max_spawn_depth} role: ${bundle.role} context_owner_id: ${bundle.context_owner_id ?? deriveContextOwnerId(bundle)} context_budget: ${JSON.stringify(bundle.context_budget ?? {})} +caveman_output: ${caveman} +caveman_skill: ${CAVEMAN_SKILL_REL} +caveman_opt_out: ${CAVEMAN_OPT_OUT} `; } diff --git a/orchestrator/src/v22/brevity-caveman.ts b/orchestrator/src/v22/brevity-caveman.ts index ea32d35a..d6a54eb7 100644 --- a/orchestrator/src/v22/brevity-caveman.ts +++ b/orchestrator/src/v22/brevity-caveman.ts @@ -1,8 +1,10 @@ /** - * V22-GOAL-009 — opt-in Caveman-style brevity (voice only; preserves contracts verbatim). + * V22-GOAL-009 — explicit Caveman briefing compressor (bench arm only). + * The output hard gate does not call this. Explicit `EVOLVELOOP_BREVITY_CAVEMAN=on` + * still enables it for direct callers; unset does not. */ -import { isCavemanBrevityEnabled } from "./feature-flags.js"; +import { isCavemanBrevityExplicitlyOn } from "./feature-flags.js"; import { countBenchTokens } from "./bench-tokenizer.js"; const FENCE_RE = /```[\s\S]*?```/g; @@ -49,7 +51,7 @@ function cavemanLine(line: string): string { } export function applyCavemanBrevity(text: string, options?: { force?: boolean }): BrevityResult { - const enabled = options?.force === true || isCavemanBrevityEnabled(); + const enabled = options?.force === true || isCavemanBrevityExplicitlyOn(); const input_tokens = countBenchTokens(text); if (!enabled) { return { enabled: false, text, input_tokens, output_tokens: input_tokens, preserved_blocks: 0 }; @@ -114,7 +116,7 @@ export function applyCavemanToBriefingSection( const head = fullPrompt.slice(0, bodyStart); const briefing = fullPrompt.slice(bodyStart, end); const tail = fullPrompt.slice(end); - const enabled = options?.enabled ?? isCavemanBrevityEnabled(); + const enabled = options?.enabled ?? isCavemanBrevityExplicitlyOn(); const compressedBriefing = enabled ? compressBriefingProse(briefing) : briefing; const text = head + compressedBriefing + tail; return { diff --git a/orchestrator/src/v22/caveman-hard-gate.ts b/orchestrator/src/v22/caveman-hard-gate.ts new file mode 100644 index 00000000..abcf0717 --- /dev/null +++ b/orchestrator/src/v22/caveman-hard-gate.ts @@ -0,0 +1,66 @@ +/** + * V22-CAVEMAN-HG-1 — Caveman output hard gate. + * + * The vendored skill is upstream bytes (see vendor/juliusbrussee-caveman/PIN.json). + * This module only points at it and states the EvolveLoop exceptions. + * It does not rewrite the skill and it does not lossy-compress worker prompts. + */ + +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; + +export const CAVEMAN_SKILL_REL = "vendor/juliusbrussee-caveman/skills/caveman/SKILL.md"; +export const CAVEMAN_UPSTREAM_COMMIT = "d262ab3882952a59312ff3537cd86d894523c5ab"; +export const CAVEMAN_OPT_OUT = "EVOLVELOOP_BREVITY_CAVEMAN=off"; +export const CAVEMAN_GATE_HEADING = "## Caveman output hard gate"; +export const CAVEMAN_EXCEPTION_LINE = + "code, commands, paths, evidence, SHAs, commit messages, user docs, task reports (structured fields), security content"; + +const SKILL_URL = new URL(`../../../${CAVEMAN_SKILL_REL}`, import.meta.url); + +let cachedSection: string | undefined; + +export function cavemanSkillPath(): string { + return fileURLToPath(SKILL_URL); +} + +export function readVendoredCavemanSkill(): string { + return readFileSync(cavemanSkillPath(), "utf8"); +} + +/** Upstream SKILL.md plus the EvolveLoop exception overlay. Skill bytes stay intact. */ +export function renderCavemanHardGateSection(): string { + if (cachedSection) return cachedSection; + const skill = readVendoredCavemanSkill(); + if (!skill.includes("name: caveman") || !skill.includes("Only fluff die.")) { + throw new Error("vendored caveman SKILL.md failed the integrity marker check"); + } + cachedSection = [ + CAVEMAN_GATE_HEADING, + "", + "Mode: caveman. Default ON for every EvolveLoop agent and worker.", + `Opt-out: ${CAVEMAN_OPT_OUT} (also 0, false, no). Unset means ON.`, + "Follow the vendored skill below. Do not rewrite it. Do not switch to ultracave, megacave, or caveman-compress.", + `Skill: \`${CAVEMAN_SKILL_REL}\``, + `Upstream: https://github.com/juliusbrussee/caveman @ ${CAVEMAN_UPSTREAM_COMMIT} (v4.0.1)`, + "", + "Exceptions — never compress or alter:", + CAVEMAN_EXCEPTION_LINE, + "Security warnings and irreversible confirmations stay full sentences.", + "Structured task-report fields keep their labels and their verbatim values.", + "", + skill.endsWith("\n") ? skill : `${skill}\n`, + ].join("\n"); + return cachedSection; +} + +const BRIEFING_ANCHOR = "## Briefing\n\n"; + +/** Insert the gate before the briefing so Definition of Done and inputs stay byte-identical. */ +export function injectCavemanHardGate(prompt: string, enabled: boolean): string { + if (!enabled) return prompt; + const block = renderCavemanHardGateSection(); + const at = prompt.indexOf(BRIEFING_ANCHOR); + if (at === -1) return `${prompt.trimEnd()}\n\n${block}`; + return `${prompt.slice(0, at)}${block}\n${prompt.slice(at)}`; +} diff --git a/orchestrator/src/v22/caveman-output-measure-cli.ts b/orchestrator/src/v22/caveman-output-measure-cli.ts new file mode 100644 index 00000000..5c9d5deb --- /dev/null +++ b/orchestrator/src/v22/caveman-output-measure-cli.ts @@ -0,0 +1,58 @@ +/** + * npm run v22:caveman-measure + * Reads CURSOR_API_KEY from the environment and never prints it. + * + * Live comparison (run outside CI, N=5, six frozen tasks, cursor-agent): + * cd orchestrator && CURSOR_API_KEY="$CURSOR_API_KEY" npm run v22:caveman-measure -- --provider cursor-agent --n 5 + * + * Dry-run, no key and no spend: + * cd orchestrator && npm run v22:caveman-measure -- --provider cursor-agent --dry-run --n 5 + */ + +import { mkdirSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { redactSecrets } from "../evidence/secret-redaction.js"; +import { repoRootFromModule } from "./p0-baseline-harness.js"; +import { cavemanMeasurePublicError, runCavemanOutputMeasure } from "./caveman-output-measure.js"; + +function flag(name: string): boolean { + return process.argv.includes(name); +} + +function option(name: string): string | undefined { + const index = process.argv.indexOf(name); + if (index === -1) return undefined; + return process.argv[index + 1]; +} + +const provider = option("--provider") ?? "cursor-agent"; +if (provider !== "cursor-agent") { + throw new Error("provider must be cursor-agent"); +} + +const rawN = option("--n"); +const n = rawN === undefined ? undefined : Number(rawN); +if (rawN !== undefined && !Number.isFinite(n)) throw new Error("invalid --n"); + +const apiKey = process.env.CURSOR_API_KEY; +const out = option("--out") ?? path.join(repoRootFromModule(), "docs/v22/baseline/raw/caveman-hg-report.json"); + +try { + const report = await runCavemanOutputMeasure({ + dryRun: flag("--dry-run"), + n, + apiKey, + bin: process.env.CURSOR_AGENT_BIN, + env: process.env, + }); + mkdirSync(path.dirname(out), { recursive: true }); + const body = `${JSON.stringify(report, null, 2)}\n`; + writeFileSync(out, redactSecrets(body, { extraCanaries: apiKey ? [apiKey] : [] })); + process.stdout.write( + `${report.status} ${report.provider} tasks=${report.tasks.length} n=${report.n} calls=${report.calls} out=${out}\n`, + ); + if (report.status === "ABORTED_MISSING_KEY") process.exitCode = 2; +} catch (error) { + process.stderr.write(`${cavemanMeasurePublicError(error, apiKey ? [apiKey] : [])}\n`); + process.exitCode = 1; +} diff --git a/orchestrator/src/v22/caveman-output-measure.ts b/orchestrator/src/v22/caveman-output-measure.ts new file mode 100644 index 00000000..cf314b08 --- /dev/null +++ b/orchestrator/src/v22/caveman-output-measure.ts @@ -0,0 +1,300 @@ +/** + * V22-CAVEMAN-HG-1 — output measurement plan. + * + * Compares Caveman ON vs OFF on the six frozen P0 tasks. + * cursor-agent does not publish token counts. Response size is tiktoken + * cl100k_base over the result text. Latency is duration_ms. Quality is the + * fraction of task anchors and restrictions present in the reply. + * The command does not call the provider during --dry-run and never prints a key. + */ + +import { createHash } from "node:crypto"; +import { spawnSync } from "node:child_process"; +import { LlmHttpProviderAdapter } from "../providers/llm/llm-http-provider-adapter.js"; +import type { CursorAgentSpawn } from "../providers/llm/cursor-agent-provider.js"; +import { requireTiktokenCounts } from "../context/tokenizer.js"; +import { redactSecrets } from "../evidence/secret-redaction.js"; +import { + loadFrozenTasks, + measureP0V22Text, + P0_TASK_IDS, + repoRootFromModule, + type P0TaskId, +} from "./p0-baseline-harness.js"; +import { renderCavemanHardGateSection } from "./caveman-hard-gate.js"; + +export const CAVEMAN_MEASURE_N = 5; +export type CavemanArm = "off" | "on"; +export type NotMeasured = "NOT_MEASURED"; +export type NumOrNot = number | NotMeasured; + +const ARMS: CavemanArm[] = ["off", "on"]; + +export interface CavemanMeasurePack { + taskId: P0TaskId; + query: string; + needles: string[]; + context: string; +} + +export interface CavemanArmPlan { + arm: CavemanArm; + local_prompt_tokens: number; + prompt_sha256: string; + n: number; + response_tokens: NumOrNot; + provider_output_tokens: NotMeasured; + latency_ms: NumOrNot; + quality: NumOrNot; + dispersion: Record; + runs: Array>; +} + +export interface CavemanMeasureReport { + schema_id: "v22-caveman-output-measure-1"; + task_id: "V22-CAVEMAN-HG-1"; + status: "DRY_RUN" | "MEASURED" | "ABORTED_MISSING_KEY"; + provider: "cursor-agent"; + n: number; + tokenizer: "tiktoken:cl100k_base"; + response_token_source: "tiktoken:cl100k_base of cursor-agent result text"; + tree_sha: string; + calls: number; + tasks: Array<{ id: string; arms: { off: CavemanArmPlan; on: CavemanArmPlan } }>; + limitation: string; + measured_at: string; +} + +export function cavemanMeasurePublicError(error: unknown, secrets: string[]): string { + const raw = error instanceof Error ? error.message : String(error); + return redactSecrets(raw, { extraCanaries: secrets.filter((item) => item.length >= 6) }); +} + +export function buildCavemanArmPrompt(query: string, context: string, arm: CavemanArm): string { + const base = [ + "Reply in at most 120 words. Use only the context below. Do not call tools.", + "", + `Question: ${query}`, + "", + "Context:", + context, + ].join("\n"); + if (arm === "off") return base; + return `${base}\n\n${renderCavemanHardGateSection()}\nApply that Caveman output hard gate to the reply. The exception classes stay verbatim.`; +} + +export async function loadCavemanMeasurePacks(repoRoot: string): Promise { + const loaded = loadFrozenTasks(repoRoot); + const packs: CavemanMeasurePack[] = []; + for (const taskId of P0_TASK_IDS) { + const task = loaded.tasks.find((item) => item.id === taskId); + if (!task) throw new Error(`missing frozen task ${taskId}`); + const v22 = await measureP0V22Text(taskId, repoRoot); + packs.push({ + taskId, + query: task.query, + needles: [...task.anchors.map((anchor) => anchor.substring), ...task.restrictions], + context: v22.text, + }); + } + return packs; +} + +function assertPacks(packs: CavemanMeasurePack[]): void { + const ids = packs.map((pack) => pack.taskId); + if (ids.length !== P0_TASK_IDS.length || P0_TASK_IDS.some((id, index) => ids[index] !== id)) { + throw new Error(`caveman measure requires these tasks in order: ${P0_TASK_IDS.join(", ")}`); + } +} + +function treeSha(root: string): string { + const result = spawnSync("git", ["rev-parse", "HEAD"], { cwd: root, encoding: "utf-8" }); + const sha = result.stdout?.trim() ?? ""; + return result.status === 0 && /^[0-9a-f]{40}$/.test(sha) ? sha : "NOT_MEASURED"; +} + +function sha256(text: string): string { + return createHash("sha256").update(text, "utf8").digest("hex"); +} + +function mean(values: number[]): number { + return values.reduce((sum, value) => sum + value, 0) / values.length; +} + +function sampleStddev(values: number[]): number { + const center = mean(values); + const square = values.reduce((sum, value) => sum + (value - center) ** 2, 0); + return Math.sqrt(square / (values.length - 1)); +} + +function numericDispersion( + values: Array, +): NumOrNot | { statistic: "sample_stddev"; value: number; n: number } { + if (values.some((value) => value === "NOT_MEASURED") || values.length < 2) return "NOT_MEASURED"; + return { statistic: "sample_stddev", value: sampleStddev(values as number[]), n: values.length }; +} + +function qualityOf(text: string, needles: string[]): { quality: number; missing: string[] } { + if (needles.length === 0) return { quality: 1, missing: [] }; + const missing = needles.filter((needle) => !text.includes(needle)); + return { quality: (needles.length - missing.length) / needles.length, missing }; +} + +function emptyArm(arm: CavemanArm, tokens: number, prompt: string, n: number): CavemanArmPlan { + return { + arm, + local_prompt_tokens: tokens, + prompt_sha256: sha256(prompt), + n, + response_tokens: "NOT_MEASURED", + provider_output_tokens: "NOT_MEASURED", + latency_ms: "NOT_MEASURED", + quality: "NOT_MEASURED", + dispersion: { + response_tokens: "NOT_MEASURED", + latency_ms: "NOT_MEASURED", + quality: "NOT_MEASURED", + }, + runs: [], + }; +} + +function finishArm(plan: CavemanArmPlan, runs: CavemanArmPlan["runs"]): CavemanArmPlan { + const field = (name: string) => runs.map((run) => run[name]) as Array; + const meanOf = (name: string): NumOrNot => { + const values = field(name); + if (values.some((value) => value === "NOT_MEASURED") || values.length === 0) return "NOT_MEASURED"; + return mean(values as number[]); + }; + return { + ...plan, + response_tokens: meanOf("response_tokens"), + latency_ms: meanOf("latency_ms"), + quality: meanOf("quality"), + dispersion: { + response_tokens: numericDispersion(field("response_tokens")), + latency_ms: numericDispersion(field("latency_ms")), + quality: numericDispersion(field("quality")), + }, + runs, + }; +} + +export async function runCavemanOutputMeasure(options: { + dryRun: boolean; + n?: number; + repoRoot?: string; + packs?: CavemanMeasurePack[]; + apiKey?: string; + bin?: string; + cwd?: string; + env?: NodeJS.ProcessEnv; + spawnImpl?: CursorAgentSpawn; +}): Promise { + const n = options.n ?? CAVEMAN_MEASURE_N; + if (!Number.isInteger(n) || n < CAVEMAN_MEASURE_N) { + throw new Error("caveman measure n must be an integer >= 5"); + } + const repoRoot = options.repoRoot ?? repoRootFromModule(); + const packs = options.packs ?? (await loadCavemanMeasurePacks(repoRoot)); + assertPacks(packs); + const prompts: string[] = []; + const meta: Array<{ taskId: P0TaskId; arm: CavemanArm; prompt: string }> = []; + for (const pack of packs) { + for (const arm of ARMS) { + const prompt = buildCavemanArmPrompt(pack.query, pack.context, arm); + meta.push({ taskId: pack.taskId, arm, prompt }); + prompts.push(prompt); + } + } + const counts = requireTiktokenCounts(prompts); + const arms = new Map(); + meta.forEach((item, index) => { + arms.set( + `${item.taskId}:${item.arm}`, + emptyArm(item.arm, counts[index] ?? 0, item.prompt, n), + ); + }); + const calls = packs.length * ARMS.length * n; + const base: CavemanMeasureReport = { + schema_id: "v22-caveman-output-measure-1", + task_id: "V22-CAVEMAN-HG-1", + status: "DRY_RUN", + provider: "cursor-agent", + n, + tokenizer: "tiktoken:cl100k_base", + response_token_source: "tiktoken:cl100k_base of cursor-agent result text", + tree_sha: treeSha(repoRoot), + calls, + tasks: packs.map((pack) => ({ + id: pack.taskId, + arms: { + off: arms.get(`${pack.taskId}:off`)!, + on: arms.get(`${pack.taskId}:on`)!, + }, + })), + limitation: + "CI does not call cursor-agent. Live response size is local tiktoken over result text. Provider output tokens and cost stay NOT_MEASURED because the official cursor-agent schema has neither. Latency is duration_ms. Quality is the fraction of frozen anchors and restrictions present in the reply.", + measured_at: new Date().toISOString(), + }; + if (options.dryRun) return base; + if (!options.apiKey?.trim()) return { ...base, status: "ABORTED_MISSING_KEY" }; + + const secrets = [options.apiKey]; + const adapter = new LlmHttpProviderAdapter(); + const runs = new Map(); + const pendingTexts: string[] = []; + const pendingRefs: Array<{ key: string; index: number }> = []; + try { + for (const item of meta) { + const pack = packs.find((candidate) => candidate.taskId === item.taskId); + if (!pack) continue; + const key = `${item.taskId}:${item.arm}`; + const bucket = runs.get(key) ?? []; + for (let repetition = 1; repetition <= n; repetition += 1) { + const result = await adapter.completeCursorAgent({ + prompt: item.prompt, + bin: options.bin, + cwd: options.cwd ?? repoRoot, + env: options.env ?? process.env, + spawnImpl: options.spawnImpl, + }); + const scored = qualityOf(result.text, pack.needles); + pendingRefs.push({ key, index: bucket.length }); + pendingTexts.push(result.text); + bucket.push({ + repetition, + response_tokens: "NOT_MEASURED", + provider_output_tokens: "NOT_MEASURED", + latency_ms: result.duration_ms, + quality: scored.quality, + missing: scored.missing, + model_id: result.model_id, + }); + runs.set(key, bucket); + } + } + } catch (error) { + throw new Error(cavemanMeasurePublicError(error, secrets)); + } + + const responseTokens = pendingTexts.length > 0 ? requireTiktokenCounts(pendingTexts) : []; + pendingRefs.forEach((ref, index) => { + const bucket = runs.get(ref.key); + const run = bucket?.[ref.index]; + if (!run) return; + run.response_tokens = responseTokens[index] ?? "NOT_MEASURED"; + }); + + return { + ...base, + status: "MEASURED", + tasks: packs.map((pack) => ({ + id: pack.taskId, + arms: { + off: finishArm(arms.get(`${pack.taskId}:off`)!, runs.get(`${pack.taskId}:off`) ?? []), + on: finishArm(arms.get(`${pack.taskId}:on`)!, runs.get(`${pack.taskId}:on`) ?? []), + }, + })), + }; +} diff --git a/orchestrator/src/v22/feature-flags.ts b/orchestrator/src/v22/feature-flags.ts index 8e7e6e39..a45728ec 100644 --- a/orchestrator/src/v22/feature-flags.ts +++ b/orchestrator/src/v22/feature-flags.ts @@ -1,7 +1,10 @@ /** - * V22 P2 experiment flags — default OFF; no behavior change when unset. + * V22 P2 experiment flags. Graphify, prompt cache, and compaction stay OFF + * when unset. The Caveman output gate is the exception: default ON. */ +const CAVEMAN_OFF = new Set(["0", "false", "off", "no"]); + function envOn(name: string): boolean { const v = process.env[name]?.trim().toLowerCase(); return v === "1" || v === "true" || v === "on" || v === "yes"; @@ -12,11 +15,29 @@ export function isGraphifyExperimentEnabled(): boolean { return envOn("EVOLVELOOP_GRAPHIFY"); } -/** V22-GOAL-009 — Caveman-style brevity for host prompts/reports (not core contracts). */ -export function isCavemanBrevityEnabled(): boolean { +/** + * V22-CAVEMAN-HG-1 — Caveman output hard gate. + * Default ON. Opt-out: `EVOLVELOOP_BREVITY_CAVEMAN=off` (also `0`, `false`, `no`). + * Does not, by itself, lossy-compress briefings. + */ +export function isCavemanOutputGateEnabled(): boolean { + const raw = process.env.EVOLVELOOP_BREVITY_CAVEMAN; + if (raw === undefined) return true; + const v = raw.trim().toLowerCase(); + if (v === "") return true; + return !CAVEMAN_OFF.has(v); +} + +/** Explicit `on|true|1|yes`. Attaches the historical GOAL-009/010 bench. Unset does not. */ +export function isCavemanBrevityExplicitlyOn(): boolean { return envOn("EVOLVELOOP_BREVITY_CAVEMAN"); } +/** Same switch as `isCavemanOutputGateEnabled`. Name kept for existing imports. */ +export function isCavemanBrevityEnabled(): boolean { + return isCavemanOutputGateEnabled(); +} + /** V22-GOAL-010 — stable prefix + cache key on HTTP LLM adapter. */ export function isPromptCacheEnabled(): boolean { return envOn("EVOLVELOOP_PROMPT_CACHE"); diff --git a/orchestrator/tests/integration/v22-p2-goals.integration.test.ts b/orchestrator/tests/integration/v22-p2-goals.integration.test.ts index 88be7c61..74fd3d47 100644 --- a/orchestrator/tests/integration/v22-p2-goals.integration.test.ts +++ b/orchestrator/tests/integration/v22-p2-goals.integration.test.ts @@ -91,7 +91,7 @@ describe("V22 P2 goals integration (run-engine / run-jobs)", () => { expect(bench?.goal_010_prefix?.vendor_http_cache_hit).toBe("NOT_MEASURED"); }); - it("run-jobs invoke path compresses briefing only when caveman flag on", () => { + it("run-jobs invoke injects the caveman hard gate by default and opt-out removes it", () => { const jobsDir = mkdtempSync(join(tmpdir(), "v22-p2-jobs-")); const job: SkillJob = { apiVersion: "capability-orchestrator.io/v2", @@ -110,25 +110,45 @@ describe("V22 P2 goals integration (run-engine / run-jobs)", () => { writeFileSync(join(jobsDir, `${job.run_id}.json`), JSON.stringify(job)); clearP2Env(); - const offPrompt = buildPickupPrompt(job, jobsDir, orchestratorRoot); - process.env.EVOLVELOOP_BREVITY_CAVEMAN = "on"; const onPrompt = buildPickupPrompt(job, jobsDir, orchestratorRoot); + process.env.EVOLVELOOP_BREVITY_CAVEMAN = "off"; + const offPrompt = buildPickupPrompt(job, jobsDir, orchestratorRoot); - expect(estimateWhitespaceTokens(onPrompt)).toBeLessThan(estimateWhitespaceTokens(offPrompt)); + expect(onPrompt).toContain("## Caveman output hard gate"); + expect(offPrompt).not.toContain("## Caveman output hard gate"); + expect(estimateWhitespaceTokens(onPrompt)).toBeGreaterThan(estimateWhitespaceTokens(offPrompt)); expect(onPrompt).toContain("do not skip"); + expect(offPrompt).toContain("do not skip"); expect(onPrompt).toContain('"id": "d1"'); + expect(offPrompt).toContain('"id": "d1"'); + const dod = "## Definition of Done"; + expect(onPrompt.slice(onPrompt.indexOf(dod))).toBe(offPrompt.slice(offPrompt.indexOf(dod))); + expect(onPrompt).toContain(job.briefing); + expect(offPrompt).toContain(job.briefing); + delete process.env.EVOLVELOOP_BREVITY_CAVEMAN; const promptDir = mkdtempSync(join(tmpdir(), "v22-p2-pickup-")); const invokeOut = runCli( "run-jobs", ["invoke", "--jobs-dir", jobsDir, "--prompt-dir", promptDir], - { EVOLVELOOP_BREVITY_CAVEMAN: "on" }, ); const plan = JSON.parse(invokeOut); expect(plan.status).toBe("ready"); const written = readFileSync(join(promptDir, "current-job.md"), "utf-8"); + expect(written).toContain("## Caveman output hard gate"); expect(written).toContain("do not skip"); + + const offDir = mkdtempSync(join(tmpdir(), "v22-p2-pickup-off-")); + runCli( + "run-jobs", + ["invoke", "--jobs-dir", jobsDir, "--prompt-dir", offDir], + { EVOLVELOOP_BREVITY_CAVEMAN: "off" }, + ); + const writtenOff = readFileSync(join(offDir, "current-job.md"), "utf-8"); + expect(writtenOff).not.toContain("## Caveman output hard gate"); + expect(writtenOff).toContain("do not skip"); rmSync(jobsDir, { recursive: true, force: true }); rmSync(promptDir, { recursive: true, force: true }); + rmSync(offDir, { recursive: true, force: true }); }); }); diff --git a/orchestrator/tests/unit/run-engine-env.test.ts b/orchestrator/tests/unit/run-engine-env.test.ts index 48da8202..1febc9be 100644 --- a/orchestrator/tests/unit/run-engine-env.test.ts +++ b/orchestrator/tests/unit/run-engine-env.test.ts @@ -45,6 +45,18 @@ describe("run-engine env defaults", () => { expect(paths.jobsDir).toBe("/cli/jobs"); }); + it("ignores unexpanded shell defaults from the install template", () => { + const envFile = join(tempDir, "agents.env"); + writeFileSync( + envFile, + 'export ORCHESTRATOR_JOBS_DIR="${ORCHESTRATOR_JOBS_DIR:-$ORCHESTRATOR_ROOT/jobs}"\n', + ); + process.env.ORCHESTRATOR_AGENTS_ENV = envFile; + const paths = resolveOrchestratorCliPaths({}, true); + expect(paths.jobsDir).toBe("./jobs"); + expect(process.env.ORCHESTRATOR_JOBS_DIR).toBeUndefined(); + }); + it("does not override existing process.env keys", () => { const envFile = join(tempDir, "agents.env"); writeFileSync(envFile, 'export ORCHESTRATOR_JOBS_DIR="/from-file"\n'); diff --git a/orchestrator/tests/unit/v22-caveman-hard-gate.test.ts b/orchestrator/tests/unit/v22-caveman-hard-gate.test.ts new file mode 100644 index 00000000..82347b0f --- /dev/null +++ b/orchestrator/tests/unit/v22-caveman-hard-gate.test.ts @@ -0,0 +1,115 @@ +import { createHash } from "node:crypto"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { afterEach, describe, expect, it } from "vitest"; +import { buildPickupPrompt } from "../../src/jobs/job-pickup.js"; +import { + CAVEMAN_EXCEPTION_LINE, + CAVEMAN_GATE_HEADING, + CAVEMAN_UPSTREAM_COMMIT, + readVendoredCavemanSkill, +} from "../../src/v22/caveman-hard-gate.js"; +import { + isCavemanBrevityExplicitlyOn, + isCavemanOutputGateEnabled, +} from "../../src/v22/feature-flags.js"; +import type { SkillJob } from "../../src/jobs/job-store.js"; + +const repoRoot = join(import.meta.dirname, "../../.."); +const prev = process.env.EVOLVELOOP_BREVITY_CAVEMAN; + +const PAYLOAD = [ + "```ts\nexport const token = 1;\n```", + "npm test -- --run", + "orchestrator/src/v22/brevity-caveman.ts", + '{"kind":"Evidence","id":"e1"}', + "d262ab3882952a59312ff3537cd86d894523c5ab", + "chore: sync SKILL.md copies [skip ci]", + "See docs/v22/VENDOR-MEASURE.md for the operator command.", + "task_id: V22-CAVEMAN-HG-1", + "status: pass", + "No secret leakage in evidence payload", +]; + +function job(briefing: string): SkillJob { + return { + apiVersion: "capability-orchestrator.io/v2", + kind: "SkillJob", + run_id: "00000000-0000-4000-8000-0000000000c1", + provider_id: "testing", + skill_path: ".cursor/skills/testing/SKILL.md", + capability: "testing", + node_id: "n1", + briefing, + definition_of_done: [{ id: "d1", check: "pass", verification: "automated" }], + inputs: [{ name: "sha", value: CAVEMAN_UPSTREAM_COMMIT }], + status: "pending", + }; +} + +describe("caveman output hard gate", () => { + afterEach(() => { + if (prev === undefined) delete process.env.EVOLVELOOP_BREVITY_CAVEMAN; + else process.env.EVOLVELOOP_BREVITY_CAVEMAN = prev; + }); + + it("pins the vendored skill bytes", () => { + const pin = JSON.parse(readFileSync(join(repoRoot, "vendor/juliusbrussee-caveman/PIN.json"), "utf8")) as { + commit: string; + vendored_paths: Record; + }; + expect(pin.commit).toBe(CAVEMAN_UPSTREAM_COMMIT); + for (const [rel, sha] of Object.entries(pin.vendored_paths)) { + const body = readFileSync(join(repoRoot, "vendor/juliusbrussee-caveman", rel)); + expect(createHash("sha256").update(body).digest("hex")).toBe(sha); + } + expect(pin.vendored_paths["skills/caveman/SKILL.md"]).toBe( + createHash("sha256").update(readVendoredCavemanSkill()).digest("hex"), + ); + }); + + it("is on by default and off only for the documented opt-out", () => { + delete process.env.EVOLVELOOP_BREVITY_CAVEMAN; + expect(isCavemanOutputGateEnabled()).toBe(true); + expect(isCavemanBrevityExplicitlyOn()).toBe(false); + for (const value of ["on", "true", "1", "yes", "ON"]) { + process.env.EVOLVELOOP_BREVITY_CAVEMAN = value; + expect(isCavemanOutputGateEnabled()).toBe(true); + } + for (const value of ["off", "false", "0", "no", " OFF "]) { + process.env.EVOLVELOOP_BREVITY_CAVEMAN = value; + expect(isCavemanOutputGateEnabled()).toBe(false); + expect(isCavemanBrevityExplicitlyOn()).toBe(false); + } + }); + + it("keeps exception payloads byte-identical and embeds the official skill only when on", () => { + const briefing = PAYLOAD.join("\n"); + delete process.env.EVOLVELOOP_BREVITY_CAVEMAN; + const on = buildPickupPrompt(job(briefing), "/tmp/jobs", join(repoRoot, "orchestrator")); + process.env.EVOLVELOOP_BREVITY_CAVEMAN = "on"; + const explicit = buildPickupPrompt(job(briefing), "/tmp/jobs", join(repoRoot, "orchestrator")); + process.env.EVOLVELOOP_BREVITY_CAVEMAN = "off"; + const off = buildPickupPrompt(job(briefing), "/tmp/jobs", join(repoRoot, "orchestrator")); + + const skill = readVendoredCavemanSkill(); + expect(on).toContain(CAVEMAN_GATE_HEADING); + expect(on).toContain(CAVEMAN_EXCEPTION_LINE); + expect(on).toContain(skill); + expect(explicit).toContain(skill); + expect(off).not.toContain(CAVEMAN_GATE_HEADING); + expect(off).not.toContain("Only fluff die."); + expect(on).toContain("caveman_output: on"); + expect(off).toContain("caveman_output: off"); + + const dod = "## Definition of Done"; + const onContract = on.slice(on.indexOf(dod)); + expect(explicit.slice(explicit.indexOf(dod))).toBe(onContract); + expect(off.slice(off.indexOf(dod))).toBe(onContract); + expect(on).toContain(briefing); + expect(explicit).toContain(briefing); + expect(off).toContain(briefing); + expect(onContract).toContain(`"value": "${CAVEMAN_UPSTREAM_COMMIT}"`); + expect(onContract).toContain('"id": "d1"'); + }); +}); diff --git a/orchestrator/tests/unit/v22-caveman-output-measure.test.ts b/orchestrator/tests/unit/v22-caveman-output-measure.test.ts new file mode 100644 index 00000000..8efcddfe --- /dev/null +++ b/orchestrator/tests/unit/v22-caveman-output-measure.test.ts @@ -0,0 +1,116 @@ +import { describe, expect, it } from "vitest"; +import { requireTiktokenCounts } from "../../src/context/tokenizer.js"; +import { P0_TASK_IDS, type P0TaskId } from "../../src/v22/p0-baseline-harness.js"; +import { CAVEMAN_EXCEPTION_LINE, CAVEMAN_UPSTREAM_COMMIT } from "../../src/v22/caveman-hard-gate.js"; +import { + buildCavemanArmPrompt, + runCavemanOutputMeasure, + type CavemanMeasurePack, +} from "../../src/v22/caveman-output-measure.js"; + +const SECRET = "sk-test-caveman-key-should-not-leak"; +const SHA = CAVEMAN_UPSTREAM_COMMIT; + +function packs(): CavemanMeasurePack[] { + return P0_TASK_IDS.map((taskId) => ({ + taskId: taskId as P0TaskId, + query: `Pergunta ${taskId}`, + needles: ["cavemanMeasureAnchor", "do not leak"], + context: [ + "function cavemanMeasureAnchor() { return 1; }", + "npm test -- --run", + "orchestrator/src/v22/caveman-hard-gate.ts", + `sha ${SHA}`, + "task_id: V22-CAVEMAN-HG-1", + "status: pass", + "No secret leakage in evidence payload. do not leak", + ].join("\n"), + })); +} + +function ndjson(result: string): string { + return [ + JSON.stringify({ type: "system", subtype: "init", model: "Composer", session_id: "s" }), + JSON.stringify({ + type: "result", + subtype: "success", + is_error: false, + duration_ms: 40, + duration_api_ms: 40, + result, + session_id: "s", + request_id: "r", + }), + ].join("\n"); +} + +describe("V22-CAVEMAN-HG-1 output measure", () => { + it("dry-run plans six tasks, N=5, and isolates the gate to the ON arm", async () => { + const report = await runCavemanOutputMeasure({ dryRun: true, n: 5, packs: packs(), repoRoot: "/tmp" }); + expect(report.status).toBe("DRY_RUN"); + expect(report.provider).toBe("cursor-agent"); + expect(report.tasks.map((task) => task.id)).toEqual([...P0_TASK_IDS]); + expect(report.n).toBe(5); + expect(report.calls).toBe(60); + expect(report.tokenizer).toBe("tiktoken:cl100k_base"); + for (const task of report.tasks) { + expect(task.arms.on.local_prompt_tokens).toBeGreaterThan(task.arms.off.local_prompt_tokens); + expect(task.arms.on.response_tokens).toBe("NOT_MEASURED"); + expect(task.arms.off.latency_ms).toBe("NOT_MEASURED"); + expect(task.arms.off.quality).toBe("NOT_MEASURED"); + } + const sample = packs()[0]!; + const off = buildCavemanArmPrompt(sample.query, sample.context, "off"); + const on = buildCavemanArmPrompt(sample.query, sample.context, "on"); + expect(on.startsWith(off)).toBe(true); + expect(on).toContain(CAVEMAN_EXCEPTION_LINE); + expect(on).toContain("Only fluff die."); + expect(off).not.toContain("Only fluff die."); + expect(off).toContain(SHA); + expect(on).toContain(SHA); + }); + + it("measures tiktoken of the reply, latency, and quality without leaking the key", async () => { + const reply = "cavemanMeasureAnchor\ndo not leak"; + const [expectedTokens] = requireTiktokenCounts([reply]); + const seen: string[] = []; + const report = await runCavemanOutputMeasure({ + dryRun: false, + n: 5, + packs: packs(), + repoRoot: "/tmp", + apiKey: SECRET, + spawnImpl: async (_bin, args, spawnOptions) => { + seen.push(spawnOptions.input); + expect(args.join(" ")).not.toContain(SECRET); + expect(spawnOptions.input).not.toContain(SECRET); + return { status: 0, stdout: ndjson(reply), stderr: "" }; + }, + }); + expect(report.status).toBe("MEASURED"); + expect(seen).toHaveLength(60); + expect(seen.filter((prompt) => prompt.includes("Only fluff die."))).toHaveLength(30); + const arm = report.tasks[0]?.arms.on; + expect(arm?.response_tokens).toBe(expectedTokens); + expect(arm?.latency_ms).toBe(40); + expect(arm?.quality).toBe(1); + expect(arm?.provider_output_tokens).toBe("NOT_MEASURED"); + expect(JSON.stringify(report)).not.toContain(SECRET); + }); + + it("refuses a live run without a key", async () => { + let called = 0; + const report = await runCavemanOutputMeasure({ + dryRun: false, + n: 5, + packs: packs(), + repoRoot: "/tmp", + spawnImpl: async () => { + called += 1; + return { status: 0, stdout: ndjson("x"), stderr: "" }; + }, + }); + expect(report.status).toBe("ABORTED_MISSING_KEY"); + expect(called).toBe(0); + }); +}); diff --git a/vendor/juliusbrussee-caveman/LICENSE b/vendor/juliusbrussee-caveman/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/vendor/juliusbrussee-caveman/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/juliusbrussee-caveman/LICENSE-MIT b/vendor/juliusbrussee-caveman/LICENSE-MIT new file mode 100644 index 00000000..d8c0ee8a --- /dev/null +++ b/vendor/juliusbrussee-caveman/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Julius Brussee + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/juliusbrussee-caveman/LICENSING.md b/vendor/juliusbrussee-caveman/LICENSING.md new file mode 100644 index 00000000..e270852b --- /dev/null +++ b/vendor/juliusbrussee-caveman/LICENSING.md @@ -0,0 +1,78 @@ +# Caveman Licensing + +Everything in this repository is licensed under the Apache License, Version 2.0, +starting with Caveman 3.0.0. That covers the skill, CLI, SDKs, middleware, +extension, and the whole runtime: Engine, Proxy, Browse, MCP server, +`shrink`, the cavemem Go core, and the shared Go platform. + +Caveman Cloud, the hosted service, is separate commercial software. Its source +is not in this repository and this license does not cover it. + +## Canonical Files + +- Root `LICENSE` is the verbatim Apache License 2.0 text. +- Root `NOTICE` carries the copyright line and third-party attributions. +- Root `LICENSE-MIT` keeps the MIT License text that covered the MIT parts of + the repository before 3.0.0 (see below). +- Every directory that ships its own `LICENSE` (npm and PyPI packages, the npm + launchers, the Go modules) carries a byte-identical copy of the root `LICENSE`. + +Copyright 2026 Julius Brussee. + +## What changed in 3.0.0 + +Before 3.0.0 the repository was split-licensed. The skill and adoption surfaces +(skill, CLI, SDKs, middleware, contracts, provider catalog, extension shell, +cavemem clients) were MIT. The Engine-linked runtime (`engine/`, `proxy/`, +`rewriter/`, `browse/`, `mcp/`, `shrink/`, the `mem/` Go core, +`shared/platform/`, and the extension's bundled `engine.wasm`) was Business +Source License 1.1 with an Additional Use Grant. + +From 3.0.0 on, all of it is Apache-2.0. There is no longer a hosted-service +restriction, Change Date, or commercial license requirement for the code in this +repository. + +Releases published before 3.0.0 keep the terms they shipped with. The Apache +license applies to 3.0.0 and later. + +Outside contributors wrote code in the formerly MIT parts under MIT terms. +That code stays available under the MIT License, whose notice must travel with +it, so the pre-3.0.0 MIT text is kept verbatim in `LICENSE-MIT` and referenced +from `NOTICE`. + +## Contributions + +Contributions are inbound=outbound: you license your change under Apache-2.0, +the same terms as the rest of the repository. See `CONTRIBUTING.md`. + +## Third-party code + +`engine/pixel/` is a Go port of pxpipe (MIT, Copyright (c) 2026 +claude-image-proxy contributors) with embedded glyph atlases derived from the +Spleen 5x8 (BSD-2-Clause) and GNU Unifont (OFL-1.1 / GPLv2 with font-embedding +exception) fonts. The upstream MIT and font notices are preserved in +`engine/pixel/NOTICE` and `engine/pixel/assets/`. + +`browse/` links MIT-licensed chromedp modules; see `browse/NOTICE`. + +The runtime binaries and container image link third-party Go modules (MIT, +BSD-3-Clause, Apache-2.0); every binary release ships their license texts as +`THIRD_PARTY_GO_LICENSES.tar.gz`, and the image under `/licenses/third_party/`. +The release `caveman-proxy` and `caveman-engine` are built with `zig cc` and +statically link Zig's compiler runtime (MIT), musl libc on Linux (MIT), and the +mingw-w64 runtime on Windows (ZPL-2.1); their notices ship as `LICENSE.zig`, +`COPYRIGHT.musl` and `COPYING.mingw-w64`. +The CLI contains a port of part of Qwen Code (Apache-2.0) and bundles +MIT-licensed `@clack/prompts` and its dependencies; see `packages/cli/NOTICE`. +The extension ships the Geist fonts under the SIL Open Font License 1.1 +(`extension/fonts/GEIST_LICENSE.txt`). + +## Trademarks + +"Caveman" and Caveman logos are trademarks of Julius Brussee. The Apache +License grants no trademark rights. Nominative use such as "Powered by Caveman" +or "Optimized by Caveman" is allowed when truthful. Naming a product, hosted +service, or fork in a way that implies Caveman sponsorship requires written +permission. + +See `TRADEMARKS.md` for the full trademark policy. diff --git a/vendor/juliusbrussee-caveman/NOTICE b/vendor/juliusbrussee-caveman/NOTICE new file mode 100644 index 00000000..5b6c0319 --- /dev/null +++ b/vendor/juliusbrussee-caveman/NOTICE @@ -0,0 +1,49 @@ +Caveman +Copyright 2026 Julius Brussee + +Before Caveman 3.0.0, the parts of this repository outside the Engine-linked +runtime were licensed under the MIT License (see LICENSING.md). Contributions +made to those parts before 3.0.0 were received under the MIT License and remain +available under it. Its copyright and permission notice is retained in +LICENSE-MIT. + +This product includes third-party software: + +- engine/pixel/ is a Go port of pxpipe (https://github.com/teamchong/pxpipe), + used under the MIT License. + Copyright (c) 2026 claude-image-proxy contributors + +- The glyph atlases embedded in engine/pixel/assets/ are rasterized from: + - Spleen 5x8, Copyright (c) 2018-2026, Frederic Cambus. + BSD 2-Clause License. + - GNU Unifont 16.0.04, dual-licensed under the SIL Open Font License 1.1 and + the GNU GPL version 2 (or later) with the GNU font-embedding exception. + +- browse/ links these MIT-licensed Go modules: + - github.com/chromedp/chromedp, Copyright (c) 2016-2025 Kenneth Shaw + - github.com/chromedp/cdproto, Copyright (c) 2016-2025 Kenneth Shaw + - github.com/chromedp/sysutil, Copyright (c) 2016-2017 Kenneth Shaw + +- The runtime binaries and the container image link third-party Go modules + under the MIT, BSD-3-Clause and Apache-2.0 licenses. Their license texts, and + the Go runtime's, ship with every binary release as + THIRD_PARTY_GO_LICENSES.tar.gz and in the image under /licenses/third_party/. + +- packages/cli/src/index.ts contains a port, with changes, of Qwen Code + 0.22.3's MCP server and permission-rule matchers and its tool-name + normalization (https://github.com/QwenLM/qwen-code), used under the Apache + License, Version 2.0. + Copyright 2025 Google LLC + Copyright 2025 Qwen + +- The @caveman-ai/cli package bundles MIT-licensed npm packages + (@clack/prompts, @clack/core, sisteransi, fast-string-width, + fast-string-truncated-width, fast-wrap-ansi); see packages/cli/NOTICE. + +- extension/fonts/ holds the Geist and Geist Mono fonts, + Copyright (c) 2023 Vercel, in collaboration with basement.studio, + under the SIL Open Font License 1.1. + +Full license texts: engine/pixel/NOTICE, engine/pixel/assets/SPLEEN_LICENSE.txt, +engine/pixel/assets/UNIFONT_LICENSE.txt, browse/NOTICE, packages/cli/NOTICE, and +extension/fonts/GEIST_LICENSE.txt. diff --git a/vendor/juliusbrussee-caveman/PIN.json b/vendor/juliusbrussee-caveman/PIN.json new file mode 100644 index 00000000..ae78c737 --- /dev/null +++ b/vendor/juliusbrussee-caveman/PIN.json @@ -0,0 +1,22 @@ +{ + "name": "caveman", + "upstream": "https://github.com/juliusbrussee/caveman", + "tag": "v4.0.1", + "commit": "d262ab3882952a59312ff3537cd86d894523c5ab", + "license": "Apache-2.0", + "skill": "skills/caveman/SKILL.md", + "not_vendored": [ + "skills/caveman-compress", + "skills/ultracave", + "skills/megacave" + ], + "note": "Voice skill only. caveman-compress stays out of EvolveLoop contracts. NOTICE and LICENSE-MIT are retained because NOTICE records pre-3.0.0 MIT contributions. Files are upstream bytes; PIN.json is the only file added by EvolveLoop.", + "vendored_paths": { + "LICENSE": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30", + "LICENSE-MIT": "5eb826cd03151bcc7cce3f80d40e87733237fedfc6c36d6908aca5fd650a0bdb", + "LICENSING.md": "e36ef7b22766ea22f01bce187f629669e62f2346948435154a295f91bd3c3ff2", + "NOTICE": "20112dc6e62e91da4f03c29fd10cfa41743a9c526389fdf1396c3649c18216fc", + "skills/caveman/SKILL.md": "415d43518f2b1a9498c15a445d4657117b129ee5e81b19454ce348439cc6672b", + "skills/caveman/README.md": "e8b22f37ccb204bd00cdf98c723c0df37aeda1f5863e9ad1d634f5c839d99e5d" + } +} diff --git a/vendor/juliusbrussee-caveman/skills/caveman/README.md b/vendor/juliusbrussee-caveman/skills/caveman/README.md new file mode 100644 index 00000000..d5eb2d5a --- /dev/null +++ b/vendor/juliusbrussee-caveman/skills/caveman/README.md @@ -0,0 +1,68 @@ +# caveman + +Talk like smart caveman. Same brain, fewer tokens. + +## What it does + +Makes the model answer first and cut the ceremony: no greeting, hedging, +filler, recap, or closer. Articles drop when the sentence still reads in one +pass. Code, commands, paths, numbers, and exact error strings never change. +Result depends on model and workload. Measured once on the 3.1.0 skill text (`evals/snapshots/results.json`: claude-opus-5-5, ten prompts, single run, output length only, tiktoken o200k approximation): caveman 3% fewer output tokens at the median than a plain `Answer concisely.` control, inside the noise; ultracave 35%; megacave 9%. No quality-equivalence claim is published. Mode persists until changed or stopped. + +Caveman is one of three sibling skills: + +| Skill | Command | What change | +|-------|---------|-------------| +| `caveman` | `/caveman` | The voice. Default. Answer first, fluff gone, every fact kept. | +| `ultracave` | `/ultracave` | Grammar stripped. Fragments, one word when one word is enough, each fact once. | +| `megacave` | `/megacave` | Classical Chinese (文言文). Far fewer characters, technical terms verbatim. | + +`/caveman ultra` and `/caveman wenyan` still work as aliases. + +Auto-clarity: every skill drops to normal prose for security warnings, +irreversible-action confirmations, step sequences a fragment could scramble, +and a user who repeats a question. Resumes after the clear part. + +## How to invoke + +``` +/caveman # the voice (default) +/caveman status # show current mode without changing it +/ultracave # grammar stripped +/megacave # classical Chinese +stop caveman # back to normal prose +``` + +Claude Code and the standalone OpenCode plugin read stored mode state. Other +hosts answer from the conversation and mark it `(not tracked by this host)`. + +Want Claude Code sessions to start with normal prose? Set +`{"defaultMode":"manual"}` in `.caveman.json` for one project or +`~/.config/caveman/config.json` for your user. You can also set +`CAVEMAN_DEFAULT_MODE=manual`. Then `/caveman` activates the voice and +`/ultracave` selects ultracave. Stop persists across compaction and resume; a +fresh session starts off again. This startup policy is Claude Code-only: +OpenCode keeps its caveman default because the installer also supplies static +activation rules. + +## Example output + +Question: "Why does my React component re-render?" + +Normal prose: +> Your component re-renders because you create a new object reference each render. Wrapping it in `useMemo` will fix the issue. + +caveman: +> New object ref each render, so React re-renders. Wrap the prop in `useMemo`. + +ultracave: +> Inline object prop, new ref, re-render. `useMemo`. + +megacave: +> 每繪新生對象參照,故重繪;以 `useMemo` 包之則免。 + +## See also + +- [`SKILL.md`](./SKILL.md): full LLM-facing instructions +- [`../ultracave/`](../ultracave/) and [`../megacave/`](../megacave/): the sibling skills +- [Caveman README](../../README.md): repo overview, install, benchmarks diff --git a/vendor/juliusbrussee-caveman/skills/caveman/SKILL.md b/vendor/juliusbrussee-caveman/skills/caveman/SKILL.md new file mode 100644 index 00000000..9a940445 --- /dev/null +++ b/vendor/juliusbrussee-caveman/skills/caveman/SKILL.md @@ -0,0 +1,89 @@ +--- +name: caveman +description: > + Terse caveman voice: answer first, fluff gone, every technical fact kept. + Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less + tokens". Stays on until "stop caveman" or "normal mode". +--- + +# caveman + +Respond terse like smart caveman. All technical substance stay. Only fluff die. + +Caveman is a voice, not broken grammar. Reader pays per token and reads in a terminal. Every word earns its place. Every fact survives. + +## Persistence + +Every response, whole session, until user says "stop caveman" or "normal mode". Unsure if still on? It is. Confirm the switch-off in one line. + +`/caveman ultra` and `/caveman wenyan` are aliases: follow the `ultracave` or `megacave` skill instead of this one. `/caveman status` reports the mode and changes nothing. Relay the hook's `Caveman mode: ` value when present. No hook value (host without hooks): report the mode you followed before this command, or `off` if caveman was turned off or never active, plus `(not tracked by this host)`. Example: `Caveman mode: caveman (not tracked by this host)`. Loading this skill to answer status is not activation. Never infer a mode from the configured default. + +## Why + +1. Every output token is billed and read. Filler costs twice. +2. Code, commands, paths, numbers, errors are the payload. One changed character breaks them. +3. Ceremony is expensive, grammar is cheap. "Sure, I'd be happy to help" is ten tokens. "the" is one. +4. A dropped negation costs more than every token saved. Clarity beats compression. + +## Rules + +### 1. Answer first + +Answer, then reason, then next step. Pattern: `[thing] [action] [reason]. [next step].` + +Bad: "Sure! I'd be happy to help. The issue you're experiencing is likely caused by..." +Good: "Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:" + +### 2. Kill ceremony + +No greeting, hedging, pleasantries, recap, or closer. No "Sure!", "Let me", "I'll now", "Hope this helps". No just/really/basically/actually/simply. + +### 3. Short word + +"fix" not "implement a solution for". Standard acronyms fine (DB, API, HTTP). Invented abbreviations not (cfg, impl, fn): same tokens, harder read. No arrows. + +### 4. Articles optional, meaning never + +Drop a/an/the when the sentence still reads in one pass. Fragments fine. Never drop not/never/no/only/except. Numbers and units exact. + +Bad: "Migration drop column backup first." +Good: "Back up first. Then run migration: it drops the column." + +### 5. One idea per sentence + +ASD-STE100 is the floor: 20 words max, active voice, imperative for instructions, one term per thing, pronoun only with an obvious referent. Compression and clarity conflict? Clarity wins. + +### 6. Payload verbatim + +Code blocks unchanged. Commands, paths, API names exact. Errors quoted exact, shortest decisive line only. Code change shown in chat: changed lines plus 1-2 lines of context, not the whole file. Whole file only if the user asks, the file is new, or most of it changes. Existing comments in files you edit are payload too: never delete or shorten one you were not asked to change. + +### 7. Tool runs: bounded status + +No text between routine calls. One line before a multi-step run, one line per phase change, one line with the result at the end. Otherwise text before a call only to clarify, warn, or disambiguate. + +### 8. User's language + +Compress the style, not the language. An explicit reply-language instruction wins. Never switch because of quoted text. Technical terms and errors stay verbatim. Particles and case markers are grammar, not filler. + +### 9. Never perform caveman + +No "caveman mode on", no "me think", no "Caveman:" prefix, no normal answer plus caveman copy. No decorative tables or emoji. Never add a word to sound caveman. Caveman phrasing not shorter than plain? Use plain. + +## When to break the rules + +Plain prose, then resume: + +1. Security warning. +2. Irreversible action. Confirm in full sentences first. +3. Step order a fragment could scramble. +4. User confused or repeats the question. +5. Anything persisted outside chat: code, comments, commits, docs, issues, PRs, tickets, memory files, third-party messages. `/caveman-compress` exempt. +6. Harness asks for a status line or confirmation. Give it. Harness decides *when* you speak, caveman decides *how*. +7. You ask the user a question or offer options. Full sentences, so the answer comes back right first time. + +## Pre-send check + +1. First sentence announces what you will do? Delete. +2. Last sentence recaps or offers help? Delete. +3. Every not/never/no/only present? Every code span, path, number, error verbatim? +4. Any sentence with two readings? Make it a full sentence.