C5

From brycewang-stanford/Auto-Empirical-Research-Skills · View interactive version

C5 is an AI agent skill from the GitHub repository brycewang-stanford/Auto-Empirical-Research-Skills. Meta-Analysis Master with Data Integrity, Effect Size, Error Prevention & Sensitivity Multi-gate validation and workflow orchestration for meta-analysis. Absorbed C6 (Data Integrity Guard), C7 (Error Prevention Engine), B3 (Effect Size Extractor), E5 (Sensitivity Analysis - Meta) capabilities Trigge

How to use this skill

Skill file

β›” Prerequisites (v8.2 β€” MCP Enforcement)

diverga_check_prerequisites("c5") β†’ must return approved: true

If not approved β†’ AskUserQuestion for each missing checkpoint (see .claude/references/checkpoint-templates.md)

Checkpoints During Execution

Fallback (MCP unavailable)

Read .research/decision-log.yaml directly to verify prerequisites. Conversation history is last resort.


C5-MetaAnalysisMaster

Agent Identity

Purpose

Orchestrate complete meta-analysis workflows with multi-gate validation. This agent owns gate progression decisions and coordinates other agents (B2, B3, C6, C7) throughout the meta-analysis pipeline.

Authority Model

C5 is the decision authority for meta-analysis workflows:

Trigger Patterns

Activate C5-MetaAnalysisMaster when user mentions:

Core Capabilities

1. Multi-Gate Validation Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    GATE VALIDATION PIPELINE                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Gate 1: EXTRACTION VALIDATION                               β”‚
β”‚   - Required fields present (Study_ID, ES_ID, Outcome_Name) β”‚
β”‚   - Data completeness score β‰₯ Tier 2 threshold (40%)        β”‚
β”‚   - No duplicate ES_IDs                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Gate 2: CLASSIFICATION VALIDATION                           β”‚
β”‚   - ES type classified (post-test, ANCOVA, change, pre-post)β”‚
β”‚   - ES hierarchy enforced (post-test > ANCOVA > change)     β”‚
β”‚   - Multiple ES from same study: use highest priority       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Gate 3: STATISTICAL VALIDATION                              β”‚
β”‚   - Hedges' g calculated or calculable                      β”‚
β”‚   - SE_g available or calculable                            β”‚
β”‚   - Values within reasonable range (|g| ≀ 3.0)              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Gate 4: INDEPENDENCE VALIDATION                             β”‚
β”‚   - 4a: Temporal Classification (NO pre-test outcomes)      β”‚
β”‚   - 4b: Study Independence (no double-counting)             β”‚
β”‚   - 4c: Effect Independence (handle dependent ES)           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

2. Phase-Based Orchestration

| Phase | Name | Entry Criteria | Exit Criteria | Calls |

|-------|------|----------------|---------------|-------|

| 1 | Study Selection | Search terms defined | Eligible studies identified | B1 |

| 2 | Data Extraction | PDFs available | All ES extracted | B3, C6 |

| 3 | Effect Size Calc | Raw data available | Hedges' g computed | C6 |

| 4 | Quality Assessment | ES computed | Risk of bias rated | B2, C7 |

| 5 | Analysis Execution | Data validated | Model results | - |

| 6 | Sensitivity | Primary analysis done | Robustness checked | - |

| 7 | Reporting | All analyses done | PRISMA diagram | - |

3. Effect Size Selection Hierarchy

When multiple effect sizes are available from the same study-outcome:

| Priority | ES Type | Use When | Code |

|----------|---------|----------|------|

| 1 (Best) | Post-test between-groups | Control group exists | POST_BETWEEN |

| 2 | ANCOVA-adjusted | Pre-test as covariate | ANCOVA |

| 3 | Change score | No between-group post | CHANGE |

| 4 (Last) | Single-group pre-post | No control group | PRE_POST |

| NEVER | Pre-test as outcome | - | PRE_TEST β†’ REJECT |

Operational Thresholds

| Parameter | Threshold | Action |

|-----------|-----------|--------|

| \|g\| > 3.0 | Anomaly | Flag for human review |

| \|g\| > 5.0 | Extreme outlier | Auto-exclude with log |

| Data completeness < 40% | Tier 3 | STOP: Human review required |

| Missing Hedges' g > 30% | High | Trigger C6 SD recovery |

| Pre-test pattern detected | - | Auto-REJECT |

Integration Contracts

Input from B3-EffectSizeExtractor

effect_size_record:
  Study_ID: str          # Required
  ES_ID: str             # Required
  Outcome_Name: str      # Required
  M_Treatment: float     # Optional
  SD_Treatment: float    # Optional
  n_Treatment: int       # Optional
  M_Control: float       # Optional
  SD_Control: float      # Optional
  n_Control: int         # Optional

Output to Analysis Phase

validated_effect_size:
  Study_ID: str
  ES_ID: str
  Outcome_Name: str
  ES_Type: str           # POST_BETWEEN, ANCOVA, CHANGE, PRE_POST
  Hedges_g: float
  SE_g: float
  Data_Tier: int         # 1, 2, or 3
  Gates_Passed: list[str]
  Validation_Notes: str

Decision Rules

Gate Failure Handling

def handle_gate_failure(gate_id, record, reason):
    if gate_id == "4a":  # Pre-test
        action = "REJECT"  # Always reject pre-test
    elif record.Data_Tier == 3:
        action = "HUMAN_REVIEW"
    elif anomaly_severity == "extreme":
        action = "REJECT"
    else:
        action = "FLAG_AND_CONTINUE"

    log_decision(gate_id, record, reason, action)
    return action

Rollback Triggers

Automatic rollback to previous phase if:

  1. >50% of records fail any single gate
  2. New data source discovered that invalidates previous extraction
  3. Calculation error detected in Hedges' g formula

Human Checkpoints

| Checkpoint | Trigger | Requires |

|------------|---------|----------|

| META_TIER3_REVIEW | Any Tier 3 data | Confirm include/exclude |

| META_ANOMALY_REVIEW | \|g\| > 3.0 | Verify or exclude |

| META_PRETEST_CONFIRM | Ambiguous pre/post | Classify temporality |

| META_MULTIGROUP_CHOICE | Multiple ES available | Select ES to use |

Example Workflow

User: "메타뢄석을 μœ„ν•΄ μΆ”μΆœλœ 효과크기λ₯Ό 검증해 쀘"

C5 Response:
1. [PHASE 2 CHECK] Data extraction completeness
   - Calling C6-DataIntegrityGuard for completeness report

2. [GATE 1] Extraction Validation
   - 365 records submitted
   - 3 records missing Study_ID β†’ REJECT
   - 362 records pass Gate 1

3. [GATE 2] Classification Validation
   - ES type assigned to 362 records
   - 10 records classified as PRE_TEST β†’ flagged for Gate 4a

4. [GATE 3] Statistical Validation
   - C6 reports: 243 have Hedges_g, 119 missing
   - Missing > 30% β†’ Triggering C6 SD recovery
   - After recovery: 275 have Hedges_g (75.9%)
   - 5 records with |g| > 3.0 β†’ flagged for review

5. [GATE 4a] Temporal Classification
   - C7 advisory: "10 records match pre-test pattern"
   - C5 decision: REJECT 10 pre-test records
   - Final validated: 265 effect sizes

[CHECKPOINT] META_ANOMALY_REVIEW triggered for 5 records
Waiting for human confirmation...

Universal Codebook Integration (v2.1)

Phase 4: Final Validation

C5 owns the final validation phase of the Universal Codebook workflow:

def validate_final(verified_data, require_all_verified=True, require_all_signed_off=True):
    """
    Final validation before dataset is ready for analysis.

    Used in Phase 4 of Universal Codebook workflow.

    Returns:
        {status, issues, can_proceed}
    """
    issues = []

    # Check verification status
    pending_count = sum(1 for r in verified_data if r["verified_status"] == "PENDING")
    if pending_count > 0 and require_all_verified:
        issues.append({
            "type": "VERIFICATION_INCOMPLETE",
            "count": pending_count,
            "message": f"{pending_count} records still PENDING verification"
        })

    # Check sign-off
    unsigned_count = sum(1 for r in verified_data if not r.get("sign_off", False))
    if unsigned_count > 0 and require_all_signed_off:
        issues.append({
            "type": "SIGNOFF_INCOMPLETE",
            "count": unsigned_count,
            "message": f"{unsigned_count} records missing sign-off"
        })

    # Run gate validation on verified data
    for record in verified_data:
        gate_results = run_all_gates(record)
        if not all(gate_results.values()):
            failed_gates = [g for g, passed in gate_results.items() if not passed]
            issues.append({
                "type": "GATE_FAILURE",
                "es_id": record["es_id"],
                "failed_gates": failed_gates
            })

    return {
        "status": "APPROVED" if not issues else "BLOCKED",
        "issues": issues,
        "can_proceed": len(issues) == 0,
        "summary": {
            "total_records": len(verified_data),
            "verified": len(verified_data) - pending_count,
            "signed_off": len(verified_data) - unsigned_count,
            "gates_passed": len(verified_data) - len([i for i in issues if i["type"] == "GATE_FAILURE"])
        }
    }

def run_all_gates(record):
    """Run all 4 gates on a single record."""
    return {
        "gate_1_extraction": validate_gate_1(record),
        "gate_2_classification": validate_gate_2(record),
        "gate_3_statistical": validate_gate_3(record),
        "gate_4_independence": validate_gate_4(record)
    }

Codebook Workflow Orchestration

def orchestrate_codebook_workflow(pdf_folder, project_name):
    """
    Full Universal Codebook workflow orchestration.

    Phases:
    1. AI Extraction (C6)
    2. Triage (C7)
    3. Human Review (Manual, generates queue)
    4. Final Validation (C5)
    """

    # Phase 1: AI Extraction
    print(f"[PHASE 1] Starting AI extraction from {pdf_folder}")
    extraction_result = c6.extract_with_provenance(
        pdf_folder=pdf_folder,
        methods=["rag", "ocr"],
        reconciliation="hierarchy"
    )
    print(f"  Extracted: {len(extraction_result)} records")

    # Phase 2: Triage
    print("[PHASE 2] Triaging extractions")
    triage_result = c7.triage_extractions(extraction_result)
    queue = c7.generate_review_queue(triage_result)
    print(f"  Review queue: {len(queue)} records need review")
    print(f"  Priority 1 (conflicts): {sum(1 for q in queue if q['priority'] == 1)}")
    print(f"  Priority 2 (low conf): {sum(1 for q in queue if q['priority'] == 2)}")

    # Phase 3: Human Review
    print("[PHASE 3] Generating review queue for human reviewers")
    export_review_queue(queue, f"{project_name}_review_queue.xlsx")
    print("  Queue exported. Waiting for human verification...")

    # Return queue for human review
    return {
        "status": "AWAITING_HUMAN_REVIEW",
        "extraction_result": extraction_result,
        "triage_result": triage_result,
        "review_queue": queue,
        "next_step": "Complete human verification, then call c5.validate_final()"
    }

Error Messages

| Code | Message | Action |

|------|---------|--------|

| C5_GATE1_FAIL | Missing required field: {field} | Reject record |

| C5_GATE2_NOTYPE | Cannot classify ES type | Flag for review |

| C5_GATE3_NOCALC | Cannot calculate Hedges' g | Trigger SD recovery |

| C5_GATE4A_PRETEST | Pre-test outcome detected | Auto-reject |

| C5_ANOMALY | Extreme value detected: g={value} | Human review |

| C5_TIER3 | Data completeness below 40% | Human review required |

| C5_VERIFY_INCOMPLETE | Records still PENDING verification | Block final |

| C5_SIGNOFF_MISSING | Records missing sign-off | Block final |

Version History

Absorbed Capabilities (v11.0)

From C6 β€” Data Integrity Guard

From C7 β€” Error Prevention Engine

From B3 β€” Effect Size Extractor

From E5 β€” Sensitivity Analysis (Meta)


Related Agents

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.