@drawbridge/drawbridge-agents 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,7 +52,26 @@ skill) so it stops living only in tribal memory.
52
52
  worker retries it into the update path. The merge path must delete duplicate contacts BEFORE
53
53
  `$set`-ing the survivor (the expanded `leads` array collides with rows about to be deleted).
54
54
  Drop the index → duplicate contacts, doubled segment members, double-billed `contact.create` +
55
- `segment.join`; reorder the merge → every merge aborts E11000 and duplicates never heal.
55
+ `segment.join`; reorder the merge → every merge aborts E11000 and duplicates never heal. The
56
+ merge path also reverses each merged-away contact's **current-period** `action` rows (matched by
57
+ `meta.contact`, in the billing transaction) so the survivor isn't billed once per duplicate.
58
+ - The `action` ledger's **`{ organization : 1, createdAt : 1 }` index** (drawbridge-api
59
+ `schema/action.js`) is a shared dependency: sync's `computeCycleActions` (billing, by `createdAt`
60
+ window) AND api's date-ranged reporting (`route/organization-usage.js`) both match on it. Drop it
61
+ → COLLSCAN on every invoice + usage query.
62
+ - The `action` ledger is **permanent — no TTL** (drawbridge-api `schema/action.js`): the
63
+ proof-of-billing record AND the source for date-ranged usage reporting, both read as raw rows by
64
+ `createdAt`. Re-adding a TTL shorter than any billing interval silently under-bills long cycles
65
+ and blanks reporting past the window — any retention change must clear billing + reporting.
66
+
67
+ ## Reporting (api ↔ app-web)
68
+
69
+ - Every reporting request (usage/revenue/redemptions/analytics, org + admin) carries the viewer's
70
+ IANA `timezone` (app-web sends `Intl.DateTimeFormat().resolvedOptions().timeZone`); drawbridge-api
71
+ buckets the date range in it via `lib/report-window.js` (half-open UTC window, defaults to UTC when
72
+ absent). app-web omitting it → ranges bucket by UTC not the user's calendar days (boundary events
73
+ land on the wrong day). The param rides each endpoint's existing query shape (top-level vs
74
+ `filters`) — do NOT normalise the shapes.
56
75
 
57
76
  ## `@drawbridge/*` package coordination
58
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/drawbridge-agents",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Shared agent-instruction content (rules, code style, conventions) for the drawbridge-* monorepo.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {