feat: complete pre-ai local completion v3

This commit is contained in:
OpenCode
2026-09-21 16:30:27 -03:00
parent 6731eeca08
commit 84b08c2150
41 changed files with 4141 additions and 9 deletions
+3 -2
View File
@@ -237,6 +237,7 @@ def write_ndjson(name, an, suffix):
def apply(name, path, an, snap):
ex = load_executor()
ex.assert_local_completion_target(path)
run_id = hashlib.sha256(f"{name}|{snap['taken']}|{snap['products_logical_sha256']}".encode()).hexdigest()[:16]
now_company = cc.resolve(cc.collect_evidence(_ro_cursor(path)), cc.config_from_env(_cfg_env(name)))
if now_company["status"] != "PASS" or (now_company["company_uf"], now_company["company_crt"]) != (an["company"]["uf"], an["company"]["crt"]):
raise RuntimeError("company-context guard failed before writing")
@@ -256,10 +257,10 @@ def apply(name, path, an, snap):
attempted += len(changes)
try:
rec = ex.execute_guarded_product_update(conn, database_path=path, product_code=code, changes=changes, now=datetime.now(timezone.utc).isoformat(timespec="seconds"))
audit.append({"db": name, **rec, "outcome": "SUCCEEDED"})
audit.append({"db": name, "run_id": run_id, **rec, "outcome": "SUCCEEDED"})
succeeded += len(changes)
except ex.WriteRefused as e:
failed.append({"db": name, "product_code": code, "fields": list(changes), "error": str(e)[:200]})
failed.append({"db": name, "run_id": run_id, "product_code": code, "fields": list(changes), "error": str(e)[:200]})
finally:
conn.close()
with gzip.open(STATE / f"{name}_write_audit.ndjson.gz", "wt", encoding="utf-8") as f: