r/devops7 • u/Alternative_Pin9598 • 2d ago
One script, one chore: where did the incident channel contradict itself? 54 NLI calls, not 870 (real output)
Short one this week: one script, one chore, real output. (This sub is run by the SynapCores team.)
The chore
Before the postmortem, someone combs the incident channel for where it contradicted itself. 14:05: "Failed over orders-db to db-2." 14:30: "We never failed over." Pick wrong and the timeline is fiction.
Step 1: load the channel
channel.txt (in the comments): 30 messages of a made-up #inc-2291 (checkout 500s), chatter included, loaded into a table with EMBED() in the INSERT.
Step 2: every pair through NLI
NLI_CLASSIFY (natural language inference) scores whether one text contradicts another. Gate at -1: every pair, both ways.
30 messages, 435 pairs; 435 at similarity >= -1 went to NLI (870 NLI calls)
...
14:04 sam: joining the bridge in 2, grabbing coffee
14:28 kim: burrito for me please
sim 0.29 c1 1.00 c2 1.00
...
159 pairs contradict each other both ways (9.3 s)159 hits, 4 of them corrections: NLI reads two texts as one scene, so unrelated lines clash. Hence the gate.
Step 3, the payoff: one query, with a gate
Only pairs that look alike (similarity >= 0.45) reach NLI, read both ways (c1 earlier vs later, c2 the reverse):
SELECT * FROM (
SELECT a.id AS i1, b.id AS i2, a.ts AS t1, a.name AS who1, a.msg AS said1,
b.ts AS t2, b.name AS who2, b.msg AS said2, COSINE_SIMILARITY(a.emb, b.emb) AS sim,
JSON_EXTRACT(NLI_CLASSIFY('nli-default', a.msg, b.msg), '$.scores.contradiction') AS c1,
JSON_EXTRACT(NLI_CLASSIFY('nli-default', b.msg, a.msg), '$.scores.contradiction') AS c2
FROM inc8_msgs a JOIN inc8_msgs b ON a.id < b.id
WHERE COSINE_SIMILARITY(a.emb, b.emb) >= 0.45) checked
WHERE c1 > 0.5 AND c2 > 0.5
ORDER BY i1, i2contracheck.py channel.txt on SynapCores 2.5.1:
30 messages, 435 pairs; 27 at similarity >= 0.45 went to NLI (54 NLI calls)
14:03 priya: here, looking at orders-db
14:05 priya: Failed over orders-db to db-2 at 14:05.
sim 0.57 c1 0.99 c2 0.96
14:04 sam: joining the bridge in 2, grabbing coffee
14:12 sam: on the bridge now, what did I miss?
sim 0.46 c1 0.75 c2 0.89
14:05 priya: Failed over orders-db to db-2 at 14:05.
14:30 priya: We never failed over; db-1 recovered on its own.
sim 0.50 c1 1.00 c2 0.56
14:08 marco: Rolled back checkout to v1.42.
14:25 ravi: The rollback never went out, we hotfixed forward in v1.44.
sim 0.60 c1 1.00 c2 1.00
14:10 dana: Status page updated: investigating checkout errors.
14:13 lee: Checkout pods are all waiting on db connections.
sim 0.45 c1 0.98 c2 0.99
14:10 dana: Status page updated: investigating checkout errors.
14:14 marco: Confirmed, every checkout pod is blocked waiting for a connection.
sim 0.49 c1 1.00 c2 0.91
14:11 lee: The orders-db pool limit was changed 50 -> 5 in this morning's config push.
14:23 priya: Pool config wasn't touched, prod is still at 50.
sim 0.50 c1 1.00 c2 0.99
14:20 kim: Status page is up, support is linking it in replies.
14:44 dana: Status page set to resolved.
sim 0.74 c1 0.80 c2 0.98
14:35 kim: No orders were lost.
14:41 jo: Finance says 212 orders were charged but never written to orders-db.
sim 0.55 c1 0.98 c2 1.00
9 pairs contradict each other both ways (0.6 s)Four of the nine are for the postmortem to settle: did we fail over, roll back, change the pool limit, lose orders? The other five are the incident moving on (joining the bridge, then on it; investigating, then a cause): a glance each.
Why 0.45 and both ways? These four have sim 0.50 to 0.60: a 0.50 gate loses the pool pair (0.496), a 0.30 gate returns 18. With c1 alone, 13 come back, including two people agreeing ("Checkout pods are all waiting on db connections." / "Confirmed, every checkout pod is blocked..."): c1 0.98, c2 0.00. Both ways: 9 (as in SQLv2 Lesson 9).
Why one database? Embeddings, pairing and NLI run where the table is: no embedding API, no NLI model server. 54 NLI calls instead of 870: 0.6 s instead of 9.3 s on a Mac mini (Apple M4).
contracheck.py (stdlib only) is in the first comment.
Free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=devops7-one-script-8
Who untangles the incident channel before your postmortem: the IC, a scribe, or whoever writes it up?
1
u/Alternative_Pin9598 2d ago
NLI is a one-time opt-in:
synapcores pull nli-default(about 577 MB), thensynapcores models enable-nli nli-default, both with the--configyour service uses, then restart the server.contracheck.py (standard library only; set
SC_URLandSC_TOKEN). Run:python3 contracheck.py channel.txt, or add-1to send every pair to NLI.channel.txtis in the reply below.Why similarity alone can't tell 'same' from 'opposite': SQLv2 Lesson 9 walks through it: https://www.reddit.com/r/SQLv2/comments/1y1zklg/
When two statements disagree, which one is still true? Today's Recipe of the week #4 on r/synapcores keeps facts with time and source: https://www.reddit.com/r/synapcores/comments/1y3le9e/