# Model Extraction Workflow

This workflow is the required gate sequence for extracting or repairing cognitive model assets.

## Stage 0: GPT Plan Intake

Input from user:

- GPT planning document path
- Source article paths
- Existing model or application material paths
- Target model IDs
- Whether placeholder evidence is allowed
- Whether the goal is rules only, content extraction, or full chain

Codex output:

- Local execution plan
- Open questions
- Owner review gate

## Stage 1: Rules, Schema, Index, And Workflow Foundation

Codex actions:

- Convert GPT planning document into local rules.
- Define or update schemas.
- Define or update indexes.
- Define workflow gates.
- Define validation expectations.

Output:

- Rules docs
- Schema files
- Index contracts
- Workflow docs
- Difference report

Owner confirmation:

- The project owner reviews rules, schemas, indexes, and workflow before content extraction.

## Stage 2: Source And Evidence Preparation

Codex actions:

- Register source articles.
- Extract source evidence excerpts.
- Mark placeholder evidence explicitly if source text is unavailable or insufficient.

Output:

- `sources/source_articles.json`
- `sources/source_excerpts.json`

Checks:

- Every excerpt references a known source article.
- Every source ID is unique.
- Placeholder evidence is not treated as verified evidence.

## Stage 3: Model Asset Extraction

Codex actions:

- Write machine-readable model JSON.
- Write human-readable Markdown card.
- Update model and card indexes.

Output:

- `models/<model_id>.model.json`
- `cards/<model_id>.md`
- `models/model_index.json`
- `cards/card_index.md`

Checks:

- JSON passes schema.
- Markdown card contains required sections.
- Source references resolve.
- Index entries match model and card files.

## Stage 4: Regression And Selector Preparation

Codex actions:

- Write at least five regression cases per core model.
- Include positive, boundary, and misuse cases.
- Add selector rules and selector examples.

Output:

- Regression case files or consolidated regression case JSON.
- Selector rules.
- Selector examples.

Checks:

- Every core model has at least five cases.
- Each model has positive, boundary, and misuse cases.
- Selector examples return model IDs and reasons.

## Stage 5: Validation And Audit

Codex actions:

- Run local validation scripts.
- Generate validation report.
- Generate extraction audit report.

Output:

- `reports/validation_report.md`
- `reports/<model_id>_extraction_audit.md` or session-level audit report.

## Stage 6: Owner Review

Owner reviews:

- Model definition
- Field completeness
- Evidence quality
- Boundary and misuse cases
- Selector behavior
- Open questions

Content is not considered stable until owner review completes.

## Workflow Rule

Do not repair or expand model content before Stage 1 foundation is implemented and reviewed, unless the project owner explicitly overrides the gate.
