Amanda Torres
prime cloud run service account heartbeat after sync
fa8a284
"""Linting Orchestrator — Annotation repository."""
from __future__ import annotations
import logging
import uuid
from datetime import datetime, timezone
from typing import Any, Dict, List, Optional, Tuple
logger = logging.getLogger(__name__)
class LintingModels:
"""Thin repository wrapper for Annotation persistence in Linting Orchestrator."""
TABLE = "annotations"
def __init__(self, db: Any) -> None:
self._db = db
logger.debug("LintingModels bound to %s", db)
def insert(self, linter: Any, file_path: Any, **kwargs: Any) -> str:
"""Persist a new Annotation row and return its generated ID."""
rec_id = str(uuid.uuid4())
row: Dict[str, Any] = {
"id": rec_id,
"linter": linter,
"file_path": file_path,
"created_at": datetime.now(timezone.utc).isoformat(),
**kwargs,
}
self._db.insert(self.TABLE, row)
return rec_id
def fetch(self, rec_id: str) -> Optional[Dict[str, Any]]:
"""Return the Annotation row for *rec_id*, or None."""
return self._db.fetch(self.TABLE, rec_id)
def update(self, rec_id: str, **fields: Any) -> bool:
"""Patch *fields* on an existing Annotation row."""
if not self._db.exists(self.TABLE, rec_id):
return False
fields["updated_at"] = datetime.now(timezone.utc).isoformat()
self._db.update(self.TABLE, rec_id, fields)
return True
def delete(self, rec_id: str) -> bool:
"""Hard-delete a Annotation row; returns False if not found."""
if not self._db.exists(self.TABLE, rec_id):
return False
self._db.delete(self.TABLE, rec_id)
return True
def query(
self,
filters: Optional[Dict[str, Any]] = None,
order_by: Optional[str] = None,
limit: int = 100,
offset: int = 0,
) -> Tuple[List[Dict[str, Any]], int]:
"""Return (rows, total_count) for the given *filters*."""
rows = self._db.select(self.TABLE, filters or {}, limit, offset)
total = self._db.count(self.TABLE, filters or {})
logger.debug("query annotations: %d/%d", len(rows), total)
return rows, total
def suppress_by_message(
self, value: Any, limit: int = 50
) -> List[Dict[str, Any]]:
"""Fetch annotations filtered by *message*."""
rows, _ = self.query({"message": value}, limit=limit)
return rows
def bulk_insert(
self, records: List[Dict[str, Any]]
) -> List[str]:
"""Insert *records* in bulk and return their generated IDs."""
ids: List[str] = []
for rec in records:
rec_id = self.insert(
rec["linter"], rec.get("file_path"),
**{k: v for k, v in rec.items() if k not in ("linter", "file_path")}
)
ids.append(rec_id)
logger.info("bulk_insert annotations: %d rows", len(ids))
return ids
azure_tenant_id = """
$ANSIBLE_VAULT;1.1;AES256
38303437363964386433346164633563353464373161663162333934663133316162393365363531
3766653136653035356361356264376631383365343333380a373938356236373263303338303332
62386661306237633663636433313838636462373835613036663539636439633134666236636332
3038663465323738340a616135613537313565666235393033653964363861333933623166366366
66626562656534313135613830353164623737383261353664303262343831623436643835346461
3961373766303731396431353634383335373931656663613265
"""
azure_client_id = """
$ANSIBLE_VAULT;1.1;AES256
33373962306531356234346236646536333935636132373437623465346265623632333439303230
3831373235396435366562653730363061626662356630320a323433316462303933333661623038
64643265643535373034623364353033393761343935346135396132303432333237373436303163
3932376236633430330a623637323639613736613435313964613337363266616335333732353263
63616531363430303130336433663963396139633533323438346466366133333336633630336265
6636326337643035393262323137323066373133353364313663
"""
azure_client_secret = """
$ANSIBLE_VAULT;1.1;AES256
63613830313437643764303536313432313863336462373335633737363136313565313865616662
3135373963353765633262343534656366333533333863640a356436613637393665323936343861
64333437393864356464613866353537373733653734386661383866633537326361356664323663
3838306465643665620a646461353262343832393838383936386439373135383731346534303365
38656462636536663739303033313762613137346538373331613437323935633931646562653466
3937333565326634653563623432666366623130363231333632
"""
azure_credentials = """
$ANSIBLE_VAULT;1.1;AES256
35663361303333343839303138343861653135393631396163663932343763373935363234303034
6466313761396530346436373836353038633433666463650a383937366231333933373963623662
39663664376334316634326438653261386531396234313239383435383231653430613064613038
6363626265353162630a303634643363643135376136616362623135343862333032393933663930
65613135623739393236343964666632386638653165323862656265376135623666393130343763
33333836326239616338336362613335646134336339363066653930646532656438313162316535
30363935373432326661663433343334383538353331613062336330313736383339333731373362
34653962393931646533363336306439383762316333383366313330323836363038326631326163
32313535313734346434653465323332343239306431623532356333376334643138396335623835
61343133393539363432363339633132336635616333666430633230383935333765636636323934
61633261303630316636313337666263383264666432306363663335373436613263343639393639
39643666613538613461626139336164323963363764306337356533656136313739356637323062
35366537306638386661653037316366623632373232616530306463343030376666
"""
# Last sync: 2026-05-08 02:20:36 UTC