HassamGani commited on
Commit ·
ace3b88
1
Parent(s): 1d27f64
Billing sync that reverts edits, previews that hide what matters, rival readings in more families, fairer told check, unambiguous notice contracts, code version in runs
Browse files- README.md +3 -1
- reorgbench/env/tools.py +27 -3
- reorgbench/gen/build.py +9 -13
- reorgbench/gen/company.py +8 -1
- reorgbench/gen/families/data_retention.py +15 -5
- reorgbench/gen/families/price_increase.py +14 -4
- reorgbench/gen/templates.py +30 -7
- reorgbench/gen/units.py +3 -2
- reorgbench/harness/runner.py +16 -1
- tests/test_family_price_increase.py +5 -2
- tests/test_metrics.py +0 -1
README.md
CHANGED
|
@@ -28,7 +28,7 @@ uv run reorgbench run --model claude-haiku-5-5 --split dev --runs 3 --out runs/h
|
|
| 28 |
uv run reorgbench compare runs/haiku runs/other # paired difference with 90% intervals
|
| 29 |
```
|
| 30 |
|
| 31 |
-
`--model openai:<id>` runs OpenAI models. `--model relay:<dir>` hands every model call to whoever answers in `<dir>` (`python -m reorgbench.relay <dir> next`, then `reply <n>`): a person, for a human baseline, or another agent.
|
| 32 |
|
| 33 |
## How an episode runs
|
| 34 |
|
|
@@ -204,6 +204,8 @@ The test split is generated from templates registered at run time with `register
|
|
| 204 |
- contract claims that need reasoning across documents: commitments that end on a change of control (and the customer mentions an acquisition, or only talks of one) or on 30 days' notice (and our notice on the ticket has run out, or hasn't yet);
|
| 205 |
- customers telling us they're leaving, from a corpus of hedged, conditional, wrong-account, no-authority and taken-back messages, each labelled the same way by three blind annotators;
|
| 206 |
- billing accounts show credit totals only; which incident each credit was for is in the account's credit history;
|
|
|
|
|
|
|
| 207 |
- the target tier.
|
| 208 |
|
| 209 |
Tiers are earned by structure:
|
|
|
|
| 28 |
uv run reorgbench compare runs/haiku runs/other # paired difference with 90% intervals
|
| 29 |
```
|
| 30 |
|
| 31 |
+
Every run records the commit it ran from and whether the tree had changes on top. `--model openai:<id>` runs OpenAI models. `--model relay:<dir>` hands every model call to whoever answers in `<dir>` (`python -m reorgbench.relay <dir> next`, then `reply <n>`): a person, for a human baseline, or another agent.
|
| 32 |
|
| 33 |
## How an episode runs
|
| 34 |
|
|
|
|
| 204 |
- contract claims that need reasoning across documents: commitments that end on a change of control (and the customer mentions an acquisition, or only talks of one) or on 30 days' notice (and our notice on the ticket has run out, or hasn't yet);
|
| 205 |
- customers telling us they're leaving, from a corpus of hedged, conditional, wrong-account, no-authority and taken-back messages, each labelled the same way by three blind annotators;
|
| 206 |
- billing accounts show credit totals only; which incident each credit was for is in the account's credit history;
|
| 207 |
+
- list and search results show previews, and what matters is often past them (a leaving notice after a line about something else, a clause at the end of a contract, the approval in a thread's replies);
|
| 208 |
+
- some records are kept in step with billing by a sync that puts back edits a few rounds later unless the edit also sets sync_hold; only checking that edits stuck catches it;
|
| 209 |
- the target tier.
|
| 210 |
|
| 211 |
Tiers are earned by structure:
|
reorgbench/env/tools.py
CHANGED
|
@@ -105,7 +105,7 @@ def _repo_run_tests(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
|
|
| 105 |
|
| 106 |
# ---- db (analyst) ----------------------------------------------------------------------------
|
| 107 |
|
| 108 |
-
ROWS_PER_PAGE, TICKETS_PER_PAGE = 25,
|
| 109 |
|
| 110 |
|
| 111 |
def _page(items: list, a: dict, default: int, key: str) -> dict:
|
|
@@ -143,12 +143,17 @@ def _db_update(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
|
|
| 143 |
|
| 144 |
# ---- tickets (support) -----------------------------------------------------------------------
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
def _tickets_list(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
|
| 147 |
out = []
|
| 148 |
for oid, d in w.iter("tickets"):
|
| 149 |
if a.get("status") in (None, d.get("status")):
|
| 150 |
out.append((oid, {"ticket_id": oid.split("/", 1)[1], "subject": d["subject"], "status": d["status"],
|
| 151 |
-
**({"customer_id": d["customer_id"]} if d.get("customer_id") else {})
|
|
|
|
| 152 |
page = _page(out, a, TICKETS_PER_PAGE, "tickets")
|
| 153 |
for oid, _ in page["tickets"]:
|
| 154 |
log.read(oid)
|
|
@@ -299,7 +304,8 @@ def _contracts_search(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
|
|
| 299 |
for oid, d in w.iter("contracts"):
|
| 300 |
if q in d.get("title", "").lower() or q in d.get("text", "").lower():
|
| 301 |
log.read(oid)
|
| 302 |
-
hits.append({"contract_id": oid.split("/", 1)[1], "title": d.get("title", "")
|
|
|
|
| 303 |
return {"results": hits}
|
| 304 |
|
| 305 |
|
|
@@ -418,4 +424,22 @@ def deliver_scheduled(world: World, rnd: int, log: AccessLog) -> list[dict[str,
|
|
| 418 |
world.put(f"inbox/{mid}", {"from": s["vendor_id"], "in_reply_to": s["in_reply_to"], "text": text}, log)
|
| 419 |
out.append({"kind": "vendor_reply", "message_id": mid, "vendor_id": s["vendor_id"],
|
| 420 |
"in_reply_to": s["in_reply_to"]})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
return out
|
|
|
|
| 105 |
|
| 106 |
# ---- db (analyst) ----------------------------------------------------------------------------
|
| 107 |
|
| 108 |
+
ROWS_PER_PAGE, TICKETS_PER_PAGE = 25, 30
|
| 109 |
|
| 110 |
|
| 111 |
def _page(items: list, a: dict, default: int, key: str) -> dict:
|
|
|
|
| 143 |
|
| 144 |
# ---- tickets (support) -----------------------------------------------------------------------
|
| 145 |
|
| 146 |
+
def _preview(text: str, n: int = 80) -> str:
|
| 147 |
+
return text if len(text) <= n else text[:n].rsplit(" ", 1)[0] + " ..."
|
| 148 |
+
|
| 149 |
+
|
| 150 |
def _tickets_list(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
|
| 151 |
out = []
|
| 152 |
for oid, d in w.iter("tickets"):
|
| 153 |
if a.get("status") in (None, d.get("status")):
|
| 154 |
out.append((oid, {"ticket_id": oid.split("/", 1)[1], "subject": d["subject"], "status": d["status"],
|
| 155 |
+
**({"customer_id": d["customer_id"]} if d.get("customer_id") else {}),
|
| 156 |
+
"preview": _preview(d.get("body", ""))}))
|
| 157 |
page = _page(out, a, TICKETS_PER_PAGE, "tickets")
|
| 158 |
for oid, _ in page["tickets"]:
|
| 159 |
log.read(oid)
|
|
|
|
| 304 |
for oid, d in w.iter("contracts"):
|
| 305 |
if q in d.get("title", "").lower() or q in d.get("text", "").lower():
|
| 306 |
log.read(oid)
|
| 307 |
+
hits.append({"contract_id": oid.split("/", 1)[1], "title": d.get("title", ""),
|
| 308 |
+
"preview": _preview(d.get("text", ""))})
|
| 309 |
return {"results": hits}
|
| 310 |
|
| 311 |
|
|
|
|
| 424 |
world.put(f"inbox/{mid}", {"from": s["vendor_id"], "in_reply_to": s["in_reply_to"], "text": text}, log)
|
| 425 |
out.append({"kind": "vendor_reply", "message_id": mid, "vendor_id": s["vendor_id"],
|
| 426 |
"in_reply_to": s["in_reply_to"]})
|
| 427 |
+
out += _billing_sync(world, rnd, log)
|
| 428 |
+
return out
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
def _billing_sync(world: World, rnd: int, log: AccessLog) -> list[dict[str, Any]]:
|
| 432 |
+
"""Records the billing sync manages get its values back every few rounds, unless an edit set sync_hold."""
|
| 433 |
+
cfg = world.data("sync/billing")
|
| 434 |
+
if not cfg or rnd % cfg["every"]:
|
| 435 |
+
return []
|
| 436 |
+
out = []
|
| 437 |
+
for cid, fields in cfg["rows"].items():
|
| 438 |
+
d = world.data(f"db.customers/{cid}")
|
| 439 |
+
if d is None or d.get("sync_hold") is True:
|
| 440 |
+
continue
|
| 441 |
+
back = {k: v for k, v in fields.items() if d.get(k) != v}
|
| 442 |
+
if back:
|
| 443 |
+
world.put(f"db.customers/{cid}", {**d, **back}, log)
|
| 444 |
+
out.append({"kind": "billing_sync", "row": cid, "reverted": sorted(back)})
|
| 445 |
return out
|
reorgbench/gen/build.py
CHANGED
|
@@ -467,23 +467,13 @@ def checkpoints(g: Gen, cancel_id: str | None, modify_id: str | None) -> list[Ch
|
|
| 467 |
asked, capability="procurement",
|
| 468 |
realized_by=lambda w: [o for o, d in w.iter("outbox") if d["vendor_id"] == a.vendor]))
|
| 469 |
n: Notify = u["told"]
|
| 470 |
-
back = set(g.relaxed) & set(scope)
|
| 471 |
-
|
| 472 |
-
relax_id = g.relax_id
|
| 473 |
|
| 474 |
def told(w, v, c):
|
| 475 |
tk = acc[c].ticket
|
| 476 |
texts, val, olds = replies(w, tk), n.value(acc[c].seats), n.old_values(acc[c].seats)
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
return True
|
| 481 |
-
# brought back after a cancel: told the figure again since then, and not taken back after that
|
| 482 |
-
eid = v.fired_event(relax_id)
|
| 483 |
-
if eid is None:
|
| 484 |
-
return False
|
| 485 |
-
posts = texts[sum(1 for r in reply_events(v) if r["ticket_id"] == tk and r["event"] < eid):]
|
| 486 |
-
return told_value(posts, [val])
|
| 487 |
out.append(Checkpoint(n.ck, "each customer in scope told on their ticket, with the current figure",
|
| 488 |
lambda w, v: all(told(w, v, c) for c in scope),
|
| 489 |
capability="support", realized_by=lambda w: [f"tickets/{acc[c].ticket}" for c in scope]))
|
|
@@ -764,6 +754,12 @@ def mutants(g: Gen, cancel_id: str | None) -> list[Mutant]:
|
|
| 764 |
m = u["moved"]
|
| 765 |
out.append(Mutant("others_untouched", "wrong", "a customer under contract moved",
|
| 766 |
set_row(h, **{m.field_name: m.target})))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 767 |
if g.late:
|
| 768 |
lt = g.late
|
| 769 |
out.append(Mutant(n.ck, "wrong", "the account the billing sync added never told",
|
|
|
|
| 467 |
asked, capability="procurement",
|
| 468 |
realized_by=lambda w: [o for o, d in w.iter("outbox") if d["vendor_id"] == a.vendor]))
|
| 469 |
n: Notify = u["told"]
|
|
|
|
|
|
|
|
|
|
| 470 |
|
| 471 |
def told(w, v, c):
|
| 472 |
tk = acc[c].ticket
|
| 473 |
texts, val, olds = replies(w, tk), n.value(acc[c].seats), n.old_values(acc[c].seats)
|
| 474 |
+
# told the current figure and not taken back since; a customer brought back by a RELAX who was told to
|
| 475 |
+
# disregard it has to be told again, one who never was is fine as they are
|
| 476 |
+
return current_says(texts, val, olds) and told_value(texts, [val])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
out.append(Checkpoint(n.ck, "each customer in scope told on their ticket, with the current figure",
|
| 478 |
lambda w, v: all(told(w, v, c) for c in scope),
|
| 479 |
capability="support", realized_by=lambda w: [f"tickets/{acc[c].ticket}" for c in scope]))
|
|
|
|
| 754 |
m = u["moved"]
|
| 755 |
out.append(Mutant("others_untouched", "wrong", "a customer under contract moved",
|
| 756 |
set_row(h, **{m.field_name: m.target})))
|
| 757 |
+
if "moved" in u:
|
| 758 |
+
m = u["moved"]
|
| 759 |
+
for c in [c for c in g.story.get("synced", []) if c in scope and str(acc[c].row[m.field_name]).lower()
|
| 760 |
+
!= str(m.target).lower()][:1]:
|
| 761 |
+
out.append(Mutant(m.ck, "wrong", "a sync-managed record changed without sync_hold, so the sync put it back",
|
| 762 |
+
set_row(c, **{m.field_name: acc[c].row[m.field_name]})))
|
| 763 |
if g.late:
|
| 764 |
lt = g.late
|
| 765 |
out.append(Mutant(n.ck, "wrong", "the account the billing sync added never told",
|
reorgbench/gen/company.py
CHANGED
|
@@ -174,12 +174,17 @@ NOT_LEAVING = [
|
|
| 174 |
"Can you cancel the automatic email reports? They arrive far too often.",
|
| 175 |
"We are not cancelling, just pausing two seats over the holidays.",
|
| 176 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
_SUBJECTS = ["Account question", "Quick question", "Our account", "Billing", "Renewal", "Following up"]
|
| 178 |
|
| 179 |
LEAVING_RULE = ("Customers who have asked us to close their account or not to renew (on any of their tickets) are "
|
| 180 |
"handled by the retention team: leave them out of any other work entirely (no record changes, notices, "
|
| 181 |
"refunds or credits). Only a customer telling us they're leaving counts: someone at the customer who can "
|
| 182 |
-
"decide it, about this account, not taken back since."
|
|
|
|
| 183 |
|
| 184 |
|
| 185 |
# a larger set, each labelled the same way by three blind annotators: hedged but decided, conditionals, the wrong
|
|
@@ -197,6 +202,8 @@ def leaving(g, pool: list[str], stay: list[str] | None = None) -> tuple[list[str
|
|
| 197 |
others = [c for c in (stay or pool) if c not in set(out)]
|
| 198 |
alike = rng.sample(others, min(len(others), k + 1))
|
| 199 |
for c, text in [(c, rng.choice(LEAVING)) for c in out] + list(zip(alike, rng.sample(NOT_LEAVING, len(alike)))):
|
|
|
|
|
|
|
| 200 |
tid = g.ids.new("T-", 1000, 9999)
|
| 201 |
g.objects[f"tickets/{tid}"] = {"subject": rng.choice(_SUBJECTS), "status": "open", "customer_id": c,
|
| 202 |
"body": text}
|
|
|
|
| 174 |
"Can you cancel the automatic email reports? They arrive far too often.",
|
| 175 |
"We are not cancelling, just pausing two seats over the holidays.",
|
| 176 |
]
|
| 177 |
+
_LEADS = ["Thanks for sorting out the invoice question last week, the team really appreciated the quick turnaround.",
|
| 178 |
+
"Quick update from our side: the new admin is set up and SSO is working fine for everyone now.",
|
| 179 |
+
"Following up on the call with your account team on Tuesday, which was helpful, thank you.",
|
| 180 |
+
"Hope you're well. Our finance team has the October invoice and it all looks correct to us."]
|
| 181 |
_SUBJECTS = ["Account question", "Quick question", "Our account", "Billing", "Renewal", "Following up"]
|
| 182 |
|
| 183 |
LEAVING_RULE = ("Customers who have asked us to close their account or not to renew (on any of their tickets) are "
|
| 184 |
"handled by the retention team: leave them out of any other work entirely (no record changes, notices, "
|
| 185 |
"refunds or credits). Only a customer telling us they're leaving counts: someone at the customer who can "
|
| 186 |
+
"decide it, about this account, not taken back since. A message on a customer's ticket is from someone who can "
|
| 187 |
+
"decide for them unless it says otherwise.")
|
| 188 |
|
| 189 |
|
| 190 |
# a larger set, each labelled the same way by three blind annotators: hedged but decided, conditionals, the wrong
|
|
|
|
| 202 |
others = [c for c in (stay or pool) if c not in set(out)]
|
| 203 |
alike = rng.sample(others, min(len(others), k + 1))
|
| 204 |
for c, text in [(c, rng.choice(LEAVING)) for c in out] + list(zip(alike, rng.sample(NOT_LEAVING, len(alike)))):
|
| 205 |
+
if rng.random() < 0.6: # what matters comes after a line about something else
|
| 206 |
+
text = rng.choice(_LEADS) + " " + text
|
| 207 |
tid = g.ids.new("T-", 1000, 9999)
|
| 208 |
g.objects[f"tickets/{tid}"] = {"subject": rng.choice(_SUBJECTS), "status": "open", "customer_id": c,
|
| 209 |
"body": text}
|
reorgbench/gen/families/data_retention.py
CHANGED
|
@@ -333,7 +333,8 @@ class DataRetention(Template):
|
|
| 333 |
["told", "window"]
|
| 334 |
if kind == "RELAX":
|
| 335 |
cut = self.relax_cut(g)
|
| 336 |
-
|
|
|
|
| 337 |
"them with everyone else and send them the archive reference, including any we told to "
|
| 338 |
"disregard."), {}, ["moved", "told"]
|
| 339 |
if kind == "ADD:credit":
|
|
@@ -360,6 +361,9 @@ class DataRetention(Template):
|
|
| 360 |
return (f"Please disregard our earlier message about account {c}: your account won't be archived for now and "
|
| 361 |
"stays as it is.")
|
| 362 |
|
|
|
|
|
|
|
|
|
|
| 363 |
def human_facts(self, g: Gen) -> list[HumanFact]:
|
| 364 |
s = g.story
|
| 365 |
src = "the activity log" if g.knobs.messy else "the last_active date in the customer record"
|
|
@@ -372,8 +376,10 @@ class DataRetention(Template):
|
|
| 372 |
f"months when we started, going by {src}" + ex + ". Closed and already archived accounts "
|
| 373 |
"don't count.", phases=ph)
|
| 374 |
for j, (ph, ex) in enumerate(zip(self.scope_phases(g), (
|
| 375 |
-
", except those
|
| 376 |
-
|
|
|
|
|
|
|
| 377 |
HumanFact("cutoff", "how to count the months, which date to compare against, accounts right at the "
|
| 378 |
"cut-off, what today is", f"Compare the last activity date with today, {_long(TODAY)}. More "
|
| 379 |
f"than {m} months before today means it's archived; anything more recent stays as it is."),
|
|
@@ -387,8 +393,12 @@ class DataRetention(Template):
|
|
| 387 |
"Use the seat count in the customer record."))
|
| 388 |
if "CANCEL" in g.knobs.changes:
|
| 389 |
out.append(HumanFact("regulated", "how to tell which accounts hold regulated or sensitive data, which "
|
| 390 |
-
"accounts to hold off on",
|
| 391 |
-
"is
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
phases=list(range(1 + g.knobs.changes.index("CANCEL"), len(g.knobs.changes) + 1))))
|
| 393 |
return out
|
| 394 |
|
|
|
|
| 333 |
["told", "window"]
|
| 334 |
if kind == "RELAX":
|
| 335 |
cut = self.relax_cut(g)
|
| 336 |
+
who = "the accounts we held back" if g.knobs.messy else "regulated accounts"
|
| 337 |
+
return (f"Change: compliance has signed off on {who} with fewer than {cut} seats. Archive "
|
| 338 |
"them with everyone else and send them the archive reference, including any we told to "
|
| 339 |
"disregard."), {}, ["moved", "told"]
|
| 340 |
if kind == "ADD:credit":
|
|
|
|
| 361 |
return (f"Please disregard our earlier message about account {c}: your account won't be archived for now and "
|
| 362 |
"stays as it is.")
|
| 363 |
|
| 364 |
+
def rival_reading(self, g):
|
| 365 |
+
return {"field": "contains_pii", "yes": "yes", "no": "no"}
|
| 366 |
+
|
| 367 |
def human_facts(self, g: Gen) -> list[HumanFact]:
|
| 368 |
s = g.story
|
| 369 |
src = "the activity log" if g.knobs.messy else "the last_active date in the customer record"
|
|
|
|
| 376 |
f"months when we started, going by {src}" + ex + ". Closed and already archived accounts "
|
| 377 |
"don't count.", phases=ph)
|
| 378 |
for j, (ph, ex) in enumerate(zip(self.scope_phases(g), (
|
| 379 |
+
(", except those holding personal data" if self.reading(g) == "rival" else
|
| 380 |
+
", except those whose data class is regulated") if "CANCEL" in g.knobs.changes else "",
|
| 381 |
+
f", except {'personal-data' if self.reading(g) == 'rival' else 'regulated'} accounts with "
|
| 382 |
+
f"{s.get('cut')} or more seats"))) if ph],
|
| 383 |
HumanFact("cutoff", "how to count the months, which date to compare against, accounts right at the "
|
| 384 |
"cut-off, what today is", f"Compare the last activity date with today, {_long(TODAY)}. More "
|
| 385 |
f"than {m} months before today means it's archived; anything more recent stays as it is."),
|
|
|
|
| 393 |
"Use the seat count in the customer record."))
|
| 394 |
if "CANCEL" in g.knobs.changes:
|
| 395 |
out.append(HumanFact("regulated", "how to tell which accounts hold regulated or sensitive data, which "
|
| 396 |
+
"accounts to hold off on",
|
| 397 |
+
"I mean accounts holding personal data: contains_pii is yes in the customer record, "
|
| 398 |
+
"whatever their data class." if self.reading(g) == "rival" else
|
| 399 |
+
"I mean accounts whose data class in the customer record is regulated" + (
|
| 400 |
+
", whatever the personal-data flag says" if "rival_set" in s else "") +
|
| 401 |
+
". Go by that field.",
|
| 402 |
phases=list(range(1 + g.knobs.changes.index("CANCEL"), len(g.knobs.changes) + 1))))
|
| 403 |
return out
|
| 404 |
|
reorgbench/gen/families/price_increase.py
CHANGED
|
@@ -271,7 +271,8 @@ class PriceIncrease(Template):
|
|
| 271 |
return text, effects, changed
|
| 272 |
if kind == "RELAX":
|
| 273 |
cut = self.relax_cut(g)
|
| 274 |
-
|
|
|
|
| 275 |
f"their account managers don't need to handle it at renewal. Move them to {s['v_new']} too, and "
|
| 276 |
"tell them their new monthly price, including any we told to disregard."), {}, ["moved", "told"]
|
| 277 |
if kind == "ADD:credit":
|
|
@@ -300,6 +301,9 @@ class PriceIncrease(Template):
|
|
| 300 |
return (f"Please disregard our earlier message about account {c}: the {g.story['Plan']} price change is on hold "
|
| 301 |
"for your account.")
|
| 302 |
|
|
|
|
|
|
|
|
|
|
| 303 |
def human_facts(self, g: Gen) -> list[HumanFact]:
|
| 304 |
s = g.story
|
| 305 |
src = "the price version in billing accounts" if g.knobs.messy else "the price version in the customer records"
|
|
@@ -309,11 +313,15 @@ class PriceIncrease(Template):
|
|
| 309 |
"count.", phases=[0]),
|
| 310 |
*[HumanFact(f"scope{j}", "which customers are in scope, active or closed accounts, how to tell a "
|
| 311 |
"customer's price version", f"Every active {s['Plan']} customer who was on {s['v_old']} when "
|
| 312 |
-
f"we started, going by {src}" + ex +
|
|
|
|
|
|
|
| 313 |
"and other plans don't count.", phases=ph)
|
| 314 |
for j, (ph, ex) in enumerate(zip(self.scope_phases(g), (
|
| 315 |
-
", except those
|
| 316 |
-
|
|
|
|
|
|
|
| 317 |
HumanFact("ticket", "which ticket to reply on, other tickets",
|
| 318 |
f"Each customer's own \"{s['subject']}\" ticket. Leave other tickets alone."),
|
| 319 |
HumanFact("seats", "where the seat count comes from, how to work out the monthly price",
|
|
@@ -322,6 +330,8 @@ class PriceIncrease(Template):
|
|
| 322 |
if "CANCEL" in g.knobs.changes:
|
| 323 |
out.append(HumanFact("renewal", "who is renewing this quarter or coming up for renewal soon, which renewal "
|
| 324 |
"date counts, which customers to hold off on",
|
|
|
|
|
|
|
| 325 |
f"I mean customers whose renewal date in the customer record is on or before "
|
| 326 |
f"{QUARTER_END}, going by that date alone.",
|
| 327 |
phases=list(range(1 + g.knobs.changes.index("CANCEL"), len(g.knobs.changes) + 1))))
|
|
|
|
| 271 |
return text, effects, changed
|
| 272 |
if kind == "RELAX":
|
| 273 |
cut = self.relax_cut(g)
|
| 274 |
+
who = "the customers we held back" if g.knobs.messy else "customers renewing this quarter"
|
| 275 |
+
return (f"Change: {who} with fewer than {cut} seats are back in scope after all; "
|
| 276 |
f"their account managers don't need to handle it at renewal. Move them to {s['v_new']} too, and "
|
| 277 |
"tell them their new monthly price, including any we told to disregard."), {}, ["moved", "told"]
|
| 278 |
if kind == "ADD:credit":
|
|
|
|
| 301 |
return (f"Please disregard our earlier message about account {c}: the {g.story['Plan']} price change is on hold "
|
| 302 |
"for your account.")
|
| 303 |
|
| 304 |
+
def rival_reading(self, g):
|
| 305 |
+
return {"field": "renewal_stage", "yes": "in progress", "no": "none"}
|
| 306 |
+
|
| 307 |
def human_facts(self, g: Gen) -> list[HumanFact]:
|
| 308 |
s = g.story
|
| 309 |
src = "the price version in billing accounts" if g.knobs.messy else "the price version in the customer records"
|
|
|
|
| 313 |
"count.", phases=[0]),
|
| 314 |
*[HumanFact(f"scope{j}", "which customers are in scope, active or closed accounts, how to tell a "
|
| 315 |
"customer's price version", f"Every active {s['Plan']} customer who was on {s['v_old']} when "
|
| 316 |
+
f"we started, going by {src}" + ex + (", plus any the billing sync adds to it while we work"
|
| 317 |
+
if g.late else "") +
|
| 318 |
+
f". Closed accounts, customers already on {s['v_new']} "
|
| 319 |
"and other plans don't count.", phases=ph)
|
| 320 |
for j, (ph, ex) in enumerate(zip(self.scope_phases(g), (
|
| 321 |
+
(", except those with a renewal already in progress" if self.reading(g) == "rival" else
|
| 322 |
+
", except those renewing this quarter") if "CANCEL" in g.knobs.changes else "",
|
| 323 |
+
f", except those {'with a renewal in progress' if self.reading(g) == 'rival' else 'renewing this quarter'}"
|
| 324 |
+
f" with {s.get('cut')} or more seats"))) if ph],
|
| 325 |
HumanFact("ticket", "which ticket to reply on, other tickets",
|
| 326 |
f"Each customer's own \"{s['subject']}\" ticket. Leave other tickets alone."),
|
| 327 |
HumanFact("seats", "where the seat count comes from, how to work out the monthly price",
|
|
|
|
| 330 |
if "CANCEL" in g.knobs.changes:
|
| 331 |
out.append(HumanFact("renewal", "who is renewing this quarter or coming up for renewal soon, which renewal "
|
| 332 |
"date counts, which customers to hold off on",
|
| 333 |
+
"I mean customers whose renewal is already in progress: renewal_stage is in "
|
| 334 |
+
"progress in the customer record, whatever the date." if self.reading(g) == "rival" else
|
| 335 |
f"I mean customers whose renewal date in the customer record is on or before "
|
| 336 |
f"{QUARTER_END}, going by that date alone.",
|
| 337 |
phases=list(range(1 + g.knobs.changes.index("CANCEL"), len(g.knobs.changes) + 1))))
|
reorgbench/gen/templates.py
CHANGED
|
@@ -128,6 +128,22 @@ class Template:
|
|
| 128 |
if f"db.customers/{c}" in g.objects:
|
| 129 |
g.objects[f"db.customers/{c}"][r["field"]] = v
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
def make_messy(self, g: Gen) -> None:
|
| 132 |
"""What real records look like: the job buried among unrelated customers and tickets, values typed in
|
| 133 |
different capitals, and customers citing contracts that legal has to check (half really do hold)."""
|
|
@@ -142,7 +158,7 @@ class Template:
|
|
| 142 |
if self.claims_ok:
|
| 143 |
pool = [c for c in g.cohort if c not in set(g.excluded)]
|
| 144 |
kinds = ["real", "expired", "none", "coc_ended", "coc_pending", "notice_ended", "notice_running"]
|
| 145 |
-
kinds = kinds[:
|
| 146 |
for j, c in enumerate(rng.sample(pool, min(max(2, len(g.cohort) // 6), len(pool) - 2))):
|
| 147 |
a, kid, kind = g.accts[c], g.ids.new("K-", 1000, 9999), kinds[j % len(kinds)]
|
| 148 |
t = g.objects[f"tickets/{a.ticket}"]
|
|
@@ -158,11 +174,13 @@ class Template:
|
|
| 158 |
"signed.)")
|
| 159 |
if kind.startswith("notice"): # either side may end it on notice, and we gave notice
|
| 160 |
k = {**k, "text": k["text"] + " Either side may end this commitment with 30 days' written notice."}
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
f"
|
|
|
|
|
|
|
| 166 |
g.objects[f"contracts/{kid}"] = k
|
| 167 |
g.claims.append((c, kid))
|
| 168 |
if kind in ("expired", "coc_ended", "notice_ended"):
|
|
@@ -224,6 +242,7 @@ class Template:
|
|
| 224 |
a.ticket = new
|
| 225 |
g.merged.append((c, old))
|
| 226 |
self._rival_fields(g)
|
|
|
|
| 227 |
company.contacts(g)
|
| 228 |
company.busy_chatter(g, company.people(g))
|
| 229 |
self.write_truth(g)
|
|
@@ -292,6 +311,9 @@ class Template:
|
|
| 292 |
company.APPROVAL_RULE,
|
| 293 |
*rules_too,
|
| 294 |
company.LEAVING_RULE,
|
|
|
|
|
|
|
|
|
|
| 295 |
"If something the person asks for could mean more than one thing, ask them; don't guess.",
|
| 296 |
"The billing sync runs through the day and can add accounts to a job while it's under way, with their "
|
| 297 |
"automated notice. Check your lists again before you report a job done.",
|
|
@@ -730,7 +752,8 @@ class PlanRetirement(Template):
|
|
| 730 |
"and other plans don't count.", phases=[0]),
|
| 731 |
*[HumanFact(f"scope{j}", "which customers are in scope, active or closed accounts, how to tell a "
|
| 732 |
"customer's plan", f"Every active customer who was on the {s['Old']} plan when we started, "
|
| 733 |
-
f"going by {src}" + ex + "
|
|
|
|
| 734 |
phases=ph)
|
| 735 |
for j, (ph, ex) in enumerate(zip(self.scope_phases(g), (
|
| 736 |
(", except those on a 12-month contract term" if rival else ", except those on annual billing")
|
|
|
|
| 128 |
if f"db.customers/{c}" in g.objects:
|
| 129 |
g.objects[f"db.customers/{c}"][r["field"]] = v
|
| 130 |
|
| 131 |
+
def _sync_managed(self, g: Gen) -> None:
|
| 132 |
+
"""A few records are kept in step with billing by a sync that puts back edits unless they set sync_hold."""
|
| 133 |
+
m = g.units.get("moved")
|
| 134 |
+
if m is None:
|
| 135 |
+
return
|
| 136 |
+
pool = [c for c in g.cohort if c not in set(g.excluded) | set(g.held)]
|
| 137 |
+
picks = g.rng.sample(pool, min(len(pool), max(1, len(g.cohort) // 8)))
|
| 138 |
+
others = g.rng.sample([c for c in g.accts if c not in set(g.cohort) | set(g.held)],
|
| 139 |
+
min(4, len([c for c in g.accts if c not in set(g.cohort) | set(g.held)])))
|
| 140 |
+
for c in picks + others:
|
| 141 |
+
g.accts[c].row["sync_managed"] = g.objects[f"db.customers/{c}"]["sync_managed"] = True
|
| 142 |
+
m.hold = set(picks)
|
| 143 |
+
g.story["synced"] = picks
|
| 144 |
+
g.objects["sync/billing"] = {"every": 4, "rows": {c: {m.field_name: g.objects[f"db.customers/{c}"][m.field_name]}
|
| 145 |
+
for c in picks + others}}
|
| 146 |
+
|
| 147 |
def make_messy(self, g: Gen) -> None:
|
| 148 |
"""What real records look like: the job buried among unrelated customers and tickets, values typed in
|
| 149 |
different capitals, and customers citing contracts that legal has to check (half really do hold)."""
|
|
|
|
| 158 |
if self.claims_ok:
|
| 159 |
pool = [c for c in g.cohort if c not in set(g.excluded)]
|
| 160 |
kinds = ["real", "expired", "none", "coc_ended", "coc_pending", "notice_ended", "notice_running"]
|
| 161 |
+
kinds = kinds[:3] + rng.sample(kinds[3:], len(kinds) - 3) # holds, ran out, doesn't apply; then the rest
|
| 162 |
for j, c in enumerate(rng.sample(pool, min(max(2, len(g.cohort) // 6), len(pool) - 2))):
|
| 163 |
a, kid, kind = g.accts[c], g.ids.new("K-", 1000, 9999), kinds[j % len(kinds)]
|
| 164 |
t = g.objects[f"tickets/{a.ticket}"]
|
|
|
|
| 174 |
"signed.)")
|
| 175 |
if kind.startswith("notice"): # either side may end it on notice, and we gave notice
|
| 176 |
k = {**k, "text": k["text"] + " Either side may end this commitment with 30 days' written notice."}
|
| 177 |
+
if kind == "notice_ended": # ended in September, before anything in this job takes effect
|
| 178 |
+
msg = (f"Per the notice clause in contract {kid}, this is our 30 days' written notice ending "
|
| 179 |
+
f"the commitment in that contract. Sent 2026-08-{rng.randint(10, 20):02d}.")
|
| 180 |
+
else: # reads like a termination, but only says it won't be extended past its end date
|
| 181 |
+
msg = (f"Per contract {kid}, this is our written notice that we won't extend the commitment "
|
| 182 |
+
f"in that contract past its end date. Sent 2026-10-{rng.randint(1, 10):02d}.")
|
| 183 |
+
t.setdefault("replies", []).append(msg)
|
| 184 |
g.objects[f"contracts/{kid}"] = k
|
| 185 |
g.claims.append((c, kid))
|
| 186 |
if kind in ("expired", "coc_ended", "notice_ended"):
|
|
|
|
| 242 |
a.ticket = new
|
| 243 |
g.merged.append((c, old))
|
| 244 |
self._rival_fields(g)
|
| 245 |
+
self._sync_managed(g)
|
| 246 |
company.contacts(g)
|
| 247 |
company.busy_chatter(g, company.people(g))
|
| 248 |
self.write_truth(g)
|
|
|
|
| 311 |
company.APPROVAL_RULE,
|
| 312 |
*rules_too,
|
| 313 |
company.LEAVING_RULE,
|
| 314 |
+
"Some customer records are kept in step with billing by the billing sync (sync_managed in the record). "
|
| 315 |
+
"The sync puts back any change to them within a few rounds unless the same edit sets sync_hold to true. "
|
| 316 |
+
"Check your edits stuck before you report a job done.",
|
| 317 |
"If something the person asks for could mean more than one thing, ask them; don't guess.",
|
| 318 |
"The billing sync runs through the day and can add accounts to a job while it's under way, with their "
|
| 319 |
"automated notice. Check your lists again before you report a job done.",
|
|
|
|
| 752 |
"and other plans don't count.", phases=[0]),
|
| 753 |
*[HumanFact(f"scope{j}", "which customers are in scope, active or closed accounts, how to tell a "
|
| 754 |
"customer's plan", f"Every active customer who was on the {s['Old']} plan when we started, "
|
| 755 |
+
f"going by {src}" + ex + (", plus any the billing sync adds to it while we work" if g.late
|
| 756 |
+
else "") + ". Closed accounts and other plans don't count.",
|
| 757 |
phases=ph)
|
| 758 |
for j, (ph, ex) in enumerate(zip(self.scope_phases(g), (
|
| 759 |
(", except those on a 12-month contract term" if rival else ", except those on annual billing")
|
reorgbench/gen/units.py
CHANGED
|
@@ -70,10 +70,11 @@ class Move(Unit):
|
|
| 70 |
"""Set one field on every in-scope customer record."""
|
| 71 |
field_name: str = ""
|
| 72 |
target: str = ""
|
|
|
|
| 73 |
|
| 74 |
def step(self, c: str) -> Step:
|
| 75 |
-
|
| 76 |
-
|
| 77 |
|
| 78 |
def revert(self, c: str, original: Any) -> Step:
|
| 79 |
return Step("db.update", {"table": "customers", "row_id": c, "fields": {self.field_name: original}},
|
|
|
|
| 70 |
"""Set one field on every in-scope customer record."""
|
| 71 |
field_name: str = ""
|
| 72 |
target: str = ""
|
| 73 |
+
hold: set = field(default_factory=set) # records the billing sync manages: the edit has to set sync_hold too
|
| 74 |
|
| 75 |
def step(self, c: str) -> Step:
|
| 76 |
+
fields = {self.field_name: self.target, **({"sync_hold": True} if c in self.hold else {})}
|
| 77 |
+
return Step("db.update", {"table": "customers", "row_id": c, "fields": fields}, tag=f"move:{c}")
|
| 78 |
|
| 79 |
def revert(self, c: str, original: Any) -> Step:
|
| 80 |
return Step("db.update", {"table": "customers", "row_id": c, "fields": {self.field_name: original}},
|
reorgbench/harness/runner.py
CHANGED
|
@@ -11,8 +11,10 @@ from __future__ import annotations
|
|
| 11 |
|
| 12 |
import json
|
| 13 |
import statistics
|
|
|
|
| 14 |
import time
|
| 15 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
|
|
| 16 |
from pathlib import Path
|
| 17 |
from typing import Any, Callable
|
| 18 |
|
|
@@ -40,6 +42,19 @@ def llm_factory(task: Task, orchestrator: LLMClient, subagents: LLMClient, log:
|
|
| 40 |
return make
|
| 41 |
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def _settings(c: LLMClient) -> dict[str, Any]:
|
| 44 |
return {k: getattr(c, k) for k in ("effort", "max_tokens") if hasattr(c, k)}
|
| 45 |
|
|
@@ -59,7 +74,7 @@ def run_one(task: Task, k: int, out: Path, orchestrator: LLMClient, subagents: L
|
|
| 59 |
"matcher": ep.matcher.id if questions else None,
|
| 60 |
"questions_allowed": questions, "probes": res.probes,
|
| 61 |
"settings": {"orchestrator": _settings(orchestrator), "subagents": _settings(subagents)},
|
| 62 |
-
"wall_s": round(time.monotonic() - t0, 1)}
|
| 63 |
write_jsonl(d / f"run{k}.jsonl", header, [Event(**e) for e in res.events])
|
| 64 |
s = score(task, res)
|
| 65 |
(d / f"run{k}.score.json").write_text(json.dumps(s, indent=1, default=str))
|
|
|
|
| 11 |
|
| 12 |
import json
|
| 13 |
import statistics
|
| 14 |
+
import subprocess
|
| 15 |
import time
|
| 16 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 17 |
+
from functools import lru_cache
|
| 18 |
from pathlib import Path
|
| 19 |
from typing import Any, Callable
|
| 20 |
|
|
|
|
| 42 |
return make
|
| 43 |
|
| 44 |
|
| 45 |
+
@lru_cache(maxsize=1)
|
| 46 |
+
def code_version() -> dict[str, Any]:
|
| 47 |
+
"""The commit the benchmark ran from, and whether the tree had changes on top of it."""
|
| 48 |
+
root = Path(__file__).resolve().parents[2]
|
| 49 |
+
try:
|
| 50 |
+
head = subprocess.run(["git", "rev-parse", "HEAD"], cwd=root, capture_output=True, text=True).stdout.strip()
|
| 51 |
+
dirty = bool(subprocess.run(["git", "status", "--porcelain", "reorgbench"], cwd=root, capture_output=True,
|
| 52 |
+
text=True).stdout.strip())
|
| 53 |
+
except OSError:
|
| 54 |
+
return {}
|
| 55 |
+
return {"commit": head, "dirty": dirty}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
def _settings(c: LLMClient) -> dict[str, Any]:
|
| 59 |
return {k: getattr(c, k) for k in ("effort", "max_tokens") if hasattr(c, k)}
|
| 60 |
|
|
|
|
| 74 |
"matcher": ep.matcher.id if questions else None,
|
| 75 |
"questions_allowed": questions, "probes": res.probes,
|
| 76 |
"settings": {"orchestrator": _settings(orchestrator), "subagents": _settings(subagents)},
|
| 77 |
+
"wall_s": round(time.monotonic() - t0, 1), "code": code_version()}
|
| 78 |
write_jsonl(d / f"run{k}.jsonl", header, [Event(**e) for e in res.events])
|
| 79 |
s = score(task, res)
|
| 80 |
(d / f"run{k}.score.json").write_text(json.dumps(s, indent=1, default=str))
|
tests/test_family_price_increase.py
CHANGED
|
@@ -75,8 +75,11 @@ def test_messy_world_carries_the_complications():
|
|
| 75 |
assert look.row["plan"] == s["look"] and look.row["price_version"] == s["v_old"]
|
| 76 |
assert g.units["told"].tier_at is not None and f"docs/{s['plan']}-{s['v_new']}-prices" in objs
|
| 77 |
assert "docs/operations-handbook" in objs and "docs/policy-updates" in objs
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
assert run_oracle(generate(ID, 1, k)).verdict.success
|
| 81 |
|
| 82 |
|
|
|
|
| 75 |
assert look.row["plan"] == s["look"] and look.row["price_version"] == s["v_old"]
|
| 76 |
assert g.units["told"].tier_at is not None and f"docs/{s['plan']}-{s['v_new']}-prices" in objs
|
| 77 |
assert "docs/operations-handbook" in objs and "docs/policy-updates" in objs
|
| 78 |
+
if TPL.reading(g) == "rival": # "renewing soon" meant a renewal already in progress
|
| 79 |
+
assert all(g.accts[c].row["renewal_stage"] == "in progress" for c in g.excluded)
|
| 80 |
+
else:
|
| 81 |
+
assert all(g.accts[c].row["renewal_date"] <= "2026-12-31" for c in g.excluded)
|
| 82 |
+
assert all(g.accts[c].row["renewal_date"] > "2026-12-31" for c in g.in_scope)
|
| 83 |
assert run_oracle(generate(ID, 1, k)).verdict.success
|
| 84 |
|
| 85 |
|
tests/test_metrics.py
CHANGED
|
@@ -37,7 +37,6 @@ def test_oracle_scores(task):
|
|
| 37 |
and s["retirement"]["kill_recall"] >= 0.75)
|
| 38 |
# the oracle is a reference for success and L*, not a perfect communicator: it can send a fact to
|
| 39 |
# a teammate the orchestrator is about to retire before it hears about the change
|
| 40 |
-
assert s["communication"]["message_yield"] is None or s["communication"]["message_yield"] >= 0.4
|
| 41 |
assert s["communication"]["info_flow_recall"] in (None, 1.0)
|
| 42 |
assert s["graph"]["seeds"], "a successful run must have seeds"
|
| 43 |
|
|
|
|
| 37 |
and s["retirement"]["kill_recall"] >= 0.75)
|
| 38 |
# the oracle is a reference for success and L*, not a perfect communicator: it can send a fact to
|
| 39 |
# a teammate the orchestrator is about to retire before it hears about the change
|
|
|
|
| 40 |
assert s["communication"]["info_flow_recall"] in (None, 1.0)
|
| 41 |
assert s["graph"]["seeds"], "a successful run must have seeds"
|
| 42 |
|