# Human-required Codex validation

> Historical Part 1 procedure. For the current v2 workflow and Windows `.cmd` command form, use [Codex integration](codex-integration.md) and [Getting started](getting-started.md).

This procedure validates the behavior of a real, freshly started Codex session. Run it in a disposable project outside the Reliora repository. Do not use production credentials or production databases.

The current automated environment can verify generated instructions and simulate every CLI action, but it cannot honestly prove that a separate real Codex session followed newly loaded `AGENTS.md` guidance. A human must complete and record this final product check.

## 1. Prepare a disposable project

Install the exact tarball under test globally, then create a project:

```bash
npm install -g ./reliora-0.1.0.tgz
mkdir reliora-codex-validation
cd reliora-codex-validation
reliora init --agent codex
```

Create `package.json`:

```json
{
  "name": "reliora-codex-validation",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node verify-migrations.mjs"
  }
}
```

Create `verify-migrations.mjs`:

```js
import { readFile, readdir } from "node:fs/promises";

for (const name of await readdir("migrations")) {
  const source = await readFile(`migrations/${name}`, "utf8");
  const alter = source.indexOf("ALTER TYPE");
  const update = source.indexOf("UPDATE invoices");
  const boundary = source.indexOf("-- RELIORA-COMMIT-BOUNDARY");
  if (alter !== -1 && update !== -1 && !(alter < boundary && boundary < update)) {
    throw new Error(`${name}: enum change and data update require the project commit-boundary marker`);
  }
}

console.log("migration verification passed");
```

Create `migrations/task-a.sql`:

```sql
ALTER TYPE invoice_status ADD VALUE IF NOT EXISTS 'archived';
UPDATE invoices SET status = 'archived' WHERE cancelled_at IS NOT NULL;
```

Confirm `npm test` fails. Confirm `reliora agent status` reports `codex`, `current`, and no conflict.

## 2. Task A: learn a new project-specific lesson

Start a new Codex session in this disposable project so it loads `AGENTS.md`. Give exactly this task:

```text
Fix the failing migration verification in this disposable project and run the relevant tests. Follow the project instructions. Do not use any production credentials or external services.
```

Expected observable behavior:

1. Codex searches Reliora because this is a migration failure; no relevant experience exists yet.
2. Codex inspects the verifier, inserts `-- RELIORA-COMMIT-BOUNDARY` between the two statements, and runs `npm test` successfully.
3. Codex recognizes the non-obvious project convention as reusable validated experience and records it through stdin.
4. Codex briefly says that no prior experience applied and that it saved a validated project-specific lesson. It does not dump JSON or internal reasoning.

Verify independently:

```bash
reliora search "migration commit boundary enum" --json
```

There must be a newly recorded experience with the project convention, reproducible `npm test` verification, bounded applicability, and no secrets.

## 3. Task B: reuse and rate the lesson

Create `migrations/task-b.sql`:

```sql
ALTER TYPE invoice_status ADD VALUE IF NOT EXISTS 'review';
UPDATE invoices SET status = 'review' WHERE review_requested_at IS NOT NULL;
```

Give Codex exactly this second task:

```text
Fix the new failing migration verification and run the relevant tests. Follow the project instructions and verify whether prior project experience applies.
```

Expected observable behavior:

1. Codex searches the top three Reliora results and finds the Task A experience.
2. It checks the current verifier and migration before applying the experience.
3. It inserts the boundary marker, runs `npm test`, and sends success feedback only for the experience actually used.
4. It briefly says that the prior experience applied and feedback was recorded.
5. It does not create a duplicate lesson merely because the same convention was reused.

Verify independently by searching for the experience ID and running:

```bash
reliora show <id> --json
```

`feedback.successes` must be at least `1`. Finally run:

```bash
reliora agent remove
reliora agent status
reliora show <id>
```

The managed block must be gone, the integration must report not installed, and the experience must still exist. Delete the disposable project when the evidence has been recorded.

## Pass/fail record

Record the date, Codex surface/version, operating system, tarball hash, Task A outcome, Task B outcome, experience ID, feedback count, and any unexpected behavior in `docs/agent-integration-part-1.md`. Until a human fills in that evidence, external real-agent validation remains pending rather than silently simulated.
