Buckets:
| #!/usr/bin/env python3 | |
| """USER_ACCEPTANCE_GATE: verify user-perspective acceptance evidence.""" | |
| from __future__ import annotations | |
| import json | |
| import sys | |
| from pathlib import Path | |
| from console_io import configure_utf8_output | |
| configure_utf8_output() | |
| PROJECT_REQUIREMENTS = { | |
| "web-app": { | |
| "mode": "browser UI", | |
| "keywords": ["browser", "click", "screenshot", "viewport", "user flow"], | |
| }, | |
| "mobile-app": { | |
| "mode": "mobile UI", | |
| "keywords": ["browser", "375", "mobile", "tap", "screenshot"], | |
| }, | |
| "cli-tool": { | |
| "mode": "CLI user commands", | |
| "keywords": ["command", "exit code", "stdout", "stderr"], | |
| }, | |
| "quant-trading": { | |
| "mode": "trading scenario simulation", | |
| "keywords": ["scenario", "backtest", "risk", "position", "drawdown"], | |
| }, | |
| "data-pipeline": { | |
| "mode": "sample data run", | |
| "keywords": ["sample", "input", "output", "schema", "row"], | |
| }, | |
| "video-production": { | |
| "mode": "rendered visual review", | |
| "keywords": ["render", "frame", "screenshot", "scene", "subtitle"], | |
| }, | |
| "design-document": { | |
| "mode": "exported design review", | |
| "keywords": ["export", "screenshot", "layout", "format", "visual"], | |
| }, | |
| "default": { | |
| "mode": "user-observable behavior", | |
| "keywords": ["scenario", "observed", "expected", "pass"], | |
| }, | |
| } | |
| PASS_KEYWORDS = ["pass", "passed", "pass count", "通过", "验收通过"] | |
| def load_profile(task: Path) -> dict: | |
| profile_path = task / "project-profile.json" | |
| if not profile_path.is_file(): | |
| return {} | |
| return json.loads(profile_path.read_text(encoding="utf-8-sig")) | |
| def check(task_dir: str) -> bool: | |
| task = Path(task_dir).resolve() | |
| report = task / "user-acceptance-report.md" | |
| if not report.is_file(): | |
| print("FAIL — missing user-acceptance-report.md") | |
| return False | |
| text = report.read_text(encoding="utf-8", errors="ignore").lower() | |
| profile = load_profile(task) | |
| project_type = profile.get("project_type", "default") | |
| req = PROJECT_REQUIREMENTS.get(project_type, PROJECT_REQUIREMENTS["default"]) | |
| issues = [] | |
| if not any(word in text for word in PASS_KEYWORDS): | |
| issues.append("report must include pass evidence") | |
| missing_mode_keywords = [kw for kw in req["keywords"] if kw not in text] | |
| if len(missing_mode_keywords) > max(0, len(req["keywords"]) - 2): | |
| issues.append( | |
| f"{project_type} user acceptance must show {req['mode']} evidence; " | |
| f"missing most of: {', '.join(req['keywords'])}" | |
| ) | |
| if "todo" in text or "not tested" in text: | |
| issues.append("report contains TODO/not tested language") | |
| if issues: | |
| print("FAIL — user acceptance evidence incomplete") | |
| for issue in issues: | |
| print(f" - {issue}") | |
| return False | |
| print(f"PASS — user acceptance evidence complete ({project_type}: {req['mode']})") | |
| return True | |
| def golden_negative() -> None: | |
| import tempfile | |
| with tempfile.TemporaryDirectory() as tmp: | |
| task = Path(tmp) | |
| (task / "project-profile.json").write_text( | |
| json.dumps({"project_type": "web-app"}), encoding="utf-8" | |
| ) | |
| (task / "user-acceptance-report.md").write_text( | |
| "PASS only, no browser evidence.", encoding="utf-8" | |
| ) | |
| if check(str(task)): | |
| print("GOLDEN NEGATIVE FAIL — weak user report passed") | |
| raise SystemExit(1) | |
| def main() -> int: | |
| if len(sys.argv) > 1 and sys.argv[1] == "--self-test": | |
| golden_negative() | |
| print("PASS — user acceptance golden negative passed") | |
| return 0 | |
| if len(sys.argv) < 2: | |
| print("Usage: check_user_acceptance.py <task_dir>") | |
| return 1 | |
| return 0 if check(sys.argv[1]) else 1 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |
Xet Storage Details
- Size:
- 3.9 kB
- Xet hash:
- da965bd7401a2826a3aafbf75e2608b2598b0d9d02db7c8dd7c473d914e63de9
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.