ci: שער undefined-names (pyflakes) — שהבאג של PR #249 לא יחזור + תיקון NameError חבוי #250

Merged
chaim merged 1 commits from worktree-ci-undefined-name-guard into main 2026-06-14 09:59:12 +00:00
Owner

רקע

שורש הבאג בשינוי-שם תיק (PR #249, 500) היה שם לא-מוגדר (paperclip_client) שישב בתוך background_tasks — בלתי-נראה לבדיקות עד שהקוד רץ בייצור. שום gate לא תפס אותו. PR זה סוגר את מחלקת-הבאג.

מה נוסף

  • scripts/check_undefined_names.py — מריץ pyflakes על web/, mcp-server/src, scripts/ ומפיל build רק על undefined name/may be undefined (מחלקת ה-crash). imports-לא-בשימוש ו-f-strings לא מגודרים — שמירה על אות גבוה ו-gate ירוק.
  • .gitea/workflows/lint.yaml — מריץ את השער בכל PR ו-push ל-main, ב-venv זמני (חסין PEP-668).
  • db.pyfrom datetime import datedate, datetime. השער חשף NameError חבוי אמיתי: ה-annotation round_ts: datetime ב-insert_panel_round הפנה ל-datetime שלא יובא (תמים רק בזכות from __future__ import annotations; כעת תקין).
  • SCRIPTS.md — תיעוד השער.

אימות

עץ נקי → exit 0; הזרקת שם-לא-מוגדר → exit 1 (תופס). אומת מקומית מול origin/main לאחר התיקון: 0 undefined-names.

Invariants

  • כלל-הנדסה §6 — לא לשלוח כשל-שקט שמתפוצץ רק בזמן-ריצה.

🤖 Generated with Claude Code

## רקע שורש הבאג בשינוי-שם תיק (PR #249, 500) היה **שם לא-מוגדר** (`paperclip_client`) שישב בתוך `background_tasks` — בלתי-נראה לבדיקות עד שהקוד רץ בייצור. שום gate לא תפס אותו. PR זה סוגר את מחלקת-הבאג. ## מה נוסף - **`scripts/check_undefined_names.py`** — מריץ pyflakes על `web/`, `mcp-server/src`, `scripts/` ומפיל build **רק** על `undefined name`/`may be undefined` (מחלקת ה-crash). imports-לא-בשימוש ו-f-strings **לא** מגודרים — שמירה על אות גבוה ו-gate ירוק. - **`.gitea/workflows/lint.yaml`** — מריץ את השער בכל PR ו-push ל-main, ב-venv זמני (חסין PEP-668). - **`db.py`** — `from datetime import date` → `date, datetime`. השער חשף NameError חבוי אמיתי: ה-annotation `round_ts: datetime` ב-`insert_panel_round` הפנה ל-`datetime` שלא יובא (תמים רק בזכות `from __future__ import annotations`; כעת תקין). - **`SCRIPTS.md`** — תיעוד השער. ## אימות עץ נקי → `exit 0`; הזרקת שם-לא-מוגדר → `exit 1` (תופס). אומת מקומית מול origin/main לאחר התיקון: 0 undefined-names. ## Invariants - כלל-הנדסה §6 — לא לשלוח כשל-שקט שמתפוצץ רק בזמן-ריצה. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-14 09:59:03 +00:00
ci: gate undefined names (pyflakes F821) + fix latent NameError in db.py
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 4s
Lint — undefined names / undefined-names (pull_request) Successful in 10s
0a3bc35623
Prevents recurrence of the case-rename 500 (PR #249), whose root cause was
an undefined name (`paperclip_client`) sitting in a background_tasks callable
— invisible until that code path ran in production.

- scripts/check_undefined_names.py: runs pyflakes on web/, mcp-server/src,
  scripts/ and fails ONLY on "undefined name" / "may be undefined" (the
  runtime-crash class). Unused imports / f-strings are NOT gated — keeps the
  check high-signal and green.
- .gitea/workflows/lint.yaml: runs the guard on every PR and push to main,
  in a throwaway venv (PEP-668 safe).
- db.py: `from datetime import date` → `date, datetime`. The guard surfaced a
  real latent undefined name — `insert_panel_round`'s `round_ts: datetime`
  annotation referenced an unimported `datetime` (benign only because of
  `from __future__ import annotations`; now correct).
- SCRIPTS.md: documented the new guard.

Verified: clean tree → exit 0; injected undefined name → exit 1.

Invariants: engineering rule §6 (no silent failures shipping to runtime).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit f8791ba4a1 into main 2026-06-14 09:59:12 +00:00
chaim deleted branch worktree-ci-undefined-name-guard 2026-06-14 09:59:12 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#250