@danceiny/gotry 0.0.1-rc.16 → 0.0.1-rc.17
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.
- package/README.md +47 -13
- package/README.zh-CN.md +20 -10
- package/bin/gotry-booking-copilot.js +53 -0
- package/bin/gotry-bootstrap.js +111 -51
- package/bin/gotry-inner.js +442 -60
- package/bin/gotry-runtime-resolution.d.ts +27 -0
- package/bin/gotry-runtime-resolution.js +50 -0
- package/bin/gotry.js +1 -1
- package/cordis.gotry-patch.yml +5 -1
- package/dist/capabilities/agent-reach-deep.js +1 -1
- package/dist/capabilities/agent-reach.js +1 -1
- package/dist/capabilities/anything.js +1 -1
- package/dist/capabilities/artifacts.js +1 -1
- package/dist/capabilities/effect.js +1 -1
- package/dist/capabilities/fact-log.js +1 -1
- package/dist/capabilities/flyai.js +20 -6
- package/dist/capabilities/hbcli.js +1 -1
- package/dist/capabilities/incident-log.js +1 -1
- package/dist/capabilities/model-override.js +18 -0
- package/dist/capabilities/opensky.js +1 -1
- package/dist/capabilities/resilience.js +1 -1
- package/dist/capabilities/session/action-cache.js +1 -1
- package/dist/capabilities/session/adapters/ctrip-flight.js +1 -1
- package/dist/capabilities/session/adapters/meituan-local.js +1 -1
- package/dist/capabilities/session/benchmark.js +1 -1
- package/dist/capabilities/session/extension-bridge.js +19 -6
- package/dist/capabilities/session/extension-channel.js +3 -3
- package/dist/capabilities/session/extension-distribution.js +234 -0
- package/dist/capabilities/session/extract.js +1 -1
- package/dist/capabilities/session/golden-score.js +92 -0
- package/dist/capabilities/session/health-watch.js +1 -1
- package/dist/capabilities/session/read-guard.js +1 -1
- package/dist/capabilities/session/static-flight-golden.js +137 -0
- package/dist/capabilities/session/transport.js +1 -1
- package/dist/capabilities/session/wizard.js +21 -251
- package/dist/capabilities/session-consent.js +1 -1
- package/dist/capabilities/session-login.js +11 -5
- package/dist/capabilities/session-search.js +46 -4
- package/dist/capabilities/weather.js +168 -46
- package/dist/data/session-golden-20.json +25 -0
- package/dist/data/sf-golden-manifest.json +102 -0
- package/dist/data/sf-static-routes.json +91 -0
- package/dist/scripts/action-cache-tests.js +1 -1
- package/dist/scripts/agent-planning-budget-e2e.js +227 -0
- package/dist/scripts/agent-planning-budget-tests.js +173 -0
- package/dist/scripts/agent-reach-deep-tests.js +1 -1
- package/dist/scripts/agent-reach-tests.js +1 -1
- package/dist/scripts/agent-reach-wrapper-tests.js +1 -1
- package/dist/scripts/anything-tests.js +1 -1
- package/dist/scripts/async-collect.js +1 -1
- package/dist/scripts/benchmark-environment-bridge-e2e.js +981 -0
- package/dist/scripts/benchmark-environment-bridge-tests.js +2544 -0
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +335 -0
- package/dist/scripts/booking-copilot-availability-policy-v2-tests.js +1355 -0
- package/dist/scripts/booking-copilot-bin-proof-tests.js +89 -0
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +113 -0
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +356 -0
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +557 -0
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +140 -0
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +202 -0
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +102 -0
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +374 -0
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +447 -0
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +205 -0
- package/dist/scripts/booking-copilot-server-proof-tests.js +317 -0
- package/dist/scripts/booking-copilot-startup-proof-tests.js +283 -0
- package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +3935 -0
- package/dist/scripts/booking-saga-tests.js +1 -1
- package/dist/scripts/booking-surface-contract-proof-tests.js +393 -0
- package/dist/scripts/booking-surface-v2-contract-proof-tests.js +1174 -0
- package/dist/scripts/bootstrap-tests.js +30 -10
- package/dist/scripts/build-changelog.js +1 -1
- package/dist/scripts/changelog-tests.js +1 -1
- package/dist/scripts/companion-tests.js +1 -1
- package/dist/scripts/diff-test.js +1 -1
- package/dist/scripts/dsh-runtime-closure-tests.js +225 -0
- package/dist/scripts/dsh-runtime-closure.js +150 -0
- package/dist/scripts/effect-tests.js +1 -1
- package/dist/scripts/engine-run.js +1 -1
- package/dist/scripts/engine-tests.js +1 -1
- package/dist/scripts/evaluation-cadence-tests.js +347 -0
- package/dist/scripts/evaluation-contract-tests.js +574 -0
- package/dist/scripts/extension-distribution-cli.js +35 -0
- package/dist/scripts/extension-distribution-tests.js +341 -0
- package/dist/scripts/extension-tests.js +128 -23
- package/dist/scripts/fact-gate-tests.js +1 -1
- package/dist/scripts/flyai-tests.js +1 -1
- package/dist/scripts/hbcli-e2e-tests.js +1 -1
- package/dist/scripts/hbcli-tests.js +1 -1
- package/dist/scripts/health-watch-cli.js +1 -1
- package/dist/scripts/i18n-tests.js +1 -1
- package/dist/scripts/incident-tests.js +1 -1
- package/dist/scripts/journey-tests.js +1 -1
- package/dist/scripts/ledger-tests.js +1 -1
- package/dist/scripts/ledger-workflow-crash.js +1 -1
- package/dist/scripts/memory-capture-tests.js +1 -1
- package/dist/scripts/memory-decay-tests.js +1 -1
- package/dist/scripts/memory-metrics.js +1 -1
- package/dist/scripts/memory-value-report.js +1 -1
- package/dist/scripts/model-override-e2e.js +176 -0
- package/dist/scripts/nightly-evidence-tests.js +1 -1
- package/dist/scripts/nightly-evidence.js +1 -1
- package/dist/scripts/nudge-digest.js +1 -1
- package/dist/scripts/onboarding-tests.js +21 -53
- package/dist/scripts/opensky-check.js +1 -1
- package/dist/scripts/opensky-tests.js +1 -1
- package/dist/scripts/pnpm-dsh-closure-proof.js +20 -0
- package/dist/scripts/price-drift-tests.js +1 -1
- package/dist/scripts/price-drift-watch.js +1 -1
- package/dist/scripts/probe-poi-tests.js +1 -1
- package/dist/scripts/product-metrics.js +1 -1
- package/dist/scripts/publish-preverify.js +40 -4
- package/dist/scripts/realtime-pricing-tests.js +1 -1
- package/dist/scripts/replay-async.js +1 -1
- package/dist/scripts/replay-real.js +1 -1
- package/dist/scripts/replay.js +1 -1
- package/dist/scripts/session-attach-diagnose.js +1 -1
- package/dist/scripts/session-attach-poc.js +1 -1
- package/dist/scripts/session-benchmark.js +1 -1
- package/dist/scripts/session-extract-tests.js +1 -1
- package/dist/scripts/session-login.js +1 -1
- package/dist/scripts/session-tests.js +70 -20
- package/dist/scripts/sf-live-benchmark.js +338 -0
- package/dist/scripts/sf-live-cli-tests.js +21 -0
- package/dist/scripts/sf-soft-score-tests.js +108 -0
- package/dist/scripts/sf-summary.js +93 -0
- package/dist/scripts/skeleton-check.js +1 -1
- package/dist/scripts/skeleton-integration-test.js +1 -1
- package/dist/scripts/skills-contract-tests.js +1 -1
- package/dist/scripts/smoke-session-gate-tests.js +29 -0
- package/dist/scripts/smoke.js +79 -33
- package/dist/scripts/state-cli-tests.js +1 -1
- package/dist/scripts/state-cli.js +1 -1
- package/dist/scripts/static-golden-tests.js +299 -0
- package/dist/scripts/time-eval-tests.js +1 -1
- package/dist/scripts/travel-timeline-tests.js +1 -1
- package/dist/scripts/unified-tests.js +1 -1
- package/dist/scripts/weather-tests.js +694 -44
- package/dist/scripts/z3-race-tests.js +1 -1
- package/dist/src/artifact-gate.js +1 -1
- package/dist/src/benchmark-agent-conformance.js +370 -0
- package/dist/src/benchmark-environment-bridge.js +384 -0
- package/dist/src/benchmark-headless-child-diagnostics.js +173 -0
- package/dist/src/benchmark-tool-isolation.js +124 -0
- package/dist/src/bookable-facts.js +1 -1
- package/dist/src/booking-saga.js +1 -1
- package/dist/src/booking-surface/availability-policy-v2.js +830 -0
- package/dist/src/booking-surface/canonical-schema.js +113 -0
- package/dist/src/booking-surface/contracts-v2.js +89 -0
- package/dist/src/booking-surface/contracts.js +46 -0
- package/dist/src/booking-surface/dsh-planner.js +453 -0
- package/dist/src/booking-surface/dsh-plugin.js +93 -0
- package/dist/src/booking-surface/error-codes.js +94 -0
- package/dist/src/booking-surface/index.js +15 -0
- package/dist/src/booking-surface/profile.js +68 -0
- package/dist/src/booking-surface/runtime-v2.js +1771 -0
- package/dist/src/booking-surface/runtime.js +351 -0
- package/dist/src/booking-surface/server-v2.js +334 -0
- package/dist/src/booking-surface/server.js +302 -0
- package/dist/src/booking-surface/startup.js +159 -0
- package/dist/src/booking-surface/validation-v2.js +319 -0
- package/dist/src/booking-surface/validation.js +809 -0
- package/dist/src/bridge.js +1 -1
- package/dist/src/companions.js +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/dsh-llm.js +1 -1
- package/dist/src/engine.js +1 -1
- package/dist/src/evaluation-cadence.js +234 -0
- package/dist/src/evaluation-contracts.js +906 -0
- package/dist/src/i18n.js +1 -1
- package/dist/src/index.js +50 -19
- package/dist/src/journey.js +1 -1
- package/dist/src/loop.js +1 -1
- package/dist/src/memory-capture.js +1 -1
- package/dist/src/memory-decay.js +1 -1
- package/dist/src/memory-utility.js +1 -1
- package/dist/src/mock-llm.js +1 -1
- package/dist/src/model.js +1 -1
- package/dist/src/realtime-pricing.js +1 -1
- package/dist/src/slot-spec.js +1 -1
- package/dist/src/state-ledger.js +2 -1
- package/dist/src/time-anchor.js +1 -1
- package/dist/src/tool-budget.js +136 -0
- package/dist/src/tool-packet.js +1 -1
- package/dist/src/travel-slots.js +1 -1
- package/dist/src/travel-timeline.js +1 -1
- package/dist/src/unified.js +1 -1
- package/dist/src/wish-pool.js +1 -1
- package/dist/src/z3-shared.js +1 -1
- package/extension/README.md +31 -7
- package/package.json +286 -11
- package/schemas/booking.surface.v1.schema.json +927 -0
- package/schemas/booking.surface.v2.schema.json +61 -0
- package/ts/capabilities/flyai.ts +16 -3
- package/ts/capabilities/session/extension-bridge.ts +37 -14
- package/ts/capabilities/session/extension-channel.ts +6 -3
- package/ts/capabilities/session/extension-distribution.ts +264 -0
- package/ts/capabilities/session/golden-score.ts +139 -0
- package/ts/capabilities/session/health-watch.ts +1 -1
- package/ts/capabilities/session/static-flight-golden.ts +209 -0
- package/ts/capabilities/session/wizard.ts +34 -176
- package/ts/capabilities/session-login.ts +15 -5
- package/ts/capabilities/session-search.ts +40 -3
- package/ts/capabilities/weather.ts +141 -52
- package/ts/package.json +3 -3
- package/ts/src/benchmark-agent-conformance.ts +448 -0
- package/ts/src/benchmark-environment-bridge.ts +348 -0
- package/ts/src/benchmark-headless-child-diagnostics.ts +184 -0
- package/ts/src/benchmark-tool-isolation.ts +166 -0
- package/ts/src/booking-surface/availability-policy-v2.ts +523 -0
- package/ts/src/booking-surface/canonical-schema.js +113 -0
- package/ts/src/booking-surface/contracts-v2.ts +118 -0
- package/ts/src/booking-surface/contracts.ts +380 -0
- package/ts/src/booking-surface/dsh-planner.ts +452 -0
- package/ts/src/booking-surface/dsh-plugin.js +93 -0
- package/ts/src/booking-surface/error-codes.ts +101 -0
- package/ts/src/booking-surface/index.ts +12 -0
- package/ts/src/booking-surface/profile.ts +42 -0
- package/ts/src/booking-surface/runtime-v2.ts +1466 -0
- package/ts/src/booking-surface/runtime.ts +483 -0
- package/ts/src/booking-surface/server-v2.ts +247 -0
- package/ts/src/booking-surface/server.ts +324 -0
- package/ts/src/booking-surface/startup.ts +196 -0
- package/ts/src/booking-surface/validation-v2.ts +205 -0
- package/ts/src/booking-surface/validation.ts +453 -0
- package/ts/src/index.ts +64 -11
- package/ts/src/state-ledger.ts +1 -0
- package/ts/src/tool-budget.ts +165 -0
- package/dist/scripts/wizard-bootstrap.js +0 -32
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { ensureLedger } from '../src/state-ledger.js';
|
|
6
|
+
import { BookingCopilotTaskRuntimeV2, bookingV2Digest } from '../src/booking-surface/runtime-v2.js';
|
|
7
|
+
const workspace = (revision)=>({
|
|
8
|
+
schemaVersion: 'booking.surface.v2',
|
|
9
|
+
contextRef: 'ctx-ledger-binding',
|
|
10
|
+
surface: 'tenant',
|
|
11
|
+
revision,
|
|
12
|
+
locale: 'en-US',
|
|
13
|
+
currency: 'AED',
|
|
14
|
+
searchDraft: {},
|
|
15
|
+
results: {
|
|
16
|
+
status: 'idle'
|
|
17
|
+
},
|
|
18
|
+
visibleHotels: [
|
|
19
|
+
{
|
|
20
|
+
hotelRef: 'h1',
|
|
21
|
+
name: 'H1',
|
|
22
|
+
factRefs: []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
hotelRef: 'h2',
|
|
26
|
+
name: 'H2',
|
|
27
|
+
factRefs: []
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
loadedOffers: [
|
|
31
|
+
{
|
|
32
|
+
offerRef: 'o1',
|
|
33
|
+
offerVersionRef: 'o1:v1',
|
|
34
|
+
hotelRef: 'h1',
|
|
35
|
+
evidenceLevel: 'rate_loaded',
|
|
36
|
+
factRefs: []
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
offerRef: 'o2',
|
|
40
|
+
offerVersionRef: 'o2:v1',
|
|
41
|
+
hotelRef: 'h2',
|
|
42
|
+
evidenceLevel: 'rate_loaded',
|
|
43
|
+
factRefs: []
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
shortlistedOfferRefs: [
|
|
47
|
+
'o1',
|
|
48
|
+
'o2'
|
|
49
|
+
],
|
|
50
|
+
capabilities: {
|
|
51
|
+
surface: 'tenant',
|
|
52
|
+
allowedActions: [
|
|
53
|
+
'offers.query',
|
|
54
|
+
'offer.check'
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const offersReceipt = (actionId, revision)=>({
|
|
59
|
+
schemaVersion: 'booking.surface.v2',
|
|
60
|
+
kind: 'action.receipt',
|
|
61
|
+
actionId,
|
|
62
|
+
contextRef: 'ctx-ledger-binding',
|
|
63
|
+
status: 'applied',
|
|
64
|
+
revision,
|
|
65
|
+
observation: {
|
|
66
|
+
kind: 'offers.state',
|
|
67
|
+
hotelRefs: [
|
|
68
|
+
'h1'
|
|
69
|
+
],
|
|
70
|
+
offerRefs: [
|
|
71
|
+
'o1'
|
|
72
|
+
],
|
|
73
|
+
loadedHotelCount: 1
|
|
74
|
+
},
|
|
75
|
+
resultContract: {
|
|
76
|
+
outcome: 'complete',
|
|
77
|
+
hardCriteriaMet: true,
|
|
78
|
+
factRefs: [],
|
|
79
|
+
gapCodes: [],
|
|
80
|
+
blockers: [],
|
|
81
|
+
relaxationsApplied: []
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const checkReceipt = (actionId, revision)=>({
|
|
85
|
+
schemaVersion: 'booking.surface.v2',
|
|
86
|
+
kind: 'action.receipt',
|
|
87
|
+
actionId,
|
|
88
|
+
contextRef: 'ctx-ledger-binding',
|
|
89
|
+
status: 'unavailable',
|
|
90
|
+
revision,
|
|
91
|
+
observation: {
|
|
92
|
+
kind: 'offer.availability',
|
|
93
|
+
offerRef: 'o1',
|
|
94
|
+
checkedOfferVersionRef: 'o1:v1',
|
|
95
|
+
available: false,
|
|
96
|
+
changedFactRefs: [],
|
|
97
|
+
gapCodes: []
|
|
98
|
+
},
|
|
99
|
+
resultContract: {
|
|
100
|
+
outcome: 'empty',
|
|
101
|
+
hardCriteriaMet: false,
|
|
102
|
+
factRefs: [],
|
|
103
|
+
gapCodes: [],
|
|
104
|
+
blockers: [],
|
|
105
|
+
relaxationsApplied: []
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
function fixture(stage) {
|
|
109
|
+
const root = mkdtempSync(join(tmpdir(), 'gotry-availability-ledger-binding-'));
|
|
110
|
+
const ledger = ensureLedger(root);
|
|
111
|
+
const runtime = new BookingCopilotTaskRuntimeV2(ledger, {
|
|
112
|
+
contextRefFactory: ()=>'ctx-ledger-binding'
|
|
113
|
+
});
|
|
114
|
+
const task = 'ledger-binding-task';
|
|
115
|
+
runtime.startTask({
|
|
116
|
+
schemaVersion: 'booking.surface.v2',
|
|
117
|
+
kind: 'user.turn',
|
|
118
|
+
taskId: task,
|
|
119
|
+
turnId: 'turn-1',
|
|
120
|
+
workspace: workspace(0),
|
|
121
|
+
request: {
|
|
122
|
+
text: 'find rates'
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const query = {
|
|
126
|
+
schemaVersion: 'booking.surface.v2',
|
|
127
|
+
kind: 'offers.query',
|
|
128
|
+
actionId: 'query-1',
|
|
129
|
+
contextRef: 'ctx-ledger-binding',
|
|
130
|
+
expectedRevision: 0,
|
|
131
|
+
reason: 'load offers',
|
|
132
|
+
factRefs: [],
|
|
133
|
+
input: {
|
|
134
|
+
hotelRefs: [
|
|
135
|
+
'h1'
|
|
136
|
+
],
|
|
137
|
+
criteria: {}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
runtime.issueOperation(task, query);
|
|
141
|
+
runtime.continueWithReceipt({
|
|
142
|
+
schemaVersion: 'booking.surface.v2',
|
|
143
|
+
kind: 'action.receipt.continuation',
|
|
144
|
+
taskId: task,
|
|
145
|
+
workspace: workspace(1),
|
|
146
|
+
receipt: offersReceipt('query-1', 1)
|
|
147
|
+
});
|
|
148
|
+
const check = {
|
|
149
|
+
schemaVersion: 'booking.surface.v2',
|
|
150
|
+
kind: 'offer.check',
|
|
151
|
+
actionId: 'check-1',
|
|
152
|
+
contextRef: 'ctx-ledger-binding',
|
|
153
|
+
expectedRevision: 1,
|
|
154
|
+
reason: 'check',
|
|
155
|
+
factRefs: [],
|
|
156
|
+
input: {
|
|
157
|
+
offerRef: 'o1',
|
|
158
|
+
offerVersionRef: 'o1:v1'
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
runtime.issueOperation(task, check);
|
|
162
|
+
if (stage === 'receipt') runtime.continueWithReceipt({
|
|
163
|
+
schemaVersion: 'booking.surface.v2',
|
|
164
|
+
kind: 'action.receipt.continuation',
|
|
165
|
+
taskId: task,
|
|
166
|
+
workspace: {
|
|
167
|
+
...workspace(2),
|
|
168
|
+
shortlistedOfferRefs: [
|
|
169
|
+
'o2'
|
|
170
|
+
],
|
|
171
|
+
selectedOfferRef: undefined,
|
|
172
|
+
verifiedOffer: undefined
|
|
173
|
+
},
|
|
174
|
+
receipt: checkReceipt('check-1', 2)
|
|
175
|
+
});
|
|
176
|
+
ledger.close();
|
|
177
|
+
return {
|
|
178
|
+
root,
|
|
179
|
+
ledger,
|
|
180
|
+
task
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function rewrite(root, kind, mutate) {
|
|
184
|
+
const ledger = ensureLedger(root);
|
|
185
|
+
const row = ledger.db.prepare('SELECT seq, payload FROM events WHERE run_id = ? AND kind = ? ORDER BY seq DESC LIMIT 1').get('ledger-binding-task', kind);
|
|
186
|
+
assert.ok(row);
|
|
187
|
+
const payload = JSON.parse(row.payload);
|
|
188
|
+
mutate(payload);
|
|
189
|
+
ledger.db.prepare('UPDATE events SET payload = ? WHERE seq = ?').run(JSON.stringify(payload), row.seq);
|
|
190
|
+
ledger.close();
|
|
191
|
+
}
|
|
192
|
+
function assertCorrupt(root, label) {
|
|
193
|
+
const ledger = ensureLedger(root);
|
|
194
|
+
const runtime = new BookingCopilotTaskRuntimeV2(ledger, {
|
|
195
|
+
contextRefFactory: ()=>'ctx-ledger-binding'
|
|
196
|
+
});
|
|
197
|
+
assert.throws(()=>runtime.resumeTask('ledger-binding-task'), /ledger_corrupt:ledger-binding-task/, label);
|
|
198
|
+
ledger.close();
|
|
199
|
+
}
|
|
200
|
+
{
|
|
201
|
+
const fixtureState = fixture('action');
|
|
202
|
+
const ledger = ensureLedger(fixtureState.root);
|
|
203
|
+
assert.doesNotThrow(()=>new BookingCopilotTaskRuntimeV2(ledger).resumeTask(fixtureState.task));
|
|
204
|
+
ledger.close();
|
|
205
|
+
rmSync(fixtureState.root, {
|
|
206
|
+
recursive: true,
|
|
207
|
+
force: true
|
|
208
|
+
});
|
|
209
|
+
}for (const [label, mutate] of [
|
|
210
|
+
[
|
|
211
|
+
'candidate digest',
|
|
212
|
+
(payload)=>{
|
|
213
|
+
payload.availability.candidateSetDigest = 'f'.repeat(64);
|
|
214
|
+
payload.availabilityDigest = bookingV2Digest(payload.availability);
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
[
|
|
218
|
+
'offer set digest',
|
|
219
|
+
(payload)=>{
|
|
220
|
+
payload.availability.hotels.h1.currentGeneration.offerSetDigest = 'e'.repeat(64);
|
|
221
|
+
payload.availabilityDigest = bookingV2Digest(payload.availability);
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
[
|
|
225
|
+
'source receipt digest',
|
|
226
|
+
(payload)=>{
|
|
227
|
+
payload.availability.hotels.h1.currentGeneration.source.receiptDigest = 'd'.repeat(64);
|
|
228
|
+
payload.availabilityDigest = bookingV2Digest(payload.availability);
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
[
|
|
232
|
+
'active ordinal',
|
|
233
|
+
(payload)=>{
|
|
234
|
+
payload.availability.activeHotelOrdinal = 1;
|
|
235
|
+
payload.availabilityDigest = bookingV2Digest(payload.availability);
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
[
|
|
239
|
+
'fake terminal',
|
|
240
|
+
(payload)=>{
|
|
241
|
+
payload.availability.terminal = {
|
|
242
|
+
code: 'availability_confirmed',
|
|
243
|
+
hotelRefs: [
|
|
244
|
+
'h1',
|
|
245
|
+
'h2'
|
|
246
|
+
],
|
|
247
|
+
reason: 'confirmed',
|
|
248
|
+
evidence: 'conclusive'
|
|
249
|
+
};
|
|
250
|
+
payload.availability.availabilityPhase = 'terminal';
|
|
251
|
+
payload.availabilityDigest = bookingV2Digest(payload.availability);
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
]){
|
|
255
|
+
const fixtureState = fixture('action');
|
|
256
|
+
rewrite(fixtureState.root, 'booking.copilot.v2.action.issued', mutate);
|
|
257
|
+
assertCorrupt(fixtureState.root, label);
|
|
258
|
+
rmSync(fixtureState.root, {
|
|
259
|
+
recursive: true,
|
|
260
|
+
force: true
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
{
|
|
264
|
+
const fixtureState = fixture('action');
|
|
265
|
+
rewrite(fixtureState.root, 'booking.copilot.v2.action.issued', (payload)=>{
|
|
266
|
+
payload.availability.activeHotelOrdinal = 1;
|
|
267
|
+
});
|
|
268
|
+
assertCorrupt(fixtureState.root, 'raw ACTION availability digest mismatch');
|
|
269
|
+
rmSync(fixtureState.root, {
|
|
270
|
+
recursive: true,
|
|
271
|
+
force: true
|
|
272
|
+
});
|
|
273
|
+
}{
|
|
274
|
+
const fixtureState = fixture('receipt');
|
|
275
|
+
rewrite(fixtureState.root, 'booking.copilot.v2.receipt.observed', (payload)=>{
|
|
276
|
+
payload.availability.activeHotelOrdinal = 1;
|
|
277
|
+
});
|
|
278
|
+
assertCorrupt(fixtureState.root, 'raw RECEIPT availability digest mismatch');
|
|
279
|
+
rmSync(fixtureState.root, {
|
|
280
|
+
recursive: true,
|
|
281
|
+
force: true
|
|
282
|
+
});
|
|
283
|
+
}{
|
|
284
|
+
const fixtureState = fixture('action');
|
|
285
|
+
rewrite(fixtureState.root, 'booking.copilot.v2.action.issued', (payload)=>{
|
|
286
|
+
payload.action.input.offerRef = 'o2';
|
|
287
|
+
const { actionDigest: _ignored, ...base } = payload.action;
|
|
288
|
+
payload.action.actionDigest = bookingV2Digest(base);
|
|
289
|
+
});
|
|
290
|
+
assertCorrupt(fixtureState.root, 'wrong action transition');
|
|
291
|
+
rmSync(fixtureState.root, {
|
|
292
|
+
recursive: true,
|
|
293
|
+
force: true
|
|
294
|
+
});
|
|
295
|
+
}{
|
|
296
|
+
const fixtureState = fixture('receipt');
|
|
297
|
+
const runtimeLedger = ensureLedger(fixtureState.root);
|
|
298
|
+
const runtime = new BookingCopilotTaskRuntimeV2(runtimeLedger);
|
|
299
|
+
assert.deepEqual(runtime.resumeTask(fixtureState.task)?.availability.criteria, {}, 'recovery retains the canonical offer criteria after restart');
|
|
300
|
+
const wrongDetour = {
|
|
301
|
+
schemaVersion: 'booking.surface.v2',
|
|
302
|
+
kind: 'search.run',
|
|
303
|
+
actionId: 'detour',
|
|
304
|
+
contextRef: 'ctx-ledger-binding',
|
|
305
|
+
expectedRevision: 2,
|
|
306
|
+
reason: 'detour',
|
|
307
|
+
factRefs: [],
|
|
308
|
+
input: {}
|
|
309
|
+
};
|
|
310
|
+
assert.throws(()=>runtime.applyDecisionBatch(fixtureState.task, 'detour-batch', [
|
|
311
|
+
{
|
|
312
|
+
kind: 'operation',
|
|
313
|
+
action: wrongDetour
|
|
314
|
+
}
|
|
315
|
+
]), /availability_operation_incompatible/);
|
|
316
|
+
runtimeLedger.close();
|
|
317
|
+
rmSync(fixtureState.root, {
|
|
318
|
+
recursive: true,
|
|
319
|
+
force: true
|
|
320
|
+
});
|
|
321
|
+
}{
|
|
322
|
+
const fixtureState = fixture('receipt');
|
|
323
|
+
rewrite(fixtureState.root, 'booking.copilot.v2.receipt.observed', (payload)=>{
|
|
324
|
+
payload.receipt.status = 'applied';
|
|
325
|
+
payload.receiptDigest = bookingV2Digest(payload.receipt);
|
|
326
|
+
});
|
|
327
|
+
assertCorrupt(fixtureState.root, 'wrong receipt transition');
|
|
328
|
+
rmSync(fixtureState.root, {
|
|
329
|
+
recursive: true,
|
|
330
|
+
force: true
|
|
331
|
+
});
|
|
332
|
+
}console.log('BOOKING COPILOT AVAILABILITY LEDGER BINDING: exact replay and candidate/generation/source/ordinal/terminal/action/receipt tamper rejection OK');
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
//# sourceURL=ts/scripts/booking-copilot-availability-ledger-binding-tests.ts
|