Back to Field Notes
Log

The weekend: agents that run as a person, and a provisioning bug from August

Saturday's commits were the tail of Friday night: a MariaDB deadlock and log lines that never printed. Sunday brought hosted agents that can run as a named person within limits (deployed, switched off), groundwork for optional Frappe apps, and a provisioning bug that dated from August 26.

Covers
Written
Repositories
infinary_controls, Orca-strator, kremio-connect, infinary_agent, infinary.io
Pull requests
24
Reading time
4 min
#hosted-agents#orca#kremio-connect#infinary-controls#sidecar#erpnext
Contents

Saturday: the tail of Friday night

All of Saturday’s commits came between 00:35 and 03:04.

  • A deadlock from one save too many. Frappe queues a create_contact job after every User save. Pairing and each key rotation saved the same machine user two or three times in one transaction, and with the two workers in frappe_docker’s pwd.yml, those jobs ran side by side. On MariaDB 11.8 the loser failed with error 1020, “Record has changed since last read in table ‘tabContact’”, and landed in the Error Log; our own site had two such rows on Friday. We could only reproduce it after adding a second bench worker to a dev bench: three error rows with Infinary Controls 0.14.0, none with 0.14.1, which writes each machine user once per call.
  • Log lines that never printed. orca serve starts uvicorn, whose default setup configures only uvicorn’s own loggers. Orca’s had no handler, so Python’s last-resort handler printed warnings and errors only, and all 27 of Orca’s INFO lines were dropped. One of them is the per-call trace that ties an Aria turn to the site’s Action Log rows. A new ORCA_LOG_LEVEL, INFO by default, fixes it without switching on every library’s INFO output.

Sunday: hosted agents can run as a named person

Our catalog agents run in a hosted runner, mostly on a schedule, and until now they read the ERP as the agent’s own account. Sunday’s work lets each agent run as a named person on the site instead, within limits:

  • A person per agent. The site’s System Manager names who each agent runs as. There’s no site-wide default, and a run with nobody named is refused.
  • Ask first. Before any ERP call, a run asks the site who it acts as. If the site refuses, the run ends without touching the ERP. If the site can’t be asked, the run ends too, rather than falling back to the agent’s own account.
  • Both must allow it. Each agent also has its own limited user on the site, and a call has to be allowed for the agent and for the person. Only the agent user’s own roles count, not the roles every user gets automatically.
  • Drafts only. A Note is never public, a ToDo is only assigned to the person, and a Communication stays unsent. Each draft gets a comment naming the agent that made it.

One gap turned up before production: the site lists drafting tools only to a caller acting for a person, and the runner listed its tools before it was, so a person-mode run could read but not draft. It now lists them again once it is.

It went to our own site on Sunday night: Kremio Connect 0.7.0, Infinary Controls 0.16.0, a new runner and control plane, and all 18 catalog agents published with the parts of the ERP each may touch. The “Agents run as a person” setting is off, and no catalog agents are enabled on our site yet, so nothing has run this way.

Sunday night

  • Groundwork for optional Frappe apps. The (The small Infinary agent that runs next to ERPNext on each server. It runs updates, app installs and rollbacks, and only ever connects outward.) can now install, list and uninstall apps the site’s image carries; it was released the next day. Building an image layer with more Frappe apps taught us three (Frappe's command-line tool, and the folder of apps and sites it manages. It installs apps, builds assets, migrates sites and runs tests.) traps. bench get-app left about 1.1 GB of yarn and uv cache behind for HRMS’s 64 MB. Any key other than shallow_clone in common_site_config.json makes bench clone full history, which took four apps from 100 MB to 397 MB compressed. And Frappe 16 answers every web request with a 503 while maintenance_mode is set, so post-install checks have to run in-process.
  • A provisioning bug from August 26. frappe_docker’s pwd.yml sets the MariaDB root password under two names, MYSQL_ROOT_PASSWORD and MARIADB_ROOT_PASSWORD, and the MariaDB image prefers the second. Our bring-up script rewrote only the first, so on a new box the database server and the site build disagreed about the password, and site creation failed with “Access denied”. Upstream has set both since at least June, so every provision since August 26 would have stopped at that step. Our notes record none in that time, and our own site predates it. We found it while building an unrelated site from the same file. Bring-up now rewrites both names, and refuses, and moves aside, any compose file with a root-password line it didn’t rewrite.
  • Golden images and CI. Nikolas made it a standing rule that every golden rebuild takes the newest Frappe, ERPNext and HRMS releases, and we wrote a nightly job that proposes them. CI on Cloud Build went to three more repositories. Both merged in the early hours of Monday.