Turn any AI agent into an AI Scientist. The #1 Agent Skills library for science, used by 250,000+ scientists worldwide. 177 ready-to-use validated skills plus 100+ scientific databases covering biology, chemistry, medicine, and drug discovery. Compatible with Cursor, Claude Code, Codex, Pi, Antigravity, and the open Agent Skills standard.
Python agent-skillsai-scientistbioinformaticschemoinformaticsclaudeclaude-skillsclaudecodeclinical-researchcomputational-biologydata-analysisdrug-discoverygenomicsmaterials-sciencemetabolomicsproteomicsscientific-computingscientific-visualization
Redesign scholar evaluation safeguards
Timothy Kassisb295e73b0b84
diff --git a/skills/scholar-evaluation/SKILL.md b/skills/scholar-evaluation/SKILL.mdindex 8111f00f..a4dbcad8 100644--- a/skills/scholar-evaluation/SKILL.md+++ b/skills/scholar-evaluation/SKILL.md@@ -1,298 +1,296 @@---name: scholar-evaluation-description: Systematically evaluate scholarly work using the ScholarEval framework, providing structured assessment across research quality dimensions including problem formulation, methodology, analysis, and writing with quantitative scoring and actionable feedback.-license: MIT license-required_environment_variables: [{"name": "OPENROUTER_API_KEY", "prompt": "OpenRouter API key for the skill's LLM-powered steps.", "required_for": "optional features"}]-metadata: {"version": "1.2", "skill-author": "K-Dense Inc.", "openclaw": {"primaryEnv": "OPENROUTER_API_KEY", "envVars": [{"name": "OPENROUTER_API_KEY", "required": false, "description": "OpenRouter API key for the skill's LLM-powered steps."}]}}+description: Provide qualitative-first, evidence-traceable developmental review of scholarly works and audit low-stakes research-assessment rubrics with optional local quality controls. Never use for ranking people or consequential decisions.+license: MIT+compatibility: Requires Python 3.11+ for optional bundled standard-library CLIs. All tooling is local JSON/CSV processing with no network, credentials, external models, or subprocesses.+allowed-tools: Read, Write, Bash, Glob, Python+metadata:+ version: "2.0"+ skill-author: K-Dense Inc.---# Scholar Evaluation-## Overview+## Purpose-Apply the ScholarEval framework to systematically evaluate scholarly and research work. This skill provides structured evaluation methodology based on peer-reviewed research assessment criteria, enabling comprehensive analysis of academic papers, research proposals, literature reviews, and scholarly writing across multiple quality dimensions.+Provide developmental, evidence-traceable feedback on a **scholarly work**:+paper, draft, protocol, literature synthesis, or research idea. Use+qualitative judgment first. Optional scores only describe how submitted+evidence maps to a predeclared bounded rubric.-## When to Use This Skill+This skill also audits whether a low-stakes assessment process documents its+construct, provenance, rater quality, uncertainty, traceability, sensitivity,+fairness, accessibility, privacy, and human governance.-Use this skill when:-- Evaluating research papers for quality and rigor-- Assessing literature review comprehensiveness and quality-- Reviewing research methodology design-- Scoring data analysis approaches-- Evaluating scholarly writing and presentation-- Providing structured feedback on academic work-- Benchmarking research quality against established criteria-- Assessing publication readiness for target venues-- Providing quantitative evaluation to complement qualitative peer review+## Hard safety boundary-## Visual Enhancement with Scientific Schematics+Never use this skill to automate, recommend, materially influence, or score:-**When creating documents with this skill, always consider adding scientific diagrams and schematics to enhance visual communication.**+- hiring, promotion, or tenure;+- admissions;+- grants or other funding;+- prizes, honors, or awards;+- discipline, dismissal, or sanctions; or+- any other high-impact personnel decision.-If your document does not already contain schematics or diagrams:-- Use the **scientific-schematics** skill to generate AI-powered publication-quality diagrams-- Simply describe your desired diagram in natural language-- Nano Banana Pro will automatically generate, review, and refine the schematic+Never rank people. Never reduce a person to a composite score. Never infer+ability, character, integrity, protected traits, future performance, or worth.+A nominal human-in-the-loop does not remove this boundary.-**For new documents:** Scientific schematics should be generated by default to visually represent key concepts, workflows, architectures, or relationships described in the text.+If asked for a prohibited use, stop. Offer developmental comments on a+scholarly work or a process-only audit that does not process applications,+compare people, recommend an outcome, or advise a decision.-**How to generate schematics:**-```bash-python scripts/generate_schematic.py "your diagram description" -o figures/output.png-```+Do not issue publication-readiness, accept/reject, or “top-tier” judgments.-The AI will automatically:-- Create publication-quality images with proper formatting-- Review and refine through multiple iterations-- Ensure accessibility (colorblind-friendly, high contrast)-- Save outputs in the figures/ directory+Read `references/responsible_assessment.md` before any organizational use.-**When to add schematics:**-- Evaluation framework diagrams-- Quality assessment criteria decision trees-- Scholarly workflow visualizations-- Assessment methodology flowcharts-- Scoring rubric visualizations-- Evaluation process diagrams-- Any complex concept that benefits from visualization+## ScholarEval status-For detailed guidance on creating schematics, refer to the scientific-schematics skill documentation.+The referenced ScholarEval project is an **experimental+literature-grounded research-idea evaluation framework**, not validated+psychometrics.----+The verified primary record is Moussa et al., *ScholarEval: Research Idea+Evaluation Grounded in Literature*, arXiv:2510.16234v2, revised 2026-02-28.+It reports a retrieval-augmented soundness/contribution framework, a+117-idea four-discipline dataset, coverage experiments, and a user study.++Do not generalize those results to person assessment, consequential decisions,+all disciplines, or this skill's rubric. No peer-reviewed publication status+was verified during the dated review. See `references/source_ledger.md`.++## Metric and prestige policy++Do not score or infer quality from:++- Journal Impact Factor or other journal measures;+- h-index, publication counts, or citation counts;+- altmetrics or attention;+- journal, conference, venue, institution, employer, or geographic prestige;+- author affiliation, reputation, network, or career path.++The rubric validator rejects common proxy-measure criteria.++If a qualified reviewer mentions an indicator descriptively outside the+scoring tools, record its exact purpose, source, coverage, field and time+effects, uncertainty, missingness, biases, gaming risk, and why it does not+directly measure quality. Never hide indicators inside an opaque composite.-## Evaluation Workflow--### Step 1: Initial Assessment and Scope Definition--Begin by identifying the type of scholarly work being evaluated and the evaluation scope:+## Data boundary-**Work Types:**-- Full research paper (empirical, theoretical, or review)-- Research proposal or protocol-- Literature review (systematic, narrative, or scoping)-- Thesis or dissertation chapter-- Conference abstract or short paper+Bundled scripts accept only strict local JSON/CSV containing pseudonymous IDs,+bounded ratings, statuses, uncertainty, and local references.-**Evaluation Scope:**-- Comprehensive (all dimensions)-- Targeted (specific aspects like methodology or writing)-- Comparative (benchmarking against other work)+Do not put raw private applications, CVs, letters, reviewer identities,+contact details, protected attributes, or source-document text in inputs,+outputs, logs, examples, or prompts. Keep source content in the authorized+records system and use opaque local references.-Ask the user to clarify if the scope is ambiguous.--### Step 2: Dimension-Based Evaluation+Allowed classifications are:-Systematically evaluate the work across the ScholarEval dimensions. For each applicable dimension, assess quality, identify strengths and weaknesses, and provide scores where appropriate.--Refer to `references/evaluation_framework.md` for detailed criteria and rubrics for each dimension.--**Core Evaluation Dimensions:**--1. **Problem Formulation & Research Questions**- - Clarity and specificity of research questions- - Theoretical or practical significance- - Feasibility and scope appropriateness- - Novelty and contribution potential+- `synthetic`+- `public_scholarly_work`+- `deidentified_low_stakes`-2. **Literature Review**- - Comprehensiveness of coverage- - Critical synthesis vs. mere summarization- - Identification of research gaps- - Currency and relevance of sources- - Proper contextualization--3. **Methodology & Research Design**- - Appropriateness for research questions- - Rigor and validity- - Reproducibility and transparency- - Ethical considerations- - Limitations acknowledgment--4. **Data Collection & Sources**- - Quality and appropriateness of data- - Sample size and representativeness- - Data collection procedures- - Source credibility and reliability+No script searches the web, loads environment files, reads credentials, calls a+model, executes supplied text, deserializes executable objects, or launches a+process.-5. **Analysis & Interpretation**- - Appropriateness of analytical methods- - Rigor of analysis- - Logical coherence- - Alternative explanations considered- - Results-claims alignment--6. **Results & Findings**- - Clarity of presentation- - Statistical or qualitative rigor- - Visualization quality- - Interpretation accuracy- - Implications discussion+Use Bash only to invoke the documented local `python3` commands.-7. **Scholarly Writing & Presentation**- - Clarity and organization- - Academic tone and style- - Grammar and mechanics- - Logical flow- - Accessibility to target audience+## Workflow-8. **Citations & References**- - Citation completeness- - Source quality and appropriateness- - Citation accuracy- - Balance of perspectives- - Adherence to citation standards+### 1. Confirm allowed use and authorization-### Step 3: Scoring and Rating+Record:-For each evaluated dimension, provide:+- developmental purpose;+- unit of assessment: `scholarly_work`;+- work type, stage, discipline, language, and audience;+- authorized source location and data classification;+- accountable committee owner;+- conflicts and recusals;+- accessibility and accommodation process;+- appeal or correction route; and+- data purpose, access, retention, and deletion.-**Qualitative Assessment:**-- Key strengths (2-3 specific points)-- Areas for improvement (2-3 specific points)-- Critical issues (if any)+Stop on a prohibited decision context or unnecessary private data.-**Quantitative Scoring (Optional):**-Use a 5-point scale where applicable:-- 5: Excellent - Exemplary quality, publishable in top venues-- 4: Good - Strong quality with minor improvements needed-- 3: Adequate - Acceptable quality with notable areas for improvement-- 2: Needs Improvement - Significant revisions required-- 1: Poor - Fundamental issues requiring major revision+### 2. Define the construct before criteria-To calculate aggregate scores programmatically, use `scripts/calculate_scores.py`.+State:-### Step 4: Synthesize Overall Assessment--Provide an integrated evaluation summary:--1. **Overall Quality Assessment** - Holistic judgment of the work's scholarly merit-2. **Major Strengths** - 3-5 key strengths across dimensions-3. **Critical Weaknesses** - 3-5 primary areas requiring attention-4. **Priority Recommendations** - Ranked list of improvements by impact-5. **Publication Readiness** (if applicable) - Assessment of suitability for target venues--### Step 5: Provide Actionable Feedback+- what quality or support is being examined;+- excluded constructs;+- intended interpretation;+- contexts where the interpretation does not travel;+- evidence requirements; and+- known limitations.-Transform evaluation findings into constructive, actionable feedback:--**Feedback Structure:**-- **Specific** - Reference exact sections, paragraphs, or page numbers-- **Actionable** - Provide concrete suggestions for improvement-- **Prioritized** - Rank recommendations by importance and feasibility-- **Balanced** - Acknowledge strengths while addressing weaknesses-- **Evidence-based** - Ground feedback in evaluation criteria--**Feedback Format Options:**-- Structured report with dimension-by-dimension analysis-- Annotated comments mapped to specific document sections-- Executive summary with key findings and recommendations-- Comparative analysis against benchmark standards--### Step 6: Contextual Considerations--Adjust evaluation approach based on:--**Stage of Development:**-- Early draft: Focus on conceptual and structural issues-- Advanced draft: Focus on refinement and polish-- Final submission: Comprehensive quality check--**Purpose and Venue:**-- Journal article: High standards for rigor and contribution-- Conference paper: Balance novelty with presentation clarity-- Student work: Educational feedback with developmental focus-- Grant proposal: Emphasis on feasibility and impact--**Discipline-Specific Norms:**-- STEM fields: Emphasis on reproducibility and statistical rigor-- Social sciences: Balance quantitative and qualitative standards-- Humanities: Focus on argumentation and scholarly interpretation--## Resources--### references/evaluation_framework.md--Detailed evaluation criteria, rubrics, and quality indicators for each ScholarEval dimension. Load this reference when conducting evaluations to access specific assessment guidelines and scoring rubrics.+Start with values and disciplinary context, not available metrics.-Search patterns for quick access:-- "Problem Formulation criteria"-- "Literature Review rubric"-- "Methodology assessment"-- "Data quality indicators"-- "Analysis rigor standards"-- "Writing quality checklist"+### 3. Adapt and validate the rubric-### scripts/calculate_scores.py+Begin with `assets/rubric_template.json`, then obtain qualified disciplinary,+assessment-methods, stakeholder, accessibility, privacy, and fairness review.-Python script for calculating aggregate evaluation scores from dimension-level ratings. Supports weighted averaging, threshold analysis, and score visualization.+The template deliberately records content validity as `not_established`.+Do not change that status without documented evidence for the exact intended+use.++Validate structure:-Usage:```bash-python scripts/calculate_scores.py --scores <dimension_scores.json> --output <report.txt>+PYTHONDONTWRITEBYTECODE=1 python3 scripts/validate_rubric.py \+ --rubric assets/rubric_template.json```-## Best Practices+Read `references/evaluation_framework.md` for construct, anchor, validity, and+rater guidance.++### 4. Build traceable evidence records-1. **Maintain Objectivity** - Base evaluations on established criteria, not personal preferences-2. **Be Comprehensive** - Evaluate all applicable dimensions systematically-3. **Provide Evidence** - Support assessments with specific examples from the work-4. **Stay Constructive** - Frame weaknesses as opportunities for improvement-5. **Consider Context** - Adjust expectations based on work stage and purpose-6. **Document Rationale** - Explain the reasoning behind assessments and scores-7. **Encourage Strengths** - Explicitly acknowledge what the work does well-8. **Prioritize Feedback** - Focus on high-impact improvements first+Reviewers may read an authorized work outside the scripts. Record only stable+local locators and claim references in+`assets/evidence_manifest_template.json`.-## Example Evaluation Workflow+For every criterion, distinguish:-**User Request:** "Evaluate this research paper on machine learning for drug discovery"+- observed evidence from interpretation;+- supporting from contrary evidence;+- available from unavailable evidence;+- `missing` from `not_applicable`; and+- uncertainty from absence.-**Response Process:**-1. Identify work type (empirical research paper) and scope (comprehensive evaluation)-2. Load `references/evaluation_framework.md` for detailed criteria-3. Systematically assess each dimension:- - Problem formulation: Clear research question about ML model performance- - Literature review: Comprehensive coverage of recent ML and drug discovery work- - Methodology: Appropriate deep learning architecture with validation procedures- - [Continue through all dimensions...]-4. Calculate dimension scores and overall assessment-5. Synthesize findings into structured report highlighting:- - Strong methodology and reproducible code- - Needs more diverse dataset evaluation- - Writing could improve clarity in results section-6. Provide prioritized recommendations with specific suggestions+Failure to find prior work does not prove novelty.-## Integration with Scientific Writer+### 5. Rate independently-This skill integrates seamlessly with the scientific writer workflow:+Use `assets/evaluation_template.json`. Each criterion must be:-**After Paper Generation:**-- Use Scholar Evaluation as an alternative or complement to peer review-- Generate `SCHOLAR_EVALUATION.md` alongside `PEER_REVIEW.md`-- Provide quantitative scores to track improvement across revisions+- `rated` with an anchor score, bounded uncertainty, evidence IDs, and a local+ rationale reference;+- `missing` with null score/uncertainty and a rationale reference; or+- `not_applicable` with null score/uncertainty and a rationale reference.-**During Revision:**-- Re-evaluate specific dimensions after addressing feedback-- Track score improvements over multiple versions-- Identify persistent weaknesses requiring attention+Do not encode missing or not-applicable as zero. Raters should train, calibrate,+disclose conflicts, rate independently, and document disagreement.-**Publication Preparation:**-- Assess readiness for target journal/conference-- Identify gaps before submission-- Benchmark against publication standards+### 6. Run local quality checks-## Notes+Bounded scoring, without labels or recommendation:-- Evaluation rigor should match the work's purpose and stage-- Some dimensions may not apply to all work types (e.g., data collection for purely theoretical papers)-- Cultural and disciplinary differences in scholarly norms should be considered-- This framework complements, not replaces, domain-specific expertise-- Use in combination with peer-review skill for comprehensive assessment+```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/calculate_scores.py \+ --rubric assets/rubric_template.json \+ --evaluation assets/evaluation_template.json+```-## Citation+Evidence traceability:-This skill is based on the ScholarEval framework introduced in:+```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/check_traceability.py \+ --rubric assets/rubric_template.json \+ --evaluation assets/evaluation_template.json \+ --evidence assets/evidence_manifest_template.json+```-**Moussa, H. N., Da Silva, P. Q., Adu-Ampratwum, D., East, A., Lu, Z., Puccetti, N., Xue, M., Sun, H., Majumder, B. P., & Kumar, S. (2025).** _ScholarEval: Research Idea Evaluation Grounded in Literature_. arXiv preprint arXiv:2510.16234. [https://arxiv.org/abs/2510.16234](https://arxiv.org/abs/2510.16234)+Inter-rater agreement:-**Abstract:** ScholarEval is a retrieval augmented evaluation framework that assesses research ideas based on two fundamental criteria: soundness (the empirical validity of proposed methods based on existing literature) and contribution (the degree of advancement made by the idea across different dimensions relative to prior research). The framework achieves significantly higher coverage of expert-annotated evaluation points and is consistently preferred over baseline systems in terms of evaluation actionability, depth, and evidence support.+```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/summarize_agreement.py \+ --rubric assets/rubric_template.json \+ --ratings assets/ratings_template.csv+```++Weight sensitivity requires two or more distinct scholarly-work evaluation+files:++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/weight_sensitivity.py \+ --rubric assets/rubric_template.json \+ --evaluation /tmp/work-a-evaluation.json \+ --evaluation /tmp/work-b-evaluation.json+```++Process controls:++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/check_process.py \+ --process assets/process_checklist_template.json+```++The checklist template is intentionally unconfirmed and fails closed.+Instructions and exact schemas are in `references/local_tooling.md`.++### 7. Synthesize qualitative findings++Lead with criterion-level evidence, not the composite. For each criterion:++1. cite evidence references;+2. state `rated`, `missing`, or `not_applicable`;+3. explain the anchor interpretation;+4. report score and uncertainty only if rated;+5. note disagreements and context;+6. identify strengths and limitations; and+7. offer non-prescriptive improvement options.++Generate an empty-reference scaffold if useful:++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/generate_report_scaffold.py \+ --rubric assets/rubric_template.json \+ --evaluation assets/evaluation_template.json \+ --output /tmp/developmental-report-scaffold.json+```+The scaffold does not read source documents or draft findings.++### 8. Human review and release++Before releasing an organizational report, a qualified accountable human+committee must verify:++- construct and rubric provenance;+- content-validity evidence and limits;+- rater training, agreement, inter-rater reliability evidence, and drift;+- evidence traceability and source access;+- missingness, not-applicable rationales, and uncertainty;+- weight sensitivity and order instability;+- disciplinary and subgroup bias review;+- conflicts and recusals;+- accessibility and accommodations;+- privacy, minimization, retention, and output controls; and+- correction or appeal information.++Document dissent. Do not imply consensus, validity, or precision beyond the+evidence. Periodically evaluate the evaluation and retire harmful criteria.++## Interpretation rules++- A score is an ordinal rubric summary, not a natural measurement.+- Normalization does not repair incomplete evidence.+- The bundled uncertainty range is not a confidence interval.+- Agreement does not establish reliability, validity, fairness, or correctness.+- Stable results under tested weights do not establish validity.+- The overall score never overrides criterion evidence or qualified judgment.+- No output is a decision recommendation.++## Bundled resources++- `references/responsible_assessment.md` — safety, metrics, governance,+ accessibility, privacy, and bias.+- `references/evaluation_framework.md` — ScholarEval boundary, construct,+ criteria, anchors, validity, and interpretation.+- `references/local_tooling.md` — strict schemas, formulas, commands, and+ output behavior.+- `references/source_ledger.md` — authoritative sources and publication-status+ verification dated 2026-07-23.+- `references/security_validation.md` — baseline remediation, validation, and+ residual security-scan record.+- `assets/rubric_template.json` — bounded rubric template.+- `assets/evaluation_template.json` — rating template.+- `assets/evidence_manifest_template.json` — traceability template.+- `assets/process_checklist_template.json` — fail-closed process checklist.+- `assets/ratings_template.csv` — synthetic agreement data.diff --git a/skills/scholar-evaluation/assets/evaluation_template.json b/skills/scholar-evaluation/assets/evaluation_template.jsonnew file mode 100644index 00000000..e5371ee2--- /dev/null+++ b/skills/scholar-evaluation/assets/evaluation_template.json@@ -0,0 +1,50 @@+{+ "schema_version": "2.0",+ "evaluation_id": "EVALUATION-SYNTHETIC-001",+ "rubric_id": "RUBRIC-SYNTHETIC-001",+ "work_id": "WORK-SYNTHETIC-001",+ "data_classification": "synthetic",+ "purpose": "developmental_review_of_scholarly_work",+ "ratings": [+ {+ "criterion_id": "question_scope",+ "status": "missing",+ "score": null,+ "uncertainty": null,+ "evidence_ids": [],+ "rationale_ref": "LOCAL-MISSING-RATIONALE-QUESTION"+ },+ {+ "criterion_id": "literature_contribution",+ "status": "missing",+ "score": null,+ "uncertainty": null,+ "evidence_ids": [],+ "rationale_ref": "LOCAL-MISSING-RATIONALE-LITERATURE"+ },+ {+ "criterion_id": "method_design",+ "status": "missing",+ "score": null,+ "uncertainty": null,+ "evidence_ids": [],+ "rationale_ref": "LOCAL-MISSING-RATIONALE-METHOD"+ },+ {+ "criterion_id": "analysis_claims",+ "status": "missing",+ "score": null,+ "uncertainty": null,+ "evidence_ids": [],+ "rationale_ref": "LOCAL-MISSING-RATIONALE-ANALYSIS"+ },+ {+ "criterion_id": "transparency_integrity",+ "status": "missing",+ "score": null,+ "uncertainty": null,+ "evidence_ids": [],+ "rationale_ref": "LOCAL-MISSING-RATIONALE-TRANSPARENCY"+ }+ ]+}diff --git a/skills/scholar-evaluation/assets/evidence_manifest_template.json b/skills/scholar-evaluation/assets/evidence_manifest_template.jsonnew file mode 100644index 00000000..4c49e153--- /dev/null+++ b/skills/scholar-evaluation/assets/evidence_manifest_template.json@@ -0,0 +1,63 @@+{+ "schema_version": "2.0",+ "evaluation_id": "EVALUATION-SYNTHETIC-001",+ "work_id": "WORK-SYNTHETIC-001",+ "data_classification": "synthetic",+ "evidence": [+ {+ "evidence_id": "EVIDENCE-SYNTHETIC-QUESTION",+ "criterion_ids": [+ "question_scope"+ ],+ "source_type": "section",+ "locator_ref": "LOCAL-WORK-SECTION-QUESTION",+ "claim_ref": "LOCAL-CLAIM-QUESTION",+ "access_status": "available",+ "verification_status": "verified"+ },+ {+ "evidence_id": "EVIDENCE-SYNTHETIC-LITERATURE",+ "criterion_ids": [+ "literature_contribution"+ ],+ "source_type": "section",+ "locator_ref": "LOCAL-WORK-SECTION-LITERATURE",+ "claim_ref": "LOCAL-CLAIM-CONTRIBUTION",+ "access_status": "available",+ "verification_status": "verified"+ },+ {+ "evidence_id": "EVIDENCE-SYNTHETIC-METHOD",+ "criterion_ids": [+ "method_design"+ ],+ "source_type": "protocol",+ "locator_ref": "LOCAL-WORK-PROTOCOL",+ "claim_ref": "LOCAL-CLAIM-METHOD",+ "access_status": "available",+ "verification_status": "verified"+ },+ {+ "evidence_id": "EVIDENCE-SYNTHETIC-ANALYSIS",+ "criterion_ids": [+ "analysis_claims"+ ],+ "source_type": "section",+ "locator_ref": "LOCAL-WORK-SECTION-ANALYSIS",+ "claim_ref": "LOCAL-CLAIM-ANALYSIS",+ "access_status": "available",+ "verification_status": "verified"+ },+ {+ "evidence_id": "EVIDENCE-SYNTHETIC-TRANSPARENCY",+ "criterion_ids": [+ "transparency_integrity"+ ],+ "source_type": "other_local_record",+ "locator_ref": "LOCAL-WORK-TRANSPARENCY-RECORD",+ "claim_ref": "LOCAL-CLAIM-TRANSPARENCY",+ "access_status": "available",+ "verification_status": "verified"+ }+ ]+}diff --git a/skills/scholar-evaluation/assets/process_checklist_template.json b/skills/scholar-evaluation/assets/process_checklist_template.jsonnew file mode 100644index 00000000..2e2559bf--- /dev/null+++ b/skills/scholar-evaluation/assets/process_checklist_template.json@@ -0,0 +1,70 @@+{+ "schema_version": "2.0",+ "process_id": "PROCESS-SYNTHETIC-001",+ "purpose": "developmental_review_of_scholarly_work",+ "unit_of_assessment": "scholarly_work",+ "data_classification": "synthetic",+ "high_impact_use": false,+ "committee": {+ "qualified_members_confirmed": false,+ "training_completed": false,+ "accountable_owner_role": "",+ "training_record_ref": ""+ },+ "conflicts": {+ "disclosure_process_confirmed": false,+ "recusal_process_confirmed": false,+ "record_ref": ""+ },+ "appeals": {+ "process_confirmed": false,+ "process_ref": "",+ "notice_ref": ""+ },+ "accessibility": {+ "accommodations_process_confirmed": false,+ "accessible_materials_confirmed": false,+ "process_ref": ""+ },+ "data_protection": {+ "purpose_limitation_confirmed": false,+ "data_minimisation_confirmed": false,+ "access_controls_confirmed": false,+ "retention_schedule_confirmed": false,+ "raw_private_documents_excluded_from_tool_outputs": false,+ "review_ref": ""+ },+ "rubric_quality": {+ "construct_documented": false,+ "rubric_provenance_documented": false,+ "content_validity_documented": false,+ "rater_training_documented": false,+ "agreement_reviewed": false,+ "inter_rater_reliability_reviewed": false,+ "uncertainty_recorded": false,+ "missing_and_not_applicable_supported": false,+ "evidence_traceability_checked": false,+ "weight_sensitivity_reviewed": false,+ "quality_record_ref": ""+ },+ "fairness": {+ "stakeholder_review_completed": false,+ "disciplinary_context_reviewed": false,+ "subgroup_bias_review_completed": false,+ "protected_attributes_excluded_from_scoring": false,+ "bias_review_ref": ""+ },+ "decision_controls": {+ "no_automated_decision": false,+ "no_person_ranking": false,+ "no_decision_recommendation": false,+ "qualified_human_accountability": false+ },+ "monitoring": {+ "rater_drift_reviewed": false,+ "unintended_consequences_reviewed": false,+ "periodic_revision_scheduled": false,+ "review_record_ref": "",+ "revision_owner_role": ""+ }+}diff --git a/skills/scholar-evaluation/assets/ratings_template.csv b/skills/scholar-evaluation/assets/ratings_template.csvnew file mode 100644index 00000000..c97c1c8e--- /dev/null+++ b/skills/scholar-evaluation/assets/ratings_template.csv@@ -0,0 +1,21 @@+evaluation_id,work_id,rater_id,criterion_id,status,score+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-1,question_scope,rated,3+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-2,question_scope,rated,4+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-1,literature_contribution,rated,2+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-2,literature_contribution,rated,3+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-1,method_design,rated,3+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-2,method_design,rated,3+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-1,analysis_claims,rated,2+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-2,analysis_claims,rated,3+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-1,transparency_integrity,rated,3+EVALUATION-SYNTHETIC-A,WORK-SYNTHETIC-A,RATER-SYNTHETIC-2,transparency_integrity,rated,3+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-1,question_scope,rated,2+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-2,question_scope,rated,2+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-1,literature_contribution,rated,3+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-2,literature_contribution,rated,2+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-1,method_design,rated,2+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-2,method_design,rated,3+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-1,analysis_claims,missing,+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-2,analysis_claims,rated,2+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-1,transparency_integrity,not_applicable,+EVALUATION-SYNTHETIC-B,WORK-SYNTHETIC-B,RATER-SYNTHETIC-2,transparency_integrity,not_applicable,diff --git a/skills/scholar-evaluation/assets/rubric_template.json b/skills/scholar-evaluation/assets/rubric_template.jsonnew file mode 100644index 00000000..38b281ab--- /dev/null+++ b/skills/scholar-evaluation/assets/rubric_template.json@@ -0,0 +1,301 @@+{+ "schema_version": "2.0",+ "rubric_id": "RUBRIC-SYNTHETIC-001",+ "title": "Developmental scholarly-work evidence rubric",+ "intended_use": {+ "purpose": "developmental_review_of_scholarly_work",+ "unit_of_assessment": "scholarly_work",+ "allowed_contexts": [+ "draft feedback",+ "research idea feedback",+ "retrospective methods review"+ ],+ "prohibited_uses": [+ "admissions",+ "awards",+ "discipline",+ "funding",+ "hiring",+ "promotion",+ "tenure",+ "other_high_impact_personnel_decision"+ ]+ },+ "construct": {+ "label": "Traceable support for a scholarly work's claims and methods",+ "definition": "The degree to which a scholarly work states a bounded question, situates its contribution, uses fit-for-purpose methods, aligns analysis with claims, and documents transparent and responsible practices using traceable evidence.",+ "boundaries": [+ "The construct applies to a scholarly work, not a person or organization.",+ "Scores describe evidence against this rubric and do not establish merit, readiness, impact, or a decision outcome.",+ "Disciplinary experts must adapt criterion interpretation before use."+ ],+ "limitations": [+ "This template has not established content validity for any discipline or decision context.",+ "Ordinal ratings and weights are judgments rather than natural measurements.",+ "Literature coverage, rater interpretation, missing evidence, and rubric choices can change results."+ ]+ },+ "provenance": {+ "rubric_version": "1.0",+ "owner_role": "qualified accountable assessment-methods owner",+ "source_ids": [+ "SOURCE-DORA-DECLARATION",+ "SOURCE-DORA-INDICATORS-2024",+ "SOURCE-LEIDEN-2015",+ "SOURCE-COARA-2022",+ "SOURCE-HONG-KONG-2020",+ "SOURCE-SCOPE-2021",+ "SOURCE-TESTING-STANDARDS-2014"+ ],+ "content_validity_status": "not_established",+ "content_validity_evidence_ref": "",+ "last_reviewed_date": "2026-07-23"+ },+ "scale": {+ "minimum": 0,+ "maximum": 4,+ "step": 1,+ "anchors": [+ {+ "score": 0,+ "label": "No assessable evidence",+ "description": "Required evidence is absent, inaccessible, or too unclear to assess."+ },+ {+ "score": 1,+ "label": "Limited support",+ "description": "Some relevant evidence is present, but major gaps or unresolved contradictions remain."+ },+ {+ "score": 2,+ "label": "Mixed support",+ "description": "Evidence partly supports the criterion, with material limitations or uncertainty."+ },+ {+ "score": 3,+ "label": "Substantial support",+ "description": "Traceable evidence substantially supports the criterion and important limitations are stated."+ },+ {+ "score": 4,+ "label": "Strong support",+ "description": "Multiple appropriate evidence elements coherently support the criterion and boundaries are handled explicitly."+ }+ ]+ },+ "criteria": [+ {+ "criterion_id": "question_scope",+ "label": "Question and scope",+ "construct_component": "Clarity, boundedness, significance rationale, assumptions, and feasible scope",+ "weight": 0.15,+ "required": true,+ "anchors": [+ {+ "score": 0,+ "description": "No assessable question, scope, assumptions, or success conditions are provided."+ },+ {+ "score": 1,+ "description": "A question is suggested, but scope or assumptions are materially unclear."+ },+ {+ "score": 2,+ "description": "The question is identifiable, with mixed clarity, feasibility, or boundary specification."+ },+ {+ "score": 3,+ "description": "The question, scope, assumptions, and success conditions are substantially clear and feasible."+ },+ {+ "score": 4,+ "description": "The question and boundaries are precise, justified, feasible, and explicitly connected to success conditions."+ }+ ],+ "evidence_requirements": [+ "A stable locator for the stated question or objective",+ "A stable locator for scope, assumptions, and boundary conditions",+ "A stable locator for the significance rationale"+ ],+ "limitations": [+ "Significance is context-dependent and must be interpreted by relevant disciplinary experts."+ ]+ },+ {+ "criterion_id": "literature_contribution",+ "label": "Literature grounding and contribution claim",+ "construct_component": "Traceable engagement with relevant prior work and a bounded comparison-based contribution claim",+ "weight": 0.2,+ "required": true,+ "anchors": [+ {+ "score": 0,+ "description": "No assessable literature grounding or comparison-based contribution claim is provided."+ },+ {+ "score": 1,+ "description": "Prior work is referenced selectively or the contribution claim is largely unsupported."+ },+ {+ "score": 2,+ "description": "Relevant prior work and comparison evidence are present, with material coverage or inference gaps."+ },+ {+ "score": 3,+ "description": "The work is substantially grounded in relevant literature and the contribution claim is bounded by traceable comparisons."+ },+ {+ "score": 4,+ "description": "Search boundaries, contrary evidence, and comparison dimensions are explicit and strongly support a carefully limited contribution claim."+ }+ ],+ "evidence_requirements": [+ "A documented literature-search or source-selection boundary",+ "Traceable primary sources for comparison claims",+ "A stable locator for contrary, null, or competing evidence considered"+ ],+ "limitations": [+ "Absence from a search result does not establish novelty.",+ "Coverage varies by discipline, language, database, date, and access."+ ]+ },+ {+ "criterion_id": "method_design",+ "label": "Method and design fit",+ "construct_component": "Alignment of design, data or materials, methods, ethics, and validity safeguards with the question",+ "weight": 0.25,+ "required": true,+ "anchors": [+ {+ "score": 0,+ "description": "Methods are absent or cannot address the stated question."+ },+ {+ "score": 1,+ "description": "Methods are partly described but have major unresolved alignment or validity problems."+ },+ {+ "score": 2,+ "description": "The design is partly fit for purpose, with material weaknesses or incomplete safeguards."+ },+ {+ "score": 3,+ "description": "The design is substantially aligned, reproducibly described, and addresses major validity and ethics concerns."+ },+ {+ "score": 4,+ "description": "The design is strongly justified against alternatives, with comprehensive safeguards, transparent choices, and bounded claims."+ }+ ],+ "evidence_requirements": [+ "A stable locator for the design and method rationale",+ "A stable locator for data, sampling, materials, or corpus boundaries",+ "A stable locator for ethics, validity threats, and mitigation"+ ],+ "limitations": [+ "Method quality depends on disciplinary norms and the stated inferential target."+ ]+ },+ {+ "criterion_id": "analysis_claims",+ "label": "Analysis, claims, and uncertainty",+ "construct_component": "Fit of analysis, robustness checks, uncertainty representation, and proportionality of conclusions",+ "weight": 0.2,+ "required": true,+ "anchors": [+ {+ "score": 0,+ "description": "Analysis is absent, uninterpretable, or disconnected from the claims."+ },+ {+ "score": 1,+ "description": "Analysis is present but major assumptions, alternatives, or uncertainty are unaddressed."+ },+ {+ "score": 2,+ "description": "Analysis partly supports the claims, with material robustness or uncertainty limitations."+ },+ {+ "score": 3,+ "description": "Analysis substantially supports proportionate claims and reports important uncertainty and alternatives."+ },+ {+ "score": 4,+ "description": "Analysis, robustness checks, uncertainty, alternatives, and claim boundaries form a coherent and transparent evidentiary chain."+ }+ ],+ "evidence_requirements": [+ "A stable locator for analysis procedures and assumptions",+ "A stable locator for uncertainty or qualitative confidence treatment",+ "A stable locator for robustness checks and alternative explanations"+ ],+ "limitations": [+ "Criterion-level uncertainty records rater judgment range and is not a statistical confidence interval."+ ]+ },+ {+ "criterion_id": "transparency_integrity",+ "label": "Transparency, integrity, and reproducibility",+ "construct_component": "Complete reporting, traceability, responsible practice, openness where appropriate, and recognition of limitations",+ "weight": 0.2,+ "required": true,+ "anchors": [+ {+ "score": 0,+ "description": "Key procedures, provenance, limitations, or integrity safeguards are not assessable."+ },+ {+ "score": 1,+ "description": "Some transparency elements are present, but major omissions prevent checking or reuse."+ },+ {+ "score": 2,+ "description": "Reporting and provenance are partly traceable, with material gaps or unjustified restrictions."+ },+ {+ "score": 3,+ "description": "Reporting, provenance, limitations, and responsible-practice safeguards are substantially traceable and appropriate."+ },+ {+ "score": 4,+ "description": "The work provides strong, accessible traceability and justified openness or restrictions across methods, outputs, limitations, and contributions."+ }+ ],+ "evidence_requirements": [+ "Stable locators for methods, materials, data, code, or justified access restrictions",+ "A stable locator for limitations, conflicts, and ethical safeguards",+ "A stable locator for contribution and provenance records"+ ],+ "limitations": [+ "Open practice must account for privacy, safety, sovereignty, consent, and disciplinary constraints."+ ]+ }+ ],+ "rater_protocol": {+ "minimum_raters": 2,+ "training_required": true,+ "training_ref": "LOCAL-RATER-TRAINING-REQUIRED",+ "calibration_required": true,+ "calibration_ref": "LOCAL-RATER-CALIBRATION-REQUIRED",+ "agreement_method": "exact_within_step_and_mean_absolute_difference",+ "inter_rater_reliability_status": "not_established",+ "inter_rater_reliability_ref": "",+ "drift_monitoring_required": true,+ "drift_review_ref": "LOCAL-RATER-DRIFT-REVIEW-REQUIRED"+ },+ "governance": {+ "accountable_committee_required": true,+ "committee_owner_role": "qualified accountable human committee chair",+ "conflict_disclosure_required": true,+ "recusal_required": true,+ "appeal_process_required": true,+ "appeal_process_ref": "LOCAL-APPEAL-PROCESS-REQUIRED",+ "accessibility_accommodations_required": true,+ "accessibility_process_ref": "LOCAL-ACCESSIBILITY-PROCESS-REQUIRED",+ "data_protection_review_required": true,+ "data_protection_process_ref": "LOCAL-DATA-PROTECTION-REVIEW-REQUIRED",+ "subgroup_bias_review_required": true,+ "subgroup_review_ref": "LOCAL-SUBGROUP-BIAS-REVIEW-REQUIRED",+ "review_cycle_ref": "LOCAL-RUBRIC-REVIEW-CYCLE-REQUIRED"+ }+}diff --git a/skills/scholar-evaluation/references/evaluation_framework.md b/skills/scholar-evaluation/references/evaluation_framework.mdindex f1170c08..1fbbd82f 100644--- a/skills/scholar-evaluation/references/evaluation_framework.md+++ b/skills/scholar-evaluation/references/evaluation_framework.md@@ -1,663 +1,264 @@-# ScholarEval Evaluation Framework--## Overview--This document provides detailed evaluation criteria, rubrics, and quality indicators for each dimension of the ScholarEval framework. Use these standards when conducting systematic evaluations of scholarly work.-------## Dimension 1: Problem Formulation & Research Questions--### Quality Indicators--**Excellent (5):**-- Research question is specific, measurable, and clearly articulated-- Problem addresses significant gap in literature with high impact potential-- Scope is appropriate and feasible within constraints-- Novel contribution is clearly differentiated from existing work-- Theoretical or practical significance is compellingly justified--**Good (4):**-- Research question is clear with minor ambiguities-- Problem is relevant with moderate impact potential-- Scope is generally appropriate with minor feasibility concerns-- Contribution is identifiable though not groundbreaking-- Significance is adequately justified--**Adequate (3):**-- Research question is present but lacks specificity-- Problem relevance is unclear or incremental-- Scope may be too broad or narrow-- Contribution is unclear or overlaps heavily with existing work-- Significance justification is weak--**Needs Improvement (2):**-- Research question is vague or poorly defined-- Problem lacks clear relevance or significance-- Scope is inappropriate or infeasible-- Contribution is not articulated-- No clear justification for significance--**Poor (1):**-- No clear research question-- Problem is trivial or irrelevant-- Scope is fundamentally flawed-- No identifiable contribution-- No significance justification--### Assessment Checklist--- [ ] Is the research question clearly stated?-- [ ] Can the question be answered with the proposed approach?-- [ ] Is the problem significant to the field?-- [ ] Is the scope feasible within resource constraints?-- [ ] Is the novelty/contribution clearly articulated?-- [ ] Are key assumptions explicitly stated?-- [ ] Are success criteria or expected outcomes defined?-------## Dimension 2: Literature Review--### Quality Indicators--**Excellent (5):**-- Comprehensive coverage of relevant literature across key areas-- Critical synthesis identifying patterns, contradictions, and gaps-- Literature is current (majority from last 3-5 years for rapidly evolving fields)-- Sources are authoritative and peer-reviewed-- Clear positioning of current work within scholarly conversation-- Identifies genuine research gaps that the work addresses--**Good (4):**-- Good coverage with minor gaps in key areas-- Mostly synthesis with some description-- Literature is mostly current with some older foundational works-- Sources are generally authoritative-- Work positioning is present but could be stronger-- Research gaps are identified but may not be critical--**Adequate (3):**-- Partial coverage with notable gaps-- More descriptive summarization than synthesis-- Literature mix of current and dated sources-- Mix of authoritative and less rigorous sources-- Weak positioning within existing literature-- Research gaps are vague or questionable--**Needs Improvement (2):**-- Minimal coverage with major gaps-- Purely descriptive without synthesis-- Literature is largely outdated-- Sources lack authority or rigor-- Little to no positioning of current work-- No clear research gaps identified--**Poor (1):**-- Inadequate or absent literature review-- No synthesis-- Outdated or inappropriate sources-- No engagement with scholarly conversation-- No gap identification--### Assessment Checklist--- [ ] Does review cover all major relevant areas?-- [ ] Is literature synthesized rather than just summarized?-- [ ] Are sources current and authoritative?-- [ ] Are contrasting viewpoints presented?-- [ ] Are research gaps clearly identified?-- [ ] Is the current work positioned within existing literature?-- [ ] Is citation balance appropriate (not over-relying on few authors)?-- [ ] Are seminal/foundational works included?--### Common Issues--- **Insufficient coverage**: Missing key papers or research streams-- **Descriptive listing**: Summarizing papers sequentially without synthesis-- **Outdated sources**: Relying on literature more than 5-10 years old-- **Cherry-picking**: Only citing work that supports hypothesis-- **Poor organization**: Lack of thematic or conceptual structure-- **Weak gap identification**: Gaps are trivial or not actually gaps-------## Dimension 3: Methodology & Research Design--### Quality Indicators--**Excellent (5):**-- Research design perfectly aligned with research questions-- Methods are rigorous, valid, and reliable-- Procedures are detailed enough for replication-- Controls, randomization, or triangulation appropriate-- Potential biases acknowledged and mitigated-- Ethical considerations addressed comprehensively-- Limitations are explicitly discussed--**Good (4):**-- Design is appropriate with minor alignment issues-- Methods are sound with small validity concerns-- Procedures are mostly replicable-- Some controls or validation present-- Major biases addressed-- Ethical considerations mentioned-- Some limitations discussed--**Adequate (3):**-- Design partially appropriate for questions-- Methods have notable validity concerns-- Procedures lack detail for full replication-- Limited controls or validation-- Bias mitigation is minimal-- Ethics addressed superficially-- Limitations minimally discussed--**Needs Improvement (2):**-- Design poorly aligned with research questions-- Methods have serious validity issues-- Procedures too vague to replicate-- No controls or validation-- Biases not addressed-- Ethical concerns not addressed-- No limitation discussion--**Poor (1):**-- Inappropriate or absent methodology-- Methods fundamentally flawed-- Not replicable-- No validity considerations-- No ethical considerations-- No acknowledgment of limitations--### Assessment Checklist--- [ ] Is methodology appropriate for research questions?-- [ ] Are procedures described in sufficient detail?-- [ ] Can the study be replicated from the description?-- [ ] Are validity and reliability addressed?-- [ ] Are potential biases identified and mitigated?-- [ ] Are ethical considerations discussed?-- [ ] Are limitations acknowledged?-- [ ] Is sample size justified (for quantitative work)?-- [ ] Are qualitative methods rigorous (if applicable)?--### Design-Specific Considerations--**Quantitative Studies:**-- Sample size with power analysis-- Control groups and randomization-- Measurement validity and reliability-- Statistical assumptions checking--**Qualitative Studies:**-- Sampling strategy and saturation-- Data collection procedures-- Coding and analysis framework-- Trustworthiness criteria (credibility, transferability, etc.)--**Mixed Methods:**-- Integration rationale-- Sequencing justification-- Data convergence strategy-------## Dimension 4: Data Collection & Sources--### Quality Indicators--**Excellent (5):**-- Data sources are highly credible and appropriate-- Sample size is sufficient and well-justified-- Data collection procedures are rigorous and systematic-- Data quality controls are in place-- Sampling strategy ensures representativeness-- Missing data is minimal and handled appropriately--**Good (4):**-- Data sources are credible with minor concerns-- Sample size is adequate-- Collection procedures are systematic-- Some quality controls present-- Sampling is reasonable-- Missing data is addressed--**Adequate (3):**-- Data sources are acceptable but not optimal-- Sample size is marginal-- Collection procedures lack some rigor-- Limited quality controls-- Sampling may have bias concerns-- Missing data handling is basic--**Needs Improvement (2):**-- Data sources have credibility issues-- Sample size is insufficient-- Collection procedures are ad hoc-- No quality controls-- Sampling is clearly biased-- Missing data not addressed--**Poor (1):**-- Data sources are inappropriate or unreliable-- Sample size is inadequate-- Collection is unsystematic-- No quality considerations-- Sampling is fundamentally flawed-- Excessive missing data--### Assessment Checklist--- [ ] Are data sources credible and appropriate?-- [ ] Is sample size sufficient for conclusions?-- [ ] Is sampling strategy clearly described?-- [ ] Is the sample representative of target population?-- [ ] Are data collection procedures systematic?-- [ ] Are data quality controls described?-- [ ] Is missing data addressed?-- [ ] Are any potential data biases discussed?-------## Dimension 5: Analysis & Interpretation--### Quality Indicators--**Excellent (5):**-- Analytical methods perfectly suited to data and questions-- Analysis is rigorous with appropriate techniques-- Results interpretation is logical and well-supported-- Alternative explanations are considered-- Claims are proportionate to evidence-- Assumptions are validated-- Analysis is transparent and reproducible--**Good (4):**-- Methods are appropriate with minor issues-- Analysis is sound-- Interpretation is mostly logical-- Some alternatives considered-- Claims generally match evidence-- Key assumptions checked-- Analysis is mostly transparent--**Adequate (3):**-- Methods are acceptable but not optimal-- Analysis has some technical issues-- Interpretation has logical gaps-- Alternatives not thoroughly explored-- Some claims exceed evidence-- Assumptions not fully validated-- Analysis transparency is limited--**Needs Improvement (2):**-- Methods are questionable for data/questions-- Analysis has significant technical flaws-- Interpretation is poorly supported-- No alternative explanations-- Claims significantly exceed evidence-- Assumptions not checked-- Analysis is not transparent--**Poor (1):**-- Methods are inappropriate-- Analysis is fundamentally flawed-- Interpretation is illogical-- No consideration of alternatives-- Claims unsupported by evidence-- No assumption validation-- Analysis is opaque--### Assessment Checklist--- [ ] Are analytical methods appropriate?-- [ ] Are statistical tests/qualitative methods properly applied?-- [ ] Are assumptions tested?-- [ ] Is interpretation logical and well-supported?-- [ ] Are alternative explanations considered?-- [ ] Do claims align with evidence strength?-- [ ] Is analysis reproducible from description?-- [ ] Are uncertainties acknowledged?--### Quantitative Analysis--- Appropriate statistical tests-- Assumptions checked (normality, homogeneity, etc.)-- Effect sizes reported-- Confidence intervals provided-- Multiple testing corrections (if applicable)-- Model diagnostics performed--### Qualitative Analysis--- Coding framework is clear-- Inter-rater reliability (if applicable)-- Saturation discussed-- Negative cases examined-- Member checking or validation-- Clear audit trail-------## Dimension 6: Results & Findings--### Quality Indicators--**Excellent (5):**-- Results are clearly and comprehensively presented-- Visualizations are effective and appropriate-- Statistical or qualitative rigor is evident-- Key findings are highlighted effectively-- Results directly address research questions-- Patterns and relationships are clearly shown-- Negative and null results are reported--**Good (4):**-- Results are clear with minor presentation issues-- Visualizations are generally effective-- Rigor is present-- Main findings are identifiable-- Results mostly address questions-- Patterns are shown-- Some negative results included--**Adequate (3):**-- Results presentation is adequate but could be clearer-- Visualizations are basic or have issues-- Rigor is questionable in places-- Findings are present but not emphasized-- Partial alignment with questions-- Patterns are unclear-- Negative results may be omitted--**Needs Improvement (2):**-- Results presentation is unclear or confusing-- Visualizations are poor or misleading-- Lack of rigor-- Findings are difficult to identify-- Weak alignment with questions-- No clear patterns-- Only positive results shown--**Poor (1):**-- Results are poorly presented or absent-- Visualizations are inappropriate or missing-- No evidence of rigor-- Findings are unclear-- Results don't address questions-- No identifiable patterns-- Results appear selective--### Assessment Checklist--- [ ] Are results clearly presented?-- [ ] Do results directly address research questions?-- [ ] Are visualizations appropriate and effective?-- [ ] Are key findings highlighted?-- [ ] Are negative/null results reported?-- [ ] Is appropriate precision reported (p-values, CIs, effect sizes)?-- [ ] Are qualitative findings supported by data excerpts?-- [ ] Is there evidence of selective reporting?--### Presentation Quality--**Tables:**-- Clear labels and captions-- Appropriate precision-- Organized logically-- Not overly complex--**Figures:**-- Clear axes and legends-- Appropriate chart type-- Professional appearance-- Accessible (color-blind friendly)--**Text:**-- Highlights key findings-- Avoids redundancy with tables/figures-- Uses appropriate statistical language-------## Dimension 7: Scholarly Writing & Presentation--### Quality Indicators--**Excellent (5):**-- Writing is clear, concise, and precise-- Organization is logical with excellent flow-- Academic tone is appropriate and consistent-- Grammar and mechanics are flawless-- Technical terms are used correctly-- Accessible to target audience-- Abstract/summary is comprehensive and accurate--**Good (4):**-- Writing is clear with minor awkwardness-- Organization is logical with good flow-- Tone is mostly appropriate-- Few grammar/mechanical errors-- Technical terms mostly correct-- Generally accessible-- Abstract is adequate--**Adequate (3):**-- Writing is understandable but has clarity issues-- Organization has some logical gaps-- Tone inconsistencies-- Noticeable grammar/mechanical errors-- Some technical term misuse-- Accessibility issues for target audience-- Abstract is incomplete or vague--**Needs Improvement (2):**-- Writing is often unclear or verbose-- Poor organization and flow-- Tone is inappropriate-- Frequent grammar/mechanical errors-- Technical terminology problems-- Not accessible to target audience-- Abstract is poor or missing--**Poor (1):**-- Writing is unclear and difficult to follow-- No clear organization-- Tone is inappropriate-- Pervasive grammar/mechanical errors-- Incorrect technical terminology-- Inaccessible-- No adequate abstract--### Assessment Checklist--- [ ] Is writing clear and concise?-- [ ] Is organization logical?-- [ ] Is tone appropriate for academic writing?-- [ ] Are grammar and mechanics correct?-- [ ] Are technical terms used appropriately?-- [ ] Is jargon explained when necessary?-- [ ] Does abstract accurately summarize the work?-- [ ] Are transitions between sections smooth?-- [ ] Is the target audience clear?--### Common Writing Issues--- **Wordiness**: Unnecessarily complex or lengthy prose-- **Passive voice overuse**: Reduces clarity and directness-- **Paragraph structure**: Lack of topic sentences or coherence-- **Redundancy**: Repeating information unnecessarily-- **Logical flow**: Poor transitions between ideas-- **Precision**: Vague or ambiguous language-- **Accessibility**: Too technical or not technical enough-------## Dimension 8: Citations & References--### Quality Indicators--**Excellent (5):**-- All claims are appropriately cited-- Sources are authoritative and current-- Citations are accurate and complete-- Diverse perspectives are represented-- Citation format is consistent and correct-- Balance between self-citation and others-- Primary sources used appropriately--**Good (4):**-- Most claims are cited-- Sources are generally authoritative-- Few citation errors-- Reasonable diversity of sources-- Format is mostly consistent-- Citation balance is good-- Mix of primary and secondary sources--**Adequate (3):**-- Some claims lack citations-- Source quality is mixed-- Several citation errors-- Limited source diversity-- Format inconsistencies-- Citation balance issues-- Over-reliance on secondary sources--**Needs Improvement (2):**-- Many claims uncited-- Sources are questionable-- Numerous citation errors-- Narrow source base-- Format is inconsistent-- Excessive self-citation or narrow citing-- Inappropriate sources (e.g., only secondary)--**Poor (1):**-- Inadequate citations-- Unreliable sources-- Pervasive citation errors-- Minimal source diversity-- No consistent format-- Severe citation imbalance-- Inappropriate source types--### Assessment Checklist--- [ ] Are all factual claims cited?-- [ ] Are citations to primary sources when appropriate?-- [ ] Are sources authoritative and peer-reviewed?-- [ ] Is there balance in perspectives cited?-- [ ] Are citations accurate (authors, dates, pages)?-- [ ] Is citation format consistent?-- [ ] Are self-citations appropriate (typically <20%)?-- [ ] Are sources current (for time-sensitive topics)?-- [ ] Are classic/seminal works included where relevant?--### Citation Quality Assessment--**Source Types (in order of preference for most academic work):**-1. Peer-reviewed journal articles-2. Academic books from reputable publishers-3. Conference proceedings (field-dependent)-4. Technical reports from reputable institutions-5. Dissertations/theses-6. Preprints (with caution, field-dependent)-7. Grey literature (limited use)-8. Websites (rarely appropriate, except for factual data)--**Red Flags:**-- Wikipedia as a primary source-- Excessive self-citation (>30%)-- Only citing papers that support hypothesis-- Outdated sources when current ones exist-- Missing key papers in the field-- Citing abstracts only when full papers are available-- Inconsistent or incorrect citation format-------## Cross-Cutting Considerations--### Reproducibility--Assess across dimensions:-- Are methods detailed enough to replicate?-- Are data and code available (or availability explained)?-- Are analysis steps transparent?-- Are materials/instruments specified?--### Ethics--Consider:-- IRB approval (for human subjects)-- Informed consent-- Privacy and confidentiality-- Conflicts of interest-- Research integrity-- Data sharing ethics--### Bias and Limitations--Evaluate whether:-- Potential biases are acknowledged-- Limitations are discussed honestly-- Boundary conditions are specified-- Generalizability is appropriately claimed--### Impact and Significance--Consider:-- Theoretical contribution-- Practical implications-- Policy relevance-- Methodological innovation-- Field advancement-------## Scoring Guidelines--### Dimension Weighting (Suggested, Adjust by Context)--- Problem Formulation: 15%-- Literature Review: 15%-- Methodology: 20%-- Data Collection: 10%-- Analysis: 15%-- Results: 10%-- Writing: 10%-- Citations: 5%--### Overall Assessment Thresholds--- **Exceptional (4.5-5.0)**: Ready for top-tier publication-- **Strong (4.0-4.4)**: Publication-ready with minor revisions-- **Good (3.5-3.9)**: Major revisions required, promising work-- **Acceptable (3.0-3.4)**: Significant revisions needed-- **Weak (2.0-2.9)**: Fundamental issues, major rework required-- **Poor (<2.0)**: Not suitable for publication without complete revision--### Contextual Adjustments--Adjust standards based on:-- **Stage**: Proposal < Draft < Final submission-- **Venue**: Student thesis < Conference < Journal < Top-tier journal-- **Type**: Theoretical < Empirical < Meta-analysis-- **Field**: Standards vary by discipline-- **Purpose**: Educational < Professional < Publication-------## Using This Framework--1. **Read the work thoroughly** before beginning evaluation-2. **Score each dimension** using the 5-point scale-3. **Document evidence** for each score with specific examples-4. **Consider context** and adjust expectations appropriately-5. **Synthesize findings** across dimensions-6. **Provide actionable feedback** prioritized by impact-7. **Balance criticism with recognition** of strengths--This framework is a guide, not a rigid checklist. Professional judgment should always be applied in context.+# Evaluation Framework++## What ScholarEval is—and is not++The paper currently referenced by this skill is Moussa et al.,+[*ScholarEval: Research Idea Evaluation Grounded in+Literature*](https://arxiv.org/abs/2510.16234), arXiv:2510.16234v2,+revised 2026-02-28.++The preprint describes an experimental retrieval-augmented system for evaluating+research ideas on:++- **soundness:** whether existing literature empirically supports proposed+ methods; and+- **contribution:** how an idea advances beyond prior work along comparison+ dimensions.++It reports a 117-idea, four-discipline dataset, coverage comparisons with+expert-annotated review points, and a user study. Those studies evaluate that+framework. They do **not** validate the generalized rubric in this skill as a+psychometric instrument, establish stable score meaning across disciplines, or+authorize use in consequential decisions.++As of the dated source review, arXiv and the official project repository were+the verified primary publication records. No peer-reviewed publication status+was verified. Cite it as an arXiv preprint unless a later primary record is+checked. See `references/source_ledger.md`.++## Relationship to this skill++This skill borrows the useful discipline of:++1. defining what is being assessed;+2. grounding judgments in traceable literature and work evidence;+3. separating soundness-like questions from contribution-like questions; and+4. auditing whether generated feedback covers expert concerns.++It does not reproduce ScholarEval's model pipeline, prompts, retrieval system,+dataset, or reported metrics. The bundled scripts do not call ScholarEval,+search the web, invoke a model, or evaluate private documents.++The template is a **locally governed developmental rubric**. Its default+construct is:++> Traceable support for a scholarly work's claims and methods: the degree to+> which a work states a bounded question, situates its contribution, uses+> fit-for-purpose methods, aligns analysis with claims, and documents+> transparent and responsible practices using traceable evidence.++This construct must be reviewed and adapted by relevant disciplinary experts.++## Five template criteria++### 1. Question and scope++Review:++- a clear, bounded question or objective;+- significance rationale appropriate to the field and work stage;+- assumptions, boundary conditions, and success conditions; and+- feasibility of the proposed or reported scope.++Do not treat fashionable topics, institutional affiliation, or venue+expectations as evidence of significance.++### 2. Literature grounding and contribution claim++Review:++- source-selection or search boundaries;+- engagement with relevant and contrary evidence;+- traceable primary sources for comparison claims;+- comparison dimensions used to define the contribution; and+- limits on novelty or advancement claims.++Failure to find prior work does not establish novelty. Search coverage varies by+database, language, date, indexing, terminology, discipline, and access.++### 3. Method and design fit++Review:++- alignment between question, design, data or materials, and method;+- sampling, corpus, inclusion, exclusion, and measurement choices;+- alternatives and design rationale;+- validity threats, bias, and mitigation;+- ethics, consent, privacy, safety, and governance; and+- detail sufficient for appropriate checking or reproduction.++Use discipline-specific reporting and methods standards. Do not reward+complexity for its own sake.++### 4. Analysis, claims, and uncertainty++Review:++- fit of analytical methods to data and inferential target;+- assumptions and diagnostics;+- robustness, sensitivity, negative cases, and alternative explanations;+- appropriate statistical or qualitative uncertainty;+- alignment between results and claims; and+- explicit limits on generalization and causal language.++The rubric's `uncertainty` value is a rater-supplied bounded judgment range. It+is not a sampling confidence interval, posterior interval, or standard error.++### 5. Transparency, integrity, and reproducibility++Review:++- complete reporting, provenance, and stable evidence locators;+- protocols, registrations, data, code, materials, and justified restrictions;+- negative, null, and contradictory findings where relevant;+- conflicts, limitations, corrections, and research-integrity safeguards;+- accessible communication; and+- transparent attribution of contributions.++Open practice is not an absolute requirement when privacy, consent, safety,+security, Indigenous data governance, commercial constraints, or other+legitimate restrictions apply. Assess whether restrictions are justified and+whether safe access or metadata alternatives are provided.++## Scale semantics++The template uses an ordinal 0–4 scale:++- **0 — no assessable evidence**+- **1 — limited support**+- **2 — mixed support**+- **3 — substantial support**+- **4 — strong support**++These are evidence anchors, not labels of a person or universal levels of+research quality. The rubric defines criterion-specific anchors. Raters must use+the anchor text, not intuition about what a number “usually means.”++Do not convert the score to:++- accept/reject or publication readiness;+- exceptional/poor labels;+- predicted success or impact;+- person ranking; or+- funding, hiring, promotion, tenure, admissions, award, or discipline advice.++## Rating statuses++Each criterion has exactly one status:++- `rated`: score, uncertainty, evidence identifiers, and rationale reference+ are required;+- `missing`: evidence needed for assessment is absent or unavailable; score and+ uncertainty are null; or+- `not_applicable`: the criterion does not apply to this work under a documented+ rationale; score and uncertainty are null.++Do not encode missing or not-applicable as zero.++## Transparent score math++For rated criteria \(R\), score \(s_i\), and predeclared weight \(w_i\):++\[+\text{descriptive score}+=+\frac{\sum_{i \in R} w_i s_i}+ {\sum_{i \in R} w_i}+\]++The score report separately provides:++- total, applicable, rated, missing, and not-applicable weight;+- coverage of applicable weight;+- each weighted contribution;+- the normalized descriptive score; and+- a bounded aggregation of criterion uncertainty ranges.++The uncertainty aggregation is not a confidence interval. Normalization does+not make incomplete evaluations comparable. Review missingness before looking+at any score.++## Rubric development record++Before replacing `content_validity_status: not_established`, document:++1. the exact discipline, work type, language, stage, and intended use;+2. construct definition and excluded constructs;+3. literature and standard review used to draft criteria;+4. disciplinary expert and stakeholder selection;+5. systematic mapping of criteria to construct components;+6. cognitive interviews or rater response-process evidence;+7. accessibility and translation review;+8. pilot sample and evidence-availability analysis;+9. revisions, dissent, unresolved gaps, and approval; and+10. the limits of any validity claim.++Rubric provenance must identify the version, owner role, source identifiers,+review date, and content-evidence reference.++## Rater protocol++At minimum:++1. select qualified raters with relevant disciplinary and methods expertise;+2. disclose conflicts and recuse where required;+3. train on construct boundaries, anchors, evidence rules, missingness,+ accessibility, bias, and privacy;+4. calibrate on synthetic or authorized examples;+5. rate independently before discussion;+6. record evidence identifiers and uncertainty;+7. summarize agreement and investigate systematic disagreements;+8. resolve only through documented evidence and rationale, not forced averaging;+9. monitor drift over time; and+10. retrain, revise, or suspend the rubric when evidence warrants.++The bundled agreement script reports exact agreement, within-one-step agreement,+and mean absolute difference. Those summaries do not replace a+design-appropriate reliability analysis. The rubric therefore separately+records `inter_rater_reliability_status` and+`inter_rater_reliability_ref`; the template leaves reliability not established.++## Evidence traceability++Each rated criterion must point to one or more entries in the evidence manifest.+Each entry records:++- pseudonymous evidence identifier;+- linked criterion identifiers;+- source type;+- local stable locator;+- local claim reference;+- access status; and+- verification status.++Never place an excerpt or raw private document in the manifest. Keep source+content in the authorized source system.++## Weight sensitivity and order instability++Weights are value judgments. Predeclare and justify them. Run+`scripts/weight_sensitivity.py` before interpreting a composite.++The script increases and decreases one weight at a time and renormalizes the+weights. It reports score ranges and whether pairwise ordinal relationships+among scholarly works change. Instability is evidence that an apparent order+depends on contestable weights.++The output must not be used to rank people or decide a high-impact outcome.+Even stable ordering does not establish validity.++## Interpretation template++For each criterion, qualified reviewers should record:++1. status and evidence references;+2. observed evidence;+3. interpretation against the anchor;+4. score and uncertainty, if rated;+5. missing or not-applicable rationale;+6. disciplinary and stage context;+7. strengths and limitations; and+8. non-prescriptive improvement options.++Conclude with construct, provenance, coverage, agreement, sensitivity, bias,+privacy, accessibility, and validity limitations—not a decision recommendation.diff --git a/skills/scholar-evaluation/references/local_tooling.md b/skills/scholar-evaluation/references/local_tooling.mdnew file mode 100644index 00000000..9ced3895--- /dev/null+++ b/skills/scholar-evaluation/references/local_tooling.md@@ -0,0 +1,232 @@+# Local Deterministic Tooling++## Security properties++Every bundled script:++- uses only the Python standard library;+- reads bounded local `.json` or `.csv` files;+- rejects symbolic-link inputs, duplicate JSON keys, excessive depth or size,+ non-finite numbers, unknown schema fields, and common private-application+ fields;+- uses fixed schemas and never executes supplied text;+- has no network, model, credential, environment-file, dynamic-code,+ executable-serialization, or child-process behavior;+- writes only minimized JSON reports and refuses to overwrite by default; and+- does not copy evidence excerpts or raw source documents.++Inputs are limited to 2 MiB, JSON depth 20, 25,000 structure nodes, 50 rubric+criteria, 50 comparison evaluations, and 20,000 agreement rows. Outputs are+limited to 2 MiB.++Use an authorized local directory. Keep private source documents in the+institution's records system and reference them with opaque local identifiers.++## Templates++- `assets/rubric_template.json` — valid structure, but deliberately records+ content validity as not established.+- `assets/evaluation_template.json` — structurally valid all-missing example.+- `assets/evidence_manifest_template.json` — synthetic local-reference records.+- `assets/process_checklist_template.json` — fail-closed unconfirmed controls.+- `assets/ratings_template.csv` — pseudonymous synthetic agreement data.++Copy a template into an authorized working directory before editing it. Do not+replace synthetic identifiers with names or contact information.++## 1. Rubric schema validation++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/validate_rubric.py \+ --rubric assets/rubric_template.json+```++The validator checks:++- fixed intended use and scholarly-work unit;+- complete prohibited-use list;+- construct, boundaries, limitations, and provenance;+- content-validity status and reference;+- bounded scale and complete anchors;+- unique criteria and weights summing to one;+- absence of common scored proxy measures;+- required rater training, calibration, agreement, separately recorded+ inter-rater reliability status, and drift controls; and+- committee, conflict, appeal, accessibility, data-protection, subgroup, and+ review-cycle governance.++A rubric can be structurally `valid` while warning that content validity is not+documented. Structural validity is not psychometric validity.++## 2. Bounded descriptive scoring++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/calculate_scores.py \+ --rubric assets/rubric_template.json \+ --evaluation assets/evaluation_template.json \+ --output /tmp/scholar-score.json+```++The evaluation contains one entry for every criterion:++```json+{+ "criterion_id": "method_design",+ "status": "rated",+ "score": 3,+ "uncertainty": 0.5,+ "evidence_ids": ["EVIDENCE-SYNTHETIC-METHOD"],+ "rationale_ref": "LOCAL-RATING-RATIONALE-METHOD"+}+```++For `missing` or `not_applicable`, `score` and `uncertainty` must be null and+`evidence_ids` must be empty. A local rationale reference remains required.++The output reports weighted contributions, coverage, missing and+not-applicable weight, normalized score, and a bounded uncertainty range. It+contains no quality label, threshold, decision, or recommendation.++## 3. Evidence traceability++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/check_traceability.py \+ --rubric assets/rubric_template.json \+ --evaluation assets/evaluation_template.json \+ --evidence assets/evidence_manifest_template.json+```++The checker verifies that:++- manifest, evaluation, work, and classification identifiers match;+- every evidence identifier is unique;+- every rated evidence reference resolves;+- evidence is linked to the criterion that cites it;+- source and access types are allowed; and+- evidence is available and verified.++It reports identifiers, paths, and counts only. It never opens or copies the+referenced source.++## 4. Weight sensitivity and rank instability++Provide two to 50 evaluation JSON files for distinct scholarly works:++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/weight_sensitivity.py \+ --rubric assets/rubric_template.json \+ --evaluation /tmp/work-a-evaluation.json \+ --evaluation /tmp/work-b-evaluation.json \+ --delta 0.2 \+ --output /tmp/weight-sensitivity.json+```++For each criterion, the script multiplies its weight by `1-delta` and+`1+delta`, renormalizes all weights to one, and recomputes descriptive scores.+It reports:++- every scenario and its exact weights;+- each work's score and coverage per scenario;+- score ranges;+- base ordinal order; and+- pairwise order changes.++The base order is included solely to detect instability. It is not a ranking+recommendation and must never be used for people or high-impact decisions.++## 5. Inter-rater agreement summaries++The CSV header must be exactly:++```text+evaluation_id,work_id,rater_id,criterion_id,status,score+```++Use pseudonymous rater identifiers. Run:++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/summarize_agreement.py \+ --rubric assets/rubric_template.json \+ --ratings assets/ratings_template.csv \+ --output /tmp/agreement-summary.json+```++For each criterion and overall, the report includes:++- pair observations;+- exact agreement rate;+- within-one-scale-step agreement rate;+- mean absolute difference;+- overlap, rated, missing, and not-applicable counts.++Rater identifiers are not emitted. These are descriptive agreement summaries,+not chance-corrected reliability, generalizability, validity, or fairness+evidence.++## 6. Bias and process checklist++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/check_process.py \+ --process assets/process_checklist_template.json+```++The template is intentionally unconfirmed and therefore does not pass. Complete+it only from documented local records. The checker covers:++- qualified committee and training;+- conflicts and recusal;+- appeal and correction;+- accessibility and accommodations;+- purpose limitation, minimization, access, retention, and output controls;+- construct, provenance, content evidence, rater quality, agreement,+ inter-rater reliability review, uncertainty, missingness, traceability, and+ sensitivity;+- stakeholder, disciplinary, subgroup, and protected-attribute safeguards;+- no automation, person ranking, or decision recommendation; and+- drift, unintended-consequence, and periodic review.++`high_impact_use: true` or any unconfirmed decision control blocks the process.+The checklist does not authorize a prohibited use.++## 7. Report scaffold++Generate a minimized scaffold:++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/generate_report_scaffold.py \+ --rubric assets/rubric_template.json \+ --evaluation assets/evaluation_template.json \+ --output /tmp/developmental-report-scaffold.json+```++Optional companion reports:++```bash+PYTHONDONTWRITEBYTECODE=1 python3 scripts/generate_report_scaffold.py \+ --rubric assets/rubric_template.json \+ --evaluation /tmp/work-a-evaluation.json \+ --traceability /tmp/traceability.json \+ --agreement /tmp/agreement-summary.json \+ --sensitivity /tmp/weight-sensitivity.json \+ --process /tmp/process-check.json \+ --output /tmp/developmental-report-scaffold.json+```++The scaffold includes:++- construct and provenance status;+- descriptive scores and uncertainty;+- empty local-reference slots for evidence, strengths, limitations, and+ improvement options;+- minimized quality-assurance statuses; and+- fixed limitations and human-review fields.++It does not draft findings from source documents or issue a decision.++## Exit behavior++- exit `0`: requested calculation or validation completed successfully;+- exit `2`: invalid, blocked, incomplete, failed traceability, or unsafe input.++Errors contain only stable codes and JSON paths, never supplied values. Use+`--force` only when replacing a known local report.diff --git a/skills/scholar-evaluation/references/responsible_assessment.md b/skills/scholar-evaluation/references/responsible_assessment.mdnew file mode 100644index 00000000..a725c1d6--- /dev/null+++ b/skills/scholar-evaluation/references/responsible_assessment.md@@ -0,0 +1,196 @@+# Responsible Assessment and Safety Boundary++## Non-negotiable boundary++This skill is for **developmental review of scholarly works** and for auditing a+low-stakes assessment process. It must not automate, recommend, materially+influence, or provide a score for:++- hiring, promotion, or tenure;+- admissions;+- grant or other funding decisions;+- prizes, honors, or awards;+- discipline, dismissal, or sanctions; or+- any other high-impact personnel decision.++Do not rank people. Do not convert several judgments into a single composite+person score. Do not infer a person's ability, character, integrity, future+performance, protected characteristics, or institutional worth.++This boundary remains in force when a human is nominally “in the loop.”+Checklists, committees, or disclaimers do not make a prohibited workflow safe.+If a request crosses the boundary, stop and offer one of these alternatives:++1. developmental comments on a public or authorized scholarly work, with no+ person comparison or decision advice;+2. an audit of whether an existing assessment process follows responsible+ assessment principles, without processing applications or recommending an+ outcome; or+3. neutral documentation of criteria for review by the organization's legal,+ privacy, accessibility, labor, ethics, and disciplinary experts.++## Allowed scope++Examples of allowed uses, subject to authorization and data protection:++- feedback on a draft paper, protocol, research idea, or literature synthesis;+- a retrospective methods or reporting review;+- calibration exercises using synthetic or public scholarly works;+- checking evidence traceability;+- describing the sensitivity of work-level scores to rubric weights; and+- auditing a low-stakes evaluation design for missing governance controls.++“Publication readiness” and “accept/reject” recommendations are excluded.+Describe evidence, limitations, and improvement options instead.++## Accountable human process++For any organizational use, an accountable committee must own the process. It+must include relevant disciplinary and assessment-methods expertise and must:++- publish the construct, intended use, rubric, weights, evidence requirements,+ and interpretation limits before reviewing;+- record member qualifications, training, calibration, and drift checks;+- disclose conflicts, require recusal, and maintain a conflict record;+- provide an understandable notice and a meaningful appeal or correction route;+- provide accessible materials and reasonable accommodations;+- define lawful purpose, access controls, minimization, retention, and deletion;+- review disciplinary, language, career-path, disability, and subgroup effects;+- document disagreements and uncertainty rather than force consensus; and+- periodically evaluate and revise the evaluation.++No script in this skill is the accountable reviewer. Script output is a+descriptive record for qualified human interpretation.++## Qualitative-first evidence++Start with the values and construct, not the data that happen to be available.+Use evidence that directly bears on the criterion:++- the work's questions, methods, analyses, outputs, limitations, and provenance;+- datasets, software, protocols, materials, registrations, replications, and+ negative or null findings where relevant;+- transparent records of responsible practices and justified restrictions;+- contribution records, including CRediT roles when useful, without treating a+ role as proof of quality; and+- influence on policy, practice, communities, teaching, infrastructure, or+ knowledge, when this is within the stated construct and supported by evidence.++Ask what is missing, inaccessible, contested, or not applicable. A missing item+is not a zero. A not-applicable item is not evidence of deficiency.++## Prohibited proxies and contextual indicators++Do not score or infer quality from:++- Journal Impact Factor or other journal-level measures;+- h-index, i10-index, publication counts, or citation counts;+- altmetrics or attention counts;+- journal, conference, institutional, geographic, or employer prestige;+- venue identity or ranking; or+- author affiliation, career path, network, or reputation.++The bundled rubric validator rejects common proxy-measure criteria.++If a qualified reviewer has a legitimate, predeclared reason to mention a+quantitative indicator descriptively outside the bundled scoring tools, record:++1. the exact construct and purpose;+2. why the indicator bears on that construct at the correct unit of analysis;+3. source, version, query date, coverage, exclusions, and data quality;+4. field, language, output-type, career-stage, and time-window effects;+5. uncertainty, missingness, gaming risks, and known biases;+6. why qualitative evidence is insufficient by itself; and+7. a statement that the indicator is not a direct measure of quality.++Never use an indicator merely because it is available. Never hide several+different indicators inside an opaque composite.++## Rubric evidence and psychometric caution++A rubric is a measurement claim. Before operational use, record:++- **construct:** what is and is not being assessed;+- **intended interpretation and use:** the exact meaning claimed for scores;+- **provenance:** who designed and approved criteria, anchors, and weights;+- **content evidence:** disciplinary expert and stakeholder review of coverage;+- **response process:** how raters interpret anchors and use evidence;+- **rater protocol:** selection, training, calibration, qualification, and drift;+- **agreement/reliability:** a design-appropriate analysis and its uncertainty;+- **fairness:** accessibility, subgroup, language, and disciplinary review;+- **traceability:** stable evidence references for each rating;+- **missing/not applicable:** explicit statuses and rationales;+- **weight sensitivity:** whether plausible weights change descriptive results;+- **consequences:** gaming, burden, goal displacement, and other effects; and+- **revision:** review date, owner, change record, and retirement criteria.++Do not call a rubric “validated” because experts reviewed it once, raters agreed,+or scores correlated with another judgment. Validity concerns the evidence for a+specific interpretation and use. Reliability or agreement alone is not validity.++The provided rubric explicitly records `content_validity_status` as+`not_established`. Replace that status only when a qualified team has documented+appropriate evidence for the exact discipline, population, language, and use.++## Bias and subgroup review++Perform the fairness review outside these scripts in an authorized environment.+Do not place protected-attribute records in rubric, evaluation, evidence, or+ratings files.++A qualified review should examine, where lawful and appropriate:++- access to the measured construct and accommodation effectiveness;+- differential missingness and evidence availability;+- criteria that privilege particular languages, methods, fields, institutions,+ career patterns, or resource levels;+- rater severity, drift, and disagreement patterns;+- differential effects of weights and not-applicable decisions;+- false precision and threshold effects;+- burden, gaming, and chilling of collaboration or risky research; and+- whether the evaluation should be redesigned or stopped.++Report sample limitations and uncertainty. Do not expose small cells or attempt+to infer sensitive characteristics.++## Privacy and data protection++Use only public scholarly works, synthetic records, or deidentified low-stakes+records processed under an approved local purpose. Do not put raw private+applications, CVs, recommendation letters, reviewer identities, contact+details, protected attributes, or source-document text into tool inputs or+outputs.++The bundled formats contain only:++- pseudonymous work, evaluation, rater, criterion, and evidence identifiers;+- bounded scores, statuses, and uncertainty;+- local stable references; and+- minimized control attestations and aggregate summaries.++Keep source documents in the authorized records system. Use local references to+them. Apply least privilege, retention limits, deletion, incident handling, and+any stricter local law or policy.++## Accessibility++Provide the rubric, evidence requirements, notices, feedback, and appeal+process in accessible formats. Do not penalize an accommodation, assistive+technology, language variant, or accessible presentation choice. Confirm that+the rubric measures the intended construct rather than fluency with an+inaccessible interface or format.++## Communicating results++Lead with qualitative, traceable findings. For every criterion:++1. cite local evidence references;+2. state the rating status;+3. distinguish observed evidence from interpretation;+4. report uncertainty and disagreement;+5. state missing or not-applicable evidence;+6. explain context and limitations; and+7. offer non-prescriptive improvement options.++Do not label a person, declare a work “top-tier,” predict success, recommend a+decision, or conceal uncertainty behind a decimal.diff --git a/skills/scholar-evaluation/references/security_validation.md b/skills/scholar-evaluation/references/security_validation.mdnew file mode 100644index 00000000..4c934433--- /dev/null+++ b/skills/scholar-evaluation/references/security_validation.md@@ -0,0 +1,95 @@+# Security Validation Record++Validation date: **2026-07-23**++## Baseline++The repository `SECURITY.md` entry recorded **10 findings** with maximum+severity **CRITICAL**:++- four CRITICAL cross-file, environment, and network-exfiltration findings;+- three MEDIUM credential, prompt, and environment-harvesting findings; and+- three LOW cross-skill, command, and resource-use findings.++The affected files were the two former schematic-generation scripts and the+old `SKILL.md`.++## Remediation++- Deleted both schematic-generation scripts.+- Removed all network requests, API-key handling, environment access,+ environment-file loading, third-party model behavior, image handling,+ child-process execution, cross-skill invocation, and mandatory figure+ instructions.+- Replaced the former recommendation-producing score calculator with bounded,+ transparent descriptive rubric math.+- Added a strict prohibition on automated or assisted hiring, promotion,+ tenure, admissions, funding, awards, discipline, person ranking, and other+ high-impact personnel decisions.+- Added qualitative-first metric and prestige safeguards.+- Added construct, provenance, content-evidence, rater, agreement, uncertainty,+ missingness, not-applicable, traceability, sensitivity, subgroup, conflict,+ appeal, accessibility, privacy, and accountable-human controls.+- Added dependency-free, bounded local JSON/CSV tools with duplicate-key,+ unknown-field, size, depth, non-finite-number, symbolic-link, and private+ application-field rejection.+- Added minimized reports that never copy source-document content or emit rater+ identifiers.+- Added static AST tests that prohibit network libraries, dynamic-code calls,+ executable serialization, process launching, environment access, and the+ deleted schematic files.++## Validation results++- Agent Skills reference validator: **PASS**+- Dependency-free CLI help checks: **8 passed**+- Synthetic standard-library tests: **29 passed**+- Explicit AST parse with bytecode disabled: **8 scripts parsed**+- Bytecode artifacts: **0**+- IDE lints: **0**+- Documented local-path check: **PASS**+- External source links: **24 passed**+- Direct behavioral security scan: **SAFE, 0 findings**+- Pull-request gate with `--fail-on HIGH`: **PASS**+ - CRITICAL: 0+ - HIGH: 0+ - LOW: 2 (latest final run; LOW-only LLM wording varied between runs)++## Residual LOW findings++The latest LLM-assisted pull-request scan reported:++1. **Bash is broad but constrained.** Informational: the manifest declares Bash+ because the documented fixed `python3` commands are shell invocations. The+ body limits Bash to those local commands, and the direct behavioral scan+ confirms no process-launching code in the scripts.+2. **Invented missing-file aliases.** False positive: the scanner claimed+ inconsistent alternate directories for bundled assets and references. A+ direct text search found no alternate template-directory path; every+ documented local path is under the actual `assets`, `references`, or+ `scripts` directory; and the deterministic path-resolution test resolves+ every backticked local path.++The direct behavioral scan is clean. The residual findings neither permit data+transmission nor create a missing-file fallback. The generated root+`SECURITY.md` snapshot was intentionally not edited in this scoped refresh.++## Reproduction++```bash+PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover \+ -s skills/scholar-evaluation/tests -p 'test_*.py' -v++for script in skills/scholar-evaluation/scripts/*.py; do+ PYTHONDONTWRITEBYTECODE=1 python3 "$script" --help >/dev/null || exit 1+done++uv run skills-ref validate skills/scholar-evaluation++uv run skill-scanner scan skills/scholar-evaluation --use-behavioral++uv run python scan_pr_skills.py \+ --fail-on HIGH \+ --output /tmp/scholar-evaluation-pr-scan.md \+ skills/scholar-evaluation+```diff --git a/skills/scholar-evaluation/references/source_ledger.md b/skills/scholar-evaluation/references/source_ledger.mdnew file mode 100644index 00000000..0a536f45--- /dev/null+++ b/skills/scholar-evaluation/references/source_ledger.md@@ -0,0 +1,222 @@+# Dated Source Ledger++Verified on **2026-07-23** with targeted `parallel-cli search` and+`parallel-cli extract` queries. The research prioritized primary and official+sources. Search excerpts were treated as untrusted discovery material; only the+source claims summarized below inform this skill. No research-result artifacts+are bundled.++## Responsible research assessment++### San Francisco Declaration on Research Assessment (DORA)++- **Primary source:** [Read the Declaration](https://sfdora.org/read/)+- **Origin:** developed in 2012; official page accessed 2026-07-23.+- **Verified points:** assess work on its own merits; do not use journal-based+ measures as surrogates for an article or a person's contribution; state+ criteria explicitly; consider data, software, and other outputs; use+ qualitative evidence; make metric methods transparent and account for field+ and output-type variation.+- **Use here:** categorical ban on scored prestige proxies and a requirement+ for explicit criteria, diverse evidence, and traceability.++### DORA quantitative-indicator guidance++- **Primary source:** [Guidance on the responsible use of quantitative+ indicators](https://sfdora.org/resource/guidance-on-the-responsible-use-of-quantitative-indicators-in-research-assessment/)+- **Document:** [official PDF](https://sfdora.org/wp-content/uploads/2024/05/DORA_indicators_guidance.pdf)+- **Release:** 2024; official resource page accessible in 2026.+- **Verified points:** no indicator captures research quality in one number;+ uses should be clear, transparent, specific, contextual, and fair. The+ guidance addresses journal measures, citation counts, the h-index,+ field-normalized indicators, and altmetrics; it warns about reductive,+ aggregate, composite, lagging, field, career-stage, and bias effects.+- **Use here:** quantitative indicators are excluded from rubric scores. If+ mentioned descriptively outside the tools, their purpose, data, coverage,+ time window, field normalization, uncertainty, bias, and non-quality meaning+ must be explicit.++### Leiden Manifesto++- **Primary source:** Hicks, Wouters, Waltman, de Rijcke, and Rafols,+ [“Bibliometrics: The Leiden Manifesto for research+ metrics”](https://doi.org/10.1038/520429a), *Nature* 520, 429–431.+- **Published:** 2015-04-22.+- **Verified points:** quantitative evaluation should support qualitative+ expert assessment; measure against missions; protect locally relevant+ research; account for field variation; keep data and analysis open and+ verifiable; allow those evaluated to verify data; account for age and gender;+ avoid false precision; recognize gaming and system effects; review indicators+ regularly.+- **Use here:** contextualization, inspectability, uncertainty, fairness review,+ and periodic revision.++### Agreement on Reforming Research Assessment / CoARA++- **Primary record:** [Agreement on Reforming Research+ Assessment](https://doi.org/10.5281/zenodo.13480728), version 1.+- **Published:** 2022-07-20; Zenodo record modified 2024-08-29.+- **Current official overview:** [CoARA Agreement](https://coara.eu/agreement/the-agreement-full-text/)+- **Verified points:** recognize diverse outputs, practices, activities, roles,+ and careers; base assessment primarily on qualitative judgment with peer+ review central; use quantitative indicators responsibly; abandon+ inappropriate uses of journal- and publication-based measures, especially+ Journal Impact Factor and h-index; publish criteria; train assessors; review+ and evaluate criteria, tools, and processes.+- **Use here:** qualitative-first process, rubric provenance, rater training,+ monitoring, and no metric shortcut.++### Hong Kong Principles++- **Primary article:** Moher et al. (2020), [“The Hong Kong Principles for+ assessing researchers: Fostering research+ integrity”](https://doi.org/10.1371/journal.pbio.3000737), *PLOS Biology*+ 18(7):e3000737.+- **Published:** 2020-07-16.+- **Official implementation page:** [World Conferences on Research Integrity+ Foundation](https://www.wcrif.org/guidance/hong-kong-principles)+- **Verified points:** assess responsible practices, value complete reporting,+ reward open research, acknowledge diverse research activity, and recognize+ essential work such as review and mentoring.+- **Use here:** integrity, reporting, appropriate openness, and diverse+ contribution evidence. The principles do not supply validated score weights.++### The Metric Tide and its commissioned revisit++- **Primary public-sector source:** Research England/UKRI, [*The Metric+ Tide*](https://www.ukri.org/publications/review-of-metrics-in-research-assessment-and-management/).+- **Published:** 2015-07-06.+- **Revisit:** Curry, Gadd, and Wilsdon, [*Harnessing the Metric+ Tide*](https://doi.org/10.6084/m9.figshare.21701624).+- **Posted:** 2022-12-12; commissioned by the joint UK higher-education funding+ bodies for the Future Research Assessment Programme.+- **Verified points:** the revisit recommends putting principles into practice,+ evaluating with those evaluated, avoiding all-metric approaches, using data+ for public benefit, and rethinking rankings.+- **Status limitation:** *Harnessing the Metric Tide* describes itself as an+ independent input to deliberations, not the eventual policy conclusion.+- **Use here:** stakeholder participation, no all-metric process, and explicit+ scrutiny of rankings and system effects.++### Current UKRI guidance++- **Primary policy:** [UKRI funding assessment and decision-making policy and+ principles](https://www.ukri.org/publications/ukri-principles-of-assessment-and-decision-making/uk-research-and-innovation-ukri-funding-assessment-and-decision-making-policy-and-principles)+- **Primary implementation guidance:** [Résumé for Research and Innovation+ (R4RI)](https://www.ukri.org/apply-for-funding/develop-your-application/resume-for-research-and-innovation-r4ri-guidance/)+- **R4RI last updated:** 2026-04-30.+- **Verified points:** UKRI will not use journal-based measures as surrogates+ for article quality, individual contribution, or funding decisions. R4RI+ evidences a wider range of team contributions; assessors do not score its+ individual modules or view it in isolation.+- **Use here:** diverse contribution evidence and contextual review. This skill+ nevertheless blocks funding decisions entirely; the UKRI material is+ guidance context, not authorization to support such decisions.++### UNESCO Recommendation on Open Science++- **Primary source:** [UNESCO Recommendation on Open+ Science](https://unesdoc.unesco.org/ark:/48223/pf0000379949).+- **Adopted:** 2021-11-23 by the UNESCO General Conference.+- **Official overview:** [UNESCO Open Science](https://www.unesco.org/en/open-science/about)+- **Verified points:** quality and integrity, collective benefit, equity,+ fairness, diversity, inclusion, open engagement, training, and incentives+ aligned with open science; open science must not leave people, languages,+ disciplines, or knowledge systems behind.+- **Use here:** assess responsible openness in context. Privacy, safety,+ consent, sovereignty, and legitimate restrictions can outweigh openness.++### INORMS SCOPE framework++- **Primary source:** [SCOPE Framework full guide,+ v1.0](https://inorms.net/wp-content/uploads/2022/03/21655-scope-guide-v10.pdf).+- **Current official page:** [INORMS SCOPE Framework for Research+ Evaluation](https://inorms.net/scope-framework-for-research-evaluation).+- **Verified points:** Start with values; consider Context; identify Options;+ Probe for discrimination, gaming, unintended effects, and cost-benefit; and+ Evaluate the evaluation. Evaluate only where needed, with those evaluated,+ and with evaluation expertise.+- **Use here:** process design and the bias/process checklist.++### CRediT contributor taxonomy++- **Primary source:** [CRediT](https://credit.niso.org/).+- **Standard:** ANSI/NISO Z39.104-2022, approved 2022-01-14 and published+ 2022-02-08.+- **Verified points:** 14 roles provide transparent attribution of diverse+ contributions. CRediT does not determine authorship or contribution quality.+- **Use here:** optional vocabulary for contribution evidence, never a score.++## Measurement, fairness, accessibility, and privacy++### Standards for Educational and Psychological Testing++- **Primary source:** AERA, APA, and NCME, [*Standards for Educational and+ Psychological Testing*, 2014+ edition](https://www.testingstandards.net/uploads/7/6/6/4/76643089/standards_2014edition.pdf).+- **Official status page:** [APA Testing Standards](https://www.apa.org/science/programs/testing/standards).+- **Status:** the 2014 edition is open access; the sponsoring organizations+ announced a revision process. No later completed edition was verified.+- **Verified points:** intended interpretations and uses require validity+ evidence; reliability/precision and relevant errors should be reported;+ rater selection, training, qualification, monitoring, agreement, accuracy,+ and drift need documentation; fairness and subgroup validity require+ evidence; uncertainty should accompany estimates.+- **Use here:** these are measurement principles, not proof that this rubric is+ a psychological test. The template records evidence gaps and must not be+ described as validated psychometrics.++### Accessibility++- **Primary source:** W3C, [Web Content Accessibility Guidelines+ 2.2](https://www.w3.org/TR/WCAG22/).+- **Status:** W3C Recommendation published 2023-10-05; update noted+ 2024-12-12.+- **Use here:** accessible materials and reasonable accommodation processes+ are required; local legal and institutional requirements may be broader.++### Data protection++- **Primary guidance:** UK Information Commissioner's Office,+ [purpose limitation](https://ico.org.uk/for-organisations/uk-gdpr-guidance-and-resources/data-protection-principles/a-guide-to-the-data-protection-principles/purpose-limitation)+ and [data minimisation](https://ico.org.uk/for-organisations/uk-gdpr-guidance-and-resources/data-protection-principles/a-guide-to-the-data-protection-principles/data-minimisation).+- **Current guidance dates found:** purpose limitation updated 2026-03-23;+ data minimisation page published 2025-09-09.+- **Verified points:** specify legitimate purposes and process only adequate,+ relevant, necessary data; review and delete data no longer needed.+- **Use here:** scripts accept only minimized IDs, scores, statuses, and local+ references. They reject common private-application fields and never reproduce+ raw source documents.++## ScholarEval paper and project status++- **Exact paper:** Hanane Nour Moussa, Patrick Queiroz Da Silva, Daniel+ Adu-Ampratwum, Alyson East, Zitong Lu, Nikki Puccetti, Mingyi Xue, Huan Sun,+ Bodhisattwa Prasad Majumder, and Sachin Kumar, [*ScholarEval: Research Idea+ Evaluation Grounded in Literature*](https://arxiv.org/abs/2510.16234).+- **Verified status:** arXiv:2510.16234, submitted 2025-10-17; latest verified+ version **v2**, revised 2026-02-28. The displayed DOI+ `10.48550/arXiv.2510.16234` is an arXiv/DataCite DOI, not evidence of journal+ publication.+- **Official project:** [skai-research/ScholarEval](https://github.com/skai-research/ScholarEval).+ The repository describes itself as official code and data and cites the work+ as `@misc`; no release or peer-reviewed publication claim was verified.+- **Review-status caution:** a public OpenReview forum for the title was+ discoverable, but the official page's decision/status was not accessible or+ exposed in indexed primary-source text during this refresh. It is therefore+ not used as evidence of acceptance or peer review.+- **What the preprint reports:** a retrieval-augmented framework assessing+ research ideas for soundness and contribution; a 117-idea, four-discipline+ dataset; coverage comparisons against expert-annotated review points; and a+ user study.+- **What it does not establish:** validated psychometric measurement of+ scholar quality, transportability to personnel or funding decisions, validity+ of this skill's generalized rubric, stable cross-discipline score meaning, or+ freedom from subgroup bias.++## Review cadence++Re-check this ledger before any rubric adoption and at least annually. Re-check+the ScholarEval arXiv and official project records before describing its+publication status. Record any local disciplinary standards separately; a+global source cannot substitute for local construct validation.diff --git a/skills/scholar-evaluation/scripts/_common.py b/skills/scholar-evaluation/scripts/_common.pynew file mode 100644index 00000000..eb0d8034--- /dev/null+++ b/skills/scholar-evaluation/scripts/_common.py@@ -0,0 +1,986 @@+#!/usr/bin/env python3+"""Bounded, dependency-free helpers for local scholar-evaluation records."""++from __future__ import annotations++import json+import math+import re+from dataclasses import dataclass+from datetime import date+from pathlib import Path+from typing import Any, Iterable++SCHEMA_VERSION = "2.0"+NOTICE = (+ "DESCRIPTIVE DEVELOPMENTAL ASSESSMENT ONLY — NOT A DECISION "+ "RECOMMENDATION — QUALIFIED HUMAN REVIEW REQUIRED"+)+PROHIBITED_USES = {+ "admissions",+ "awards",+ "discipline",+ "funding",+ "hiring",+ "promotion",+ "tenure",+ "other_high_impact_personnel_decision",+}+ALLOWED_PURPOSE = "developmental_review_of_scholarly_work"+ALLOWED_UNIT = "scholarly_work"+ALLOWED_CLASSIFICATIONS = {+ "synthetic",+ "public_scholarly_work",+ "deidentified_low_stakes",+}+RATING_STATUSES = {"rated", "missing", "not_applicable"}++MAX_INPUT_BYTES = 2 * 1024 * 1024+MAX_OUTPUT_BYTES = 2 * 1024 * 1024+MAX_TEXT_CHARS = 4_000+MAX_LIST_ITEMS = 1_000+MAX_OBJECT_FIELDS = 100+MAX_DEPTH = 20+MAX_TOTAL_NODES = 25_000+MAX_CRITERIA = 50+MAX_EVALUATIONS = 50+MAX_CSV_ROWS = 20_000++IDENTIFIER_RE = re.compile(r"^[A-Za-z][A-Za-z0-9._:-]{1,95}$")+PRIVATE_FIELD_KEYS = {+ "applicant_name",+ "application_text",+ "candidate_name",+ "cv_text",+ "date_of_birth",+ "dob",+ "document_text",+ "email",+ "full_name",+ "home_address",+ "person_name",+ "phone",+ "private_application",+ "raw_application",+ "resume_text",+ "social_security_number",+ "ssn",+}+PROXY_TERMS = (+ "journal impact factor",+ "impact factor",+ "h-index",+ "h index",+ "citation count",+ "altmetric",+ "conference ranking",+ "journal ranking",+ "institution prestige",+ "journal prestige",+ "venue prestige",+ "university ranking",+)+++class ValidationError(ValueError):+ """A deterministic input failure that never includes a supplied value."""++ def __init__(self, code: str, path: str = "$") -> None:+ super().__init__(code)+ self.code = code+ self.path = path+++@dataclass(frozen=True)+class Issue:+ """A minimized validation issue."""++ code: str+ path: str+ level: str = "error"++ def as_dict(self) -> dict[str, str]:+ return {"code": self.code, "path": self.path, "level": self.level}+++def _pairs_no_duplicates(pairs: list[tuple[str, Any]]) -> dict[str, Any]:+ result: dict[str, Any] = {}+ for key, value in pairs:+ if key in result:+ raise ValidationError("JSON_DUPLICATE_KEY")+ result[key] = value+ return result+++def _check_local_file(path: Path, suffix: str) -> None:+ if path.suffix.lower() != suffix:+ raise ValidationError("INPUT_SUFFIX_NOT_ALLOWED")+ if not path.exists():+ raise ValidationError("INPUT_NOT_FOUND")+ if path.is_symlink():+ raise ValidationError("INPUT_SYMLINK_NOT_ALLOWED")+ if not path.is_file():+ raise ValidationError("INPUT_NOT_REGULAR_FILE")+ if path.stat().st_size > MAX_INPUT_BYTES:+ raise ValidationError("INPUT_TOO_LARGE")+++def _scan_structure(value: Any, path: str = "$") -> None:+ nodes = 0+ stack: list[tuple[Any, str, int]] = [(value, path, 0)]+ while stack:+ current, current_path, depth = stack.pop()+ nodes += 1+ if nodes > MAX_TOTAL_NODES:+ raise ValidationError("STRUCTURE_TOO_LARGE", current_path)+ if depth > MAX_DEPTH:+ raise ValidationError("STRUCTURE_TOO_DEEP", current_path)+ if isinstance(current, dict):+ if len(current) > MAX_OBJECT_FIELDS:+ raise ValidationError("OBJECT_TOO_LARGE", current_path)+ for key, child in current.items():+ if not isinstance(key, str):+ raise ValidationError("OBJECT_KEY_NOT_TEXT", current_path)+ normalized = key.strip().lower()+ if normalized in PRIVATE_FIELD_KEYS:+ raise ValidationError("PRIVATE_FIELD_NOT_ALLOWED", f"{current_path}.{key}")+ stack.append((child, f"{current_path}.{key}", depth + 1))+ elif isinstance(current, list):+ if len(current) > MAX_LIST_ITEMS:+ raise ValidationError("LIST_TOO_LARGE", current_path)+ for index, child in enumerate(current):+ stack.append((child, f"{current_path}[{index}]", depth + 1))+ elif isinstance(current, str) and len(current) > MAX_TEXT_CHARS:+ raise ValidationError("TEXT_TOO_LONG", current_path)+ elif current is not None and not isinstance(+ current, (str, int, float, bool)+ ):+ raise ValidationError("VALUE_TYPE_NOT_ALLOWED", current_path)+ if isinstance(current, float) and not math.isfinite(current):+ raise ValidationError("NUMBER_NOT_FINITE", current_path)+++def read_json(path: Path | str) -> Any:+ """Read bounded JSON with duplicate-key and private-field rejection."""++ local_path = Path(path)+ _check_local_file(local_path, ".json")+ try:+ data = json.loads(+ local_path.read_text(encoding="utf-8"),+ object_pairs_hook=_pairs_no_duplicates,+ )+ except UnicodeDecodeError as error:+ raise ValidationError("INPUT_NOT_UTF8") from error+ except json.JSONDecodeError as error:+ raise ValidationError("JSON_INVALID") from error+ _scan_structure(data)+ return data+++def read_csv_text(path: Path | str) -> str:+ """Read a bounded UTF-8 CSV file after local-path checks."""++ local_path = Path(path)+ _check_local_file(local_path, ".csv")+ try:+ return local_path.read_text(encoding="utf-8-sig")+ except UnicodeDecodeError as error:+ raise ValidationError("INPUT_NOT_UTF8") from error+++def write_json(+ value: dict[str, Any], output: Path | None, *, force: bool = False+) -> None:+ """Write deterministic JSON locally or print it to standard output."""++ rendered = json.dumps(value, indent=2, sort_keys=True, ensure_ascii=False) + "\n"+ if len(rendered.encode("utf-8")) > MAX_OUTPUT_BYTES:+ raise ValidationError("OUTPUT_TOO_LARGE")+ if output is None:+ print(rendered, end="")+ return+ if output.suffix.lower() != ".json":+ raise ValidationError("OUTPUT_SUFFIX_NOT_ALLOWED")+ if output.is_symlink():+ raise ValidationError("OUTPUT_SYMLINK_NOT_ALLOWED")+ if output.exists() and not force:+ raise ValidationError("OUTPUT_EXISTS")+ if not output.parent.exists() or not output.parent.is_dir():+ raise ValidationError("OUTPUT_PARENT_NOT_FOUND")+ output.write_text(rendered, encoding="utf-8")+++def failure_report(error: ValidationError) -> dict[str, Any]:+ return {+ "schema_version": SCHEMA_VERSION,+ "status": "error",+ "issues": [Issue(error.code, error.path).as_dict()],+ }+++def is_number(value: Any) -> bool:+ return isinstance(value, (int, float)) and not isinstance(value, bool)+++def is_identifier(value: Any) -> bool:+ return isinstance(value, str) and bool(IDENTIFIER_RE.fullmatch(value))+++def is_nonempty_text(value: Any, maximum: int = MAX_TEXT_CHARS) -> bool:+ return isinstance(value, str) and bool(value.strip()) and len(value) <= maximum+++def is_reference(value: Any) -> bool:+ if not is_nonempty_text(value, 500):+ return False+ lowered = value.strip().lower()+ return not (+ lowered.startswith(("http://", "https://", "file://"))+ or "\n" in value+ or "\r" in value+ )+++def is_date(value: Any) -> bool:+ if not isinstance(value, str):+ return False+ try:+ date.fromisoformat(value)+ except ValueError:+ return False+ return len(value) == 10+++def exact_keys(+ value: Any,+ expected: Iterable[str],+ path: str,+ issues: list[Issue],+) -> bool:+ if not isinstance(value, dict):+ issues.append(Issue("SCHEMA_OBJECT_REQUIRED", path))+ return False+ expected_set = set(expected)+ actual_set = set(value)+ for missing in sorted(expected_set - actual_set):+ issues.append(Issue("SCHEMA_REQUIRED_FIELD", f"{path}.{missing}"))+ for unknown in sorted(actual_set - expected_set):+ issues.append(Issue("SCHEMA_UNKNOWN_FIELD", f"{path}.{unknown}"))+ return not (expected_set - actual_set)+++def validate_identifier(+ value: Any, path: str, issues: list[Issue], code: str = "IDENTIFIER_INVALID"+) -> None:+ if not is_identifier(value):+ issues.append(Issue(code, path))+++def validate_reference(+ value: Any, path: str, issues: list[Issue], *, allow_empty: bool = False+) -> None:+ if allow_empty and value == "":+ return+ if not is_reference(value):+ issues.append(Issue("LOCAL_REFERENCE_INVALID", path))+++def validate_text(+ value: Any, path: str, issues: list[Issue], *, allow_empty: bool = False+) -> None:+ if allow_empty and value == "":+ return+ if not is_nonempty_text(value):+ issues.append(Issue("TEXT_INVALID", path))+++def validate_bool(value: Any, path: str, issues: list[Issue]) -> None:+ if not isinstance(value, bool):+ issues.append(Issue("BOOLEAN_REQUIRED", path))+++def validate_text_list(+ value: Any,+ path: str,+ issues: list[Issue],+ *,+ minimum: int = 0,+ maximum: int = 100,+ references: bool = False,+) -> None:+ if not isinstance(value, list):+ issues.append(Issue("LIST_REQUIRED", path))+ return+ if not minimum <= len(value) <= maximum:+ issues.append(Issue("LIST_LENGTH_INVALID", path))+ for index, item in enumerate(value):+ if references:+ validate_reference(item, f"{path}[{index}]", issues)+ else:+ validate_text(item, f"{path}[{index}]", issues)+++def _validate_scale(scale: Any, issues: list[Issue]) -> tuple[float, float, float]:+ path = "$.scale"+ expected = {"minimum", "maximum", "step", "anchors"}+ if not exact_keys(scale, expected, path, issues):+ return 0.0, 0.0, 1.0+ minimum = scale.get("minimum")+ maximum = scale.get("maximum")+ step = scale.get("step")+ if not is_number(minimum) or not is_number(maximum) or not is_number(step):+ issues.append(Issue("SCALE_NUMBER_REQUIRED", path))+ return 0.0, 0.0, 1.0+ minimum_f = float(minimum)+ maximum_f = float(maximum)+ step_f = float(step)+ if minimum_f < 0 or maximum_f <= minimum_f or maximum_f - minimum_f > 10:+ issues.append(Issue("SCALE_BOUNDS_INVALID", path))+ if step_f <= 0 or step_f > maximum_f - minimum_f:+ issues.append(Issue("SCALE_STEP_INVALID", f"{path}.step"))+ anchors = scale.get("anchors")+ if not isinstance(anchors, list) or not 2 <= len(anchors) <= 21:+ issues.append(Issue("SCALE_ANCHORS_INVALID", f"{path}.anchors"))+ return minimum_f, maximum_f, step_f+ anchor_scores: list[float] = []+ for index, anchor in enumerate(anchors):+ anchor_path = f"{path}.anchors[{index}]"+ if not exact_keys(anchor, {"score", "label", "description"}, anchor_path, issues):+ continue+ score = anchor.get("score")+ if not is_number(score):+ issues.append(Issue("ANCHOR_SCORE_INVALID", f"{anchor_path}.score"))+ else:+ anchor_scores.append(float(score))+ validate_text(anchor.get("label"), f"{anchor_path}.label", issues)+ validate_text(anchor.get("description"), f"{anchor_path}.description", issues)+ if anchor_scores:+ if len(anchor_scores) != len(set(anchor_scores)):+ issues.append(Issue("ANCHOR_SCORE_DUPLICATE", f"{path}.anchors"))+ if min(anchor_scores) != minimum_f or max(anchor_scores) != maximum_f:+ issues.append(Issue("ANCHOR_BOUNDS_MISSING", f"{path}.anchors"))+ return minimum_f, maximum_f, step_f+++def _validate_proxy_absence(value: Any, path: str, issues: list[Issue]) -> None:+ strings: list[str] = []+ stack = [value]+ while stack:+ current = stack.pop()+ if isinstance(current, str):+ strings.append(current.lower())+ elif isinstance(current, list):+ stack.extend(current)+ elif isinstance(current, dict):+ stack.extend(current.values())+ combined = "\n".join(strings)+ if any(term in combined for term in PROXY_TERMS):+ issues.append(Issue("PROXY_METRIC_CRITERION_PROHIBITED", path))+++def validate_rubric(rubric: Any) -> list[Issue]:+ """Validate the strict local rubric schema."""++ issues: list[Issue] = []+ top_keys = {+ "schema_version",+ "rubric_id",+ "title",+ "intended_use",+ "construct",+ "provenance",+ "scale",+ "criteria",+ "rater_protocol",+ "governance",+ }+ if not exact_keys(rubric, top_keys, "$", issues):+ return issues+ if rubric.get("schema_version") != SCHEMA_VERSION:+ issues.append(Issue("SCHEMA_VERSION_UNSUPPORTED", "$.schema_version"))+ validate_identifier(rubric.get("rubric_id"), "$.rubric_id", issues)+ validate_text(rubric.get("title"), "$.title", issues)++ intended = rubric.get("intended_use")+ if exact_keys(+ intended,+ {"purpose", "unit_of_assessment", "allowed_contexts", "prohibited_uses"},+ "$.intended_use",+ issues,+ ):+ if intended.get("purpose") != ALLOWED_PURPOSE:+ issues.append(Issue("PURPOSE_NOT_ALLOWED", "$.intended_use.purpose"))+ if intended.get("unit_of_assessment") != ALLOWED_UNIT:+ issues.append(+ Issue("UNIT_OF_ASSESSMENT_NOT_ALLOWED", "$.intended_use.unit_of_assessment")+ )+ validate_text_list(+ intended.get("allowed_contexts"),+ "$.intended_use.allowed_contexts",+ issues,+ minimum=1,+ maximum=20,+ )+ prohibited = intended.get("prohibited_uses")+ validate_text_list(+ prohibited,+ "$.intended_use.prohibited_uses",+ issues,+ minimum=len(PROHIBITED_USES),+ maximum=30,+ )+ prohibited_set = (+ set(prohibited)+ if isinstance(prohibited, list)+ and all(isinstance(item, str) for item in prohibited)+ else set()+ )+ if isinstance(prohibited, list) and not PROHIBITED_USES.issubset(+ prohibited_set+ ):+ issues.append(+ Issue("PROHIBITED_USES_INCOMPLETE", "$.intended_use.prohibited_uses")+ )++ construct = rubric.get("construct")+ if exact_keys(+ construct,+ {"label", "definition", "boundaries", "limitations"},+ "$.construct",+ issues,+ ):+ validate_text(construct.get("label"), "$.construct.label", issues)+ validate_text(construct.get("definition"), "$.construct.definition", issues)+ validate_text_list(+ construct.get("boundaries"),+ "$.construct.boundaries",+ issues,+ minimum=1,+ maximum=20,+ )+ validate_text_list(+ construct.get("limitations"),+ "$.construct.limitations",+ issues,+ minimum=1,+ maximum=20,+ )++ provenance = rubric.get("provenance")+ if exact_keys(+ provenance,+ {+ "rubric_version",+ "owner_role",+ "source_ids",+ "content_validity_status",+ "content_validity_evidence_ref",+ "last_reviewed_date",+ },+ "$.provenance",+ issues,+ ):+ validate_text(provenance.get("rubric_version"), "$.provenance.rubric_version", issues)+ validate_text(provenance.get("owner_role"), "$.provenance.owner_role", issues)+ validate_text_list(+ provenance.get("source_ids"),+ "$.provenance.source_ids",+ issues,+ minimum=1,+ maximum=50,+ references=True,+ )+ validity_status = provenance.get("content_validity_status")+ if validity_status not in {"not_established", "pilot_evidence", "documented"}:+ issues.append(+ Issue(+ "CONTENT_VALIDITY_STATUS_INVALID",+ "$.provenance.content_validity_status",+ )+ )+ validate_reference(+ provenance.get("content_validity_evidence_ref"),+ "$.provenance.content_validity_evidence_ref",+ issues,+ allow_empty=validity_status == "not_established",+ )+ if validity_status != "documented":+ issues.append(+ Issue(+ "CONTENT_VALIDITY_NOT_DOCUMENTED",+ "$.provenance.content_validity_status",+ "warning",+ )+ )+ if not is_date(provenance.get("last_reviewed_date")):+ issues.append(Issue("DATE_INVALID", "$.provenance.last_reviewed_date"))++ scale_object = rubric.get("scale")+ minimum, maximum, step = _validate_scale(scale_object, issues)+ raw_scale_anchors = (+ scale_object.get("anchors") if isinstance(scale_object, dict) else []+ )+ if not isinstance(raw_scale_anchors, list):+ raw_scale_anchors = []+ scale_anchor_scores = {+ float(anchor["score"])+ for anchor in raw_scale_anchors+ if isinstance(anchor, dict) and is_number(anchor.get("score"))+ }++ criteria = rubric.get("criteria")+ criterion_ids: set[str] = set()+ total_weight = 0.0+ if not isinstance(criteria, list) or not 1 <= len(criteria) <= MAX_CRITERIA:+ issues.append(Issue("CRITERIA_INVALID", "$.criteria"))+ else:+ for index, criterion in enumerate(criteria):+ path = f"$.criteria[{index}]"+ if not exact_keys(+ criterion,+ {+ "criterion_id",+ "label",+ "construct_component",+ "weight",+ "required",+ "anchors",+ "evidence_requirements",+ "limitations",+ },+ path,+ issues,+ ):+ continue+ criterion_id = criterion.get("criterion_id")+ validate_identifier(criterion_id, f"{path}.criterion_id", issues)+ if isinstance(criterion_id, str):+ if criterion_id in criterion_ids:+ issues.append(Issue("CRITERION_ID_DUPLICATE", f"{path}.criterion_id"))+ criterion_ids.add(criterion_id)+ validate_text(criterion.get("label"), f"{path}.label", issues)+ validate_text(+ criterion.get("construct_component"),+ f"{path}.construct_component",+ issues,+ )+ validate_bool(criterion.get("required"), f"{path}.required", issues)+ weight = criterion.get("weight")+ if not is_number(weight) or not 0 < float(weight) <= 1:+ issues.append(Issue("CRITERION_WEIGHT_INVALID", f"{path}.weight"))+ else:+ total_weight += float(weight)+ validate_text_list(+ criterion.get("evidence_requirements"),+ f"{path}.evidence_requirements",+ issues,+ minimum=1,+ maximum=20,+ )+ validate_text_list(+ criterion.get("limitations"),+ f"{path}.limitations",+ issues,+ minimum=1,+ maximum=20,+ )+ anchors = criterion.get("anchors")+ criterion_anchor_scores: set[float] = set()+ if not isinstance(anchors, list) or not 2 <= len(anchors) <= 21:+ issues.append(Issue("CRITERION_ANCHORS_INVALID", f"{path}.anchors"))+ else:+ for anchor_index, anchor in enumerate(anchors):+ anchor_path = f"{path}.anchors[{anchor_index}]"+ if not exact_keys(+ anchor, {"score", "description"}, anchor_path, issues+ ):+ continue+ if not is_number(anchor.get("score")):+ issues.append(+ Issue("ANCHOR_SCORE_INVALID", f"{anchor_path}.score")+ )+ else:+ criterion_anchor_scores.add(float(anchor["score"]))+ validate_text(+ anchor.get("description"),+ f"{anchor_path}.description",+ issues,+ )+ if criterion_anchor_scores != scale_anchor_scores:+ issues.append(Issue("CRITERION_ANCHORS_INCOMPLETE", f"{path}.anchors"))+ _validate_proxy_absence(criterion, path, issues)+ if criteria and not math.isclose(total_weight, 1.0, abs_tol=1e-9):+ issues.append(Issue("CRITERION_WEIGHTS_MUST_SUM_TO_ONE", "$.criteria"))++ protocol = rubric.get("rater_protocol")+ if exact_keys(+ protocol,+ {+ "minimum_raters",+ "training_required",+ "training_ref",+ "calibration_required",+ "calibration_ref",+ "agreement_method",+ "inter_rater_reliability_status",+ "inter_rater_reliability_ref",+ "drift_monitoring_required",+ "drift_review_ref",+ },+ "$.rater_protocol",+ issues,+ ):+ minimum_raters = protocol.get("minimum_raters")+ if (+ not isinstance(minimum_raters, int)+ or isinstance(minimum_raters, bool)+ or not 2 <= minimum_raters <= 50+ ):+ issues.append(+ Issue("MINIMUM_RATERS_INVALID", "$.rater_protocol.minimum_raters")+ )+ for field in (+ "training_required",+ "calibration_required",+ "drift_monitoring_required",+ ):+ validate_bool(protocol.get(field), f"$.rater_protocol.{field}", issues)+ if protocol.get(field) is not True:+ issues.append(+ Issue("RATER_CONTROL_MUST_BE_REQUIRED", f"$.rater_protocol.{field}")+ )+ for field in ("training_ref", "calibration_ref", "drift_review_ref"):+ validate_reference(protocol.get(field), f"$.rater_protocol.{field}", issues)+ if protocol.get("agreement_method") != (+ "exact_within_step_and_mean_absolute_difference"+ ):+ issues.append(+ Issue(+ "AGREEMENT_METHOD_INVALID", "$.rater_protocol.agreement_method"+ )+ )+ reliability_status = protocol.get("inter_rater_reliability_status")+ if reliability_status not in {+ "not_established",+ "pilot_evidence",+ "documented",+ }:+ issues.append(+ Issue(+ "INTER_RATER_RELIABILITY_STATUS_INVALID",+ "$.rater_protocol.inter_rater_reliability_status",+ )+ )+ validate_reference(+ protocol.get("inter_rater_reliability_ref"),+ "$.rater_protocol.inter_rater_reliability_ref",+ issues,+ allow_empty=reliability_status == "not_established",+ )+ if reliability_status != "documented":+ issues.append(+ Issue(+ "INTER_RATER_RELIABILITY_NOT_DOCUMENTED",+ "$.rater_protocol.inter_rater_reliability_status",+ "warning",+ )+ )++ governance = rubric.get("governance")+ governance_bool_fields = (+ "accountable_committee_required",+ "conflict_disclosure_required",+ "recusal_required",+ "appeal_process_required",+ "accessibility_accommodations_required",+ "data_protection_review_required",+ "subgroup_bias_review_required",+ )+ governance_ref_fields = (+ "committee_owner_role",+ "appeal_process_ref",+ "accessibility_process_ref",+ "data_protection_process_ref",+ "subgroup_review_ref",+ "review_cycle_ref",+ )+ if exact_keys(+ governance,+ set(governance_bool_fields) | set(governance_ref_fields),+ "$.governance",+ issues,+ ):+ for field in governance_bool_fields:+ validate_bool(governance.get(field), f"$.governance.{field}", issues)+ if governance.get(field) is not True:+ issues.append(+ Issue("GOVERNANCE_CONTROL_MUST_BE_REQUIRED", f"$.governance.{field}")+ )+ for field in governance_ref_fields:+ validate_reference(governance.get(field), f"$.governance.{field}", issues)++ if maximum <= minimum or step <= 0:+ issues.append(Issue("SCALE_UNUSABLE", "$.scale"))+ return issues+++def scale_values(rubric: dict[str, Any]) -> set[float]:+ return {+ float(anchor["score"])+ for anchor in rubric["scale"]["anchors"]+ if is_number(anchor["score"])+ }+++def validate_evaluation(+ evaluation: Any, rubric: dict[str, Any]+) -> list[Issue]:+ """Validate one strict scholarly-work evaluation record."""++ issues: list[Issue] = []+ if not exact_keys(+ evaluation,+ {+ "schema_version",+ "evaluation_id",+ "rubric_id",+ "work_id",+ "data_classification",+ "purpose",+ "ratings",+ },+ "$",+ issues,+ ):+ return issues+ if evaluation.get("schema_version") != SCHEMA_VERSION:+ issues.append(Issue("SCHEMA_VERSION_UNSUPPORTED", "$.schema_version"))+ validate_identifier(evaluation.get("evaluation_id"), "$.evaluation_id", issues)+ validate_identifier(evaluation.get("rubric_id"), "$.rubric_id", issues)+ validate_identifier(evaluation.get("work_id"), "$.work_id", issues)+ if evaluation.get("rubric_id") != rubric.get("rubric_id"):+ issues.append(Issue("RUBRIC_ID_MISMATCH", "$.rubric_id"))+ if evaluation.get("data_classification") not in ALLOWED_CLASSIFICATIONS:+ issues.append(Issue("DATA_CLASSIFICATION_NOT_ALLOWED", "$.data_classification"))+ if evaluation.get("purpose") != ALLOWED_PURPOSE:+ issues.append(Issue("PURPOSE_NOT_ALLOWED", "$.purpose"))++ criteria = {criterion["criterion_id"]: criterion for criterion in rubric["criteria"]}+ accepted_scores = scale_values(rubric)+ maximum_uncertainty = float(rubric["scale"]["maximum"]) - float(+ rubric["scale"]["minimum"]+ )+ ratings = evaluation.get("ratings")+ seen: set[str] = set()+ if not isinstance(ratings, list) or not 1 <= len(ratings) <= MAX_CRITERIA:+ issues.append(Issue("RATINGS_INVALID", "$.ratings"))+ return issues+ for index, rating in enumerate(ratings):+ path = f"$.ratings[{index}]"+ if not exact_keys(+ rating,+ {+ "criterion_id",+ "status",+ "score",+ "uncertainty",+ "evidence_ids",+ "rationale_ref",+ },+ path,+ issues,+ ):+ continue+ criterion_id = rating.get("criterion_id")+ validate_identifier(criterion_id, f"{path}.criterion_id", issues)+ if isinstance(criterion_id, str):+ if criterion_id in seen:+ issues.append(Issue("RATING_DUPLICATE", f"{path}.criterion_id"))+ seen.add(criterion_id)+ if criterion_id not in criteria:+ issues.append(Issue("CRITERION_UNKNOWN", f"{path}.criterion_id"))+ status = rating.get("status")+ if status not in RATING_STATUSES:+ issues.append(Issue("RATING_STATUS_INVALID", f"{path}.status"))+ evidence_ids = rating.get("evidence_ids")+ if not isinstance(evidence_ids, list) or len(evidence_ids) > 100:+ issues.append(Issue("EVIDENCE_IDS_INVALID", f"{path}.evidence_ids"))+ evidence_ids = []+ else:+ hashable_evidence_ids = [+ evidence_id+ for evidence_id in evidence_ids+ if isinstance(evidence_id, str)+ ]+ if len(hashable_evidence_ids) != len(set(hashable_evidence_ids)):+ issues.append(Issue("EVIDENCE_ID_DUPLICATE", f"{path}.evidence_ids"))+ for evidence_index, evidence_id in enumerate(evidence_ids):+ validate_identifier(+ evidence_id,+ f"{path}.evidence_ids[{evidence_index}]",+ issues,+ "EVIDENCE_ID_INVALID",+ )+ validate_reference(rating.get("rationale_ref"), f"{path}.rationale_ref", issues)+ if status == "rated":+ score = rating.get("score")+ uncertainty = rating.get("uncertainty")+ if not is_number(score) or float(score) not in accepted_scores:+ issues.append(Issue("SCORE_NOT_ON_SCALE", f"{path}.score"))+ if (+ not is_number(uncertainty)+ or not 0 <= float(uncertainty) <= maximum_uncertainty+ ):+ issues.append(Issue("UNCERTAINTY_INVALID", f"{path}.uncertainty"))+ if not evidence_ids:+ issues.append(Issue("RATED_EVIDENCE_REQUIRED", f"{path}.evidence_ids"))+ elif status in {"missing", "not_applicable"}:+ if rating.get("score") is not None:+ issues.append(Issue("UNRATED_SCORE_MUST_BE_NULL", f"{path}.score"))+ if rating.get("uncertainty") is not None:+ issues.append(+ Issue("UNRATED_UNCERTAINTY_MUST_BE_NULL", f"{path}.uncertainty")+ )+ if evidence_ids:+ issues.append(+ Issue("UNRATED_EVIDENCE_MUST_BE_EMPTY", f"{path}.evidence_ids")+ )+ missing_criteria = set(criteria) - seen+ for criterion_id in sorted(missing_criteria):+ issues.append(Issue("CRITERION_RATING_REQUIRED", f"$.ratings.{criterion_id}"))+ return issues+++def error_issues(issues: Iterable[Issue]) -> list[Issue]:+ return [issue for issue in issues if issue.level == "error"]+++def require_valid(issues: Iterable[Issue]) -> None:+ errors = error_issues(issues)+ if errors:+ raise ValidationError(errors[0].code, errors[0].path)+++def rounded(value: float | None) -> float | None:+ if value is None:+ return None+ return round(value, 6)+++def weights_by_criterion(rubric: dict[str, Any]) -> dict[str, float]:+ return {+ criterion["criterion_id"]: float(criterion["weight"])+ for criterion in rubric["criteria"]+ }+++def score_evaluation(+ rubric: dict[str, Any],+ evaluation: dict[str, Any],+ *,+ weights: dict[str, float] | None = None,+) -> dict[str, Any]:+ """Calculate bounded descriptive rubric math without a recommendation."""++ selected_weights = weights or weights_by_criterion(rubric)+ scale_minimum = float(rubric["scale"]["minimum"])+ scale_maximum = float(rubric["scale"]["maximum"])+ rating_by_id = {+ rating["criterion_id"]: rating for rating in evaluation["ratings"]+ }+ criteria_output: list[dict[str, Any]] = []+ weighted_sum = 0.0+ lower_sum = 0.0+ upper_sum = 0.0+ rated_weight = 0.0+ missing_weight = 0.0+ not_applicable_weight = 0.0+ for criterion in rubric["criteria"]:+ criterion_id = criterion["criterion_id"]+ rating = rating_by_id[criterion_id]+ weight = float(selected_weights[criterion_id])+ status = rating["status"]+ item: dict[str, Any] = {+ "criterion_id": criterion_id,+ "status": status,+ "weight": rounded(weight),+ "score": None,+ "uncertainty": None,+ "weighted_contribution": None,+ "lower_contribution": None,+ "upper_contribution": None,+ }+ if status == "rated":+ score = float(rating["score"])+ uncertainty = float(rating["uncertainty"])+ lower = max(scale_minimum, score - uncertainty)+ upper = min(scale_maximum, score + uncertainty)+ contribution = weight * score+ weighted_sum += contribution+ lower_sum += weight * lower+ upper_sum += weight * upper+ rated_weight += weight+ item.update(+ {+ "score": rounded(score),+ "uncertainty": rounded(uncertainty),+ "weighted_contribution": rounded(contribution),+ "lower_contribution": rounded(weight * lower),+ "upper_contribution": rounded(weight * upper),+ }+ )+ elif status == "missing":+ missing_weight += weight+ else:+ not_applicable_weight += weight+ criteria_output.append(item)+ applicable_weight = rated_weight + missing_weight+ normalized = weighted_sum / rated_weight if rated_weight else None+ lower_score = lower_sum / rated_weight if rated_weight else None+ upper_score = upper_sum / rated_weight if rated_weight else None+ coverage = rated_weight / applicable_weight if applicable_weight else None+ warnings: list[str] = []+ if missing_weight > 0:+ warnings.append("MISSING_RATINGS_EXCLUDED_FROM_NORMALIZED_SCORE")+ if not_applicable_weight > 0:+ warnings.append("NOT_APPLICABLE_RATINGS_EXCLUDED")+ if coverage is None or coverage < 1.0:+ warnings.append("INCOMPLETE_APPLICABLE_COVERAGE")+ if normalized is None:+ warnings.append("NO_NORMALIZED_SCORE_AVAILABLE")+ return {+ "schema_version": SCHEMA_VERSION,+ "report_type": "bounded_descriptive_rubric_score",+ "notice": NOTICE,+ "evaluation_id": evaluation["evaluation_id"],+ "work_id": evaluation["work_id"],+ "rubric_id": rubric["rubric_id"],+ "scale": {"minimum": scale_minimum, "maximum": scale_maximum},+ "formula": (+ "normalized_score = sum(score_i * weight_i for rated criteria) "+ "/ sum(weight_i for rated criteria); missing and not_applicable "+ "criteria are reported and excluded"+ ),+ "criteria": criteria_output,+ "aggregates": {+ "total_weight": rounded(sum(selected_weights.values())),+ "applicable_weight": rounded(applicable_weight),+ "rated_weight": rounded(rated_weight),+ "missing_weight": rounded(missing_weight),+ "not_applicable_weight": rounded(not_applicable_weight),+ "coverage_of_applicable_weight": rounded(coverage),+ "weighted_sum": rounded(weighted_sum),+ "normalized_score": rounded(normalized),+ "uncertainty_interval": {+ "lower": rounded(lower_score),+ "upper": rounded(upper_score),+ "method": (+ "weighted aggregation of criterion-level bounded uncertainty "+ "intervals; not a confidence interval"+ ),+ },+ },+ "warnings": warnings,+ "decision_recommendation_provided": False,+ }diff --git a/skills/scholar-evaluation/scripts/calculate_scores.py b/skills/scholar-evaluation/scripts/calculate_scores.pyindex e705b84e..d6eb5d6e 100644--- a/skills/scholar-evaluation/scripts/calculate_scores.py+++ b/skills/scholar-evaluation/scripts/calculate_scores.py@@ -1,378 +1,57 @@#!/usr/bin/env python3-"""-ScholarEval Score Calculator+"""Calculate transparent bounded rubric math for one scholarly work."""-Calculate aggregate evaluation scores from dimension-level ratings.-Supports weighted averaging, threshold analysis, and score visualization.+from __future__ import annotations-Usage:- python calculate_scores.py --scores <dimension_scores.json> --output <report.txt>- python calculate_scores.py --scores <dimension_scores.json> --weights <weights.json>- python calculate_scores.py --interactive--Author: ScholarEval Framework-License: MIT-"""--import jsonimport argparse-import sys-from typing import Dict, List, Optionalfrom pathlib import Path+import _common-# Default dimension weights (total = 100%)-DEFAULT_WEIGHTS = {- "problem_formulation": 0.15,- "literature_review": 0.15,- "methodology": 0.20,- "data_collection": 0.10,- "analysis": 0.15,- "results": 0.10,- "writing": 0.10,- "citations": 0.05-}--# Quality level definitions-QUALITY_LEVELS = {- (4.5, 5.0): ("Exceptional", "Ready for top-tier publication"),- (4.0, 4.4): ("Strong", "Publication-ready with minor revisions"),- (3.5, 3.9): ("Good", "Major revisions required, promising work"),- (3.0, 3.4): ("Acceptable", "Significant revisions needed"),- (2.0, 2.9): ("Weak", "Fundamental issues, major rework required"),- (0.0, 1.9): ("Poor", "Not suitable without complete revision")-}---def load_scores(filepath: Path) -> Dict[str, float]:- """Load dimension scores from JSON file."""- try:- with open(filepath, 'r') as f:- scores = json.load(f)-- # Validate scores- for dim, score in scores.items():- if not 1 <= score <= 5:- raise ValueError(f"Score for {dim} must be between 1 and 5, got {score}")-- return scores- except FileNotFoundError:- print(f"Error: File not found: {filepath}")- sys.exit(1)- except json.JSONDecodeError:- print(f"Error: Invalid JSON in {filepath}")- sys.exit(1)- except ValueError as e:- print(f"Error: {e}")- sys.exit(1)---def load_weights(filepath: Optional[Path] = None) -> Dict[str, float]:- """Load dimension weights from JSON file or return defaults."""- if filepath is None:- return DEFAULT_WEIGHTS-- try:- with open(filepath, 'r') as f:- weights = json.load(f)-- # Validate weights sum to 1.0- total = sum(weights.values())- if not 0.99 <= total <= 1.01: # Allow small floating point errors- raise ValueError(f"Weights must sum to 1.0, got {total}")-- return weights- except FileNotFoundError:- print(f"Error: File not found: {filepath}")- sys.exit(1)- except json.JSONDecodeError:- print(f"Error: Invalid JSON in {filepath}")- sys.exit(1)- except ValueError as e:- print(f"Error: {e}")- sys.exit(1)---def calculate_weighted_average(scores: Dict[str, float], weights: Dict[str, float]) -> float:- """Calculate weighted average score."""- total_score = 0.0- total_weight = 0.0-- for dimension, score in scores.items():- # Handle dimension name variations (e.g., "problem_formulation" vs "problem-formulation")- dim_key = dimension.replace('-', '_').lower()- weight = weights.get(dim_key, 0.0)-- total_score += score * weight- total_weight += weight- # Normalize if not all dimensions were scored- if total_weight > 0:- return total_score / total_weight * (sum(weights.values()) / total_weight)- return 0.0---def get_quality_level(score: float) -> tuple:- """Get quality level description for a given score."""- for (low, high), (level, description) in QUALITY_LEVELS.items():- if low <= score <= high:- return level, description- return "Unknown", "Score out of expected range"---def generate_bar_chart(scores: Dict[str, float], max_width: int = 50) -> str:- """Generate ASCII bar chart of dimension scores."""- lines = []- max_name_len = max(len(name) for name in scores.keys())-- for dimension, score in sorted(scores.items(), key=lambda x: x[1], reverse=True):- bar_length = int((score / 5.0) * max_width)- bar = '█' * bar_length- padding = ' ' * (max_name_len - len(dimension))- lines.append(f" {dimension}{padding} │ {bar} {score:.2f}")-- return '\n'.join(lines)---def identify_strengths_weaknesses(scores: Dict[str, float]) -> tuple:- """Identify top strengths and areas for improvement."""- sorted_scores = sorted(scores.items(), key=lambda x: x[1], reverse=True)-- strengths = [dim for dim, score in sorted_scores[:3] if score >= 4.0]- weaknesses = [dim for dim, score in sorted_scores[-3:] if score < 3.5]-- return strengths, weaknesses---def generate_report(scores: Dict[str, float], weights: Dict[str, float],- output_file: Optional[Path] = None) -> str:- """Generate comprehensive evaluation report."""- overall_score = calculate_weighted_average(scores, weights)- quality_level, quality_desc = get_quality_level(overall_score)- strengths, weaknesses = identify_strengths_weaknesses(scores)-- report_lines = [- "="*70,- "SCHOLAREVAL SCORE REPORT",- "="*70,- "",- f"Overall Score: {overall_score:.2f} / 5.00",- f"Quality Level: {quality_level}",- f"Assessment: {quality_desc}",- "",- "="*70,- "DIMENSION SCORES",- "="*70,- "",- generate_bar_chart(scores),- "",- "="*70,- "DETAILED BREAKDOWN",- "="*70,- ""+def calculate(rubric: dict, evaluation: dict) -> dict:+ rubric_issues = _common.validate_rubric(rubric)+ _common.require_valid(rubric_issues)+ evaluation_issues = _common.validate_evaluation(evaluation, rubric)+ _common.require_valid(evaluation_issues)+ report = _common.score_evaluation(rubric, evaluation)+ report["rubric_warnings"] = [+ issue.as_dict() for issue in rubric_issues if issue.level == "warning"]-- # Add detailed scores with weights- for dimension, score in sorted(scores.items()):- dim_key = dimension.replace('-', '_').lower()- weight = weights.get(dim_key, 0.0)- weighted_contribution = score * weight- percentage = weight * 100-- report_lines.append(- f" {dimension:25s} {score:.2f}/5.00 "- f"(weight: {percentage:4.1f}%, contribution: {weighted_contribution:.3f})"- )-- report_lines.extend([- "",- "="*70,- "ASSESSMENT SUMMARY",- "="*70,- ""- ])-- if strengths:- report_lines.append("Top Strengths:")- for dim in strengths:- report_lines.append(f" • {dim}: {scores[dim]:.2f}/5.00")- report_lines.append("")-- if weaknesses:- report_lines.append("Areas for Improvement:")- for dim in weaknesses:- report_lines.append(f" • {dim}: {scores[dim]:.2f}/5.00")- report_lines.append("")-- # Add recommendations based on score- report_lines.extend([- "="*70,- "RECOMMENDATIONS",- "="*70,- ""- ])-- if overall_score >= 4.5:- report_lines.append(" Excellent work! Ready for submission to top-tier venues.")- elif overall_score >= 4.0:- report_lines.append(" Strong work. Address minor issues identified in weaknesses.")- elif overall_score >= 3.5:- report_lines.append(" Good foundation. Focus on major revisions in weak dimensions.")- elif overall_score >= 3.0:- report_lines.append(" Significant revisions needed. Prioritize weakest dimensions.")- elif overall_score >= 2.0:- report_lines.append(" Major rework required. Consider restructuring approach.")- else:- report_lines.append(" Fundamental revision needed across multiple dimensions.")-- report_lines.append("")- report_lines.append("="*70)-- report = '\n'.join(report_lines)-- # Write to file if specified- if output_file:- try:- with open(output_file, 'w') as f:- f.write(report)- print(f"\nReport saved to: {output_file}")- except IOError as e:- print(f"Error writing to {output_file}: {e}")-return report-def interactive_mode():- """Run interactive score entry mode."""- print("ScholarEval Interactive Score Calculator")- print("="*50)- print("\nEnter scores for each dimension (1-5):")- print("(Press Enter to skip a dimension)\n")-- scores = {}- dimensions = [- "problem_formulation",- "literature_review",- "methodology",- "data_collection",- "analysis",- "results",- "writing",- "citations"- ]-- for dim in dimensions:- while True:- dim_display = dim.replace('_', ' ').title()- user_input = input(f"{dim_display}: ").strip()-- if not user_input:- break-- try:- score = float(user_input)- if 1 <= score <= 5:- scores[dim] = score- break- else:- print(" Score must be between 1 and 5")- except ValueError:- print(" Invalid input. Please enter a number between 1 and 5")-- if not scores:- print("\nNo scores entered. Exiting.")- return-- print("\n" + "="*50)- print("SCORES ENTERED:")- for dim, score in scores.items():- print(f" {dim.replace('_', ' ').title()}: {score}")-- print("\nCalculating overall assessment...\n")-- report = generate_report(scores, DEFAULT_WEIGHTS)- print(report)-- # Ask if user wants to save- save = input("\nSave report to file? (y/n): ").strip().lower()- if save == 'y':- filename = input("Enter filename [scholareval_report.txt]: ").strip()- if not filename:- filename = "scholareval_report.txt"- generate_report(scores, DEFAULT_WEIGHTS, Path(filename))---def main():+def build_parser() -> argparse.ArgumentParser:parser = argparse.ArgumentParser(- description="Calculate aggregate ScholarEval scores from dimension ratings",- formatter_class=argparse.RawDescriptionHelpFormatter,- epilog="""-Examples:- # Calculate from JSON file- python calculate_scores.py --scores my_scores.json-- # Calculate with custom weights- python calculate_scores.py --scores my_scores.json --weights custom_weights.json-- # Save report to file- python calculate_scores.py --scores my_scores.json --output report.txt-- # Interactive mode- python calculate_scores.py --interactive--Score JSON Format:- {- "problem_formulation": 4.5,- "literature_review": 4.0,- "methodology": 3.5,- "data_collection": 4.0,- "analysis": 3.5,- "results": 4.0,- "writing": 4.5,- "citations": 4.0- }--Weights JSON Format:- {- "problem_formulation": 0.15,- "literature_review": 0.15,- "methodology": 0.20,- "data_collection": 0.10,- "analysis": 0.15,- "results": 0.10,- "writing": 0.10,- "citations": 0.05- }- """+ description=(+ "Compute bounded descriptive rubric scores with explicit missing, "+ "not-applicable, coverage, and uncertainty fields. The output never "+ "makes a decision recommendation."+ ))-- parser.add_argument('--scores', type=Path, help='Path to JSON file with dimension scores')- parser.add_argument('--weights', type=Path, help='Path to JSON file with dimension weights (optional)')- parser.add_argument('--output', type=Path, help='Path to output report file (optional)')- parser.add_argument('--interactive', '-i', action='store_true', help='Run in interactive mode')-- args = parser.parse_args()-- # Interactive mode- if args.interactive:- interactive_mode()- return-- # File mode- if not args.scores:- parser.print_help()- print("\nError: --scores is required (or use --interactive)")- sys.exit(1)-- scores = load_scores(args.scores)- weights = load_weights(args.weights)-- report = generate_report(scores, weights, args.output)-- # Print to stdout if no output file specified- if not args.output:- print(report)+ parser.add_argument("--rubric", required=True, type=Path, help="Local rubric JSON")+ parser.add_argument(+ "--evaluation", required=True, type=Path, help="Local evaluation JSON"+ )+ parser.add_argument("--output", type=Path, help="Optional local JSON report")+ parser.add_argument(+ "--force", action="store_true", help="Replace an existing output JSON file"+ )+ return parser-if __name__ == '__main__':- main()+def main() -> int:+ args = build_parser().parse_args()+ try:+ rubric = _common.read_json(args.rubric)+ evaluation = _common.read_json(args.evaluation)+ report = calculate(rubric, evaluation)+ _common.write_json(report, args.output, force=args.force)+ return 0+ except _common.ValidationError as error:+ _common.write_json(_common.failure_report(error), None)+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/scholar-evaluation/scripts/check_process.py b/skills/scholar-evaluation/scripts/check_process.pynew file mode 100644index 00000000..b9c2819e--- /dev/null+++ b/skills/scholar-evaluation/scripts/check_process.py@@ -0,0 +1,231 @@+#!/usr/bin/env python3+"""Check low-stakes assessment governance and bias-process controls."""++from __future__ import annotations++import argparse+from pathlib import Path+from typing import Any++import _common++SECTION_FIELDS: dict[str, dict[str, tuple[str, ...]]] = {+ "committee": {+ "booleans": ("qualified_members_confirmed", "training_completed"),+ "references": ("accountable_owner_role", "training_record_ref"),+ },+ "conflicts": {+ "booleans": (+ "disclosure_process_confirmed",+ "recusal_process_confirmed",+ ),+ "references": ("record_ref",),+ },+ "appeals": {+ "booleans": ("process_confirmed",),+ "references": ("process_ref", "notice_ref"),+ },+ "accessibility": {+ "booleans": (+ "accommodations_process_confirmed",+ "accessible_materials_confirmed",+ ),+ "references": ("process_ref",),+ },+ "data_protection": {+ "booleans": (+ "purpose_limitation_confirmed",+ "data_minimisation_confirmed",+ "access_controls_confirmed",+ "retention_schedule_confirmed",+ "raw_private_documents_excluded_from_tool_outputs",+ ),+ "references": ("review_ref",),+ },+ "rubric_quality": {+ "booleans": (+ "construct_documented",+ "rubric_provenance_documented",+ "content_validity_documented",+ "rater_training_documented",+ "agreement_reviewed",+ "inter_rater_reliability_reviewed",+ "uncertainty_recorded",+ "missing_and_not_applicable_supported",+ "evidence_traceability_checked",+ "weight_sensitivity_reviewed",+ ),+ "references": ("quality_record_ref",),+ },+ "fairness": {+ "booleans": (+ "stakeholder_review_completed",+ "disciplinary_context_reviewed",+ "subgroup_bias_review_completed",+ "protected_attributes_excluded_from_scoring",+ ),+ "references": ("bias_review_ref",),+ },+ "decision_controls": {+ "booleans": (+ "no_automated_decision",+ "no_person_ranking",+ "no_decision_recommendation",+ "qualified_human_accountability",+ ),+ "references": (),+ },+ "monitoring": {+ "booleans": (+ "rater_drift_reviewed",+ "unintended_consequences_reviewed",+ "periodic_revision_scheduled",+ ),+ "references": ("review_record_ref", "revision_owner_role"),+ },+}+++def validate_process(record: Any) -> list[_common.Issue]:+ issues: list[_common.Issue] = []+ top_fields = {+ "schema_version",+ "process_id",+ "purpose",+ "unit_of_assessment",+ "data_classification",+ "high_impact_use",+ *SECTION_FIELDS,+ }+ if not _common.exact_keys(record, top_fields, "$", issues):+ return issues+ if record.get("schema_version") != _common.SCHEMA_VERSION:+ issues.append(_common.Issue("SCHEMA_VERSION_UNSUPPORTED", "$.schema_version"))+ _common.validate_identifier(record.get("process_id"), "$.process_id", issues)+ if record.get("purpose") != _common.ALLOWED_PURPOSE:+ issues.append(_common.Issue("PURPOSE_NOT_ALLOWED", "$.purpose"))+ if record.get("unit_of_assessment") != _common.ALLOWED_UNIT:+ issues.append(+ _common.Issue(+ "UNIT_OF_ASSESSMENT_NOT_ALLOWED", "$.unit_of_assessment"+ )+ )+ if record.get("data_classification") not in _common.ALLOWED_CLASSIFICATIONS:+ issues.append(+ _common.Issue(+ "DATA_CLASSIFICATION_NOT_ALLOWED", "$.data_classification"+ )+ )+ _common.validate_bool(record.get("high_impact_use"), "$.high_impact_use", issues)+ for section_name, field_groups in SECTION_FIELDS.items():+ section = record.get(section_name)+ expected = set(field_groups["booleans"]) | set(field_groups["references"])+ if not _common.exact_keys(section, expected, f"$.{section_name}", issues):+ continue+ for field in field_groups["booleans"]:+ _common.validate_bool(+ section.get(field), f"$.{section_name}.{field}", issues+ )+ for field in field_groups["references"]:+ _common.validate_reference(+ section.get(field),+ f"$.{section_name}.{field}",+ issues,+ allow_empty=True,+ )+ return issues+++def check_process(record: dict[str, Any]) -> dict[str, Any]:+ schema_issues = validate_process(record)+ if _common.error_issues(schema_issues):+ return {+ "schema_version": _common.SCHEMA_VERSION,+ "report_type": "bias_and_process_check",+ "status": "invalid",+ "process_id": record.get("process_id"),+ "issues": [issue.as_dict() for issue in schema_issues],+ }+ blockers: list[str] = []+ missing_controls: list[str] = []+ if record["high_impact_use"]:+ blockers.append("PROHIBITED_HIGH_IMPACT_USE")+ if record["purpose"] != _common.ALLOWED_PURPOSE:+ blockers.append("PROHIBITED_PURPOSE")+ if record["unit_of_assessment"] != _common.ALLOWED_UNIT:+ blockers.append("PROHIBITED_UNIT_OF_ASSESSMENT")+ for field in SECTION_FIELDS["decision_controls"]["booleans"]:+ if record["decision_controls"][field] is not True:+ blockers.append(f"DECISION_CONTROL_NOT_CONFIRMED:{field}")+ for section_name, field_groups in SECTION_FIELDS.items():+ for field in field_groups["booleans"]:+ if record[section_name][field] is not True:+ missing_controls.append(f"{section_name}.{field}")+ for field in field_groups["references"]:+ if not record[section_name][field]:+ missing_controls.append(f"{section_name}.{field}")+ status = (+ "blocked"+ if blockers+ else "incomplete"+ if missing_controls+ else "complete_for_low_stakes_process"+ )+ confirmed_count = sum(+ record[section_name][field] is True+ for section_name, groups in SECTION_FIELDS.items()+ for field in groups["booleans"]+ )+ boolean_count = sum(+ len(groups["booleans"]) for groups in SECTION_FIELDS.values()+ )+ return {+ "schema_version": _common.SCHEMA_VERSION,+ "report_type": "bias_and_process_check",+ "notice": _common.NOTICE,+ "status": status,+ "process_id": record["process_id"],+ "purpose": record["purpose"],+ "unit_of_assessment": record["unit_of_assessment"],+ "confirmed_boolean_controls": confirmed_count,+ "total_boolean_controls": boolean_count,+ "blockers": blockers,+ "missing_controls": sorted(set(missing_controls)),+ "prohibited_uses": sorted(_common.PROHIBITED_USES),+ "protected_attribute_data_processed": False,+ "decision_recommendation_provided": False,+ "issues": [],+ }+++def build_parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(+ description=(+ "Check committee, conflict, appeal, accessibility, data-protection, "+ "rubric-quality, fairness, and monitoring attestations for a "+ "low-stakes scholarly-work review process."+ )+ )+ parser.add_argument(+ "--process", required=True, type=Path, help="Local process-checklist JSON"+ )+ parser.add_argument("--output", type=Path, help="Optional local JSON report")+ parser.add_argument(+ "--force", action="store_true", help="Replace an existing output JSON file"+ )+ return parser+++def main() -> int:+ args = build_parser().parse_args()+ try:+ report = check_process(_common.read_json(args.process))+ _common.write_json(report, args.output, force=args.force)+ return 0 if report["status"] == "complete_for_low_stakes_process" else 2+ except _common.ValidationError as error:+ _common.write_json(_common.failure_report(error), None)+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/scholar-evaluation/scripts/check_traceability.py b/skills/scholar-evaluation/scripts/check_traceability.pynew file mode 100644index 00000000..3bc4c3e4--- /dev/null+++ b/skills/scholar-evaluation/scripts/check_traceability.py@@ -0,0 +1,233 @@+#!/usr/bin/env python3+"""Check criterion-to-evidence traceability without copying source content."""++from __future__ import annotations++import argparse+from pathlib import Path+from typing import Any++import _common++SOURCE_TYPES = {+ "section",+ "table",+ "figure",+ "dataset",+ "code",+ "protocol",+ "registration",+ "other_local_record",+}+ACCESS_STATUSES = {"available", "restricted_authorized", "unavailable"}+VERIFICATION_STATUSES = {"verified", "unverified"}+++def validate_manifest(+ manifest: Any, rubric: dict, evaluation: dict+) -> tuple[list[_common.Issue], dict[str, dict]]:+ issues: list[_common.Issue] = []+ evidence_by_id: dict[str, dict] = {}+ if not _common.exact_keys(+ manifest,+ {+ "schema_version",+ "evaluation_id",+ "work_id",+ "data_classification",+ "evidence",+ },+ "$",+ issues,+ ):+ return issues, evidence_by_id+ if manifest.get("schema_version") != _common.SCHEMA_VERSION:+ issues.append(_common.Issue("SCHEMA_VERSION_UNSUPPORTED", "$.schema_version"))+ if manifest.get("evaluation_id") != evaluation.get("evaluation_id"):+ issues.append(_common.Issue("EVALUATION_ID_MISMATCH", "$.evaluation_id"))+ if manifest.get("work_id") != evaluation.get("work_id"):+ issues.append(_common.Issue("WORK_ID_MISMATCH", "$.work_id"))+ if manifest.get("data_classification") != evaluation.get("data_classification"):+ issues.append(+ _common.Issue("DATA_CLASSIFICATION_MISMATCH", "$.data_classification")+ )+ if manifest.get("data_classification") not in _common.ALLOWED_CLASSIFICATIONS:+ issues.append(+ _common.Issue(+ "DATA_CLASSIFICATION_NOT_ALLOWED", "$.data_classification"+ )+ )+ criterion_ids = {criterion["criterion_id"] for criterion in rubric["criteria"]}+ evidence = manifest.get("evidence")+ if not isinstance(evidence, list) or len(evidence) > 5_000:+ issues.append(_common.Issue("EVIDENCE_LIST_INVALID", "$.evidence"))+ return issues, evidence_by_id+ for index, item in enumerate(evidence):+ path = f"$.evidence[{index}]"+ if not _common.exact_keys(+ item,+ {+ "evidence_id",+ "criterion_ids",+ "source_type",+ "locator_ref",+ "claim_ref",+ "access_status",+ "verification_status",+ },+ path,+ issues,+ ):+ continue+ evidence_id = item.get("evidence_id")+ _common.validate_identifier(+ evidence_id, f"{path}.evidence_id", issues, "EVIDENCE_ID_INVALID"+ )+ if isinstance(evidence_id, str):+ if evidence_id in evidence_by_id:+ issues.append(+ _common.Issue("EVIDENCE_ID_DUPLICATE", f"{path}.evidence_id")+ )+ evidence_by_id[evidence_id] = item+ linked = item.get("criterion_ids")+ if not isinstance(linked, list) or not 1 <= len(linked) <= 50:+ issues.append(_common.Issue("CRITERION_IDS_INVALID", f"{path}.criterion_ids"))+ else:+ linked_text = [+ criterion_id+ for criterion_id in linked+ if isinstance(criterion_id, str)+ ]+ if len(linked_text) != len(set(linked_text)):+ issues.append(+ _common.Issue(+ "CRITERION_ID_DUPLICATE", f"{path}.criterion_ids"+ )+ )+ for criterion_index, criterion_id in enumerate(linked):+ _common.validate_identifier(+ criterion_id,+ f"{path}.criterion_ids[{criterion_index}]",+ issues,+ )+ if isinstance(criterion_id, str) and criterion_id not in criterion_ids:+ issues.append(+ _common.Issue(+ "CRITERION_UNKNOWN",+ f"{path}.criterion_ids[{criterion_index}]",+ )+ )+ if item.get("source_type") not in SOURCE_TYPES:+ issues.append(_common.Issue("SOURCE_TYPE_INVALID", f"{path}.source_type"))+ _common.validate_reference(item.get("locator_ref"), f"{path}.locator_ref", issues)+ _common.validate_reference(item.get("claim_ref"), f"{path}.claim_ref", issues)+ if item.get("access_status") not in ACCESS_STATUSES:+ issues.append(_common.Issue("ACCESS_STATUS_INVALID", f"{path}.access_status"))+ if item.get("access_status") == "unavailable":+ issues.append(_common.Issue("EVIDENCE_UNAVAILABLE", f"{path}.access_status"))+ if item.get("verification_status") not in VERIFICATION_STATUSES:+ issues.append(+ _common.Issue(+ "VERIFICATION_STATUS_INVALID", f"{path}.verification_status"+ )+ )+ elif item.get("verification_status") != "verified":+ issues.append(+ _common.Issue("EVIDENCE_UNVERIFIED", f"{path}.verification_status")+ )+ return issues, evidence_by_id+++def check_traceability(rubric: dict, evaluation: dict, manifest: dict) -> dict:+ rubric_issues = _common.validate_rubric(rubric)+ _common.require_valid(rubric_issues)+ evaluation_issues = _common.validate_evaluation(evaluation, rubric)+ _common.require_valid(evaluation_issues)+ issues, evidence_by_id = validate_manifest(manifest, rubric, evaluation)+ used_ids: set[str] = set()+ for index, rating in enumerate(evaluation["ratings"]):+ if rating["status"] != "rated":+ continue+ criterion_id = rating["criterion_id"]+ for evidence_index, evidence_id in enumerate(rating["evidence_ids"]):+ used_ids.add(evidence_id)+ path = f"$.ratings[{index}].evidence_ids[{evidence_index}]"+ evidence = evidence_by_id.get(evidence_id)+ if evidence is None:+ issues.append(_common.Issue("EVIDENCE_REFERENCE_UNRESOLVED", path))+ elif criterion_id not in evidence.get("criterion_ids", []):+ issues.append(_common.Issue("EVIDENCE_CRITERION_MISMATCH", path))+ for evidence_id in sorted(set(evidence_by_id) - used_ids):+ issues.append(+ _common.Issue(+ "EVIDENCE_UNUSED",+ f"$.evidence.{evidence_id}",+ "warning",+ )+ )+ errors = _common.error_issues(issues)+ rated_count = sum(+ rating["status"] == "rated" for rating in evaluation["ratings"]+ )+ resolved_count = sum(+ 1+ for rating in evaluation["ratings"]+ if rating["status"] == "rated"+ and rating["evidence_ids"]+ and all(evidence_id in evidence_by_id for evidence_id in rating["evidence_ids"])+ )+ return {+ "schema_version": _common.SCHEMA_VERSION,+ "report_type": "evidence_traceability_check",+ "notice": _common.NOTICE,+ "status": "fail" if errors else "pass",+ "evaluation_id": evaluation["evaluation_id"],+ "work_id": evaluation["work_id"],+ "rated_criteria": rated_count,+ "rated_criteria_with_resolved_evidence": resolved_count,+ "evidence_records": len(evidence_by_id),+ "error_count": len(errors),+ "warning_count": len(issues) - len(errors),+ "issues": [issue.as_dict() for issue in issues],+ "source_content_copied_to_output": False,+ }+++def build_parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(+ description=(+ "Verify local evidence identifiers and criterion mappings. "+ "The report contains references and counts, never evidence excerpts."+ )+ )+ parser.add_argument("--rubric", required=True, type=Path, help="Local rubric JSON")+ parser.add_argument(+ "--evaluation", required=True, type=Path, help="Local evaluation JSON"+ )+ parser.add_argument(+ "--evidence", required=True, type=Path, help="Local evidence-manifest JSON"+ )+ parser.add_argument("--output", type=Path, help="Optional local JSON report")+ parser.add_argument(+ "--force", action="store_true", help="Replace an existing output JSON file"+ )+ return parser+++def main() -> int:+ args = build_parser().parse_args()+ try:+ report = check_traceability(+ _common.read_json(args.rubric),+ _common.read_json(args.evaluation),+ _common.read_json(args.evidence),+ )+ _common.write_json(report, args.output, force=args.force)+ return 0 if report["status"] == "pass" else 2+ except _common.ValidationError as error:+ _common.write_json(_common.failure_report(error), None)+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/scholar-evaluation/scripts/generate_report_scaffold.py b/skills/scholar-evaluation/scripts/generate_report_scaffold.pynew file mode 100644index 00000000..4f5db9f1--- /dev/null+++ b/skills/scholar-evaluation/scripts/generate_report_scaffold.py@@ -0,0 +1,231 @@+#!/usr/bin/env python3+"""Generate a minimized local JSON scaffold for qualified human review."""++from __future__ import annotations++import argparse+from pathlib import Path+from typing import Any++import _common+++def _load_companion(+ report: dict[str, Any] | None,+ *,+ report_type: str,+ rubric_id: str | None = None,+ evaluation_id: str | None = None,+ work_id: str | None = None,+) -> dict[str, Any] | None:+ if report is None:+ return None+ if not isinstance(report, dict) or report.get("schema_version") != _common.SCHEMA_VERSION:+ raise _common.ValidationError("COMPANION_REPORT_INVALID")+ if report.get("report_type") != report_type:+ raise _common.ValidationError("COMPANION_REPORT_TYPE_MISMATCH")+ if rubric_id is not None and report.get("rubric_id") != rubric_id:+ raise _common.ValidationError("COMPANION_RUBRIC_ID_MISMATCH")+ if evaluation_id is not None and report.get("evaluation_id") != evaluation_id:+ raise _common.ValidationError("COMPANION_EVALUATION_ID_MISMATCH")+ if work_id is not None and report.get("work_id") != work_id:+ raise _common.ValidationError("COMPANION_WORK_ID_MISMATCH")+ return report+++def generate_scaffold(+ rubric: dict[str, Any],+ evaluation: dict[str, Any],+ *,+ traceability: dict[str, Any] | None = None,+ agreement: dict[str, Any] | None = None,+ sensitivity: dict[str, Any] | None = None,+ process: dict[str, Any] | None = None,+) -> dict[str, Any]:+ rubric_issues = _common.validate_rubric(rubric)+ _common.require_valid(rubric_issues)+ evaluation_issues = _common.validate_evaluation(evaluation, rubric)+ _common.require_valid(evaluation_issues)+ score_report = _common.score_evaluation(rubric, evaluation)+ traceability = _load_companion(+ traceability,+ report_type="evidence_traceability_check",+ evaluation_id=evaluation["evaluation_id"],+ work_id=evaluation["work_id"],+ )+ agreement = _load_companion(+ agreement,+ report_type="inter_rater_agreement_summary",+ rubric_id=rubric["rubric_id"],+ )+ sensitivity = _load_companion(+ sensitivity,+ report_type="weight_sensitivity_and_rank_instability",+ rubric_id=rubric["rubric_id"],+ )+ process = _load_companion(process, report_type="bias_and_process_check")+ if traceability and (+ traceability.get("status") not in {"pass", "fail"}+ or not isinstance(traceability.get("error_count"), int)+ ):+ raise _common.ValidationError("COMPANION_REPORT_INVALID")+ agreement_overall = agreement.get("overall") if agreement else None+ if agreement and (+ not isinstance(agreement_overall, dict)+ or not isinstance(agreement_overall.get("pair_observations"), int)+ ):+ raise _common.ValidationError("COMPANION_REPORT_INVALID")+ if sensitivity and not isinstance(+ sensitivity.get("rank_instability_detected"), bool+ ):+ raise _common.ValidationError("COMPANION_REPORT_INVALID")+ if process and process.get("status") not in {+ "invalid",+ "blocked",+ "incomplete",+ "complete_for_low_stakes_process",+ }:+ raise _common.ValidationError("COMPANION_REPORT_INVALID")+ criterion_scaffold = []+ for result in score_report["criteria"]:+ criterion_scaffold.append(+ {+ "criterion_id": result["criterion_id"],+ "status": result["status"],+ "score": result["score"],+ "uncertainty": result["uncertainty"],+ "evidence_finding_refs": [],+ "strength_refs": [],+ "limitation_refs": [],+ "improvement_option_refs": [],+ "qualified_reviewer_comment_ref": "",+ }+ )+ return {+ "schema_version": _common.SCHEMA_VERSION,+ "report_type": "developmental_scholarly_work_report_scaffold",+ "notice": _common.NOTICE,+ "evaluation_id": evaluation["evaluation_id"],+ "work_id": evaluation["work_id"],+ "rubric_id": rubric["rubric_id"],+ "purpose": _common.ALLOWED_PURPOSE,+ "unit_of_assessment": _common.ALLOWED_UNIT,+ "construct": {+ "rubric_record_ref": rubric["rubric_id"],+ "content_validity_status": rubric["provenance"][+ "content_validity_status"+ ],+ "rubric_source_count": len(rubric["provenance"]["source_ids"]),+ },+ "descriptive_score_summary": score_report["aggregates"],+ "criterion_scaffold": criterion_scaffold,+ "quality_assurance": {+ "traceability_status": (+ traceability.get("status") if traceability else "not_provided"+ ),+ "traceability_error_count": (+ traceability.get("error_count") if traceability else None+ ),+ "agreement_pair_observations": (+ agreement_overall.get("pair_observations") if agreement_overall else None+ ),+ "agreement_status": (+ "provided" if agreement else "not_provided"+ ),+ "inter_rater_reliability_status": rubric["rater_protocol"][+ "inter_rater_reliability_status"+ ],+ "weight_sensitivity_status": (+ "provided" if sensitivity else "not_provided"+ ),+ "rank_instability_detected": (+ sensitivity.get("rank_instability_detected")+ if sensitivity+ else None+ ),+ "process_check_status": (+ process.get("status") if process else "not_provided"+ ),+ },+ "human_review": {+ "committee_finding_refs": [],+ "conflict_and_recusal_record_ref": "",+ "disciplinary_context_ref": "",+ "accessibility_accommodation_record_ref": "",+ "subgroup_bias_review_ref": rubric["governance"][+ "subgroup_review_ref"+ ],+ "appeal_process_ref": rubric["governance"]["appeal_process_ref"],+ "final_human_review_record_ref": "",+ },+ "required_limitations": [+ "ScholarEval is an experimental literature-grounded research-idea framework, not validated psychometrics.",+ "This rubric requires separate validity, reliability, fairness, and intended-use evidence.",+ "Missing and not-applicable ratings limit comparability.",+ "Criterion uncertainty intervals are bounded judgment ranges, not confidence intervals.",+ "Journal, citation, prestige, institution, venue, and attention indicators do not establish quality.",+ ],+ "private_source_content_included": False,+ "person_ranking_provided": False,+ "decision_recommendation_provided": False,+ }+++def build_parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(+ description=(+ "Generate a local JSON report scaffold containing bounded scores, "+ "quality-control summaries, and empty reference slots for qualified "+ "human findings. No source-document text is copied."+ )+ )+ parser.add_argument("--rubric", required=True, type=Path, help="Local rubric JSON")+ parser.add_argument(+ "--evaluation", required=True, type=Path, help="Local evaluation JSON"+ )+ parser.add_argument(+ "--traceability", type=Path, help="Optional traceability report JSON"+ )+ parser.add_argument(+ "--agreement", type=Path, help="Optional agreement report JSON"+ )+ parser.add_argument(+ "--sensitivity", type=Path, help="Optional sensitivity report JSON"+ )+ parser.add_argument(+ "--process", type=Path, help="Optional process-check report JSON"+ )+ parser.add_argument("--output", type=Path, help="Optional local JSON report")+ parser.add_argument(+ "--force", action="store_true", help="Replace an existing output JSON file"+ )+ return parser+++def main() -> int:+ args = build_parser().parse_args()+ try:+ optional_paths = {+ "traceability": args.traceability,+ "agreement": args.agreement,+ "sensitivity": args.sensitivity,+ "process": args.process,+ }+ companions = {+ name: _common.read_json(path) if path else None+ for name, path in optional_paths.items()+ }+ report = generate_scaffold(+ _common.read_json(args.rubric),+ _common.read_json(args.evaluation),+ **companions,+ )+ _common.write_json(report, args.output, force=args.force)+ return 0+ except _common.ValidationError as error:+ _common.write_json(_common.failure_report(error), None)+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/scholar-evaluation/scripts/generate_schematic.py b/skills/scholar-evaluation/scripts/generate_schematic.pydeleted file mode 100644index 43331870..00000000--- a/skills/scholar-evaluation/scripts/generate_schematic.py+++ /dev/null@@ -1,139 +0,0 @@-#!/usr/bin/env python3-"""-Scientific schematic generation using Nano Banana 2.--Generate any scientific diagram by describing it in natural language.-Nano Banana 2 handles everything automatically with smart iterative refinement.--Smart iteration: Only regenerates if quality is below threshold for your document type.-Quality review: Uses Gemini 3.6 Flash for professional scientific evaluation.--Usage:- # Generate for journal paper (highest quality threshold)- python generate_schematic.py "CONSORT flowchart" -o flowchart.png --doc-type journal-- # Generate for presentation (lower threshold, faster)- python generate_schematic.py "Transformer architecture" -o transformer.png --doc-type presentation-- # Generate for poster- python generate_schematic.py "MAPK signaling pathway" -o pathway.png --doc-type poster-"""--import argparse-import os-import subprocess-import sys-from pathlib import Path---def main():- """Command-line interface."""- parser = argparse.ArgumentParser(- description="Generate scientific schematics using AI with smart iterative refinement",- formatter_class=argparse.RawDescriptionHelpFormatter,- epilog="""-How it works:- Simply describe your diagram in natural language- Nano Banana 2 generates it automatically with:- - Smart iteration (only regenerates if quality is below threshold)- - Quality review by Gemini 3.6 Flash- - Document-type aware quality thresholds- - Publication-ready output--Document Types (quality thresholds):- journal 8.5/10 - Nature, Science, peer-reviewed journals- conference 8.0/10 - Conference papers- thesis 8.0/10 - Dissertations, theses- grant 8.0/10 - Grant proposals- preprint 7.5/10 - arXiv, bioRxiv, etc.- report 7.5/10 - Technical reports- poster 7.0/10 - Academic posters- presentation 6.5/10 - Slides, talks- default 7.5/10 - General purpose--Examples:- # Generate for journal paper (strict quality)- python generate_schematic.py "CONSORT participant flow" -o flowchart.png --doc-type journal-- # Generate for poster (moderate quality)- python generate_schematic.py "Transformer architecture" -o arch.png --doc-type poster-- # Generate for slides (faster, lower threshold)- python generate_schematic.py "System diagram" -o system.png --doc-type presentation-- # Custom max iterations- python generate_schematic.py "Complex pathway" -o pathway.png --iterations 2-- # Verbose output- python generate_schematic.py "Circuit diagram" -o circuit.png -v--Environment Variables:- OPENROUTER_API_KEY Required for AI generation- """- )-- parser.add_argument("prompt",- help="Description of the diagram to generate")- parser.add_argument("-o", "--output", required=True,- help="Output file path")- parser.add_argument("--doc-type", default="default",- choices=["journal", "conference", "poster", "presentation",- "report", "grant", "thesis", "preprint", "default"],- help="Document type for quality threshold (default: default)")- parser.add_argument("--iterations", type=int, default=2,- help="Maximum refinement iterations (default: 2, max: 2)")- parser.add_argument("--api-key",- help="OpenRouter API key (or use OPENROUTER_API_KEY env var)")- parser.add_argument("-v", "--verbose", action="store_true",- help="Verbose output")-- args = parser.parse_args()-- # Check for API key- api_key = args.api_key or os.getenv("OPENROUTER_API_KEY")- if not api_key:- print("Error: OPENROUTER_API_KEY environment variable not set")- print("\nFor AI generation, you need an OpenRouter API key.")- print("Get one at: https://openrouter.ai/keys")- print("\nSet it with:")- print(" export OPENROUTER_API_KEY='your_api_key'")- print("\nOr use --api-key flag")- sys.exit(1)-- # Find AI generation script- script_dir = Path(__file__).parent- ai_script = script_dir / "generate_schematic_ai.py"-- if not ai_script.exists():- print(f"Error: AI generation script not found: {ai_script}")- sys.exit(1)-- # Build command- cmd = [sys.executable, str(ai_script), args.prompt, "-o", args.output]-- if args.doc_type != "default":- cmd.extend(["--doc-type", args.doc_type])-- # Enforce max 2 iterations- iterations = min(args.iterations, 2)- if iterations != 2:- cmd.extend(["--iterations", str(iterations)])-- if args.verbose:- cmd.append("-v")-- # Execute — pass API key via environment to avoid exposure in process listings- try:- env = os.environ.copy()- if api_key:- env["OPENROUTER_API_KEY"] = api_key- result = subprocess.run(cmd, check=False, env=env)- sys.exit(result.returncode)- except Exception as e:- print(f"Error executing AI generation: {e}")- sys.exit(1)---if __name__ == "__main__":- main()-diff --git a/skills/scholar-evaluation/scripts/generate_schematic_ai.py b/skills/scholar-evaluation/scripts/generate_schematic_ai.pydeleted file mode 100644index 651b6c76..00000000--- a/skills/scholar-evaluation/scripts/generate_schematic_ai.py+++ /dev/null@@ -1,817 +0,0 @@-#!/usr/bin/env python3-"""-AI-powered scientific schematic generation using Nano Banana 2.--This script uses a smart iterative refinement approach:-1. Generate initial image with Nano Banana 2-2. AI quality review using Gemini 3.6 Flash for scientific critique-3. Only regenerate if quality is below threshold for document type-4. Repeat until quality meets standards (max iterations)--Requirements:- - OPENROUTER_API_KEY environment variable- - requests library--Usage:- python generate_schematic_ai.py "Create a flowchart showing CONSORT participant flow" -o flowchart.png- python generate_schematic_ai.py "Neural network architecture diagram" -o architecture.png --iterations 2- python generate_schematic_ai.py "Simple block diagram" -o diagram.png --doc-type poster-"""--import argparse-import base64-import json-import os-import sys-import time-from pathlib import Path-from typing import Optional, Dict, Any, List, Tuple--try:- import requests-except ImportError:- print("Error: requests library not found. Install with: pip install requests")- sys.exit(1)--# Try to load .env file from multiple potential locations-def _load_env_file():- """Load .env file from current directory or script directory only."""- try:- from dotenv import load_dotenv- except ImportError:- return False-- for candidate in [Path.cwd() / ".env", Path(__file__).resolve().parent / ".env"]:- if candidate.exists():- load_dotenv(dotenv_path=candidate, override=False)- return True-- return False---class ScientificSchematicGenerator:- """Generate scientific schematics using AI with smart iterative refinement.-- Uses Gemini 3.6 Flash for quality review to determine if regeneration is needed.- Multiple passes only occur if the generated schematic doesn't meet the- quality threshold for the target document type.- """-- # Quality thresholds by document type (score out of 10)- # Higher thresholds for more formal publications- QUALITY_THRESHOLDS = {- "journal": 8.5, # Nature, Science, etc. - highest standards- "conference": 8.0, # Conference papers - high standards- "poster": 7.0, # Academic posters - good quality- "presentation": 6.5, # Slides/talks - clear but less formal- "report": 7.5, # Technical reports - professional- "grant": 8.0, # Grant proposals - must be compelling- "thesis": 8.0, # Dissertations - formal academic- "preprint": 7.5, # arXiv, etc. - good quality- "default": 7.5, # Default threshold- }-- # Scientific diagram best practices prompt template- SCIENTIFIC_DIAGRAM_GUIDELINES = """-Create a high-quality scientific diagram with these requirements:--VISUAL QUALITY:-- Clean white or light background (no textures or gradients)-- High contrast for readability and printing-- Professional, publication-ready appearance-- Sharp, clear lines and text-- Adequate spacing between elements to prevent crowding--TYPOGRAPHY:-- Clear, readable sans-serif fonts (Arial, Helvetica style)-- Minimum 10pt font size for all labels-- Consistent font sizes throughout-- All text horizontal or clearly readable-- No overlapping text--SCIENTIFIC STANDARDS:-- Accurate representation of concepts-- Clear labels for all components-- Include scale bars, legends, or axes where appropriate-- Use standard scientific notation and symbols-- Include units where applicable--ACCESSIBILITY:-- Colorblind-friendly color palette (use Okabe-Ito colors if using color)-- High contrast between elements-- Redundant encoding (shapes + colors, not just colors)-- Works well in grayscale--LAYOUT:-- Logical flow (left-to-right or top-to-bottom)-- Clear visual hierarchy-- Balanced composition-- Appropriate use of whitespace-- No clutter or unnecessary decorative elements--IMPORTANT - NO FIGURE NUMBERS:-- Do NOT include "Figure 1:", "Fig. 1", or any figure numbering in the image-- Do NOT add captions or titles like "Figure: ..." at the top or bottom-- Figure numbers and captions are added separately in the document/LaTeX-- The diagram should contain only the visual content itself-"""-- def __init__(self, api_key: Optional[str] = None, verbose: bool = False):- """- Initialize the generator.-- Args:- api_key: OpenRouter API key (or use OPENROUTER_API_KEY env var)- verbose: Print detailed progress information- """- # Priority: 1) explicit api_key param, 2) environment variable, 3) .env file- self.api_key = api_key or os.getenv("OPENROUTER_API_KEY")-- # If not found in environment, try loading from .env file- if not self.api_key:- _load_env_file()- self.api_key = os.getenv("OPENROUTER_API_KEY")-- if not self.api_key:- raise ValueError(- "OPENROUTER_API_KEY not found. Please either:\n"- " 1. Set the OPENROUTER_API_KEY environment variable\n"- " 2. Add OPENROUTER_API_KEY to your .env file\n"- " 3. Pass api_key parameter to the constructor\n"- "Get your API key from: https://openrouter.ai/keys"- )-- self.verbose = verbose- self._last_error = None # Track last error for better reporting- self.base_url = "https://openrouter.ai/api/v1"- # Nano Banana 2 - Google's advanced image generation model- # https://openrouter.ai/google/gemini-3.6-flash- self.image_model = "google/gemini-3.1-flash-image-preview"- # Gemini 3.6 Flash for quality review - excellent vision and reasoning- self.review_model = "google/gemini-3.6-flash"-- def _log(self, message: str):- """Log message if verbose mode is enabled."""- if self.verbose:- print(f"[{time.strftime('%H:%M:%S')}] {message}")-- def _make_request(self, model: str, messages: List[Dict[str, Any]],- modalities: Optional[List[str]] = None) -> Dict[str, Any]:- """- Make a request to OpenRouter API.-- Args:- model: Model identifier- messages: List of message dictionaries- modalities: Optional list of modalities (e.g., ["image", "text"])-- Returns:- API response as dictionary- """- headers = {- "Authorization": f"Bearer {self.api_key}",- "Content-Type": "application/json",- "HTTP-Referer": "https://github.com/scientific-writer",- "X-Title": "Scientific Schematic Generator"- }-- payload = {- "model": model,- "messages": messages- }-- if modalities:- payload["modalities"] = modalities-- self._log(f"Making request to {model}...")-- try:- response = requests.post(- f"{self.base_url}/chat/completions",- headers=headers,- json=payload,- timeout=120- )-- # Try to get response body even on error- try:- response_json = response.json()- except json.JSONDecodeError:- response_json = {"raw_text": response.text[:500]}-- # Check for HTTP errors but include response body in error message- if response.status_code != 200:- error_detail = response_json.get("error", response_json)- self._log(f"HTTP {response.status_code}: {error_detail}")- raise RuntimeError(f"API request failed (HTTP {response.status_code}): {error_detail}")-- return response_json- except requests.exceptions.Timeout:- raise RuntimeError("API request timed out after 120 seconds")- except requests.exceptions.RequestException as e:- raise RuntimeError(f"API request failed: {str(e)}")-- def _extract_image_from_response(self, response: Dict[str, Any]) -> Optional[bytes]:- """- Extract base64-encoded image from API response.-- For Nano Banana 2, images are returned in the 'images' field of the message,- not in the 'content' field.-- Args:- response: API response dictionary-- Returns:- Image bytes or None if not found- """- try:- choices = response.get("choices", [])- if not choices:- self._log("No choices in response")- return None-- message = choices[0].get("message", {})-- # IMPORTANT: Nano Banana 2 returns images in the 'images' field- images = message.get("images", [])- if images and len(images) > 0:- self._log(f"Found {len(images)} image(s) in 'images' field")-- # Get first image- first_image = images[0]- if isinstance(first_image, dict):- # Extract image_url- if first_image.get("type") == "image_url":- url = first_image.get("image_url", {})- if isinstance(url, dict):- url = url.get("url", "")-- if url and url.startswith("data:image"):- # Extract base64 data after comma- if "," in url:- base64_str = url.split(",", 1)[1]- # Clean whitespace- base64_str = base64_str.replace('\n', '').replace('\r', '').replace(' ', '')- self._log(f"Extracted base64 data (length: {len(base64_str)})")- return base64.b64decode(base64_str)-- # Fallback: check content field (for other models or future changes)- content = message.get("content", "")-- if self.verbose:- self._log(f"Content type: {type(content)}, length: {len(str(content))}")-- # Handle string content- if isinstance(content, str) and "data:image" in content:- import re- match = re.search(r'data:image/[^;]+;base64,([A-Za-z0-9+/=\n\r]+)', content, re.DOTALL)- if match:- base64_str = match.group(1).replace('\n', '').replace('\r', '').replace(' ', '')- self._log(f"Found image in content field (length: {len(base64_str)})")- return base64.b64decode(base64_str)-- # Handle list content- if isinstance(content, list):- for i, block in enumerate(content):- if isinstance(block, dict) and block.get("type") == "image_url":- url = block.get("image_url", {})- if isinstance(url, dict):- url = url.get("url", "")- if url and url.startswith("data:image") and "," in url:- base64_str = url.split(",", 1)[1].replace('\n', '').replace('\r', '').replace(' ', '')- self._log(f"Found image in content block {i}")- return base64.b64decode(base64_str)-- self._log("No image data found in response")- return None-- except Exception as e:- self._log(f"Error extracting image: {str(e)}")- import traceback- if self.verbose:- traceback.print_exc()- return None-- def _image_to_base64(self, image_path: str) -> str:- """- Convert image file to base64 data URL.-- Args:- image_path: Path to image file-- Returns:- Base64 data URL string- """- with open(image_path, "rb") as f:- image_data = f.read()-- # Determine image type from extension- ext = Path(image_path).suffix.lower()- mime_type = {- ".png": "image/png",- ".jpg": "image/jpeg",- ".jpeg": "image/jpeg",- ".gif": "image/gif",- ".webp": "image/webp"- }.get(ext, "image/png")-- base64_data = base64.b64encode(image_data).decode("utf-8")- return f"data:{mime_type};base64,{base64_data}"-- def generate_image(self, prompt: str) -> Optional[bytes]:- """- Generate an image using Nano Banana 2.-- Args:- prompt: Description of the diagram to generate-- Returns:- Image bytes or None if generation failed- """- self._last_error = None # Reset error-- messages = [- {- "role": "user",- "content": prompt- }- ]-- try:- response = self._make_request(- model=self.image_model,- messages=messages,- modalities=["image", "text"]- )-- # Debug: print response structure if verbose- if self.verbose:- self._log(f"Response keys: {response.keys()}")- if "error" in response:- self._log(f"API Error: {response['error']}")- if "choices" in response and response["choices"]:- msg = response["choices"][0].get("message", {})- self._log(f"Message keys: {msg.keys()}")- # Show content preview without printing huge base64 data- content = msg.get("content", "")- if isinstance(content, str):- preview = content[:200] + "..." if len(content) > 200 else content- self._log(f"Content preview: {preview}")- elif isinstance(content, list):- self._log(f"Content is list with {len(content)} items")- for i, item in enumerate(content[:3]):- if isinstance(item, dict):- self._log(f" Item {i}: type={item.get('type')}")-- # Check for API errors in response- if "error" in response:- error_msg = response["error"]- if isinstance(error_msg, dict):- error_msg = error_msg.get("message", str(error_msg))- self._last_error = f"API Error: {error_msg}"- print(f"✗ {self._last_error}")- return None-- image_data = self._extract_image_from_response(response)- if image_data:- self._log(f"✓ Generated image ({len(image_data)} bytes)")- else:- self._last_error = "No image data in API response - model may not support image generation"- self._log(f"✗ {self._last_error}")- # Additional debug info when image extraction fails- if self.verbose and "choices" in response:- msg = response["choices"][0].get("message", {})- self._log(f"Full message structure: {json.dumps({k: type(v).__name__ for k, v in msg.items()})}")-- return image_data- except RuntimeError as e:- self._last_error = str(e)- self._log(f"✗ Generation failed: {self._last_error}")- return None- except Exception as e:- self._last_error = f"Unexpected error: {str(e)}"- self._log(f"✗ Generation failed: {self._last_error}")- import traceback- if self.verbose:- traceback.print_exc()- return None-- def review_image(self, image_path: str, original_prompt: str,- iteration: int, doc_type: str = "default",- max_iterations: int = 2) -> Tuple[str, float, bool]:- """- Review generated image using Gemini 3.6 Flash for quality analysis.-- Uses Gemini 3.6 Flash's superior vision and reasoning capabilities to- evaluate the schematic quality and determine if regeneration is needed.-- Args:- image_path: Path to the generated image- original_prompt: Original user prompt- iteration: Current iteration number- doc_type: Document type (journal, poster, presentation, etc.)- max_iterations: Maximum iterations allowed-- Returns:- Tuple of (critique text, quality score 0-10, needs_improvement bool)- """- # Use Gemini 3.6 Flash for review - excellent vision and analysis- image_data_url = self._image_to_base64(image_path)-- # Get quality threshold for this document type- threshold = self.QUALITY_THRESHOLDS.get(doc_type.lower(),- self.QUALITY_THRESHOLDS["default"])-- review_prompt = f"""You are an expert reviewer evaluating a scientific diagram for publication quality.--ORIGINAL REQUEST: {original_prompt}--DOCUMENT TYPE: {doc_type} (quality threshold: {threshold}/10)-ITERATION: {iteration}/{max_iterations}--Carefully evaluate this diagram on these criteria:--1. **Scientific Accuracy** (0-2 points)- - Correct representation of concepts- - Proper notation and symbols- - Accurate relationships shown--2. **Clarity and Readability** (0-2 points)- - Easy to understand at a glance- - Clear visual hierarchy- - No ambiguous elements--3. **Label Quality** (0-2 points)- - All important elements labeled- - Labels are readable (appropriate font size)- - Consistent labeling style--4. **Layout and Composition** (0-2 points)- - Logical flow (top-to-bottom or left-to-right)- - Balanced use of space- - No overlapping elements--5. **Professional Appearance** (0-2 points)- - Publication-ready quality- - Clean, crisp lines and shapes- - Appropriate colors/contrast--RESPOND IN THIS EXACT FORMAT:-SCORE: [total score 0-10]--STRENGTHS:-- [strength 1]-- [strength 2]--ISSUES:-- [issue 1 if any]-- [issue 2 if any]--VERDICT: [ACCEPTABLE or NEEDS_IMPROVEMENT]--If score >= {threshold}, the diagram is ACCEPTABLE for {doc_type} publication.-If score < {threshold}, mark as NEEDS_IMPROVEMENT with specific suggestions."""-- messages = [- {- "role": "user",- "content": [- {- "type": "text",- "text": review_prompt- },- {- "type": "image_url",- "image_url": {- "url": image_data_url- }- }- ]- }- ]-- try:- # Use Gemini 3.6 Flash for high-quality review- response = self._make_request(- model=self.review_model,- messages=messages- )-- # Extract text response- choices = response.get("choices", [])- if not choices:- return "Image generated successfully", 8.0-- message = choices[0].get("message", {})- content = message.get("content", "")-- # Check reasoning field (Nano Banana 2 puts analysis here)- reasoning = message.get("reasoning", "")- if reasoning and not content:- content = reasoning-- if isinstance(content, list):- # Extract text from content blocks- text_parts = []- for block in content:- if isinstance(block, dict) and block.get("type") == "text":- text_parts.append(block.get("text", ""))- content = "\n".join(text_parts)-- # Try to extract score- score = 7.5 # Default score if extraction fails- import re-- # Look for SCORE: X or SCORE: X/10 format- score_match = re.search(r'SCORE:\s*(\d+(?:\.\d+)?)', content, re.IGNORECASE)- if score_match:- score = float(score_match.group(1))- else:- # Fallback: look for any score pattern- score_match = re.search(r'(?:score|rating|quality)[:\s]+(\d+(?:\.\d+)?)\s*(?:/\s*10)?', content, re.IGNORECASE)- if score_match:- score = float(score_match.group(1))-- # Determine if improvement is needed based on verdict or score- needs_improvement = False- if "NEEDS_IMPROVEMENT" in content.upper():- needs_improvement = True- elif score < threshold:- needs_improvement = True-- self._log(f"✓ Review complete (Score: {score}/10, Threshold: {threshold}/10)")- self._log(f" Verdict: {'Needs improvement' if needs_improvement else 'Acceptable'}")-- return (content if content else "Image generated successfully",- score,- needs_improvement)- except Exception as e:- self._log(f"Review skipped: {str(e)}")- # Don't fail the whole process if review fails - assume acceptable- return "Image generated successfully (review skipped)", 7.5, False-- def improve_prompt(self, original_prompt: str, critique: str,- iteration: int) -> str:- """- Improve the generation prompt based on critique.-- Args:- original_prompt: Original user prompt- critique: Review critique from previous iteration- iteration: Current iteration number-- Returns:- Improved prompt for next generation- """- improved_prompt = f"""{self.SCIENTIFIC_DIAGRAM_GUIDELINES}--USER REQUEST: {original_prompt}--ITERATION {iteration}: Based on previous feedback, address these specific improvements:-{critique}--Generate an improved version that addresses all the critique points while maintaining scientific accuracy and professional quality."""-- return improved_prompt-- def generate_iterative(self, user_prompt: str, output_path: str,- iterations: int = 2,- doc_type: str = "default") -> Dict[str, Any]:- """- Generate scientific schematic with smart iterative refinement.-- Only regenerates if the quality score is below the threshold for the- specified document type. This saves API calls and time when the first- generation is already good enough.-- Args:- user_prompt: User's description of desired diagram- output_path: Path to save final image- iterations: Maximum refinement iterations (default: 2, max: 2)- doc_type: Document type for quality threshold (journal, poster, etc.)-- Returns:- Dictionary with generation results and metadata- """- output_path = Path(output_path)- output_dir = output_path.parent- output_dir.mkdir(parents=True, exist_ok=True)-- base_name = output_path.stem- extension = output_path.suffix or ".png"-- # Get quality threshold for this document type- threshold = self.QUALITY_THRESHOLDS.get(doc_type.lower(),- self.QUALITY_THRESHOLDS["default"])-- results = {- "user_prompt": user_prompt,- "doc_type": doc_type,- "quality_threshold": threshold,- "iterations": [],- "final_image": None,- "final_score": 0.0,- "success": False,- "early_stop": False,- "early_stop_reason": None- }-- current_prompt = f"""{self.SCIENTIFIC_DIAGRAM_GUIDELINES}--USER REQUEST: {user_prompt}--Generate a publication-quality scientific diagram that meets all the guidelines above."""-- print(f"\n{'='*60}")- print(f"Generating Scientific Schematic")- print(f"{'='*60}")- print(f"Description: {user_prompt}")- print(f"Document Type: {doc_type}")- print(f"Quality Threshold: {threshold}/10")- print(f"Max Iterations: {iterations}")- print(f"Output: {output_path}")- print(f"{'='*60}\n")-- for i in range(1, iterations + 1):- print(f"\n[Iteration {i}/{iterations}]")- print("-" * 40)-- # Generate image- print(f"Generating image...")- image_data = self.generate_image(current_prompt)-- if not image_data:- error_msg = getattr(self, '_last_error', 'Image generation failed - no image data returned')- print(f"✗ Generation failed: {error_msg}")- results["iterations"].append({- "iteration": i,- "success": False,- "error": error_msg- })- continue-- # Save iteration image- iter_path = output_dir / f"{base_name}_v{i}{extension}"- with open(iter_path, "wb") as f:- f.write(image_data)- print(f"✓ Saved: {iter_path}")-- # Review image using Gemini 3.6 Flash- print(f"Reviewing image with Gemini 3.6 Flash...")- critique, score, needs_improvement = self.review_image(- str(iter_path), user_prompt, i, doc_type, iterations- )- print(f"✓ Score: {score}/10 (threshold: {threshold}/10)")-- # Save iteration results- iteration_result = {- "iteration": i,- "image_path": str(iter_path),- "prompt": current_prompt,- "critique": critique,- "score": score,- "needs_improvement": needs_improvement,- "success": True- }- results["iterations"].append(iteration_result)-- # Check if quality is acceptable - STOP EARLY if so- if not needs_improvement:- print(f"\n✓ Quality meets {doc_type} threshold ({score} >= {threshold})")- print(f" No further iterations needed!")- results["final_image"] = str(iter_path)- results["final_score"] = score- results["success"] = True- results["early_stop"] = True- results["early_stop_reason"] = f"Quality score {score} meets threshold {threshold} for {doc_type}"- break-- # If this is the last iteration, we're done regardless- if i == iterations:- print(f"\n⚠ Maximum iterations reached")- results["final_image"] = str(iter_path)- results["final_score"] = score- results["success"] = True- break-- # Quality below threshold - improve prompt for next iteration- print(f"\n⚠ Quality below threshold ({score} < {threshold})")- print(f"Improving prompt based on feedback...")- current_prompt = self.improve_prompt(user_prompt, critique, i + 1)-- # Copy final version to output path- if results["success"] and results["final_image"]:- final_iter_path = Path(results["final_image"])- if final_iter_path != output_path:- import shutil- shutil.copy(final_iter_path, output_path)- print(f"\n✓ Final image: {output_path}")-- # Save review log- log_path = output_dir / f"{base_name}_review_log.json"- with open(log_path, "w") as f:- json.dump(results, f, indent=2)- print(f"✓ Review log: {log_path}")-- print(f"\n{'='*60}")- print(f"Generation Complete!")- print(f"Final Score: {results['final_score']}/10")- if results["early_stop"]:- print(f"Iterations Used: {len([r for r in results['iterations'] if r.get('success')])}/{iterations} (early stop)")- print(f"{'='*60}\n")-- return results---def main():- """Command-line interface."""- parser = argparse.ArgumentParser(- description="Generate scientific schematics using AI with smart iterative refinement",- formatter_class=argparse.RawDescriptionHelpFormatter,- epilog="""-Examples:- # Generate a flowchart for a journal paper- python generate_schematic_ai.py "CONSORT participant flow diagram" -o flowchart.png --doc-type journal-- # Generate neural network architecture for presentation (lower threshold)- python generate_schematic_ai.py "Transformer encoder-decoder architecture" -o transformer.png --doc-type presentation-- # Generate with custom max iterations for poster- python generate_schematic_ai.py "Biological signaling pathway" -o pathway.png --iterations 2 --doc-type poster-- # Verbose output- python generate_schematic_ai.py "Circuit diagram" -o circuit.png -v--Document Types (quality thresholds):- journal 8.5/10 - Nature, Science, peer-reviewed journals- conference 8.0/10 - Conference papers- thesis 8.0/10 - Dissertations, theses- grant 8.0/10 - Grant proposals- preprint 7.5/10 - arXiv, bioRxiv, etc.- report 7.5/10 - Technical reports- poster 7.0/10 - Academic posters- presentation 6.5/10 - Slides, talks- default 7.5/10 - General purpose--Note: Multiple iterations only occur if quality is BELOW the threshold.- If the first generation meets the threshold, no extra API calls are made.--Environment:- OPENROUTER_API_KEY OpenRouter API key (required)- """- )-- parser.add_argument("prompt", help="Description of the diagram to generate")- parser.add_argument("-o", "--output", required=True,- help="Output image path (e.g., diagram.png)")- parser.add_argument("--iterations", type=int, default=2,- help="Maximum refinement iterations (default: 2, max: 2)")- parser.add_argument("--doc-type", default="default",- choices=["journal", "conference", "poster", "presentation",- "report", "grant", "thesis", "preprint", "default"],- help="Document type for quality threshold (default: default)")- parser.add_argument("--api-key", help="OpenRouter API key (or set OPENROUTER_API_KEY)")- parser.add_argument("-v", "--verbose", action="store_true",- help="Verbose output")-- args = parser.parse_args()-- # Check for API key- api_key = args.api_key or os.getenv("OPENROUTER_API_KEY")- if not api_key:- print("Error: OPENROUTER_API_KEY environment variable not set")- print("\nSet it with:")- print(" export OPENROUTER_API_KEY='your_api_key'")- print("\nOr provide via --api-key flag")- sys.exit(1)-- # Validate iterations - enforce max of 2- if args.iterations < 1 or args.iterations > 2:- print("Error: Iterations must be between 1 and 2")- sys.exit(1)-- try:- generator = ScientificSchematicGenerator(api_key=api_key, verbose=args.verbose)- results = generator.generate_iterative(- user_prompt=args.prompt,- output_path=args.output,- iterations=args.iterations,- doc_type=args.doc_type- )-- if results["success"]:- print(f"\n✓ Success! Image saved to: {args.output}")- if results.get("early_stop"):- print(f" (Completed in {len([r for r in results['iterations'] if r.get('success')])} iteration(s) - quality threshold met)")- sys.exit(0)- else:- print(f"\n✗ Generation failed. Check review log for details.")- sys.exit(1)- except Exception as e:- print(f"\n✗ Error: {str(e)}")- sys.exit(1)---if __name__ == "__main__":- main()-diff --git a/skills/scholar-evaluation/scripts/summarize_agreement.py b/skills/scholar-evaluation/scripts/summarize_agreement.pynew file mode 100644index 00000000..e5242e4c--- /dev/null+++ b/skills/scholar-evaluation/scripts/summarize_agreement.py@@ -0,0 +1,235 @@+#!/usr/bin/env python3+"""Summarize inter-rater agreement from pseudonymous local CSV ratings."""++from __future__ import annotations++import argparse+import csv+import io+import itertools+import math+from collections import defaultdict+from pathlib import Path+from typing import Any++import _common++CSV_FIELDS = [+ "evaluation_id",+ "work_id",+ "rater_id",+ "criterion_id",+ "status",+ "score",+]+++def read_rows(path: Path, rubric: dict[str, Any]) -> list[dict[str, Any]]:+ text = _common.read_csv_text(path)+ reader = csv.DictReader(io.StringIO(text))+ if reader.fieldnames != CSV_FIELDS:+ raise _common.ValidationError("CSV_HEADER_INVALID")+ accepted_scores = _common.scale_values(rubric)+ criterion_ids = {criterion["criterion_id"] for criterion in rubric["criteria"]}+ rows: list[dict[str, Any]] = []+ seen: set[tuple[str, str, str, str]] = set()+ for index, row in enumerate(reader, start=2):+ if len(rows) >= _common.MAX_CSV_ROWS:+ raise _common.ValidationError("CSV_TOO_MANY_ROWS")+ path_prefix = f"$.rows[{index}]"+ if set(row) != set(CSV_FIELDS) or any(+ not isinstance(row.get(field), str) for field in CSV_FIELDS+ ):+ raise _common.ValidationError("CSV_ROW_SHAPE_INVALID", path_prefix)+ for field in ("evaluation_id", "work_id", "rater_id", "criterion_id"):+ if not _common.is_identifier(row.get(field)):+ raise _common.ValidationError(+ "CSV_IDENTIFIER_INVALID", f"{path_prefix}.{field}"+ )+ if row["criterion_id"] not in criterion_ids:+ raise _common.ValidationError(+ "CRITERION_UNKNOWN", f"{path_prefix}.criterion_id"+ )+ if row["status"] not in _common.RATING_STATUSES:+ raise _common.ValidationError(+ "RATING_STATUS_INVALID", f"{path_prefix}.status"+ )+ key = (+ row["evaluation_id"],+ row["work_id"],+ row["rater_id"],+ row["criterion_id"],+ )+ if key in seen:+ raise _common.ValidationError("CSV_RATING_DUPLICATE", path_prefix)+ seen.add(key)+ score: float | None+ if row["status"] == "rated":+ try:+ score = float(row["score"])+ except ValueError as error:+ raise _common.ValidationError(+ "CSV_SCORE_INVALID", f"{path_prefix}.score"+ ) from error+ if not math.isfinite(score) or score not in accepted_scores:+ raise _common.ValidationError(+ "SCORE_NOT_ON_SCALE", f"{path_prefix}.score"+ )+ else:+ if row["score"].strip():+ raise _common.ValidationError(+ "UNRATED_SCORE_MUST_BE_BLANK", f"{path_prefix}.score"+ )+ score = None+ rows.append({**row, "score": score})+ if not rows:+ raise _common.ValidationError("CSV_NO_ROWS")+ return rows+++def _summary(differences: list[float], step: float) -> dict[str, Any]:+ if not differences:+ return {+ "pair_observations": 0,+ "exact_agreement_rate": None,+ "within_one_scale_step_rate": None,+ "mean_absolute_difference": None,+ }+ return {+ "pair_observations": len(differences),+ "exact_agreement_rate": _common.rounded(+ sum(difference <= 1e-9 for difference in differences)+ / len(differences)+ ),+ "within_one_scale_step_rate": _common.rounded(+ sum(difference <= step + 1e-9 for difference in differences)+ / len(differences)+ ),+ "mean_absolute_difference": _common.rounded(+ sum(differences) / len(differences)+ ),+ }+++def summarize(rubric: dict[str, Any], rows: list[dict[str, Any]]) -> dict[str, Any]:+ rubric_issues = _common.validate_rubric(rubric)+ _common.require_valid(rubric_issues)+ grouped: dict[str, dict[str, dict[str, float]]] = defaultdict(+ lambda: defaultdict(dict)+ )+ status_counts: dict[str, dict[str, int]] = defaultdict(+ lambda: {"rated": 0, "missing": 0, "not_applicable": 0}+ )+ raters_by_criterion: dict[str, set[str]] = defaultdict(set)+ works_by_criterion: dict[str, set[str]] = defaultdict(set)+ all_raters: set[str] = set()+ all_works: set[str] = set()+ for row in rows:+ criterion_id = row["criterion_id"]+ status_counts[criterion_id][row["status"]] += 1+ raters_by_criterion[criterion_id].add(row["rater_id"])+ works_by_criterion[criterion_id].add(row["work_id"])+ all_raters.add(row["rater_id"])+ all_works.add(row["work_id"])+ if row["status"] == "rated":+ grouped[criterion_id][row["work_id"]][row["rater_id"]] = row["score"]++ minimum_raters = int(rubric["rater_protocol"]["minimum_raters"])+ if len(all_raters) < minimum_raters:+ raise _common.ValidationError("MINIMUM_RATERS_NOT_MET")+ step = float(rubric["scale"]["step"])+ criterion_reports: list[dict[str, Any]] = []+ overall_differences: list[float] = []+ insufficient: list[str] = []+ for criterion in rubric["criteria"]:+ criterion_id = criterion["criterion_id"]+ differences: list[float] = []+ overlap_work_count = 0+ for work_ratings in grouped.get(criterion_id, {}).values():+ values = list(work_ratings.values())+ if len(values) >= 2:+ overlap_work_count += 1+ differences.extend(+ abs(first - second)+ for first, second in itertools.combinations(values, 2)+ )+ if not differences:+ insufficient.append(criterion_id)+ overall_differences.extend(differences)+ criterion_reports.append(+ {+ "criterion_id": criterion_id,+ "rater_count": len(raters_by_criterion.get(criterion_id, set())),+ "work_count": len(works_by_criterion.get(criterion_id, set())),+ "works_with_rater_overlap": overlap_work_count,+ "rated_rows": status_counts[criterion_id]["rated"],+ "missing_rows": status_counts[criterion_id]["missing"],+ "not_applicable_rows": status_counts[criterion_id][+ "not_applicable"+ ],+ **_summary(differences, step),+ }+ )+ warnings = []+ if insufficient:+ warnings.append("INSUFFICIENT_OVERLAP_FOR_SOME_CRITERIA")+ if any(+ counts["missing"] or counts["not_applicable"]+ for counts in status_counts.values()+ ):+ warnings.append("MISSING_OR_NOT_APPLICABLE_RATINGS_PRESENT")+ return {+ "schema_version": _common.SCHEMA_VERSION,+ "report_type": "inter_rater_agreement_summary",+ "notice": _common.NOTICE,+ "rubric_id": rubric["rubric_id"],+ "rater_count": len(all_raters),+ "work_count": len(all_works),+ "row_count": len(rows),+ "scale_step": step,+ "overall": _summary(overall_differences, step),+ "criteria": criterion_reports,+ "criteria_with_insufficient_overlap": insufficient,+ "warnings": warnings,+ "rater_identifiers_in_output": False,+ "limitations": [+ "Percent agreement and mean absolute difference are descriptive.",+ "These summaries are not a psychometric validation or reliability coefficient.",+ "Select a construct- and design-appropriate reliability model with qualified measurement expertise.",+ ],+ }+++def build_parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(+ description=(+ "Summarize exact agreement, within-step agreement, and mean "+ "absolute difference from pseudonymous local CSV ratings."+ )+ )+ parser.add_argument("--rubric", required=True, type=Path, help="Local rubric JSON")+ parser.add_argument(+ "--ratings", required=True, type=Path, help="Local ratings CSV"+ )+ parser.add_argument("--output", type=Path, help="Optional local JSON report")+ parser.add_argument(+ "--force", action="store_true", help="Replace an existing output JSON file"+ )+ return parser+++def main() -> int:+ args = build_parser().parse_args()+ try:+ rubric = _common.read_json(args.rubric)+ _common.require_valid(_common.validate_rubric(rubric))+ report = summarize(rubric, read_rows(args.ratings, rubric))+ _common.write_json(report, args.output, force=args.force)+ return 0+ except _common.ValidationError as error:+ _common.write_json(_common.failure_report(error), None)+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/scholar-evaluation/scripts/validate_rubric.py b/skills/scholar-evaluation/scripts/validate_rubric.pynew file mode 100644index 00000000..51b03bd4--- /dev/null+++ b/skills/scholar-evaluation/scripts/validate_rubric.py@@ -0,0 +1,54 @@+#!/usr/bin/env python3+"""Validate a bounded scholar-evaluation rubric JSON file."""++from __future__ import annotations++import argparse+from pathlib import Path++import _common+++def validate_file(path: Path) -> dict:+ rubric = _common.read_json(path)+ issues = _common.validate_rubric(rubric)+ errors = _common.error_issues(issues)+ return {+ "schema_version": _common.SCHEMA_VERSION,+ "report_type": "rubric_schema_validation",+ "status": "invalid" if errors else "valid",+ "rubric_id": rubric.get("rubric_id") if isinstance(rubric, dict) else None,+ "error_count": len(errors),+ "warning_count": len(issues) - len(errors),+ "issues": [issue.as_dict() for issue in issues],+ }+++def build_parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(+ description=(+ "Validate a strict local rubric schema; no document content, "+ "credentials, models, or network access are used."+ )+ )+ parser.add_argument("--rubric", required=True, type=Path, help="Local rubric JSON")+ parser.add_argument("--output", type=Path, help="Optional local JSON report")+ parser.add_argument(+ "--force", action="store_true", help="Replace an existing output JSON file"+ )+ return parser+++def main() -> int:+ args = build_parser().parse_args()+ try:+ report = validate_file(args.rubric)+ _common.write_json(report, args.output, force=args.force)+ return 0 if report["status"] == "valid" else 2+ except _common.ValidationError as error:+ _common.write_json(_common.failure_report(error), None)+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/scholar-evaluation/scripts/weight_sensitivity.py b/skills/scholar-evaluation/scripts/weight_sensitivity.pynew file mode 100644index 00000000..42868184--- /dev/null+++ b/skills/scholar-evaluation/scripts/weight_sensitivity.py@@ -0,0 +1,251 @@+#!/usr/bin/env python3+"""Stress-test rubric weights and report scholarly-work order instability."""++from __future__ import annotations++import argparse+import itertools+from pathlib import Path+from typing import Any++import _common+++def _normalized(weights: dict[str, float]) -> dict[str, float]:+ total = sum(weights.values())+ return {criterion_id: weight / total for criterion_id, weight in weights.items()}+++def _scenarios(+ base_weights: dict[str, float], delta: float+) -> list[tuple[str, str | None, float, dict[str, float]]]:+ scenarios = [("base", None, 1.0, dict(base_weights))]+ for criterion_id in sorted(base_weights):+ for label, multiplier in (("decrease", 1.0 - delta), ("increase", 1.0 + delta)):+ changed = dict(base_weights)+ changed[criterion_id] *= multiplier+ scenarios.append(+ (+ f"{criterion_id}:{label}",+ criterion_id,+ multiplier,+ _normalized(changed),+ )+ )+ return scenarios+++def _direction(first: float | None, second: float | None) -> int | None:+ if first is None or second is None:+ return None+ difference = first - second+ if abs(difference) <= 1e-9:+ return 0+ return 1 if difference > 0 else -1+++def analyze(+ rubric: dict[str, Any],+ evaluations: list[dict[str, Any]],+ delta: float,+) -> dict[str, Any]:+ rubric_issues = _common.validate_rubric(rubric)+ _common.require_valid(rubric_issues)+ if not 2 <= len(evaluations) <= _common.MAX_EVALUATIONS:+ raise _common.ValidationError("EVALUATION_COUNT_INVALID")+ work_ids: set[str] = set()+ evaluation_ids: set[str] = set()+ for index, evaluation in enumerate(evaluations):+ issues = _common.validate_evaluation(evaluation, rubric)+ _common.require_valid(issues)+ if evaluation["work_id"] in work_ids:+ raise _common.ValidationError(+ "WORK_ID_DUPLICATE", f"$.evaluations[{index}].work_id"+ )+ if evaluation["evaluation_id"] in evaluation_ids:+ raise _common.ValidationError(+ "EVALUATION_ID_DUPLICATE", f"$.evaluations[{index}].evaluation_id"+ )+ work_ids.add(evaluation["work_id"])+ evaluation_ids.add(evaluation["evaluation_id"])+ if not 0 < delta <= 0.5:+ raise _common.ValidationError("DELTA_OUT_OF_RANGE")++ base_weights = _common.weights_by_criterion(rubric)+ scenario_output: list[dict[str, Any]] = []+ score_ranges = {+ work_id: {"minimum": None, "maximum": None} for work_id in sorted(work_ids)+ }+ base_scores: dict[str, float | None] = {}+ pair_changes: set[tuple[str, str]] = set()+ pairs = list(itertools.combinations(sorted(work_ids), 2))+ incomplete_work_ids: set[str] = set()++ for scenario_index, (+ scenario_id,+ criterion_id,+ multiplier,+ weights,+ ) in enumerate(_scenarios(base_weights, delta)):+ item_scores: list[dict[str, Any]] = []+ score_lookup: dict[str, float | None] = {}+ for evaluation in evaluations:+ score_report = _common.score_evaluation(+ rubric, evaluation, weights=weights+ )+ score = score_report["aggregates"]["normalized_score"]+ coverage = score_report["aggregates"]["coverage_of_applicable_weight"]+ if score is None:+ raise _common.ValidationError(+ "SENSITIVITY_SCORE_UNAVAILABLE", evaluation["work_id"]+ )+ if coverage is None or coverage < 1:+ incomplete_work_ids.add(evaluation["work_id"])+ score_lookup[evaluation["work_id"]] = score+ current_range = score_ranges[evaluation["work_id"]]+ current_range["minimum"] = (+ score+ if current_range["minimum"] is None+ else min(current_range["minimum"], score)+ )+ current_range["maximum"] = (+ score+ if current_range["maximum"] is None+ else max(current_range["maximum"], score)+ )+ item_scores.append(+ {+ "work_id": evaluation["work_id"],+ "normalized_score": score,+ "coverage_of_applicable_weight": coverage,+ }+ )+ if scenario_index == 0:+ base_scores = score_lookup+ else:+ for first, second in pairs:+ if _direction(base_scores[first], base_scores[second]) != _direction(+ score_lookup[first], score_lookup[second]+ ):+ pair_changes.add((first, second))+ scenario_output.append(+ {+ "scenario_id": scenario_id,+ "perturbed_criterion_id": criterion_id,+ "weight_multiplier": _common.rounded(multiplier),+ "weights": {+ key: _common.rounded(value)+ for key, value in sorted(weights.items())+ },+ "item_scores": sorted(item_scores, key=lambda item: item["work_id"]),+ }+ )++ base_order = [+ work_id+ for work_id, _ in sorted(+ base_scores.items(),+ key=lambda item: (+ -(item[1] if item[1] is not None else float("-inf")),+ item[0],+ ),+ )+ ]+ range_output = [+ {+ "work_id": work_id,+ "minimum_score": _common.rounded(bounds["minimum"]),+ "maximum_score": _common.rounded(bounds["maximum"]),+ "range_width": _common.rounded(+ bounds["maximum"] - bounds["minimum"]+ if bounds["minimum"] is not None and bounds["maximum"] is not None+ else None+ ),+ }+ for work_id, bounds in sorted(score_ranges.items())+ ]+ warnings: list[str] = []+ if incomplete_work_ids:+ warnings.append("INCOMPLETE_COVERAGE_LIMITS_COMPARABILITY")+ if pair_changes:+ warnings.append("ORDINAL_ORDER_CHANGES_UNDER_WEIGHT_PERTURBATION")+ return {+ "schema_version": _common.SCHEMA_VERSION,+ "report_type": "weight_sensitivity_and_rank_instability",+ "notice": _common.NOTICE,+ "rubric_id": rubric["rubric_id"],+ "purpose": _common.ALLOWED_PURPOSE,+ "unit_of_assessment": _common.ALLOWED_UNIT,+ "delta": delta,+ "perturbation_method": (+ "multiply one criterion weight by 1-delta and 1+delta, then "+ "renormalize all weights to sum to one"+ ),+ "scenario_count": len(scenario_output),+ "base_ordinal_order": base_order,+ "base_order_is_a_decision_recommendation": False,+ "rank_instability_detected": bool(pair_changes),+ "changed_pair_count": len(pair_changes),+ "total_pair_count": len(pairs),+ "changed_work_pairs": [+ {"first_work_id": first, "second_work_id": second}+ for first, second in sorted(pair_changes)+ ],+ "incomplete_coverage_work_ids": sorted(incomplete_work_ids),+ "score_ranges": range_output,+ "scenarios": scenario_output,+ "warnings": warnings,+ "limitations": [+ "This is a deterministic local stress test, not a validity study.",+ "Ordinal order must not be used to rank people or make high-impact decisions.",+ "Results depend on the submitted rubric, ratings, missingness, and perturbation size.",+ ],+ "decision_recommendation_provided": False,+ }+++def build_parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(+ description=(+ "Perturb rubric weights and report score ranges and ordinal-order "+ "changes for scholarly works only. Never use this output to rank people."+ )+ )+ parser.add_argument("--rubric", required=True, type=Path, help="Local rubric JSON")+ parser.add_argument(+ "--evaluation",+ required=True,+ type=Path,+ action="append",+ help="Local evaluation JSON; repeat for 2 to 50 distinct scholarly works",+ )+ parser.add_argument(+ "--delta",+ type=float,+ default=0.2,+ help="Relative one-at-a-time weight change in (0, 0.5] (default: 0.2)",+ )+ parser.add_argument("--output", type=Path, help="Optional local JSON report")+ parser.add_argument(+ "--force", action="store_true", help="Replace an existing output JSON file"+ )+ return parser+++def main() -> int:+ args = build_parser().parse_args()+ try:+ report = analyze(+ _common.read_json(args.rubric),+ [_common.read_json(path) for path in args.evaluation],+ args.delta,+ )+ _common.write_json(report, args.output, force=args.force)+ return 0+ except _common.ValidationError as error:+ _common.write_json(_common.failure_report(error), None)+ return 2+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/scholar-evaluation/tests/test_scripts.py b/skills/scholar-evaluation/tests/test_scripts.pynew file mode 100644index 00000000..9405eaba--- /dev/null+++ b/skills/scholar-evaluation/tests/test_scripts.py@@ -0,0 +1,432 @@+"""Synthetic dependency-free tests for scholar-evaluation local tooling."""++from __future__ import annotations++import ast+import copy+import json+import re+import sys+import tempfile+import unittest+from pathlib import Path++sys.dont_write_bytecode = True++SKILL_ROOT = Path(__file__).resolve().parents[1]+SCRIPTS = SKILL_ROOT / "scripts"+ASSETS = SKILL_ROOT / "assets"+sys.path.insert(0, str(SCRIPTS))++import _common # noqa: E402+import calculate_scores # noqa: E402+import check_process # noqa: E402+import check_traceability # noqa: E402+import generate_report_scaffold # noqa: E402+import summarize_agreement # noqa: E402+import validate_rubric # noqa: E402+import weight_sensitivity # noqa: E402+++def load_json_asset(name: str) -> dict:+ return json.loads((ASSETS / name).read_text(encoding="utf-8"))+++def rated_evaluation(+ work_id: str = "WORK-SYNTHETIC-001",+ evaluation_id: str = "EVALUATION-SYNTHETIC-001",+ scores: list[float] | None = None,+) -> dict:+ evaluation = load_json_asset("evaluation_template.json")+ evaluation["work_id"] = work_id+ evaluation["evaluation_id"] = evaluation_id+ supplied_scores = scores or [3, 3, 3, 3, 3]+ evidence_ids = [+ "EVIDENCE-SYNTHETIC-QUESTION",+ "EVIDENCE-SYNTHETIC-LITERATURE",+ "EVIDENCE-SYNTHETIC-METHOD",+ "EVIDENCE-SYNTHETIC-ANALYSIS",+ "EVIDENCE-SYNTHETIC-TRANSPARENCY",+ ]+ for rating, score, evidence_id in zip(+ evaluation["ratings"], supplied_scores, evidence_ids, strict=True+ ):+ rating.update(+ {+ "status": "rated",+ "score": score,+ "uncertainty": 0.5,+ "evidence_ids": [evidence_id],+ "rationale_ref": f"LOCAL-RATIONALE-{rating['criterion_id']}",+ }+ )+ return evaluation+++def completed_process() -> dict:+ record = load_json_asset("process_checklist_template.json")+ for section_name, field_groups in check_process.SECTION_FIELDS.items():+ for field in field_groups["booleans"]:+ record[section_name][field] = True+ for field in field_groups["references"]:+ record[section_name][field] = f"LOCAL-{section_name}-{field}"+ return record+++class StaticSafetyTests(unittest.TestCase):+ def test_scripts_have_no_network_dynamic_process_or_executable_serialization(self) -> None:+ banned_import_roots = {+ "aiohttp",+ "httpx",+ "openai",+ "pickle",+ "requests",+ "socket",+ "".join(("sub", "process")),+ "urllib",+ }+ banned_calls = {+ "".join(("e", "val")),+ "".join(("e", "xec")),+ "".join(("com", "pile")),+ }+ for path in sorted(SCRIPTS.glob("*.py")):+ source = path.read_text(encoding="utf-8")+ tree = ast.parse(source, filename=str(path))+ for node in ast.walk(tree):+ if isinstance(node, ast.Import):+ roots = {alias.name.split(".")[0] for alias in node.names}+ self.assertFalse(roots & banned_import_roots, path.name)+ if isinstance(node, ast.ImportFrom) and node.module:+ self.assertNotIn(+ node.module.split(".")[0],+ banned_import_roots,+ path.name,+ )+ if isinstance(node, ast.Call) and isinstance(node.func, ast.Name):+ self.assertNotIn(node.func.id, banned_calls, path.name)+ self.assertNotIn("os.environ", source)+ self.assertNotIn("getenv(", source)+ self.assertNotIn("API_KEY", source)+ self.assertNotIn(".env", source)++ def test_external_schematic_scripts_are_absent(self) -> None:+ self.assertFalse((SCRIPTS / "generate_schematic.py").exists())+ self.assertFalse((SCRIPTS / "generate_schematic_ai.py").exists())++ def test_skill_is_versioned_and_under_500_lines(self) -> None:+ text = (SKILL_ROOT / "SKILL.md").read_text(encoding="utf-8")+ self.assertLess(len(text.splitlines()), 500)+ self.assertIn('metadata:\n version: "2.0"', text)+ self.assertIn("license: MIT", text)+ self.assertIn("compatibility:", text)+ self.assertNotIn("OPENROUTER", text)++ def test_documented_local_paths_exist(self) -> None:+ pattern = re.compile(+ r"`((?:assets|references|scripts)/[A-Za-z0-9_.-]+)`"+ )+ documents = [+ SKILL_ROOT / "SKILL.md",+ *sorted((SKILL_ROOT / "references").glob("*.md")),+ ]+ missing = []+ for document in documents:+ for relative in pattern.findall(document.read_text(encoding="utf-8")):+ if not (SKILL_ROOT / relative).is_file():+ missing.append(f"{document.name}:{relative}")+ self.assertEqual(missing, [])++ def test_expected_assets_only(self) -> None:+ expected = {+ "evaluation_template.json",+ "evidence_manifest_template.json",+ "process_checklist_template.json",+ "ratings_template.csv",+ "rubric_template.json",+ }+ actual = {path.name for path in ASSETS.iterdir() if path.is_file()}+ self.assertEqual(actual, expected)++ def test_no_bytecode_artifacts(self) -> None:+ artifacts = [+ path+ for path in SKILL_ROOT.rglob("*")+ if path.suffix in {".pyc", ".pyo"}+ ]+ self.assertEqual(artifacts, [])++ def test_all_script_help_is_dependency_free(self) -> None:+ modules = (+ calculate_scores,+ check_process,+ check_traceability,+ generate_report_scaffold,+ summarize_agreement,+ validate_rubric,+ weight_sensitivity,+ )+ for module in modules:+ help_text = module.build_parser().format_help()+ self.assertIn("usage:", help_text.lower(), module.__name__)+++class RubricAndInputTests(unittest.TestCase):+ def test_template_rubric_is_structurally_valid_with_warning(self) -> None:+ rubric = load_json_asset("rubric_template.json")+ issues = _common.validate_rubric(rubric)+ self.assertEqual(_common.error_issues(issues), [])+ self.assertIn(+ "CONTENT_VALIDITY_NOT_DOCUMENTED",+ {issue.code for issue in issues},+ )+ self.assertIn(+ "INTER_RATER_RELIABILITY_NOT_DOCUMENTED",+ {issue.code for issue in issues},+ )++ def test_validator_rejects_unknown_field(self) -> None:+ rubric = load_json_asset("rubric_template.json")+ rubric["unexpected"] = True+ issues = _common.validate_rubric(rubric)+ self.assertIn("SCHEMA_UNKNOWN_FIELD", {issue.code for issue in issues})++ def test_validator_fails_closed_on_malformed_scale(self) -> None:+ rubric = load_json_asset("rubric_template.json")+ rubric["scale"] = None+ issues = _common.validate_rubric(rubric)+ self.assertIn("SCHEMA_OBJECT_REQUIRED", {issue.code for issue in issues})++ def test_validator_rejects_proxy_criterion(self) -> None:+ rubric = load_json_asset("rubric_template.json")+ rubric["criteria"][0]["label"] = "Journal impact factor"+ issues = _common.validate_rubric(rubric)+ self.assertIn(+ "PROXY_METRIC_CRITERION_PROHIBITED",+ {issue.code for issue in issues},+ )++ def test_duplicate_json_key_is_rejected(self) -> None:+ with tempfile.TemporaryDirectory() as directory:+ path = Path(directory) / "duplicate.json"+ path.write_text('{"work_id":"A","work_id":"B"}', encoding="utf-8")+ with self.assertRaisesRegex(_common.ValidationError, "JSON_DUPLICATE_KEY"):+ _common.read_json(path)++ def test_private_application_field_is_rejected(self) -> None:+ with tempfile.TemporaryDirectory() as directory:+ path = Path(directory) / "private.json"+ path.write_text(+ '{"schema_version":"2.0","application_text":"private"}',+ encoding="utf-8",+ )+ with self.assertRaisesRegex(+ _common.ValidationError, "PRIVATE_FIELD_NOT_ALLOWED"+ ):+ _common.read_json(path)++ def test_excessive_depth_is_rejected(self) -> None:+ value: dict = {}+ cursor = value+ for _ in range(_common.MAX_DEPTH + 2):+ cursor["nested"] = {}+ cursor = cursor["nested"]+ with tempfile.TemporaryDirectory() as directory:+ path = Path(directory) / "deep.json"+ path.write_text(json.dumps(value), encoding="utf-8")+ with self.assertRaisesRegex(+ _common.ValidationError, "STRUCTURE_TOO_DEEP"+ ):+ _common.read_json(path)++ def test_unrated_template_is_valid(self) -> None:+ rubric = load_json_asset("rubric_template.json")+ evaluation = load_json_asset("evaluation_template.json")+ self.assertEqual(+ _common.error_issues(_common.validate_evaluation(evaluation, rubric)),+ [],+ )+++class ScoringAndTraceabilityTests(unittest.TestCase):+ def setUp(self) -> None:+ self.rubric = load_json_asset("rubric_template.json")++ def test_weighted_math_is_bounded_and_has_no_recommendation(self) -> None:+ evaluation = rated_evaluation(scores=[4, 3, 2, 1, 0])+ report = calculate_scores.calculate(self.rubric, evaluation)+ expected = 4 * 0.15 + 3 * 0.2 + 2 * 0.25 + 1 * 0.2+ self.assertAlmostEqual(+ report["aggregates"]["normalized_score"], expected, places=6+ )+ self.assertEqual(report["aggregates"]["coverage_of_applicable_weight"], 1)+ self.assertFalse(report["decision_recommendation_provided"])+ self.assertNotIn("quality_level", report)++ def test_missing_and_not_applicable_are_reported_not_zeroed(self) -> None:+ evaluation = rated_evaluation(scores=[4, 3, 2, 1, 0])+ evaluation["ratings"][3].update(+ {+ "status": "missing",+ "score": None,+ "uncertainty": None,+ "evidence_ids": [],+ }+ )+ evaluation["ratings"][4].update(+ {+ "status": "not_applicable",+ "score": None,+ "uncertainty": None,+ "evidence_ids": [],+ }+ )+ report = calculate_scores.calculate(self.rubric, evaluation)+ aggregates = report["aggregates"]+ self.assertAlmostEqual(aggregates["missing_weight"], 0.2)+ self.assertAlmostEqual(aggregates["not_applicable_weight"], 0.2)+ self.assertLess(aggregates["coverage_of_applicable_weight"], 1)+ self.assertIn(+ "MISSING_RATINGS_EXCLUDED_FROM_NORMALIZED_SCORE", report["warnings"]+ )++ def test_uncertainty_is_clamped_to_scale(self) -> None:+ evaluation = rated_evaluation(scores=[4, 3, 2, 1, 0])+ report = calculate_scores.calculate(self.rubric, evaluation)+ interval = report["aggregates"]["uncertainty_interval"]+ self.assertGreaterEqual(interval["lower"], 0)+ self.assertLessEqual(interval["upper"], 4)+ self.assertIn("not a confidence interval", interval["method"])++ def test_traceability_passes_and_never_copies_content(self) -> None:+ evaluation = rated_evaluation()+ manifest = load_json_asset("evidence_manifest_template.json")+ report = check_traceability.check_traceability(+ self.rubric, evaluation, manifest+ )+ self.assertEqual(report["status"], "pass", report["issues"])+ self.assertFalse(report["source_content_copied_to_output"])+ rendered = json.dumps(report)+ self.assertNotIn("LOCAL-WORK-SECTION", rendered)++ def test_unresolved_evidence_fails(self) -> None:+ evaluation = rated_evaluation()+ evaluation["ratings"][0]["evidence_ids"] = ["EVIDENCE-NOT-FOUND"]+ report = check_traceability.check_traceability(+ self.rubric,+ evaluation,+ load_json_asset("evidence_manifest_template.json"),+ )+ self.assertEqual(report["status"], "fail")+ self.assertIn(+ "EVIDENCE_REFERENCE_UNRESOLVED",+ {issue["code"] for issue in report["issues"]},+ )+++class SensitivityAgreementAndProcessTests(unittest.TestCase):+ def setUp(self) -> None:+ self.rubric = load_json_asset("rubric_template.json")++ def test_weight_sensitivity_detects_order_instability(self) -> None:+ first = rated_evaluation(+ "WORK-SYNTHETIC-A",+ "EVALUATION-SYNTHETIC-A",+ [4, 4, 1, 2, 2],+ )+ second = rated_evaluation(+ "WORK-SYNTHETIC-B",+ "EVALUATION-SYNTHETIC-B",+ [1, 1, 4, 3, 3],+ )+ report = weight_sensitivity.analyze(self.rubric, [first, second], 0.5)+ self.assertTrue(report["rank_instability_detected"])+ self.assertGreater(report["changed_pair_count"], 0)+ self.assertFalse(report["decision_recommendation_provided"])+ self.assertEqual(report["unit_of_assessment"], "scholarly_work")++ def test_agreement_summary_is_pseudonymous_and_descriptive(self) -> None:+ rows = summarize_agreement.read_rows(+ ASSETS / "ratings_template.csv", self.rubric+ )+ report = summarize_agreement.summarize(self.rubric, rows)+ self.assertGreater(report["overall"]["pair_observations"], 0)+ self.assertFalse(report["rater_identifiers_in_output"])+ rendered = json.dumps(report)+ self.assertNotIn("RATER-SYNTHETIC", rendered)+ self.assertIn("not a psychometric validation", report["limitations"][1])++ def test_agreement_rejects_extra_csv_column(self) -> None:+ with tempfile.TemporaryDirectory() as directory:+ path = Path(directory) / "ratings.csv"+ path.write_text(+ "evaluation_id,work_id,rater_id,criterion_id,status,score\n"+ "EVALUATION-1,WORK-1,RATER-1,question_scope,rated,3,extra\n",+ encoding="utf-8",+ )+ with self.assertRaisesRegex(+ _common.ValidationError, "CSV_ROW_SHAPE_INVALID"+ ):+ summarize_agreement.read_rows(path, self.rubric)++ def test_unconfirmed_process_is_blocked(self) -> None:+ report = check_process.check_process(+ load_json_asset("process_checklist_template.json")+ )+ self.assertEqual(report["status"], "blocked")+ self.assertTrue(report["blockers"])++ def test_completed_low_stakes_process_passes(self) -> None:+ report = check_process.check_process(completed_process())+ self.assertEqual(report["status"], "complete_for_low_stakes_process")+ self.assertEqual(report["blockers"], [])+ self.assertEqual(report["missing_controls"], [])++ def test_high_impact_process_is_blocked(self) -> None:+ record = completed_process()+ record["high_impact_use"] = True+ report = check_process.check_process(record)+ self.assertEqual(report["status"], "blocked")+ self.assertIn("PROHIBITED_HIGH_IMPACT_USE", report["blockers"])++ def test_report_scaffold_contains_only_safe_placeholders(self) -> None:+ self.rubric["construct"]["definition"] = "SYNTHETIC-SENSITIVE-RUBRIC-TEXT"+ self.rubric["criteria"][0]["label"] = "SYNTHETIC-SENSITIVE-LABEL"+ report = generate_report_scaffold.generate_scaffold(+ self.rubric, rated_evaluation()+ )+ self.assertFalse(report["private_source_content_included"])+ self.assertFalse(report["person_ranking_provided"])+ self.assertFalse(report["decision_recommendation_provided"])+ self.assertEqual(+ report["quality_assurance"]["inter_rater_reliability_status"],+ "not_established",+ )+ rendered = json.dumps(report)+ self.assertNotIn("SYNTHETIC-SENSITIVE", rendered)+ for criterion in report["criterion_scaffold"]:+ self.assertEqual(criterion["evidence_finding_refs"], [])+ self.assertEqual(criterion["qualified_reviewer_comment_ref"], "")+++class FileOutputTests(unittest.TestCase):+ def test_output_refuses_overwrite_without_force(self) -> None:+ with tempfile.TemporaryDirectory() as directory:+ output = Path(directory) / "report.json"+ _common.write_json({"status": "first"}, output)+ with self.assertRaisesRegex(_common.ValidationError, "OUTPUT_EXISTS"):+ _common.write_json({"status": "second"}, output)+ _common.write_json({"status": "second"}, output, force=True)+ self.assertEqual(+ json.loads(output.read_text(encoding="utf-8"))["status"],+ "second",+ )++ def test_validate_file_returns_minimized_report(self) -> None:+ report = validate_rubric.validate_file(ASSETS / "rubric_template.json")+ self.assertEqual(report["status"], "valid")+ self.assertEqual(report["error_count"], 0)+++if __name__ == "__main__":+ unittest.main()