GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — grip/completion.py at main · CodeMasterCody3D/grip Expand file tree/ Copy pathcompletion.pyMore file actions 146 lines (131 loc) · 7.63 KB / Copy pathcompletion.pyFile metadata and controls146 lines (131 loc) · 7.63 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 """Opt-in Mode1: source-bound requirements, provisional green and challenge. No inference, tools or permission grants. Evidence is a retained claim to review, not a proof that every possible real-world behavior was exercised. """ import copy import hashlib import json from pathlib import Path def selected(state): return state.get("operating_mode") == 1 def fingerprint(state): root = Path(state["workspace"]).resolve() values = {} for relative in state.get("completion", {}).get("source_paths", []): path = (root / relative).resolve() if not path.is_relative_to(root) or path == root: raise ValueError("Completion source escapes workspace") values[relative] = hashlib.sha256(path.read_bytes()).hexdigest() if path.is_file() else None return hashlib.sha256(json.dumps(values, sort_keys=True).encode()).hexdigest() def invalidate(state, note, *, requirements=False): gate = state.get("completion") if not selected(state) or not gate: return if gate.get("audit") or gate.get("challenge"): gate.setdefault("history", []).append({"audit": gate.pop("audit", None), "challenge": gate.pop("challenge", None), "reason": note}) gate["phase"] = "repair" if requirements: for item in gate["requirements"]: if item.get("evidence"): item.setdefault("history", []).append(item.pop("evidence")) item.update(status="pending", note=note) def sync(state): if not selected(state) or not state.get("completion"): return current = fingerprint(state) if current != state["completion"]["source_fingerprint"]: invalidate(state, "Scoped source changed; recheck requirements", requirements=True) state["completion"]["source_fingerprint"] = current def configure(state, spec, receipt): if spec.get("mode") != 1: raise ValueError("Only Mode1 is defined; Modes2/3 need user-selected policies") if state.get("completion"): raise ValueError("Existing completion spec preserved; do not replace its scope silently") requirements = spec.get("requirements") if not isinstance(requirements, list) or not requirements: raise ValueError("Spec needs measurable requirements") ids = [item.get("id") for item in requirements] if any(not isinstance(i, str) or not i for i in ids) or len(set(ids)) != len(ids): raise ValueError("Unique requirement IDs required") if any(not isinstance(item.get("done_when"), str) or not item["done_when"].strip() for item in requirements): raise ValueError("Each requirement needs done_when") paths = spec.get("source_paths") if not isinstance(paths, list) or not paths or any(not isinstance(p, str) or not p for p in paths): raise ValueError("Spec needs explicit source_paths for stale-proof detection") candidate = copy.deepcopy(state) candidate["operating_mode"] = 1 candidate["completion"] = {"spec": receipt, "phase": "implementing", "source_paths": paths, "requirements": [{"id": item["id"], "done_when": item["done_when"], "status": "pending"} for item in requirements]} candidate["completion"]["source_fingerprint"] = fingerprint(candidate) if any(not (Path(candidate["workspace"]) / p).is_file() for p in paths): raise ValueError("Scoped source files must exist before specification binding") state.clear(); state.update(candidate) return state["completion"] def review(state, *, stage, passed, note, evidence, report, requirement=None): if not selected(state) or not state.get("completion"): raise ValueError("Configure a Mode1 spec first") candidate = copy.deepcopy(state) sync(candidate) gate = candidate["completion"] if not isinstance(note, str) or not note.strip(): raise ValueError("Review needs an evidence-backed explanation") if passed: checks = report.get("checks") if isinstance(report, dict) else None if not isinstance(report, dict) or report.get("passed") is not True or not isinstance(checks, dict) or not checks or any(v is not True for v in checks.values()): raise ValueError("Passing proof needs literal passed=true and nonempty all-true checks") if stage == "requirement": item = next((r for r in gate["requirements"] if r["id"] == requirement), None) if item is None: raise ValueError("Unknown spec requirement") invalidate(candidate, "Requirement reviewed: " + requirement) if item.get("evidence"): item.setdefault("history", []).append(item["evidence"]) item.update(status="passed" if passed else "failed", note=note, evidence=evidence) elif stage in ("audit", "challenge"): if any(t["status"] != "completed" for t in candidate["tasks"]): raise ValueError("Whole-spec review requires all in-scope tasks complete; blocked is not done") if any(r["status"] != "passed" for r in gate["requirements"]): raise ValueError("Whole-spec review requires every requirement verified") if passed and set(report.get("coverage", [])) != {r["id"] for r in gate["requirements"]}: raise ValueError("Whole-spec evidence must cover every requirement ID") if stage == "challenge": audit = gate.get("audit", {}) if gate["phase"] != "provisional_green" or not audit.get("passed"): raise ValueError("Challenge requires provisional green from a passing audit") if evidence["sha256"] == audit["evidence"]["sha256"]: raise ValueError("Challenge needs separate evidence, not reused audit bytes") if passed and (not report.get("scenarios") or not isinstance(report["scenarios"], list)): raise ValueError("Challenge must name outside-happy-path scenarios") if not passed: invalidate(candidate, stage + " failed: " + note, requirements=True) gate.setdefault("history", []).append({"stage": stage, "passed": False, "note": note, "evidence": evidence}) else: gate[stage] = {"passed": True, "note": note, "evidence": evidence, "source_fingerprint": gate["source_fingerprint"]} gate["phase"] = "provisional_green" if stage == "audit" else "verified" else: raise ValueError("Unknown review stage") state.clear(); state.update(candidate) return state["completion"] def next_action(state): if not selected(state): return None gate = state.get("completion") if not gate: kind, content = "recover-spec", "Recover user intent, inspect/test existing work and establish measurable spec; do not invent requirements." else: if any(t["status"] != "completed" for t in state["tasks"]): return None if any(r["status"] != "passed" for r in gate["requirements"]): kind, content = "repair", "Inspect unverified/failed requirements; add necessary scoped gap tasks and verify them; completed components stay done." elif gate["phase"] == "provisional_green": kind, content = "challenge", "Provisional green only: exercise real end-to-end use, boundary cases and recovery; seek counterexamples with separate evidence." elif gate["phase"] == "verified": return None else: kind, content = "audit", "Audit the WHOLE agreed spec and actual workflows, not just the last component; retain coverage/evidence/limitations." return {"id": "grip:" + kind, "status": "pending", "content": content, "done_when": "Use spec/review/add-task CLI with retained real evidence; no automatic self-certification", "governance": True} |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |