@danceiny/gotry 0.0.1-rc.17 → 0.0.1-rc.19

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.
Files changed (137) hide show
  1. package/README.md +185 -148
  2. package/README.zh-CN.md +195 -154
  3. package/bin/gotry-bootstrap.js +246 -26
  4. package/bin/gotry-inner.js +68 -38
  5. package/bin/gotry-runtime-resolution.d.ts +1 -1
  6. package/bin/gotry-runtime-resolution.js +7 -8
  7. package/cordis.gotry-patch.yml +15 -5
  8. package/data/stations-12306-verify.json +524 -0
  9. package/dist/capabilities/agent-reach.js +4 -4
  10. package/dist/capabilities/channel-health.js +103 -0
  11. package/dist/capabilities/channel-registry.js +213 -0
  12. package/dist/capabilities/doctor.js +285 -0
  13. package/dist/capabilities/effect.js +178 -5
  14. package/dist/capabilities/flyai.js +13 -0
  15. package/dist/capabilities/session/adapters/ctrip-hotel.js +207 -0
  16. package/dist/capabilities/session/adapters/rail-12306.js +285 -0
  17. package/dist/capabilities/session/extension-bridge.js +14 -1
  18. package/dist/capabilities/session/extension-channel.js +4 -2
  19. package/dist/capabilities/session/extension-distribution.js +1 -1
  20. package/dist/capabilities/session-search.js +311 -0
  21. package/dist/capabilities/visa-policy.js +126 -0
  22. package/dist/scripts/agent-planning-turn-deadline-e2e.js +304 -0
  23. package/dist/scripts/agent-planning-turn-deadline-tests.js +281 -0
  24. package/dist/scripts/benchmark-environment-bridge-e2e.js +5 -10
  25. package/dist/scripts/benchmark-environment-bridge-tests.js +148 -142
  26. package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +26 -26
  27. package/dist/scripts/{booking-copilot-availability-policy-v2-tests.js → booking-copilot-availability-policy-tests.js} +115 -115
  28. package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +41 -1
  29. package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +75 -120
  30. package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +370 -61
  31. package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +2 -2
  32. package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +7 -3
  33. package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +15 -9
  34. package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +19 -11
  35. package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +16 -52
  36. package/dist/scripts/booking-copilot-runtime-proof-tests.js +3953 -155
  37. package/dist/scripts/booking-copilot-server-proof-tests.js +58 -23
  38. package/dist/scripts/booking-copilot-startup-proof-tests.js +10 -119
  39. package/dist/scripts/booking-surface-contract-proof-tests.js +1154 -326
  40. package/dist/scripts/bootstrap-tests.js +115 -44
  41. package/dist/scripts/build-metrics-report.js +339 -0
  42. package/dist/scripts/channel-probe-tests.js +148 -0
  43. package/dist/scripts/channel-probe.js +252 -0
  44. package/dist/scripts/channel-registry-tests.js +262 -0
  45. package/dist/scripts/doctor-tests.js +121 -0
  46. package/dist/scripts/effect-tests.js +274 -1
  47. package/dist/scripts/extension-tests.js +129 -11
  48. package/dist/scripts/fact-gate-tests.js +91 -2
  49. package/dist/scripts/flyai-tests.js +17 -1
  50. package/dist/scripts/hbcli-e2e-tests.js +1 -3
  51. package/dist/scripts/metrics-report-tests.js +288 -0
  52. package/dist/scripts/persona-surface-guard-tests.js +19 -0
  53. package/dist/scripts/session-tests.js +401 -1
  54. package/dist/scripts/smoke.js +100 -83
  55. package/dist/scripts/turn-handoff-collect-tests.js +216 -0
  56. package/dist/scripts/turn-handoff-collect.js +189 -0
  57. package/dist/scripts/turn-policy-tests.js +56 -0
  58. package/dist/scripts/typed-contract-canary.js +261 -0
  59. package/dist/scripts/visa-policy-tests.js +75 -0
  60. package/dist/scripts/wish-channel-gate-tests.js +111 -0
  61. package/dist/src/artifact-gate.js +91 -3
  62. package/dist/src/benchmark-agent-conformance.js +7 -4
  63. package/dist/src/benchmark-environment-bridge.js +68 -7
  64. package/dist/src/bookable-facts.js +62 -3
  65. package/dist/src/booking-surface/{availability-policy-v2.js → availability-policy.js} +89 -89
  66. package/dist/src/booking-surface/canonical-schema.js +8 -22
  67. package/dist/src/booking-surface/contracts.js +70 -19
  68. package/dist/src/booking-surface/dsh-planner.js +310 -177
  69. package/dist/src/booking-surface/dsh-plugin.js +3 -3
  70. package/dist/src/booking-surface/index.js +1 -5
  71. package/dist/src/booking-surface/profile.js +1 -1
  72. package/dist/src/booking-surface/runtime.js +1682 -247
  73. package/dist/src/booking-surface/server.js +371 -185
  74. package/dist/src/booking-surface/startup.js +17 -27
  75. package/dist/src/booking-surface/validation.js +270 -760
  76. package/dist/src/index.js +735 -149
  77. package/dist/src/turn-deadline.js +292 -0
  78. package/dist/src/turn-policy.js +146 -0
  79. package/dist/src/wish-pool.js +5 -0
  80. package/extension/background.js +23 -4
  81. package/extension/content-main.js +47 -9
  82. package/extension/manifest.json +27 -9
  83. package/package.json +6 -26
  84. package/schemas/booking.surface.schema.json +2593 -0
  85. package/ts/capabilities/agent-reach.ts +4 -4
  86. package/ts/capabilities/flyai.ts +21 -3
  87. package/ts/capabilities/session/action-cache.ts +1 -1
  88. package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
  89. package/ts/capabilities/session/adapters/rail-12306.ts +293 -0
  90. package/ts/capabilities/session/extension-bridge.ts +32 -2
  91. package/ts/capabilities/session/extension-channel.ts +9 -8
  92. package/ts/capabilities/session/extension-distribution.ts +3 -1
  93. package/ts/capabilities/session/health-watch.ts +1 -1
  94. package/ts/capabilities/session/read-guard.ts +1 -1
  95. package/ts/capabilities/session/wizard.ts +1 -1
  96. package/ts/capabilities/session-search.ts +323 -1
  97. package/ts/package.json +1 -0
  98. package/ts/scripts/turn-handoff-collect.ts +178 -0
  99. package/ts/src/artifact-gate.ts +82 -2
  100. package/ts/src/benchmark-agent-conformance.ts +14 -6
  101. package/ts/src/benchmark-environment-bridge.ts +29 -10
  102. package/ts/src/bookable-facts.ts +109 -5
  103. package/ts/src/booking-saga.ts +1 -1
  104. package/ts/src/booking-surface/{availability-policy-v2.ts → availability-policy.ts} +124 -125
  105. package/ts/src/booking-surface/canonical-schema.js +8 -22
  106. package/ts/src/booking-surface/contracts.ts +278 -239
  107. package/ts/src/booking-surface/dsh-planner.ts +333 -194
  108. package/ts/src/booking-surface/dsh-plugin.js +3 -3
  109. package/ts/src/booking-surface/index.ts +1 -5
  110. package/ts/src/booking-surface/profile.ts +11 -11
  111. package/ts/src/booking-surface/runtime.ts +1351 -351
  112. package/ts/src/booking-surface/server.ts +282 -175
  113. package/ts/src/booking-surface/startup.ts +36 -48
  114. package/ts/src/booking-surface/validation.ts +194 -442
  115. package/ts/src/contracts.ts +1 -1
  116. package/ts/src/index.ts +489 -171
  117. package/ts/src/loop.ts +1 -1
  118. package/ts/src/state-ledger.ts +1 -1
  119. package/ts/src/turn-deadline.ts +361 -0
  120. package/ts/src/turn-policy.ts +154 -0
  121. package/ts/src/wish-pool.ts +17 -4
  122. package/dist/scripts/agent-planning-budget-e2e.js +0 -227
  123. package/dist/scripts/agent-planning-budget-tests.js +0 -173
  124. package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +0 -3935
  125. package/dist/scripts/booking-surface-v2-contract-proof-tests.js +0 -1174
  126. package/dist/src/booking-surface/contracts-v2.js +0 -89
  127. package/dist/src/booking-surface/runtime-v2.js +0 -1771
  128. package/dist/src/booking-surface/server-v2.js +0 -334
  129. package/dist/src/booking-surface/validation-v2.js +0 -319
  130. package/dist/src/tool-budget.js +0 -136
  131. package/schemas/booking.surface.v1.schema.json +0 -927
  132. package/schemas/booking.surface.v2.schema.json +0 -61
  133. package/ts/src/booking-surface/contracts-v2.ts +0 -118
  134. package/ts/src/booking-surface/runtime-v2.ts +0 -1466
  135. package/ts/src/booking-surface/server-v2.ts +0 -247
  136. package/ts/src/booking-surface/validation-v2.ts +0 -205
  137. package/ts/src/tool-budget.ts +0 -165
@@ -3,9 +3,9 @@ import { mkdtempSync, rmSync } from 'node:fs';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { ensureLedger } from '../src/state-ledger.js';
6
- import { BookingCopilotTaskRuntimeV2 } from '../src/booking-surface/runtime-v2.js';
7
- import { createAvailabilityPolicyV2, digestV2, MAX_HOTELS_PER_TASK_V2, MAX_OFFER_CHECKS_PER_HOTEL_V2, MAX_OFFER_QUERIES_PER_HOTEL_V2, recordObservedOffersQueryV2, recordOfferCheckIssuedV2, recordOfferCheckReceiptV2, recordOffersGenerationV2, recordOffersQueryIssuedV2, canIssueOfferCheckV2 } from '../src/booking-surface/availability-policy-v2.js';
8
- import { bookingSurfaceAllowedActionsV2 } from '../src/booking-surface/contracts-v2.js';
6
+ import { BookingCopilotTaskRuntime } from '../src/booking-surface/runtime.js';
7
+ import { createAvailabilityPolicy, digest, MAX_HOTELS_PER_TASK, MAX_OFFER_CHECKS_PER_HOTEL, MAX_OFFER_QUERIES_PER_HOTEL, recordObservedOffersQuery, recordOfferCheckIssued, recordOfferCheckReceipt, recordOffersGeneration, recordOffersQueryIssued, canIssueOfferCheck } from '../src/booking-surface/availability-policy.js';
8
+ import { bookingSurfaceAllowedActions } from '../src/booking-surface/contracts.js';
9
9
  const versionFor = (offerRef, suffix = 'v1')=>`${offerRef}:${suffix}`;
10
10
  const verifiedCapability = (offerRef, offerVersionRef = versionFor(offerRef), expiresAt = '2026-09-01T10:30:00.000Z')=>({
11
11
  offerRef,
@@ -14,7 +14,7 @@ const verifiedCapability = (offerRef, offerVersionRef = versionFor(offerRef), ex
14
14
  expiresAt
15
15
  });
16
16
  const ws = (revision, hotels, offers, shortlistedOfferRefs = [], verifiedOffer)=>({
17
- schemaVersion: 'booking.surface.v2',
17
+ schemaVersion: 'booking.surface',
18
18
  contextRef: 'ctx-availability',
19
19
  surface: 'tenant',
20
20
  revision,
@@ -49,7 +49,7 @@ const ws = (revision, hotels, offers, shortlistedOfferRefs = [], verifiedOffer)=
49
49
  } : {}
50
50
  });
51
51
  const receipt = (actionId, revision, offerRef, status = 'unavailable', available = false, checkedOfferVersionRef = versionFor(offerRef), currentOfferVersionRef)=>({
52
- schemaVersion: 'booking.surface.v2',
52
+ schemaVersion: 'booking.surface',
53
53
  kind: 'action.receipt',
54
54
  actionId,
55
55
  contextRef: 'ctx-availability',
@@ -74,10 +74,10 @@ const receipt = (actionId, revision, offerRef, status = 'unavailable', available
74
74
  relaxationsApplied: []
75
75
  }
76
76
  });
77
- const foldQuery = (state, hotelRefs, workspace, actionId, queryReceipt, criteriaDigest = '')=>recordOffersGenerationV2(state, hotelRefs, workspace, actionId, digestV2(queryReceipt), queryReceipt, criteriaDigest);
77
+ const foldQuery = (state, hotelRefs, workspace, actionId, queryReceipt, criteriaDigest = '')=>recordOffersGeneration(state, hotelRefs, workspace, actionId, digest(queryReceipt), queryReceipt, criteriaDigest);
78
78
  const criteria = {};
79
79
  const offersReceipt = (actionId, revision, hotelRefs, offerRefs, loadedHotelCount, status = 'applied', outcome = 'complete', hardCriteriaMet = true)=>({
80
- schemaVersion: 'booking.surface.v2',
80
+ schemaVersion: 'booking.surface',
81
81
  kind: 'action.receipt',
82
82
  actionId,
83
83
  contextRef: 'ctx-availability',
@@ -100,7 +100,7 @@ const offersReceipt = (actionId, revision, hotelRefs, offerRefs, loadedHotelCoun
100
100
  }
101
101
  });
102
102
  const gapReceipt = (actionId, revision, status = 'failed')=>({
103
- schemaVersion: 'booking.surface.v2',
103
+ schemaVersion: 'booking.surface',
104
104
  kind: 'action.receipt',
105
105
  actionId,
106
106
  contextRef: 'ctx-availability',
@@ -122,13 +122,13 @@ const gapReceipt = (actionId, revision, status = 'failed')=>({
122
122
  relaxationsApplied: []
123
123
  }
124
124
  });
125
- assert.deepEqual(bookingSurfaceAllowedActionsV2('storefront'), [
125
+ assert.deepEqual(bookingSurfaceAllowedActions('storefront'), [
126
126
  'search.patch',
127
127
  'search.run',
128
128
  'results.view.patch',
129
129
  'hotel.focus'
130
130
  ]);
131
- assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
131
+ assert.deepEqual(bookingSurfaceAllowedActions('payment_link'), [
132
132
  'search.patch',
133
133
  'search.run',
134
134
  'results.view.patch',
@@ -136,9 +136,9 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
136
136
  'hotel.select'
137
137
  ]);
138
138
  {
139
- assert.equal(MAX_HOTELS_PER_TASK_V2, 5);
140
- assert.equal(MAX_OFFER_CHECKS_PER_HOTEL_V2, 2);
141
- assert.equal(MAX_OFFER_QUERIES_PER_HOTEL_V2, 2);
139
+ assert.equal(MAX_HOTELS_PER_TASK, 5);
140
+ assert.equal(MAX_OFFER_CHECKS_PER_HOTEL, 2);
141
+ assert.equal(MAX_OFFER_QUERIES_PER_HOTEL, 2);
142
142
  const unavailableWorkspace = ws(0, [
143
143
  'budget-hotel'
144
144
  ], [
@@ -147,8 +147,8 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
147
147
  'budget-hotel'
148
148
  ]
149
149
  ]);
150
- let exhausted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), 'budget-check-1');
151
- exhausted = recordOfferCheckReceiptV2(exhausted, ws(1, [
150
+ let exhausted = recordOfferCheckIssued(createAvailabilityPolicy(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), 'budget-check-1');
151
+ exhausted = recordOfferCheckReceipt(exhausted, ws(1, [
152
152
  'budget-hotel'
153
153
  ], [
154
154
  [
@@ -157,7 +157,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
157
157
  ]
158
158
  ]), receipt('budget-check-1', 1, 'budget-hotel:ratepkg-1'), 'budget-check-1', 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), 0);
159
159
  assert.equal(exhausted.hotels['budget-hotel']?.freshOffersRequired, true, 'first unavailable opens exactly one fresh-generation transition');
160
- exhausted = recordOffersQueryIssuedV2(exhausted, [
160
+ exhausted = recordOffersQueryIssued(exhausted, [
161
161
  'budget-hotel'
162
162
  ], ws(1, [
163
163
  'budget-hotel'
@@ -172,7 +172,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
172
172
  ], [
173
173
  'budget-hotel:ratepkg-1'
174
174
  ], 1);
175
- const reused = recordOffersGenerationV2(exhausted, [
175
+ const reused = recordOffersGeneration(exhausted, [
176
176
  'budget-hotel'
177
177
  ], ws(2, [
178
178
  'budget-hotel'
@@ -181,7 +181,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
181
181
  'budget-hotel:ratepkg-1',
182
182
  'budget-hotel'
183
183
  ]
184
- ]), 'budget-query-1', digestV2(reusedReceipt), reusedReceipt);
184
+ ]), 'budget-query-1', digest(reusedReceipt), reusedReceipt);
185
185
  assert.deepEqual(reused.hotels['budget-hotel']?.currentOfferRefs, [], 'fresh HotelRates cannot re-admit the checked stale OfferRef');
186
186
  assert.equal(reused.hotels['budget-hotel']?.freshOffersRequired, true, 'stale OfferRef reuse leaves an explicit refresh transition');
187
187
  const refreshedReceipt = offersReceipt('budget-query-1', 2, [
@@ -189,7 +189,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
189
189
  ], [
190
190
  'budget-hotel:ratepkg-2'
191
191
  ], 1);
192
- exhausted = recordOffersGenerationV2(exhausted, [
192
+ exhausted = recordOffersGeneration(exhausted, [
193
193
  'budget-hotel'
194
194
  ], ws(2, [
195
195
  'budget-hotel'
@@ -198,8 +198,8 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
198
198
  'budget-hotel:ratepkg-2',
199
199
  'budget-hotel'
200
200
  ]
201
- ]), 'budget-query-1', digestV2(refreshedReceipt), refreshedReceipt);
202
- exhausted = recordOfferCheckIssuedV2(exhausted, ws(2, [
201
+ ]), 'budget-query-1', digest(refreshedReceipt), refreshedReceipt);
202
+ exhausted = recordOfferCheckIssued(exhausted, ws(2, [
203
203
  'budget-hotel'
204
204
  ], [
205
205
  [
@@ -207,7 +207,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
207
207
  'budget-hotel'
208
208
  ]
209
209
  ]), 'budget-hotel:ratepkg-2', versionFor('budget-hotel:ratepkg-2'), 'budget-check-2');
210
- exhausted = recordOfferCheckReceiptV2(exhausted, ws(3, [
210
+ exhausted = recordOfferCheckReceipt(exhausted, ws(3, [
211
211
  'budget-hotel'
212
212
  ], [
213
213
  [
@@ -217,7 +217,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
217
217
  ]), receipt('budget-check-2', 3, 'budget-hotel:ratepkg-2'), 'budget-check-2', 'budget-hotel:ratepkg-2', versionFor('budget-hotel:ratepkg-2'), 2);
218
218
  assert.equal(exhausted.hotels['budget-hotel']?.checksIssued, 2, 'second unavailable consumes the lifetime CheckAvail budget');
219
219
  assert.equal(exhausted.terminal?.code, 'availability_exhausted_complete', 'second unavailable reaches conclusive exhaustion');
220
- assert.throws(()=>recordOfferCheckIssuedV2(exhausted, ws(3, [
220
+ assert.throws(()=>recordOfferCheckIssued(exhausted, ws(3, [
221
221
  'budget-hotel'
222
222
  ], [
223
223
  [
@@ -248,8 +248,8 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
248
248
  relaxationsApplied: []
249
249
  }
250
250
  });
251
- let inconclusive = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), 'gap-check-1');
252
- inconclusive = recordOfferCheckReceiptV2(inconclusive, ws(1, [
251
+ let inconclusive = recordOfferCheckIssued(createAvailabilityPolicy(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), 'gap-check-1');
252
+ inconclusive = recordOfferCheckReceipt(inconclusive, ws(1, [
253
253
  'budget-hotel'
254
254
  ], [
255
255
  [
@@ -260,7 +260,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
260
260
  assert.equal(inconclusive.hotels['budget-hotel']?.status, 'inconclusive', 'generic gap is not accepted as a typed negative');
261
261
  assert.equal(inconclusive.hotels['budget-hotel']?.tombstonedOfferRefs.includes('budget-hotel:ratepkg-1'), false, 'generic gap cannot tombstone logical offer');
262
262
  assert.equal(inconclusive.hotels['budget-hotel']?.tombstonedOfferVersionRefs.includes(versionFor('budget-hotel:ratepkg-1')), false, 'generic gap cannot tombstone offer version');
263
- inconclusive = recordOffersQueryIssuedV2(inconclusive, [
263
+ inconclusive = recordOffersQueryIssued(inconclusive, [
264
264
  'budget-hotel'
265
265
  ], ws(1, [
266
266
  'budget-hotel'
@@ -275,7 +275,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
275
275
  ], [
276
276
  'budget-hotel:ratepkg-3'
277
277
  ], 1);
278
- inconclusive = recordOffersGenerationV2(inconclusive, [
278
+ inconclusive = recordOffersGeneration(inconclusive, [
279
279
  'budget-hotel'
280
280
  ], ws(2, [
281
281
  'budget-hotel'
@@ -284,8 +284,8 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
284
284
  'budget-hotel:ratepkg-3',
285
285
  'budget-hotel'
286
286
  ]
287
- ]), 'gap-query-1', digestV2(gapRefreshedReceipt), gapRefreshedReceipt);
288
- inconclusive = recordOfferCheckIssuedV2(inconclusive, ws(2, [
287
+ ]), 'gap-query-1', digest(gapRefreshedReceipt), gapRefreshedReceipt);
288
+ inconclusive = recordOfferCheckIssued(inconclusive, ws(2, [
289
289
  'budget-hotel'
290
290
  ], [
291
291
  [
@@ -293,7 +293,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
293
293
  'budget-hotel'
294
294
  ]
295
295
  ]), 'budget-hotel:ratepkg-3', versionFor('budget-hotel:ratepkg-3'), 'gap-check-2');
296
- inconclusive = recordOfferCheckReceiptV2(inconclusive, ws(3, [
296
+ inconclusive = recordOfferCheckReceipt(inconclusive, ws(3, [
297
297
  'budget-hotel'
298
298
  ], [
299
299
  [
@@ -317,7 +317,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
317
317
  'no_match'
318
318
  ]){
319
319
  const gapAction = `generic-gap-${status}`;
320
- const gapState = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), gapAction);
320
+ const gapState = recordOfferCheckIssued(createAvailabilityPolicy(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), gapAction);
321
321
  const gap = {
322
322
  ...receipt(gapAction, 1, 'budget-hotel:ratepkg-1', status),
323
323
  observation: {
@@ -341,7 +341,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
341
341
  relaxationsApplied: []
342
342
  }
343
343
  };
344
- const afterGap = recordOfferCheckReceiptV2(gapState, ws(1, [
344
+ const afterGap = recordOfferCheckReceipt(gapState, ws(1, [
345
345
  'budget-hotel'
346
346
  ], [
347
347
  [
@@ -353,8 +353,8 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
353
353
  assert.equal(afterGap.hotels['budget-hotel']?.tombstonedOfferRefs.includes('budget-hotel:ratepkg-1'), false, `${status} with generic gap cannot tombstone logical offer`);
354
354
  assert.equal(afterGap.hotels['budget-hotel']?.tombstonedOfferVersionRefs.includes(versionFor('budget-hotel:ratepkg-1')), false, `${status} with generic gap cannot tombstone version`);
355
355
  }
356
- let queryBudget = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), 'query-budget-check');
357
- queryBudget = recordOfferCheckReceiptV2(queryBudget, ws(1, [
356
+ let queryBudget = recordOfferCheckIssued(createAvailabilityPolicy(unavailableWorkspace), unavailableWorkspace, 'budget-hotel:ratepkg-1', versionFor('budget-hotel:ratepkg-1'), 'query-budget-check');
357
+ queryBudget = recordOfferCheckReceipt(queryBudget, ws(1, [
358
358
  'budget-hotel'
359
359
  ], [
360
360
  [
@@ -373,7 +373,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
373
373
  ]
374
374
  ]){
375
375
  const offerRef = `budget-hotel:query-ratepkg-${revision}`;
376
- queryBudget = recordOffersQueryIssuedV2(queryBudget, [
376
+ queryBudget = recordOffersQueryIssued(queryBudget, [
377
377
  'budget-hotel'
378
378
  ], ws(revision - 1, [
379
379
  'budget-hotel'
@@ -388,7 +388,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
388
388
  ], [
389
389
  offerRef
390
390
  ], 1);
391
- queryBudget = recordOffersGenerationV2(queryBudget, [
391
+ queryBudget = recordOffersGeneration(queryBudget, [
392
392
  'budget-hotel'
393
393
  ], ws(revision, [
394
394
  'budget-hotel'
@@ -397,10 +397,10 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
397
397
  offerRef,
398
398
  'budget-hotel'
399
399
  ]
400
- ]), actionId, digestV2(queryReceipt), queryReceipt);
400
+ ]), actionId, digest(queryReceipt), queryReceipt);
401
401
  }
402
402
  assert.equal(queryBudget.hotels['budget-hotel']?.offerQueriesIssued, 2, 'two refresh queries are retained as lifetime usage');
403
- assert.throws(()=>recordOffersQueryIssuedV2(queryBudget, [
403
+ assert.throws(()=>recordOffersQueryIssued(queryBudget, [
404
404
  'budget-hotel'
405
405
  ], ws(3, [
406
406
  'budget-hotel'
@@ -429,7 +429,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
429
429
  'candidate-4',
430
430
  'candidate-5'
431
431
  ]);
432
- const candidates = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(candidateWorkspace), candidateWorkspace, 'candidate-6', versionFor('candidate-6'), 'candidate-check');
432
+ const candidates = recordOfferCheckIssued(createAvailabilityPolicy(candidateWorkspace), candidateWorkspace, 'candidate-6', versionFor('candidate-6'), 'candidate-check');
433
433
  assert.deepEqual(candidates.hotelRefs, [
434
434
  'h6',
435
435
  'h1',
@@ -451,8 +451,8 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
451
451
  'dup-b'
452
452
  ]
453
453
  ]);
454
- assert.throws(()=>createAvailabilityPolicyV2(duplicateWorkspace), /availability_duplicate_offer_ref/, 'loaded OfferRef must be globally unique before any .find-based authority lookup');
455
- assert.throws(()=>canIssueOfferCheckV2(createAvailabilityPolicyV2(ws(0, [
454
+ assert.throws(()=>createAvailabilityPolicy(duplicateWorkspace), /availability_duplicate_offer_ref/, 'loaded OfferRef must be globally unique before any .find-based authority lookup');
455
+ assert.throws(()=>canIssueOfferCheck(createAvailabilityPolicy(ws(0, [
456
456
  'dup-a'
457
457
  ], [])), duplicateWorkspace, 'dup-offer', versionFor('dup-offer')), /availability_duplicate_offer_ref/);
458
458
  }{
@@ -478,7 +478,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
478
478
  ], [
479
479
  'room-4'
480
480
  ]);
481
- const selected = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(roomList), roomList, 'room-4', versionFor('room-4'), 'room-check');
481
+ const selected = recordOfferCheckIssued(createAvailabilityPolicy(roomList), roomList, 'room-4', versionFor('room-4'), 'room-check');
482
482
  assert.deepEqual(selected.hotels['room-hotel']?.currentOfferRefs, [
483
483
  'room-4',
484
484
  'room-1',
@@ -493,10 +493,10 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
493
493
  'complete-hotel'
494
494
  ]
495
495
  ]);
496
- const completeStarted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(complete), complete, 'complete-1', versionFor('complete-1'), 'complete-check');
497
- const completeQuery = recordOffersQueryIssuedV2(completeStarted, [
496
+ const completeStarted = recordOfferCheckIssued(createAvailabilityPolicy(complete), complete, 'complete-1', versionFor('complete-1'), 'complete-check');
497
+ const completeQuery = recordOffersQueryIssued(completeStarted, [
498
498
  'complete-hotel'
499
- ], complete, 'complete-query', digestV2(criteria), criteria);
499
+ ], complete, 'complete-query', digest(criteria), criteria);
500
500
  const fourOfferWorkspace = ws(1, [
501
501
  'complete-hotel'
502
502
  ], [
@@ -517,9 +517,9 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
517
517
  'complete-hotel'
518
518
  ]
519
519
  ]);
520
- assert.throws(()=>recordOffersGenerationV2(completeQuery, [
520
+ assert.throws(()=>recordOffersGeneration(completeQuery, [
521
521
  'complete-hotel'
522
- ], fourOfferWorkspace, 'complete-query', digestV2(offersReceipt('complete-query', 1, [
522
+ ], fourOfferWorkspace, 'complete-query', digest(offersReceipt('complete-query', 1, [
523
523
  'complete-hotel'
524
524
  ], [
525
525
  'complete-1',
@@ -533,7 +533,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
533
533
  'complete-2',
534
534
  'complete-3',
535
535
  'complete-4'
536
- ], 1), digestV2(criteria), criteria), /availability_offer_limit_exceeded/);
536
+ ], 1), digest(criteria), criteria), /availability_offer_limit_exceeded/);
537
537
  }{
538
538
  const partialWorkspace = ws(0, [
539
539
  'partial-hotel'
@@ -551,16 +551,16 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
551
551
  'partial-hotel'
552
552
  ]
553
553
  ]);
554
- const partialStarted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(partialWorkspace), partialWorkspace, 'partial-1', versionFor('partial-1'), 'partial-check');
555
- const partialQuery = recordOffersQueryIssuedV2(partialStarted, [
554
+ const partialStarted = recordOfferCheckIssued(createAvailabilityPolicy(partialWorkspace), partialWorkspace, 'partial-1', versionFor('partial-1'), 'partial-check');
555
+ const partialQuery = recordOffersQueryIssued(partialStarted, [
556
556
  'partial-hotel'
557
- ], partialWorkspace, 'partial-query', digestV2(criteria), criteria);
557
+ ], partialWorkspace, 'partial-query', digest(criteria), criteria);
558
558
  const partialReceipt = offersReceipt('partial-query', 1, [
559
559
  'partial-hotel'
560
560
  ], [
561
561
  'partial-2'
562
562
  ], 1, 'partial', 'partial', false);
563
- const partial = recordOffersGenerationV2(partialQuery, [
563
+ const partial = recordOffersGeneration(partialQuery, [
564
564
  'partial-hotel'
565
565
  ], ws(1, [
566
566
  'partial-hotel'
@@ -577,11 +577,11 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
577
577
  'partial-3',
578
578
  'partial-hotel'
579
579
  ]
580
- ]), 'partial-query', digestV2(partialReceipt), partialReceipt, digestV2(criteria), criteria);
580
+ ]), 'partial-query', digest(partialReceipt), partialReceipt, digest(criteria), criteria);
581
581
  assert.equal(partial.hotels['partial-hotel']?.currentGeneration?.evidence, 'partial');
582
582
  assert.equal(partial.hotels['partial-hotel']?.currentOfferRefs.length, 0);
583
583
  assert.equal(partial.hotels['partial-hotel']?.freshOffersRequired, true);
584
- assert.throws(()=>recordOffersGenerationV2(partialQuery, [
584
+ assert.throws(()=>recordOffersGeneration(partialQuery, [
585
585
  'partial-hotel'
586
586
  ], ws(1, [
587
587
  'partial-hotel'
@@ -594,7 +594,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
594
594
  'partial-2',
595
595
  'partial-hotel'
596
596
  ]
597
- ]), 'partial-query', digestV2(offersReceipt('partial-query', 1, [
597
+ ]), 'partial-query', digest(offersReceipt('partial-query', 1, [
598
598
  'partial-hotel'
599
599
  ], [
600
600
  'partial-1'
@@ -602,7 +602,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
602
602
  'partial-hotel'
603
603
  ], [
604
604
  'partial-1'
605
- ], 2, 'partial', 'partial', false), digestV2(criteria), criteria), /availability_offers_count_mismatch/);
605
+ ], 2, 'partial', 'partial', false), digest(criteria), criteria), /availability_offers_count_mismatch/);
606
606
  const emptyWorkspace = ws(0, [
607
607
  'empty-hotel'
608
608
  ], [
@@ -611,16 +611,16 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
611
611
  'empty-hotel'
612
612
  ]
613
613
  ]);
614
- const emptyStarted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(emptyWorkspace), emptyWorkspace, 'empty-1', versionFor('empty-1'), 'empty-check');
615
- const emptyQuery = recordOffersQueryIssuedV2(emptyStarted, [
614
+ const emptyStarted = recordOfferCheckIssued(createAvailabilityPolicy(emptyWorkspace), emptyWorkspace, 'empty-1', versionFor('empty-1'), 'empty-check');
615
+ const emptyQuery = recordOffersQueryIssued(emptyStarted, [
616
616
  'empty-hotel'
617
617
  ], emptyWorkspace, 'empty-query');
618
618
  const empty = offersReceipt('empty-query', 1, [
619
619
  'empty-hotel'
620
620
  ], [], 0, 'no_match', 'empty', false);
621
- assert.throws(()=>recordOffersGenerationV2(emptyQuery, [
621
+ assert.throws(()=>recordOffersGeneration(emptyQuery, [
622
622
  'empty-hotel'
623
- ], emptyWorkspace, 'empty-query', digestV2(empty), empty), /availability_offers_workspace_mismatch/);
623
+ ], emptyWorkspace, 'empty-query', digest(empty), empty), /availability_offers_workspace_mismatch/);
624
624
  }{
625
625
  const seedWorkspace = ws(0, [
626
626
  'seed-hotel'
@@ -635,15 +635,15 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
635
635
  ], [
636
636
  'seed-1'
637
637
  ], 1);
638
- const seeded = recordObservedOffersQueryV2(createAvailabilityPolicyV2(seedWorkspace), [
638
+ const seeded = recordObservedOffersQuery(createAvailabilityPolicy(seedWorkspace), [
639
639
  'seed-hotel'
640
- ], digestV2(criteria), seedWorkspace, seed, 'seed-query', digestV2(seed), criteria);
641
- assert.equal(seeded.criteriaDigest, digestV2(criteria));
642
- const cleared = recordObservedOffersQueryV2(seeded, [
640
+ ], digest(criteria), seedWorkspace, seed, 'seed-query', digest(seed), criteria);
641
+ assert.equal(seeded.criteriaDigest, digest(criteria));
642
+ const cleared = recordObservedOffersQuery(seeded, [
643
643
  'seed-hotel'
644
- ], digestV2(criteria), ws(2, [
644
+ ], digest(criteria), ws(2, [
645
645
  'seed-hotel'
646
- ], []), gapReceipt('failed-query', 2), 'failed-query', digestV2(gapReceipt('failed-query', 2)), criteria);
646
+ ], []), gapReceipt('failed-query', 2), 'failed-query', digest(gapReceipt('failed-query', 2)), criteria);
647
647
  assert.equal(cleared.criteria, undefined);
648
648
  assert.equal(cleared.criteriaDigest, undefined);
649
649
  assert.equal(cleared.lastQuerySourceActionId, undefined);
@@ -655,32 +655,32 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
655
655
  'verify-hotel'
656
656
  ]
657
657
  ]);
658
- const verificationStarted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(verificationWorkspace), verificationWorkspace, 'verify-1', versionFor('verify-1'), 'verify-check');
658
+ const verificationStarted = recordOfferCheckIssued(createAvailabilityPolicy(verificationWorkspace), verificationWorkspace, 'verify-1', versionFor('verify-1'), 'verify-check');
659
659
  const wrongVerified = {
660
660
  ...verificationWorkspace,
661
661
  revision: 1,
662
662
  verifiedOffer: verifiedCapability('other-offer', versionFor('other-offer'))
663
663
  };
664
- const wrong = recordOfferCheckReceiptV2(verificationStarted, wrongVerified, receipt('verify-check', 1, 'verify-1', 'applied', true), 'verify-check', 'verify-1', versionFor('verify-1'), 0);
664
+ const wrong = recordOfferCheckReceipt(verificationStarted, wrongVerified, receipt('verify-check', 1, 'verify-1', 'applied', true), 'verify-check', 'verify-1', versionFor('verify-1'), 0);
665
665
  assert.notEqual(wrong.terminal?.code, 'availability_confirmed');
666
666
  assert.equal(wrong.hotels['verify-hotel']?.status, 'inconclusive');
667
- const matchingStarted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(verificationWorkspace), verificationWorkspace, 'verify-1', versionFor('verify-1'), 'verify-match');
667
+ const matchingStarted = recordOfferCheckIssued(createAvailabilityPolicy(verificationWorkspace), verificationWorkspace, 'verify-1', versionFor('verify-1'), 'verify-match');
668
668
  const matchingWorkspace = {
669
669
  ...verificationWorkspace,
670
670
  revision: 1,
671
671
  verifiedOffer: verifiedCapability('verify-1')
672
672
  };
673
- const matching = recordOfferCheckReceiptV2(matchingStarted, matchingWorkspace, receipt('verify-match', 1, 'verify-1', 'applied', true), 'verify-match', 'verify-1', versionFor('verify-1'), 0);
673
+ const matching = recordOfferCheckReceipt(matchingStarted, matchingWorkspace, receipt('verify-match', 1, 'verify-1', 'applied', true), 'verify-match', 'verify-1', versionFor('verify-1'), 0);
674
674
  assert.equal(matching.terminal?.code, 'availability_confirmed');
675
675
  const verificationSeedReceipt = offersReceipt('verify-seed', 0, [
676
676
  'verify-hotel'
677
677
  ], [
678
678
  'verify-1'
679
679
  ], 1);
680
- const verificationSeed = recordObservedOffersQueryV2(createAvailabilityPolicyV2(verificationWorkspace), [
680
+ const verificationSeed = recordObservedOffersQuery(createAvailabilityPolicy(verificationWorkspace), [
681
681
  'verify-hotel'
682
- ], digestV2(criteria), verificationWorkspace, verificationSeedReceipt, 'verify-seed', digestV2(verificationSeedReceipt), criteria);
683
- const changedStarted = recordOfferCheckIssuedV2(verificationSeed, verificationWorkspace, 'verify-1', versionFor('verify-1'), 'verify-changed');
682
+ ], digest(criteria), verificationWorkspace, verificationSeedReceipt, 'verify-seed', digest(verificationSeedReceipt), criteria);
683
+ const changedStarted = recordOfferCheckIssued(verificationSeed, verificationWorkspace, 'verify-1', versionFor('verify-1'), 'verify-changed');
684
684
  const changedReceipt = {
685
685
  ...receipt('verify-changed', 1, 'verify-1', 'changed', true, versionFor('verify-1'), versionFor('verify-1', 'v2')),
686
686
  observation: {
@@ -703,7 +703,7 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
703
703
  relaxationsApplied: []
704
704
  }
705
705
  };
706
- const changed = recordOfferCheckReceiptV2(changedStarted, {
706
+ const changed = recordOfferCheckReceipt(changedStarted, {
707
707
  ...verificationWorkspace,
708
708
  revision: 1,
709
709
  loadedOffers: [
@@ -741,16 +741,16 @@ assert.deepEqual(bookingSurfaceAllowedActionsV2('payment_link'), [
741
741
  ], [
742
742
  'b1'
743
743
  ]);
744
- assert.throws(()=>recordOffersQueryIssuedV2(createAvailabilityPolicyV2(initial), [
744
+ assert.throws(()=>recordOffersQueryIssued(createAvailabilityPolicy(initial), [
745
745
  'h1'
746
746
  ], initial, 'pre-q'), /recovery_not_started/);
747
- let state = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(initial), initial, 'o1', versionFor('o1'), 'check-1');
747
+ let state = recordOfferCheckIssued(createAvailabilityPolicy(initial), initial, 'o1', versionFor('o1'), 'check-1');
748
748
  assert.deepEqual(state.hotelRefs, [
749
749
  'h1',
750
750
  'h2'
751
751
  ]);
752
752
  assert.equal(state.hotels.h1?.offerQueriesIssued, 0);
753
- state = recordOfferCheckReceiptV2(state, ws(1, [
753
+ state = recordOfferCheckReceipt(state, ws(1, [
754
754
  'h1',
755
755
  'h2'
756
756
  ], [
@@ -768,7 +768,7 @@ state = recordOfferCheckReceiptV2(state, ws(1, [
768
768
  ]
769
769
  ]), receipt('check-1', 1, 'o1'), 'check-1', 'o1', versionFor('o1'), 0);
770
770
  assert.equal(state.hotels.h1?.freshOffersRequired, true);
771
- assert.equal(canIssueOfferCheckV2(state, ws(1, [
771
+ assert.equal(canIssueOfferCheck(state, ws(1, [
772
772
  'h1',
773
773
  'h2'
774
774
  ], [
@@ -781,7 +781,7 @@ assert.equal(canIssueOfferCheckV2(state, ws(1, [
781
781
  'h2'
782
782
  ]
783
783
  ]), 'b1', versionFor('b1')).ok, false);
784
- let q = recordOffersQueryIssuedV2(state, [
784
+ let q = recordOffersQueryIssued(state, [
785
785
  'h1'
786
786
  ], ws(1, [
787
787
  'h1',
@@ -796,7 +796,7 @@ let q = recordOffersQueryIssuedV2(state, [
796
796
  'h2'
797
797
  ]
798
798
  ]), 'q1', 'criteria-a');
799
- assert.throws(()=>recordOffersQueryIssuedV2(q, [
799
+ assert.throws(()=>recordOffersQueryIssued(q, [
800
800
  'h1'
801
801
  ], ws(1, [
802
802
  'h1',
@@ -840,7 +840,7 @@ const completeQueryReceipt = {
840
840
  loadedHotelCount: 1
841
841
  }
842
842
  };
843
- q = recordOffersQueryIssuedV2(q, [
843
+ q = recordOffersQueryIssued(q, [
844
844
  'h1'
845
845
  ], ws(2, [
846
846
  'h1',
@@ -873,7 +873,7 @@ q = foldQuery(q, [
873
873
  assert.deepEqual(q.hotels.h1?.currentOfferRefs, [
874
874
  'o2'
875
875
  ]);
876
- q = recordOfferCheckIssuedV2(q, ws(3, [
876
+ q = recordOfferCheckIssued(q, ws(3, [
877
877
  'h1',
878
878
  'h2'
879
879
  ], [
@@ -886,7 +886,7 @@ q = recordOfferCheckIssuedV2(q, ws(3, [
886
886
  'h2'
887
887
  ]
888
888
  ]), 'o2', versionFor('o2'), 'check-2');
889
- q = recordOfferCheckReceiptV2(q, ws(4, [
889
+ q = recordOfferCheckReceipt(q, ws(4, [
890
890
  'h1',
891
891
  'h2'
892
892
  ], [
@@ -904,7 +904,7 @@ assert.deepEqual(q.hotels.h1?.invalidatedOfferRefs, [
904
904
  ]);
905
905
  assert.equal(q.hotels.h1?.freshOffersRequired, false);
906
906
  assert.equal(q.terminal, undefined);
907
- assert.throws(()=>recordOffersQueryIssuedV2(q, [
907
+ assert.throws(()=>recordOffersQueryIssued(q, [
908
908
  'h1'
909
909
  ], ws(4, [
910
910
  'h1',
@@ -930,8 +930,8 @@ const fw = ws(0, [
930
930
  ], [
931
931
  'b:ratepkg-1'
932
932
  ]);
933
- let fallback = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(fw), fw, 'a:ratepkg-1', versionFor('a:ratepkg-1'), 'fa');
934
- fallback = recordOfferCheckReceiptV2(fallback, ws(1, [
933
+ let fallback = recordOfferCheckIssued(createAvailabilityPolicy(fw), fw, 'a:ratepkg-1', versionFor('a:ratepkg-1'), 'fa');
934
+ fallback = recordOfferCheckReceipt(fallback, ws(1, [
935
935
  'a',
936
936
  'b'
937
937
  ], [
@@ -947,7 +947,7 @@ fallback = recordOfferCheckReceiptV2(fallback, ws(1, [
947
947
  'b:ratepkg-1'
948
948
  ]), receipt('fa', 1, 'a:ratepkg-1'), 'fa', 'a:ratepkg-1', versionFor('a:ratepkg-1'), 0);
949
949
  assert.equal(fallback.hotels.a?.freshOffersRequired, true);
950
- fallback = recordOffersQueryIssuedV2(fallback, [
950
+ fallback = recordOffersQueryIssued(fallback, [
951
951
  'a'
952
952
  ], ws(1, [
953
953
  'a',
@@ -981,7 +981,7 @@ fallback = foldQuery(fallback, [
981
981
  ]
982
982
  ]), 'fq1', fallbackEmpty);
983
983
  assert.equal(fallback.activeHotelOrdinal, 1);
984
- assert.equal(canIssueOfferCheckV2(fallback, ws(2, [
984
+ assert.equal(canIssueOfferCheck(fallback, ws(2, [
985
985
  'a',
986
986
  'b'
987
987
  ], [
@@ -990,7 +990,7 @@ assert.equal(canIssueOfferCheckV2(fallback, ws(2, [
990
990
  'b'
991
991
  ]
992
992
  ]), 'b:ratepkg-1', versionFor('b:ratepkg-1')).ok, false);
993
- fallback = recordOffersQueryIssuedV2(fallback, [
993
+ fallback = recordOffersQueryIssued(fallback, [
994
994
  'b'
995
995
  ], ws(2, [
996
996
  'a',
@@ -1025,7 +1025,7 @@ fallback = foldQuery(fallback, [
1025
1025
  'b'
1026
1026
  ]
1027
1027
  ]), 'fq2', fallbackOffers);
1028
- assert.equal(canIssueOfferCheckV2(fallback, ws(3, [
1028
+ assert.equal(canIssueOfferCheck(fallback, ws(3, [
1029
1029
  'a',
1030
1030
  'b'
1031
1031
  ], [
@@ -1034,7 +1034,7 @@ assert.equal(canIssueOfferCheckV2(fallback, ws(3, [
1034
1034
  'b'
1035
1035
  ]
1036
1036
  ]), 'b:ratepkg-1', versionFor('b:ratepkg-1')).ok, true);
1037
- let exhausted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(ws(0, [
1037
+ let exhausted = recordOfferCheckIssued(createAvailabilityPolicy(ws(0, [
1038
1038
  'x'
1039
1039
  ], [
1040
1040
  [
@@ -1049,7 +1049,7 @@ let exhausted = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(ws(0, [
1049
1049
  'x'
1050
1050
  ]
1051
1051
  ]), 'x1', versionFor('x1'), 'ex1');
1052
- exhausted = recordOfferCheckReceiptV2(exhausted, ws(1, [
1052
+ exhausted = recordOfferCheckReceipt(exhausted, ws(1, [
1053
1053
  'x'
1054
1054
  ], [
1055
1055
  [
@@ -1059,7 +1059,7 @@ exhausted = recordOfferCheckReceiptV2(exhausted, ws(1, [
1059
1059
  ]), receipt('ex1', 1, 'x1'), 'ex1', 'x1', versionFor('x1'), 0);
1060
1060
  assert.equal(exhausted.terminal, undefined);
1061
1061
  assert.equal(exhausted.hotels.x?.freshOffersRequired, true);
1062
- exhausted = recordOffersQueryIssuedV2(exhausted, [
1062
+ exhausted = recordOffersQueryIssued(exhausted, [
1063
1063
  'x'
1064
1064
  ], ws(1, [
1065
1065
  'x'
@@ -1087,7 +1087,7 @@ exhausted = foldQuery(exhausted, [
1087
1087
  ], []), 'exq', exhaustedReceipt);
1088
1088
  assert.equal(exhausted.hotels.x?.generationNo, 2);
1089
1089
  assert.equal(exhausted.terminal?.code, 'availability_exhausted_complete');
1090
- assert.throws(()=>recordOfferCheckIssuedV2(exhausted, ws(2, [
1090
+ assert.throws(()=>recordOfferCheckIssued(exhausted, ws(2, [
1091
1091
  'x'
1092
1092
  ], []), 'x1', versionFor('x1'), 'after-terminal'), /availability_terminal/);
1093
1093
  {
@@ -1106,8 +1106,8 @@ assert.throws(()=>recordOfferCheckIssuedV2(exhausted, ws(2, [
1106
1106
  'candidate-a',
1107
1107
  'candidate-b'
1108
1108
  ]);
1109
- let candidateState = recordOfferCheckIssuedV2(createAvailabilityPolicyV2(candidateWorkspace), candidateWorkspace, 'candidate-a', versionFor('candidate-a'), 'candidate-a-check');
1110
- candidateState = recordOfferCheckReceiptV2(candidateState, ws(1, [
1109
+ let candidateState = recordOfferCheckIssued(createAvailabilityPolicy(candidateWorkspace), candidateWorkspace, 'candidate-a', versionFor('candidate-a'), 'candidate-a-check');
1110
+ candidateState = recordOfferCheckReceipt(candidateState, ws(1, [
1111
1111
  'candidate-hotel'
1112
1112
  ], [
1113
1113
  [
@@ -1143,12 +1143,12 @@ assert.throws(()=>recordOfferCheckIssuedV2(exhausted, ws(2, [
1143
1143
  'candidate-a',
1144
1144
  'candidate-b'
1145
1145
  ], 1);
1146
- candidateState = recordOffersQueryIssuedV2(candidateState, [
1146
+ candidateState = recordOffersQueryIssued(candidateState, [
1147
1147
  'candidate-hotel'
1148
1148
  ], queryWorkspace, 'candidate-query');
1149
- candidateState = recordOffersGenerationV2(candidateState, [
1149
+ candidateState = recordOffersGeneration(candidateState, [
1150
1150
  'candidate-hotel'
1151
- ], queryWorkspace, 'candidate-query', digestV2(candidateQueryReceipt), candidateQueryReceipt);
1151
+ ], queryWorkspace, 'candidate-query', digest(candidateQueryReceipt), candidateQueryReceipt);
1152
1152
  assert.equal(candidateState.hotels['candidate-hotel']?.currentOfferRefs.includes('candidate-a'), false, 'unavailable A@v1 is not re-admitted by a same-hotel candidate query');
1153
1153
  assert.deepEqual(candidateState.hotels['candidate-hotel']?.currentOfferRefs, [
1154
1154
  'candidate-b'
@@ -1164,10 +1164,10 @@ assert.throws(()=>recordOfferCheckIssuedV2(exhausted, ws(2, [
1164
1164
  ], [
1165
1165
  'candidate-b'
1166
1166
  ]);
1167
- assert.equal(canIssueOfferCheckV2(candidateState, bWorkspace, 'candidate-b', versionFor('candidate-b')).ok, true, 'B@v1 is recheckable after A@v1 unavailable');
1168
- candidateState = recordOfferCheckIssuedV2(candidateState, bWorkspace, 'candidate-b', versionFor('candidate-b'), 'candidate-b-check');
1167
+ assert.equal(canIssueOfferCheck(candidateState, bWorkspace, 'candidate-b', versionFor('candidate-b')).ok, true, 'B@v1 is recheckable after A@v1 unavailable');
1168
+ candidateState = recordOfferCheckIssued(candidateState, bWorkspace, 'candidate-b', versionFor('candidate-b'), 'candidate-b-check');
1169
1169
  const bVerified = verifiedCapability('candidate-b', versionFor('candidate-b'));
1170
- candidateState = recordOfferCheckReceiptV2(candidateState, ws(3, [
1170
+ candidateState = recordOfferCheckReceipt(candidateState, ws(3, [
1171
1171
  'candidate-hotel'
1172
1172
  ], [
1173
1173
  [
@@ -1178,17 +1178,17 @@ assert.throws(()=>recordOfferCheckIssuedV2(exhausted, ws(2, [
1178
1178
  'candidate-b'
1179
1179
  ], bVerified), receipt('candidate-b-check', 3, 'candidate-b', 'applied', true), 'candidate-b-check', 'candidate-b', versionFor('candidate-b'), 2);
1180
1180
  assert.equal(candidateState.terminal?.code, 'availability_confirmed', 'recheck of B@v1 can confirm after A@v1 unavailable');
1181
- }console.log('BOOKING COPILOT AVAILABILITY POLICY V2: admission, criteria CAS, stale no-generation, invalidation, cursor fallback, exhaustion, absorbing terminal OK');
1181
+ }console.log('BOOKING COPILOT AVAILABILITY POLICY: admission, criteria CAS, stale no-generation, invalidation, cursor fallback, exhaustion, absorbing terminal OK');
1182
1182
  const ledgerRoot = mkdtempSync(join(tmpdir(), 'gotry-availability-proof-'));
1183
1183
  const ledger = ensureLedger(ledgerRoot);
1184
- const runtime = new BookingCopilotTaskRuntimeV2(ledger, {
1184
+ const runtime = new BookingCopilotTaskRuntime(ledger, {
1185
1185
  contextRefFactory: ()=>'ctx-availability'
1186
1186
  });
1187
1187
  const runtimeWorkspace = ws(0, [
1188
1188
  'rh'
1189
1189
  ], []);
1190
1190
  runtime.startTask({
1191
- schemaVersion: 'booking.surface.v2',
1191
+ schemaVersion: 'booking.surface',
1192
1192
  kind: 'user.turn',
1193
1193
  taskId: 'runtime-availability',
1194
1194
  turnId: 'turn-1',
@@ -1198,7 +1198,7 @@ runtime.startTask({
1198
1198
  }
1199
1199
  });
1200
1200
  const query = {
1201
- schemaVersion: 'booking.surface.v2',
1201
+ schemaVersion: 'booking.surface',
1202
1202
  kind: 'offers.query',
1203
1203
  actionId: 'rq-1',
1204
1204
  contextRef: 'ctx-availability',
@@ -1214,7 +1214,7 @@ const query = {
1214
1214
  };
1215
1215
  runtime.issueOperation('runtime-availability', query);
1216
1216
  runtime.continueWithReceipt({
1217
- schemaVersion: 'booking.surface.v2',
1217
+ schemaVersion: 'booking.surface',
1218
1218
  kind: 'action.receipt.continuation',
1219
1219
  taskId: 'runtime-availability',
1220
1220
  workspace: ws(1, [
@@ -1226,7 +1226,7 @@ runtime.continueWithReceipt({
1226
1226
  ]
1227
1227
  ]),
1228
1228
  receipt: {
1229
- schemaVersion: 'booking.surface.v2',
1229
+ schemaVersion: 'booking.surface',
1230
1230
  kind: 'action.receipt',
1231
1231
  actionId: 'rq-1',
1232
1232
  contextRef: 'ctx-availability',
@@ -1253,7 +1253,7 @@ runtime.continueWithReceipt({
1253
1253
  }
1254
1254
  });
1255
1255
  const check = {
1256
- schemaVersion: 'booking.surface.v2',
1256
+ schemaVersion: 'booking.surface',
1257
1257
  kind: 'offer.check',
1258
1258
  actionId: 'rc-1',
1259
1259
  contextRef: 'ctx-availability',
@@ -1268,12 +1268,12 @@ const check = {
1268
1268
  runtime.issueOperation('runtime-availability', check);
1269
1269
  runtime.issueOperation('runtime-availability', check);
1270
1270
  assert.equal(runtime.resumeTask('runtime-availability')?.availability.attempts.length, 1);
1271
- const restarted = new BookingCopilotTaskRuntimeV2(ensureLedger(ledgerRoot), {
1271
+ const restarted = new BookingCopilotTaskRuntime(ensureLedger(ledgerRoot), {
1272
1272
  contextRefFactory: ()=>'ctx-availability'
1273
1273
  });
1274
1274
  assert.equal(restarted.resumeTask('runtime-availability')?.availability.attempts[0]?.actionId, 'rc-1');
1275
1275
  runtime.continueWithReceipt({
1276
- schemaVersion: 'booking.surface.v2',
1276
+ schemaVersion: 'booking.surface',
1277
1277
  kind: 'action.receipt.continuation',
1278
1278
  taskId: 'runtime-availability',
1279
1279
  workspace: ws(2, [
@@ -1296,14 +1296,14 @@ const query2 = {
1296
1296
  };
1297
1297
  runtime.issueOperation('runtime-availability', query2);
1298
1298
  runtime.continueWithReceipt({
1299
- schemaVersion: 'booking.surface.v2',
1299
+ schemaVersion: 'booking.surface',
1300
1300
  kind: 'action.receipt.continuation',
1301
1301
  taskId: 'runtime-availability',
1302
1302
  workspace: ws(3, [
1303
1303
  'rh'
1304
1304
  ], []),
1305
1305
  receipt: {
1306
- schemaVersion: 'booking.surface.v2',
1306
+ schemaVersion: 'booking.surface',
1307
1307
  kind: 'action.receipt',
1308
1308
  actionId: 'rq-2',
1309
1309
  contextRef: 'ctx-availability',
@@ -1329,7 +1329,7 @@ runtime.continueWithReceipt({
1329
1329
  });
1330
1330
  assert.equal(runtime.resumeTask('runtime-availability')?.phase, 'terminal');
1331
1331
  const eventCount = ledger.countEvents();
1332
- const terminalBatchPayload = ledger.db.prepare("SELECT payload FROM events WHERE kind = 'booking.copilot.v2.decision.batch' ORDER BY seq DESC LIMIT 1").get();
1332
+ const terminalBatchPayload = ledger.db.prepare("SELECT payload FROM events WHERE kind = 'booking.copilot.decision.batch' ORDER BY seq DESC LIMIT 1").get();
1333
1333
  const terminalBatch = JSON.parse(terminalBatchPayload.payload);
1334
1334
  assert.deepEqual(runtime.terminalDecisionBatch('runtime-availability', terminalBatch.requestKey), terminalBatch.events);
1335
1335
  assert.deepEqual(runtime.terminalDecisionBatch('runtime-availability', terminalBatch.requestKey), terminalBatch.events, 'exact terminal batch replay is read-only');
@@ -1352,4 +1352,4 @@ rmSync(ledgerRoot, {
1352
1352
  });
1353
1353
 
1354
1354
 
1355
- //# sourceURL=ts/scripts/booking-copilot-availability-policy-v2-tests.ts
1355
+ //# sourceURL=ts/scripts/booking-copilot-availability-policy-tests.ts