()
| 69 | |
| 70 | |
| 71 | def main() -> int: |
| 72 | errors: list[str] = [] |
| 73 | |
| 74 | py_ids = _collect_python_model_ids(_read_text(PY_MODEL_FILE)) |
| 75 | ts_ids = _collect_workers_model_ids(_read_text(TS_MODEL_FILE)) |
| 76 | |
| 77 | if py_ids != ts_ids: |
| 78 | only_python = sorted(py_ids - ts_ids) |
| 79 | only_workers = sorted(ts_ids - py_ids) |
| 80 | lines = ["Model catalog mismatch between python and workers."] |
| 81 | if only_python: |
| 82 | lines.append("Only in app/services/grok/model.py:") |
| 83 | lines.extend(f" - {mid}" for mid in only_python) |
| 84 | if only_workers: |
| 85 | lines.append("Only in src/grok/models.ts:") |
| 86 | lines.extend(f" - {mid}" for mid in only_workers) |
| 87 | errors.append("\n".join(lines)) |
| 88 | |
| 89 | removed_hits = _scan_removed_identifiers() |
| 90 | if removed_hits: |
| 91 | lines = ["Removed model identifiers found under src/**/*.ts:"] |
| 92 | for rel_path, line_no, token, snippet in removed_hits: |
| 93 | lines.append(f" - {rel_path}:{line_no} -> {token}") |
| 94 | lines.append(f" {snippet}") |
| 95 | errors.append("\n".join(lines)) |
| 96 | |
| 97 | if errors: |
| 98 | print("[check_model_catalog_sync] FAILED", file=sys.stderr) |
| 99 | for idx, msg in enumerate(errors, start=1): |
| 100 | print(f"\n[{idx}] {msg}", file=sys.stderr) |
| 101 | return 1 |
| 102 | |
| 103 | print("[check_model_catalog_sync] OK: model catalogs are synchronized and legacy identifiers are absent.") |
| 104 | return 0 |
| 105 | |
| 106 | |
| 107 | if __name__ == "__main__": |
no test coverage detected