# CLAUDE.md — Wikifita

Alefita's persistent memory. Shared knowledge base across all projects.

## What is Wikifita

Wikifita is not a conventional wiki. It is a **persistent memory layer** that:
- Boots with the session and persists across sessions
- Is shared across all projects and agents
- Follows OKF (Open Knowledge Format) for consistency
- Has constitutional directives governing artifact production
- Has structured memories (global + per-project) in `memorias/`

## OKF v0.1 Conventions

Every page follows the Open Knowledge Format:
- `type` (required): Nature of the concept
- `title`: Human-readable title
- `description`: One-line summary
- `tags`: List for cross-indexing
- `timestamp`: ISO 8601

## Structure

```
wikifita/
├── index.md          ← Global index with tags
├── log.md            ← Chronological log
├── CLAUDE.md         ← This file
├── AGENTS.md         ← Relative symlink to CLAUDE.md
├── .githooks/        ← Versioned integrity hooks
├── scripts/          ← PEP 723 scripts (uv run)
│   ├── install_hooks.py
│   └── wikifita_audit.py
├── memorias/         ← Shared memory
│   ├── MEMORY.md     ← Memory index
│   ├── user_alefita.md
│   ├── feedback/
│   └── projetos/
├── diretivas/        ← Constitutional rules
│   ├── identidade-visual.md
│   ├── preferencias-tecnicas.md
│   ├── artefatos/
│   └── design-systems/
├── ai_modelos/       ← DeepSeek, MiMo, LiteLLM
├── infraestrutura/   ← Docker, Gateway, Hardware
├── claude_desktop/   ← Reverse engineering, ASAR, bundles, voice
├── mcp/              ← Model Context Protocol
├── hacks/            ← Kickbacks, Antigravity, Hermes
├── fitdnuvo/         ← Denuvo security research
├── kaggle/           ← Agent security competition
├── clickfix/         ← ClickFix APT threat intelligence
└── pesquisas/        ← Papers, hypersigil, multi-agent
```

## Branch Model

| Branch | Purpose | Deployed | Content |
|---|---|---|---|
| `main` | Public knowledge base + site content | Yes → wikifita.aleffita.dev | Technical documentation, research, forensics, infrastructure |
| `personal` | Private notes, correspondence, sensitive references | No | Emails, salary negotiations, personal contacts, internal decisions |

**Rule:** Anything on `main` is potentially visible on the public site. Sensitive content goes on `personal`. Never merge `personal` to `main` without explicit review and sanitization.

## Site Pipeline

The wikifita repo serves as both internal knowledge base and source for the public-facing site at `wikifita.aleffita.dev` (Next.js). Pushes to `main` trigger automatic site rebuild. See [[wikifita-site]] for full documentation.

## Gitflow — ENFORCED

- **Mandatory commits** after every significant change
- **Pre-commit hook:** runs full audit and blocks commits on inconsistencies
- **Post-checkout/post-merge hooks:** run `uv run scripts/wikifita_audit.py --fix` to reconcile `AGENTS.md -> CLAUDE.md`
- **Versioned hooks:** `.githooks/`, activated via `core.hooksPath=.githooks`
- **Idempotent setup:** in new environments, run `uv run scripts/install_hooks.py` or validate with `uv run scripts/install_hooks.py --check`
- **NEVER** use `git commit --no-verify` — hooks exist for a reason
- Semantic commit messages: `feat:`, `fix:`, `docs:`, `chore:`

## Rules

- OKF frontmatter required on every page
- Canonical documents can be `.md` or `.mdx`; raw content must be preserved without arbitrary re-serialization
- MDX is restricted to controlled documentary components; external renderers must sanitize HTML/JSX and deny arbitrary execution
- Rich media enters via secure remote URL in Markdown/MDX (image, video, audio, transcript or allowlisted embed); at this stage there is no `/assets`, local manifest, upload, bucket or automatic ingest
- Tags enable cross-index queries
- `index.md` and `log.md` are reserved filenames (OKF)
- Everything committed — git is the persistence layer
- Never use regex for bulk operations — treat each file individually
- Audit periodically with `uv run scripts/wikifita_audit.py`; audit validates `.md`, `.mdx`, wiki/markdown links, media URLs, and `AGENTS.md -> CLAUDE.md` symlinks
- `CLAUDE.md` is canonical; every corresponding `AGENTS.md` is a relative symlink to it
- If an agent recognizes a materially harmful or unauthorized action serious enough to warrant a formal apology, stop ongoing harm, disclose it to Alefita immediately, and obtain her judgment before remediation. Use only preauthorized channels and authority. Identity-compromise and imminent-catastrophe edge cases follow [[human_principal_escalation]].

## Directives

Before producing any artifact, read `diretivas/`:
- `human_principal_escalation.md` — disclosure-before-remediation, identity compromise, safe-state containment, and authority limits
- `identidade-visual.md` — Anthropic dark mode as default
- `preferencias-tecnicas.md` — uv, PEP 723, artifacts, hardware
- `artefatos/padrao-pdf.md` — PDF standard
- `protocolo-re-e-probes.md` — dogmas insubordináveis de RE e segurança: RE antes de chamada, fluxo como todo, 3 tentativas, anti-reward-hacking

## Probes

Research probes (executáveis de exploração/validação contra serviços externos) são cidadãos de primeira classe da wikifita:

- **Código versionado fora, documentação dentro**: o source das probes vive no repositório do projeto onde rodam (ex.: `deepseek-harness/scripts/probes/`), e a wikifita documenta metodologia, resultados, logs relevantes e lições — cruzando por links relativos para o path do código
- **Page de probes por pesquisa**: cada linha de pesquisa mantém uma page `probes.md` no seu diretório (ex.: `openai-research/probes.md`) com inventário, resultados por tentativa e pontos abertos
- **Rich media**: logs (trechos sanitizados), screenshots e capturas entram como arquivos referenciados por path local ou URL remota; valores sensíveis (tokens, cookies, ids de conta) NUNCA são commitados — sempre mascarados (`prefix…(n chars)`)
- **Ciclo disciplinado**: RE 100% antes da primeira chamada; máximo 3 tentativas por ciclo; falha = volta pra RE; nunca assumir intermitência sem prova
- **Disclosure**: pesquisas contra serviços de terceiros documentam o plano de disclosure responsável na page hub da pesquisa

## Commit attribution

- `Co-Authored-By` MUST be the model that actually did the work in the commit (e.g. `DeepSeek <noreply@deepseek.com>`). Never hardcode another model's name; when in doubt, use the agent/model that produced the change.

## Note for agents

- **PAGES ARE NEVER ONE-SHOT. Every page created or materially changed gets AT LEAST 3 refinement iterations** (write → re-read against sources → correct/extend → repeat), plus an explicit cross-reference net (hub/dependent pages) before it is considered done. A page written once and committed is not finished.
- **Never write from memory alone. Any analysis, postmortem, or "lessons" page MUST be built from primary data first** (transcripts, bezetacil logs, captured payloads) — read the data, then draft; refine by re-reading. Inventing timelines, quotes, or payload values is a failure, not a shortcut.
- **Wikifita is consolidation, not planning.** Only consolidated facts go here — no open specs, proposals, RFCs, TODO lists or "alternatives" (this reuses the errors of past sessions). Implement first, then document the result.
- **Curation is the AGENTS' job, not Alefita's.** Agents own: add, edit, review, reconcile, and *continuously re-curate*. Alefita coordinates only. Never assume a page is done because it exists.
- **Integrate, never dump.** Before writing a page or a fact: (1) read what already exists on the topic (all pages it touches); (2) cross-reference the new evidence against the old claims — every old claim that the new evidence refines, corrects, or contradicts MUST be updated in place (or superseded with an explicit, dated note at the top of the *whole* page, not buried mid-page); (3) update dependent pages (hubs, statuses, "open items" lists, cross-references). A fact has no owner-page: it lives in every page that touches it.
- **Every "not observed / unknown" statement carries its scope**: which flow (A / A1 / B…), which surface (main / rust / renderer), which evidence, and what remains untested. Never generalize a local observation into a global law.
- After a change: re-read the touched pages as a stranger would and confirm nothing else in the wiki now contradicts them (immediately, not later).
- **Alefita often sends messages via speech-to-text (PT)**. Typos, transcription artifacts, and rephrasings are expected — infer intent from context and do not correct her writing. Read [memorias/user_alefita.md](memorias/user_alefita.md) to know who she is (never impersonate her, never role-play her) — when a dictated instruction is ambiguous, ask rather than guess.

## Memory

`memorias/` contains structured memory:
- `user_alefita.md` — global profile (NEVER in projects)
- `feedback/` — preferences and corrections
- `projetos/` — per-project memories
