Skip to content

dongshuyan/compass-skills / skills/assess-interview-candidate

assess-interview-candidate

Verified

根据候选人简历与岗位要求生成可审计的后台评估、简明的候选人介绍、按岗位重要性排列的简历疑点、12–18 道可直接照读的面试题,以及支持重点标记和本机保存的离线 HTML。用于招聘方准备结构化面试、核验岗位能力和记录回答。不要用于求职者模拟面试、私人背景调查、心理或人格诊断、从敏感属性推断表现,或自动录用、淘汰、排序候选人。

FileKindSize
SKILL.mdskill md17.9 KB
agents/openai.yamlconfig329 B
assets/candidate-assessment-template.htmlother35.5 KB
evals/evals.jsonconfig11.1 KB
references/agent-portability.mdmarkdown3.5 KB
references/evidence-and-inference-policy.mdmarkdown7.8 KB
references/job-modeling.mdmarkdown3.8 KB
references/privacy-and-fairness-cn.mdmarkdown7.1 KB
references/research-and-identity-policy.mdmarkdown4.0 KB
references/role-adapter-ai-llm-engineering.mdmarkdown5.7 KB
references/schema-evidence-ledger.jsonconfig6.2 KB
references/schema-interview-blueprint.jsonconfig5.6 KB
references/schema-interviewer-report.jsonconfig13.7 KB
references/schema-job-model.jsonconfig4.5 KB
references/schema-source-record.jsonconfig9.5 KB
references/scoring-and-coverage.mdmarkdown9.5 KB
references/structured-interview-methods.mdmarkdown4.8 KB
references/workflow-contract.mdmarkdown14.7 KB
scripts/calculate_interview_score.pyscript15.5 KB
scripts/create_candidate_case.pyscript3.6 KB
scripts/derive_timeline_age.pyscript9.9 KB
scripts/normalize_inputs.pyscript9.0 KB
scripts/prepare_candidate_photo.pyscript12.4 KB
scripts/render_candidate_report.pyscript5.3 KB
scripts/validate_candidate_report.pyscript10.1 KB
scripts/validate_case_contract.pyscript28.3 KB
scripts/validate_evidence_ledger.pyscript15.2 KB
scripts/validate_interviewer_report_data.pyscript35.4 KB
scripts/validate_source_log.pyscript21.4 KB
tests/test_candidate_profile_enrichment.pyscript40.3 KB
tests/test_interviewer_report.pyscript34.1 KB
tests/test_public_package.pyscript7.0 KB

tests/test_interviewer_report.py

View on GitHub
#!/usr/bin/env python3
"""Behavior tests for the simplified interviewer-facing report."""

from __future__ import annotations

import base64
import hashlib
import json
import os
import struct
import subprocess
import sys
import tempfile
import unittest
import zlib
from pathlib import Path


SKILL_DIR = Path(__file__).resolve().parents[1]
SCRIPTS_DIR = SKILL_DIR / "scripts"
NO_BYTECODE_ENV = {**os.environ, "PYTHONDONTWRITEBYTECODE": "1"}
sys.dont_write_bytecode = True
sys.path.insert(0, str(SCRIPTS_DIR))

from validate_interviewer_report_data import calculate_age, validate_interviewer_report_data  # noqa: E402


def provided(value: str, locator: str = "normalized/resume.md:基本信息") -> dict[str, str]:
    return {
        "value": value,
        "source_status": "candidate_provided",
        "source_locator": locator,
    }


def not_provided() -> dict[str, str | None]:
    return {
        "value": "未提供",
        "source_status": "not_provided",
        "source_locator": None,
    }


def png_bytes(width: int = 96, height: int = 128) -> bytes:
    """Return a small standards-compliant RGB PNG without external libraries."""

    def chunk(kind: bytes, payload: bytes) -> bytes:
        body = kind + payload
        return struct.pack(">I", len(payload)) + body + struct.pack(">I", zlib.crc32(body) & 0xFFFFFFFF)

    signature = b"\x89PNG\r\n\x1a\n"
    ihdr = struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0)
    row = b"\x00" + (b"\x80\x80\x80" * width)
    pixels = zlib.compress(row * height)
    return signature + chunk(b"IHDR", ihdr) + chunk(b"IDAT", pixels) + chunk(b"IEND", b"")


PHOTO_BYTES = png_bytes()
PHOTO_DATA_URI = "data:image/png;base64," + base64.b64encode(PHOTO_BYTES).decode("ascii")


def no_candidate_photo() -> dict[str, object]:
    return {
        "status": "not_present",
        "data_uri": None,
        "mime_type": None,
        "byte_length": None,
        "pixel_width": None,
        "pixel_height": None,
        "sha256": None,
        "provenance": None,
    }


def included_candidate_photo() -> dict[str, object]:
    return {
        "status": "included",
        "data_uri": PHOTO_DATA_URI,
        "mime_type": "image/png",
        "byte_length": len(PHOTO_BYTES),
        "pixel_width": 96,
        "pixel_height": 128,
        "sha256": hashlib.sha256(PHOTO_BYTES).hexdigest(),
        "provenance": {
            "source_kind": "resume_pdf",
            "source_document": "input/resume-original.pdf",
            "source_document_sha256": "a" * 64,
            "page": 1,
            "extraction_method": "embedded_image",
            "image_index": 3,
            "crop_box": None,
        },
    }


def no_timeline_estimate() -> dict[str, object]:
    return {
        "status": "not_needed",
        "display": "候选人已提供年龄信息,不进行履历年龄推算",
        "as_of": "2026-08-23",
        "min_years": None,
        "max_years": None,
        "anchor": None,
        "assumptions": {
            "undergraduate_start_age_min": 16,
            "undergraduate_start_age_typical": 18,
            "undergraduate_start_age_max": 20,
        },
        "consistency_status": "not_checked",
        "consistency_checks": [],
    }


def insufficient_timeline_estimate() -> dict[str, object]:
    value = no_timeline_estimate()
    value.update(
        {
            "status": "insufficient_evidence",
            "display": "未找到明确的本科入学时间,也无法由明确的毕业时间与学制可靠反推",
            "consistency_status": "not_assessable",
        }
    )
    return value


def estimated_from_undergraduate_start() -> dict[str, object]:
    return {
        "status": "estimated",
        "display": "约29–34岁(按2012年本科入学、入学年龄18±2岁推算;非候选人自述)",
        "as_of": "2026-08-23",
        "min_years": 29,
        "max_years": 34,
        "anchor": {
            "kind": "undergraduate_start",
            "start": "2012",
            "precision": "year",
            "source_locators": ["normalized/resume.md:教育背景"],
            "graduation_date": None,
            "degree_duration_years": None,
        },
        "assumptions": {
            "undergraduate_start_age_min": 16,
            "undergraduate_start_age_typical": 18,
            "undergraduate_start_age_max": 20,
        },
        "consistency_status": "not_checked",
        "consistency_checks": [],
    }


def rated_question(index: int) -> dict[str, object]:
    return {
        "id": f"q-{index:02d}",
        "order": index,
        "priority": "must_ask" if index <= 4 else "recommended",
        "kind": "job_core" if index <= 4 else "resume_check",
        "question": f"这是第 {index} 道可以直接照读的问题吗?",
        "purpose": "核验与目标岗位直接相关的可观察能力。",
        "evaluation_mode": "rated",
        "good_answer": "能说明本人行动、约束、结果和验证方法。",
        "average_answer": "能说明做过相关工作,但个人边界或验证不够完整。",
        "poor_answer": "只罗列术语或团队结果,无法说明本人行动。",
        "bonus_signals": ["主动说明失败和修正过程"],
        "penalty_signals": ["把未验证结果当作已经完成"],
    }


def sample_report_data() -> dict[str, object]:
    questions = [rated_question(index) for index in range(1, 11)]
    questions[1]["kind"] = "work_sample"
    questions[2]["kind"] = "soft_skill"
    questions.append(
        {
            "id": "q-11",
            "order": 11,
            "priority": "recommended",
            "kind": "logistics",
            "question": "你目前常住在哪个城市,现场办公、搬迁和到岗时间分别有什么安排?",
            "purpose": "确认双方实际工作安排是否一致,不用于判断人格或稳定性。",
            "evaluation_mode": "record_only",
            "recording_guidance": "如实记录地点、到岗和现场办公条件;不设好坏,不加分、不扣分。",
        }
    )
    questions.append(
        {
            "id": "q-12",
            "order": 12,
            "priority": "optional",
            "kind": "candidate_choice",
            "question": "方便说明一下你的婚姻状况吗?如果不方便,可以不回答。",
            "purpose": "记录候选人自愿补充的信息;是否提问由面试官决定,不用于岗位评分。",
            "evaluation_mode": "record_only",
            "recording_guidance": "如实记录或记为不便回答;不设好坏,不加分、不扣分。",
        }
    )
    return {
        "schema_version": "1.1.0",
        "case": {
            "id": "case-synthetic-candidate",
            "candidate_name": "测试候选人",
            "role_title": "AI 辅助全栈工程师",
            "report_date": "2026-08-23",
            "blueprint_version": "1.0.0",
            "human_review_status": "待面试官人工复核",
        },
        "candidate_overview": {
            "personal_info": {
                "birth_information": provided("1992-08-22"),
                "age": {
                    "display": "34岁",
                    "years": 34,
                    "approximate": False,
                    "as_of": "2026-08-23",
                    "normalized_birth": "1992-08-22",
                    "precision": "day",
                    "source_status": "candidate_provided",
                    "source_locator": "normalized/resume.md:基本信息",
                },
                "birthplace": provided("甲省乙市"),
                "hometown": provided("甲省乙市"),
                "marital_status": provided("已婚"),
                "current_city": provided("丙市"),
            },
            "candidate_photo": no_candidate_photo(),
            "timeline_age_estimate": no_timeline_estimate(),
            "profile_summary": [
                "医学与计算机双学士。",
                "目前从事医疗 AI 算法与 Agent 工程。",
            ],
            "education": [
                {
                    "school": "示例大学",
                    "degree_or_program": "医学、计算机科学与技术双学士",
                    "period": "2012–2017",
                    "city": "未提供",
                    "city_source_status": "not_provided",
                    "source_locator": "normalized/resume.md:教育背景",
                }
            ],
            "employment": [
                {
                    "organization": "示例科技公司",
                    "role": "算法策略工程师",
                    "period": "2025–至今",
                    "city": "丙市",
                    "city_source_status": "candidate_provided",
                    "source_locator": "normalized/resume.md:工作经历",
                }
            ],
            "fit_items": [
                {
                    "order": 1,
                    "capability": "AI Agent 工程",
                    "status": "match",
                    "summary": "有 Agent 与工作流编排经历。",
                    "interview_focus": "确认本人负责范围和可运行交付。",
                },
                {
                    "order": 2,
                    "capability": "前端产品工程",
                    "status": "evidence_insufficient",
                    "summary": "简历没有直接展示前端项目。",
                    "interview_focus": "通过工作样本核验,不因简历缺失直接扣分。",
                },
            ],
            "location_and_availability": {
                "company_location": "未提供",
                "distance_summary": "距离无法计算,待补充公司地址",
                "questions": [
                    "你目前常住在哪个城市?",
                    "如果工作地点不同,你是否愿意搬迁?",
                    "最早什么时候可以到岗?",
                ],
            },
        },
        "resume_risks": [
            {
                "id": "risk-1",
                "order": 1,
                "importance": 5,
                "capability": "AI 协作下的端到端交付",
                "resume_excerpt": "参与模型训练、评估与策略迭代。",
                "unclear_point": "“参与”没有说明本人具体负责哪一段。",
                "why_check": "岗位要求独立完成可运行的前后端闭环。",
                "how_to_verify": "让候选人按需求、本人实现、测试、失败和结果逐步说明。",
            }
        ],
        "interview_questions": questions,
        "footer_note": "本报告只辅助人工面试,不自动录用、淘汰或排序候选人。",
    }


class InterviewerReportDataTests(unittest.TestCase):
    def test_birth_month_only_is_exact_when_all_possible_birthdays_agree(self) -> None:
        for birth, report_date, expected in (
            ("2001-05", "2026-09-26", (25, False, "month")),
            ("1997-10", "2026-09-26", (28, False, "month")),
            ("2001-05", "2026-05-15", (25, True, "month")),
            ("2001-05", "2026-05-31", (25, False, "month")),
        ):
            with self.subTest(birth=birth, report_date=report_date):
                self.assertEqual(expected, calculate_age(birth, report_date))

    def test_timeline_point_estimate_is_validated_without_erasing_internal_bounds(self) -> None:
        data = sample_report_data()
        overview = data["candidate_overview"]
        overview["personal_info"]["birth_information"] = not_provided()
        overview["personal_info"]["age"].update({
            "display": "未提供", "years": None, "approximate": False,
            "normalized_birth": None, "precision": "not_provided",
            "source_status": "not_provided", "source_locator": None,
        })
        estimate = estimated_from_undergraduate_start()
        estimate["display"] = "约32岁(按2012本科入学、入学时18岁假设推算;非候选人自述)"
        overview["timeline_age_estimate"] = estimate
        errors, _ = validate_interviewer_report_data(data)
        self.assertEqual([], errors)
        for invalid_display in (
            "约33岁(按2012本科入学、入学时18岁假设推算;非候选人自述)",
            "32岁(按2012本科入学、入学时18岁假设推算;非候选人自述)",
        ):
            with self.subTest(display=invalid_display):
                estimate["display"] = invalid_display
                errors, _ = validate_interviewer_report_data(data)
                self.assertTrue(any("timeline_age_estimate.display" in item for item in errors), errors)

    def test_valid_data_passes(self) -> None:
        errors, warnings = validate_interviewer_report_data(sample_report_data())
        self.assertEqual([], errors)
        self.assertEqual([], warnings)

    def test_clear_resume_photo_can_be_embedded_as_an_offline_data_uri(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["candidate_photo"] = included_candidate_photo()
        errors, _ = validate_interviewer_report_data(data)
        self.assertEqual([], errors)

    def test_external_photo_source_is_rejected(self) -> None:
        data = sample_report_data()
        photo = included_candidate_photo()
        photo["data_uri"] = "https://example.com/avatar.png"
        data["candidate_overview"]["candidate_photo"] = photo
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("candidate_photo" in item and "data URI" in item for item in errors), errors)

    def test_undergraduate_start_year_produces_a_display_only_age_range(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["birth_information"] = not_provided()
        data["candidate_overview"]["personal_info"]["age"] = {
            "display": "未提供",
            "years": None,
            "approximate": False,
            "as_of": "2026-08-23",
            "normalized_birth": None,
            "precision": "not_provided",
            "source_status": "not_provided",
            "source_locator": None,
        }
        data["candidate_overview"]["timeline_age_estimate"] = estimated_from_undergraduate_start()
        errors, _ = validate_interviewer_report_data(data)
        self.assertEqual([], errors)

    def test_explicit_self_reported_age_disables_timeline_inference(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["birth_information"] = not_provided()
        data["candidate_overview"]["personal_info"]["age"] = {
            "display": "27岁",
            "years": 27,
            "approximate": False,
            "as_of": "2026-08-23",
            "normalized_birth": None,
            "precision": "not_provided",
            "source_status": "candidate_provided",
            "source_locator": "normalized/resume.md:基本信息",
        }
        data["candidate_overview"]["timeline_age_estimate"] = no_timeline_estimate()
        for display in ("27岁", "候选人自述:27岁", "27周岁"):
            with self.subTest(display=display):
                data["candidate_overview"]["personal_info"]["age"]["display"] = display
                errors, _ = validate_interviewer_report_data(data)
                self.assertEqual([], errors)

    def test_self_reported_age_display_rejects_conflicting_or_partial_numbers(self) -> None:
        data = sample_report_data()
        personal = data["candidate_overview"]["personal_info"]
        personal["birth_information"] = not_provided()
        personal["age"] = {
            "display": "27岁",
            "years": 27,
            "approximate": False,
            "as_of": "2026-08-23",
            "normalized_birth": None,
            "precision": "not_provided",
            "source_status": "candidate_provided",
            "source_locator": "normalized/resume.md:基本信息",
        }
        data["candidate_overview"]["timeline_age_estimate"] = no_timeline_estimate()
        for display in ("127岁", "28岁(原记录27岁)", "27.5岁", "-27岁"):
            with self.subTest(display=display):
                personal["age"]["display"] = display
                errors, _ = validate_interviewer_report_data(data)
                self.assertTrue(any("personal_info.age.display" in item for item in errors), errors)

    def test_explicit_self_reported_age_cannot_keep_timeline_inference(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["birth_information"] = not_provided()
        data["candidate_overview"]["personal_info"]["age"] = {
            "display": "27岁",
            "years": 27,
            "approximate": False,
            "as_of": "2026-08-23",
            "normalized_birth": None,
            "precision": "not_provided",
            "source_status": "candidate_provided",
            "source_locator": "normalized/resume.md:基本信息",
        }
        data["candidate_overview"]["timeline_age_estimate"] = estimated_from_undergraduate_start()
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("not_needed" in item for item in errors), errors)

    def test_timeline_estimate_cannot_be_used_for_scoring(self) -> None:
        data = sample_report_data()
        data["interview_questions"][0]["good_answer"] = "年龄在29至34岁区间可以加分。"
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("interview_questions[0]" in item and "年龄" in item for item in errors), errors)

    def test_birth_information_takes_precedence_over_timeline_inference(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["timeline_age_estimate"] = estimated_from_undergraduate_start()
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("not_needed" in item or "birth information" in item for item in errors), errors)

    def test_exact_birth_date_age_must_match_report_date(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["age"]["years"] = 33
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("age.years" in item for item in errors), errors)

    def test_converted_age_keeps_the_birth_information_source(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["age"]["source_locator"] = "normalized/resume.md:其他位置"
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("age.source_locator" in item for item in errors), errors)

    def test_birth_year_is_converted_to_approximate_age(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["birth_information"] = provided("1992")
        data["candidate_overview"]["personal_info"]["age"] = {
            "display": "约34岁(按出生年份估算)",
            "years": 34,
            "approximate": True,
            "as_of": "2026-08-23",
            "normalized_birth": "1992",
            "precision": "year",
            "source_status": "candidate_provided",
            "source_locator": "normalized/resume.md:基本信息",
        }
        errors, _ = validate_interviewer_report_data(data)
        self.assertEqual([], errors)

    def test_absent_birth_information_displays_age_as_not_provided(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["birth_information"] = not_provided()
        data["candidate_overview"]["personal_info"]["age"] = {
            "display": "未提供",
            "years": None,
            "approximate": False,
            "as_of": "2026-08-23",
            "normalized_birth": None,
            "precision": "not_provided",
            "source_status": "not_provided",
            "source_locator": None,
        }
        data["candidate_overview"]["timeline_age_estimate"] = insufficient_timeline_estimate()
        errors, _ = validate_interviewer_report_data(data)
        self.assertEqual([], errors)

    def test_missing_personal_information_cannot_be_inferred(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["personal_info"]["hometown"] = {
            "value": "甲省乙市",
            "source_status": "inferred_from_school",
            "source_locator": "normalized/resume.md:教育背景",
        }
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("hometown" in item for item in errors), errors)

    def test_unwritten_school_or_work_city_cannot_be_filled(self) -> None:
        data = sample_report_data()
        education = data["candidate_overview"]["education"][0]
        education["city"] = "乙市"
        education["city_source_status"] = "not_provided"
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("education[0].city" in item for item in errors), errors)

    def test_personal_information_cannot_enter_job_fit(self) -> None:
        data = sample_report_data()
        data["candidate_overview"]["fit_items"][0]["summary"] = "年龄合适,已婚,看起来会比较稳定。"
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("fit_items[0]" in item for item in errors), errors)

    def test_personal_information_cannot_be_a_resume_risk_or_rating_signal(self) -> None:
        data = sample_report_data()
        data["resume_risks"][0]["why_check"] = "候选人已婚,需要判断是否稳定。"
        data["interview_questions"][0]["bonus_signals"] = ["年龄较小,可能更能承压"]
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("resume_risks[0]" in item for item in errors), errors)
        self.assertTrue(any("interview_questions[0]" in item for item in errors), errors)

    def test_contact_and_identity_details_cannot_enter_interviewer_data(self) -> None:
        cases = {
            "email": "联系邮箱 candidate@example.com",
            "mobile": "联系电话 13812345678",
            "identity_number": "身份证号 110105199001011234",
        }
        for label, leaked_value in cases.items():
            with self.subTest(label=label):
                data = sample_report_data()
                data["candidate_overview"]["profile_summary"][0] = leaked_value
                errors, _ = validate_interviewer_report_data(data)
                self.assertTrue(any("contact or identity detail" in item for item in errors), errors)

    def test_logistics_questions_are_record_only(self) -> None:
        data = sample_report_data()
        data["interview_questions"][9]["kind"] = "logistics"
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("logistics" in item and "record-only" in item for item in errors), errors)

    def test_question_pool_requires_each_core_question_kind(self) -> None:
        data = sample_report_data()
        data["interview_questions"][1]["kind"] = "job_core"
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("work_sample" in item for item in errors), errors)

    def test_question_pool_must_contain_twelve_to_eighteen_questions(self) -> None:
        data = sample_report_data()
        data["interview_questions"] = data["interview_questions"][:11]
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("12" in item and "18" in item for item in errors), errors)

    def test_marital_status_question_is_required_and_record_only(self) -> None:
        data = sample_report_data()
        data["interview_questions"][-1] = rated_question(12)
        errors, _ = validate_interviewer_report_data(data)
        self.assertTrue(any("marital-status question" in item for item in errors), errors)


class CandidatePhotoPreparationTests(unittest.TestCase):
    def test_selected_image_is_converted_to_a_report_photo_object(self) -> None:
        temp_dir = tempfile.TemporaryDirectory()
        self.addCleanup(temp_dir.cleanup)
        root = Path(temp_dir.name)
        image_path = root / "selected-photo.png"
        input_dir = root / "input"
        input_dir.mkdir()
        resume_path = input_dir / "resume-original.pdf"
        image_path.write_bytes(PHOTO_BYTES)
        resume_path.write_bytes(b"%PDF-1.4\n%%EOF\n")
        completed = subprocess.run(
            [
                sys.executable,
                str(SCRIPTS_DIR / "prepare_candidate_photo.py"),
                "--input",
                str(image_path),
                "--resume-pdf",
                str(resume_path),
                "--page",
                "1",
                "--extraction-method",
                "embedded_image",
                "--image-index",
                "0",
            ],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        self.assertEqual(0, completed.returncode, completed.stderr)
        payload = json.loads(completed.stdout)
        self.assertEqual("included", payload["status"])
        self.assertEqual("image/png", payload["mime_type"])
        self.assertTrue(payload["data_uri"].startswith("data:image/png;base64,"))
        self.assertEqual("resume_pdf", payload["provenance"]["source_kind"])

    def test_non_image_input_is_rejected(self) -> None:
        temp_dir = tempfile.TemporaryDirectory()
        self.addCleanup(temp_dir.cleanup)
        root = Path(temp_dir.name)
        input_path = root / "not-an-image.bin"
        input_dir = root / "input"
        input_dir.mkdir()
        resume_path = input_dir / "resume-original.pdf"
        input_path.write_bytes(b"not an image")
        resume_path.write_bytes(b"%PDF-1.4\n%%EOF\n")
        completed = subprocess.run(
            [
                sys.executable,
                str(SCRIPTS_DIR / "prepare_candidate_photo.py"),
                "--input",
                str(input_path),
                "--resume-pdf",
                str(resume_path),
                "--page",
                "1",
                "--extraction-method",
                "embedded_image",
                "--image-index",
                "0",
            ],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        self.assertNotEqual(0, completed.returncode)
        self.assertIn("unsupported image", completed.stderr)


class RenderedReportTests(unittest.TestCase):
    def render(self, output_name: str) -> tuple[subprocess.CompletedProcess[str], Path, tempfile.TemporaryDirectory[str]]:
        temp_dir = tempfile.TemporaryDirectory()
        root = Path(temp_dir.name)
        data_path = root / "interviewer-report-data.json"
        data_path.write_text(json.dumps(sample_report_data(), ensure_ascii=False), encoding="utf-8")
        output = root / output_name
        completed = subprocess.run(
            [
                sys.executable,
                str(SCRIPTS_DIR / "render_candidate_report.py"),
                "--data",
                str(data_path),
                "--output",
                str(output),
            ],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        return completed, output, temp_dir

    def test_output_filename_must_contain_candidate_name(self) -> None:
        completed, _, temp_dir = self.render("候选人评估与面试报告.html")
        self.addCleanup(temp_dir.cleanup)
        self.assertNotEqual(0, completed.returncode)
        self.assertIn("测试候选人", completed.stderr)

    def test_rendered_report_has_name_three_modules_and_offline_interactions(self) -> None:
        completed, output, temp_dir = self.render("测试候选人-候选人评估与面试报告.html")
        self.addCleanup(temp_dir.cleanup)
        self.assertEqual(0, completed.returncode, completed.stderr)
        html = output.read_text(encoding="utf-8")
        self.assertIn("<title>测试候选人|候选人评估与面试报告</title>", html)
        self.assertIn("<h1 id=\"report-title\">测试候选人|候选人评估与面试报告</h1>", html)
        self.assertEqual(1, html.count('id="candidate-overview"'))
        self.assertEqual(1, html.count('id="resume-risks"'))
        self.assertEqual(1, html.count('id="interview-questions"'))
        self.assertIn("localStorage", html)
        self.assertIn("可能要问", html)
        self.assertIn("一定要问", html)
        self.assertIn("备选", html)
        self.assertNotIn("window.confirm", html)
        self.assertIn("再次点击确认清空", html)
        self.assertIn("面试记录已导出", html)

        checked = subprocess.run(
            [sys.executable, str(SCRIPTS_DIR / "validate_candidate_report.py"), str(output)],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        self.assertEqual(0, checked.returncode, checked.stdout + checked.stderr)

    def test_rendered_report_shows_embedded_photo_and_age_inference(self) -> None:
        temp_dir = tempfile.TemporaryDirectory()
        self.addCleanup(temp_dir.cleanup)
        root = Path(temp_dir.name)
        data = sample_report_data()
        data["candidate_overview"]["candidate_photo"] = included_candidate_photo()
        data["candidate_overview"]["personal_info"]["birth_information"] = not_provided()
        data["candidate_overview"]["personal_info"]["age"] = {
            "display": "未提供",
            "years": None,
            "approximate": False,
            "as_of": "2026-08-23",
            "normalized_birth": None,
            "precision": "not_provided",
            "source_status": "not_provided",
            "source_locator": None,
        }
        data["candidate_overview"]["timeline_age_estimate"] = estimated_from_undergraduate_start()
        data_path = root / "interviewer-report-data.json"
        output = root / "测试候选人-候选人评估与面试报告.html"
        data_path.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
        completed = subprocess.run(
            [
                sys.executable,
                str(SCRIPTS_DIR / "render_candidate_report.py"),
                "--data",
                str(data_path),
                "--output",
                str(output),
            ],
            text=True,
            capture_output=True,
            check=False,
        )
        self.assertEqual(0, completed.returncode, completed.stderr)
        rendered = output.read_text(encoding="utf-8")
        self.assertIn("candidate-photo", rendered)
        self.assertIn(PHOTO_DATA_URI, rendered)
        self.assertIn("履历推算年龄", rendered)

    def test_legacy_v10_html_without_photo_placeholder_still_validates(self) -> None:
        temp_dir = tempfile.TemporaryDirectory()
        self.addCleanup(temp_dir.cleanup)
        root = Path(temp_dir.name)
        data = sample_report_data()
        data["schema_version"] = "1.0.0"
        data["candidate_overview"].pop("candidate_photo")
        data["candidate_overview"].pop("timeline_age_estimate")
        data_path = root / "interviewer-report-data.json"
        output = root / "测试候选人-旧版候选人评估与面试报告.html"
        data_path.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
        rendered = subprocess.run(
            [
                sys.executable,
                str(SCRIPTS_DIR / "render_candidate_report.py"),
                "--data",
                str(data_path),
                "--output",
                str(output),
            ],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        self.assertEqual(0, rendered.returncode, rendered.stderr)
        html = output.read_text(encoding="utf-8")
        legacy_html = html.replace(
            '<div id="candidate-photo" class="candidate-photo" hidden aria-label="候选人简历照片"></div>',
            "",
        )
        self.assertNotEqual(html, legacy_html)
        output.write_text(legacy_html, encoding="utf-8")
        checked = subprocess.run(
            [sys.executable, str(SCRIPTS_DIR / "validate_candidate_report.py"), str(output)],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        self.assertEqual(0, checked.returncode, checked.stdout + checked.stderr)

    def test_v11_html_requires_photo_placeholder(self) -> None:
        completed, output, temp_dir = self.render("测试候选人-候选人评估与面试报告.html")
        self.addCleanup(temp_dir.cleanup)
        self.assertEqual(0, completed.returncode, completed.stderr)
        html = output.read_text(encoding="utf-8")
        output.write_text(
            html.replace(
                '<div id="candidate-photo" class="candidate-photo" hidden aria-label="候选人简历照片"></div>',
                "",
            ),
            encoding="utf-8",
        )
        checked = subprocess.run(
            [sys.executable, str(SCRIPTS_DIR / "validate_candidate_report.py"), str(output)],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        self.assertNotEqual(0, checked.returncode)
        self.assertIn("candidate-photo", checked.stdout)

    def test_report_validator_rejects_executable_data_uri_resources(self) -> None:
        completed, output, temp_dir = self.render("测试候选人-候选人评估与面试报告.html")
        self.addCleanup(temp_dir.cleanup)
        self.assertEqual(0, completed.returncode, completed.stderr)
        html = output.read_text(encoding="utf-8")
        output.write_text(
            html.replace(
                "</body>",
                '<script src="data:text/javascript,alert(1)"></script></body>',
            ),
            encoding="utf-8",
        )
        checked = subprocess.run(
            [sys.executable, str(SCRIPTS_DIR / "validate_candidate_report.py"), str(output)],
            text=True,
            capture_output=True,
            check=False,
            env=NO_BYTECODE_ENV,
        )
        self.assertNotEqual(0, checked.returncode)
        self.assertIn("forbidden data URI", checked.stdout)


if __name__ == "__main__":
    unittest.main()
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall