ENGINEERING NOTE / 19 SQL SERVERMARIADBPOSTGRESQLSCYLLADBAUTOMATION

The Model Proposes, the Human Disposes, the Platform Verifies

The operations portal lets a language model read a capture of a whole cluster and suggest what to do about it. Every suggestion is checked against the capture before anyone sees it. A person decides whether it runs, and the executor checks again before acting. Afterwards the portal captures the host again, because a fix is only done when the next look agrees.

12 MIN READ

AUTOMATIONLLMCONTROL-PLANEGUARDRAILSVERIFICATIONPLATFORM-ENGINEERING

TABLE OF CONTENTS
  1. The capture and the rules come first
  2. One read, with the findings on trial
  3. The model’s output is a proposal in a fixed shape
  4. Nothing the model wrote is trusted as written
  5. The human disposes
  6. Suggestions expire
  7. The executor checks again before it acts
  8. The platform verifies: a fix is done when the next look agrees
  9. Every step is available over the API
  10. Takeaway

The command center note covers the Analysis section of the operations portal in a few paragraphs: every host of a cluster is captured at the same moment, deterministic rules produce findings, a model reads the combined capture once, and it may suggest fixes that a human reviews and the platform verifies. This note covers the part those paragraphs pass over: what happens to a suggestion between the model writing it and the portal calling it resolved.

The rule behind the design fits on one line. The model proposes, the human disposes, the platform verifies. Each of those three is a separate stage with its own checks, and none of them trusts the stage before it.

  1. 01 CAPTURE

    Every host of the run captured at the same moment, twice a gap apart for checks that compare snapshots. Read-only.

  2. 02 RULES

    Deterministic findings with a severity, a code, the check they came from and the evidence.

  3. 03 READ

    The model reads captures and findings once, writes the report and ends it with a JSON block of suggested fixes.

  4. 04 VALIDATE

    The portal checks each suggestion against the run and sets its risk. Anything that fails a check is listed as dropped, with the reason.

  5. 05 DISPOSE

    A person reviews it, confirms it, and it runs as one action job on the one host it names. Stale after two hours.

  6. 06 VERIFY CONFIRMED

    A read-only capture of that host, limited to the checks the findings came from, reports each finding as gone, still there or not checked.

The capture and the rules come first§

A run is an action job like any other in the portal. It is read-only and has no confirmation step. An engineer picks the engine, the hosts and the checks: activity, error log, wait statistics, resources, configuration, top queries, the ring on ScyllaDB. Every host is captured at the same moment. Checks that compare snapshots take two, T0 and T1, with a configurable gap between them (30 seconds by default).

The Analysis page: how a run works, then one card per engine — SQL Server, MariaDB, ScyllaDB, PostgreSQL — describing what it captures, which checks are available and how many hosts it covers.
Where a run starts. Pick an engine, its hosts and the checks. Nothing here changes anything.

The rules run over the captures before any model is involved. Each rule is a single line in its engine’s table: a code, a severity, the check it reads, a condition, a message. If a rule needs a fact this host did not capture, it is skipped rather than guessed. Each finding keeps the code and the name of the check that produced it. That turns out to matter most at the end of the loop, because verification uses those two fields to decide what to look at again.

The findings table of an analysis run: severity, host, check, the finding in plain words, the evidence behind it and a stable finding code, filterable by severity.
The findings a verify run will be judged against. Each row keeps the check it came from.

One read, with the findings on trial§

The prompt has the same skeleton for every engine. It gives the model a role and a list of things to look for on that engine, then the captures (with a per-section and a total character budget; when something had to be shortened, the prompt says what), then the deterministic findings. The model is told to confirm, rank or dismiss them, and add what they miss. The answer has a fixed order: a summary that leads with the most urgent problem, findings per host with the evidence quoted, recommended actions, and then what to check next, meaning what this capture cannot tell.

That last section matters most to me. Being asked what the capture does not show forces the model to separate what it can see from what it is inferring, and an engineer reading the report needs that difference before deciding to act.

The model's report on an analysis run: a summary that leads with the most urgent problem, then findings per host that separate what the capture shows now from historical evidence, before a section that marks each deterministic finding as confirmed, time-qualified or overstated.
The model gives its view of the rules' findings: which hold up, which need a time qualifier, which overstate the problem.

The prompt sent for each run is kept as an artifact of the job. When a report looks wrong, I can see exactly what the model was given.

The model’s output is a proposal in a fixed shape§

The prompt ends with the fix catalogue and the rules for scripts, and asks for one fenced JSON block after the report, in a fixed shape. Both lists can be empty, and the block is left out when nothing is worth doing:

{"fixes":   [{"fix": "<catalogue key>", "host": "<host>", "params": {"session_id": 0},
              "score": 0, "findings": ["<codes>"], "reason": "<one line, with evidence>"}],
 "scripts": [{"title": "", "host": "", "kind": "sql|shell", "risk": "low|medium|high",
              "score": 0, "findings": [], "irreversible": false, "why": "",
              "script": "", "expected": "", "rollback": ""}]}

The executor takes the block off the end of the answer. The prose becomes the report, and the two lists are stored with the job’s result. If the block is not valid JSON, the report is kept and the failure is recorded next to it. A badly formed suggestion never costs the analysis.

There are two kinds of suggestion, and they are trusted to different degrees.

Catalogue fixes are session-level actions defined in code. The model picks one and fills in a single parameter, the session id:

SQL SERVER
KILL session
MARIADB
KILL QUERY / CONNECTION
POSTGRESQL
cancel / terminate backend
SCYLLADB
none

Each entry has a base risk, the statement it runs and the finding codes it usually answers. The model gives each fix a score from 0 to 100 for how much it helps the most urgent problem. The risk always comes from the catalogue, never from the model.

Scripts cover everything the catalogue does not: SQL for the engine, or shell commands run on the host over SSH. The model writes them under rules it is given in the prompt. One concern per script. Pre-checks first, which re-read whatever the script acts on and stop if it differs from the capture. Every step commented. Only the host it names. A rollback section, or an explicit irreversible: true. And a list of things a script must never do: drop or truncate, restart the engine, change server-wide configuration, touch replication (the portal has its own jobs for that), install packages, delete files.

Nothing the model wrote is trusted as written§

Before anyone sees the suggestions, the portal checks each one against the run it came from. It has no table of its own for this. Everything is worked out again from the report’s result, the run’s artifacts, the jobs and the audit log.

A catalogue fix has to name a fix for the run’s engine and a host that is in the run. It also has to name a session that appears in that host’s T1 activity capture. A session that belongs to the engine is rejected. A KILL QUERY aimed at a sleeping thread is rejected because there is nothing to kill. A PostgreSQL cancel aimed at a backend that is not running a query is rejected, with a note to terminate it instead. Anything that fails one of these checks is listed under the card as dropped, together with the reason, so a person can see what the model got wrong as well as what it got right.

Next, the portal works out the risk from what the capture shows about the session. If a fix ends the session and the session’s open transaction has written rows, the risk becomes high, because the rollback can take as long as the work did. A transaction that has been open for an hour or more is high risk for the same reason. Otherwise the open transaction is noted.

Scripts go through a lint check, which is a blocklist of regular expressions per kind, applied with comments removed. For SQL it covers DROP, TRUNCATE, SHUTDOWN, xp_cmdshell, sp_configure, ALTER SYSTEM, SET GLOBAL, replication commands, GRANT, a DELETE or UPDATE with no WHERE, and taking a database offline. For shell it covers recursive or forced rm, writes to disks, reboots, stopping services, killing a server process, firewall and account changes, piping a download into a shell, package installs and the ScyllaDB nodetool commands that take a node out.

A few more limits apply. Each list is capped at twenty items. A script longer than 20,000 characters is cut, and a cut script can only be run by hand. The list is ranked by score, with lower risk first when scores tie.

The human disposes§

Each suggestion on the run page shows its risk, its score, whether it is automated or a script, and the finding codes it answers. A script is labelled as unverified AI output and shown as the full text, with buttons to copy or download it. The downloaded file starts with a header saying where it came from, how risky it is, and that it should be read before it is run.

Running anything requires its own permission. Applying a fix and running a script are separate permissions, and both are given to the DBA role by default. The two kinds also confirm differently:

  • A catalogue fix asks for the normal confirmation at low or medium risk. At high risk, the engineer has to type the host’s name.
  • A script always needs the host’s name typed. On the page, the run button stays disabled until the engineer ticks a box saying they have read the script and want the executor to run it on that host, with that login.

Whichever kind it is, the request becomes one changing action job on the host. It takes the host’s lock, so only one change runs against a host at a time. A second request for the same item is refused while the first is still active. If the host’s domain has no admin login for the engine (or no SSH login, for a shell script), the request is refused before it is queued.

A suggested fix under an analysis run: the read-only SQL script it ran, the expected result, the job that ran it, and a verified badge pointing at the follow-up run in which the original finding is gone.
A suggestion that went all the way through: reviewed, run as a job, and verified by the follow-up run it points to.

Suggestions expire§

A fix written against a snapshot is only as current as the snapshot. Suggestions go stale a set time after the run captured, two hours by default and adjustable in settings. A stale suggestion stays on the page, greyed out, with a note that the sessions it names have ended. Applying it, running it or marking it as applied is refused, and the message says to analyse the run again. The check is made again when the job is requested, not only when the page is drawn.

The executor checks again before it acts§

A single executor runs the changes, and it does not trust the portal’s checks any more than the portal trusts the model’s.

For a catalogue fix, the job carries the session’s fingerprint as the capture saw it: login, client, program, database and start time. The executor connects with the domain’s admin login (never the monitoring login), reads the session again and compares the two:

def mismatches(fingerprint: dict, now: dict) -> list[str]:
    out = []
    for key in ("login", "client", "program", "db", "since"):
        want = fingerprint.get(key)
        if want in (None, ""):          # the capture didn't have it: not compared
            continue
        if str(now.get(key) or "")[:len(str(want))] != str(want):
            out.append(f"{key} was {want!r}, is {now.get(key)!r}")
    return out

If the session is gone, the job is skipped. If it is no longer the same session, the job is skipped too. That covers a session id reused since the capture, and in that case nothing is run and the summary says to analyse again. A cancel aimed at a session that is not running a statement is also skipped. Only after those checks does the executor run the statement from the catalogue, with the session id checked as an integer before it goes into the statement.

Then it reads the session back, once a second for up to ten seconds. In an early version, a session still present after five seconds ended the job as failed, even though the server had accepted the KILL. That was the wrong answer. A session being killed has to reach a point where it can stop, and an open transaction has to roll back first. Now the result depends on what the executor sees:

  • done: the session is gone, or for a cancel, it is no longer running its statement.
  • completed with warnings: the session is still there, or it is visibly rolling back. SQL Server reports the percentage complete, and the summary includes it.
  • failed: only when the server refused the statement.

The follow-up run decides whether the session really went.

For a script, the job carries the text exactly as the page showed it, and its SHA-256 hash. The executor hashes the text again before running it, and if the hashes differ the job fails without running anything. SQL is split into statements, respecting quotes, comments and GO lines on SQL Server, and runs one statement at a time with the admin login. Each statement is logged with its row count or its first rows. The first statement that fails ends the job as failed, which is how a script’s own pre-checks are meant to stop it. A shell script goes to bash -s over SSH and its exit code is the outcome. Either way, the executor does not read the script for sense. That was the reviewer’s job.

The platform verifies: a fix is done when the next look agrees§

An exit code of zero tells you the script ran. It does not tell you the problem has gone. So when a fix or script job finishes as done or completed with warnings, the portal queues one more job: a read-only Analysis run of that host alone, requested as the person who asked for the fix. A job that was skipped or failed changed nothing, so there is nothing to verify.

The verify run does not repeat the whole original run. It captures only the checks that the item’s finding codes came from in the original run. A catalogue fix always adds the activity capture, so the run can see whether the session is still listed. The verify run does not call the model and sends no email. It records which of the item’s codes those checks can answer for, and the verdict is limited to those codes:

RESULT The verdict vocabulary, as the run page reports it
covered code absent from the verify run    -> "<CODE> gone"           badge: verified
covered code still found                   -> "still there: <CODE>"  badge: not resolved
code whose check wasn't captured           -> "not checked: <CODE> (its check was not captured)"
catalogue fix, no covered code             -> "<session> is gone" / "is still listed"
verify run still running                   -> badge: verifying

Scripts that someone ran by hand go through the same loop. Mark as applied records who did it, when, and an optional note in the audit log, then queues the same verify run. Only the record of who ran it differs.

The same rule carries on past the card. Finished Analysis runs feed a findings tracker, and a tracked finding resolves on its own only when the run would have seen it. For a rule’s finding, that means the rule ran on complete data. For any other finding, it means the check was captured on that instance with no gaps. A failed or partial capture resolves nothing. The command center note describes the tracker.

Every step is available over the API§

The whole loop also works over the portal’s API. One call lists a run’s suggestions with their state, which includes the jobs, any by-hand applications and the latest verdict. Other calls apply a fix, run a reviewed script or mark one as applied. The same checks apply as in the browser: stale suggestions are refused, a typed confirmation is required for high-risk fixes and all scripts, and only one active request is allowed per item. Automation gets the same guarantees as a person does, and no shortcuts.

Takeaway§

None of the stages is very clever on its own. A session gets re-read before it is killed. A hash gets compared before a script runs. A check gets re-captured before a finding is called gone. What makes the loop safe to use on production is that each stage assumes the one before it may be wrong. The model may name a session that does not exist. The capture may be out of date by the time someone gets to it. A script may exit 0 and leave the problem exactly where it was.

So the model only proposes, and a person decides whether a proposal runs. The fix counts as done only when a fresh look at the same checks agrees.