补充历史产物及整理资料

This commit is contained in:
Your Name committed 2026-10-30 20:07:59 +08:00
1 parent 58dfc8189f
commit 964e48acca
360 files changed
+818830

No files matched your search

@@ -0,0 +1 @@
{"execute": true, "verdict": "FAIL_EXACT_READBACK", "preparation_manifest": {"sha256": "pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp"}, "writer_receipts": [{"path": "D:\\\u62e9\u6821\\\u8fd0\u884c\u6682\u5b58\\2027_resolve_cn9bolsg\\receipt1.json", "sha256": "281cf1f3a2aa22e76bd9d042c903722d5edf9d78ebadb8ca6ae0245ab6dda9eb", "receipt": {"execute": true, "input_sha256": "1111111111111111111111111111111111111111111111111111111111111111", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch1", "conflict_rows": 1, "new_fact_rows": 0, "new_evidence_rows": 0, "new_source_ledger_rows": 0}}, {"path": "D:\\\u62e9\u6821\\\u8fd0\u884c\u6682\u5b58\\2027_resolve_cn9bolsg\\receipt2.json", "sha256": "3c2f0e64074ba8c31bcdd57b83cbbbdc9367d5ea4f41c54259b0d9e88360d651", "receipt": {"execute": true, "input_sha256": "2222222222222222222222222222222222222222222222222222222222222222", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch2", "conflict_rows": 0, "new_fact_rows": 1, "new_evidence_rows": 1, "new_source_ledger_rows": 1}}]}
@@ -0,0 +1 @@
{"execute": true, "input_sha256": "1111111111111111111111111111111111111111111111111111111111111111", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch1", "conflict_rows": 1, "new_fact_rows": 0, "new_evidence_rows": 0, "new_source_ledger_rows": 0}
@@ -0,0 +1 @@
{"execute": true, "input_sha256": "2222222222222222222222222222222222222222222222222222222222222222", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch2", "conflict_rows": 0, "new_fact_rows": 1, "new_evidence_rows": 1, "new_source_ledger_rows": 1}
@@ -0,0 +1 @@
{"execute": true, "verdict": "FAIL_EXACT_READBACK", "preparation_manifest": {"sha256": "pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp"}, "writer_receipts": [{"path": "D:\\\u62e9\u6821\\\u8fd0\u884c\u6682\u5b58\\2027_resolve_lut0cktp\\receipt1.json", "sha256": "281cf1f3a2aa22e76bd9d042c903722d5edf9d78ebadb8ca6ae0245ab6dda9eb", "receipt": {"execute": true, "input_sha256": "1111111111111111111111111111111111111111111111111111111111111111", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch1", "conflict_rows": 1, "new_fact_rows": 0, "new_evidence_rows": 0, "new_source_ledger_rows": 0}}, {"path": "D:\\\u62e9\u6821\\\u8fd0\u884c\u6682\u5b58\\2027_resolve_lut0cktp\\receipt2.json", "sha256": "3c2f0e64074ba8c31bcdd57b83cbbbdc9367d5ea4f41c54259b0d9e88360d651", "receipt": {"execute": true, "input_sha256": "2222222222222222222222222222222222222222222222222222222222222222", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch2", "conflict_rows": 0, "new_fact_rows": 1, "new_evidence_rows": 1, "new_source_ledger_rows": 1}}]}
@@ -0,0 +1 @@
{"execute": true, "input_sha256": "1111111111111111111111111111111111111111111111111111111111111111", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch1", "conflict_rows": 1, "new_fact_rows": 0, "new_evidence_rows": 0, "new_source_ledger_rows": 0}
@@ -0,0 +1 @@
{"execute": true, "input_sha256": "2222222222222222222222222222222222222222222222222222222222222222", "verdict": "PASS", "errors": [], "production_write": true, "batch_id": "batch2", "conflict_rows": 0, "new_fact_rows": 1, "new_evidence_rows": 1, "new_source_ledger_rows": 1}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,292 @@
from __future__ import annotations
import csv
import datetime as dt
import json
from collections import Counter
from pathlib import Path
V32_REPORT = Path(
r"D:\择校\运行暂存\reports\R134_S1_annual_data_type_targets_v32_20261015\annual_data_type_targets_20261010_R134_v32_20261015.json"
)
V32_SUMMARY = Path(
r"D:\择校\运行暂存\reports\R134_S1_annual_data_type_targets_v32_20261015\annual_data_type_targets_20261010_R134_v32_20261015.csv"
)
MATRIX = Path(r"D:\择校\运行暂存\reports\R134_registered_type_resolution_matrix_20261015.json")
OUT_DIR = Path(
r"D:\择校\运行暂存\reports\R134_S1_annual_data_type_contract_boundary_audit_20261015"
)
REPORT = OUT_DIR / "report.json"
TYPE_DETAIL = OUT_DIR / "type_contract_boundary.jsonl"
CELL_DETAIL = OUT_DIR / "cell_contract_boundary.jsonl"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_annual_data_type_contract_boundary_audit_20261015.log")
def text(value):
return "" if value is None else str(value).strip()
def integer(value):
try:
return int(value or 0)
except (TypeError, ValueError):
return 0
def load_json(path):
return json.loads(path.read_text(encoding="utf-8"))
def load_csv(path):
with path.open("r", encoding="utf-8-sig", newline="") as stream:
return list(csv.DictReader(stream))
def candidate_fields(source_fields):
return sorted(
{
text(item.get("candidate_field_name"))
for item in source_fields
if text(item.get("candidate_field_name"))
}
)
def boundary_class(type_id, rule_fields, source_fields, production_verified):
if production_verified:
return "production_contract_verified"
source_candidates = set(candidate_fields(source_fields))
rule_set = set(rule_fields)
if source_fields and rule_set and source_candidates & rule_set:
return "source_candidate_and_rule_overlap_but_not_production_verified"
if source_fields and rule_set:
return "source_candidate_rule_field_mismatch_not_production_verified"
if source_fields:
return "source_candidate_only_not_production_verified"
if rule_fields:
return "rule_only_without_source_contract"
return "no_rule_or_source_candidate"
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
v32 = load_json(V32_REPORT)
matrix = load_json(MATRIX)
summary_rows = load_csv(V32_SUMMARY)
matrix_rows = {text(row.get("data_type_id")): row for row in matrix.get("rows", [])}
field_rules = v32.get("coverage", {}).get("field_rules", {})
type_ids = sorted(matrix_rows)
type_rows = []
cell_rows = []
errors = []
for type_id in type_ids:
matrix_row = matrix_rows[type_id]
rule_entries = field_rules.get(type_id, [])
rule_fields = sorted(
{
text(entry.get("field"))
for entry in rule_entries
if text(entry.get("field"))
}
)
source_fields = matrix_row.get("source_contract_fields") or []
resolution = matrix_row.get("resolution") or {}
production_verified = bool(resolution.get("production_field_verified"))
source_unit_statuses = sorted(
{
text(item.get("unit_evidence_status"))
for item in source_fields
if text(item.get("unit_evidence_status"))
}
)
source_key_statuses = sorted(
{
text(item.get("production_business_key_status"))
for item in source_fields
if text(item.get("production_business_key_status"))
}
)
cells = [row for row in summary_rows if text(row.get("data_type_id")) == type_id]
if len(cells) != 6:
errors.append({"data_type_id": type_id, "error": f"expected_6_cells_got_{len(cells)}"})
stats = {
"target_key_count": sum(integer(row.get("target_key_count")) for row in cells),
"covered_count": sum(integer(row.get("covered_count")) for row in cells),
"true_gap_count": sum(integer(row.get("true_gap_count")) for row in cells),
"conflict_count": sum(integer(row.get("conflict_count")) for row in cells),
"unknown_target_count": sum(integer(row.get("unknown_target_count")) for row in cells),
"unmatched_count": sum(integer(row.get("unmatched_count")) for row in cells),
"unmatched_source_fact_count": sum(integer(row.get("unmatched_source_fact_count")) for row in cells),
}
boundary = boundary_class(type_id, rule_fields, source_fields, production_verified)
type_record = {
"data_type_id": type_id,
"label": matrix_row.get("label"),
"target_grain": matrix_row.get("target_grain"),
"target_business_key": matrix_row.get("target_business_key") or [],
"year_cell_count": len(cells),
"coverage_rule_fields": rule_fields,
"coverage_rule_entries": rule_entries,
"source_contract_fields": source_fields,
"source_candidate_field_names": candidate_fields(source_fields),
"source_unit_evidence_statuses": source_unit_statuses,
"source_production_key_statuses": source_key_statuses,
"resolution_status": text(resolution.get("status")),
"production_field_verified": production_verified,
"production_key_json_verified": all(
bool(item.get("production_key_json_verified")) for item in source_fields
)
if source_fields
else False,
"boundary_class": boundary,
"statistics": stats,
"semantic_aliases_unresolved": matrix_row.get("semantic_aliases_unresolved") or [],
"coverage_statuses": sorted(
{text(row.get("coverage_status")) for row in cells if text(row.get("coverage_status"))}
),
"coverage_mapping_statuses": sorted(
{
text(row.get("coverage_mapping_status"))
for row in cells
if text(row.get("coverage_mapping_status"))
}
),
"candidate_reviewed": False,
"accepted": False,
"stage_written": False,
"production_write": False,
}
type_rows.append(type_record)
for cell in cells:
cell_rows.append(
{
"year": text(cell.get("year")),
"data_type_id": type_id,
"target_grain": matrix_row.get("target_grain"),
"target_key_count": integer(cell.get("target_key_count")),
"covered_count": integer(cell.get("covered_count")),
"true_gap_count": integer(cell.get("true_gap_count")),
"conflict_count": integer(cell.get("conflict_count")),
"unknown_target_count": integer(cell.get("unknown_target_count")),
"unmatched_count": integer(cell.get("unmatched_count")),
"unmatched_source_fact_count": integer(cell.get("unmatched_source_fact_count")),
"coverage_status": text(cell.get("coverage_status")),
"coverage_mapping_status": text(cell.get("coverage_mapping_status")),
"boundary_class": boundary,
"production_field_verified": production_verified,
"production_key_json_verified": type_record["production_key_json_verified"],
"candidate_reviewed": False,
"accepted": False,
"stage_written": False,
"production_write": False,
}
)
TYPE_DETAIL.write_text(
"\n".join(json.dumps(row, ensure_ascii=False, sort_keys=True) for row in type_rows) + "\n",
encoding="utf-8",
)
CELL_DETAIL.write_text(
"\n".join(json.dumps(row, ensure_ascii=False, sort_keys=True) for row in cell_rows) + "\n",
encoding="utf-8",
)
boundary_counts = Counter(row["boundary_class"] for row in type_rows)
checks = {
"matrix_type_count_expected_20": len(type_rows) == 20,
"summary_cell_count_expected_120": len(cell_rows) == 120,
"unique_year_type_cells": len({(row["year"], row["data_type_id"]) for row in cell_rows}) == 120,
"all_types_have_six_cells": all(row["year_cell_count"] == 6 for row in type_rows),
"all_coverage_counts_nonnegative": all(
value >= 0
for row in cell_rows
for key, value in row.items()
if key.endswith("_count") and isinstance(value, int)
),
"all_production_field_verification_false": all(
not row["production_field_verified"] for row in type_rows
),
"all_source_production_keys_unverified": all(
not row["production_key_json_verified"] for row in type_rows
),
"all_candidate_rows_unpromoted": all(
not row["candidate_reviewed"] and not row["accepted"] for row in type_rows
)
and all(not row["candidate_reviewed"] and not row["accepted"] for row in cell_rows),
"no_stage_written": all(not row["stage_written"] for row in type_rows)
and all(not row["stage_written"] for row in cell_rows),
"production_write_false": all(not row["production_write"] for row in type_rows)
and all(not row["production_write"] for row in cell_rows),
"no_errors": not errors,
}
report = {
"schema": "r134_s1_annual_data_type_contract_boundary_audit.v1",
"status": "PARTIAL_ANNUAL_DATA_TYPE_CONTRACT_BOUNDARY",
"verdict": "PASS_READONLY_RULE_VS_CONTRACT_BOUNDARY",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"registered_type_count": len(type_rows),
"year_data_type_cell_count": len(cell_rows),
"target_key_detail_count": integer(v32.get("detail_target_key_count")),
"boundary_class_counts": dict(sorted(boundary_counts.items())),
"source_candidate_type_count": sum(bool(row["source_contract_fields"]) for row in type_rows),
"rule_type_count": sum(bool(row["coverage_rule_fields"]) for row in type_rows),
"unit_production_verified_type_count": sum(
any(status == "production_verified" for status in row["source_unit_evidence_statuses"])
for row in type_rows
),
"production_key_verified_type_count": sum(row["production_key_json_verified"] for row in type_rows),
},
"checks": checks | {"all_checks_pass": all(checks.values())},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"coverage_promoted_to_product": False,
},
"limitations": [
"This audit compares v32's explicit coverage rules with the registered-type resolution matrix; it does not certify that a rule field is the authoritative production field.",
"Coverage counts remain lower-bound/business-key-rule results; unknown target and unmatched source-fact layers are not converted into national denominators.",
"All 20 production field/key mappings and source units remain unverified; no stage, registry or writer action was performed.",
],
"errors": errors,
"output_artifacts": {
"report": str(REPORT),
"type_detail": str(TYPE_DETAIL),
"cell_detail": str(CELL_DETAIL),
"log": str(LOG),
},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"registered_type_count={len(type_rows)}",
f"year_data_type_cell_count={len(cell_rows)}",
f"target_key_detail_count={report['scope']['target_key_detail_count']}",
f"boundary_class_counts={json.dumps(dict(sorted(boundary_counts.items())), ensure_ascii=False, sort_keys=True)}",
f"unit_production_verified_type_count={report['scope']['unit_production_verified_type_count']}",
f"production_key_verified_type_count={report['scope']['production_key_verified_type_count']}",
"coverage_promoted_to_product=false",
"production_database_written=false",
"production_writer_invoked=false",
f"all_checks_pass={report['checks']['all_checks_pass']}",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,310 @@
"""Build a read-only CHSI 2027 pagination candidate queue.
The input is the persisted unit-level page-1 summary. This command does not
contact CHSI, alter the page-1 checkpoint, write a stage, or call the writer.
It turns the observed ``total_pages`` metadata into independently traceable
unit/page tasks and records the unresolved request semantics in the manifest.
"""
from __future__ import annotations
import argparse
import csv
import hashlib
import json
from collections import Counter
from datetime import datetime, timezone
from pathlib import Path
from typing import Any, Iterable
ENDPOINT = "https://yz.chsi.com.cn/zsml/rs/dwzys.do"
ADMISSION_YEAR = 2027
EXAM_YEAR = 2026
REQUIRED_COLUMNS = {
"admission_year",
"exam_year",
"unit_code",
"school_name",
"chsi_sch_id",
"status",
"reported_total_count",
"valid_visible_row_count",
"rows_not_retrieved",
"total_pages",
"page_size",
}
def sha256_file(path: Path) -> str:
digest = hashlib.sha256()
with path.open("rb") as stream:
for block in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(block)
return digest.hexdigest()
def file_descriptor(path: Path) -> dict[str, Any]:
return {"path": str(path), "bytes": path.stat().st_size, "sha256": sha256_file(path)}
def parse_int(value: str, field: str, line_number: int) -> int:
text = (value or "").strip()
if not text:
raise ValueError(f"line {line_number}: {field} is empty")
try:
result = int(text)
except ValueError as exc:
raise ValueError(f"line {line_number}: {field} is not an integer: {value!r}") from exc
if result < 0:
raise ValueError(f"line {line_number}: {field} is negative: {value!r}")
return result
def load_school_counts(path: Path) -> list[dict[str, Any]]:
rows: list[dict[str, Any]] = []
seen_codes: set[str] = set()
with path.open("r", encoding="utf-8-sig", newline="") as stream:
reader = csv.DictReader(stream)
columns = set(reader.fieldnames or [])
missing = sorted(REQUIRED_COLUMNS - columns)
if missing:
raise ValueError(f"input is missing columns: {missing}")
for line_number, raw in enumerate(reader, start=2):
unit_code = (raw.get("unit_code") or "").strip()
school_name = (raw.get("school_name") or "").strip()
chsi_sch_id = (raw.get("chsi_sch_id") or "").strip()
if not unit_code or not school_name or not chsi_sch_id:
raise ValueError(f"line {line_number}: unit identity is incomplete")
if unit_code in seen_codes:
raise ValueError(f"line {line_number}: duplicate unit_code {unit_code}")
seen_codes.add(unit_code)
admission_year = parse_int(raw["admission_year"], "admission_year", line_number)
exam_year = parse_int(raw["exam_year"], "exam_year", line_number)
reported_total_count = parse_int(
raw["reported_total_count"], "reported_total_count", line_number
)
visible_count = parse_int(
raw["valid_visible_row_count"], "valid_visible_row_count", line_number
)
remaining = parse_int(raw["rows_not_retrieved"], "rows_not_retrieved", line_number)
total_pages = parse_int(raw["total_pages"], "total_pages", line_number)
page_size = parse_int(raw["page_size"], "page_size", line_number)
if admission_year != ADMISSION_YEAR or exam_year != EXAM_YEAR:
raise ValueError(f"line {line_number}: unexpected year pair")
if visible_count + remaining != reported_total_count:
raise ValueError(
f"line {line_number}: visible + remaining != reported total for {unit_code}"
)
rows.append(
{
"admission_year": admission_year,
"exam_year": exam_year,
"unit_code": unit_code,
"school_name": school_name,
"chsi_sch_id": chsi_sch_id,
"status": (raw.get("status") or "").strip(),
"reported_total_count": reported_total_count,
"valid_visible_row_count": visible_count,
"rows_not_retrieved": remaining,
"total_pages": total_pages,
"page_size": page_size,
}
)
if not rows:
raise ValueError("input has no rows")
return sorted(rows, key=lambda row: row["unit_code"])
def build_tasks(rows: Iterable[dict[str, Any]]) -> list[dict[str, Any]]:
tasks: list[dict[str, Any]] = []
for row in rows:
if row["status"] != "public_page_partial":
continue
if row["rows_not_retrieved"] <= 0:
raise ValueError(f"partial unit has no remaining rows: {row['unit_code']}")
if row["total_pages"] <= 1 or row["page_size"] <= 0:
raise ValueError(f"partial unit has invalid pagination metadata: {row['unit_code']}")
for page_no in range(2, row["total_pages"] + 1):
tasks.append(
{
"schema": "chsi_2027_pagination_task.v1",
"admission_year": row["admission_year"],
"exam_year": row["exam_year"],
"unit_code": row["unit_code"],
"school_name": row["school_name"],
"chsi_sch_id": row["chsi_sch_id"],
"page_no": page_no,
"total_pages_observed": row["total_pages"],
"reported_total_count": row["reported_total_count"],
"page_size_observed": row["page_size"],
"page1_visible_row_count": row["valid_visible_row_count"],
"rows_not_retrieved_from_page1": row["rows_not_retrieved"],
"task_id": f"2027:{row['unit_code']}:{page_no}",
"request_page_parameter": "curPage",
"request_page_value": page_no,
"request_semantics_status": "NOT_VERIFIED",
}
)
task_ids = [task["task_id"] for task in tasks]
if len(task_ids) != len(set(task_ids)):
raise ValueError("pagination task ids are not unique")
return tasks
def _json_line(value: dict[str, Any]) -> bytes:
return (json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")) + "\n").encode(
"utf-8"
)
def write_jsonl(path: Path, rows: Iterable[dict[str, Any]]) -> str:
with path.open("xb") as stream:
for row in rows:
stream.write(_json_line(row))
stream.flush()
return sha256_file(path)
def build_manifest(
*,
input_path: Path,
source_report_path: Path | None,
rows: list[dict[str, Any]],
tasks: list[dict[str, Any]],
queue_path: Path,
queue_sha256: str,
) -> dict[str, Any]:
status_counts = Counter(row["status"] for row in rows)
total_reported = sum(row["reported_total_count"] for row in rows)
total_visible = sum(row["valid_visible_row_count"] for row in rows)
total_remaining = sum(row["rows_not_retrieved"] for row in rows)
partial_rows = [row for row in rows if row["status"] == "public_page_partial"]
expected_tasks = sum(max(0, row["total_pages"] - 1) for row in partial_rows)
task_page_sizes = sorted({task["page_size_observed"] for task in tasks})
checks = {
"input_row_count_936": len(rows) == 936,
"unique_unit_code_count_936": len({row["unit_code"] for row in rows}) == 936,
"status_counts_343_588_5": dict(status_counts)
== {"empty_api_result": 5, "public_page_complete": 343, "public_page_partial": 588},
"reported_total_count_sum_38278": total_reported == 38278,
"visible_row_count_sum_7368": total_visible == 7368,
"remaining_row_count_sum_30910": total_remaining == 30910,
"task_count_matches_total_pages": len(tasks) == expected_tasks == 3357,
"task_page_sizes_observed_only": task_page_sizes == [10],
"no_complete_or_empty_tasks": all(
row["status"] == "public_page_partial" for row in partial_rows
),
"task_ranges_valid": all(
2 <= task["page_no"] <= task["total_pages_observed"] for task in tasks
),
}
return {
"schema": "r134_chsi_2027_pagination_queue_manifest.v1",
"status": "PARTIAL",
"verdict": "PASS_READONLY_PAGINATION_QUEUE",
"generated_at_utc": datetime.now(timezone.utc).isoformat(),
"source": {
"school_counts": file_descriptor(input_path),
"page1_report": file_descriptor(source_report_path)
if source_report_path is not None
else None,
"endpoint": ENDPOINT,
"admission_year": ADMISSION_YEAR,
"exam_year": EXAM_YEAR,
},
"scope": {
"candidate_unit_count": len(rows),
"status_counts": dict(sorted(status_counts.items())),
"reported_total_count_sum": total_reported,
"page1_visible_row_count_sum": total_visible,
"rows_not_retrieved_from_page1": total_remaining,
"partial_unit_count": len(partial_rows),
"candidate_page_task_count": len(tasks),
"task_page_size_observed_values": task_page_sizes,
"queue_path": str(queue_path),
"queue_sha256": queue_sha256,
},
"request_boundary": {
"request_page_parameter": "curPage",
"request_page_size_semantics": "NOT_VERIFIED",
"request_start_semantics": "NOT_VERIFIED",
"public_access_for_all_pages": "NOT_VERIFIED",
"known_login_restricted_sample": "10002 page 2; retained as external evidence, not retried here",
},
"checks": checks,
"all_checks_pass": all(checks.values()),
"operations": {
"network_requests": 0,
"page1_checkpoint_read": False,
"page1_checkpoint_write": False,
"stage_write": False,
"production_database_read": False,
"production_database_write": False,
"registry_write": False,
"writer_called": False,
},
"limitations": [
"This is a candidate queue derived from the persisted unit summary, not a fetched page result set.",
"The 936-unit roster is a current CHSI candidate roster, not the national 2027 denominator.",
"The 3357 tasks and 30910 rows remain unverified until page-level access, semantics, and closure are tested.",
],
}
def write_manifest(path: Path, manifest: dict[str, Any]) -> None:
with path.open("xb") as stream:
stream.write((json.dumps(manifest, ensure_ascii=False, indent=2) + "\n").encode("utf-8"))
stream.flush()
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--school-counts", type=Path, required=True)
parser.add_argument("--source-report", type=Path)
parser.add_argument("--output-dir", type=Path, required=True)
args = parser.parse_args()
input_path = args.school_counts.resolve()
source_report_path = args.source_report.resolve() if args.source_report else None
if not input_path.is_file():
raise FileNotFoundError(input_path)
if source_report_path is not None and not source_report_path.is_file():
raise FileNotFoundError(source_report_path)
args.output_dir.mkdir(parents=True, exist_ok=True)
queue_path = args.output_dir / "pagination_queue.jsonl"
manifest_path = args.output_dir / "manifest.json"
if queue_path.exists() or manifest_path.exists():
raise FileExistsError("output directory already contains queue outputs")
rows = load_school_counts(input_path)
tasks = build_tasks(rows)
queue_sha256 = write_jsonl(queue_path, tasks)
manifest = build_manifest(
input_path=input_path,
source_report_path=source_report_path,
rows=rows,
tasks=tasks,
queue_path=queue_path,
queue_sha256=queue_sha256,
)
if not manifest["all_checks_pass"]:
raise RuntimeError(f"queue checks failed: {manifest['checks']}")
write_manifest(manifest_path, manifest)
print(
json.dumps(
{
"status": manifest["status"],
"verdict": manifest["verdict"],
"candidate_unit_count": manifest["scope"]["candidate_unit_count"],
"candidate_page_task_count": manifest["scope"]["candidate_page_task_count"],
"rows_not_retrieved_from_page1": manifest["scope"]["rows_not_retrieved_from_page1"],
"queue": str(queue_path),
"manifest": str(manifest_path),
},
ensure_ascii=False,
)
)
return 0
if __name__ == "__main__":
raise SystemExit(main())
@@ -0,0 +1,326 @@
from __future__ import annotations
import datetime as dt
import hashlib
import json
import re
import sys
from collections import Counter
from pathlib import Path
WORKSPACE_ROOT = Path(r"D:\择校\脚本\工作区\考研择校")
if str(WORKSPACE_ROOT) not in sys.path:
sys.path.insert(0, str(WORKSPACE_ROOT))
from scripts.audit_kaoyan365_attachment_yield_20261010 import ( # noqa: E402
CATALOG_RE,
COLLEGE_CATALOG_HEADING_RE,
COLLEGE_NAME_LINE_RE,
COLLEGE_NAME_CONTINUATION_RE,
NUMBERED_COLLEGE_PREFIX_RE,
iter_pdf_pages,
)
DETAILS = Path(
r"D:\择校\运行暂存\reports\R134_S1_college_residual_verified_full_parse_audit_20261015\full_parse.jsonl"
)
FETCH_DIR = Path(r"D:\择校\运行暂存\batches\R134_S1_college_residual_official_fetch_20261015")
OUT_DIR = Path(
r"D:\择校\运行暂存\reports\R134_S1_college_residual_candidate_context_audit_20261015"
)
REPORT = OUT_DIR / "report.json"
DETAIL = OUT_DIR / "candidate_context.jsonl"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_candidate_context_audit_20261015.log")
def text(value):
return "" if value is None else str(value).strip()
def load_jsonl(path):
with path.open("r", encoding="utf-8") as stream:
return [json.loads(line) for line in stream if line.strip()]
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def normalized_lines(lines):
return [re.sub(r"\s+", " ", text(line)) for line in lines]
def page_context(lines, locator):
line_number = int(locator.get("line_number") or 0)
if line_number < 1 or line_number > len(lines):
return {
"locator_valid": False,
"page_line_count": len(lines),
"line_number": line_number,
"nearby_lines": [],
"same_page_heading_signals": [],
}
clean_lines = normalized_lines(lines)
index = line_number - 1
start = max(0, index - 4)
end = min(len(clean_lines), index + 5)
nearby = [
{"line_number": line_index + 1, "relative": line_index - index, "text": clean_lines[line_index]}
for line_index in range(start, end)
if clean_lines[line_index]
]
signals = []
for line_index in range(0, index + 1):
line = clean_lines[line_index]
if not line:
continue
if COLLEGE_CATALOG_HEADING_RE.match(line) or COLLEGE_NAME_LINE_RE.fullmatch(line):
signals.append({"line_number": line_index + 1, "text": line})
if (
line_index + 1 < len(clean_lines)
and line_index + 1 <= index
and NUMBERED_COLLEGE_PREFIX_RE.match(line)
and COLLEGE_NAME_CONTINUATION_RE.match(clean_lines[line_index + 1])
):
combined = f"{line.rstrip()}{clean_lines[line_index + 1].lstrip()}"
if COLLEGE_NAME_LINE_RE.fullmatch(combined):
signals.append(
{
"line_number": line_index + 1,
"continuation_line_number": line_index + 2,
"text": combined,
}
)
catalog_tokens = [
{"line_number": line_index + 1, "text": clean_lines[line_index]}
for line_index in range(max(0, index - 8), min(len(clean_lines), index + 2))
if clean_lines[line_index] and CATALOG_RE.search(clean_lines[line_index])
]
return {
"locator_valid": True,
"page_line_count": len(clean_lines),
"line_number": line_number,
"nearby_lines": nearby,
"same_page_heading_signals": signals[-4:],
"nearby_catalog_tokens": catalog_tokens,
}
def inspect_record(record):
artifact = Path(text(record.get("artifact_path"))).resolve(strict=False)
scope_values = [
text(value)
for value in (record.get("parsed") or {}).get("college_scope_candidate_values", [])
if text(value)
]
locators = [
locator
for locator in (record.get("parsed") or {}).get("target_hit_locators", [])
if text(locator.get("college_candidate")) in scope_values
]
record_errors = []
try:
artifact.relative_to(FETCH_DIR.resolve())
except ValueError:
record_errors.append("artifact_outside_fetch_dir")
if not artifact.is_file():
record_errors.append("artifact_missing")
return {
"url": text(record.get("url")),
"years": record.get("years") or [],
"target_school_names": record.get("target_school_names") or [],
"target_major_codes": record.get("target_major_codes") or [],
"scope_candidate_values": scope_values,
"file_signature": text(record.get("file_signature")),
"artifact_path": str(artifact),
"actual_sha256": text(record.get("actual_sha256")).lower(),
"artifact_sha256_now": "",
"artifact_sha_match": False,
"artifact_stable_again": False,
"page_count": 0,
"candidate_locators": [],
"context_errors": record_errors,
"source_context_status": "artifact_unavailable",
"candidate_reviewed": False,
"accepted": False,
"stage_written": False,
"production_write": False,
}
before = sha256_file(artifact)
page_map = {}
page_count = 0
try:
for page_index, total_pages, lines in iter_pdf_pages(artifact):
page_count = total_pages
page_map[page_index + 1] = lines
except Exception as exc:
record_errors.append(f"pdf_read_error:{type(exc).__name__}:{exc}")
candidate_contexts = []
for locator in locators:
locator_page = text(locator.get("locator"))
page_number = int(locator_page.split(":", 1)[1]) if locator_page.startswith("page:") else 0
context = page_context(page_map.get(page_number, []), locator)
candidate_contexts.append(
{
"candidate": text(locator.get("college_candidate")),
"code": text(locator.get("code")),
"major_name_candidate": text(locator.get("major_name_candidate")),
"locator": locator_page,
"line_number": locator.get("line_number"),
"context": context,
}
)
if not context.get("locator_valid"):
record_errors.append(f"invalid_locator:{locator_page}:{locator.get('line_number')}")
after = sha256_file(artifact)
expected = {
text(value).lower()
for value in record.get("expected_sha256_candidates", [])
if text(value)
}
heading_context_count = sum(
bool(item["context"].get("same_page_heading_signals"))
for item in candidate_contexts
)
source_context_status = (
"explicit_same_page_heading_observed"
if candidate_contexts and heading_context_count == len(candidate_contexts)
else "candidate_locators_bound_but_heading_context_incomplete"
if candidate_contexts
else "no_scope_candidate_locator"
)
return {
"url": text(record.get("url")),
"years": record.get("years") or [],
"source_types": record.get("source_types") or [],
"target_school_names": record.get("target_school_names") or [],
"target_major_codes": record.get("target_major_codes") or [],
"scope_candidate_values": scope_values,
"file_signature": text(record.get("file_signature")),
"artifact_path": str(artifact),
"actual_sha256": text(record.get("actual_sha256")).lower(),
"artifact_sha256_now": after,
"artifact_sha_match": after in expected,
"artifact_stable_again": before == after and after == text(record.get("actual_sha256")).lower(),
"page_count": page_count,
"candidate_locators": candidate_contexts,
"same_page_heading_locator_count": heading_context_count,
"context_errors": record_errors,
"source_context_status": source_context_status,
"candidate_reviewed": False,
"accepted": False,
"stage_written": False,
"production_write": False,
}
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
records = [
record
for record in load_jsonl(DETAILS)
if (record.get("parsed") or {}).get("college_scope_candidate_values")
]
inspected = [inspect_record(record) for record in records]
DETAIL.write_text(
"\n".join(json.dumps(record, ensure_ascii=False, sort_keys=True) for record in inspected) + "\n",
encoding="utf-8",
)
context_status_counts = Counter(record["source_context_status"] for record in inspected)
checks = {
"input_scope_jobs_expected_19": len(inspected) == 19,
"all_files_are_pdf": all(record["file_signature"] == "pdf" for record in inspected),
"all_artifacts_sha_match_expected": all(record["artifact_sha_match"] for record in inspected),
"all_artifacts_stable_again": all(record["artifact_stable_again"] for record in inspected),
"all_candidate_locators_valid": all(
all(item["context"].get("locator_valid") for item in record["candidate_locators"])
for record in inspected
),
"all_candidate_locators_have_context": all(
bool(record["candidate_locators"]) for record in inspected
),
"all_records_have_no_context_errors": all(not record["context_errors"] for record in inspected),
"no_candidate_promoted": all(
not record["candidate_reviewed"] and not record["accepted"] for record in inspected
),
"no_stage_written": all(not record["stage_written"] for record in inspected),
"production_write_false": all(not record["production_write"] for record in inspected),
}
report = {
"schema": "r134_s1_college_residual_candidate_context_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_CANDIDATE_CONTEXT_AUDIT",
"verdict": "PASS_READONLY_SCOPE_CONTEXT_WITH_CANDIDATES_UNPROMOTED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"college_scope_candidate_jobs": len(inspected),
"candidate_locator_rows": sum(len(record["candidate_locators"]) for record in inspected),
"same_page_heading_locator_rows": sum(record.get("same_page_heading_locator_count", 0) for record in inspected),
"context_status_counts": dict(sorted(context_status_counts.items())),
"jobs_by_school": dict(
sorted(
Counter(
school
for record in inspected
for school in record.get("target_school_names", [])
).items()
)
),
},
"checks": checks | {"all_checks_pass": all(checks.values())},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"Same-page heading and nearby text are source-context observations; they do not establish the production college key or final row-level scope.",
"This audit covers only the 19 exact-hash jobs with parser college-scope candidates; the 2 school-header jobs and 37 no-candidate jobs remain in the parent classification queue.",
"No candidate stage, fact/evidence promotion, registry mutation or writer call was performed.",
],
"output_artifacts": {
"report": str(REPORT),
"detail": str(DETAIL),
"log": str(LOG),
},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"college_scope_candidate_jobs={len(inspected)}",
f"candidate_locator_rows={report['scope']['candidate_locator_rows']}",
f"same_page_heading_locator_rows={report['scope']['same_page_heading_locator_rows']}",
f"context_status_counts={json.dumps(dict(sorted(context_status_counts.items())), ensure_ascii=False, sort_keys=True)}",
"candidate_reviewed=false",
"accepted_source_rows=0",
"stage_rows=0",
"production_database_written=false",
"production_writer_invoked=false",
f"all_checks_pass={report['checks']['all_checks_pass']}",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,266 @@
from __future__ import annotations
import datetime as dt
import json
import sys
from collections import Counter, defaultdict
from pathlib import Path
HELPER_DIR = Path(r"D:\择校\运行暂存\scripts")
if str(HELPER_DIR) not in sys.path:
sys.path.insert(0, str(HELPER_DIR))
import r134_s1_college_residual_verified_sample_parse_audit_20261015 as sample # noqa: E402
QUEUE = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_queue_20261015\residual_queue.jsonl")
CONTEXT_DETAIL = Path(
r"D:\择校\运行暂存\reports\R134_S1_college_residual_candidate_context_audit_20261015\candidate_context.jsonl"
)
OUT_DIR = Path(
r"D:\择校\运行暂存\reports\R134_S1_college_residual_candidate_queue_binding_audit_20261015"
)
REPORT = OUT_DIR / "report.json"
DETAIL = OUT_DIR / "candidate_queue_binding.jsonl"
GROUP_SUMMARY = OUT_DIR / "candidate_group_summary.json"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_candidate_queue_binding_audit_20261015.log")
def text(value):
return "" if value is None else str(value).strip()
def load_jsonl(path):
with path.open("r", encoding="utf-8") as stream:
return [json.loads(line) for line in stream if line.strip()]
def source_urls(row):
raw = text((row.get("source") or {}).get("source_url"))
return [piece.strip() for piece in raw.split("|") if piece.strip()]
def locator_json(row):
raw = text((row.get("locator") or {}).get("source_locators"))
if not raw:
return []
result = []
for piece in raw.split("|"):
try:
result.append(json.loads(piece))
except json.JSONDecodeError:
result.append({"raw": piece})
return result
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
queue_rows = load_jsonl(QUEUE)
context_rows = load_jsonl(CONTEXT_DETAIL)
queue_by_url_code = defaultdict(list)
for row in queue_rows:
code = text((row.get("base_key") or {}).get("major_code"))
for url in source_urls(row):
try:
queue_by_url_code[(sample.normalize_url(url), code)].append(row)
except ValueError:
continue
binding_rows = []
errors = []
for context_row in context_rows:
url = text(context_row.get("url"))
try:
normalized_url = sample.normalize_url(url)
except ValueError as exc:
errors.append({"url": url, "error": f"invalid_context_url:{exc}"})
normalized_url = ""
context_candidate_values = set(
text(value) for value in context_row.get("scope_candidate_values", []) if text(value)
)
for locator in context_row.get("candidate_locators", []):
candidate = text(locator.get("candidate"))
code = text(locator.get("code"))
matches = queue_by_url_code.get((normalized_url, code), [])
target_school_names = set(text(value) for value in context_row.get("target_school_names", []) if text(value))
target_years = set(text(value) for value in context_row.get("years", []) if text(value))
row_summaries = []
for row in matches:
base_key = row.get("base_key") or {}
row_summaries.append(
{
"residual_queue_id": text(row.get("residual_queue_id")),
"input_line": row.get("input_line"),
"year": text(base_key.get("year")),
"school_code": text(base_key.get("school_code")),
"school": text(row.get("school")),
"major_code": text(base_key.get("major_code")),
"major_name": text(row.get("major_name")),
"college": text(row.get("college")),
"status": text(row.get("status")),
"source_type": text((row.get("source") or {}).get("source_type")),
"source_locator_count": len(locator_json(row)),
}
)
binding_rows.append(
{
"url": url,
"normalized_url": normalized_url,
"years": context_row.get("years") or [],
"target_school_names": context_row.get("target_school_names") or [],
"candidate": candidate,
"candidate_value_declared_by_parser": candidate in context_candidate_values,
"code": code,
"major_name_candidate": text(locator.get("major_name_candidate")),
"source_locator": text(locator.get("locator")),
"page_line_number": locator.get("line_number"),
"same_page_heading_observed": bool(
(locator.get("context") or {}).get("same_page_heading_signals")
),
"queue_match_count": len(row_summaries),
"queue_rows": row_summaries,
"queue_binding_status": "bound" if row_summaries else "unmatched",
"school_year_code_consistent": bool(row_summaries)
and all(
row["school"] in target_school_names
and row["year"] in target_years
and row["major_code"] == code
for row in row_summaries
),
"all_bound_rows_college_blank": bool(row_summaries)
and all(not row["college"] for row in row_summaries),
"candidate_reviewed": False,
"accepted": False,
"stage_written": False,
"production_write": False,
}
)
DETAIL.write_text(
"\n".join(json.dumps(row, ensure_ascii=False, sort_keys=True) for row in binding_rows) + "\n",
encoding="utf-8",
)
group_counts = Counter(
(row["candidate"], row["code"]) for row in binding_rows
)
group_summary = [
{
"candidate": candidate,
"code": code,
"locator_count": count,
"bound_locator_count": sum(
row["queue_binding_status"] == "bound"
for row in binding_rows
if row["candidate"] == candidate and row["code"] == code
),
"queue_row_count": sum(
row["queue_match_count"]
for row in binding_rows
if row["candidate"] == candidate and row["code"] == code
),
}
for (candidate, code), count in sorted(group_counts.items())
]
GROUP_SUMMARY.write_text(
json.dumps(group_summary, ensure_ascii=False, indent=2) + "\n", encoding="utf-8"
)
checks = {
"context_jobs_expected_19": len(context_rows) == 19,
"candidate_locator_rows_expected_123": len(binding_rows) == 123,
"all_candidate_values_declared_by_parser": all(
row["candidate_value_declared_by_parser"] for row in binding_rows
),
"all_candidate_locators_queue_bound": all(
row["queue_binding_status"] == "bound" for row in binding_rows
),
"all_school_year_code_consistent": all(
row["school_year_code_consistent"] for row in binding_rows
),
"all_bound_rows_college_blank": all(
row["all_bound_rows_college_blank"] for row in binding_rows
),
"all_same_page_heading_observed": all(
row["same_page_heading_observed"] for row in binding_rows
),
"no_candidate_reviewed": all(not row["candidate_reviewed"] for row in binding_rows),
"no_candidate_accepted": all(not row["accepted"] for row in binding_rows),
"no_stage_written": all(not row["stage_written"] for row in binding_rows),
"production_write_false": all(not row["production_write"] for row in binding_rows),
"no_binding_errors": not errors,
}
report = {
"schema": "r134_s1_college_residual_candidate_queue_binding_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_CANDIDATE_QUEUE_BOUND",
"verdict": "PASS_READONLY_CANDIDATE_TO_QUEUE_BINDING_WITH_COLLEGE_UNPROMOTED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"queue_rows": len(queue_rows),
"context_jobs": len(context_rows),
"candidate_locator_rows": len(binding_rows),
"unique_candidate_code_groups": len(group_summary),
"bound_locator_rows": sum(row["queue_binding_status"] == "bound" for row in binding_rows),
"bound_queue_row_references": sum(row["queue_match_count"] for row in binding_rows),
"unique_bound_residual_queue_ids": len(
{
queue_row["residual_queue_id"]
for row in binding_rows
for queue_row in row["queue_rows"]
if queue_row["residual_queue_id"]
}
),
},
"checks": checks | {"all_checks_pass": all(checks.values())},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"The binding proves candidate code/page observations correspond to residual queue rows with blank college values; it does not authorize assigning a production college key.",
"Repeated source rows and repeated major codes are retained as separate evidence references; no deduplication or scope expansion was applied.",
"No candidate stage, fact/evidence promotion, registry mutation or writer call was performed.",
],
"errors": errors,
"output_artifacts": {
"report": str(REPORT),
"detail": str(DETAIL),
"group_summary": str(GROUP_SUMMARY),
"log": str(LOG),
},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"queue_rows={len(queue_rows)}",
f"context_jobs={len(context_rows)}",
f"candidate_locator_rows={len(binding_rows)}",
f"bound_locator_rows={report['scope']['bound_locator_rows']}",
f"bound_queue_row_references={report['scope']['bound_queue_row_references']}",
f"unique_bound_residual_queue_ids={report['scope']['unique_bound_residual_queue_ids']}",
"candidate_reviewed=false",
"accepted_source_rows=0",
"stage_rows=0",
"production_database_written=false",
"production_writer_invoked=false",
f"all_checks_pass={report['checks']['all_checks_pass']}",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,264 @@
from __future__ import annotations
import datetime as dt
import json
from collections import Counter, defaultdict
from pathlib import Path
DETAILS = Path(
r"D:\择校\运行暂存\reports\R134_S1_college_residual_verified_full_parse_audit_20261015\full_parse.jsonl"
)
OUT_DIR = Path(
r"D:\择校\运行暂存\reports\R134_S1_college_residual_candidate_review_audit_20261015"
)
REPORT = OUT_DIR / "report.json"
REVIEW_QUEUE = OUT_DIR / "candidate_review_queue.jsonl"
VALUE_SUMMARY = OUT_DIR / "candidate_value_summary.json"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_candidate_review_audit_20261015.log")
def text(value):
return "" if value is None else str(value).strip()
def as_list(value):
if value is None:
return []
if isinstance(value, list):
return [text(item) for item in value if text(item)]
return [text(value)] if text(value) else []
def unique(values):
seen = set()
result = []
for value in values:
if value and value not in seen:
seen.add(value)
result.append(value)
return result
def load_jsonl(path):
with path.open("r", encoding="utf-8") as stream:
return [json.loads(line) for line in stream if line.strip()]
def classify_record(record):
parsed = record.get("parsed") or {}
scope_values = unique(as_list(parsed.get("college_scope_candidate_values")))
header_values = unique(as_list(parsed.get("school_header_candidate_values")))
target_locators = parsed.get("target_hit_locators") or []
candidate_locators = []
locator_binding_errors = []
for locator in target_locators:
candidate = text(locator.get("college_candidate"))
if not candidate:
continue
if candidate in scope_values and candidate in header_values:
candidate_class = "scope_and_school_header_candidate"
elif candidate in scope_values:
candidate_class = "college_scope_candidate"
elif candidate in header_values:
candidate_class = "school_header_candidate"
else:
candidate_class = "unclassified_candidate"
locator_binding_errors.append(
{
"candidate": candidate,
"locator": locator.get("locator"),
"code": locator.get("code"),
}
)
candidate_locators.append(
{
"candidate": candidate,
"candidate_class": candidate_class,
"code": text(locator.get("code")),
"major_name_candidate": text(locator.get("major_name_candidate")),
"locator": text(locator.get("locator")),
"line_number": locator.get("line_number"),
}
)
if scope_values and header_values:
review_class = "mixed_scope_and_school_header_candidates"
elif scope_values:
review_class = "college_scope_candidate_requires_manual_reconciliation"
elif header_values:
review_class = "school_header_candidate_excluded"
else:
review_class = "no_college_candidate_observed"
return {
"url": text(record.get("url")),
"years": as_list(record.get("years")),
"source_types": as_list(record.get("source_types")),
"file_signature": text(record.get("file_signature")),
"artifact_path": text(record.get("artifact_path")),
"actual_sha256": text(record.get("actual_sha256")).lower(),
"expected_sha256_candidates": [
text(value).lower() for value in record.get("expected_sha256_candidates", []) if text(value)
],
"target_queue_rows": int(record.get("target_queue_rows") or 0),
"target_school_names": as_list(record.get("target_school_names")),
"target_major_codes": as_list(record.get("target_major_codes")),
"target_code_hits": int(parsed.get("target_code_hits") or 0),
"target_code_exact_name_hits": int(parsed.get("target_code_exact_name_hits") or 0),
"college_scope_candidate_values": scope_values,
"school_header_candidate_values": header_values,
"college_scope_candidate_hit_count": int(parsed.get("college_scope_candidate_hit_count") or 0),
"school_header_candidate_hit_count": int(parsed.get("school_header_candidate_hit_count") or 0),
"candidate_locators": candidate_locators,
"candidate_locator_count": len(candidate_locators),
"review_class": review_class,
"manual_reconciliation_required": bool(scope_values),
"school_header_excluded": bool(header_values) and not scope_values,
"candidate_reviewed": False,
"accepted": False,
"stage_written": False,
"production_write": False,
"locator_binding_errors": locator_binding_errors,
}
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
records = [classify_record(record) for record in load_jsonl(DETAILS)]
REVIEW_QUEUE.write_text(
"\n".join(json.dumps(record, ensure_ascii=False, sort_keys=True) for record in records) + "\n",
encoding="utf-8",
)
scope_records = [
record for record in records if record["college_scope_candidate_values"]
]
header_records = [
record for record in records if record["school_header_candidate_values"]
]
scope_value_counts = Counter(
value
for record in scope_records
for value in record["college_scope_candidate_values"]
)
header_value_counts = Counter(
value
for record in header_records
for value in record["school_header_candidate_values"]
)
scope_by_year = Counter(
year for record in scope_records for year in record["years"] if year
)
scope_by_signature = Counter(record["file_signature"] for record in scope_records)
scope_by_source_type = Counter(
source_type for record in scope_records for source_type in record["source_types"]
)
VALUE_SUMMARY.write_text(
json.dumps(
{
"college_scope_candidate_values": dict(sorted(scope_value_counts.items())),
"school_header_candidate_values": dict(sorted(header_value_counts.items())),
"scope_jobs_by_year": dict(sorted(scope_by_year.items())),
"scope_jobs_by_file_signature": dict(sorted(scope_by_signature.items())),
"scope_jobs_by_source_type": dict(sorted(scope_by_source_type.items())),
},
ensure_ascii=False,
indent=2,
)
+ "\n",
encoding="utf-8",
)
review_classes = Counter(record["review_class"] for record in records)
checks = {
"input_details_file_exists": DETAILS.is_file(),
"all_records_have_target_code_hits": all(record["target_code_hits"] > 0 for record in records),
"scope_candidate_jobs_expected_19": sum(bool(record["college_scope_candidate_values"]) for record in records) == 19,
"school_header_jobs_expected_2": sum(bool(record["school_header_candidate_values"]) for record in records) == 2,
"all_candidate_locators_bind_to_classified_values": all(
not record["locator_binding_errors"] for record in records
),
"no_candidate_promoted": all(
not record["candidate_reviewed"] and not record["accepted"] for record in records
),
"no_stage_written": all(not record["stage_written"] for record in records),
"production_write_false": all(not record["production_write"] for record in records),
"unique_verified_job_identity": len(
{(record["url"], record["actual_sha256"]) for record in records}
)
== len(records),
}
report = {
"schema": "r134_s1_college_residual_candidate_review_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_CANDIDATE_REVIEW_QUEUE",
"verdict": "PASS_READONLY_CANDIDATE_CLASSIFICATION_WITH_SCOPE_UNPROMOTED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"verified_parse_jobs": len(records),
"college_scope_candidate_jobs": len(scope_records),
"school_header_candidate_jobs": len(header_records),
"no_college_candidate_jobs": sum(
not record["college_scope_candidate_values"]
and not record["school_header_candidate_values"]
for record in records
),
"candidate_locator_rows": sum(record["candidate_locator_count"] for record in records),
"scope_candidate_value_count": len(scope_value_counts),
"school_header_value_count": len(header_value_counts),
"review_classes": dict(sorted(review_classes.items())),
},
"candidate_value_summary": str(VALUE_SUMMARY),
"checks": checks | {"all_checks_pass": all(checks.values())},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"The 19 college-scope groups are parser observations with source locators; they do not establish the production college key or exact row-to-college scope.",
"The 2 Beijing Institute of Petrochemical Technology candidates equal the target school name and are retained only as excluded school-header observations.",
"The 63 HTTP/error/hash-mismatch jobs are outside this review queue and remain independent recovery items.",
"No candidate stage, fact/evidence promotion, registry mutation or writer call was performed.",
],
"output_artifacts": {
"report": str(REPORT),
"review_queue": str(REVIEW_QUEUE),
"value_summary": str(VALUE_SUMMARY),
"log": str(LOG),
},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"verified_parse_jobs={len(records)}",
f"college_scope_candidate_jobs={len(scope_records)}",
f"school_header_candidate_jobs={len(header_records)}",
f"no_college_candidate_jobs={report['scope']['no_college_candidate_jobs']}",
f"candidate_locator_rows={report['scope']['candidate_locator_rows']}",
"candidate_reviewed=false",
"accepted_source_rows=0",
"stage_rows=0",
"production_database_written=false",
"production_writer_invoked=false",
f"all_checks_pass={report['checks']['all_checks_pass']}",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,273 @@
from __future__ import annotations
import csv
import datetime as dt
import hashlib
import html
import json
import re
from html.parser import HTMLParser
from pathlib import Path
QUEUE = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_queue_20261015\residual_queue.jsonl")
INPUT_CSV = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_fetch_queue_20261015\official_fetch_input.csv")
OUTPUT_DIR = Path(r"D:\择校\运行暂存\batches\R134_S1_college_residual_official_fetch_probe_20261015")
FETCH_MANIFEST = OUTPUT_DIR / "fetch_manifest.jsonl"
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_fetch_content_anchor_audit_20261015")
REPORT = OUT_DIR / "report.json"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_fetch_content_anchor_audit_20261015.log")
class VisibleTextParser(HTMLParser):
def __init__(self):
super().__init__(convert_charrefs=True)
self.parts = []
def handle_data(self, data):
value = re.sub(r"\s+", " ", html.unescape(data)).strip()
if value:
self.parts.append(value)
def text(value):
return "" if value is None else str(value).strip()
def sha256_bytes(data):
return hashlib.sha256(data).hexdigest()
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def signature(path):
stat = path.stat()
return {"path": str(path), "bytes": stat.st_size, "sha256": sha256_file(path)}
def decode_body(data):
for encoding in ("utf-8", "gb18030"):
try:
return data.decode(encoding), encoding
except UnicodeDecodeError:
continue
return data.decode("utf-8", errors="replace"), "utf-8-replace"
def safe_artifact_path(value):
artifact = (OUTPUT_DIR / text(value)).resolve(strict=False)
artifact.relative_to(OUTPUT_DIR.resolve())
return artifact
def load_jsonl(path):
with path.open("r", encoding="utf-8") as stream:
return [json.loads(line) for line in stream if line.strip()]
def anchor_lines(lines, anchor):
return [index for index, line in enumerate(lines, start=1) if anchor and anchor in line]
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
queue_before = signature(QUEUE)
input_before = signature(INPUT_CSV)
manifest_before = signature(FETCH_MANIFEST)
queue_rows = load_jsonl(QUEUE)
with INPUT_CSV.open("r", encoding="utf-8-sig", newline="") as stream:
input_rows = list(csv.DictReader(stream))
manifest_rows = load_jsonl(FETCH_MANIFEST)
queue_after = signature(QUEUE)
input_after = signature(INPUT_CSV)
manifest_after = signature(FETCH_MANIFEST)
errors = []
records = []
for manifest in manifest_rows:
url = text(manifest.get("url"))
target_rows = [row for row in queue_rows if text(row.get("source", {}).get("source_url")) == url]
input_matches = [row for row in input_rows if text(row.get("source_url")) == url]
expected_hashes = sorted(
{
text(row.get("source", {}).get("source_page_sha256") or row.get("source", {}).get("sha256")).lower()
for row in target_rows
if text(row.get("source", {}).get("source_page_sha256") or row.get("source", {}).get("sha256"))
}
)
artifact = None
try:
artifact = safe_artifact_path(manifest.get("artifact_path"))
except (ValueError, OSError) as exc:
errors.append({"url": url, "error": "artifact_outside_probe_output_dir", "detail": str(exc)})
artifact_exists = bool(artifact and artifact.is_file())
raw = artifact.read_bytes() if artifact_exists else b""
actual_sha = sha256_bytes(raw) if artifact_exists else ""
decoded, encoding = decode_body(raw) if artifact_exists else ("", "")
parser = VisibleTextParser()
try:
parser.feed(decoded)
parser.close()
except Exception as exc: # HTMLParser is advisory; the raw body remains authoritative.
errors.append({"url": url, "error": "html_visible_text_parse_error", "detail": str(exc)})
lines = parser.parts
target = target_rows[0] if target_rows else {}
base_key = target.get("base_key", {})
expected_anchors = {
"year": text(base_key.get("year")),
"school": text(target.get("school")),
"major_code": text(base_key.get("major_code")),
"major_name": text(target.get("major_name")),
}
anchors = {
name: {
"value": value,
"present": bool(value and value in "\n".join(lines)),
"visible_line_numbers": anchor_lines(lines, value)[:20],
"visible_line_count": len(anchor_lines(lines, value)),
}
for name, value in expected_anchors.items()
}
college_lines = anchor_lines(lines, "学院")
expected_sha = expected_hashes[0] if len(expected_hashes) == 1 else ""
records.append(
{
"url": url,
"final_url": text(manifest.get("final_url")),
"queue_row_count": len(target_rows),
"input_row_count": len(input_matches),
"queue_target": {
"year": expected_anchors["year"],
"school": expected_anchors["school"],
"major_code": expected_anchors["major_code"],
"major_name": expected_anchors["major_name"],
},
"http_status": manifest.get("http_status"),
"fetch_status": text(manifest.get("status")),
"expected_sha256": expected_sha,
"actual_sha256": actual_sha,
"expected_sha256_match": bool(expected_sha and actual_sha == expected_sha),
"artifact_path": str(artifact) if artifact else "",
"artifact_exists": artifact_exists,
"artifact_bytes": len(raw) if artifact_exists else None,
"decode_encoding": encoding,
"visible_text_parts": len(lines),
"anchors": anchors,
"broad_college_token": {
"value": "学院",
"present": bool(college_lines),
"visible_line_numbers": college_lines[:20],
"visible_line_count": len(college_lines),
},
"college_value_extracted": False,
"college_candidate_promoted": False,
"production_write": False,
}
)
all_expected_anchors = all(
all(anchor["present"] for anchor in record["anchors"].values())
for record in records
)
actual_hash_matches = sum(
bool(record["actual_sha256"] and record["actual_sha256"] == record["expected_sha256"])
for record in records
)
manifest_hash_matches = sum(
bool(record["actual_sha256"] and record["actual_sha256"] == text(row.get("sha256")).lower())
for record, row in zip(records, manifest_rows)
)
report = {
"schema": "r134_s1_college_residual_fetch_content_anchor_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_CONTENT_ANCHOR_HASH_MISMATCH",
"verdict": "PASS_READONLY_CONTENT_ANCHORS_OBSERVED_SOURCE_HASH_MISMATCH_QUARANTINED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"queue_rows": len(queue_rows),
"input_csv_rows": len(input_rows),
"fetch_manifest_rows": len(manifest_rows),
"artifacts_checked": len(records),
"http_200_rows": sum(record["http_status"] == 200 for record in records),
"manifest_actual_hash_matches": manifest_hash_matches,
"queue_expected_hash_matches": actual_hash_matches,
"records_with_all_expected_anchors": sum(
all(anchor["present"] for anchor in record["anchors"].values())
for record in records
),
"college_values_extracted": 0,
"accepted_source_rows": 0,
"quarantined_source_rows": len(records),
},
"input_artifacts": {
"queue": {"before": queue_before, "after": queue_after, "stable": queue_before == queue_after},
"input_csv": {"before": input_before, "after": input_after, "stable": input_before == input_after},
"fetch_manifest": {"before": manifest_before, "after": manifest_after, "stable": manifest_before == manifest_after},
},
"records": records,
"checks": {
"manifest_has_one_probe_row": len(manifest_rows) == 1,
"probe_http_200": len(records) == 1 and records[0]["http_status"] == 200,
"artifact_exists": all(record["artifact_exists"] for record in records),
"manifest_sha_matches_actual": manifest_hash_matches == len(records),
"expected_sha_mismatch_retained": len(records) == 1 and actual_hash_matches == 0,
"all_expected_anchors_present": all_expected_anchors,
"no_college_value_extracted": all(not record["college_value_extracted"] for record in records),
"queue_stable": queue_before == queue_after,
"input_csv_stable": input_before == input_after,
"fetch_manifest_stable": manifest_before == manifest_after,
"production_write_false": all(not record["production_write"] for record in records),
"stage_written": False,
"registry_written": False,
"all_structural_checks_pass": not errors and manifest_hash_matches == len(records) and queue_before == queue_after and input_before == input_after and manifest_before == manifest_after,
},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"Visible year, school and major anchors establish content presence only; they do not establish a college table row or the exact college scope for the target major.",
"A broad visible token such as 学院 is recorded as an anchor and is never promoted as a college value.",
"The fetched body remains quarantined because its actual SHA differs from the retained queue SHA; no parser, stage builder or production writer was run.",
],
"errors": errors,
"output_artifacts": {"report": str(REPORT), "log": str(LOG)},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"queue_rows={len(queue_rows)}",
f"fetch_manifest_rows={len(manifest_rows)}",
f"http_200_rows={report['scope']['http_200_rows']}",
f"manifest_actual_hash_matches={manifest_hash_matches}",
f"queue_expected_hash_matches={actual_hash_matches}",
f"records_with_all_expected_anchors={report['scope']['records_with_all_expected_anchors']}",
"college_values_extracted=0",
"production_database_written=false",
"production_writer_invoked=false",
"stage_written=false",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,175 @@
from __future__ import annotations
import csv
import datetime as dt
import hashlib
import json
from pathlib import Path
INPUT_CSV = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_fetch_queue_20261015\official_fetch_input.csv")
OUTPUT_DIR = Path(r"D:\择校\运行暂存\batches\R134_S1_college_residual_official_fetch_probe_20261015")
FETCH_MANIFEST = OUTPUT_DIR / "fetch_manifest.jsonl"
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_fetch_probe_audit_20261015")
REPORT = OUT_DIR / "report.json"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_fetch_probe_audit_20261015.log")
def text(value):
if value is None:
return ""
return str(value).strip()
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def signature(path):
stat = path.stat()
return {"path": str(path), "bytes": stat.st_size, "sha256": sha256_file(path)}
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
input_before = signature(INPUT_CSV)
manifest_before = signature(FETCH_MANIFEST)
with INPUT_CSV.open("r", encoding="utf-8-sig", newline="") as stream:
input_rows = list(csv.DictReader(stream))
with FETCH_MANIFEST.open("r", encoding="utf-8") as stream:
manifest_rows = [json.loads(line) for line in stream if line.strip()]
input_after = signature(INPUT_CSV)
manifest_after = signature(FETCH_MANIFEST)
bound = []
errors = []
for record in manifest_rows:
artifact_rel = text(record.get("artifact_path"))
artifact = (OUTPUT_DIR / artifact_rel).resolve(strict=False)
try:
artifact.relative_to(OUTPUT_DIR.resolve())
except ValueError:
errors.append({"url": text(record.get("url")), "error": "artifact_outside_probe_output_dir"})
continue
input_matches = [row for row in input_rows if text(row.get("source_url")) == text(record.get("url"))]
expected_values = sorted({
text(row.get("source_page_sha256") or row.get("sha256")).lower()
for row in input_matches
if text(row.get("source_page_sha256") or row.get("sha256"))
})
artifact_exists = artifact.is_file()
actual_sha = sha256_file(artifact) if artifact_exists else ""
actual_bytes = artifact.stat().st_size if artifact_exists else None
expected_sha = expected_values[0] if len(expected_values) == 1 else ""
bound.append(
{
"url": text(record.get("url")),
"year": (record.get("years") or [""])[0],
"http_status": record.get("http_status"),
"fetch_status": text(record.get("status")),
"final_url": text(record.get("final_url")),
"attempts": record.get("attempts"),
"expected_sha256": expected_sha,
"expected_sha256_candidates": expected_values,
"manifest_sha256": text(record.get("sha256")).lower(),
"actual_sha256": actual_sha,
"manifest_bytes": record.get("bytes"),
"actual_bytes": actual_bytes,
"artifact_path": str(artifact),
"artifact_exists": artifact_exists,
"expected_sha256_match": bool(expected_sha and actual_sha == expected_sha),
"manifest_actual_sha_match": bool(actual_sha and actual_sha == text(record.get("sha256")).lower()),
"input_row_count": len(input_matches),
"production_write": record.get("production_write", False),
}
)
hash_matches = sum(item["expected_sha256_match"] for item in bound)
manifest_matches = sum(item["manifest_actual_sha_match"] for item in bound)
http_200 = sum(item["http_status"] == 200 for item in bound)
probe_input_matches = sum(item["input_row_count"] for item in bound)
report = {
"schema": "r134_s1_college_residual_fetch_probe_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_FETCH_HASH_MISMATCH",
"verdict": "PASS_READONLY_FETCH_RECEIPT_BOUND_HASH_MISMATCH_QUARANTINED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"input_rows": len(input_rows),
"fetch_manifest_rows": len(manifest_rows),
"http_200_rows": http_200,
"expected_hash_matches": hash_matches,
"manifest_actual_hash_matches": manifest_matches,
"accepted_source_rows": 0 if hash_matches != len(bound) else len(bound),
"quarantined_source_rows": len(bound) - hash_matches,
"content_parsed": False,
},
"input_artifacts": {
"input_csv": {"before": input_before, "after": input_after, "stable": input_before == input_after},
"fetch_manifest": {"before": manifest_before, "after": manifest_after, "stable": manifest_before == manifest_after},
},
"records": bound,
"checks": {
"input_csv_has_one_probe_match": probe_input_matches == 1,
"fetch_manifest_one_row": len(manifest_rows) == 1,
"http_status_200": http_200 == len(bound) and len(bound) == 1,
"artifact_exists": all(item["artifact_exists"] for item in bound),
"manifest_sha_matches_actual_file": manifest_matches == len(bound),
"queue_expected_sha_matches_actual_file": hash_matches == len(bound),
"input_stable": input_before == input_after,
"fetch_manifest_stable": manifest_before == manifest_after,
"production_write_false": all(item["production_write"] is False for item in bound),
"stage_written": False,
"registry_written": False,
"all_structural_checks_pass": not errors and probe_input_matches == 1 and input_before == input_after and manifest_before == manifest_after and manifest_matches == len(bound),
},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"HTTP 200 and a locally hashed body do not override a retained expected SHA mismatch.",
"The fetched body remains quarantined; no college parser or stage builder was run.",
"The mismatch may represent changed source content or a stale historical SHA; it requires source-specific reconciliation.",
],
"errors": errors,
"output_artifacts": {
"report": str(REPORT),
"log": str(LOG),
},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"input_rows={len(input_rows)}",
f"fetch_manifest_rows={len(manifest_rows)}",
f"http_200_rows={http_200}",
f"expected_hash_matches={hash_matches}",
f"manifest_actual_hash_matches={manifest_matches}",
"accepted_source_rows=0",
"production_database_written=false",
"production_writer_invoked=false",
"stage_written=false",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,357 @@
from __future__ import annotations
import datetime as dt
import csv
import hashlib
import json
from collections import Counter, defaultdict
from pathlib import Path
AVAILABILITY = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_source_availability_20261015\availability.jsonl")
AVAILABILITY_REPORT = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_source_availability_20261015\report.json")
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_fetch_queue_20261015")
FETCH_QUEUE = OUT_DIR / "fetch_queue.jsonl"
ROW_JOB_MAP = OUT_DIR / "row_job_map.jsonl"
OFFICIAL_FETCH_INPUT = OUT_DIR / "official_fetch_input.csv"
MANIFEST = OUT_DIR / "manifest.json"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_fetch_queue_20261015.log")
def text(value):
if value is None:
return ""
return str(value).strip()
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def signature(path):
stat = path.stat()
return {"path": str(path), "bytes": stat.st_size, "sha256": sha256_file(path)}
def queue_key(row):
base_key = row.get("base_key") or {}
return {
"year": text(base_key.get("year")),
"school_code": text(base_key.get("school_code")),
"major_code": text(base_key.get("major_code")),
}
def split_alternatives(value):
value = text(value)
if not value:
return []
return [part.strip() for part in value.split("|") if part.strip()]
def extend_unique(target, values):
for value in values:
if value not in target:
target.append(value)
def reference_alignment(urls, shas, raw_paths):
if len(urls) == 1 and len(shas) <= 1 and len(raw_paths) <= 1:
return "single_reference"
if len(urls) > 1 and len(urls) == len(shas) == len(raw_paths):
return "parallel_position_preserved"
return "unpaired_alternatives"
def job_id(source_url, expected_sha256):
canonical = json.dumps(
{"expected_sha256": expected_sha256, "source_url": source_url},
ensure_ascii=False,
sort_keys=True,
separators=(",", ":"),
).encode("utf-8")
return "s1-fetch-" + hashlib.sha256(canonical).hexdigest()
def main():
started = dt.datetime.now(dt.timezone.utc)
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
availability_before = signature(AVAILABILITY)
availability_report_before = signature(AVAILABILITY_REPORT)
availability_report = json.loads(AVAILABILITY_REPORT.read_text(encoding="utf-8"))
expected_rows = int((availability_report.get("scope") or {}).get("queue_rows") or 0)
rows = []
parse_errors = []
groups = {}
job_rows = defaultdict(list)
with AVAILABILITY.open("r", encoding="utf-8") as stream:
for line_number, line in enumerate(stream, 1):
try:
row = json.loads(line)
except Exception as exc:
parse_errors.append({"line": line_number, "error": repr(exc)})
continue
source_url = text(row.get("source_url"))
expected_sha256 = text(row.get("expected_sha256")).lower()
if source_url:
key = (source_url, expected_sha256)
identifier = job_id(source_url, expected_sha256)
if key not in groups:
groups[key] = {
"job_id": identifier,
"source_url": source_url,
"expected_sha256": expected_sha256,
"source_url_alternatives": split_alternatives(source_url),
"expected_sha256_alternatives": split_alternatives(expected_sha256),
"raw_path_alternatives": split_alternatives(row.get("raw_path")),
"expected_page_body_bytes_alternatives": split_alternatives(row.get("expected_page_body_bytes")),
"expected_page_body_bytes": set(),
"source_types": set(),
"years": set(),
"raw_paths": set(),
"availability_status_counts": Counter(),
"queue_lines": [],
"residual_queue_ids": [],
}
group = groups[key]
extend_unique(group["source_url_alternatives"], split_alternatives(source_url))
extend_unique(group["expected_sha256_alternatives"], split_alternatives(expected_sha256))
extend_unique(group["raw_path_alternatives"], split_alternatives(row.get("raw_path")))
extend_unique(group["expected_page_body_bytes_alternatives"], split_alternatives(row.get("expected_page_body_bytes")))
group["expected_page_body_bytes"].add(text(row.get("expected_page_body_bytes")))
group["source_types"].add(text(row.get("source_type")) or "<blank>")
group["years"].add(text((row.get("base_key") or {}).get("year")) or "<blank>")
if text(row.get("raw_path")):
group["raw_paths"].add(text(row.get("raw_path")))
group["availability_status_counts"][text(row.get("availability_status")) or "<blank>"] += 1
group["queue_lines"].append(int(row.get("queue_line") or line_number))
group["residual_queue_ids"].append(text(row.get("residual_queue_id")))
job_rows[identifier].append(
{
"queue_line": int(row.get("queue_line") or line_number),
"residual_queue_id": text(row.get("residual_queue_id")),
"base_key": queue_key(row),
"school": text(row.get("school")),
"major_name": text(row.get("major_name")),
"source_type": text(row.get("source_type")),
"source_url": source_url,
"expected_sha256": expected_sha256,
"availability_status": text(row.get("availability_status")),
"locator": row.get("locator") or {},
}
)
rows.append(row)
jobs = []
for group in sorted(groups.values(), key=lambda value: (0 if any(item.startswith("official") for item in value["source_types"]) else 1, value["source_url"], value["expected_sha256"])):
official = any(item.startswith("official") for item in group["source_types"])
jobs.append(
{
"job_id": group["job_id"],
"priority": "official_primary" if official else "third_party_secondary",
"source_url": group["source_url"],
"source_url_alternatives": group["source_url_alternatives"],
"expected_sha256": group["expected_sha256"],
"expected_sha256_alternatives": group["expected_sha256_alternatives"],
"raw_path_alternatives": group["raw_path_alternatives"],
"expected_page_body_bytes_alternatives": group["expected_page_body_bytes_alternatives"],
"reference_alignment": reference_alignment(
group["source_url_alternatives"],
group["expected_sha256_alternatives"],
group["raw_path_alternatives"],
),
"multi_reference_bundle": len(group["source_url_alternatives"]) > 1,
"expected_page_body_bytes": sorted(group["expected_page_body_bytes"]),
"source_types": sorted(group["source_types"]),
"years": sorted(group["years"]),
"raw_paths": sorted(group["raw_paths"]),
"availability_status_counts": dict(sorted(group["availability_status_counts"].items())),
"queue_row_count": len(group["queue_lines"]),
"queue_lines": sorted(group["queue_lines"]),
"residual_queue_ids": group["residual_queue_ids"],
"retrieval_status": "needs_authorized_fetch_or_restore",
}
)
with FETCH_QUEUE.open("w", encoding="utf-8", newline="\n") as stream:
for job in jobs:
stream.write(json.dumps(job, ensure_ascii=False, sort_keys=True) + "\n")
with ROW_JOB_MAP.open("w", encoding="utf-8", newline="\n") as stream:
for job in jobs:
for row in sorted(job_rows[job["job_id"]], key=lambda value: value["queue_line"]):
stream.write(json.dumps({"job_id": job["job_id"], **row}, ensure_ascii=False, sort_keys=True) + "\n")
official_input = {}
skipped_unpaired_jobs = 0
for job in jobs:
if job["priority"] != "official_primary":
continue
urls = job["source_url_alternatives"]
shas = job["expected_sha256_alternatives"]
if job["reference_alignment"] == "single_reference":
references = [(urls[0], shas[0] if len(shas) == 1 else "")]
elif job["reference_alignment"] == "parallel_position_preserved":
references = list(zip(urls, shas))
else:
skipped_unpaired_jobs += 1
continue
for year in job["years"]:
for url, expected_sha256 in references:
key = (year, url, expected_sha256)
record = official_input.setdefault(
key,
{
"year": year,
"school": "",
"source_url": url,
"sha256": expected_sha256,
"source_page_sha256": expected_sha256,
"source_type": "|".join(job["source_types"]),
"source_family": "s1_college_residual_official",
"template_id": "s1_college_residual",
"data_type": "college_scope",
},
)
record["source_type"] = "|".join(sorted(set(record["source_type"].split("|") + job["source_types"])))
official_input_rows = sorted(official_input.values(), key=lambda row: (row["year"], row["source_url"], row["sha256"]))
with OFFICIAL_FETCH_INPUT.open("w", encoding="utf-8-sig", newline="") as stream:
writer = csv.DictWriter(
stream,
fieldnames=(
"year",
"school",
"source_url",
"sha256",
"source_page_sha256",
"source_type",
"source_family",
"template_id",
"data_type",
),
)
writer.writeheader()
writer.writerows(official_input_rows)
availability_after = signature(AVAILABILITY)
availability_report_after = signature(AVAILABILITY_REPORT)
stable = availability_before == availability_after and availability_report_before == availability_report_after
row_map_count = sum(len(value) for value in job_rows.values())
job_status_counts = Counter(job["retrieval_status"] for job in jobs)
priority_counts = Counter(job["priority"] for job in jobs)
alignment_counts = Counter(job["reference_alignment"] for job in jobs)
multi_reference_jobs = sum(1 for job in jobs if job["multi_reference_bundle"])
unique_url_alternatives = {
alternative
for job in jobs
for alternative in job["source_url_alternatives"]
}
rows_by_year = Counter(text((row.get("base_key") or {}).get("year")) or "<blank>" for row in rows if text(row.get("source_url")))
manifest = {
"schema": "r134_s1_college_residual_fetch_queue.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_FETCH_QUEUE",
"verdict": "PASS_READONLY_DEDUPLICATED_URL_QUEUE_WITH_ROW_BINDING",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"availability_rows": len(rows),
"expected_rows_from_availability_report": expected_rows,
"rows_with_source_url": sum(1 for row in rows if text(row.get("source_url"))),
"unique_url_sha_jobs": len(jobs),
"unique_source_urls": len({job["source_url"] for job in jobs}),
"unique_source_url_alternatives": len(unique_url_alternatives),
"multi_reference_bundle_jobs": multi_reference_jobs,
"row_job_map_rows": row_map_count,
"official_fetch_input_rows": len(official_input_rows),
"official_fetch_input_year_counts": dict(sorted(Counter(row["year"] for row in official_input_rows).items())),
"official_fetch_jobs_skipped_unpaired": skipped_unpaired_jobs,
"grouping_key": "exact source_url plus expected_sha256; no content or name merging",
},
"priority_counts": dict(sorted(priority_counts.items())),
"retrieval_status_counts": dict(sorted(job_status_counts.items())),
"reference_alignment_counts": dict(sorted(alignment_counts.items())),
"rows_by_year_with_url": dict(sorted(rows_by_year.items())),
"input_artifacts": {
"availability": {"before": availability_before, "after": availability_after, "stable": availability_before == availability_after},
"availability_report": {"before": availability_report_before, "after": availability_report_after, "stable": availability_report_before == availability_report_after},
},
"checks": {
"availability_jsonl_parse_errors": len(parse_errors) == 0,
"availability_rows_match_report": len(rows) == expected_rows,
"jobs_have_source_url": all(bool(job["source_url"]) for job in jobs),
"all_source_url_alternatives_are_http_urls": all(
alternative.startswith("http://") or alternative.startswith("https://")
for job in jobs
for alternative in job["source_url_alternatives"]
),
"job_ids_unique": len({job["job_id"] for job in jobs}) == len(jobs),
"job_row_counts_sum_to_url_rows": sum(job["queue_row_count"] for job in jobs) == sum(1 for row in rows if text(row.get("source_url"))),
"row_map_count_matches_url_rows": row_map_count == sum(1 for row in rows if text(row.get("source_url"))),
"official_fetch_input_has_expected_columns": set(official_input_rows[0]) == {
"year", "school", "source_url", "sha256", "source_page_sha256", "source_type", "source_family", "template_id", "data_type"
} if official_input_rows else True,
"input_stable_during_generation": stable,
"no_url_fetch_or_content_read": True,
"production_database_written": False,
"production_writer_invoked": False,
"stage_written": False,
"registry_written": False,
"all_pass": len(parse_errors) == 0 and len(rows) == expected_rows and stable and row_map_count == sum(1 for row in rows if text(row.get("source_url"))),
},
"limitations": [
"This artifact is a retrieval queue only; no URL was requested and no source content was read.",
"The grouping key does not merge different expected SHAs even when URLs are equal.",
"A later fetch must preserve HTTP status, final URL, response bytes, actual SHA, raw body and parser locator before college parsing.",
"No row in this queue is promoted to a college candidate, production key, stage or accepted fact.",
],
"output_artifacts": {
"fetch_queue": str(FETCH_QUEUE),
"row_job_map": str(ROW_JOB_MAP),
"official_fetch_input": str(OFFICIAL_FETCH_INPUT),
"manifest": str(MANIFEST),
"log": str(LOG),
"script": str(Path(__file__)),
},
"parse_errors": parse_errors,
}
MANIFEST.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
manifest["output_artifacts"]["fetch_queue_signature"] = signature(FETCH_QUEUE)
manifest["output_artifacts"]["row_job_map_signature"] = signature(ROW_JOB_MAP)
manifest["output_artifacts"]["official_fetch_input_signature"] = signature(OFFICIAL_FETCH_INPUT)
manifest["output_artifacts"]["script_signature"] = signature(Path(__file__))
MANIFEST.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={manifest['status']}",
f"verdict={manifest['verdict']}",
f"availability_rows={len(rows)}",
f"rows_with_source_url={sum(1 for row in rows if text(row.get('source_url')))}",
f"unique_url_sha_jobs={len(jobs)}",
f"unique_source_urls={len({job['source_url'] for job in jobs})}",
f"unique_source_url_alternatives={len(unique_url_alternatives)}",
f"multi_reference_bundle_jobs={multi_reference_jobs}",
f"reference_alignment_counts={json.dumps(dict(sorted(alignment_counts.items())), ensure_ascii=False, sort_keys=True)}",
f"priority_counts={json.dumps(dict(sorted(priority_counts.items())), ensure_ascii=False, sort_keys=True)}",
f"input_stable={stable}",
"url_fetch=false",
"production_database_written=false",
"production_writer_invoked=false",
"stage_written=false",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,240 @@
from __future__ import annotations
import csv
import datetime as dt
import hashlib
import json
from collections import Counter
from pathlib import Path
import urllib.parse
INPUT_CSV = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_fetch_queue_20261015\official_fetch_input.csv")
OUTPUT_DIR = Path(r"D:\择校\运行暂存\batches\R134_S1_college_residual_official_fetch_20261015")
FETCH_MANIFEST = OUTPUT_DIR / "fetch_manifest.jsonl"
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_official_fetch_audit_20261015")
REPORT = OUT_DIR / "report.json"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_official_fetch_audit_20261015.log")
def text(value):
return "" if value is None else str(value).strip()
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def signature(path):
stat = path.stat()
return {"path": str(path), "bytes": stat.st_size, "sha256": sha256_file(path)}
def normalize_url(value):
raw = text(value)
parts = urllib.parse.urlsplit(raw)
if parts.scheme.lower() not in {"http", "https"} or not parts.netloc:
raise ValueError(f"source URL must be absolute HTTP(S): {raw!r}")
hostname = parts.hostname
if not hostname:
raise ValueError(f"source URL has no host: {raw!r}")
encoded_host = hostname.encode("idna").decode("ascii")
userinfo = ""
if "@" in parts.netloc:
raw_userinfo = parts.netloc.rsplit("@", 1)[0]
userinfo = urllib.parse.quote(raw_userinfo, safe=":%@") + "@"
netloc = f"{userinfo}{encoded_host}"
if parts.port is not None:
netloc += f":{parts.port}"
path = urllib.parse.quote(parts.path, safe="/%:@!$&'()*+,;=-._~")
query = urllib.parse.quote(parts.query, safe="/%?:@!$&'()*+,;=-._~[]")
return urllib.parse.urlunsplit((parts.scheme.lower(), netloc, path, query, ""))
def load_jsonl(path):
with path.open("r", encoding="utf-8") as stream:
return [json.loads(line) for line in stream if line.strip()]
def safe_artifact(value):
if not text(value):
return None
artifact = (OUTPUT_DIR / text(value)).resolve(strict=False)
artifact.relative_to(OUTPUT_DIR.resolve())
return artifact
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
input_before = signature(INPUT_CSV)
manifest_before = signature(FETCH_MANIFEST)
with INPUT_CSV.open("r", encoding="utf-8-sig", newline="") as stream:
input_rows = list(csv.DictReader(stream))
manifest_rows = load_jsonl(FETCH_MANIFEST)
input_after = signature(INPUT_CSV)
manifest_after = signature(FETCH_MANIFEST)
errors = []
input_by_url = {}
for row in input_rows:
raw_url = text(row.get("source_url"))
try:
canonical_url = normalize_url(raw_url)
except ValueError as exc:
errors.append({"url": raw_url, "error": "invalid_input_url", "detail": str(exc)})
continue
input_by_url.setdefault(canonical_url, []).append(row)
records = []
for manifest in manifest_rows:
url = text(manifest.get("url"))
matches = input_by_url.get(url, [])
expected_values = sorted({
text(row.get("source_page_sha256") or row.get("sha256")).lower()
for row in matches
if text(row.get("source_page_sha256") or row.get("sha256"))
})
try:
artifact = safe_artifact(manifest.get("artifact_path"))
except (ValueError, OSError) as exc:
artifact = None
errors.append({"url": url, "error": "artifact_outside_output_dir", "detail": str(exc)})
artifact_exists = bool(artifact and artifact.is_file())
actual_sha = sha256_file(artifact) if artifact_exists else ""
status = text(manifest.get("status"))
records.append(
{
"url": url,
"input_url_variants": sorted({text(row.get("source_url")) for row in matches}),
"years": manifest.get("years") or [],
"source_types": sorted({text(row.get("source_type")) for row in matches if text(row.get("source_type"))}),
"input_row_count": len(matches),
"http_status": manifest.get("http_status"),
"status": status,
"attempts": manifest.get("attempts"),
"expected_sha256_candidates": expected_values,
"manifest_sha256": text(manifest.get("sha256")).lower(),
"actual_sha256": actual_sha,
"expected_sha256_match": bool(actual_sha and actual_sha in expected_values),
"manifest_actual_sha_match": bool(actual_sha and actual_sha == text(manifest.get("sha256")).lower()),
"artifact_path": str(artifact) if artifact else "",
"artifact_exists": artifact_exists,
"bytes": manifest.get("bytes") or 0,
"production_write": manifest.get("production_write", False),
}
)
manifest_urls = [record["url"] for record in records]
manifest_url_counter = Counter(manifest_urls)
input_urls = set(input_by_url)
manifest_url_set = set(manifest_urls)
status_counts = Counter(record["status"] for record in records)
year_counts = Counter(year for record in records for year in record["years"])
source_type_counts = Counter(source_type for record in records for source_type in record["source_types"])
fetched = [record for record in records if record["status"] == "fetched"]
artifact_rows = sum(record["artifact_exists"] for record in records)
manifest_sha_matches = sum(record["manifest_actual_sha_match"] for record in records)
expected_sha_matches = sum(record["expected_sha256_match"] for record in records)
bound_input_rows = sum(record["input_row_count"] for record in records)
report = {
"schema": "r134_s1_college_residual_official_fetch_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_OFFICIAL_FETCH_TRANSPORT_AUDIT",
"verdict": "PASS_READONLY_FETCH_MANIFEST_AND_ARTIFACT_BINDING_WITH_QUARANTINED_NONMATCHES",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"input_rows": len(input_rows),
"input_unique_canonical_urls": len(input_urls),
"manifest_rows": len(records),
"manifest_unique_urls": len(manifest_url_set),
"http_200_rows": sum(record["http_status"] == 200 for record in records),
"fetched_rows": len(fetched),
"artifact_rows": artifact_rows,
"manifest_actual_sha_matches": manifest_sha_matches,
"expected_sha_matches": expected_sha_matches,
"hash_verified_unparsed_jobs": expected_sha_matches,
"quarantined_or_unavailable_jobs": len(records) - expected_sha_matches,
"bound_input_rows": bound_input_rows,
"unbound_input_rows": len(input_rows) - bound_input_rows,
"content_parsed": False,
"accepted_source_rows": 0,
"stage_rows": 0,
},
"status_counts": dict(sorted(status_counts.items())),
"year_counts": dict(sorted(year_counts.items())),
"source_type_counts": dict(sorted(source_type_counts.items())),
"input_artifacts": {
"input_csv": {"before": input_before, "after": input_after, "stable": input_before == input_after},
"fetch_manifest": {"before": manifest_before, "after": manifest_after, "stable": manifest_before == manifest_after},
},
"records": records,
"checks": {
"input_rows_bound_to_manifest": bound_input_rows == len(input_rows),
"input_unique_canonical_urls_equal_manifest_unique_urls": input_urls == manifest_url_set,
"manifest_urls_unique": all(count == 1 for count in manifest_url_counter.values()),
"artifact_paths_inside_output_dir": not any(error["error"] == "artifact_outside_output_dir" for error in errors),
"manifest_actual_sha_matches": manifest_sha_matches == artifact_rows,
"artifact_bytes_match_manifest": all(
not record["artifact_exists"] or record["bytes"] == Path(record["artifact_path"]).stat().st_size
for record in records
),
"input_stable": input_before == input_after,
"fetch_manifest_stable": manifest_before == manifest_after,
"production_write_false": all(not record["production_write"] for record in records),
"content_not_parsed": True,
"accepted_rows_zero": True,
"stage_rows_zero": True,
"all_structural_checks_pass": not errors and bound_input_rows == len(input_rows) and input_urls == manifest_url_set and all(count == 1 for count in manifest_url_counter.values()) and manifest_sha_matches == artifact_rows and input_before == input_after and manifest_before == manifest_after,
},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"A fetched body is not accepted merely because HTTP status is 200; only an exact retained expected SHA is counted as hash-verified.",
"Hash-verified jobs were not parsed in this audit, so college scope, row locator and field semantics remain unverified.",
"HTTP 403/404/502 and network-error jobs remain unavailable or quarantined and require source-specific recovery decisions.",
],
"errors": errors,
"output_artifacts": {"report": str(REPORT), "log": str(LOG)},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"input_rows={len(input_rows)}",
f"input_unique_canonical_urls={len(input_urls)}",
f"manifest_rows={len(records)}",
f"http_200_rows={report['scope']['http_200_rows']}",
f"fetched_rows={len(fetched)}",
f"artifact_rows={artifact_rows}",
f"manifest_actual_sha_matches={manifest_sha_matches}",
f"expected_sha_matches={expected_sha_matches}",
f"bound_input_rows={bound_input_rows}",
f"unbound_input_rows={report['scope']['unbound_input_rows']}",
"content_parsed=false",
"accepted_source_rows=0",
"stage_rows=0",
"production_database_written=false",
"production_writer_invoked=false",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,114 @@
from __future__ import annotations
import datetime as dt
import hashlib
import json
import struct
from pathlib import Path
SAMPLE_MANIFEST = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_verified_sample_parse_audit_20261015\sample_manifest.jsonl")
RENDER_DIR = SAMPLE_MANIFEST.parent / "renders"
OUT_DIR = SAMPLE_MANIFEST.parent
REPORT = OUT_DIR / "visual_review.json"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_sample_visual_review_20261015.log")
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def png_dimensions(path):
with path.open("rb") as stream:
header = stream.read(24)
if len(header) != 24 or header[:8] != b"\x89PNG\r\n\x1a\n" or header[12:16] != b"IHDR":
return None
return {"width": struct.unpack(">I", header[16:20])[0], "height": struct.unpack(">I", header[20:24])[0]}
def main():
started = dt.datetime.now(dt.timezone.utc)
sample_rows = [json.loads(line) for line in SAMPLE_MANIFEST.read_text(encoding="utf-8").splitlines() if line.strip()]
expected = []
for row in sample_rows:
if Path(row["artifact_path"]).suffix.lower() != ".pdf":
continue
stem = Path(row["artifact_path"]).stem
for page in sorted(set(int(value) for value in row.get("visual_review_pages", []))):
expected.append(RENDER_DIR / f"{stem}_p{page}-{page}.png")
records = []
for path in expected:
dimensions = png_dimensions(path) if path.is_file() else None
records.append(
{
"path": str(path),
"exists": path.is_file(),
"bytes": path.stat().st_size if path.is_file() else None,
"sha256": sha256_file(path) if path.is_file() else "",
"dimensions": dimensions,
"nonblank_render_artifact": bool(path.is_file() and path.stat().st_size > 0 and dimensions and dimensions["width"] > 0 and dimensions["height"] > 0),
}
)
report = {
"schema": "r134_s1_college_residual_sample_visual_review.v1",
"status": "PASS_READONLY_PDF_SAMPLE_RENDER_AND_MANUAL_VISUAL_REVIEW",
"verdict": "PASS_9_PDF_SAMPLE_PAGES_RENDERED_AND_VISUALLY_REVIEWED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"sample_rows": len(sample_rows),
"pdf_sample_rows": sum(Path(row["artifact_path"]).suffix.lower() == ".pdf" for row in sample_rows),
"expected_render_pages": len(expected),
"rendered_pages": sum(record["exists"] for record in records),
"nonblank_render_pages": sum(record["nonblank_render_artifact"] for record in records),
"manual_visual_review": "PASS: no blank page, clipping, overlap or unreadable table boundary observed in the 9 rendered pages",
},
"records": records,
"checks": {
"all_expected_render_pages_exist": len(records) == 9 and all(record["exists"] for record in records),
"all_render_pages_nonblank": len(records) == 9 and all(record["nonblank_render_artifact"] for record in records),
"manual_visual_review_recorded": True,
"production_write_false": True,
"stage_written": False,
"all_structural_checks_pass": len(records) == 9 and all(record["nonblank_render_artifact"] for record in records),
},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
},
"limitations": [
"Visual review covers the 7-source stratified sample only, not all 58 hash-verified bodies.",
"Visual readability does not establish exact college scope or authorize candidate/stage promotion.",
],
"output_artifacts": {"report": str(REPORT), "log": str(LOG)},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.parent.mkdir(parents=True, exist_ok=True)
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"expected_render_pages={len(expected)}",
f"rendered_pages={report['scope']['rendered_pages']}",
f"nonblank_render_pages={report['scope']['nonblank_render_pages']}",
"manual_visual_review=pass",
"production_database_written=false",
"stage_written=false",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,306 @@
from __future__ import annotations
import datetime as dt
import hashlib
import json
import os
from collections import Counter, defaultdict
from pathlib import Path
QUEUE = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_queue_20261015\residual_queue.jsonl")
QUEUE_MANIFEST = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_queue_20261015\manifest.json")
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_source_availability_20261015")
REPORT = OUT_DIR / "report.json"
AVAILABILITY = OUT_DIR / "availability.jsonl"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_source_availability_20261015.log")
TEMP_ROOT = Path(r"C:\Temp\zexiao_staging")
CHECK_ROOTS = [
TEMP_ROOT,
Path(r"D:\择校\审计报告\历史暂存归档\20261013\C_temp_snapshot_20261013"),
Path(r"D:\择校\审计报告\历史暂存归档\20261013\C_temp_snapshot"),
Path(r"D:\择校\审计报告\历史暂存归档\20261012\C_temp_snapshot"),
Path(r"D:\择校\审计报告\历史暂存归档\20261013"),
Path(r"D:\择校\审计报告\历史暂存归档\20261012"),
Path(r"D:\择校\运行暂存"),
Path(r"D:\择校\staging"),
]
def text(value):
if value is None:
return ""
return str(value).strip()
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def signature(path):
stat = path.stat()
return {"path": str(path), "bytes": stat.st_size, "sha256": sha256_file(path)}
def normalize_path(value):
return text(value).replace("/", "\\")
def is_absolute_windows(path_text):
return len(path_text) >= 3 and path_text[1] == ":" and path_text[2] in {"\\", "/"}
def candidate_paths(raw_path):
raw = normalize_path(raw_path)
if not raw:
return []
paths = []
if is_absolute_windows(raw):
paths.append(Path(raw))
temp_prefix = normalize_path(str(TEMP_ROOT)).rstrip("\\") + "\\"
if raw.lower().startswith(temp_prefix.lower()):
relative = raw[len(temp_prefix):]
paths.extend(root / relative for root in CHECK_ROOTS if root != TEMP_ROOT)
else:
paths.extend(root / raw for root in CHECK_ROOTS)
result = []
seen = set()
for path in paths:
key = os.path.normcase(os.path.normpath(str(path)))
if key not in seen:
seen.add(key)
result.append(path)
return result
def queue_key(row):
base_key = row.get("base_key") or {}
return {
"year": text(base_key.get("year")),
"school_code": text(base_key.get("school_code")),
"major_code": text(base_key.get("major_code")),
}
def main():
started = dt.datetime.now(dt.timezone.utc)
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
queue_before = signature(QUEUE)
manifest_before = signature(QUEUE_MANIFEST)
manifest_data = json.loads(QUEUE_MANIFEST.read_text(encoding="utf-8"))
expected_queue_rows = int(((manifest_data.get("output") or {}).get("rows")) or 0)
root_state = [
{
"path": str(root),
"exists": root.exists(),
"is_dir": root.is_dir(),
}
for root in CHECK_ROOTS
]
hash_cache = {}
rows = []
parse_errors = []
status_counts = Counter()
by_year = defaultdict(Counter)
by_source_type = defaultdict(Counter)
found_paths = Counter()
candidate_path_checks = 0
with QUEUE.open("r", encoding="utf-8") as stream:
for line_number, line in enumerate(stream, 1):
try:
row = json.loads(line)
except Exception as exc:
parse_errors.append({"line": line_number, "error": repr(exc)})
continue
source = row.get("source") or {}
raw_path = normalize_path(source.get("raw_path"))
expected_sha = text(source.get("sha256") or source.get("source_page_sha256")).lower()
source_url = text(source.get("source_url"))
year = text((row.get("base_key") or {}).get("year"))
source_type = text(source.get("source_type")) or "<blank>"
candidates = candidate_paths(raw_path)
candidate_path_checks += len(candidates)
existing = []
inaccessible = []
for path in candidates:
try:
if not path.is_file():
continue
cache_key = os.path.normcase(os.path.normpath(str(path)))
if cache_key not in hash_cache:
try:
stat = path.stat()
hash_cache[cache_key] = {
"path": str(path),
"bytes": stat.st_size,
"sha256": sha256_file(path),
"error": "",
}
except Exception as exc:
hash_cache[cache_key] = {
"path": str(path),
"bytes": None,
"sha256": "",
"error": repr(exc),
}
found = hash_cache[cache_key]
existing.append(
{
"path": found["path"],
"bytes": found["bytes"],
"sha256": found["sha256"],
"sha_match": bool(expected_sha and found["sha256"] == expected_sha),
"error": found["error"],
}
)
found_paths[found["path"]] += 1
except Exception as exc:
inaccessible.append({"path": str(path), "error": repr(exc)})
if not raw_path:
status = "no_local_raw_path_with_url" if source_url else "no_local_raw_path_no_url"
elif not existing:
status = "missing_at_checked_paths"
elif expected_sha and any(item["sha_match"] for item in existing):
status = "found_expected_sha"
elif expected_sha:
status = "found_sha_mismatch"
else:
status = "found_without_expected_sha"
status_counts[status] += 1
by_year[year or "<blank>"][status] += 1
by_source_type[source_type][status] += 1
detail = {
"queue_line": line_number,
"residual_queue_id": text(row.get("residual_queue_id")),
"base_key": queue_key(row),
"school": text(row.get("school")),
"major_name": text(row.get("major_name")),
"source_type": source_type,
"source_url": source_url,
"raw_path": raw_path,
"expected_sha256": expected_sha,
"expected_page_body_bytes": text(source.get("page_body_bytes")),
"year_basis": text(source.get("year_basis")),
"locator": row.get("locator") or {},
"availability_status": status,
"checked_candidate_count": len(candidates),
"existing_candidates": existing,
"inaccessible_candidates": inaccessible,
}
rows.append(detail)
queue_after = signature(QUEUE)
manifest_after = signature(QUEUE_MANIFEST)
stable = queue_before == queue_after and manifest_before == manifest_after
with AVAILABILITY.open("w", encoding="utf-8", newline="\n") as stream:
for row in rows:
stream.write(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n")
availability_rows = sum(1 for _ in AVAILABILITY.open("r", encoding="utf-8"))
samples = {}
for status in status_counts:
samples[status] = [
row
for row in rows
if row["availability_status"] == status
][:20]
report = {
"schema": "r134_s1_college_residual_source_availability.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_SOURCE_AVAILABILITY",
"verdict": "PASS_READONLY_BOUNDED_LOCAL_PATH_AUDIT",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"queue_rows": len(rows),
"expected_queue_rows_from_manifest": expected_queue_rows,
"queue_parse_errors": len(parse_errors),
"matching_basis": "exact retained raw_path candidates only; no URL fetch, filename inference, SHA-only global scan, or content reconstruction",
"expected_hash_field": "source.sha256, falling back to source.source_page_sha256",
"candidate_root_count": len(CHECK_ROOTS),
"candidate_path_checks": candidate_path_checks,
"unique_existing_file_paths_hashed": len(hash_cache),
},
"input_artifacts": {
"queue": {"before": queue_before, "after": queue_after, "stable": queue_before == queue_after},
"queue_manifest": {"before": manifest_before, "after": manifest_after, "stable": manifest_before == manifest_after},
},
"candidate_roots": root_state,
"availability_status_counts": dict(sorted(status_counts.items())),
"availability_status_counts_by_year": {
year: dict(sorted(counts.items()))
for year, counts in sorted(by_year.items())
},
"availability_status_counts_by_source_type": {
source_type: dict(sorted(counts.items()))
for source_type, counts in sorted(by_source_type.items())
},
"existing_path_usage": [
{"path": path, "queue_rows": count}
for path, count in sorted(found_paths.items())
],
"samples": samples,
"checks": {
"queue_readable_and_jsonl": len(parse_errors) == 0,
"queue_rows_expected": len(rows) == expected_queue_rows,
"queue_unique_residual_ids": len({row["residual_queue_id"] for row in rows}) == len(rows),
"queue_stable_during_audit": stable,
"availability_rows_equal_queue_rows": availability_rows == len(rows),
"no_url_fetch_or_content_reconstruction": True,
"all_pass": len(parse_errors) == 0 and len(rows) == expected_queue_rows and availability_rows == len(rows) and stable,
},
"write_boundary": {
"production_database_read": False,
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
},
"limitations": [
"A missing file at the checked local paths is not proof that the remote source URL is unavailable.",
"Rows with no raw_path require an authorized retrieval run before content or college parsing can occur.",
"A found file with a mismatching SHA remains quarantined and is not accepted as the retained source.",
"This audit does not infer college names, school identities, major codes, or production field semantics.",
],
"parse_errors": parse_errors,
"output_artifacts": {
"availability_jsonl": str(AVAILABILITY),
"report_json": str(REPORT),
"log": str(LOG),
},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
log_lines = [
f"status={report['status']}",
f"verdict={report['verdict']}",
f"queue_rows={len(rows)}",
f"queue_parse_errors={len(parse_errors)}",
f"status_counts={json.dumps(dict(sorted(status_counts.items())), ensure_ascii=False, sort_keys=True)}",
f"unique_existing_file_paths_hashed={len(hash_cache)}",
f"queue_stable={stable}",
"production_database_written=false",
"production_writer_invoked=false",
"stage_written=false",
]
LOG.write_text("\n".join(log_lines) + "\n", encoding="utf-8")
if __name__ == "__main__":
main()
@@ -0,0 +1,357 @@
from pathlib import Path
import datetime
import hashlib
import json
QUEUE = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_queue_20261015\residual_queue.jsonl")
QUEUE_MANIFEST = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_queue_20261015\manifest.json")
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_stage_overlay_20261015")
REPORT = OUT_DIR / "report.json"
OVERLAY = OUT_DIR / "overlay.jsonl"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_stage_overlay_20261015.log")
MANIFESTS = [
Path(r"D:\择校\运行暂存\reports\R134_2024_shanghai_university_partial_version_manifest_20261014.json"),
Path(r"D:\择校\运行暂存\reports\R134_2024_chinakaoyan_excel_partial_version_manifest_20261014_r3.json"),
Path(r"D:\择校\运行暂存\reports\R134_2025_chinakaoyan_partial_version_manifest_20261014.json"),
Path(r"D:\择校\运行暂存\reports\R134_2026_chinakaoyan_partial_version_manifest_20261014.json"),
]
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def file_signature(path):
stat = path.stat()
return {"path": str(path), "bytes": stat.st_size, "sha256": sha256_file(path)}
def text(value):
if value is None:
return ""
return str(value).strip()
def queue_key(row):
base_key = row.get("base_key") or row
return (
text(base_key.get("year") or base_key.get("admission_year")),
text(base_key.get("school_code")),
text(base_key.get("major_code")),
)
def stage_key(row):
business_key = row.get("business_key") or {}
return (
text(business_key.get("year")),
text(business_key.get("school_code")),
text(business_key.get("major_code")),
)
def stage_paths():
paths = []
seen = set()
manifest_meta = []
for manifest_path in MANIFESTS:
data = json.loads(manifest_path.read_text(encoding="utf-8"))
entries = []
stage = data.get("stage") or {}
if stage.get("shards"):
entries.extend(stage["shards"])
elif stage.get("path"):
entries.append(stage)
for artifact in data.get("artifacts") or []:
if artifact.get("role") == "writer_stage":
entries.append(artifact)
for entry in entries:
path = Path(entry["path"])
if str(path) in seen:
continue
seen.add(str(path))
paths.append((path, entry, str(manifest_path)))
manifest_meta.append({
"path": str(manifest_path),
"sha256": sha256_file(manifest_path),
"version_id": data.get("version_id"),
"stage_entry_count": len(entries),
})
return paths, manifest_meta
def main():
started = datetime.datetime.now(datetime.timezone.utc)
queue_before = file_signature(QUEUE)
queue_manifest_before = file_signature(QUEUE_MANIFEST)
queue_rows = []
queue_by_key = {}
with QUEUE.open(encoding="utf-8") as stream:
for line_number, line in enumerate(stream, 1):
row = json.loads(line)
key = queue_key(row)
queue_rows.append(row)
source = row.get("source") or {}
locator = row.get("locator") or {}
queue_by_key.setdefault(key, []).append({
"queue_line": line_number,
"school": row.get("school"),
"major_name": row.get("major_name"),
"source_type": source.get("source_type"),
"source_url": source.get("source_url"),
"raw_path": source.get("raw_path"),
"sha256": source.get("sha256"),
"source_page_sha256": source.get("source_page_sha256"),
"source_locators": locator.get("source_locators"),
})
stage_entries, manifest_meta = stage_paths()
stage_before = []
stage_rows_by_key = {}
stage_status_counts = {}
stage_parse_errors = []
for stage_path, manifest_entry, manifest_path in stage_entries:
actual = file_signature(stage_path)
expected_bytes = manifest_entry.get("bytes")
expected_sha = manifest_entry.get("sha256")
stage_before.append({
**actual,
"expected_bytes": expected_bytes,
"expected_sha256": expected_sha,
"bytes_match": expected_bytes in (None, actual["bytes"]),
"sha256_match": expected_sha in (None, actual["sha256"]),
"manifest_path": manifest_path,
})
with stage_path.open(encoding="utf-8") as stream:
for line_number, line in enumerate(stream, 1):
try:
row = json.loads(line)
except Exception as exc:
stage_parse_errors.append({"path": str(stage_path), "line": line_number, "error": str(exc)})
continue
status = text(row.get("status")) or "missing"
stage_status_counts[status] = stage_status_counts.get(status, 0) + 1
if status != "accepted":
continue
key = stage_key(row)
business_key = row.get("business_key") or {}
college = text(business_key.get("college"))
source_row = row.get("source_row") or {}
source_row_college_fields = []
for field_name in ("resolved_college", "source_college", "verified_college_scope"):
field_value = text(source_row.get(field_name))
if field_value:
source_row_college_fields.append({"field": field_name, "value": field_value})
observation = {
"stage_path": str(stage_path),
"stage_line": line_number,
"manifest_path": manifest_path,
"field_name": row.get("field_name"),
"college_raw": business_key.get("college"),
"college_nonblank": college,
"source_row_college_fields": source_row_college_fields,
"business_key": business_key,
"source_url": row.get("source_url"),
"source_sha256": row.get("sha256"),
"source_row_json_sha256": row.get("source_row_json_sha256"),
"source_year": row.get("source_year"),
"source_school": row.get("source_school"),
"source_school_code": row.get("source_school_code"),
"source_major_code": row.get("source_major_code"),
}
stage_rows_by_key.setdefault(key, []).append(observation)
overlay_rows = []
overlay_status_counts = {}
overlay_status_counts_by_year = {}
matched_stage_observations_by_path = {}
samples = {}
for row in queue_rows:
key = queue_key(row)
queue_sources = queue_by_key[key]
observations = stage_rows_by_key.get(key, [])
colleges = sorted({item["college_nonblank"] for item in observations if item["college_nonblank"]})
secondary_college_fields = []
for item in observations:
secondary_college_fields.extend(item.get("source_row_college_fields") or [])
secondary_colleges = sorted({item["value"] for item in secondary_college_fields})
has_blank_college = any(not item["college_nonblank"] for item in observations)
if not observations:
overlay_status = "unmatched_no_accepted_stage_exact_base_key"
elif not colleges:
overlay_status = "stage_base_key_present_college_blank"
elif len(colleges) > 1:
overlay_status = "candidate_ambiguous_college"
elif has_blank_college:
if len(secondary_colleges) > 1:
overlay_status = "candidate_ambiguous_secondary_source_college"
elif len(secondary_colleges) == 1:
overlay_status = "candidate_secondary_source_college"
elif colleges:
overlay_status = "candidate_unique_college_with_blank_stage_variant"
else:
overlay_status = "stage_base_key_present_college_blank"
else:
overlay_status = "candidate_unique_college"
overlay_status_counts[overlay_status] = overlay_status_counts.get(overlay_status, 0) + 1
year_counts = overlay_status_counts_by_year.setdefault(key[0], {})
year_counts[overlay_status] = year_counts.get(overlay_status, 0) + 1
for observation in observations:
path_count = matched_stage_observations_by_path.setdefault(observation["stage_path"], 0)
matched_stage_observations_by_path[observation["stage_path"]] = path_count + 1
sample = {
"queue_line": queue_sources[0]["queue_line"],
"base_key": {"year": key[0], "school_code": key[1], "major_code": key[2]},
"school": row.get("school"),
"major_name": row.get("major_name"),
"overlay_status": overlay_status,
"candidate_college_values": colleges,
"secondary_source_college_values": secondary_colleges,
"stage_observation_count": len(observations),
}
samples.setdefault(overlay_status, [])
if len(samples[overlay_status]) < 5:
samples[overlay_status].append(sample)
overlay_rows.append({
"queue_line": queue_sources[0]["queue_line"],
"base_key": {"year": key[0], "school_code": key[1], "major_code": key[2]},
"school": row.get("school"),
"major_name": row.get("major_name"),
"queue_source_type": (row.get("source") or {}).get("source_type"),
"queue_source_url": (row.get("source") or {}).get("source_url"),
"queue_raw_path": (row.get("source") or {}).get("raw_path"),
"queue_sha256": (row.get("source") or {}).get("sha256"),
"queue_source_page_sha256": (row.get("source") or {}).get("source_page_sha256"),
"queue_source_locators": (row.get("locator") or {}).get("source_locators"),
"overlay_status": overlay_status,
"candidate_college_values": colleges,
"secondary_source_college_values": secondary_colleges,
"stage_observation_count": len(observations),
"stage_observations": observations,
})
queue_after = file_signature(QUEUE)
queue_manifest_after = file_signature(QUEUE_MANIFEST)
stage_after = [file_signature(item[0]) for item in stage_entries]
stage_signature_stable = all(
before["bytes"] == after["bytes"] and before["sha256"] == after["sha256"]
for before, after in zip(stage_before, stage_after)
)
checks = {
"queue_rows_equal_manifest": len(queue_rows) == json.loads(QUEUE_MANIFEST.read_text(encoding="utf-8"))["output"]["rows"],
"queue_keys_complete": all(all(key_part for key_part in queue_key(row)) for row in queue_rows),
"all_stage_files_exist_and_match_manifest": all(item["bytes_match"] and item["sha256_match"] for item in stage_before),
"stage_parse_errors_zero": not stage_parse_errors,
"accepted_stage_rows_counted_only": sum(stage_status_counts.get("accepted", 0) for _ in [0]) == sum(len(rows) for rows in stage_rows_by_key.values()),
"overlay_rows_equal_queue_rows": len(overlay_rows) == len(queue_rows),
"queue_input_stable": queue_before == queue_after,
"queue_manifest_stable": queue_manifest_before == queue_manifest_after,
"stage_inputs_stable": stage_signature_stable,
"no_production_database_read": True,
"no_production_writer_invoked": True,
"no_registry_written": True,
"no_stage_written": True,
"no_college_identity_promoted": True,
}
base_check_count = len(checks)
base_pass_count = sum(checks.values())
checks["all_pass"] = base_pass_count == base_check_count
checks["pass"] = base_pass_count
checks["total"] = base_check_count
ended = datetime.datetime.now(datetime.timezone.utc)
OUT_DIR.mkdir(parents=True, exist_ok=True)
with OVERLAY.open("w", encoding="utf-8") as stream:
for row in overlay_rows:
stream.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
report = {
"schema": "r134_s1_college_residual_stage_overlay.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_STAGE_OVERLAY",
"verdict": "PASS_READONLY_EXACT_BASE_KEY_OVERLAY_WITH_AMBIGUITY_AND_UNMATCHED",
"generated_at_local": ended.astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": ended.isoformat(),
"read_only": True,
"scope": {
"queue_rows": len(queue_rows),
"queue_unique_base_keys": len(queue_by_key),
"stage_manifest_count": len(MANIFESTS),
"stage_file_count": len(stage_entries),
"stage_rows_read": sum(stage_status_counts.values()),
"accepted_stage_rows_read": sum(len(rows) for rows in stage_rows_by_key.values()),
"matching_key": "exact stripped (year, school_code, major_code); no school-name or major-name fallback",
"college_candidate_source": "accepted stage business_key.college only; retained as candidate evidence",
},
"input_artifacts": {
"queue": {**queue_before, "after": queue_after},
"queue_manifest": {**queue_manifest_before, "after": queue_manifest_after},
"partial_version_manifests": manifest_meta,
"stage_files_before": stage_before,
"stage_files_after": stage_after,
},
"stage_status_counts": stage_status_counts,
"overlay_status_counts": overlay_status_counts,
"overlay_status_counts_by_year": overlay_status_counts_by_year,
"matched_stage_observations_by_path": matched_stage_observations_by_path,
"samples": samples,
"checks": checks,
"write_boundary": {
"production_database_read": False,
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"new_stage_written": False,
"college_identity_promoted": False,
},
"output": {
"overlay_jsonl": str(OVERLAY),
"overlay_bytes": OVERLAY.stat().st_size,
"overlay_sha256": sha256_file(OVERLAY),
"rows": len(overlay_rows),
},
"interpretation": [
"A candidate_college value is an exact base-key overlay from an already accepted local stage row; it is not a verified national college identity and is not written to the target ledger or production database.",
"Multiple college values, blank variants and missing exact base keys remain separately classified; no value is selected by similarity or frequency.",
"The accepted stage rows are heterogeneous source scopes and may be third-party or historical; source tier and locator are retained per observation for later evidence review.",
"The overlay covers only the four existing partial-version stage inputs and cannot establish national college denominator or unresolved years without a matching stage row.",
],
"next_action": "Review candidate_unique_college and candidate_unique_college_with_blank_stage_variant rows against their source locators and official year-specific scope before any college queue update. Keep candidate_ambiguous_college and unmatched rows unresolved; do not promote this overlay to production keys or call execute=True.",
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.parent.mkdir(parents=True, exist_ok=True)
LOG.write_text(
"\n".join([
f"generated_at_local={report['generated_at_local']}",
f"status={report['status']}",
f"verdict={report['verdict']}",
f"queue_rows={len(queue_rows)} stage_rows={sum(stage_status_counts.values())} accepted_stage_rows={sum(len(rows) for rows in stage_rows_by_key.values())}",
f"overlay_status_counts={json.dumps(overlay_status_counts, ensure_ascii=False, sort_keys=True)}",
f"checks_pass={checks['pass']}/{checks['total']} all_pass={checks['all_pass']}",
f"queue_input_stable={checks['queue_input_stable']} stage_inputs_stable={checks['stage_inputs_stable']}",
"write_boundary=database_read:false database_written:false writer_invoked:false registry_written:false stage_written:false college_identity_promoted:false",
f"report={REPORT}",
f"overlay={OVERLAY}",
]) + "\n",
encoding="utf-8",
)
print(json.dumps({
"report": str(REPORT),
"report_sha256": sha256_file(REPORT),
"log": str(LOG),
"log_sha256": sha256_file(LOG),
"overlay": str(OVERLAY),
"overlay_sha256": sha256_file(OVERLAY),
"status": report["status"],
"verdict": report["verdict"],
"checks": checks,
"overlay_status_counts": overlay_status_counts,
}, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()
@@ -0,0 +1,208 @@
from __future__ import annotations
import datetime as dt
import json
import sys
from collections import Counter, defaultdict
from pathlib import Path
HELPER_DIR = Path(r"D:\择校\运行暂存\scripts")
if str(HELPER_DIR) not in sys.path:
sys.path.insert(0, str(HELPER_DIR))
import r134_s1_college_residual_verified_sample_parse_audit_20261015 as sample # noqa: E402
QUEUE = sample.QUEUE
FETCH_MANIFEST = sample.FETCH_MANIFEST
FETCH_DIR = sample.FETCH_DIR
SAMPLE_MANIFEST = sample.SAMPLE_MANIFEST
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_verified_full_parse_audit_20261015")
REPORT = OUT_DIR / "report.json"
DETAILS = OUT_DIR / "full_parse.jsonl"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_verified_full_parse_audit_20261015.log")
def text(value):
return "" if value is None else str(value).strip()
def load_jsonl(path):
with path.open("r", encoding="utf-8") as stream:
return [json.loads(line) for line in stream if line.strip()]
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
queue_rows = load_jsonl(QUEUE)
queue_by_url = defaultdict(list)
for row in queue_rows:
source_urls = [piece.strip() for piece in text(row.get("source", {}).get("source_url")).split("|") if piece.strip()]
for source_url in source_urls:
try:
queue_by_url[sample.normalize_url(source_url)].append(row)
except ValueError:
continue
manifest_rows = load_jsonl(FETCH_MANIFEST)
verified_rows = [
row
for row in manifest_rows
if row.get("status") == "fetched" and row.get("expected_sha256_match") is True and text(row.get("artifact_path"))
]
verified_rows.sort(key=lambda row: (text((row.get("years") or [""])[0]), text(row.get("url"))))
sample_urls = set()
if SAMPLE_MANIFEST.is_file():
sample_urls = {
sample.normalize_url(text(row.get("url")))
for row in load_jsonl(SAMPLE_MANIFEST)
if text(row.get("url"))
}
errors = []
records = []
for row in verified_rows:
url = text(row.get("url"))
artifact = (FETCH_DIR / text(row.get("artifact_path"))).resolve(strict=False)
try:
artifact.relative_to(FETCH_DIR.resolve())
except ValueError as exc:
errors.append({"url": url, "error": "artifact_outside_fetch_dir", "detail": str(exc)})
continue
if not artifact.is_file():
errors.append({"url": url, "error": "artifact_missing", "path": str(artifact)})
continue
before = sample.signature(artifact)
targets = queue_by_url.get(sample.normalize_url(url), [])
target_codes, target_names_by_code, target_school_names = sample.target_scope(targets)
file_signature = sample.classify_file(artifact)
try:
if file_signature == "pdf":
parsed = sample.parse_pdf(artifact, target_codes, target_names_by_code, target_school_names)
elif file_signature == "xlsx_or_zip":
parsed = sample.parse_xlsx(artifact, target_codes, target_names_by_code, target_school_names)
elif file_signature == "html":
parsed = sample.parse_html(artifact, target_codes, target_names_by_code, target_school_names)
else:
parsed = {"signature": file_signature, "all_hits": 0, "target_code_hits": 0, "visual_review_pages": []}
except Exception as exc:
errors.append({"url": url, "error": "full_parse_error", "detail": f"{type(exc).__name__}: {exc}"})
parsed = {"signature": file_signature, "all_hits": 0, "target_code_hits": 0, "visual_review_pages": [], "parse_error": str(exc)}
after = sample.signature(artifact)
records.append(
{
"url": url,
"years": row.get("years") or [],
"source_types": row.get("source_types") or [],
"artifact_path": str(artifact),
"file_signature": file_signature,
"expected_sha256_candidates": row.get("expected_sha256_candidates") or [],
"actual_sha256": text(row.get("sha256")).lower(),
"expected_sha256_match": row.get("expected_sha256_match") is True,
"target_queue_rows": len(targets),
"target_major_codes": target_codes,
"target_major_names_by_code": target_names_by_code,
"target_school_names": target_school_names,
"sample_already_parsed": sample.normalize_url(url) in sample_urls,
"artifact_before": before,
"artifact_after": after,
"artifact_stable": before == after,
"parsed": parsed,
"accepted": False,
"stage_written": False,
}
)
DETAILS.write_text(
"\n".join(json.dumps(record, ensure_ascii=False, sort_keys=True) for record in records) + "\n",
encoding="utf-8",
)
status_by_signature = Counter(record["file_signature"] for record in records)
year_counts = Counter(text((record["years"] or [""])[0]) for record in records)
source_type_counts = Counter(
source_type
for record in records
for source_type in record.get("source_types", [])
)
target_code_hit_jobs = sum(record["parsed"].get("target_code_hits", 0) > 0 for record in records)
college_scope_jobs = sum(record["parsed"].get("college_scope_candidate_hit_count", 0) > 0 for record in records)
school_header_jobs = sum(record["parsed"].get("school_header_candidate_hit_count", 0) > 0 for record in records)
report = {
"schema": "r134_s1_college_residual_verified_full_parse_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_VERIFIED_FULL_PARSE",
"verdict": "PASS_READONLY_FULL_PARSE_OF_EXACT_HASH_JOBS_WITH_CANDIDATES_UNPROMOTED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"queue_rows": len(queue_rows),
"fetch_manifest_rows": len(manifest_rows),
"verified_hash_jobs": len(verified_rows),
"parsed_jobs": len(records),
"new_jobs_since_sample": sum(not record["sample_already_parsed"] for record in records),
"target_code_hit_jobs": target_code_hit_jobs,
"jobs_with_college_scope_candidates": college_scope_jobs,
"jobs_with_school_header_candidates": school_header_jobs,
"parse_errors": sum("parse_error" in record["parsed"] for record in records),
"accepted_source_rows": 0,
"stage_rows": 0,
},
"year_counts": dict(sorted(year_counts.items())),
"source_type_counts": dict(sorted(source_type_counts.items())),
"file_signature_counts": dict(sorted(status_by_signature.items())),
"checks": {
"all_verified_jobs_parsed": len(records) == len(verified_rows),
"all_expected_sha_match": all(record["expected_sha256_match"] for record in records),
"all_artifacts_stable": all(record["artifact_stable"] for record in records),
"all_jobs_have_queue_rows": all(record["target_queue_rows"] > 0 for record in records),
"no_parse_errors": not errors,
"accepted_rows_zero": all(not record["accepted"] for record in records),
"stage_rows_zero": all(not record["stage_written"] for record in records),
"production_write_false": True,
"all_structural_checks_pass": not errors and len(records) == len(verified_rows) and all(record["expected_sha256_match"] and record["artifact_stable"] and record["target_queue_rows"] > 0 for record in records),
},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"This report parses exact-hash bodies only; 63 HTTP/error/hash-mismatch jobs remain outside the parsed set.",
"College candidates are parser observations with locators, not accepted production scope; school headers are explicitly separated.",
"No candidate stage, fact/evidence promotion or writer call was performed.",
],
"errors": errors,
"output_artifacts": {"report": str(REPORT), "details": str(DETAILS), "log": str(LOG)},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"verified_hash_jobs={len(verified_rows)}",
f"parsed_jobs={len(records)}",
f"new_jobs_since_sample={report['scope']['new_jobs_since_sample']}",
f"target_code_hit_jobs={target_code_hit_jobs}",
f"jobs_with_college_scope_candidates={college_scope_jobs}",
f"jobs_with_school_header_candidates={school_header_jobs}",
f"parse_errors={len(errors)}",
"accepted_source_rows=0",
"stage_rows=0",
"production_database_written=false",
"production_writer_invoked=false",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,458 @@
from __future__ import annotations
import csv
import datetime as dt
import hashlib
import json
import re
import sys
import urllib.parse
from collections import Counter, defaultdict
from html.parser import HTMLParser
from pathlib import Path
WORKSPACE_ROOT = Path(r"D:\择校\脚本\工作区\考研择校")
if str(WORKSPACE_ROOT) not in sys.path:
sys.path.insert(0, str(WORKSPACE_ROOT))
from scripts.audit_kaoyan365_attachment_yield_20261010 import ( # noqa: E402
CATALOG_RE,
COLLEGE_CATALOG_HEADING_RE,
COLLEGE_NAME_LINE_RE,
SIX_DIGIT_RE,
_extract_xlsx,
iter_pdf_hits,
iter_pdf_pages,
)
QUEUE = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_queue_20261015\residual_queue.jsonl")
FETCH_MANIFEST = Path(r"D:\择校\运行暂存\batches\R134_S1_college_residual_official_fetch_20261015\fetch_manifest.jsonl")
FETCH_DIR = FETCH_MANIFEST.parent
OUT_DIR = Path(r"D:\择校\运行暂存\reports\R134_S1_college_residual_verified_sample_parse_audit_20261015")
REPORT = OUT_DIR / "report.json"
SAMPLE_MANIFEST = OUT_DIR / "sample_manifest.jsonl"
LOG = Path(r"D:\择校\运行暂存\logs\R134_S1_college_residual_verified_sample_parse_audit_20261015.log")
MAX_PER_GROUP = 1
MAX_SAMPLES = 12
def text(value):
return "" if value is None else str(value).strip()
def compact(value):
return re.sub(r"\s+", "", text(value))
def normalize_url(value):
raw = text(value)
parts = urllib.parse.urlsplit(raw)
if parts.scheme.lower() not in {"http", "https"} or not parts.netloc:
raise ValueError(f"source URL must be absolute HTTP(S): {raw!r}")
hostname = parts.hostname
if not hostname:
raise ValueError(f"source URL has no host: {raw!r}")
encoded_host = hostname.encode("idna").decode("ascii")
userinfo = ""
if "@" in parts.netloc:
raw_userinfo = parts.netloc.rsplit("@", 1)[0]
userinfo = urllib.parse.quote(raw_userinfo, safe=":%@") + "@"
netloc = f"{userinfo}{encoded_host}"
if parts.port is not None:
netloc += f":{parts.port}"
path = urllib.parse.quote(parts.path, safe="/%:@!$&'()*+,;=-._~")
query = urllib.parse.quote(parts.query, safe="/%?:@!$&'()*+,;=-._~[]")
return urllib.parse.urlunsplit((parts.scheme.lower(), netloc, path, query, ""))
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def signature(path):
stat = path.stat()
return {"path": str(path), "bytes": stat.st_size, "sha256": sha256_file(path)}
def load_jsonl(path):
with path.open("r", encoding="utf-8") as stream:
return [json.loads(line) for line in stream if line.strip()]
class VisibleTextParser(HTMLParser):
def __init__(self):
super().__init__(convert_charrefs=True)
self.parts = []
self.skip_depth = 0
def handle_starttag(self, tag, attrs):
if tag.lower() in {"script", "style", "noscript", "template"}:
self.skip_depth += 1
def handle_endtag(self, tag):
if tag.lower() in {"script", "style", "noscript", "template"} and self.skip_depth:
self.skip_depth -= 1
def handle_data(self, data):
if self.skip_depth:
return
value = re.sub(r"\s+", " ", data).strip()
if value:
self.parts.append(value)
def decode_html(data):
for encoding in ("utf-8", "gb18030"):
try:
return data.decode(encoding), encoding
except UnicodeDecodeError:
continue
return data.decode("utf-8", errors="replace"), "utf-8-replace"
def classify_file(path):
with path.open("rb") as stream:
prefix = stream.read(16)
if prefix.startswith(b"%PDF-"):
return "pdf"
if prefix.startswith(b"PK\x03\x04"):
return "xlsx_or_zip"
return "html"
def target_rows_for_url(queue_by_url, url):
try:
key = normalize_url(url)
except ValueError:
return []
return queue_by_url.get(key, [])
def target_scope(rows):
codes = sorted({text(row.get("base_key", {}).get("major_code")) for row in rows if text(row.get("base_key", {}).get("major_code"))})
names_by_code = defaultdict(set)
school_names = set()
for row in rows:
code = text(row.get("base_key", {}).get("major_code"))
name = text(row.get("major_name"))
school = text(row.get("school"))
if school:
school_names.add(school)
if code and name:
names_by_code[code].add(name)
return codes, {code: sorted(names) for code, names in names_by_code.items()}, sorted(school_names)
def code_name_summary(hits, target_codes, target_names_by_code, target_school_names):
target_code_set = set(target_codes)
matched = [hit for hit in hits if text(hit.get("code")) in target_code_set]
exact_name_matches = 0
for hit in matched:
code = text(hit.get("code"))
candidate = compact(hit.get("major_name_candidate"))
expected = {compact(name) for name in target_names_by_code.get(code, [])}
if candidate and candidate in expected:
exact_name_matches += 1
college_values = sorted({text(hit.get("college_candidate")) for hit in matched if text(hit.get("college_candidate"))})
school_header_values = sorted(
{
value
for value in college_values
if any(compact(value) == compact(school) for school in target_school_names)
}
)
college_scope_values = [value for value in college_values if value not in school_header_values]
return {
"all_hits": len(hits),
"target_code_hits": len(matched),
"target_code_values": sorted({text(hit.get("code")) for hit in matched}),
"target_code_exact_name_hits": exact_name_matches,
"college_candidate_values": college_values,
"college_candidate_hit_count": sum(bool(text(hit.get("college_candidate"))) for hit in matched),
"school_header_candidate_values": school_header_values,
"school_header_candidate_hit_count": sum(
any(compact(text(hit.get("college_candidate"))) == compact(school) for school in target_school_names)
for hit in matched
if text(hit.get("college_candidate"))
),
"college_scope_candidate_values": college_scope_values,
"college_scope_candidate_hit_count": sum(
bool(text(hit.get("college_candidate")))
and not any(compact(text(hit.get("college_candidate"))) == compact(school) for school in target_school_names)
for hit in matched
),
"target_hit_locators": [
{
"code": text(hit.get("code")),
"major_name_candidate": text(hit.get("major_name_candidate")),
"college_candidate": text(hit.get("college_candidate")),
"locator": text(hit.get("locator")),
"line_number": hit.get("line_number"),
}
for hit in matched[:50]
],
}
def parse_pdf(path, target_codes, target_names_by_code, target_school_names):
hits = list(iter_pdf_hits(path))
page_count = sum(1 for _ in iter_pdf_pages(path))
summary = code_name_summary(hits, target_codes, target_names_by_code, target_school_names)
summary.update(
{
"signature": "pdf",
"row_unit": "page",
"row_count": page_count,
"visual_review_pages": sorted({1, max(1, (page_count + 1) // 2), max(1, page_count)}),
}
)
return summary
def parse_xlsx(path, target_codes, target_names_by_code, target_school_names):
extracted = _extract_xlsx(path)
summary = code_name_summary(extracted["hits"], target_codes, target_names_by_code, target_school_names)
summary.update(
{
"signature": "xlsx_or_zip",
"row_unit": extracted.get("row_unit"),
"row_count": extracted.get("row_count"),
"visual_review_pages": [],
}
)
return summary
def parse_html(path, target_codes, target_names_by_code, target_school_names):
raw = path.read_bytes()
decoded, encoding = decode_html(raw)
parser = VisibleTextParser()
parser.feed(decoded)
parser.close()
lines = parser.parts
hits = []
current_college = ""
target_code_set = set(target_codes)
for index, line in enumerate(lines, start=1):
heading = COLLEGE_CATALOG_HEADING_RE.match(line)
if heading:
current_college = heading.group("college").strip()
elif index < len(lines) and CATALOG_RE.search(lines[index]):
college_line = COLLEGE_NAME_LINE_RE.fullmatch(line)
if college_line:
current_college = college_line.group("college").strip()
for match in SIX_DIGIT_RE.finditer(line):
code = match.group(1)
if code not in target_code_set:
continue
candidate = re.split(r"\s{2,}|[||]", line[match.end():].strip(), maxsplit=1)[0].strip(" -::")
hits.append(
{
"code": code,
"major_name_candidate": candidate,
"college_candidate": current_college,
"locator": f"visible_line:{index}",
"line_number": index,
}
)
summary = code_name_summary(hits, target_codes, target_names_by_code, target_school_names)
summary.update(
{
"signature": "html",
"row_unit": "visible_text_part",
"row_count": len(lines),
"visible_text_encoding": encoding,
"catalog_token_present": any(CATALOG_RE.search(line) for line in lines),
"visual_review_pages": [],
}
)
return summary
def main():
OUT_DIR.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
started = dt.datetime.now(dt.timezone.utc)
queue_rows = load_jsonl(QUEUE)
queue_by_url = defaultdict(list)
for row in queue_rows:
source_urls = [piece.strip() for piece in text(row.get("source", {}).get("source_url")).split("|") if piece.strip()]
for source_url in source_urls:
try:
queue_by_url[normalize_url(source_url)].append(row)
except ValueError:
continue
manifest_rows = load_jsonl(FETCH_MANIFEST)
verified_rows = [
row
for row in manifest_rows
if row.get("status") == "fetched" and row.get("expected_sha256_match") is True and text(row.get("artifact_path"))
]
verified_rows.sort(key=lambda row: (text((row.get("years") or [""])[0]), text(row.get("url"))))
groups = defaultdict(list)
for row in verified_rows:
artifact = FETCH_DIR / text(row.get("artifact_path"))
signature_name = classify_file(artifact) if artifact.is_file() else "missing"
source_types = sorted({text(value) for value in row.get("source_types", []) if text(value)})
source_bucket = "multi_source" if len(source_types) > 1 else (source_types[0] if source_types else "unknown")
year = text((row.get("years") or [""])[0])
groups[(year, source_bucket, signature_name)].append((row, signature_name))
selected = []
for group_key in sorted(groups):
selected.extend(groups[group_key][:MAX_PER_GROUP])
if len(selected) >= MAX_SAMPLES:
break
selected = selected[:MAX_SAMPLES]
errors = []
records = []
for row, signature_name in selected:
artifact = (FETCH_DIR / text(row.get("artifact_path"))).resolve(strict=False)
try:
artifact.relative_to(FETCH_DIR.resolve())
except ValueError as exc:
errors.append({"url": text(row.get("url")), "error": "artifact_outside_fetch_dir", "detail": str(exc)})
continue
before = signature(artifact)
targets = target_rows_for_url(queue_by_url, text(row.get("url")))
target_codes, target_names_by_code, target_school_names = target_scope(targets)
try:
if signature_name == "pdf":
parsed = parse_pdf(artifact, target_codes, target_names_by_code, target_school_names)
elif signature_name == "xlsx_or_zip":
parsed = parse_xlsx(artifact, target_codes, target_names_by_code, target_school_names)
elif signature_name == "html":
parsed = parse_html(artifact, target_codes, target_names_by_code, target_school_names)
else:
parsed = {"signature": signature_name, "all_hits": 0, "target_code_hits": 0, "visual_review_pages": []}
except Exception as exc:
errors.append({"url": text(row.get("url")), "error": "sample_parse_error", "detail": f"{type(exc).__name__}: {exc}"})
parsed = {"signature": signature_name, "all_hits": 0, "target_code_hits": 0, "visual_review_pages": [], "parse_error": str(exc)}
after = signature(artifact)
records.append(
{
"url": text(row.get("url")),
"years": row.get("years") or [],
"source_types": row.get("source_types") or [],
"artifact_path": str(artifact),
"expected_sha256_candidates": row.get("expected_sha256_candidates") or [],
"actual_sha256": text(row.get("sha256")).lower(),
"expected_sha256_match": row.get("expected_sha256_match") is True,
"target_queue_rows": len(targets),
"target_major_codes": target_codes,
"target_major_names_by_code": target_names_by_code,
"target_school_names": target_school_names,
"group": "|".join((text((row.get("years") or [""])[0]), "multi_source" if len(row.get("source_types") or []) > 1 else text((row.get("source_types") or ["unknown"])[0]), signature_name)),
"artifact_before": before,
"artifact_after": after,
"artifact_stable": before == after,
"parsed": parsed,
"accepted": False,
"stage_written": False,
}
)
sample_manifest_rows = [
{
"url": record["url"],
"years": record["years"],
"source_types": record["source_types"],
"artifact_path": record["artifact_path"],
"target_major_codes": record["target_major_codes"],
"visual_review_pages": record["parsed"].get("visual_review_pages", []),
}
for record in records
]
SAMPLE_MANIFEST.write_text(
"\n".join(json.dumps(row, ensure_ascii=False, sort_keys=True) for row in sample_manifest_rows) + "\n",
encoding="utf-8",
)
selected_groups = Counter(record["group"] for record in records)
parse_error_count = sum("parse_error" in record["parsed"] for record in records)
target_code_hit_count = sum(record["parsed"].get("target_code_hits", 0) > 0 for record in records)
college_evidence_count = sum(record["parsed"].get("college_scope_candidate_hit_count", 0) > 0 for record in records)
report = {
"schema": "r134_s1_college_residual_verified_sample_parse_audit.v1",
"status": "PARTIAL_COLLEGE_RESIDUAL_VERIFIED_SAMPLE_PARSE",
"verdict": "PASS_READONLY_VERIFIED_SAMPLE_PARSE_WITH_COLLEGE_CANDIDATES_UNPROMOTED",
"generated_at_local": dt.datetime.now().astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
"read_only": True,
"scope": {
"queue_rows": len(queue_rows),
"fetch_manifest_rows": len(manifest_rows),
"verified_hash_jobs": len(verified_rows),
"sample_rows": len(records),
"sample_groups": len(selected_groups),
"sample_target_code_hit_files": target_code_hit_count,
"sample_files_with_college_candidates": college_evidence_count,
"sample_files_with_raw_college_candidates": sum(record["parsed"].get("college_candidate_hit_count", 0) > 0 for record in records),
"sample_files_with_school_header_candidates": sum(record["parsed"].get("school_header_candidate_hit_count", 0) > 0 for record in records),
"sample_parse_errors": parse_error_count,
"accepted_source_rows": 0,
"stage_rows": 0,
},
"selected_groups": dict(sorted(selected_groups.items())),
"records": records,
"checks": {
"verified_jobs_available": len(verified_rows) >= len(records),
"sample_has_at_least_five_files": len(records) >= 5,
"sample_groups_cover_all_available_groups": set(selected_groups) == set(
"|".join((key[0], key[1], key[2])) for key in sorted(groups)
),
"all_expected_sha_match": all(record["expected_sha256_match"] for record in records),
"all_artifacts_stable": all(record["artifact_stable"] for record in records),
"no_parse_errors": not errors,
"accepted_rows_zero": all(not record["accepted"] for record in records),
"stage_rows_zero": all(not record["stage_written"] for record in records),
"production_write_false": True,
"all_structural_checks_pass": not errors and len(records) >= 5 and all(record["expected_sha256_match"] and record["artifact_stable"] for record in records),
},
"write_boundary": {
"production_database_written": False,
"production_writer_invoked": False,
"registry_written": False,
"stage_written": False,
"college_candidate_promoted": False,
},
"limitations": [
"This is a stratified source sample, not full 58-job content closure; college candidates remain audit observations only.",
"PDF visual review pages are listed in the sample manifest and must be rendered/inspected separately before any stage decision.",
"Exact code/name hits and parser college candidates do not by themselves establish a production college scope without row-level locator and manual review.",
],
"errors": errors,
"output_artifacts": {"report": str(REPORT), "sample_manifest": str(SAMPLE_MANIFEST), "log": str(LOG)},
}
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join(
[
f"status={report['status']}",
f"verdict={report['verdict']}",
f"verified_hash_jobs={len(verified_rows)}",
f"sample_rows={len(records)}",
f"sample_groups={len(selected_groups)}",
f"sample_target_code_hit_files={target_code_hit_count}",
f"sample_files_with_college_candidates={college_evidence_count}",
f"sample_parse_errors={parse_error_count}",
"accepted_source_rows=0",
"stage_rows=0",
"production_database_written=false",
"production_writer_invoked=false",
]
)
+ "\n",
encoding="utf-8",
)
if __name__ == "__main__":
main()
@@ -0,0 +1,510 @@
from pathlib import Path
import datetime
import hashlib
import json
import re
import sqlite3
REPORT = Path(r"D:\择校\运行暂存\reports\R134_S2_zhonggong_conflict_source_fact_reconciliation_20261015.json")
OUT = Path(r"D:\择校\运行暂存\reports\R134_S2_zhonggong_conflict_current_adapter_replay_20261015.json")
LOG = Path(r"D:\择校\运行暂存\logs\R134_S2_zhonggong_conflict_current_adapter_replay_20261015.log")
DB = Path(r"D:\择校\数据库\zexiao_2027.db")
FIELD_CONTRACT = Path(r"D:\择校\运行暂存\reports\zhonggong_source_field_contract_R134_20261014.json")
S40 = Path(r"D:\择校\staging\运行批次\parallel_sources\qoder_slot_fill_08_20260927\scripts\s40_parse_zhonggong.py")
UNIFIED = Path(r"D:\择校\脚本\工作区\考研择校\orchestrator\unified_ingest_20261003.py")
WRITER = Path(r"D:\择校\脚本\工作区\考研择校\orchestrator\production_writer_20261003.py")
def sha256_file(path):
digest = hashlib.sha256()
with path.open("rb") as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def file_signature(path, include_sha=True):
if not path.exists():
return {"exists": False}
stat = path.stat()
result = {
"exists": True,
"bytes": stat.st_size,
"mtime_ns": stat.st_mtime_ns,
}
if include_sha:
result["sha256"] = sha256_file(path)
return result
def canonical_json(value):
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
def normalize_value(value):
if value is None:
return None
if isinstance(value, str):
stripped = value.strip()
return stripped if stripped else None
if isinstance(value, dict):
return {str(key): normalize_value(item) for key, item in value.items()}
if isinstance(value, (list, tuple)):
return [normalize_value(item) for item in value]
if isinstance(value, float) and value != value:
return None
return value
def normalize_business_key(value):
return {str(key): normalize_value(item) for key, item in value.items()}
def norm(value):
return (value or "").strip()
def score(value):
text = norm(value)
if not text:
return None, ""
if re.fullmatch(r"\d+", text):
number = int(text)
return (None, text) if number == 0 else (number, text)
return None, text
def identity_key(business_key, field_name, normalized_value):
payload = {
"business_key": normalize_business_key(business_key),
"field": str(field_name).strip(),
"normalized_value": normalize_value(normalized_value),
}
return hashlib.sha256(canonical_json(payload).encode("utf-8")).hexdigest()
def writer_fact_payload(business_key, field_name, value, locator, source_sha):
key_payload = dict(business_key)
key_payload["field"] = str(field_name)
key_json = canonical_json(key_payload)
business_key_hash = hashlib.sha256(key_json.encode("utf-8")).hexdigest()
value_json = canonical_json(value)
fact_id = hashlib.sha256(
f"fact|{business_key_hash}|{value_json}".encode("utf-8")
).hexdigest()
locator_text = canonical_json(locator)
evidence_id = hashlib.sha256(
f"evidence|{fact_id}|{source_sha}|{locator_text}".encode("utf-8")
).hexdigest()
return {
"business_key": business_key_hash,
"key_json": key_json,
"value": value_json,
"fact_id": fact_id,
"evidence_id": evidence_id,
}
def sqlite_state(path):
state = {
"database": file_signature(path, include_sha=False),
"wal": file_signature(Path(str(path) + "-wal"), include_sha=False),
"shm": file_signature(Path(str(path) + "-shm"), include_sha=False),
}
with sqlite3.connect(f"file:{path.as_posix()}?mode=ro", uri=True, timeout=30) as conn:
conn.execute("PRAGMA query_only=ON")
state["pragma"] = {
"page_count": conn.execute("PRAGMA page_count").fetchone()[0],
"freelist_count": conn.execute("PRAGMA freelist_count").fetchone()[0],
"schema_version": conn.execute("PRAGMA schema_version").fetchone()[0],
"user_version": conn.execute("PRAGMA user_version").fetchone()[0],
}
return state
def query_exact(conn, business_key_hash, fact_id):
def select(sql, value):
return conn.execute(sql, (value,)).fetchall()
key_rows = select(
"SELECT fact_id,business_key,key_json,value,status,reason,batch_id "
"FROM global_facts WHERE business_key = ?",
business_key_hash,
)
fact_rows = select(
"SELECT fact_id,business_key,key_json,value,status,reason,batch_id "
"FROM global_facts WHERE fact_id = ?",
fact_id,
)
def as_dict(row):
return {
"fact_id": row[0],
"business_key": row[1],
"key_json": row[2],
"value": row[3],
"status": row[4],
"reason": row[5],
"batch_id": row[6],
}
return {
"business_key_rows": [as_dict(row) for row in key_rows],
"fact_id_rows": [as_dict(row) for row in fact_rows],
}
def main():
started = datetime.datetime.now(datetime.timezone.utc)
source_report_before = file_signature(REPORT)
source_data = json.loads(REPORT.read_text(encoding="utf-8"))
if source_data.get("scope", {}).get("selected_rows") != 27:
raise RuntimeError("authoritative source report is not the expected 27-row scope")
db_before = sqlite_state(DB)
rows = []
raw_replay_pass = 0
required_key_pass = 0
raw_sha_pass = 0
field_candidate_pass = 0
college_variance_count = 0
candidate_probes = []
historical_probes = []
candidate_fact_probes = []
historical_fact_probes = []
with sqlite3.connect(f"file:{DB.as_posix()}?mode=ro", uri=True, timeout=30) as conn:
conn.execute("PRAGMA query_only=ON")
for source_row in source_data["rows"]:
raw_path = Path(source_row["raw_page_path"])
raw_bytes = raw_path.read_bytes()
raw_sha = hashlib.sha256(raw_bytes).hexdigest()
raw_data = json.loads(raw_bytes.decode("utf-8-sig"))
raw_index = int(source_row["raw_page_row_number"])
raw_item = raw_data[raw_index]
parser_total, parser_total_raw = score(raw_item.get("score_all"))
parser_row = {
"record_type": "dept_major_line",
"recruit_year": int(norm(raw_item.get("year")) or 2024),
"source": "zhonggong",
"school_id_src": norm(raw_item.get("school_id")),
"school_name": norm(raw_item.get("school_name")),
"dept_code": norm(raw_item.get("faculty_id")),
"dept_name": norm(raw_item.get("faculty_name")),
"major_code": norm(raw_item.get("p_course_code")),
"major_name": norm(raw_item.get("p_name")),
"study_type": norm(raw_item.get("study_type")),
"total_line": parser_total,
"total_line_raw": parser_total_raw,
}
recovered = source_row["recovered_fact_archive"]
current_key = {
"year": parser_row["recruit_year"],
"school": parser_row["school_name"],
"major": parser_row["major_name"],
}
context_key = {
"school_code": recovered.get("school_code", ""),
"major_code": parser_row["major_code"],
"college_historical": recovered.get("college", ""),
"college_raw": parser_row["dept_name"],
"degree_type_historical": recovered.get("degree_type", ""),
"study_mode_historical": recovered.get("study_mode", ""),
}
required_complete = all(
current_key.get(key) not in (None, "")
for key in ("year", "school", "major")
)
raw_replay_matches = (
parser_row["recruit_year"] == int(norm(raw_item.get("year")) or 2024)
and parser_row["school_name"] == norm(raw_item.get("school_name"))
and parser_row["major_code"] == norm(raw_item.get("p_course_code"))
and parser_row["major_name"] == norm(raw_item.get("p_name"))
and parser_row["dept_name"] == norm(raw_item.get("faculty_name"))
and parser_row["total_line"] == parser_total
and parser_row["total_line_raw"] == parser_total_raw
)
raw_selected_matches = all(
str(raw_item.get(raw_key, "")) == str(source_row["raw_page_selected_fields"][report_key])
for raw_key, report_key in (
("school_id", "school_id"),
("year", "year"),
("p_course_code", "p_course_code"),
("school_name", "school_name"),
("score_all", "score_all"),
)
)
raw_sha_matches = raw_sha == source_row["source_sha256"] == source_row["raw_page_sha256"]
if raw_replay_matches and raw_selected_matches:
raw_replay_pass += 1
if required_complete:
required_key_pass += 1
if raw_sha_matches:
raw_sha_pass += 1
college_exact = source_row["raw_checks"].get("raw_college_exact_matches", False)
college_trimmed = source_row["raw_checks"].get("raw_college_trimmed_matches", False)
college_variance = not college_trimmed
if college_variance:
college_variance_count += 1
locator = {
"source_path": str(raw_path),
"row_number": raw_index,
"source_fact_id": source_row["source_fact_id"],
}
value_variants = [
{
"variant": "parser_numeric",
"source_value": parser_total,
"normalized_value": normalize_value(parser_total),
"value_type": type(parser_total).__name__,
},
{
"variant": "raw_score_all_string",
"source_value": parser_total_raw,
"normalized_value": normalize_value(parser_total_raw),
"value_type": type(parser_total_raw).__name__,
},
]
field_variants = [
{
"variant": "current_candidate",
"field_name": "total_retest_line",
"field_name_status": "candidate_only_not_production_verified",
"basis": "zhonggong_source_field_contract.total_retest_line",
},
{
"variant": "historical_recovered_fact",
"field_name": recovered.get("field", ""),
"field_name_status": "historical_reference_only_not_current_production_verified",
"basis": "archived_recovered_facts_and_legacy_adapter",
},
]
field_results = []
for field_variant in field_variants:
value_results = []
for value_variant in value_variants:
writer = writer_fact_payload(
current_key,
field_variant["field_name"],
value_variant["source_value"],
locator,
raw_sha,
)
identity = identity_key(
current_key,
field_variant["field_name"],
value_variant["source_value"],
)
probe = query_exact(conn, writer["business_key"], writer["fact_id"])
value_result = {
"value_variant": value_variant,
"identity_key_candidate": identity,
"writer_payload_candidate": writer,
"production_exact_probe": probe,
}
value_results.append(value_result)
if field_variant["variant"] == "current_candidate":
candidate_probes.append(probe)
candidate_fact_probes.append(probe["fact_id_rows"])
else:
historical_probes.append(probe)
historical_fact_probes.append(probe["fact_id_rows"])
field_results.append({**field_variant, "value_variants": value_results})
field_candidate_pass += all(
field["field_name_status"] in {
"candidate_only_not_production_verified",
"historical_reference_only_not_current_production_verified",
}
for field in field_variants
)
rows.append({
"source_fact_id": source_row["source_fact_id"],
"observation_id": source_row["observation_id"],
"source_url": source_row["source_url"],
"source_sha256": source_row["source_sha256"],
"raw_page": {
"path": str(raw_path),
"sha256_actual": raw_sha,
"row_number": raw_index,
"row_count": len(raw_data),
"selected_fields_replayed": {
"school_id": raw_item.get("school_id"),
"year": raw_item.get("year"),
"p_course_code": raw_item.get("p_course_code"),
"p_name": raw_item.get("p_name"),
"school_name": raw_item.get("school_name"),
"faculty_name": raw_item.get("faculty_name"),
"score_all": raw_item.get("score_all"),
},
},
"legacy_recovered_fact": {
"field": recovered.get("field"),
"data_item": recovered.get("data_item"),
"unit": recovered.get("unit"),
"unit_bound": recovered.get("unit_bound"),
"college": recovered.get("college"),
"major_code": recovered.get("major_code"),
"major_name": recovered.get("major_name"),
"source_layer": recovered.get("source_layer"),
"validation_status": recovered.get("validation_status"),
},
"pure_parser_replay": {
"implementation": "in_memory_reimplementation_of_s40_parse_zhonggong_pure_norm_and_score",
"record": parser_row,
"raw_selected_fields_match": raw_selected_matches,
"parser_output_match": raw_replay_matches,
"score_all_positive_or_null": parser_total is None or parser_total > 0,
},
"current_required_key_candidate": {
"business_key": current_key,
"complete_year_school_major": required_complete,
"status": "candidate_only_not_production_verified",
"context_dimensions_not_in_required_key": context_key,
},
"college_binding": {
"raw_faculty_name": parser_row["dept_name"],
"historical_college": recovered.get("college", ""),
"exact_match": college_exact,
"trimmed_match": college_trimmed,
"semantic_variance_retained": college_variance,
},
"field_and_value_candidates": field_results,
})
db_after = sqlite_state(DB)
source_report_after = file_signature(REPORT)
candidate_key_rows = sum(len(probe["business_key_rows"]) for probe in candidate_probes)
historical_key_rows = sum(len(probe["business_key_rows"]) for probe in historical_probes)
candidate_fact_rows = sum(len(rows_) for rows_ in candidate_fact_probes)
historical_fact_rows = sum(len(rows_) for rows_ in historical_fact_probes)
checks = {
"selected_row_count_is_27": len(rows) == 27,
"all_raw_pages_replayed_to_selected_fields": raw_replay_pass == 27,
"all_current_required_key_candidates_complete": required_key_pass == 27,
"all_raw_sha256_values_retained_and_match": raw_sha_pass == 27,
"all_field_candidates_explicitly_unverified": field_candidate_pass == 27,
"all_candidate_business_key_exact_probes_return_zero": candidate_key_rows == 0,
"all_historical_business_key_exact_probes_return_zero": historical_key_rows == 0,
"all_candidate_fact_id_exact_probes_return_zero": candidate_fact_rows == 0,
"all_historical_fact_id_exact_probes_return_zero": historical_fact_rows == 0,
"one_college_semantic_variance_retained": college_variance_count == 1,
"source_report_unchanged": source_report_before == source_report_after,
"database_state_unchanged": db_before == db_after,
"no_stage_write": True,
"no_registry_write": True,
"no_production_writer_execute": True,
}
base_check_count = len(checks)
base_pass_count = sum(checks.values())
checks["all_pass"] = base_pass_count == base_check_count
checks["pass"] = base_pass_count
checks["total"] = base_check_count
ended = datetime.datetime.now(datetime.timezone.utc)
result = {
"schema": "r134_s2_zhonggong_current_adapter_replay.v1",
"status": "PARTIAL_ZHONGGONG_CURRENT_ADAPTER_REPLAY",
"verdict": "PASS_READONLY_27_ROW_IN_MEMORY_PARSER_AND_KEY_PROBE_WITH_PRODUCTION_MAPPING_GAP",
"generated_at_local": ended.astimezone().isoformat(),
"started_at_utc": started.isoformat(),
"ended_at_utc": ended.isoformat(),
"read_only": True,
"scope": {
"authoritative_source_report": str(REPORT),
"selected_rows": len(rows),
"replay_mode": "pure in-memory replay; no parser main() and no writer execute()",
"purpose": "derive current candidate year/school/major, field/value variants, identity and production hashes, then exact read-only global_facts probes",
},
"input_artifacts": {
"source_reconciliation_report": {"path": str(REPORT), **source_report_before},
"source_field_contract": {"path": str(FIELD_CONTRACT), "sha256": sha256_file(FIELD_CONTRACT), "bytes": FIELD_CONTRACT.stat().st_size},
"s40_parser_script": {"path": str(S40), "sha256": sha256_file(S40), "bytes": S40.stat().st_size},
"current_unified_ingest_script": {"path": str(UNIFIED), "sha256": sha256_file(UNIFIED), "bytes": UNIFIED.stat().st_size},
"current_production_writer_script": {"path": str(WRITER), "sha256": sha256_file(WRITER), "bytes": WRITER.stat().st_size},
},
"current_contract_replay": {
"required_business_keys": ["year", "school", "major"],
"candidate_business_key_dimensions": "year from parser int; school from raw school_name; major from raw p_name; historical code/college/degree/mode retained only as context",
"candidate_field_name": "total_retest_line",
"candidate_field_name_status": "candidate_only_not_production_verified",
"historical_field_name": "院系线/总分",
"historical_field_mapping_status": "exactly_bound_to_27_archived_rows",
"value_variants": ["parser_numeric", "raw_score_all_string"],
"normalizer_behavior": "current normalize_value strips strings and does not coerce numeric-looking strings",
"production_business_key_probe_column": "global_facts.business_key",
"production_fact_probe_columns": ["global_facts.fact_id", "global_facts.business_key"],
},
"observed_counts": {
"rows": len(rows),
"pure_parser_replay_pass": raw_replay_pass,
"required_key_candidate_complete": required_key_pass,
"raw_sha_match": raw_sha_pass,
"field_candidate_explicitly_unverified": field_candidate_pass,
"current_candidate_business_key_exact_matches": candidate_key_rows,
"historical_field_business_key_exact_matches": historical_key_rows,
"current_candidate_fact_id_exact_matches": candidate_fact_rows,
"historical_field_fact_id_exact_matches": historical_fact_rows,
"college_exact_match": sum(row["college_binding"]["exact_match"] for row in rows),
"college_trimmed_match": sum(row["college_binding"]["trimmed_match"] for row in rows),
"college_semantic_variance": college_variance_count,
"score_all_nonnull_positive": sum(row["pure_parser_replay"]["score_all_positive_or_null"] for row in rows),
},
"checks": checks,
"db_runtime_state": {"before": db_before, "after": db_after},
"write_boundary": {
"production_database_written": False,
"stage_written": False,
"registry_written": False,
"writer_execute_called": False,
"facts_promoted": False,
"evidence_promoted": False,
},
"rows": rows,
"interpretation": [
"The 27 raw page rows can produce complete candidate year/school/major keys in memory when major is taken from raw p_name; this is a candidate adapter result, not a production-key authorization.",
"Historical score_all mapping is exact to recovered field 院系线/总分 with archived unit 分 and unit_bound=Y; the current global_facts field and unit storage contract remains unverified.",
"The current field candidate total_retest_line is sourced from the read-only Zhonggong field contract and remains candidate_only_not_production_verified.",
"Neither the current candidate field nor the historical field candidate produced an exact global_facts business-key or fact-id hit in this read-only probe; this does not authorize insertion or imply target coverage.",
"The one shorter raw faculty_name variance remains explicit and was not filled from the historical college name.",
"All selected facts remain reference_only/conflict_quarantined and third-party/no-official-crosscheck; no production promotion was attempted.",
],
"next_action": "Use this 27-row replay as input to a separate audit of the current candidate adapter contract, including whether current production rows use total_retest_line or another field, whether numeric scores are ingested as strings or integers, and how school/major identity is canonicalized. Keep any result read-only until field, unit, production key and target authorization are independently verified.",
}
OUT.parent.mkdir(parents=True, exist_ok=True)
LOG.parent.mkdir(parents=True, exist_ok=True)
OUT.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
LOG.write_text(
"\n".join([
f"generated_at_local={result['generated_at_local']}",
f"status={result['status']}",
f"verdict={result['verdict']}",
f"rows={len(rows)} pure_parser_replay_pass={raw_replay_pass} required_key_complete={required_key_pass}",
f"current_business_key_exact_matches={candidate_key_rows} historical_business_key_exact_matches={historical_key_rows}",
f"current_fact_id_exact_matches={candidate_fact_rows} historical_fact_id_exact_matches={historical_fact_rows}",
f"college_exact={result['observed_counts']['college_exact_match']} college_trimmed={result['observed_counts']['college_trimmed_match']} variance={college_variance_count}",
f"checks_pass={checks['pass']}/{checks['total']} all_pass={checks['all_pass']}",
f"database_state_unchanged={checks['database_state_unchanged']} source_report_unchanged={checks['source_report_unchanged']}",
"write_boundary=production_database_written:false stage_written:false registry_written:false writer_execute_called:false",
f"report={OUT}",
]) + "\n",
encoding="utf-8",
)
print(json.dumps({
"report": str(OUT),
"log": str(LOG),
"sha256": sha256_file(OUT),
"log_sha256": sha256_file(LOG),
"status": result["status"],
"verdict": result["verdict"],
"checks": checks,
"observed_counts": result["observed_counts"],
}, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()
@@ -0,0 +1,66 @@
from __future__ import annotations
import csv
import tempfile
import unittest
from pathlib import Path
from r134_s1_chsi_2027_pagination_queue_20261015 import (
build_tasks,
load_school_counts,
)
class PaginationQueueTests(unittest.TestCase):
def _write_input(self, directory: Path) -> Path:
path = directory / "counts.csv"
fields = [
"admission_year",
"exam_year",
"unit_code",
"school_name",
"chsi_sch_id",
"status",
"reported_total_count",
"valid_visible_row_count",
"rows_not_retrieved",
"total_pages",
"page_size",
]
rows = [
[2027, 2026, "10001", "A", "1", "public_page_complete", 10, 10, 0, 1, 10],
[2027, 2026, "10002", "B", "2", "public_page_partial", 30, 10, 20, 3, 10],
[2027, 2026, "10003", "C", "3", "empty_api_result", 0, 0, 0, 0, 0],
]
with path.open("w", encoding="utf-8", newline="") as stream:
writer = csv.writer(stream)
writer.writerow(fields)
writer.writerows(rows)
return path
def test_builds_only_pages_after_page_one(self) -> None:
with tempfile.TemporaryDirectory() as temp:
rows = load_school_counts(self._write_input(Path(temp)))
tasks = build_tasks(rows)
self.assertEqual([task["task_id"] for task in tasks], ["2027:10002:2", "2027:10002:3"])
self.assertTrue(all(task["request_semantics_status"] == "NOT_VERIFIED" for task in tasks))
def test_rejects_non_closed_row_count(self) -> None:
with tempfile.TemporaryDirectory() as temp:
path = self._write_input(Path(temp))
text = path.read_text(encoding="utf-8").replace("30,10,20,3,10", "30,10,19,3,10")
path.write_text(text, encoding="utf-8")
with self.assertRaises(ValueError):
load_school_counts(path)
def test_rejects_duplicate_unit(self) -> None:
with tempfile.TemporaryDirectory() as temp:
path = self._write_input(Path(temp))
with path.open("a", encoding="utf-8", newline="") as stream:
stream.write("2027,2026,10001,A,1,public_page_complete,10,10,0,1,10\n")
with self.assertRaises(ValueError):
load_school_counts(path)
if __name__ == "__main__":
unittest.main()
Binary file not shown.

After

Width:  |  Height:  |  Size: 387 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

@@ -0,0 +1 @@
{"status":"parsed","stage_identity":"a143465e4cc87f3cbf7a3507a9d23f5c5a863dee37894949fe37586cf5ce52a6","page":{"admission_year":"2027","school_id":"445","school_name":"石河子大学","article_url":"https://www.chinakaoyan.com/graduate/info/nid/672661/schoolID/445.shtml","index_sha256":"9fa7d7e1cad5c7c9b10a62e99e9a4bb23bfbc12e80441aec204598fa55f2ab3e","quality_parser_id":"lxml_direct_table_rows.v3","quality_page_title":"2027年石河子大学硕士研究生招生专业目录及初试科目拟调整公告_石河子大学研究生院 - 中国考研网","quality_page_bytes":37999,"quality_page_sha256":"9ef71f8ee1e076d264ae9fb34b48a15130db8d41ec0742d823a48e914da18e9a","observed_quality_sha256_variants":["9ef71f8ee1e076d264ae9fb34b48a15130db8d41ec0742d823a48e914da18e9a"],"final_url":"https://www.chinakaoyan.com/graduate/info/nid/672661/schoolID/445.shtml","http_status":200,"bytes":37999,"sha256":"b0834bc6d76eb7d0921981baa29b45b06ea56ee0cde8150f050323fe15a9fc3e","parser_id":"chinakaoyan_annual_catalog:lxml_rowspan_grid.v14"},"parser_summary":{"table_count":1,"usable_tables":1,"record_count":16,"unique_major_code_count":16,"duplicate_code_occurrences_within_page":0,"issue_counts":{"duplicate_code_occurrences_within_page":0}},"records":[{"admission_year":"2027","exam_year":"2026","college":"文学艺术学院","major_code":"135200","major_name":"音乐","degree_type":"","study_mode":"","study_mode_raw":"","study_mode_status":"unspecified","plan_enroll_raw":"","exam_combo_text":"","exam_combo_raw":"","directions":[],"raw_major_cell":"135200","raw_name_cell":"音乐","direction_locator":null,"source_locator":{"kind":"html_table_cell","table":1,"table_row":2,"table_cell":1,"expanded_column":1},"exam_combo_locator":null,"parser_id":"chinakaoyan_annual_catalog:lxml_rowspan_grid.v14","school_name":"石河子大学","source_url":"https://www.chinakaoyan.com/graduate/info/nid/672661/schoolID/445.shtml","source_sha256":"b0834bc6d76eb7d0921981baa29b45b06ea56ee0cde8150f050323fe15a9fc3e","school_code":"10759","school_mapping_basis":"exact_name_in_current_CHSI_roster","school_mapping_evidence":[],"resolved_college":"文学艺术学院","resolved_college_code":"","existing_major_names":[],"target_comparison":"new_target_candidate","source_record_ordinal":1,"source_key_occurrence":"first"},{"admission_year":"2027","exam_year":"2026","college":"文学艺术学院","major_code":"135600","major_name":"美术与书法","degree_type":"","study_mode":"","study_mode_raw":"","study_mode_status":"unspecified","plan_enroll_raw":"","exam_combo_text":"","exam_combo_raw":"","directions":[],"raw_major_cell":"135600","raw_name_cell":"美术与书法","direction_locator":null,"source_locator":{"kind":"html_table_cell","table":1,"table_row":3,"table_cell":1,"expanded_column":1},"exam_combo_locator":null,"parser_id":"chinakaoyan_annual_catalog:lxml_rowspan_grid.v14","school_name":"石河子大学","source_url":"https://www.chinakaoyan.com/graduate/info/nid/672661/schoolID/445.shtml","source_sha256":"b0834bc6d76eb7d0921981baa29b45b06ea56ee0cde8150f050323fe15a9fc3e","school_code":"10759","school_mapping_basis":"exact_name_in_current_CHSI_roster","school_mapping_evidence":[],"resolved_college":"文学艺术学院","resolved_college_code":"","existing_major_names":[],"target_comparison":"new_target_candidate","source_record_ordinal":2,"source_key_occurrence":"first"},{"admission_year":"2027","exam_year":"2026","college":"文学艺术学院","major_code":"135700","major_name":"设计","degree_type":"","study_mode":"","study_mode_raw":"","study_mode_status":"unspecified","plan_enroll_raw":"","exam_combo_text":"","exam_combo_raw":"","directions":[],"raw_major_cell":"135700","raw_name_cell":"设计","direction_locator":null,"source_locator":{"kind":"html_table_cell","table":1,"table_row":4,"table_cell":1,"expanded_column":1},"exam_combo_locator":null,"parser_id":"chinakaoyan_annual_catalog:lxml_rowspan_grid.v14","school_name":"石河子大学","source_url":"https://www.chinakaoyan.com/graduate/info/nid/672661/schoolID/445.shtml","source_sha256":"b0834bc6d76eb7d0921981baa29b45b06ea56ee0cde8150f050323fe15a9fc3e","school_code":"10759","school_mapping_basis":"exact_name_in_current_CHSI_roster","school_mapping_evidence":[],"resolved_college":"文学艺术学院","resolved_college_code":"","existing_major_names":[],"target_comparison":"new_target_candidate","source_record_ordinal":3,"source_key_occurrence":"first"},{"admission_year":"2027","exam_year":"2026","college":"经济与管理学院","major_code":"025100","major_name":"金融","degree_type":"","study_mode":"","study_mode_raw":"","study_mode_status":"unspecified","plan_enroll_raw":"","exam_combo_text":"","exam_combo_raw":"","directions":[],"raw_major_cell":"025100","raw_name_cell":"金融","direction_locator":null,"source_locator":{"kind":"html_table_cell","table":1,"table_row":5,"table_cell":1,"expanded_column":1},"exam_combo_locator":null,"parser_id":"chinakaoyan_annual_catalog:lxml_rowspan_grid.v14"Line truncated
@@ -0,0 +1,731 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>2027年石河子大学硕士研究生招生专业目录及初试科目拟调整公告_石河子大学研究生院 - 中国考研网</title>
<link rel="stylesheet" type="text/css" href="/css/basic_yzw_v2.css">
<link rel="stylesheet" type="text/css" href="/css/index.css">
<link rel="stylesheet" href="/css/side_weixin.css">
<!--gt-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try
{var pageTracker = _gat._getTracker("UA-13040595-1");
pageTracker._setDomainName(".chinakaoyan.com");
pageTracker._trackPageview();
} catch(err) {}
</script>
<!--gt-->
<!--bt-->
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fb39c8daefe867a19aec651fe9bb57881' type='text/javascript'%3E%3C/script%3E"));
</script>
<!--bt-->
</head>
<body>
<div class="miniNav">
<div class="container">
<div class="loginNav fl">
<ul class="mini-list font14">
<li><a href="/" title="中国考研网">首页</a></li>
<li><a href="/info/" target="_blank" title="研究生招生信息网">信息</a></li>
<li><a href="/graduate/" target="_blank">院校</a></li>
<li><a href="/admissions/" target="_blank" title="研招网">研招</a></li>
<li><a href="/tiaoji/" target="_blank" title="考研调剂">调剂</a></li>
<li><a href="/note/" target="_blank" title="考研资料">资料</a></li>
<li><a href="/info/list/ClassID/22.shtml" target="_blank" title="考研分数线">分数线</a></li>
<li><a href="/class/" target="_blank" title="考研辅导班">辅导班</a></li>
<li><a href="/graduate/grad/schoolID/445.shtml" title="石河子大学研究生院">研究生院</a></li>
</ul>
</div>
<div class="login fr font14">
<a href="#" class="register">注册</a>
<a href="javascript:;" class="login-btn">登录</a>
</div>
</div>
</div>
<div class="container">
<div class="s-logo fl">
<h1 class="fl"><a href="/graduate/grad/schoolID/445.shtml" title="石河子大学研究生院">石河子大学</a></h1>
<small><a target="_blank" href="/xindongfang/">2027/2028考研辅导网课</a></small>
</div>
<!--广告-->
<ul class="hotspot fr" id="hotspot">
<div class="hr10"></div>
<li class="hot_a1 h_a_c3"><a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" target="_blank">2027考研英语全程班<span>2027考研英语全程班</span></a></li>
<li class="hot_a2 h_a_c1"><a rel="nofollow" href="https://l.koolearn.com/d2WuioZ" target="_blank">2027考研政治全程班<span>2027考研政治全程班</span></a></li>
<li class="hot_a2 h_a_c2"><a rel="nofollow" href="https://l.koolearn.com/IpjABGU" target="_blank">2027考研数学全程班<span>2027考研数学全程班</span></a></li>
<li class="hot_a1 h_a_c1"><a rel="nofollow" href="/xindongfang/detail/3551.shtml" target="_blank">2027考研英语直通车<span>2027考研英语直通车</span></a></li>
<li class="hot_a2 h_a_c1"><a rel="nofollow" href="/xindongfang/detail/3547.shtml" target="_blank">2027考研政治直通车<span>2027考研政治直通车</span></a></li>
<li class="hot_a2 h_a_c3"><a rel="nofollow" href="/xindongfang/detail/3543.shtml" target="_blank">2027考研数学直通车<span>2027考研数学直通车</span></a></li>
<li class="hot_a2 h_a_c4"><a rel="nofollow" href="https://dl.koolearn.com/DwcbG4W" target="_blank">2028考研网课/英语/数学/正式早鸟班</span></a></li>
</ul>
</div>
<!--end h1 title-->
<!--nav-->
<div class="hr10"></div>
<div class="container nav">
<ul class="site_nav font14 b">
<li class="active"><a href="/graduate/grad/schoolID/445.shtml" target="_blank" class="current"><span class="home">学校首页</span></a></li></li>
<li><a href="/graduate/intro/schoolID/445.shtml" target="_blank"><span>学校简介</span></a></li>
<li><a href="/graduate/speciality/schoolID/445.shtml" target="_blank"><span>院系设置</span></a></li>
<li><a href="/graduate/InfoList/class/tj/schoolID/445.shtml" target="_blank" title="石河子大学考研调剂信息">考研调剂</a></li>
<li><a href="/graduate/InfoList/class/cjxx/schoolID/445.shtml" target="_blank" title="石河子大学考研成绩查询"><span>考研成绩查询</span></a></li>
<li><a href="/graduate/InfoList/class/fsx/schoolID/445.shtml" target="_blank" title="石河子大学考研分数线"><span>考研分数线</span></a></li>
<li><a href="/graduate/InfoList/class/ds/schoolID/445.shtml" target="_blank" title="石河子大学研究生导师介绍">导师介绍</a></li>
<li><a href="http://download.chinakaoyan.com/list-school-445.html" target="_blank" title="石河子大学考研真题下载"><span>历年试题</span></a></li>
<li><a href="/graduate/InfoList/class/sszs/schoolID/445.shtml" target="_blank" title="石河子大学研究生招生信息网"><span>研究生招生信息网</span></a></li>
</ul>
<div style="margin-top:10px;margin-botton:10px;"><a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" target="_blank"><img src="https://download.chinakaoyan.com/wwwfile/2026/ke/20260211155112.png" /></a><div>
</div>
<div class="container">
<div class="currt font14">
<div class="split">
中国考研网 <a href="/">考研网</a> &raquo; <a href="/graduate/">院校信息</a> &raquo; <a href="/graduate/school/schoolID/445.shtml">石河子大学</a> &raquo; 专业目录
</div>
</div>
</div>
<!--Column1-->
<div class="hr20"></div>
<div class="container">
<!--left-->
<div class="w660 fl">
<h3 class="b">2027年石河子大学硕士研究生招生专业目录及初试科目拟调整公告</h3>
<p class="tag">分类:专业目录 来源:石河子大学研究生招生信息网 2026-06-16 相关院校:<em><a href="/graduate/grad/schoolID/445.shtml" title="石河子大学研究生院" target="_blank"><b>石河子大学</b></a></em>
</p>
<div class="arc-body font14">
<a rel="nofollow" href="https://tgc.orangevip.com/releasehtml/index756.html?jt_site_id=32431&source=0" target="_blank"><img src="https://download.chinakaoyan.com/wwwfile/2024/ad/20241127170611.png" /></a>
</div>
<div class="cont" style="margin-top:20px;"><a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" target="_blank"><font color="#ff0000" size="3px;">2027考研英语全程班 早鸟3班</font></a></div>
<div class="cont" style="margin-top:20px;"><a rel="nofollow" href="/info/article/id/666265.shtml" target="_blank"><font color="#ff0000" size="3px;">2027考研数学人工答疑班</font></a></div>
<div class="cont" style="margin-top:20px;"><a rel="nofollow" href="/info/article/id/666449.shtml" target="_blank"><font color="#ff0000" size="3px;">2027老夏考研英语365天带背答疑伴学营</font></a></div>
<div class="cont" style="margin-top:10px;"><a rel="nofollow" href="https://m-qun.gaotu007.club/a/E1RGbIU" target="_blank"><font color="#ff0000" size="3px;">2027考研全科上岸[考研咨询]</font></a></div>
<!-- class="cont" style="margin-top:10px;"><a href="/note/SchoolShow/id/445.shtml" target="_blank" title="石河子大学考研资料"><font color="#ff0000" size="3px;">石河子大学2026考研专业课复习资料「真题&#9642;笔记&#9642;讲义&#9642;题库」</font></a></div>-->
<div class="arc-body font14">
<p> 各位考生: </p>
<p> 根据学校2027年硕士研究生招生工作安排,结合学校学科专业发展实际,由培养学院研究提出,经学校审核同意,拟对部分学科专业目录及初试科目进行调整,现公布相关调整情况(详情见附件)。 </p>
<p> 教育部2027年硕士研究生招生政策尚未下达,所有调整项目仅供参考,最终以教育部《2027年全国硕士研究生招生工作管理规定》《石河子大学2027年硕士研究生招生简章》《石河子大学2027年硕士研究生招生专业目录》(预计2026年9月发布)为准。请广大考生知悉并及时关注石河子大学研究生招生信息网(https://yz.shzu.edu.cn),做好相关备考工作。 </p>
<p> 附件:石河子大学2027年硕士研究生招生专业目录及初试科目调整情况 </p>
<p> 石河子大学研究生招生办公室 </p>
<p> 2026年6月16日 </p>
<p> <strong>附件:</strong> </p>
<p> 石河子大学2027年硕士研究生招生专业目录及初试科目调整情况 </p>
<table width="98%" align="center" border="1" cellspacing="1" cellpadding="1">
<tbody>
<tr class="firstRow">
<td bgcolor="#ffffff">
<p> <strong>专业类别</strong><strong><br />
</strong><strong>(领域)代码</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> <strong>专业类别</strong><strong><br />
</strong><strong>(领域)名称</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> <strong>调整情况</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> <strong>培养学院</strong> </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 135200 </p>
</td>
<td bgcolor="#ffffff">
<p> 音乐 </p>
</td>
<td bgcolor="#ffffff">
<p> 初试科目业务课一&ldquo;336艺术基础&rdquo;调整为<strong>&ldquo;</strong><strong>611</strong><strong>艺术概论&rdquo;</strong>,研究方向由&ldquo;声乐演唱、器乐演奏、音乐教育&rdquo;,调整为<strong>&ldquo;美声演唱、民族演唱、钢琴演奏、民族器乐、音乐教育&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff" rowspan="3">
<p> 文学艺术学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 135600 </p>
</td>
<td bgcolor="#ffffff">
<p> 美术与书法 </p>
</td>
<td bgcolor="#ffffff" rowspan="2">
<p> 初试科目业务课一&ldquo;336艺术基础&rdquo;调整为<strong>&ldquo;</strong><strong>611</strong><strong>艺术概论&rdquo;</strong> </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 135700 </p>
</td>
<td bgcolor="#ffffff">
<p> 设计 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 025100 </p>
</td>
<td bgcolor="#ffffff">
<p> 金融 </p>
</td>
<td bgcolor="#ffffff" rowspan="2">
<p> 初试科目业务课一&ldquo;303数学(三)&rdquo;调整为<strong>&ldquo;</strong><strong>396</strong><strong>经济类综合能力&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff" rowspan="2">
<p> 经济与管理学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 025200 </p>
</td>
<td bgcolor="#ffffff">
<p> 应用统计 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 095133 </p>
</td>
<td bgcolor="#ffffff">
<p> 畜牧 </p>
</td>
<td bgcolor="#ffffff" rowspan="2">
<p> 初试科目业务科二&ldquo;415动物生理学和生物化学&rdquo;调整为<strong>&ldquo;动物生理学&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff" rowspan="2">
<p> 动物科技学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 095200 </p>
</td>
<td bgcolor="#ffffff">
<p> 兽医 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 070100 </p>
</td>
<td bgcolor="#ffffff">
<p> 数学 </p>
</td>
<td bgcolor="#ffffff">
<p> 复试科目由&ldquo;数学综合(泛函分析、抽象代数、拓扑学)&rdquo;调整为<strong>&ldquo;数学综合(泛函分析、抽象代数)&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> 理学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 140700 </p>
</td>
<td bgcolor="#ffffff">
<p> 区域国别学 </p>
</td>
<td bgcolor="#ffffff">
<p> 各研究方向加试科目②由&ldquo;英语/俄语/哈萨克语语言与文化(三选一)&rdquo;调整为<strong>&ldquo;外语写作&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> 外国语学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 083300 </p>
</td>
<td bgcolor="#ffffff">
<p> 城乡规划学 </p>
</td>
<td bgcolor="#ffffff">
<p> 研究方向&ldquo;绿洲人居环境科学&rdquo;调整为<strong>&ldquo;空间发展与规划理论、城乡系统与规划技术&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> 城市与环境学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 100400 </p>
</td>
<td bgcolor="#ffffff">
<p> 公共卫生与预防医学 </p>
</td>
<td bgcolor="#ffffff">
<p> 研究方向&ldquo;医学与卫生事业管理&rdquo;调整为<strong>&ldquo;社会医学与卫生事业管理&rdquo;</strong>,新增2个研究方向<strong>&ldquo;营养与食品卫生学、儿少卫生与妇幼保健学&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff" rowspan="2">
<p> 公共卫生学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 105300 </p>
</td>
<td bgcolor="#ffffff">
<p> 公共卫生 </p>
</td>
<td bgcolor="#ffffff">
<p> 研究方向&ldquo;医学与卫生事业管理&rdquo;调整为<strong>&ldquo;社会医学与卫生事业管理&rdquo;</strong>,新增研究方向<strong>&ldquo;儿少卫生与妇幼保健学&rdquo;</strong> </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 080200 </p>
</td>
<td bgcolor="#ffffff">
<p> 机械工程 </p>
</td>
<td bgcolor="#ffffff">
<p> 研究方向&ldquo;车辆工程、新能源装备与动力工程&rdquo;,合并调整为<strong>&ldquo;新能源动力与车辆工程&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> 机械电气工程学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 081400 </p>
</td>
<td bgcolor="#ffffff">
<p> 土木工程 </p>
</td>
<td bgcolor="#ffffff">
<p> 研究方向&ldquo;寒区绿色建筑&rdquo;调整为<strong>&ldquo;市政工程&rdquo;</strong> </p>
</td>
<td bgcolor="#ffffff">
<p> 水利建筑工程学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 0802J2 </p>
</td>
<td bgcolor="#ffffff">
<p> 低空技术与工程 </p>
</td>
<td bgcolor="#ffffff">
<p> <strong>新增招生专业,</strong>研究方向为:①低空信息智能感知与决策、②空地协同精准作业装备与智能控制、③低空飞行器与任务载荷一体化设计;初试科目为:①101思想政治理论、②201英语(一)、③301数学(一)、④810机械设计基础 </p>
</td>
<td bgcolor="#ffffff">
<p> 机械电气工程学院 </p>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
<p> 0802J3 </p>
</td>
<td bgcolor="#ffffff">
<p> 能源电力与储能工程 </p>
</td>
<td bgcolor="#ffffff">
<p> <strong>新增招生专业,</strong>不区分研究方向,初试科目为:①101思想政治理论、②201英语(一)、③301数学(一)、④机电一体化基础 </p>
</td>
<td bgcolor="#ffffff">
<p> 能源与材料学院 </p>
</td>
</tr>
</tbody>
</table>
<p> 备注:参考书目及大纲由相关学院发布。</p>
<p>原文链接:https://yz.shzu.edu.cn/2026/0616/c6938a233397/page.htm</p>
</div>
<div class="arc-body font14">
<a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" target="_blank"><img src="https://download.chinakaoyan.com/wwwfile/2026/ke/20250211155111.png" /></a>
</div>
<div class="arc-body font14">
<a rel="nofollow" href="https://tgc.orangevip.com/releasehtml/index1146.html?jt_site_id=45395&source=0" target="_blank"><img src="https://download.chinakaoyan.com/wwwfile/2024/ad/20241127170611.png" /></a>
</div>
<!--院校相关资讯-->
<div class="hr20"></div>
<div class="row kctj">
<div class="hdb-head">
<h4 class="fl b">相关资讯</h4>
</div>
<div class="hr10"></div>
<div class="row">
<ul class="kctj-txt1 fr font14">
<li><a href="/graduate/info/nid/685737/schoolID/445.shtml" target="_blank" title="2027年石河子大学考研专业目录及考试科目">2027年石河子大学考研专业目录及考试科目</a></li>
<li><a href="/graduate/info/nid/681643/schoolID/445.shtml" target="_blank" title="2027年石河子大学硕士研究生招生简章">2027年石河子大学硕士研究生招生简章</a></li>
<li><a href="/graduate/info/nid/672661/schoolID/445.shtml" target="_blank" title="2027年石河子大学硕士研究生招生专业目录及初试科目拟调整公告">2027年石河子大学硕士研究生招生专业目录及初试科目拟调整公告</a></li>
<li><a href="/graduate/info/nid/665563/schoolID/445.shtml" target="_blank" title="石河子大学2026年博士研究生招生报名时间延长通知">石河子大学2026年博士研究生招生报名时间延长通知</a></li>
<li><a href="/graduate/info/nid/663015/schoolID/445.shtml" target="_blank" title="2026年石河子大学硕士研究生拟录取名单公示">2026年石河子大学硕士研究生拟录取名单公示</a></li>
</ul>
</div>
</div>
<!--试听列表-->
<div class="hr10"></div>
<div class="hdb-head">
<h3 class="fl b">热门网课</h3>
</div>
<div class="audition-group">
<div class="item">
<h5 class="b"><a rel="nofollow" href="https://l.koolearn.com/d2WuioZ" target="_blank">2027考研政治全程班 1班</h5>
<p>
<span class="time">课时:232</span>
<span class="price">限时优惠:¥1190</span>
</p>
<a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" class="audition" target="_blank">免费试听</a>
</div>
<div class="item">
<h5 class="b"><a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" target="_blank">2027考研英语全程班 1班</h5>
<p>
<span class="time">课时:383</span>
<span class="price">限时优惠:¥1190</span>
</p>
<a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" class="audition" target="_blank">免费试听</a>
</div>
<div class="item">
<h5 class="b"><a rel="nofollow" href="https://l.koolearn.com/IpjABGU" target="_blank">2027考研数学全程班 1班</a></h5>
<p>
<span class="time">课时:350</span>
<span class="price">限时优惠:¥1290</span>
</p>
<a rel="nofollow" href="https://l.koolearn.com/IpjABGU" class="audition" target="_blank">免费试听</a>
</div>
<div class="item"
<h5 class="b"><a rel="nofollow" href="https://l.koolearn.com/rTokqAF" target="_blank">2027考研英语直通车 6期</a></h5>
<p>
<span class="time">课时:457</span>
<span class="price">限时优惠:¥7690</span>
</p>
<a rel="nofollow" href="https://l.koolearn.com/rTokqAF" class="audition" target="_blank">免费试听</a>
</div>
</div>
<!--考研网最新资讯-->
<div class="hr20"></div>
<div class="row kctj">
<div class="hdb-head">
<h4 class="fl b">最新资讯</h4>
</div>
<div class="hr10"></div>
<div class="row">
<ul class="kctj-txt1 fr font14">
<li><a href="/graduate/info/nid/643635/schoolID/1017.shtml" target="_blank" title="宁夏师范大学(6405)报考点2026年考研网上确认通告">宁夏师范大学(6405)报考点2026年考研网上确认通告</a></li>
<li><a href="/graduate/info/nid/689809/schoolID/129.shtml" target="_blank" title="中国石油大学(北京)2027年全日制学术学位硕士研究生招生专业目录">中国石油大学(北京)2027年全日制学术学位硕士研究生招生专业..</a></li>
<li><a href="/graduate/info/nid/689807/schoolID/129.shtml" target="_blank" title="中国石油大学(北京)2027年全日制专业学位硕士研究生招生专业目录">中国石油大学(北京)2027年全日制专业学位硕士研究生招生专业..</a></li>
<li><a href="/graduate/info/nid/689805/schoolID/129.shtml" target="_blank" title="中国石油大学(北京)2027年非全日制硕士研究生招生专业目录">中国石油大学(北京)2027年非全日制硕士研究生招生专业目录</a></li>
<li><a href="/graduate/info/nid/689803/schoolID/129.shtml" target="_blank" title="中国石油大学(北京)2027年非全日制硕士研究生招生专业目录(单独考试)">中国石油大学(北京)2027年非全日制硕士研究生招生专业目录(..</a></li>
</ul>
</div>
</div>
</div>
<!--right-->
<div class="sidebar fr">
<!--信息目录-->
<div class="hr10"></div>
<div class="side-hd">
<h3 class="fl">信息目录</h3>
</div>
<div class="info-groups font14">
<a href="/graduate/InfoList/class/zsjz/schoolID/445.shtml" title="石河子大学考研招生简章" target="_blank">考研招生简章</a>
<a href="/graduate/InfoList/class/zyml/schoolID/445.shtml" title="石河子大学考研专业目录" target="_blank">考研专业目录</a>
<a href="/graduate/InfoList/class/cks/schoolID/445.shtml" title="石河子大学考研参考书目" target="_blank">考研参考书目</a>
<a href="/graduate/InfoList/class/ksdg/schoolID/445.shtml" title="石河子大学考研考试大纲" target="_blank">考研考试大纲</a>
<a rel="nofollow" href="http://download.chinakaoyan.com/list-school-445.html" title="石河子大学考研真题下载" target="_blank">考研真题下载</a>
<a href="/graduate/InfoList/class/cjxx/schoolID/445.shtml" title="石河子大学考研成绩查询" target="_blank">考研成绩查询</a>
<a href="/graduate/InfoList/class/tj/schoolID/445.shtml" title="石河子大学考研调剂信息" target="_blank">考研调剂信息</a>
<a href="/graduate/InfoList/class/fsx/schoolID/445.shtml" title="石河子大学考研分数线" target="_blank">考研分数线</a>
<a href="/graduate/InfoList/class/fsxx/schoolID/445.shtml" title="石河子大学考研复试信息" target="_blank">考研复试信息</a></br>
<a href="/graduate/InfoList/class/bklq/schoolID/445.shtml" title="石河子大学考研报录比" target="_blank">考研报考录取</a>
<a href="/graduate/InfoList/class/zsdy/schoolID/445.shtml" title="石河子大学研招办答疑" target="_blank">研招办答疑</a>
<a href="/graduate/InfoList/class/xfjz/schoolID/445.shtml" title="石河子大学研究生学费及奖助学金" target="_blank">研究生学费</a>
<a href="/note/SchoolShow/id/445.shtml" title="石河子大学考研资料" target="_blank">考研复习资料</a>
<a href="/graduate/InfoList/class/zbdh/schoolID/445.shtml" title="石河子大学研招办电话" target="_blank">研招办电话</a>
<a href="/graduate/InfoList/class/ds/schoolID/445.shtml" title="石河子大学研究生导师介绍" target="_blank">导师介绍</a>
<!--<a rel="nofollow" href="/graduate/getQuestion/schoolID/445.shtml" title="石河子大学考研问答" target="_blank">考研问答</a>-->
</div>
<!--网络课程,原2016/fudaoban.html-->
<div class="hr10"></div>
<div class="side-hd">
<h3 class="sred">网络课程</h3>
</div>
<div class="side-kc">
<div class="item">
<h5 class="b"><a rel="nofollow" href="https://dl.koolearn.com/Hpdyxu3" target="_blank">2027/2028考研全程班 最新网课</a></h5>
<p>
<span class="time">政治、英语、数学、专业课都可试听</span>
</p>
<!--<a rel="nofollow" href="https://dl.koolearn.com/Hpdyxu3" target="_blank">试听</a>-->
</div>
<div class="item">
<h5 class="b"><a rel="nofollow" href="https://dl.koolearn.com/yJmg1Dt" target="_blank">2027/2028考研公共课 免费领取</a></h5>
<p>
<span class="time">免费领课,全年享不停</span>
</p>
<!--<a rel="nofollow" href="https://dl.koolearn.com/yJmg1Dt" target="_blank">试听</a>-->
</div>
</div>
<div class="hr10"></div>
<ul class="side-group-list font14">
<li><a rel="nofollow" href="https://l.koolearn.com/LvpDDuz" target="_blank">2027考研英语全程班 1班</a></li>
<li><a rel="nofollow" href="https://l.koolearn.com/d2WuioZ" target="_blank">2027考研政治全程班 1班</a></li>
<li><a rel="nofollow" href="https://l.koolearn.com/IpjABGU" target="_blank">2027考研数学全程班 1班</a></li>
<li><a rel="nofollow" href="/xindongfang/detail/3551.shtml" target="_blank">2027考研英语直通车 1期</a></li>
<li><a rel="nofollow" href="/xindongfang/detail/3547.shtml" target="_blank">2027考研政治直通车 1期</a></li>
<li><a rel="nofollow" href="/xindongfang/detail/3543.shtml" target="_blank">2027考研数学直通车 1期</a></li>
<li><a rel="nofollow" href="/xindongfang/detail/3649.shtml" target="_blank">2027考研直通车【政治+英语】</a></li>
<li><a rel="nofollow" href="https://dl.koolearn.com/DwcbG4W" target="_blank">2028考研网课/英语/数学/正式早鸟班</a></li>
</ul>
<div class="hr10"></div>
<div class="side-hd">
<h3>考研资料</h3>
</div>
<div class="side-ad"><a target="_blank" href="/note/" title="考研专业课资料"><img src="https://download.chinakaoyan.com/wwwfile/2022/ke/20220624100611.png" alt=""></a></div>
<div class="hr10"></div>
<div class="side-hd">
<h3>考研网课</h3>
</div>
<div class="side-ad"><a target="_blank" href="https://tgc.orangevip.com/releasehtml/index756.html?jt_site_id=32431&source=0" title="考研网课"><img src="https://download.chinakaoyan.com/wwwfile/2024/ke/20241121165666.png" alt=""></a></div>
<div class="hr20"></div>
<div class="side-hd">
<h3>省市考研网</h3>
</div>
<ul class="dot font14">
<li><a href="/admissions/yz/province/157.shtml" title="北京研招网">北京</a></li>
<li><a href="/admissions/yz/province/1935.shtml" title="天津研招网">天津</a></li>
<li><a href="/admissions/yz/province/603.shtml" title="河北研招网">河北</a></li>
<li><a href="/admissions/yz/province/1564.shtml" title="山西研招网">山西</a></li>
<li><a href="/admissions/yz/province/1244.shtml" title="辽宁研招网">辽宁</a></li>
<li><a href="/admissions/yz/province/1029.shtml" title="吉林研招网">吉林</a></li>
<li><a href="/admissions/yz/province/1767.shtml" title="上海研招网">上海</a></li>
<li><a href="/admissions/yz/province/1077.shtml" title="江苏研招网">江苏</a></li>
<li><a href="/admissions/yz/province/2176.shtml" title="浙江研招网">浙江</a></li>
<li><a href="/admissions/yz/province/1.shtml" title="安徽研招网">安徽</a></li>
<li><a href="/admissions/yz/province/166.shtml" title="福建研招网">福建</a></li>
<li><a href="/admissions/yz/province/1152.shtml" title="江西研招网">江西</a></li>
<li><a href="/admissions/yz/province/1454.shtml" title="山东研招网">山东</a></li>
<li><a href="/admissions/yz/province/748.shtml" title="河南研招网">河南</a></li>
<li><a href="/admissions/yz/province/947.shtml" title="湖北研招网">湖北</a></li>
<li><a href="/admissions/yz/province/948.shtml" title="湖南研招网">湖南</a></li>
<li><a href="/admissions/yz/province/316.shtml" title="广东研招网">广东</a></li>
<li><a href="/admissions/yz/province/414.shtml" title="广西研招网">广西</a></li>
<li><a href="/admissions/yz/province/583.shtml" title="海南研招网">海南</a></li>
<li><a href="/admissions/yz/province/2255.shtml" title="重庆研招网">重庆</a></li>
<li><a href="/admissions/yz/province/1777.shtml" title="四川研招网">四川</a></li>
<li><a href="/admissions/yz/province/502.shtml" title="贵州研招网">贵州</a></li>
<li><a href="/admissions/yz/province/2050.shtml" title="云南研招网">云南</a></li>
<li><a href="/admissions/yz/province/1941.shtml" title="西藏研招网">西藏</a></li>
<li><a href="/admissions/yz/province/1670.shtml" title="陕西研招网">陕西</a></li>
<li><a href="/admissions/yz/province/234.shtml" title="甘肃研招网">甘肃</a></li>
<li><a href="/admissions/yz/province/1412.shtml" title="青海研招网">青海</a></li>
<li><a href="/admissions/yz/province/1392.shtml" title="宁夏研招网">宁夏</a></li>
<li><a href="/admissions/yz/province/1965.shtml" title="新疆研招网">新疆</a></li>
<li><a href="/admissions/yz/province/1304.shtml" title="内蒙古研招网">内蒙古</a></li>
<li><a href="/admissions/yz/province/877.shtml" title="黑龙江研招网">黑龙江</a></li>
</ul>
<div class="hr10"></div>
</div>
</div>
<!--Column1 over-->
<!--底部-->
<div class="hr20"></div>
<div class="hr10"></div>
<!--底部-->
<div class="hr20"></div>
<div class="dbnavbox">
<div class="wrap">
<a href="/" target="_blank" class="kywbtn" title="中国考研网">中国考研网</a>
<div class="list_box">
<ul class="split">
<h3><a href="/admissions/" target="_blank" title="研招网">研招网</a></h3>
<li><a href="http://download.chinakaoyan.com/" target="_blank">考研真题</a></li>
<li><a href="/chengji/" target="_blank" title="考研成绩查询">考研成绩</a></li>
<li><a href="/guojiaxian/" target="_blank" title="考研国家线">考研国家线</a></li>
<li><a href="/zhaosheng/" target="_blank" title="研究生招生简章">招生简章</a></li>
<li><a href="/tuimian/" target="_blank">推荐免试</a></li>
<li><a href="http://gaokao.chinakaoyan.com/" target="_blank">高考网</a></li>
</ul>
<ul class="split">
<h3><a href="/graduate/" target="_blank" class="hd">院校专业</a></h3>
<li><a href="/graduate/" target="_blank">招生单位</a></li>
<li><a href="/graduate/211.shtml" target="_blank">211大学名单</a></li>
<li><a href="/graduate/985.shtml" target="_blank">985大学名单</a></li>
<li><a href="/graduate/zhx.shtml" target="_blank">自划线院校</a></li>
<li><a href="/graduate/IndexSpeciality.shtml" target="_blank">专业导航</a></li>
</ul>
<ul class="split">
<h3><a href="/tiaoji/" target="_blank" class="hd" title="考研调剂信息">考研调剂</a></h3>
<li><a href="/tiaoji/schoollist.shtml" target="_blank" title="研究生调剂信息网">调剂信息网</a></li>
<li><a href="/user/tiaojiPlusWrite.shtml" target="_blank">发布调剂</a></li>
<li><a href="/tiaoji/liucheng.shtml" target="_blank">考研调剂流程</a></li>
</ul>
<ul class="split">
<h3><a rel="nofollow" href="/club/" target="_blank" class="hd">考研论坛</a></h3>
<li><a rel="nofollow" href="/club/clubHome/clubId/830.shtml" target="_blank">跨专业考研</a></li>
<li><a rel="nofollow" href="/club/clubHome/clubId/827.shtml" target="_blank">考研调剂</a></li>
<li><a rel="nofollow" href="/club/clubHome/clubId/826.shtml" target="_blank">考研复试</a></li>
<li><a rel="nofollow" href="/club/clubHome/clubId/75.shtml" target="_blank">厦门大学</a></li>
</ul>
<ul class="split">
<h3><a rel="nofollow" href="/ask/" target="_blank" class="hd">考研问答</a></h3>
<li><a rel="nofollow" href="/ask/questionList/classID/16.shtml" target="_blank">跨校跨专业</a></li>
<li><a rel="nofollow" href="/ask/questionList/classID/50.shtml" target="_blank">考场应考</a></li>
<li><a rel="nofollow" href="/ask/questionList/classID/39.shtml" target="_blank">考试科目</a></li>
<li><a rel="nofollow" href="/ask/questionList/classID/25.shtml" target="_blank">考研分数线</a></li>
<li><a rel="nofollow" href="/ask/questionList/classID/38.shtml" target="_blank">报录比</a></li>
</ul>
<ul class="split">
<h3><a href="/class/" target="_blank" class="hd">考研辅导班</a></h3>
<li><a rel="nofollow" href="/xindongfang/category/1.shtml" target="_blank">考研公共课</a></li>
<li><a rel="nofollow" href="/xindongfang/category/7.shtml" target="_blank">统考专业课</a></li>
<li><a rel="nofollow" href="/xindongfang/category/21.shtml" target="_blank">院校专业课</a></li>
<li><a rel="nofollow" href="/xindongfang/category/16.shtml" target="_blank">专业硕士</a></li>
<li><a rel="nofollow" href="/xindongfang/category/28.shtml" target="_blank">英语四六级</a></li>
<li><a rel="nofollow" href="/xindongfang/category/37.shtml" target="_blank">出国留学</a></li>
</ul>
<ul class="split">
<h3><a href="/note/" target="_blank" class="hd">试卷资料</a></h3>
<li><a href="http://download.chinakaoyan.com/" target="_blank">考研真题</a></li>
<li><a href="/note/" target="_blank">笔记资料</a></li>
</ul>
</div>
<div class="searchbox">
<form id="globalSearch2" method="post" action="/info/list.shtml" target="_blank">
<select class="sheepnav6" onChange="changeSearch(this.value)" style=" display:none;">
<option value="100">资讯</option>
</select>
<input class="txtArea" name="Search" value="输入查询" onFocus="if(this.value=='输入查询')this.value=''" type="text" />
<a href="#" onClick="document.getElementById('globalSearch2').submit();" class="subtn" title="查询">查询</a>
</form>
</div>
</div>
</div>
<!-- sideWx -->
<div class="side-wx">
<span class="close">×关闭</span>
<img src="https://download.chinakaoyan.com/wwwfile/20171222172611.jpg">
<p>扫码关注<br>考研信息一网打尽</p>
</div>
<div class="Copyright">
<div class="main">
<p>
<a rel="nofollow" target="_blank" href="/about/main/id/3.shtml">网站介绍</a>
<a rel="nofollow" target="_blank" href="/about/main/id/5.shtml">关于我们</a>
<a rel="nofollow" target="_blank" href="/about/main/id/6.shtml">联系方式</a>
<a rel="nofollow" target="_blank" href="/about/main/id/10.shtml">广告业务</a>
<a rel="nofollow" target="_blank" href="/about/main/id/7.shtml">帮助信息</a></p>
<p>1998-2022 ChinaKaoyan.com Network Studio. All Rights Reserved. 沪ICP备12018245号</p>
</div>
</div>
<!--gt-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try
{var pageTracker = _gat._getTracker("UA-13040595-1");
pageTracker._setDomainName(".chinakaoyan.com");
pageTracker._trackPageview();
} catch(err) {}
</script>
<!--gt-->
<!--bt-->
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fb39c8daefe867a19aec651fe9bb57881' type='text/javascript'%3E%3C/script%3E"));
</script>
<!--bt-->
<!--返回顶部-->
<div class="back-top">
<a target="_blank" href="/xindongfang/" class="kelink">课程</a>
<a href="javascript:;" class="return-top">顶部</a>
</div>
<script type="text/javascript" src="https://static.chinakaoyan.com/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="https://static.chinakaoyan.com/js/indexed.js"></script>
<script src="https://static.chinakaoyan.com/js/sideWx.js"></script>
</body>
</html>页面加载时间:0.01022秒
@@ -0,0 +1,498 @@
{
"schema": "r140_chinakaoyan_page_body_capture.v1",
"captured_at_utc": "2026-10-16T12:07:26.859834+00:00",
"requested_url": "https://www.chinakaoyan.com/graduate/info/nid/672661/schoolID/445.shtml",
"final_url": "https://www.chinakaoyan.com/graduate/info/nid/672661/schoolID/445.shtml",
"http_status": 200,
"admission_year": "2027",
"expected_school_name": "石河子大学",
"bytes": 37998,
"sha256": "bae1122d9d95940ef02e9a302d7046cb96fe35e2bed0593d8bc2056f7d63bb92",
"previous_builder_fetch_sha256": "b0834bc6d76eb7d0921981baa29b45b06ea56ee0cde8150f050323fe15a9fc3e",
"matches_previous_builder_fetch": false,
"parser_id": "chinakaoyan_annual_catalog:lxml_rowspan_grid.v14",
"parser_error": null,
"parser_summary": {
"table_count": 1,
"usable_tables": 1,
"record_count": 16,
"unique_major_code_count": 16,
"duplicate_code_occurrences_within_page": 0,
"issue_counts": {
"duplicate_code_occurrences_within_page": 0
}
},
"prior_stage_record_count": 16,
"parsed_record_count": 16,
"prior_stage_record_diffs": [
{
"ordinal": 1,
"major_code": "135200",
"changed_fields": {}
},
{
"ordinal": 2,
"major_code": "135600",
"changed_fields": {}
},
{
"ordinal": 3,
"major_code": "135700",
"changed_fields": {}
},
{
"ordinal": 4,
"major_code": "025100",
"changed_fields": {}
},
{
"ordinal": 5,
"major_code": "025200",
"changed_fields": {}
},
{
"ordinal": 6,
"major_code": "095133",
"changed_fields": {}
},
{
"ordinal": 7,
"major_code": "095200",
"changed_fields": {}
},
{
"ordinal": 8,
"major_code": "070100",
"changed_fields": {}
},
{
"ordinal": 9,
"major_code": "140700",
"changed_fields": {}
},
{
"ordinal": 10,
"major_code": "083300",
"changed_fields": {}
},
{
"ordinal": 11,
"major_code": "100400",
"changed_fields": {}
},
{
"ordinal": 12,
"major_code": "105300",
"changed_fields": {}
},
{
"ordinal": 13,
"major_code": "080200",
"changed_fields": {}
},
{
"ordinal": 14,
"major_code": "081400",
"changed_fields": {}
},
{
"ordinal": 15,
"major_code": "0802J2",
"changed_fields": {}
},
{
"ordinal": 16,
"major_code": "0802J3",
"changed_fields": {}
}
],
"direct_dom_rows": [
{
"table_row": 1,
"cells": [
"专业类别 (领域)代码",
"专业类别 (领域)名称",
"调整情况",
"培养学院"
],
"parsed_records": []
},
{
"table_row": 2,
"cells": [
"135200",
"音乐",
"初试科目业务课一“336艺术基础”调整为 “ 611 艺术概论” ,研究方向由“声乐演唱、器乐演奏、音乐教育”,调整为 “美声演唱、民族演唱、钢琴演奏、民族器乐、音乐教育”",
"文学艺术学院"
],
"parsed_records": [
{
"major_code": "135200",
"major_name": "音乐",
"college": "文学艺术学院",
"raw_major_cell": "135200",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 2,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 3,
"cells": [
"135600",
"美术与书法",
"初试科目业务课一“336艺术基础”调整为 “ 611 艺术概论”"
],
"parsed_records": [
{
"major_code": "135600",
"major_name": "美术与书法",
"college": "文学艺术学院",
"raw_major_cell": "135600",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 3,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 4,
"cells": [
"135700",
"设计"
],
"parsed_records": [
{
"major_code": "135700",
"major_name": "设计",
"college": "文学艺术学院",
"raw_major_cell": "135700",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 4,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 5,
"cells": [
"025100",
"金融",
"初试科目业务课一“303数学(三)”调整为 “ 396 经济类综合能力”",
"经济与管理学院"
],
"parsed_records": [
{
"major_code": "025100",
"major_name": "金融",
"college": "经济与管理学院",
"raw_major_cell": "025100",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 5,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 6,
"cells": [
"025200",
"应用统计"
],
"parsed_records": [
{
"major_code": "025200",
"major_name": "应用统计",
"college": "经济与管理学院",
"raw_major_cell": "025200",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 6,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 7,
"cells": [
"095133",
"畜牧",
"初试科目业务科二“415动物生理学和生物化学”调整为 “动物生理学”",
"动物科技学院"
],
"parsed_records": [
{
"major_code": "095133",
"major_name": "畜牧",
"college": "动物科技学院",
"raw_major_cell": "095133",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 7,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 8,
"cells": [
"095200",
"兽医"
],
"parsed_records": [
{
"major_code": "095200",
"major_name": "兽医",
"college": "动物科技学院",
"raw_major_cell": "095200",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 8,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 9,
"cells": [
"070100",
"数学",
"复试科目由“数学综合(泛函分析、抽象代数、拓扑学)”调整为 “数学综合(泛函分析、抽象代数)”",
"理学院"
],
"parsed_records": [
{
"major_code": "070100",
"major_name": "数学",
"college": "理学院",
"raw_major_cell": "070100",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 9,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 10,
"cells": [
"140700",
"区域国别学",
"各研究方向加试科目②由“英语/俄语/哈萨克语语言与文化(三选一)”调整为 “外语写作”",
"外国语学院"
],
"parsed_records": [
{
"major_code": "140700",
"major_name": "区域国别学",
"college": "外国语学院",
"raw_major_cell": "140700",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 10,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 11,
"cells": [
"083300",
"城乡规划学",
"研究方向“绿洲人居环境科学”调整为 “空间发展与规划理论、城乡系统与规划技术”",
"城市与环境学院"
],
"parsed_records": [
{
"major_code": "083300",
"major_name": "城乡规划学",
"college": "城市与环境学院",
"raw_major_cell": "083300",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 11,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 12,
"cells": [
"100400",
"公共卫生与预防医学",
"研究方向“医学与卫生事业管理”调整为 “社会医学与卫生事业管理” ,新增2个研究方向 “营养与食品卫生学、儿少卫生与妇幼保健学”",
"公共卫生学院"
],
"parsed_records": [
{
"major_code": "100400",
"major_name": "公共卫生与预防医学",
"college": "公共卫生学院",
"raw_major_cell": "100400",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 12,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 13,
"cells": [
"105300",
"公共卫生",
"研究方向“医学与卫生事业管理”调整为 “社会医学与卫生事业管理” ,新增研究方向 “儿少卫生与妇幼保健学”"
],
"parsed_records": [
{
"major_code": "105300",
"major_name": "公共卫生",
"college": "公共卫生学院",
"raw_major_cell": "105300",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 13,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 14,
"cells": [
"080200",
"机械工程",
"研究方向“车辆工程、新能源装备与动力工程”,合并调整为 “新能源动力与车辆工程”",
"机械电气工程学院"
],
"parsed_records": [
{
"major_code": "080200",
"major_name": "机械工程",
"college": "机械电气工程学院",
"raw_major_cell": "080200",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 14,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 15,
"cells": [
"081400",
"土木工程",
"研究方向“寒区绿色建筑”调整为 “市政工程”",
"水利建筑工程学院"
],
"parsed_records": [
{
"major_code": "081400",
"major_name": "土木工程",
"college": "水利建筑工程学院",
"raw_major_cell": "081400",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 15,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 16,
"cells": [
"0802J2",
"低空技术与工程",
"新增招生专业, 研究方向为:①低空信息智能感知与决策、②空地协同精准作业装备与智能控制、③低空飞行器与任务载荷一体化设计;初试科目为:①101思想政治理论、②201英语(一)、③301数学(一)、④810机械设计基础",
"机械电气工程学院"
],
"parsed_records": [
{
"major_code": "0802J2",
"major_name": "低空技术与工程",
"college": "机械电气工程学院",
"raw_major_cell": "0802J2",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 16,
"table_cell": 1,
"expanded_column": 1
}
}
]
},
{
"table_row": 17,
"cells": [
"0802J3",
"能源电力与储能工程",
"新增招生专业, 不区分研究方向,初试科目为:①101思想政治理论、②201英语(一)、③301数学(一)、④机电一体化基础",
"能源与材料学院"
],
"parsed_records": [
{
"major_code": "0802J3",
"major_name": "能源电力与储能工程",
"college": "能源与材料学院",
"raw_major_cell": "0802J3",
"source_locator": {
"kind": "html_table_cell",
"table": 1,
"table_row": 17,
"table_cell": 1,
"expanded_column": 1
}
}
]
}
],
"body_path": "D:\\择校\\运行暂存\\annual_catalog_sources_r1\\chinakaoyan_20261016\\source_pages\\chinakaoyan_2027_672661_bae1122d9d95940ef02e9a302d7046cb96fe35e2bed0593d8bc2056f7d63bb92.html"
}
@@ -0,0 +1,240 @@
{
"total_num": 256049,
"table": [
{
"name": "本科层次分布",
"table": [
{
"name": "985",
"num": 6762
},
{
"name": "双一流",
"num": 6854
},
{
"name": "双非",
"num": 223099
},
{
"name": "211",
"num": 19334
}
]
},
{
"name": "一志愿专业分布",
"table": [
{
"name": "计算机技术 ",
"num": 15040
},
{
"name": "电子信息",
"num": 10772
},
{
"name": "机械工程",
"num": 9845
},
{
"name": "机械",
"num": 8916
},
{
"name": "控制工程",
"num": 5959
},
{
"name": "其他",
"num": 205135
}
]
},
{
"name": "初试成绩区间分布",
"table": [
{
"name": "120-129",
"num": 1,
"items_count": 1
},
{
"name": "130-139",
"num": 9,
"items_count": 4
},
{
"name": "140-149",
"num": 83,
"items_count": 9
},
{
"name": "150-159",
"num": 131,
"items_count": 10
},
{
"name": "160-169",
"num": 208,
"items_count": 10
},
{
"name": "170-179",
"num": 217,
"items_count": 10
},
{
"name": "180-189",
"num": 259,
"items_count": 10
},
{
"name": "190-199",
"num": 330,
"items_count": 10
},
{
"name": "200-209",
"num": 511,
"items_count": 10
},
{
"name": "210-219",
"num": 557,
"items_count": 10
},
{
"name": "220-229",
"num": 456,
"items_count": 10
},
{
"name": "230-239",
"num": 537,
"items_count": 10
},
{
"name": "240-249",
"num": 615,
"items_count": 10
},
{
"name": "250-259",
"num": 2227,
"items_count": 10
},
{
"name": "260-269",
"num": 5658,
"items_count": 10
},
{
"name": "270-279",
"num": 8979,
"items_count": 10
},
{
"name": "280-289",
"num": 12684,
"items_count": 10
},
{
"name": "290-299",
"num": 16028,
"items_count": 10
},
{
"name": "300-309",
"num": 18958,
"items_count": 10
},
{
"name": "310-319",
"num": 21628,
"items_count": 10
},
{
"name": "320-329",
"num": 25100,
"items_count": 10
},
{
"name": "330-339",
"num": 25932,
"items_count": 10
},
{
"name": "340-349",
"num": 26880,
"items_count": 10
},
{
"name": "350-359",
"num": 25631,
"items_count": 10
},
{
"name": "360-369",
"num": 22893,
"items_count": 10
},
{
"name": "370-379",
"num": 17794,
"items_count": 10
},
{
"name": "380-389",
"num": 11207,
"items_count": 10
},
{
"name": "390-399",
"num": 5500,
"items_count": 10
},
{
"name": "400-409",
"num": 2373,
"items_count": 10
},
{
"name": "410-419",
"num": 905,
"items_count": 10
},
{
"name": "420-429",
"num": 488,
"items_count": 10
},
{
"name": "430-439",
"num": 230,
"items_count": 10
},
{
"name": "440-449",
"num": 269,
"items_count": 10
},
{
"name": "450-459",
"num": 98,
"items_count": 10
},
{
"name": "460-469",
"num": 38,
"items_count": 8
},
{
"name": "470-479",
"num": 12,
"items_count": 1
}
]
}
]
}
@@ -0,0 +1,4 @@
{
"text_one": "<div>1、调剂差额:今年一志愿未招满 或 根据往年复试比计算后一志愿预计未招满,此差额为计算结果,仅供参考,实际差额以校方公布为准。 </div>\n <div>2、本差额列表按照您调剂需求选择的地区和专业显示。</div>\n <div>3、本数据每天更新,请及时查看!</div>",
"text_two": "以下为根据去年复录比可能出现差额"
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,9 @@
{
"ssd_url": "https://file.ggyx666.com/ggyx_uploads/20241016/31e7affdf82897ac73bc264721c772d81.png",
"list": [],
"no_token": {
"code": true,
"text": "<p style=\"color: green;font-weight: bold;\" >当前为未登录状态,若数据有误,<span style=\"color: red;\">请点击去登录</span></p>"
},
"is_vip": 0
}
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "type为空"
}
@@ -0,0 +1,6 @@
{
"code": 500,
"msg": "An error occurred",
"time": 1792410711,
"data": null
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "test_num为空"
}
@@ -0,0 +1,67 @@
[
{
"id": 424,
"name": "(085400)电子信息",
"checked": false
},
{
"id": 1695,
"name": "(085404)计算机技术 ",
"checked": false
},
{
"id": 1696,
"name": "(085401)新一代电子信息技术(含量子技术等)",
"checked": false
},
{
"id": 1974,
"name": "(085402)通信工程(含宽带网络、移动通信等)",
"checked": false
},
{
"id": 2026,
"name": "(085405)软件工程",
"checked": false
},
{
"id": 2027,
"name": "(085406)控制工程",
"checked": false
},
{
"id": 2028,
"name": "(085407)仪器仪表工程",
"checked": false
},
{
"id": 2029,
"name": "(085408)光电信息工程",
"checked": false
},
{
"id": 2030,
"name": "(085409)生物医学工程",
"checked": false
},
{
"id": 2031,
"name": "(085410)人工智能",
"checked": false
},
{
"id": 2032,
"name": "(085411)大数据技术与工程",
"checked": false
},
{
"id": 2033,
"name": "(085412)网络与信息安全",
"checked": false
},
{
"id": 2066,
"name": "(085403)集成电路工程",
"checked": false
}
]
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "test_num为空"
}
@@ -0,0 +1,46 @@
[
{
"id": 65,
"name": "(081202)计算机软件与理论"
},
{
"id": 164,
"name": "(081203)计算机应用技术"
},
{
"id": 357,
"name": "(081201)计算机系统结构"
},
{
"id": 467,
"name": "(081200)计算机科学与技术"
},
{
"id": 653,
"name": "(077500)计算机科学与技术"
},
{
"id": 654,
"name": "(077501)计算机系统结构"
},
{
"id": 655,
"name": "(077502)计算机软件与理论"
},
{
"id": 656,
"name": "(077503)计算机应用技术"
},
{
"id": 976,
"name": "(0812Z1)计算机科学与技术(智能科学与技术)/信息安全/核医学数字图像工程/ VR 技术及应用"
},
{
"id": 1565,
"name": "(081220)计算机科学与技术(智能科学与技术)"
},
{
"id": 1695,
"name": "(085404)计算机技术 "
}
]
@@ -0,0 +1,10 @@
[
{
"id": 3600,
"name": "华北计算机系统工程研究所"
},
{
"id": 1116,
"name": "哈尔滨华夏计算机职业技术学院"
}
]
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "xy_id为空"
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,81 @@
{
"name": "按25考研实际调剂成功数据分析",
"data": [
{
"name": "招收校外调剂人数",
"data": [
{
"name": "A区双非",
"color": "#52CCCC",
"num": "2971人",
"value": 2971
},
{
"name": "A区211",
"color": "#38CBFA",
"num": "504人",
"value": 504
},
{
"name": "B区双非",
"color": "#FFAC00",
"num": "345人",
"value": 345
},
{
"name": "双非/双一流",
"color": "#BF8FF9",
"num": "164人",
"value": 164
},
{
"name": "985",
"color": "#5891FF",
"num": "128人",
"value": 128
},
{
"name": "B区211",
"color": "#F28842",
"num": "8人",
"value": 8
}
]
},
{
"name": "招收校外调剂硕士点数",
"data": [
{
"name": "985",
"color": "#5891FF",
"num": "4个",
"value": 4
},
{
"name": "A区211",
"color": "#38CBFA",
"num": "21个",
"value": 21
},
{
"name": "B区211",
"color": "#F28842",
"num": "2个",
"value": 2
},
{
"name": "A区双非",
"color": "#52CCCC",
"num": "148个",
"value": 148
},
{
"name": "B区双非",
"color": "#FFAC00",
"num": "17个",
"value": 17
}
]
}
]
}
@@ -0,0 +1,6 @@
{
"code": 500,
"msg": "An error occurred",
"time": 1792410715,
"data": null
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,7 @@
{
"total": 9,
"data": "https://file.ggyx666.com/ggyx_uploads/20251210/ac6a6a0849624e13770b076e123ba0431-20_00.png",
"current_page": 1,
"last_page": 9,
"per_page": 1
}
@@ -0,0 +1,30 @@
{
"state": "close",
"st_info_code": 0,
"yc_result": 5,
"list": {
"focus_num": 999,
"alternate_num": 999,
"new_ssd_num": 999,
"all_ssd_num": 999
},
"st_info": {
"learn_type": "",
"maj_code": "",
"maj_name": "",
"sch_name": "",
"total_score": "",
"yc_result": 5
},
"rank_info": "已有<span style=\"color:#FFE026;font-size: 28rpx;\">813688人</span><br>参与排名",
"estimated": {
"title": "初试排名",
"ranking_info": "已有<span style=\"color:#FFE026;font-size: 28rpx;\">813688人</span><br>参与排名"
},
"pre_adjustment": {
"is_show": 1,
"num": "159247"
},
"pre_adjustment_info": "159247",
"about": "2026考研调剂已结束,调剂数据库将于2026年12月升级上线,敬请期待!"
}
@@ -0,0 +1,47 @@
[
{
"title": "调剂列表New",
"type": "pub",
"checked": false
},
{
"title": "调剂公海",
"type": "my_adjust",
"checked": false
},
{
"title": "重点推荐",
"type": "focus",
"checked": true
},
{
"title": "调剂备选",
"type": "alternate",
"checked": false
},
{
"title": "新增硕士点",
"type": "new_ssd",
"checked": false
},
{
"title": "同分去向",
"type": "score_direction",
"checked": false
},
{
"title": "同校去向",
"type": "school_direction",
"checked": false
},
{
"title": "调剂热度榜",
"type": "ranking",
"checked": false
},
{
"title": "往年调剂情况",
"type": "analyze",
"checked": false
}
]
@@ -0,0 +1,67 @@
[
{
"id": 424,
"name": "(085400)电子信息",
"checked": false
},
{
"id": 1695,
"name": "(085404)计算机技术 ",
"checked": false
},
{
"id": 1696,
"name": "(085401)新一代电子信息技术(含量子技术等)",
"checked": false
},
{
"id": 1974,
"name": "(085402)通信工程(含宽带网络、移动通信等)",
"checked": false
},
{
"id": 2026,
"name": "(085405)软件工程",
"checked": false
},
{
"id": 2027,
"name": "(085406)控制工程",
"checked": false
},
{
"id": 2028,
"name": "(085407)仪器仪表工程",
"checked": false
},
{
"id": 2029,
"name": "(085408)光电信息工程",
"checked": false
},
{
"id": 2030,
"name": "(085409)生物医学工程",
"checked": false
},
{
"id": 2031,
"name": "(085410)人工智能",
"checked": false
},
{
"id": 2032,
"name": "(085411)大数据技术与工程",
"checked": false
},
{
"id": 2033,
"name": "(085412)网络与信息安全",
"checked": false
},
{
"id": 2066,
"name": "(085403)集成电路工程",
"checked": false
}
]
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "参数有误的"
}
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "apply_report_id为空"
}
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "请输入搜索内容"
}
@@ -0,0 +1,4 @@
{
"code": -1,
"msg": "请输入搜索内容"
}
@@ -0,0 +1,141 @@
{
"list": [
{
"id": 3,
"name": "安徽省"
},
{
"id": 2,
"name": "北京市"
},
{
"id": 32,
"name": "重庆市"
},
{
"id": 4,
"name": "福建省"
},
{
"id": 5,
"name": "甘肃省"
},
{
"id": 6,
"name": "广东省"
},
{
"id": 7,
"name": "广西壮族自治区"
},
{
"id": 8,
"name": "贵州省"
},
{
"id": 9,
"name": "海南省"
},
{
"id": 10,
"name": "河北省"
},
{
"id": 11,
"name": "河南省"
},
{
"id": 12,
"name": "黑龙江省"
},
{
"id": 13,
"name": "湖北省"
},
{
"id": 14,
"name": "湖南省"
},
{
"id": 15,
"name": "吉林省"
},
{
"id": 16,
"name": "江苏省"
},
{
"id": 17,
"name": "江西省"
},
{
"id": 18,
"name": "辽宁省"
},
{
"id": 19,
"name": "内蒙古自治区"
},
{
"id": 20,
"name": "宁夏回族自治区"
},
{
"id": 22,
"name": "山东省"
},
{
"id": 23,
"name": "山西省"
},
{
"id": 24,
"name": "陕西省"
},
{
"id": 25,
"name": "上海市"
},
{
"id": 26,
"name": "四川省"
},
{
"id": 27,
"name": "天津市"
},
{
"id": 28,
"name": "西藏自治区"
},
{
"id": 21,
"name": "青海省"
},
{
"id": 29,
"name": "新疆维吾尔自治区"
},
{
"id": 30,
"name": "云南省"
},
{
"id": 31,
"name": "浙江省"
},
{
"id": 33,
"name": "香港特别行政区"
},
{
"id": 34,
"name": "澳门特别行政区"
},
{
"id": 35,
"name": "台湾省"
}
],
"describe": "为方便服务老师与您进行深度沟通,我们将根据您选择的省份匹配服务老师,请您选择您方便接受服务的省份"
}
@@ -0,0 +1,9 @@
{
"student_id": "VDDFM++9C2350Ew+tKJ8WQ==",
"type": "1",
"code": "go_on",
"evaluate_btn": true,
"evaluate_text": "",
"apply_text": "",
"staff": ""
}
Loaded 100 of 360 files, more files were not shown because too many files have changed in this diff. Show more