Skip to content

fix(audit): v4.1.0 — cortex audit hardening - #83

Merged
fermonterom merged 1 commit into
mainfrom
fix/cortex-audit-20260704
Jul 4, 2026
Merged

fix(audit): v4.1.0 — cortex audit hardening#83
fermonterom merged 1 commit into
mainfrom
fix/cortex-audit-20260704

Conversation

@fermonterom

Copy link
Copy Markdown
Owner

Origen

Auditoría multi-agente read-only del sistema Cortex vivo (workflow cortex-audit, 50 agentes, verificación adversarial). 40 hallazgos brutos → 34 confirmados / 6 refutados. Este PR aterriza los fixes de motor; la higiene de datos vivos se aplicó por separado en ~/.claude/cortex (no versionado).

Fixed (P1)

  • session-start.py: load_laws() inyectaba solo la 1ª línea de cada ley (split('\n')[0]), perdiendo checklists/exclusiones multilínea. Ahora inyecta el texto completo (cap 1000c).
  • session-learner.js: el tombstone gate ahora descarta proposals cuyo trigger (no solo id) ya figura como rejected en proposals-history.jsonl → el backlog deja de reciclar basura.
  • reflexes: re-habilitado python3-bypass-write-tool (seguridad, estaba disabled); endurecido el regex de bash-cat-use-read con negative-lookahead (pipes/heredocs).
  • storage-rotation.js: cross-day-tracker.jsonl se poda al superar 1.5× su umbral aunque el gate de 24h no haya vencido.

Added (P2)

  • storage-rotation.js: limpieza de .lock/.bak >30d, retención impact.archive/ (keep 5), rotación log/timeline.jsonl (keep 1000).
  • distill_engine.py: prune_instinct_tracking() + reap_stale_nudge_state() enganchados al pipeline de maintain + subcomandos CLI.
  • session-learner.js: dedup de trigger duplicado, normalización $HOME~, sampling head+tail (en vez de corte duro a 200c).
  • injector-engine.js: presupuesto de sesión 8000→12000 con warning visible (antes silencioso), filtro opcional domains por reflex (no-op si ausente).

Rechazado como falso positivo (criterio de coordinación, ver CHANGELOG)

  1. Mover 5 instincts scope: global a dirs de proyecto — el audit confundió project_id (procedencia) con scope (targeting). Son patrones cross-project trigger-gated; se quedan globales.
  2. Bajar NUDGE_MAX_CONF 0.99→0.80 — haría inalcanzable conf≥0.95 para la auto-promoción a ley. El problema real (cementado) lo resuelve reap_stale_nudge_state.
  3. Endurecer el dedup por dominio — la excepción gap>0.10 daba comportamiento incoherente (mantenía un instinct de baja confianza si el gap era grande). Revertido.

Verificación

  • Suite completa verde: test pair (test_security 9/9, test_dream_cycle 40/40) + todos los módulos tocados (distill 46/6, session_learner 60, storage 51, injector 29/13, session_start 4) + run_all.sh exit 0, cero suites con fallo.
  • Desplegado en local vía install.sh (v4.0.0→v4.1.0) y verificado end-to-end.
  • Datos vivos aplicados: 5 leyes truncadas regeneradas, meta-broad archivada (15→14 leyes), 8 proposals rejected purgadas, tracking 219→175, 4 nudges stale reapeados.

🤖 Generated with Claude Code

Multi-agent read-only audit of the live system surfaced 34 verified findings
(6 refuted). This lands the engine fixes; live-data hygiene applied separately.

Fixed (P1):
- session-start.py: inject full law text (cap 1000c), not just the first line
- session-learner.js: tombstone gate matches by trigger vs proposals-history
- reflexes: re-enable python3-bypass-write-tool; harden bash-cat-use-read regex
- storage-rotation.js: cross-day-tracker prunes past 1.5x threshold despite 24h gate

Added (P2):
- storage-rotation.js: stale .lock/.bak cleanup, impact.archive keep=5, timeline rotation
- distill_engine.py: prune_instinct_tracking() + reap_stale_nudge_state() + CLI
- session-learner.js: dup-trigger dedup, $HOME->~ paths, head+tail sampling
- injector-engine.js: token budget 8000->12000 + visible warning, per-reflex domains filter

Rejected as misdiagnoses (see CHANGELOG): moving scope:global instincts to project
dirs; lowering NUDGE_MAX_CONF (breaks law promotion); tightening dedup (reverted).

Full suite green (test pair + all module suites). Deployed locally via install.sh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@fermonterom
fermonterom merged commit 43239a2 into main Jul 4, 2026
11 checks passed
@fermonterom
fermonterom deleted the fix/cortex-audit-20260704 branch July 4, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant