HassamGani commited on
Commit
ed863e3
·
1 Parent(s): 845ed07

Ops queue: an archive and a refund job share a customer whose ledger freezes once archived; refund first

Browse files
README.md CHANGED
@@ -179,7 +179,7 @@ From the units, the generator derives per phase:
179
  | `sla-credit` | an outage took clusters offline; mark every affected customer's SLA credit and tell each the amount; who was hit comes from the incident report, not the CRM | CANCEL (partner-channel customers), MODIFY (higher SLA band), RELAX, ADD (goodwill credit, close) |
180
  | `price-increase` | move every customer on a plan to the new price version and tell each their new monthly price; price-protection contracts, some in force, some expired | CANCEL (renewing this quarter), MODIFY (increase trimmed), RELAX, ADD (credit, close) |
181
  | `data-retention` | archive accounts inactive past the retention period (a date comparison against today), with the archival vendor's batch reference; litigation holds | CANCEL (regulated data), MODIFY (new batch reference), RELAX, ADD (credit, close) |
182
- | `ops-queue` | all three stories at once in one company: shared customers table, tickets, ledger, people and handbook; the person changes job 1 while the other two run. The other jobs are posted in a #ops-queue chat channel with their sign-offs, next to a fourth job that was never signed off by anyone who can, or was called off; its customers wait with open tickets and must be left alone. Once job 1's changes are in, the person comes back about job 2 (a correction, an extra credit or closing its tickets), when its team may already be done and let go | job 1's changes, then one to job 2; every side job's facts, tags and checks namespaced, one ledger guard over all three |
183
 
184
  The test split is generated from templates registered at run time with `register_template`, outside this repo, so whole scenarios are held out.
185
 
 
179
  | `sla-credit` | an outage took clusters offline; mark every affected customer's SLA credit and tell each the amount; who was hit comes from the incident report, not the CRM | CANCEL (partner-channel customers), MODIFY (higher SLA band), RELAX, ADD (goodwill credit, close) |
180
  | `price-increase` | move every customer on a plan to the new price version and tell each their new monthly price; price-protection contracts, some in force, some expired | CANCEL (renewing this quarter), MODIFY (increase trimmed), RELAX, ADD (credit, close) |
181
  | `data-retention` | archive accounts inactive past the retention period (a date comparison against today), with the archival vendor's batch reference; litigation holds | CANCEL (regulated data), MODIFY (new batch reference), RELAX, ADD (credit, close) |
182
+ | `ops-queue` | all three stories at once in one company: shared customers table, tickets, ledger, people and handbook; the person changes job 1 while the other two run. The other jobs are posted in a #ops-queue chat channel with their sign-offs, next to a fourth job that was never signed off by anyone who can, or was called off; its customers wait with open tickets and must be left alone. Once job 1's changes are in, the person comes back about job 2 (a correction, an extra credit or closing its tickets), when its team may already be done and let go. In about 40% of queues an archive job and a refund job share a customer the refund job owes money to who has also gone dormant; archived accounts' ledgers are frozen, so the refund has to land before the archive, which only someone looking across both jobs sees | job 1's changes, then one to job 2; the shared customer refunded before being archived; every side job's facts, tags and checks namespaced, one ledger guard over all three |
183
 
184
  The test split is generated from templates registered at run time with `register_template`, outside this repo, so whole scenarios are held out.
185
 
reorgbench/env/tools.py CHANGED
@@ -243,10 +243,22 @@ def _post(w: World, log: AccessLog, entry: dict) -> str:
243
  return eid
244
 
245
 
 
 
 
 
 
 
 
 
 
 
246
  def _ledger_refund(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
247
  inv = w.get(f"ledger.invoices/{a['invoice_id']}", log)
248
  if inv is None:
249
  return {"error": "no such invoice"}
 
 
250
  if a["amount"] <= 0 or a["amount"] > inv["amount"]:
251
  return {"error": "refund amount must be positive and at most the invoice amount"}
252
  entry = {"kind": "refund", "invoice_id": a["invoice_id"], "customer_id": inv["customer_id"], "amount": a["amount"]}
@@ -264,6 +276,8 @@ def _ledger_refund(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
264
  def _ledger_credit(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
265
  if a["amount"] <= 0:
266
  return {"error": "credit amount must be positive"}
 
 
267
  eid = _post(w, log, {"kind": "credit", "customer_id": a["customer_id"], "amount": a["amount"], "note": a.get("note", "")})
268
  return {"ok": True, "entry_id": eid}
269
 
 
243
  return eid
244
 
245
 
246
+ def _frozen(w: World, cid: str, log: AccessLog) -> dict | None:
247
+ """Where the company freezes archived accounts' ledgers, nothing can be posted to one."""
248
+ if not (w.data("config/ledger") or {}).get("freeze_archived"):
249
+ return None
250
+ row = w.get(f"db.customers/{cid}", log) or {}
251
+ if str(row.get("status", "")).strip().lower() == "archived":
252
+ return {"error": f"account {cid} is archived: its ledger is frozen, nothing can be posted to it"}
253
+ return None
254
+
255
+
256
  def _ledger_refund(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
257
  inv = w.get(f"ledger.invoices/{a['invoice_id']}", log)
258
  if inv is None:
259
  return {"error": "no such invoice"}
260
+ if (err := _frozen(w, inv["customer_id"], log)):
261
+ return err
262
  if a["amount"] <= 0 or a["amount"] > inv["amount"]:
263
  return {"error": "refund amount must be positive and at most the invoice amount"}
264
  entry = {"kind": "refund", "invoice_id": a["invoice_id"], "customer_id": inv["customer_id"], "amount": a["amount"]}
 
276
  def _ledger_credit(w: World, a: dict, log: AccessLog, rnd: int) -> dict:
277
  if a["amount"] <= 0:
278
  return {"error": "credit amount must be positive"}
279
+ if (err := _frozen(w, a["customer_id"], log)):
280
+ return err
281
  eid = _post(w, log, {"kind": "credit", "customer_id": a["customer_id"], "amount": a["amount"], "note": a.get("note", "")})
282
  return {"ok": True, "entry_id": eid}
283
 
reorgbench/gen/queue.py CHANGED
@@ -21,7 +21,7 @@ from . import company
21
  from .build import (ALL_ROLES, CI, HIRE_ORDER, LOOSE, NEVER, SIGNOFF, GenerationError, Knobs, base_objects,
22
  calibrate, make_task, make_world, tier_of)
23
  from .templates import TEMPLATES, Template
24
- from .world import Ids
25
 
26
  QUEUE_ID = "ops-queue"
27
 
@@ -101,10 +101,15 @@ def sample(seed: int) -> list[tuple[Template, Knobs]]:
101
  """Three public stories, in a seeded order. The first is the job the person changes; the side jobs are
102
  smaller and fixed."""
103
  rng = random.Random(f"{QUEUE_ID}:{seed}:knobs")
104
- order = rng.sample(sorted((t for t in TEMPLATES.values() if t.split == "train"), key=lambda t: t.id), 3)
 
 
 
 
 
105
  main, *side = order
106
  k = main.sample(rng)
107
- while not k.messy: # the job that changes is a hard one
108
  k = main.sample(rng)
109
  # big enough that no one agent can read everything a job touches: the work has to be split and handed on
110
  jobs = [(main, Knobs(n=rng.choice([24, 32]), crew=1, changes=k.changes[:2], traps=k.traps, code=True, budget=2.0,
@@ -119,6 +124,85 @@ def sample(seed: int) -> list[tuple[Template, Knobs]]:
119
  return jobs
120
 
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  def _decoy(seed: int, attempt: int, objects: dict, ids: Ids, gens: list):
123
  """A plan retirement nobody signed off (or that was called off): its customers sit there with open tickets
124
  expecting a notice, and must be left alone. Its story must not overlap a real job's."""
@@ -152,10 +236,11 @@ def build_queue(seed: int, attempt: int = 0) -> tuple[Task, list]:
152
  objects, ids = base_objects(), Ids(random.Random(f"{QUEUE_ID}:{seed}:{attempt}:ids"))
153
  gens = [make_world(t, seed, k, attempt, objects, ids) for t, k in jobs]
154
  decoy = _decoy(seed, attempt, objects, ids, gens)
 
155
  gens[0].template.shuffle(gens[0])
156
  tasks = [make_task(g, attempt, late=j == 0)[0] for j, g in enumerate(gens)]
157
  main, side = tasks[0], tasks[1:]
158
- gens[0].template.finish_messy(gens[0], gens[1:], [company.QUEUE_RULE]) # one handbook with every job's rules
159
  who = company.people(gens[0])
160
  posts = [(t.phases[0].goal, "go") for t in side]
161
  posts.append((decoy.template.goal(decoy), decoy.rng.choice(["unsigned", "called off"])))
@@ -260,6 +345,11 @@ def build_queue(seed: int, attempt: int = 0) -> tuple[Task, list]:
260
  human.append(HumanFact(f"j{j}_{f.id}" if j else f.id, f"{g.story['subject']}: {f.about}",
261
  f"For the {g.story['subject']}: {f.text}", f.phases if j == 0 else None))
262
  n = sum(len(g.cohort) for g in gens)
 
 
 
 
 
263
  task = Task(id=f"{QUEUE_ID}-{seed:04d}", title="Ops queue: " + ", ".join(g.story["subject"] for g in gens),
264
  catalog=ALL_ROLES, initial_objects=objects, phases=phases, interventions=ivs, budgets=LOOSE,
265
  facts=[f for t in tasks for f in t.facts], mutants=[m for t in tasks for m in t.mutants] + [
 
21
  from .build import (ALL_ROLES, CI, HIRE_ORDER, LOOSE, NEVER, SIGNOFF, GenerationError, Knobs, base_objects,
22
  calibrate, make_task, make_world, tier_of)
23
  from .templates import TEMPLATES, Template
24
+ from .world import Acct, Ids
25
 
26
  QUEUE_ID = "ops-queue"
27
 
 
101
  """Three public stories, in a seeded order. The first is the job the person changes; the side jobs are
102
  smaller and fixed."""
103
  rng = random.Random(f"{QUEUE_ID}:{seed}:knobs")
104
+ pool = sorted((t for t in TEMPLATES.values() if t.split == "train"), key=lambda t: t.id)
105
+ order = rng.sample(pool, 3)
106
+ paired = rng.random() < 0.4 # an archive and a refund in one queue, sharing a customer (see _share)
107
+ if paired:
108
+ rest = [t for t in pool if t.id not in ("data-retention", "overcharge-refund")]
109
+ order = [TEMPLATES["data-retention"], rng.choice(rest), TEMPLATES["overcharge-refund"]]
110
  main, *side = order
111
  k = main.sample(rng)
112
+ while not k.messy or (paired and {"MODIFY", "ADD:credit"} & set(k.changes[:2])): # the job that changes is a hard one
113
  k = main.sample(rng)
114
  # big enough that no one agent can read everything a job touches: the work has to be split and handed on
115
  jobs = [(main, Knobs(n=rng.choice([24, 32]), crew=1, changes=k.changes[:2], traps=k.traps, code=True, budget=2.0,
 
124
  return jobs
125
 
126
 
127
+ FREEZE_RULE = ("Archived accounts are frozen: no credit or refund can be posted to one, and restoring an archived "
128
+ "account needs compliance sign-off. Post whatever an account is owed before you archive it.")
129
+
130
+
131
+ def _share(gens: list, objects: dict) -> list[str]:
132
+ """A customer the refund job owes money has also gone dormant, so the archive job takes it too. The refund has
133
+ to land before the archive does, and only someone looking across both jobs will see it. Only where nothing
134
+ later can change either job's figure or scope for that customer, so the order can always be got right."""
135
+ arch = next((g for g in gens if g.template.id == "data-retention"), None)
136
+ ref = next((g for g in gens if g.template.id == "overcharge-refund"), None)
137
+ if arch is None or ref is None or any(c in arch.knobs.changes for c in ("MODIFY", "ADD:credit")) \
138
+ or any(c in ref.knobs.changes for c in ("MODIFY", "ADD:credit")):
139
+ return []
140
+ special = {*ref.excluded, *ref.held, *ref.leaving, *ref.approved_out, *ref.not_approved, *ref.disputed,
141
+ *ref.holds, *ref.stale, *ref.expired, *(c for c, _ in ref.claims), *(c for c, _ in ref.merged),
142
+ *ref.not_leaving, *([ref.late] if ref.late else [])}
143
+ pool = [c for c in ref.cohort if c not in special and not ref.accts[c].tags and not ref.accts[c].prior_refund
144
+ and not objects[f"db.customers/{c}"].get("sync_managed")]
145
+ if not pool:
146
+ return []
147
+ shared = arch.rng.sample(pool, 1 + (len(pool) >= 12))
148
+ t = arch.template
149
+ for c in shared:
150
+ day = t._day(arch, -700, -400) # long dormant: well past any cut-off
151
+ fields = {"last_active": day, "data_class": "standard"}
152
+ objects[f"db.customers/{c}"].update(fields)
153
+ ref.accts[c].row.update(fields)
154
+ a = Acct(c, dict(objects[f"db.customers/{c}"]))
155
+ arch.accts[c] = a
156
+ arch.cohort.append(c)
157
+ objects[f"db.activity/{c}"] = {"last_active": day}
158
+ arch.leave_alone.append(f"db.activity/{c}")
159
+ t.add_ticket(arch, a, f"{arch.story['subject']} ({c})", t._notice(arch))
160
+ arch.story["seen"][c] = day
161
+ arch.units["moved"].free[c] = {ref.units["moved"].field_name, "sync_hold"}
162
+ ref.units["moved"].free[c] = {arch.units["moved"].field_name, "sync_hold"}
163
+ objects["config/ledger"] = {"freeze_archived": True}
164
+ return shared
165
+
166
+
167
+ def _settled_first(shared: list[str]) -> Checkpoint:
168
+ def ok(w, v):
169
+ for c in shared:
170
+ env = [e for e in v.events if e["type"] == "env" and e["payload"].get("result", {}).get("ok")]
171
+ archived = [e["id"] for e in env if e["payload"].get("tool") == "db.update"
172
+ and e["payload"].get("args", {}).get("row_id") == c
173
+ and str((e["payload"]["args"].get("fields") or {}).get("status", "")).strip().lower() == "archived"]
174
+ if not archived:
175
+ continue
176
+ paid = [e["id"] for e in env if e["payload"].get("tool") == "ledger.refund"
177
+ and (w.data(f"ledger.invoices/{e['payload']['args'].get('invoice_id')}") or {}).get("customer_id") == c]
178
+ if not paid or min(paid) > min(archived):
179
+ return False
180
+ return True
181
+ return Checkpoint("settled_before_archived", "a customer both jobs touch was refunded before being archived", ok,
182
+ negative=True)
183
+
184
+
185
+ def _barrier(phases: list[Phase], shared: list[str]) -> None:
186
+ """The careful plan archives a shared customer only once its refund has gone through: the analyst waits for the
187
+ refund's entry id, which finance reports (through the orchestrator if it has to)."""
188
+ from dataclasses import replace
189
+ for c in shared:
190
+ fact = f"settled_{c.replace('-', '_')}"
191
+ first = True
192
+ for ph in phases:
193
+ for label, steps in ph.oracle.steps.items():
194
+ for i, s in enumerate(steps):
195
+ if s.tool == "ledger.refund" and s.tag and s.tag.endswith(f"refund:{c}") and first:
196
+ steps[i] = replace(s, provides={**s.provides, fact: {"path": "entry_id"}})
197
+ first = False
198
+ for label, steps in ph.oracle.steps.items():
199
+ for i in [i for i, s in enumerate(steps) if s.tool == "db.update" and s.tag
200
+ and s.tag.endswith(f"move:{c}")][::-1]:
201
+ steps.insert(i, Step("db.query", {"table": "customers", "where": {"id": "{" + fact + "}"}}))
202
+ phases[0].oracle.orchestrator_steps = [*phases[0].oracle.orchestrator_steps,
203
+ Step("docs.read", {"doc_id": ["{" + fact + "}"]}, if_done="never:ghost")]
204
+
205
+
206
  def _decoy(seed: int, attempt: int, objects: dict, ids: Ids, gens: list):
207
  """A plan retirement nobody signed off (or that was called off): its customers sit there with open tickets
208
  expecting a notice, and must be left alone. Its story must not overlap a real job's."""
 
236
  objects, ids = base_objects(), Ids(random.Random(f"{QUEUE_ID}:{seed}:{attempt}:ids"))
237
  gens = [make_world(t, seed, k, attempt, objects, ids) for t, k in jobs]
238
  decoy = _decoy(seed, attempt, objects, ids, gens)
239
+ shared = _share(gens, objects)
240
  gens[0].template.shuffle(gens[0])
241
  tasks = [make_task(g, attempt, late=j == 0)[0] for j, g in enumerate(gens)]
242
  main, side = tasks[0], tasks[1:]
243
+ gens[0].template.finish_messy(gens[0], gens[1:], [company.QUEUE_RULE, *([FREEZE_RULE] if shared else [])])
244
  who = company.people(gens[0])
245
  posts = [(t.phases[0].goal, "go") for t in side]
246
  posts.append((decoy.template.goal(decoy), decoy.rng.choice(["unsigned", "called off"])))
 
345
  human.append(HumanFact(f"j{j}_{f.id}" if j else f.id, f"{g.story['subject']}: {f.about}",
346
  f"For the {g.story['subject']}: {f.text}", f.phases if j == 0 else None))
347
  n = sum(len(g.cohort) for g in gens)
348
+ if shared:
349
+ ck = _settled_first(shared)
350
+ for ph in phases:
351
+ ph.checkpoints.append(ck)
352
+ _barrier(phases, shared)
353
  task = Task(id=f"{QUEUE_ID}-{seed:04d}", title="Ops queue: " + ", ".join(g.story["subject"] for g in gens),
354
  catalog=ALL_ROLES, initial_objects=objects, phases=phases, interventions=ivs, budgets=LOOSE,
355
  facts=[f for t in tasks for f in t.facts], mutants=[m for t in tasks for m in t.mutants] + [
reorgbench/gen/units.py CHANGED
@@ -71,6 +71,7 @@ class Move(Unit):
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 {})}
@@ -82,8 +83,9 @@ class Move(Unit):
82
 
83
  def row_ok(self, w: World, c: str, orig: dict, value: Any) -> bool:
84
  d = w.data(f"db.customers/{c}") or {}
 
85
  return (str(d.get(self.field_name, "")).lower() == str(value).lower()
86
- and all(d.get(k) == v for k, v in orig.items() if k != self.field_name))
87
 
88
 
89
  @dataclass
 
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
+ free: dict = field(default_factory=dict) # customer -> fields another job in the queue changes on the same record
75
 
76
  def step(self, c: str) -> Step:
77
  fields = {self.field_name: self.target, **({"sync_hold": True} if c in self.hold else {})}
 
83
 
84
  def row_ok(self, w: World, c: str, orig: dict, value: Any) -> bool:
85
  d = w.data(f"db.customers/{c}") or {}
86
+ free = self.free.get(c, ())
87
  return (str(d.get(self.field_name, "")).lower() == str(value).lower()
88
+ and all(d.get(k) == v for k, v in orig.items() if k != self.field_name and k not in free))
89
 
90
 
91
  @dataclass
reorgbench/metrics/graph.py CHANGED
@@ -30,6 +30,7 @@ ACTION_TYPES = frozenset({"env", "msg", "relay", "spawn", "inspect", "kill", "fi
30
  _ID = re.compile(r"\b[A-Z][A-Z0-9]*(?:-[A-Za-z0-9]+)+\b") # INV-5521, PX-14b, QA-55X1
31
  _NUM = re.compile(r"(?<![\w.\-])\d+(?:\.\d+)?(?![\w.\-])") # 240.0, $1200; not the 8812 in CNQ-8812
32
  MIN_AMOUNT = 100
 
33
 
34
 
35
  def _canon(n: str) -> str:
@@ -42,6 +43,8 @@ def salient_tokens(x: Any, planted: Iterable[str] = ()) -> set[str]:
42
  s = x if isinstance(x, str) else json.dumps(x, sort_keys=True)
43
  out = set(_ID.findall(s))
44
  out |= {_canon(n) for n in _NUM.findall(s) if float(n) >= MIN_AMOUNT}
 
 
45
  out |= {t for t in planted if t in s}
46
  return out
47
 
 
30
  _ID = re.compile(r"\b[A-Z][A-Z0-9]*(?:-[A-Za-z0-9]+)+\b") # INV-5521, PX-14b, QA-55X1
31
  _NUM = re.compile(r"(?<![\w.\-])\d+(?:\.\d+)?(?![\w.\-])") # 240.0, $1200; not the 8812 in CNQ-8812
32
  MIN_AMOUNT = 100
33
+ _SMALL = re.compile(r"(?:\$\s?|(?<![=!<>])=\s?)(\d+(?:\.\d+)?)(?![\w.\-])")
34
 
35
 
36
  def _canon(n: str) -> str:
 
43
  s = x if isinstance(x, str) else json.dumps(x, sort_keys=True)
44
  out = set(_ID.findall(s))
45
  out |= {_canon(n) for n in _NUM.findall(s) if float(n) >= MIN_AMOUNT}
46
+ # smaller sums count where they're plainly money or a handed-over figure: "$40", "credit=40"; a bare "40 seats" doesn't
47
+ out |= {_canon(n) for n in _SMALL.findall(s) if float(n) >= 10}
48
  out |= {t for t in planted if t in s}
49
  return out
50
 
tests/test_generator.py CHANGED
@@ -261,3 +261,30 @@ def test_an_approval_given_before_the_approver_took_the_role_doesnt_count():
261
  named = [c for c in gens[0].not_approved if c in early[0]["text"] or gens[0].accts[c].row.get("name", "@") in
262
  early[0]["text"]]
263
  assert named or any(c not in gens[0].approved_out for c in gens[0].not_approved)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  named = [c for c in gens[0].not_approved if c in early[0]["text"] or gens[0].accts[c].row.get("name", "@") in
262
  early[0]["text"]]
263
  assert named or any(c not in gens[0].approved_out for c in gens[0].not_approved)
264
+
265
+
266
+ def test_a_customer_in_both_the_refund_and_the_archive_job_must_be_refunded_first():
267
+ from reorgbench.env.tools import call_tool
268
+ from reorgbench.env.world import AccessLog
269
+ from reorgbench.gen.queue import FREEZE_RULE, _settled_first, build_queue
270
+ from reorgbench.tasks.spec import EpisodeView
271
+ t, gens = build_queue(22)
272
+ arch = next(g for g in gens if g.template.id == "data-retention")
273
+ ref = next(g for g in gens if g.template.id == "overcharge-refund")
274
+ shared = [c for c in arch.cohort if c in ref.cohort]
275
+ assert shared and FREEZE_RULE in t.initial_objects["docs/operations-handbook"]["text"]
276
+ c = shared[0]
277
+ assert arch.accts[c].ticket != ref.accts[c].ticket and f"db.activity/{c}" in t.initial_objects
278
+ # once archived, nothing can be posted
279
+ w = t.world()
280
+ w.put(f"db.customers/{c}", {**w.data(f"db.customers/{c}"), "status": "archived"}, AccessLog(event_id=0))
281
+ assert "frozen" in call_tool(w, "ledger.refund", {"invoice_id": ref.accts[c].invoice, "amount": 1}, AccessLog(0), 1)["error"]
282
+ # and the order is checked
283
+ def env(i, tool, args):
284
+ return {"id": i, "type": "env", "payload": {"tool": tool, "args": args, "result": {"ok": True}}}
285
+ archive = env(1, "db.update", {"row_id": c, "fields": {"status": "archived"}})
286
+ refund = env(2, "ledger.refund", {"invoice_id": ref.accts[c].invoice, "amount": 1})
287
+ ck = _settled_first(shared)
288
+ w0 = t.world()
289
+ assert not ck.check(w0, EpisodeView([archive, refund], {}))
290
+ assert ck.check(w0, EpisodeView([{**refund, "id": 1}, {**archive, "id": 2}], {}))