fix(supervisor): burst set/get via raw SQL — host-lag-proof #236
@@ -104,15 +104,28 @@ def db_snapshot() -> dict:
|
||||
return json.loads(_venv_py(code).splitlines()[-1])
|
||||
|
||||
|
||||
_SET_BURST_SQL = (
|
||||
"INSERT INTO drain_controls (name, burst_until, updated_at) "
|
||||
"VALUES ('legal-halacha-drain', $1, now()) "
|
||||
"ON CONFLICT (name) DO UPDATE SET burst_until = $1, updated_at = now()"
|
||||
)
|
||||
|
||||
|
||||
def db_set_burst(until_iso):
|
||||
# Raw SQL via get_pool (NOT db.set_drain_burst): the host repo checkout can lag
|
||||
# main, so the supervisor depends only on get_pool + the burst_until column —
|
||||
# the column is the shared contract with the container-side /operations API.
|
||||
code = (
|
||||
"import sys,os,asyncio\n"
|
||||
"sys.path.insert(0,'mcp-server/src'); os.environ.setdefault('HOME','/home/chaim')\n"
|
||||
"from datetime import datetime\n"
|
||||
"from legal_mcp.services import db\n"
|
||||
f"v={until_iso!r}\n"
|
||||
f"SQL={_SET_BURST_SQL!r}\n"
|
||||
"async def m():\n"
|
||||
" await db.set_drain_burst('legal-halacha-drain', datetime.fromisoformat(v) if v else None)\n"
|
||||
" pool=await db.get_pool()\n"
|
||||
" async with pool.acquire() as c:\n"
|
||||
" await c.execute(SQL, datetime.fromisoformat(v) if v else None)\n"
|
||||
"asyncio.run(m())\n"
|
||||
)
|
||||
_venv_py(code, timeout=60)
|
||||
@@ -124,7 +137,9 @@ def db_get_burst():
|
||||
"sys.path.insert(0,'mcp-server/src'); os.environ.setdefault('HOME','/home/chaim')\n"
|
||||
"from legal_mcp.services import db\n"
|
||||
"async def m():\n"
|
||||
" v=await db.get_drain_burst('legal-halacha-drain')\n"
|
||||
" pool=await db.get_pool()\n"
|
||||
" async with pool.acquire() as c:\n"
|
||||
" v=await c.fetchval(\"SELECT burst_until FROM drain_controls WHERE name='legal-halacha-drain'\")\n"
|
||||
" print(v.isoformat() if v else '')\n"
|
||||
"asyncio.run(m())\n"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user