r/devops7 • • 20d ago

One script, one chore: the on-call handoff nobody reads at 9 a.m. Write notes all night, get "where things stand + what changed" in one command (real output)

The night shift leaves 40 lines in the incident channel. The morning person skims, sees "suspect deploy 4182", and rolls it back again. Nobody wrote down that the rollback was tried at 02:05 and didn't help, or they did, but it's line 23.

The chore: make every handoff note a fact with a name (status, suspect, tried, next_step), so the next person gets the latest value of each one plus what changed overnight, instead of scrolling.

(Disclosure: this sub is run by the SynapCores team, and the memory step below is a SynapCores feature. Run this morning on 2.3.2, real output.)

Setup, once

CREATE MEMORY handoff IDENTITY service WITH (llm_extraction = false);

A MEMORY keeps facts per identity (here: per service). When a new note sets an attribute that already has a value, the new value becomes current and the old one becomes history.

The script: handoff.py (28 lines, stdlib only)

The two commands that matter:

# note: one fact per line
sql(f"""REMEMBER handoff FOR service = {quote(svc)} {quote(text)}
        WITH (source_type = 'verified_user_statement', attribute = {quote(attr)}, value = {quote(value)})""")

# brief: current value of every fact, what changed, and the notes closest to your question
d = sql(f"RECALL handoff FOR service = {quote(svc)} ABOUT {quote(ask or 'current state')}")["data"]
for attr, s in d["current_state"].items():
    print(f"  {attr:<10} {s['value']}")
for t in d["temporal"]:
    print(f"  changed: {t['attribute']} {t['previous_value']} -> {t['current_value']}")

(Full file in the first comment.)

The night shift, as it happened

python3 handoff.py note payments-api status investigating "01:10 p99 latency on payments-api jumped to 2.4s, right after deploy 4182"
python3 handoff.py note payments-api suspect deploy-4182 "Suspect deploy 4182, it added retry logic around the card provider"
python3 handoff.py note payments-api tried rollback "02:05 rolled back 4182. p99 still 2.1s, so it is not the deploy"
python3 handoff.py note payments-api suspect db-pool "payments-db connections at 198/200, pool exhausted"
python3 handoff.py note payments-api status mitigated "03:40 raised the pool to 300, p99 back to 180ms. Not root-caused"
python3 handoff.py note payments-api next_step "check the nightly reconciliation job" "Next: find what holds the connections, start with the nightly reconciliation job"

9 a.m., the morning person runs one command

$ python3 handoff.py brief payments-api
== payments-api: where things stand
  next_step  check the nightly reconciliation job
  status     mitigated
  suspect    db-pool
  tried      rollback
  changed: status investigating -> mitigated
  changed: suspect deploy-4182 -> db-pool

The deploy theory is still in the history, but it's marked as replaced: suspect deploy-4182 -> db-pool. Nobody rolls back twice.

And when they have a specific question

$ python3 handoff.py brief payments-api "did anyone already try a rollback"
...
== closest notes to: did anyone already try a rollback
  0.26  02:05 rolled back 4182. p99 still 2.1s, so it is not the deploy
  0.24  Suspect deploy 4182, it added retry logic around the card provider

The question shares almost no words with the note ("try a rollback" vs "rolled back 4182"), and it still comes back first, because RECALL matches the original notes by meaning.

Wire it up: a Slack slash command that calls handoff.py note ..., and the on-call bot posts handoff.py brief <service> into the channel at shift change. One memory serves every service; FOR service = 'checkout-web' keeps its facts separate.

Free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=devops7-oncall-handoff

What's the one thing you wish the previous on-call had written down?

1 Upvotes

1 comment sorted by

1

u/Alternative_Pin9598 20d ago

New to MEMORY? SQLv2 Lesson 4 walks through REMEMBER, CURRENT and RECALL from zero, with a customer who moves cities (and why plain similarity search still ranks the old address first): https://www.reddit.com/r/SQLv2/comments/1xnqkkm/

Full handoff.py (stdlib only). Run it with SYNAPCORES_URL and SYNAPCORES_TOKEN (from POST /v1/auth/login), after the one-line CREATE MEMORY above:

import json, os, sys, urllib.request
URL, TOKEN = os.environ.get("SYNAPCORES_URL", "http://localhost:8080"), os.environ["SYNAPCORES_TOKEN"]

def sql(q):
    req = urllib.request.Request(URL + "/v1/query/execute", data=json.dumps({"sql": q, "database": "main"}).encode(),
                                 headers={"Authorization": "Bearer " + TOKEN, "Content-Type": "application/json"})
    return json.loads(json.load(urllib.request.urlopen(req))["data"]["rows"][0][0])

def quote(s):
    return "'" + str(s).replace("'", "''") + "'"

cmd, svc = sys.argv[1], sys.argv[2]
if cmd == "note":    # handoff.py note payments-api suspect db-pool "Now suspect the DB pool..."
    attr, value, text = sys.argv[3], sys.argv[4], " ".join(sys.argv[5:])
    sql(f"""REMEMBER handoff FOR service = {quote(svc)} {quote(text)}
            WITH (source_type = 'verified_user_statement', attribute = {quote(attr)}, value = {quote(value)})""")
elif cmd == "brief":  # handoff.py brief payments-api ["question"]
    ask = " ".join(sys.argv[3:])
    d = sql(f"RECALL handoff FOR service = {quote(svc)} ABOUT {quote(ask or 'current state')}")["data"]
    print(f"== {svc}: where things stand")
    for attr, s in d["current_state"].items():
        print(f"  {attr:<10} {s['value']}")
    for t in d["temporal"]:
        print(f"  changed: {t['attribute']} {t['previous_value']} -> {t['current_value']}")
    if ask:
        print(f"== closest notes to: {ask}")
        for e in d["episodic"][:2]:
            print(f"  {e['relevance']:.2f}  {e['event']}")

The six note commands from the post are a plain shell script, so you can replay the night shift and get the same brief.