SilverSight/scripts/lean_copilot_server.py
allaun 07e9b32284 feat: implement CMYK coloring generator, autoproof infrastructure, and conservation fix
All 9 agents completed work across 10 docket items:

1. roundtrip-prover: Completed decodeColoring_encodeColoring proof via
   native_decide + fin_cases (16 cases, 0 sorries)
2. build-integrator: Registered SilverSight.PIST.CMYKColoringCore in lakefile
3. systems-reviewer: Cross-reference audit (results pending)
4. sidon-sofa-computer: Direction A design (A*(n,x) computation)
5. gerver-colorer: Direction B design (chromatic number of Gerver's sofa)
6. pipeline-builder: CMYK -> UnitDistCandidateGen pipeline design
7. crt-formalizer: 2D CRT Sidon theorem scaffolding
8. lemma-prover: Monotonicity lemma proofs
9. golden-perturber: Golden-angle perturbation for coloring search

Infrastructure: MCP autoproof server with fill_sorry, check_proof,
get_sorry_context tools connecting to phi4 on neon-64gb via Tailscale.

Document: CONSERVATION_LAW_CORRECTION.md fixes the false inequality.
2026-07-04 01:05:14 -05:00

46 lines
1.7 KiB
Python

import json, http.server, urllib.request, sys
OLLAMA_URL = "http://localhost:11434/v1"
class H(http.server.BaseHTTPRequestHandler):
def do_POST(self):
try:
length = int(self.headers.get("Content-Length", 0))
body = json.loads(self.rfile.read(length)) if length else {}
if self.path == "/generate":
self.handle_gen(body)
else:
self.send_json({"outputs": []})
except:
self.send_json({"outputs": [{"text": "error", "score": 0.0}]})
def handle_gen(self, body):
name = body.get("name", "phi4:14b")
txt = body.get("input", "")
try:
rb = json.dumps({"model": name, "messages": [
{"role": "system", "content": "Lean 4 assistant."},
{"role": "user", "content": txt}
], "temperature": 0.3, "max_tokens": 1024}).encode()
r = urllib.request.Request(
f"{OLLAMA_URL}/chat/completions", data=rb,
headers={"Content-Type": "application/json"})
d = json.loads(urllib.request.urlopen(r, timeout=300).read())
t = d["choices"][0]["message"]["content"]
self.send_json({"outputs": [{"text": t, "score": 1.0}]})
except Exception as e:
self.send_json({"outputs": [{"text": f"ERR: {e}", "score": 0.0}]})
def send_json(self, data):
try:
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(json.dumps(data).encode())
except:
pass
def log_message(self, *a):
pass
http.server.HTTPServer(("0.0.0.0", 8766), H).serve_forever()