@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,393 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { BOOKING_READ_ACTION_KINDS, BOOKING_RECEIPT_STATUSES, BOOKING_SURFACE_EVENT_KINDS, BOOKING_SURFACE_SCHEMA_SHA256, EMBEDDED_BOOKING_CAPABILITY_IDS, bookingOperationFromEvent, embeddedBookingProfile, validateActionReceiptV1, validateBookingCopilotIngressTurnV1, validateBookingCopilotTurnV1, validateBookingReadActionV1, validateBookingSurfaceEventV1 } from '../src/booking-surface/index.js';
|
|
6
|
+
const schemaPath = fileURLToPath(new URL('../../schemas/booking.surface.v1.schema.json', import.meta.url));
|
|
7
|
+
const schema = JSON.parse(readFileSync(schemaPath, 'utf8'));
|
|
8
|
+
const schemaBytes = readFileSync(schemaPath);
|
|
9
|
+
assert.equal(createHash('sha256').update(schemaBytes).digest('hex'), BOOKING_SURFACE_SCHEMA_SHA256, 'exported schema hash matches canonical bytes');
|
|
10
|
+
assert.equal(schema.$id, 'https://gotry.dev/schemas/booking.surface.v1.schema.json');
|
|
11
|
+
assert.ok(schema.$defs?.BookingReadActionV1, 'canonical schema declares BookingReadActionV1');
|
|
12
|
+
assert.ok(schema.$defs?.ActionReceiptV1, 'canonical schema declares ActionReceiptV1');
|
|
13
|
+
assert.ok(schema.$defs?.BookingSurfaceEventV1, 'canonical schema declares typed SSE data events');
|
|
14
|
+
assert.deepEqual(BOOKING_READ_ACTION_KINDS, [
|
|
15
|
+
'search.patch',
|
|
16
|
+
'search.run',
|
|
17
|
+
'results.view.patch',
|
|
18
|
+
'hotel.focus',
|
|
19
|
+
'hotel.select',
|
|
20
|
+
'offers.query',
|
|
21
|
+
'offers.view.patch',
|
|
22
|
+
'offers.compare',
|
|
23
|
+
'offer.select',
|
|
24
|
+
'offer.check',
|
|
25
|
+
'checkout.prepare',
|
|
26
|
+
'order.observe'
|
|
27
|
+
]);
|
|
28
|
+
assert.deepEqual(BOOKING_RECEIPT_STATUSES, [
|
|
29
|
+
'applied',
|
|
30
|
+
'needs_input',
|
|
31
|
+
'partial',
|
|
32
|
+
'no_match',
|
|
33
|
+
'unavailable',
|
|
34
|
+
'changed',
|
|
35
|
+
'stale',
|
|
36
|
+
'unsupported',
|
|
37
|
+
'failed'
|
|
38
|
+
]);
|
|
39
|
+
assert.deepEqual(BOOKING_SURFACE_EVENT_KINDS, [
|
|
40
|
+
'status',
|
|
41
|
+
'question',
|
|
42
|
+
'operation',
|
|
43
|
+
'explanation',
|
|
44
|
+
'terminal',
|
|
45
|
+
'error'
|
|
46
|
+
]);
|
|
47
|
+
assert.deepEqual(EMBEDDED_BOOKING_CAPABILITY_IDS, [
|
|
48
|
+
'search-hotels',
|
|
49
|
+
'refine-results',
|
|
50
|
+
'find-room-offers',
|
|
51
|
+
'compare-offers',
|
|
52
|
+
'prepare-booking',
|
|
53
|
+
'observe-booking'
|
|
54
|
+
]);
|
|
55
|
+
const registeredActions = embeddedBookingProfile.capabilities.flatMap((capability)=>capability.actions);
|
|
56
|
+
assert.deepEqual([
|
|
57
|
+
...new Set(registeredActions)
|
|
58
|
+
].sort(), [
|
|
59
|
+
...BOOKING_READ_ACTION_KINDS
|
|
60
|
+
].sort(), 'profile registers the full read-action closure exactly once');
|
|
61
|
+
const forbiddenWriteActions = new Set([
|
|
62
|
+
'book',
|
|
63
|
+
'trade.book',
|
|
64
|
+
'gotry_book'
|
|
65
|
+
]);
|
|
66
|
+
assert.ok(!registeredActions.some((action)=>forbiddenWriteActions.has(action)), 'embedded profile exposes no Book action');
|
|
67
|
+
assert.ok(embeddedBookingProfile.capabilities.every((capability)=>capability.effect === 'read'), 'all embedded capabilities are read-side effects');
|
|
68
|
+
const ingressWorkspace = {
|
|
69
|
+
schemaVersion: 'booking.surface.v1',
|
|
70
|
+
revision: 0,
|
|
71
|
+
locale: 'zh-CN',
|
|
72
|
+
currency: 'AED',
|
|
73
|
+
searchDraft: {},
|
|
74
|
+
results: {
|
|
75
|
+
status: 'idle'
|
|
76
|
+
},
|
|
77
|
+
visibleHotels: [],
|
|
78
|
+
loadedOffers: [],
|
|
79
|
+
shortlistedOfferRefs: []
|
|
80
|
+
};
|
|
81
|
+
const ingress = {
|
|
82
|
+
schemaVersion: 'booking.surface.v1',
|
|
83
|
+
kind: 'user.turn.ingress',
|
|
84
|
+
surfaceHint: 'tenant',
|
|
85
|
+
workspace: ingressWorkspace,
|
|
86
|
+
request: {
|
|
87
|
+
text: '迪拜五星、含早可退,给我 3 个报价'
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
assert.deepEqual(validateBookingCopilotIngressTurnV1(ingress), {
|
|
91
|
+
ok: true
|
|
92
|
+
});
|
|
93
|
+
assert.equal(validateBookingCopilotIngressTurnV1({
|
|
94
|
+
...ingress,
|
|
95
|
+
actor: 'user-1'
|
|
96
|
+
}).ok, false, 'ingress cannot self-assert actor');
|
|
97
|
+
assert.equal(validateBookingCopilotIngressTurnV1({
|
|
98
|
+
...ingress,
|
|
99
|
+
tenant: 'tenant-1'
|
|
100
|
+
}).ok, false, 'ingress cannot self-assert tenant');
|
|
101
|
+
assert.equal(validateBookingCopilotIngressTurnV1({
|
|
102
|
+
...ingress,
|
|
103
|
+
customer: 'customer-1'
|
|
104
|
+
}).ok, false, 'ingress cannot self-assert customer');
|
|
105
|
+
assert.equal(validateBookingCopilotIngressTurnV1({
|
|
106
|
+
...ingress,
|
|
107
|
+
contextRef: 'client-forged-ref'
|
|
108
|
+
}).ok, false, 'ingress cannot mint a non-null contextRef');
|
|
109
|
+
assert.deepEqual(validateBookingCopilotIngressTurnV1({
|
|
110
|
+
...ingress,
|
|
111
|
+
contextRef: null
|
|
112
|
+
}), {
|
|
113
|
+
ok: true
|
|
114
|
+
}, 'explicit null contextRef is accepted for bootstrap');
|
|
115
|
+
const hotelSelectionReceipt = {
|
|
116
|
+
schemaVersion: 'booking.surface.v1',
|
|
117
|
+
kind: 'action.receipt',
|
|
118
|
+
actionId: 'select-1',
|
|
119
|
+
contextRef: 'ctx-1',
|
|
120
|
+
status: 'applied',
|
|
121
|
+
revision: 1,
|
|
122
|
+
observation: {
|
|
123
|
+
kind: 'hotel.selection',
|
|
124
|
+
hotelRef: 'hotel-1'
|
|
125
|
+
},
|
|
126
|
+
resultContract: {
|
|
127
|
+
outcome: 'complete',
|
|
128
|
+
hardCriteriaMet: true,
|
|
129
|
+
factRefs: [],
|
|
130
|
+
gapCodes: []
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
assert.deepEqual(validateActionReceiptV1(hotelSelectionReceipt), {
|
|
134
|
+
ok: true
|
|
135
|
+
}, 'hotel.select emits hotel.selection');
|
|
136
|
+
assert.equal(validateActionReceiptV1({
|
|
137
|
+
...hotelSelectionReceipt,
|
|
138
|
+
observation: {
|
|
139
|
+
kind: 'hotel.select',
|
|
140
|
+
hotelRef: 'hotel-1'
|
|
141
|
+
}
|
|
142
|
+
}).ok, false, 'hotel.select is not an observation kind');
|
|
143
|
+
const strictWorkspace = {
|
|
144
|
+
...ingressWorkspace,
|
|
145
|
+
contextRef: 'ctx-server-minted',
|
|
146
|
+
surface: 'tenant',
|
|
147
|
+
capabilities: {
|
|
148
|
+
surface: 'tenant',
|
|
149
|
+
allowedActions: [
|
|
150
|
+
...BOOKING_READ_ACTION_KINDS
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const plannerTurn = {
|
|
155
|
+
schemaVersion: 'booking.surface.v1',
|
|
156
|
+
kind: 'user.turn',
|
|
157
|
+
taskId: 'task-1',
|
|
158
|
+
workspace: strictWorkspace,
|
|
159
|
+
request: {
|
|
160
|
+
text: ingress.request.text
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
assert.deepEqual(validateBookingCopilotTurnV1(plannerTurn), {
|
|
164
|
+
ok: true
|
|
165
|
+
});
|
|
166
|
+
assert.equal(validateBookingCopilotTurnV1({
|
|
167
|
+
...plannerTurn,
|
|
168
|
+
workspace: {
|
|
169
|
+
...strictWorkspace,
|
|
170
|
+
capabilities: {
|
|
171
|
+
surface: 'tenant',
|
|
172
|
+
allowedActions: [
|
|
173
|
+
...BOOKING_READ_ACTION_KINDS
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}).ok, true, 'full closed 12-action registry is canonical-valid');
|
|
178
|
+
assert.equal(validateBookingCopilotTurnV1({
|
|
179
|
+
...plannerTurn,
|
|
180
|
+
workspace: {
|
|
181
|
+
...strictWorkspace,
|
|
182
|
+
results: {}
|
|
183
|
+
}
|
|
184
|
+
}).ok, false, 'canonical turn rejects results without status');
|
|
185
|
+
const { contextRef: _omitted, ...workspaceWithoutContext } = strictWorkspace;
|
|
186
|
+
assert.equal(validateBookingCopilotTurnV1({
|
|
187
|
+
...plannerTurn,
|
|
188
|
+
workspace: workspaceWithoutContext
|
|
189
|
+
}).ok, false, 'planner turn requires the server-minted contextRef');
|
|
190
|
+
const statusEvent = {
|
|
191
|
+
schemaVersion: 'booking.surface.v1',
|
|
192
|
+
eventId: 'event-1',
|
|
193
|
+
taskId: 'task-1',
|
|
194
|
+
contextRef: 'ctx-server-minted',
|
|
195
|
+
sequence: 1,
|
|
196
|
+
emittedAt: '2026-08-30T12:00:00.000Z',
|
|
197
|
+
kind: 'status',
|
|
198
|
+
status: 'submitted'
|
|
199
|
+
};
|
|
200
|
+
assert.deepEqual(validateBookingSurfaceEventV1(statusEvent), {
|
|
201
|
+
ok: true
|
|
202
|
+
});
|
|
203
|
+
const { contextRef: _eventContext, ...eventWithoutContext } = statusEvent;
|
|
204
|
+
assert.equal(validateBookingSurfaceEventV1(eventWithoutContext).ok, false, 'all outbound events carry contextRef');
|
|
205
|
+
assert.equal(validateBookingSurfaceEventV1({
|
|
206
|
+
...statusEvent,
|
|
207
|
+
status: 'unknown'
|
|
208
|
+
}).ok, false, 'status payload is a closed enum');
|
|
209
|
+
const { status: _status, ...eventBase } = statusEvent;
|
|
210
|
+
assert.equal(validateBookingSurfaceEventV1({
|
|
211
|
+
...eventBase,
|
|
212
|
+
kind: 'question',
|
|
213
|
+
question: {}
|
|
214
|
+
}).ok, false, 'question payload is typed, not presence-only');
|
|
215
|
+
assert.equal(validateBookingSurfaceEventV1({
|
|
216
|
+
...eventBase,
|
|
217
|
+
kind: 'operation',
|
|
218
|
+
action: '{"kind":"search.run"}'
|
|
219
|
+
}).ok, false, 'operation rejects JSON-in-text');
|
|
220
|
+
assert.equal(validateBookingSurfaceEventV1({
|
|
221
|
+
...eventBase,
|
|
222
|
+
kind: 'terminal',
|
|
223
|
+
terminal: {
|
|
224
|
+
status: 'failed',
|
|
225
|
+
summary: 'x',
|
|
226
|
+
factRefs: []
|
|
227
|
+
}
|
|
228
|
+
}).ok, false, 'terminal status is closed');
|
|
229
|
+
const errorWithJsonLookingText = {
|
|
230
|
+
...eventBase,
|
|
231
|
+
kind: 'error',
|
|
232
|
+
error: {
|
|
233
|
+
code: 'UPSTREAM_FAILED',
|
|
234
|
+
message: '{"kind":"search.run","input":{}}',
|
|
235
|
+
retryable: true
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
assert.deepEqual(validateBookingSurfaceEventV1(errorWithJsonLookingText), {
|
|
239
|
+
ok: true
|
|
240
|
+
});
|
|
241
|
+
assert.equal(bookingOperationFromEvent(errorWithJsonLookingText), null, 'JSON-looking error text never becomes an executable action');
|
|
242
|
+
const validAction = {
|
|
243
|
+
schemaVersion: 'booking.surface.v1',
|
|
244
|
+
kind: 'search.run',
|
|
245
|
+
actionId: 'action-1',
|
|
246
|
+
contextRef: 'ctx-server-minted',
|
|
247
|
+
expectedRevision: 0,
|
|
248
|
+
reason: 'Run the existing search form.',
|
|
249
|
+
factRefs: [],
|
|
250
|
+
input: {}
|
|
251
|
+
};
|
|
252
|
+
assert.deepEqual(validateBookingReadActionV1(validAction), {
|
|
253
|
+
ok: true
|
|
254
|
+
});
|
|
255
|
+
assert.equal(validateBookingReadActionV1({
|
|
256
|
+
...validAction,
|
|
257
|
+
kind: 'book'
|
|
258
|
+
}).ok, false, 'Book is outside the closed action registry');
|
|
259
|
+
assert.equal(validateBookingReadActionV1({
|
|
260
|
+
...validAction,
|
|
261
|
+
holder: {
|
|
262
|
+
email: 'x@example.com'
|
|
263
|
+
}
|
|
264
|
+
}).ok, false, 'holder/guest patches cannot enter actions');
|
|
265
|
+
assert.equal(validateBookingReadActionV1('{"kind":"search.run"}').ok, false, 'JSON-in-text is not an action');
|
|
266
|
+
const validSearchPatchAction = {
|
|
267
|
+
...validAction,
|
|
268
|
+
kind: 'search.patch',
|
|
269
|
+
input: {
|
|
270
|
+
patch: {
|
|
271
|
+
destination: {
|
|
272
|
+
query: 'Dubai'
|
|
273
|
+
},
|
|
274
|
+
budget: {
|
|
275
|
+
strength: 'must',
|
|
276
|
+
value: {
|
|
277
|
+
max: {
|
|
278
|
+
amount: '1000.00',
|
|
279
|
+
currency: 'AED',
|
|
280
|
+
sourceFactRef: 'fact-budget-1'
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
assert.deepEqual(validateBookingReadActionV1(validSearchPatchAction), {
|
|
288
|
+
ok: true
|
|
289
|
+
});
|
|
290
|
+
assert.equal(validateBookingReadActionV1({
|
|
291
|
+
...validSearchPatchAction,
|
|
292
|
+
input: {
|
|
293
|
+
patch: {
|
|
294
|
+
...validSearchPatchAction.input.patch,
|
|
295
|
+
unknownCriterion: {
|
|
296
|
+
strength: 'must',
|
|
297
|
+
value: true
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}).ok, false, 'unknown nested search criteria are rejected before an operation is issued');
|
|
302
|
+
assert.equal(validateBookingReadActionV1({
|
|
303
|
+
...validSearchPatchAction,
|
|
304
|
+
input: {
|
|
305
|
+
patch: {
|
|
306
|
+
budget: {
|
|
307
|
+
strength: 'must',
|
|
308
|
+
value: {
|
|
309
|
+
max: {
|
|
310
|
+
amount: 1000,
|
|
311
|
+
currency: 'AED',
|
|
312
|
+
sourceFactRef: 'fact-budget-1'
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}).ok, false, 'Money.amount is a decimal string, never a model-computed number');
|
|
319
|
+
assert.equal(validateBookingReadActionV1({
|
|
320
|
+
...validSearchPatchAction,
|
|
321
|
+
input: {
|
|
322
|
+
patch: {
|
|
323
|
+
destination: {
|
|
324
|
+
query: 'Dubai'
|
|
325
|
+
},
|
|
326
|
+
holder: {
|
|
327
|
+
email: 'x@example.com'
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}).ok, false, 'holder data is rejected even when nested inside a typed patch');
|
|
332
|
+
assert.equal(validateBookingReadActionV1({
|
|
333
|
+
...validAction,
|
|
334
|
+
kind: 'offers.query',
|
|
335
|
+
input: {
|
|
336
|
+
hotelRefs: [
|
|
337
|
+
'hotel-1'
|
|
338
|
+
],
|
|
339
|
+
criteria: {
|
|
340
|
+
roomType: {
|
|
341
|
+
strength: 'must',
|
|
342
|
+
value: [
|
|
343
|
+
'Twin'
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
guest: {
|
|
347
|
+
name: 'x'
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}).ok, false, 'guest data is rejected even when nested inside offer criteria');
|
|
352
|
+
const validReceipt = {
|
|
353
|
+
schemaVersion: 'booking.surface.v1',
|
|
354
|
+
kind: 'action.receipt',
|
|
355
|
+
actionId: 'action-1',
|
|
356
|
+
contextRef: 'ctx-server-minted',
|
|
357
|
+
status: 'applied',
|
|
358
|
+
revision: 1,
|
|
359
|
+
observation: {
|
|
360
|
+
kind: 'search.state',
|
|
361
|
+
resultCount: 3
|
|
362
|
+
},
|
|
363
|
+
resultContract: {
|
|
364
|
+
outcome: 'complete',
|
|
365
|
+
hardCriteriaMet: true,
|
|
366
|
+
factRefs: [],
|
|
367
|
+
gapCodes: []
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
assert.deepEqual(validateActionReceiptV1(validReceipt), {
|
|
371
|
+
ok: true
|
|
372
|
+
});
|
|
373
|
+
assert.equal(validateActionReceiptV1({
|
|
374
|
+
...validReceipt,
|
|
375
|
+
observation: {
|
|
376
|
+
kind: 'book'
|
|
377
|
+
}
|
|
378
|
+
}).ok, false, 'receipt observations are a closed typed union');
|
|
379
|
+
assert.equal(validateActionReceiptV1({
|
|
380
|
+
...validReceipt,
|
|
381
|
+
observation: null
|
|
382
|
+
}).ok, false, 'receipt observation is never null');
|
|
383
|
+
assert.equal(validateActionReceiptV1({
|
|
384
|
+
...validReceipt,
|
|
385
|
+
resultContract: {
|
|
386
|
+
...validReceipt.resultContract,
|
|
387
|
+
supplierCost: 1
|
|
388
|
+
}
|
|
389
|
+
}).ok, false, 'receipt result contract rejects supplier cost');
|
|
390
|
+
console.log('BOOKING SURFACE CONTRACT PROOF: registry/schema/ingress-planner boundary OK');
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
//# sourceURL=ts/scripts/booking-surface-contract-proof-tests.ts
|