Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 96 additions & 162 deletions .codex/skills/crpto/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,191 +1,125 @@
# CRPTO Skill

Use this skill when working inside `C:\Users\carlos\Documents\Paper_CRPTO`.
CRPTO is a standalone academic paper project for Conformal Robust
Predict-Then-Optimize in credit risk. The repository is public-facing, but the
paper champion artifacts are frozen.
Use this skill inside `C:\Users\carlos\Documents\Paper_CRPTO`. CRPTO is a
single-author IJDS paper and reproducibility bundle, not a production service.
Prefer simple code, frozen evidence, and one coherent manuscript claim.

## Required Context

Before structural work, read these files in order:
## Read First

1. `docs/ACADEMIC_CONTEXT.md`
2. `docs/SCOPE_AND_GOVERNANCE.md`
3. `docs/research/active_claims_2026-07-04.md`
4. `CONTRIBUTING.md`
5. `EXTRACTION_MANIFEST.md`
6. `configs/crpto_publication_targets.yaml`
7. `docs/research/README.md`

Use the local project context over generic habits. This is a single-author,
static-dataset, no-production academic repo. Keep code simple, functional, and
close to the existing style.

## Platform

- Work Windows-first in PowerShell.
- Prefer `uv run ...` for Python, Quarto, dbt, DVC, MLflow, pytest, and ruff.
- The local venv is `.venv/Scripts/python.exe`.
- Do not introduce Unix-only shell assumptions.

## Champion Rules

The current IJDS paper-facing body claim is the promoted pool93 finite-grid
frontier closure. It is a deterministic policy-grid re-evaluation over the
frozen upstream PD/calibration/conformal artifacts, not a retraining run.

- Terminal run tag:
`champion-reopen-2026-06-19__pool93__ijds-claim-bound-terminal`
- Body point source run:
`champion-reopen-2026-06-19__pool93__ijds-claim-micro-ext`
- Policy family: `claim_micro_ext_body_cap345`
- Policy mode: `capped_blended_uncertainty`
- Robust return: `$184,832.48`
- Return-floor surplus: `$14,367.94`
- `V(alpha=0.01)`: `0.035350`
- `Gamma_CP(alpha=0.01)`: `0.162616`
- Endpoint budget upper at `alpha=0.01`: `0.24508374`
- Markov cap at `alpha=0.01`: `0.34508374`
- Exact alpha violation: `0.0`
- Declared alpha-grid pass: `8/8`
- Consolidated frontier: `50,010` deduplicated semantic policies, `27,508`
eligible all-alpha above-floor policies.
- Terminal exact search: `37,068/37,068` all-alpha passers and `296,544`
completed exact candidate-alpha checks.

The frozen upstream baseline remains retained for provenance and as the
declared return floor:

- Run tag: `ijds-rebaseline-2026-06-07`
- Policy: `bound_aware_276k_economic_champion`
- Robust return: `$170,464.54`
- `V(alpha=0.01)`: `0.028875`
- `Gamma_CP(alpha=0.01)`: `0.187987`
- Exact pass: `True`
- Former robust region: `45/45`

The older run tag `paper-thesis-final-economic-2026-04-06` is historical
provenance only. Do not use it as the active body claim.

Never overwrite these frozen artifacts unless the user explicitly asks for a
champion rebuild:

Use Windows PowerShell and `uv run`. Do not introduce Unix-only workflow
assumptions.

## Active IJDS Policy

- Run tag:
`champion-reopen-2026-06-19__pool93__ijds-calibration-selected-endpoint28-v7`
- Exact conformal replay: target `alpha=0.10`, frozen used alpha `0.095`.
- Decision score: `q=(p+u)/2`.
- Risk tolerance: `tau=0.17`.
- Objective: point-PD expected net return; conformal `q` is the risk guardrail.
- Selector: nine round-number policies on November 2017; five satisfy full
budget, effective-PD, and deterministic `B_u<=0.28` screens. Outcomes are
stored separately from the 12-column selector frame.
- Audit: an outcome-free December replay selects the same policy; opening
outcomes afterward gives weighted default `0.145650` and miscoverage
`0.124925`, so stability is not reported as selected-set validity.
- Full OOT: 276,869 candidates, 308 funded, `$179,327.59` realized return,
`0.039375` weighted default, `0.036875` weighted miscoverage.
- `Gamma_CP=0.176102`, `Gamma_residual=0.088051`, endpoint `0.258051`.
- Markov sensitivity: threshold `0.574279` with probability bound `0.316228`
under weighted funded-set validity.
- Matched point-PD: `$196,369.14`, `0.118400` weighted default, endpoint
`0.921317`, threshold `1.237545`.

The exact paper-facing source is:

`models/experiments/champion_reopen/<run_tag>/portfolio/ijds_policy_governance.json`

A35--A40 provide exact-alpha, selector, temporal, grade, bootstrap, and matched
comparison evidence. The final selector does not read OOT outcomes, but prior
project development inspected the static OOT corpus. Say "retrospective
lockbox replay," not "preregistered," "prospective," or "untouched holdout."

Do not revive these as active claims: approximate alpha-0.01 scaling, `8/8`,
the 50,010-policy frontier, `0.345084`, capped/tail-selected policies, or OOT
outcome-selected hyperparameters.

## Frozen Provenance

Never overwrite the manifest-protected upstream or historical pool93 files:

- `models/pd_canonical.cbm`
- `models/pd_canonical_calibrator.pkl`
- `models/final_project_promotion.json`
- `models/conformal_policy_status.json`
- `data/processed/conformal_intervals_mondrian.parquet`
- `data/processed/portfolio_bound_aware/rank1_alpha01_bound_aware_276k_full_2026-04-05-1734/`
- `reports/crpto/tables/crpto_tableA35_pool93_ijds_frontier.csv`
- `reports/crpto/tables/crpto_tableA36_pool93_body_funded_grade_audit.csv`
- `reports/crpto/tables/crpto_tableA37_pool93_body_tail_risk.csv`
- `reports/crpto/tables/crpto_tableA38_pool93_body_cluster_bound_audit.csv`
- `reports/crpto/tables/crpto_tableA39_pool93_body_bootstrap_metrics.csv`
- `models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-claim-consolidated-definitive/portfolio/pool93_ijds_consolidated_governance.json`
- `models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-claim-bound-terminal/portfolio/pool93_ijds_claim_governance.json`
- historical `crpto_tableA35..A40_pool93_*` files
- historical pool93 governance JSON files
- `EXTRACTION_MANIFEST.json`

Protected DVC stages:

- Do not run without explicit permission: `crpto.portfolio.bound_exact_eval`
and any Optuna/HPO or policy search.
- Treat as protected revalidation stages: `crpto.pd.champion`,
`crpto.conformal.intervals`, `crpto.conformal.validation`, and
`crpto.portfolio.optimization`. If the user explicitly permits them, run them
as a drift check and validate hashes before/after.
- Safe paper stages: `crpto.paper.export_tables`, `crpto.paper.evidence`,
`crpto.paper.journal_package`, `crpto.paper.tail_satisficing_audit`,
`crpto.paper.figures`, `crpto.paper.spo_stability`, and `crpto.book.render`.

If the user says a change may touch the champion, isolate the work:

- Use a dedicated branch and a clear run label.
- Write new outputs under a new path; do not replace frozen champion files.
- Produce a drift report with expected tolerances.
- Run `just validate-champion` before and after.
- Do not update `EXTRACTION_MANIFEST.json` unless the user explicitly approves
a new frozen release.

## Current Journal Scope

The active paper scope is the IJDS pool93 certificate plus bounded diagnostics:

- A19/Fig15: regret-auditability frontier in the main narrative.
- A35: promoted pool93 finite-grid return-bound frontier.
- A36: funded-set grade composition audit for the selected pool93 allocation.
- A37: pool93 selected-allocation LGD/CVaR/OCE tail-risk repricing.
- A38: pool93 selected-allocation cluster-bound sensitivity; Markov remains
the body theorem because the cluster thresholds are not tighter here.
- A39: fixed-allocation bootstrap diagnostic; it does not resample model,
solver, conformal intervals or policy search.
- A20--A22: legacy tail-risk/OCE/CVaR diagnostic package retained in the
supplement, not as the promoted pool93 selector.
- A23--A24: multi-distribution/online coverage diagnostics, not universal
conditional-coverage claims.
- A25--A34: Prosper/Freddie external economic replication, not new Lending Club
champions.

Do not re-run champion search, HPO, conformal interval generation or protected
portfolio stages to support this pack. Use existing artifacts unless the user
explicitly asks for a new isolated experiment with a claim target, evidence
gate, artifact sink and stop rule.

## Objective Experiments

OCE/CVaR/satisficing can be implemented as an isolated research objective or
scoring layer. The default rule is:

- It may read existing allocations, predictions, intervals, or shortlist
artifacts.
- It may generate new diagnostic tables, figures, configs, tests, and docs.
- It must not replace the champion objective, rank-1 policy, or frozen outputs.
- A tail-satisficing challenger audit may read or re-score frozen allocations
under a new paper/audit stage if outputs are new and the status marks
`champion_promotion_changed=false`. It must not replace the A35 pool93 body
selector without a new promotion protocol.
- If used for a new search, store results under a new experiment path and make
the comparison explicit against the active pool93 body claim and the frozen
upstream rebaseline.

## Submission Closeout

For the current submission, keep these gates visible:

- Consolidate A19/Fig15, A20--A39, paper/supplement, docs, manifest hashes and
`dvc.lock`.
- Sweep the manuscript for stale numbers, captions, body-vs-appendix placement,
and IJDS length.
- Convert the final `.qmd` into the official IJDS LaTeX template when the PDF
is ready for submission.
- Keep GitHub/DagsHub/MLflow disclosure compatible with double-anonymous
review: anonymize in the manuscript, reveal in cover letter or after review
according to venue policy.
- Create the reproducible release tag/bundle only after the final PDF passes.
- Treat `dvc push` as optional and credential-dependent.

## Standard Checks

Use focused checks while editing, then close with the strongest feasible set:
New experiments must use a distinct run tag and write under
`data/processed/experiments/champion_reopen/` and
`models/experiments/champion_reopen/`. Never replace frozen paths.

Protected DVC stages are `crpto.pd.champion`,
`crpto.conformal.intervals`, `crpto.conformal.validation`,
`crpto.portfolio.optimization`, and `crpto.portfolio.bound_exact_eval`.
Experiments may read their outputs. Run a protected stage only with explicit
permission and a drift report.

## Method Boundary

The submitted method has one linear policy. Capped, tail, OCE/CVaR, SPO+,
multi-distribution, online, causal, and external-data variants are comparators
or diagnostics, not additional CRPTO methods.

Keep these distinctions explicit:

- exact conformal quantile replay versus approximate width scaling;
- point PD in the economic objective versus conformal `q` in the constraint;
- deterministic `weighted outcome <= B_u + V` versus the
assumption-conditional Markov statement;
- calibration-only final ranking versus historical OOT-aware development;
- full-OOT averages versus temporal heterogeneity;
- retrospective contrasts versus causal or universal dominance.

## Paper Workflow

Safe paper work may regenerate active A35--A40, figures, Quarto outputs, and the
official IJDS PDF. Keep body, supplement, submission TeX, governance JSON, and
claim-sync tests numerically aligned.

Standard closeout:

```powershell
uv run python scripts/build_crpto_journal_package.py
uv run pytest tests/test_publication_targets.py -q
uv run pytest tests/test_scripts/test_build_crpto_journal_package.py -q
uv run pytest tests/test_pool93_body_claim_sync.py -q
just smoke
uv run python scripts/build_ijds_calibration_selected_evidence.py
uv run pytest tests/test_ijds_active_claim_sync.py -q
just lint
just type-check
just type-advisory-full
just smoke
just validate-champion
just paper-submission
just paper-submission-official
uv run dvc status --no-updates
```

For a full milestone, also run `just test`, `just type-check`, and the relevant
Quarto render. Do not bypass hooks.
Run `just drift-gate` after changes to conformal or PD semantics. Do not bypass
hooks, commit secrets, or alter `EXTRACTION_MANIFEST.json`.

## Writing And Docs
## Writing

- Spanish for book, paper prose, and research notes.
- English for code, identifiers, CI, and docstrings.
- Do not reformat the whole book in one pass.
- Avoid broad refactors unless they directly reduce risk for the current task.
- Never commit secrets, `.env`, local credentials, or heavyweight raw data.
- Paper and code identifiers are English; project notes may be Spanish.
- Lead with data, method, decision, and managerial implication.
- Report the price of robustness and temporal failures as prominently as wins.
- Treat reproducibility as evidence quality, not as the sole novelty.
- Keep the main IJDS body within 25 pages; move proofs and diagnostics to the
separate supplement.
1 change: 1 addition & 0 deletions .github/workflows/tests-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
tests/test_features/ \
tests/test_crpto_final_sync.py \
tests/test_quarto_book_guardrails.py \
tests/test_publication_integrity.py \
-q

- name: Upload coverage if generated
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ models/feature_artifacts_runtime_status.json

# Reports (large generated outputs)
reports/run_logs/
reports/api-docs/
reports/ci/
reports/notebook_images/
reports/paper_material/
reports/crpto/experiments/
Expand Down Expand Up @@ -149,6 +151,9 @@ models/experiments/**
!models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-claim-bound-terminal/portfolio/pool93_ijds_claim_governance.json
!models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-claim-consolidated-definitive/portfolio/pool93_ijds_consolidated_governance.json
!models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-claim-consolidated-definitive/portfolio/pool93_ijds_consolidated_frontier.json
!models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-certificate-semantics-v2/portfolio/pool93_ijds_consolidated_frontier.json
!models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-certificate-semantics-v2/portfolio/pool93_ijds_consolidated_governance.json
!models/experiments/champion_reopen/champion-reopen-2026-06-19__pool93__ijds-certificate-semantics-v2/portfolio/pool93_point_pd_baseline_audit.json
configs/experiments/
!configs/experiments/
configs/experiments/*
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ repos:
stages: [pre-push]

- id: pytest-smoke
name: pytest smoke (final-sync + quarto guardrails)
entry: uv run pytest tests/test_crpto_final_sync.py tests/test_quarto_book_guardrails.py -q
name: just smoke (publication guardrails)
entry: just smoke
language: system
pass_filenames: false
stages: [pre-push]

- id: validate-champion
name: validate champion artefacts
entry: uv run python -c "import json; from pathlib import Path; m=json.loads(Path('EXTRACTION_MANIFEST.json').read_text()); print('manifest OK, keys:', len(m))"
entry: just validate-champion
language: system
pass_filenames: false
stages: [pre-push]
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Lectura obligatoria, en este orden:
1. [`CLAUDE.md`](CLAUDE.md) — reglas de operación, champion congelado
(esquema dual-tag pool93), stages prohibidos, comandos y convenciones.
2. [`docs/research/active_claims_2026-07-04.md`](docs/research/active_claims_2026-07-04.md)
— registro vigente de claims del paper (body point pool93, denominadores
finite-grid, reopen gate).
— registro vigente de claims del paper (replay exacto al 90%, selector de
calibración 3x3, política lineal 50/50 y reopen gate).
3. [`.codex/skills/crpto/SKILL.md`](.codex/skills/crpto/SKILL.md) — skill de
Codex con el detalle operativo del certificado y sus artefactos.

Expand Down
Loading