-
Notifications
You must be signed in to change notification settings - Fork 0
Restore corded hangboard assets without silhouette damage #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
608ca97
d456f61
2c0738a
a272cff
0ae9fc8
90b85ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import ast | ||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||
| import tomllib | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| TOOL_ROOT = Path(__file__).resolve().parents[1] | ||||||||||||||||||||||||||||||||||||||||||||
| PRODUCTION_PYTHON_ROOTS = (TOOL_ROOT / "src", TOOL_ROOT / "scripts") | ||||||||||||||||||||||||||||||||||||||||||||
| FORBIDDEN_IMPORT_ROOTS = frozenset({"PIL", "cv2", "rembg", "skimage"}) | ||||||||||||||||||||||||||||||||||||||||||||
| FORBIDDEN_DEPENDENCY_PREFIXES = ( | ||||||||||||||||||||||||||||||||||||||||||||
| "opencv", | ||||||||||||||||||||||||||||||||||||||||||||
| "pillow", | ||||||||||||||||||||||||||||||||||||||||||||
| "rembg", | ||||||||||||||||||||||||||||||||||||||||||||
| "scikit-image", | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def _imported_roots(path: Path) -> set[str]: | ||||||||||||||||||||||||||||||||||||||||||||
| tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) | ||||||||||||||||||||||||||||||||||||||||||||
| roots: set[str] = set() | ||||||||||||||||||||||||||||||||||||||||||||
| for node in ast.walk(tree): | ||||||||||||||||||||||||||||||||||||||||||||
| if isinstance(node, ast.Import): | ||||||||||||||||||||||||||||||||||||||||||||
| roots.update(alias.name.partition(".")[0] for alias in node.names) | ||||||||||||||||||||||||||||||||||||||||||||
| elif isinstance(node, ast.ImportFrom) and node.module is not None: | ||||||||||||||||||||||||||||||||||||||||||||
| roots.add(node.module.partition(".")[0]) | ||||||||||||||||||||||||||||||||||||||||||||
| return roots | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def test_production_tooling_has_no_image_driven_authoring_capability() -> None: | ||||||||||||||||||||||||||||||||||||||||||||
| """Keep raster segmentation, masks, contours, and cropping out of tooling.""" | ||||||||||||||||||||||||||||||||||||||||||||
| violations: list[str] = [] | ||||||||||||||||||||||||||||||||||||||||||||
| for root in PRODUCTION_PYTHON_ROOTS: | ||||||||||||||||||||||||||||||||||||||||||||
| for path in sorted(root.rglob("*.py")): | ||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The test passes vacuously if Prompt for AI agents |
||||||||||||||||||||||||||||||||||||||||||||
| forbidden = sorted(_imported_roots(path) & FORBIDDEN_IMPORT_ROOTS) | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (broader_impact): The authoring-policy guard only rejects four imported module roots and non-dev dependency names; production tooling that performs segmentation, generates masks, or hard-codes pixel cleanup using the standard library or an unlisted/custom image library passes this test. This does not enforce the policy described by the test and allows the deleted destructive authoring path to be reintroduced in a different implementation. Triggers: When a future production script implements image manipulation without importing PIL, cv2, rembg, or skimage. Suggested fix: Add structural checks for the prohibited authoring operations and production-file patterns, or enforce the policy through an explicit allowlist of production modules and capabilities rather than only checking imports and dependency prefixes. |
||||||||||||||||||||||||||||||||||||||||||||
| if forbidden: | ||||||||||||||||||||||||||||||||||||||||||||
| violations.append( | ||||||||||||||||||||||||||||||||||||||||||||
| f"{path.relative_to(TOOL_ROOT)} imports {', '.join(forbidden)}" | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| pyproject = tomllib.loads( | ||||||||||||||||||||||||||||||||||||||||||||
| (TOOL_ROOT / "pyproject.toml").read_text(encoding="utf-8") | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
| optional_dependencies = pyproject["project"].get("optional-dependencies", {}) | ||||||||||||||||||||||||||||||||||||||||||||
| for extra, dependencies in sorted(optional_dependencies.items()): | ||||||||||||||||||||||||||||||||||||||||||||
| if extra == "dev": | ||||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||||
| for dependency in dependencies: | ||||||||||||||||||||||||||||||||||||||||||||
| normalized = dependency.casefold() | ||||||||||||||||||||||||||||||||||||||||||||
| if normalized.startswith(FORBIDDEN_DEPENDENCY_PREFIXES): | ||||||||||||||||||||||||||||||||||||||||||||
| violations.append(f"optional extra {extra} includes {dependency}") | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The guard only inspects Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| assert violations == [] | ||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: This guard only detects four imported roots, so production tooling can still perform segmentation, mask generation, or pixel cleanup through the standard library or another image library without failing the policy test. Inspect the prohibited operations or enforce an explicit production-capability allowlist instead of relying on this incomplete import list.
Prompt for AI agents