@danceiny/gotry 0.0.1-rc.9 → 0.2.0-rc.28
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 +172 -219
- package/README.zh-CN.md +222 -0
- package/bin/gotry-backend.js +53 -0
- package/bin/gotry-booking-copilot.js +53 -0
- package/bin/gotry-bootstrap.js +1788 -0
- package/bin/gotry-inner.js +733 -83
- package/bin/gotry-process-liveness.d.ts +27 -0
- package/bin/gotry-process-liveness.js +97 -0
- package/bin/gotry-runtime-resolution.d.ts +27 -0
- package/bin/gotry-runtime-resolution.js +49 -0
- package/bin/gotry.js +1 -1
- package/client/client.js +203 -0
- package/cordis.gotry-patch.yml +80 -56
- package/data/airline-airports.json +39 -0
- package/data/stations-12306-verify.json +524 -0
- package/dist/capabilities/agent-reach-deep.js +45 -122
- package/dist/capabilities/agent-reach.js +101 -146
- package/dist/capabilities/anything.js +161 -94
- package/dist/capabilities/artifacts.js +370 -0
- package/dist/capabilities/channel-health.js +131 -0
- package/dist/capabilities/channel-registry.js +256 -0
- package/dist/capabilities/doctor.js +553 -0
- package/dist/capabilities/effect.js +394 -0
- package/dist/capabilities/external-event.js +149 -0
- package/dist/capabilities/fact-log.js +55 -0
- package/dist/capabilities/flyai-config.js +337 -0
- package/dist/capabilities/flyai.js +947 -110
- package/dist/capabilities/fx-contract.js +293 -0
- package/dist/capabilities/geo-atlas.js +246 -0
- package/dist/capabilities/ground-transfer.js +676 -0
- package/dist/capabilities/hbcli.js +260 -123
- package/dist/capabilities/hotelbyte-transaction.js +194 -0
- package/dist/capabilities/incident-log.js +131 -61
- package/dist/capabilities/itinerary-artifact.js +190 -0
- package/dist/capabilities/itinerary-deck-artifact.js +194 -0
- package/dist/capabilities/itinerary-deck-export.js +339 -0
- package/dist/capabilities/lavish-local.js +924 -0
- package/dist/capabilities/model-override.js +38 -0
- package/dist/capabilities/opensky.js +54 -43
- package/dist/capabilities/provider-detail-sanitize.js +64 -0
- package/dist/capabilities/resilience.js +191 -0
- package/dist/capabilities/route-provider-conformance.js +341 -0
- package/dist/capabilities/session/action-cache.js +50 -44
- package/dist/capabilities/session/adapters/ctrip-flight.js +120 -62
- package/dist/capabilities/session/adapters/ctrip-hotel.js +222 -0
- package/dist/capabilities/session/adapters/dida-portal.js +274 -0
- package/dist/capabilities/session/adapters/meituan-local.js +35 -54
- package/dist/capabilities/session/adapters/rail-12306.js +342 -0
- package/dist/capabilities/session/benchmark.js +189 -0
- package/dist/capabilities/session/bridge-ledger.js +224 -0
- package/dist/capabilities/session/extension-bridge.js +636 -0
- package/dist/capabilities/session/extension-channel.js +109 -0
- package/dist/capabilities/session/extension-distribution.js +230 -0
- package/dist/capabilities/session/extract.js +31 -21
- package/dist/capabilities/session/golden-score.js +114 -0
- package/dist/capabilities/session/health-watch.js +215 -0
- package/dist/capabilities/session/read-guard.js +75 -24
- package/dist/capabilities/session/static-flight-golden.js +150 -0
- package/dist/capabilities/session/transport.js +97 -83
- package/dist/capabilities/session/wizard.js +117 -0
- package/dist/capabilities/session-consent.js +178 -0
- package/dist/capabilities/session-login.js +170 -0
- package/dist/capabilities/session-search.js +635 -44
- package/dist/capabilities/spawn-bounded.js +203 -0
- package/dist/capabilities/sponsor-plugin.js +341 -0
- package/dist/capabilities/visa-policy.js +140 -0
- package/dist/capabilities/weather.js +243 -138
- package/dist/data/session-golden-20.json +25 -0
- package/dist/data/sf-golden-manifest.json +103 -0
- package/dist/data/sf-static-routes.json +91 -0
- package/dist/scripts/action-cache-tests.js +24 -59
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +242 -0
- package/dist/scripts/agent-planning-turn-deadline-tests.js +185 -0
- package/dist/scripts/agent-reach-deep-tests.js +30 -40
- package/dist/scripts/agent-reach-error-tests.js +354 -0
- package/dist/scripts/agent-reach-tests.js +26 -18
- package/dist/scripts/agent-reach-wrapper-tests.js +50 -50
- package/dist/scripts/anything-path-measure-tests.js +133 -0
- package/dist/scripts/anything-path-measure.js +150 -0
- package/dist/scripts/anything-tests.js +250 -60
- package/dist/scripts/artifact-client-contract-tests.js +220 -0
- package/dist/scripts/artifacts-capability-tests.js +727 -0
- package/dist/scripts/async-collect.js +50 -11
- package/dist/scripts/benchmark-environment-bridge-e2e.js +741 -0
- package/dist/scripts/benchmark-environment-bridge-tests.js +1452 -0
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +126 -0
- package/dist/scripts/booking-copilot-availability-policy-tests.js +265 -0
- package/dist/scripts/booking-copilot-bin-proof-tests.js +66 -0
- package/dist/scripts/booking-copilot-cleanup-proof-helper.js +76 -0
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +144 -0
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +424 -0
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +2839 -0
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +309 -0
- package/dist/scripts/booking-copilot-dsh-readiness-proof.js +238 -0
- package/dist/scripts/booking-copilot-dsh-warmer-proof.js +126 -0
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +156 -0
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +70 -0
- package/dist/scripts/booking-copilot-intent-proof-tests.js +422 -0
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +184 -0
- package/dist/scripts/booking-copilot-planner-live-probe.js +95 -0
- package/dist/scripts/booking-copilot-proof-runtime.js +42 -0
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +210 -0
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +2349 -0
- package/dist/scripts/booking-copilot-server-proof-tests.js +784 -0
- package/dist/scripts/booking-copilot-startup-proof-tests.js +94 -0
- package/dist/scripts/booking-executor-tests.js +80 -0
- package/dist/scripts/booking-recovery-chain-tests.js +182 -0
- package/dist/scripts/booking-saga-tests.js +125 -0
- package/dist/scripts/booking-surface-contract-proof-tests.js +212 -0
- package/dist/scripts/bootstrap-tests.js +1549 -0
- package/dist/scripts/bridge-events-tests.js +239 -0
- package/dist/scripts/bridge-ledger-tests.js +428 -0
- package/dist/scripts/build-changelog.js +238 -0
- package/dist/scripts/build-metrics-report.js +331 -0
- package/dist/scripts/changelog-tests.js +118 -0
- package/dist/scripts/channel-probe-tests.js +103 -0
- package/dist/scripts/channel-probe.js +169 -0
- package/dist/scripts/channel-registry-tests.js +208 -0
- package/dist/scripts/city-scenario-tier-tests.js +234 -0
- package/dist/scripts/companion-tests.js +25 -70
- package/dist/scripts/dida-cookie-probe.js +87 -0
- package/dist/scripts/dida-runner-stop-tests.js +311 -0
- package/dist/scripts/dida-sw-probe.js +114 -0
- package/dist/scripts/diff-test.js +17 -12
- package/dist/scripts/doctor-tests.js +600 -0
- package/dist/scripts/drill-multiuser-ledger-tests.js +1076 -0
- package/dist/scripts/drill-sdk-descendant-cleanup-tests.js +606 -0
- package/dist/scripts/drill-w2a-sensor-tests.js +788 -0
- package/dist/scripts/dsh-artifact-e2e.js +279 -0
- package/dist/scripts/dsh-artifact-web-e2e.js +675 -0
- package/dist/scripts/dsh-http-proxy-sse-proof.js +90 -0
- package/dist/scripts/dsh-llm-tests.js +437 -0
- package/dist/scripts/dsh-runtime-closure-tests.js +182 -0
- package/dist/scripts/dsh-runtime-closure.js +162 -0
- package/dist/scripts/dsh-session-v3-migration-proof.js +109 -0
- package/dist/scripts/dsh-subprocess-local-proof.js +150 -0
- package/dist/scripts/dsh-target-closure-proof.js +178 -0
- package/dist/scripts/effect-tests.js +539 -0
- package/dist/scripts/engine-run.js +1 -3
- package/dist/scripts/engine-tests.js +16 -10
- package/dist/scripts/evaluation-cadence-tests.js +174 -0
- package/dist/scripts/evaluation-contract-tests.js +268 -0
- package/dist/scripts/extension-distribution-cli.js +39 -0
- package/dist/scripts/extension-distribution-tests.js +443 -0
- package/dist/scripts/extension-tests.js +988 -0
- package/dist/scripts/external-event-tests.js +350 -0
- package/dist/scripts/fact-gate-tests.js +869 -0
- package/dist/scripts/fixtures/extension-bridge-unref-child.mjs +21 -0
- package/dist/scripts/flight-hotel-anchor-363-registered-e2e.js +169 -0
- package/dist/scripts/flight-malformed-tests.js +159 -0
- package/dist/scripts/flyai-setup-tests.js +228 -0
- package/dist/scripts/flyai-setup-tool-tests.js +54 -0
- package/dist/scripts/flyai-tests.js +692 -0
- package/dist/scripts/flyai-tool-registration-contract-tests.js +91 -0
- package/dist/scripts/fx-contract-tests.js +201 -0
- package/dist/scripts/g5-guard-tests.js +150 -0
- package/dist/scripts/g5-guard.js +193 -0
- package/dist/scripts/gen-lunar-anchors.js +106 -0
- package/dist/scripts/geo-atlas-tests.js +283 -0
- package/dist/scripts/gotry-backend-kernel-tests.js +206 -0
- package/dist/scripts/gotry-try-demo-tests.js +79 -0
- package/dist/scripts/gotry-try-demo.js +49 -0
- package/dist/scripts/ground-transfer-tests.js +956 -0
- package/dist/scripts/hbcli-e2e-tests.js +159 -0
- package/dist/scripts/hbcli-live-optin-tests.js +96 -0
- package/dist/scripts/hbcli-release-contract-tests.js +122 -0
- package/dist/scripts/hbcli-tests.js +121 -69
- package/dist/scripts/health-watch-cli.js +73 -0
- package/dist/scripts/hotel-date-gate-tests.js +496 -0
- package/dist/scripts/hotelbyte-reconcile-tests.js +141 -0
- package/dist/scripts/hotelbyte-spawn-e2e-tests.js +373 -0
- package/dist/scripts/i18n-tests.js +41 -0
- package/dist/scripts/incident-tests.js +281 -87
- package/dist/scripts/issue-194-job-id-guard-tests.js +106 -0
- package/dist/scripts/issue-233-cancel-refund-commission-tests.js +392 -0
- package/dist/scripts/issue-271-liveness-tests.js +569 -0
- package/dist/scripts/issue-289-model-retry-real-tests.js +296 -0
- package/dist/scripts/issue-289-model-retry-tests.js +441 -0
- package/dist/scripts/issue-289-web-retry-e2e.js +630 -0
- package/dist/scripts/issue-338-home-city-e2e.js +577 -0
- package/dist/scripts/issue343-real-entry-e2e.js +160 -0
- package/dist/scripts/issue436-persisted-routing-e2e.js +247 -0
- package/dist/scripts/itinerary-artifact-tests.js +368 -0
- package/dist/scripts/itinerary-deck-artifact-tests.js +416 -0
- package/dist/scripts/itinerary-deck-export-tests.js +552 -0
- package/dist/scripts/itinerary-deck-tests.js +435 -0
- package/dist/scripts/itinerary-html-tests.js +426 -0
- package/dist/scripts/journey-tests.js +22 -27
- package/dist/scripts/kernel-manifest-evidence.js +109 -0
- package/dist/scripts/kernel-manifest-gate.js +126 -0
- package/dist/scripts/kernel-manifest-tests.js +212 -0
- package/dist/scripts/kernel-manifest-trace-entry.js +7 -0
- package/dist/scripts/kernel-manifest-trace-hook.mjs +28 -0
- package/dist/scripts/kernel-manifest.js +369 -0
- package/dist/scripts/lavish-local-tests.js +1226 -0
- package/dist/scripts/lavish-product-tools-tests.js +537 -0
- package/dist/scripts/ledger-repair-apply-tests.js +316 -0
- package/dist/scripts/ledger-repair-plan-tests.js +375 -0
- package/dist/scripts/ledger-tests.js +382 -246
- package/dist/scripts/ledger-workflow-crash.js +10 -20
- package/dist/scripts/m3-cohort-tests.js +714 -0
- package/dist/scripts/m3-cohort.js +310 -0
- package/dist/scripts/managed-dsh-cleanup-diagnostic-proof.js +184 -0
- package/dist/scripts/managed-dsh-close-failure-proof.js +172 -0
- package/dist/scripts/managed-dsh-run-port-proof.js +153 -0
- package/dist/scripts/managed-dsh-terminal-proof.js +252 -0
- package/dist/scripts/map-tools-vendor-package-proof.js +365 -0
- package/dist/scripts/memory-capture-tests.js +242 -61
- package/dist/scripts/memory-decay-tests.js +18 -52
- package/dist/scripts/memory-lifecycle-tests.js +657 -0
- package/dist/scripts/memory-lifecycle.js +196 -0
- package/dist/scripts/memory-metrics.js +24 -12
- package/dist/scripts/memory-value-report.js +631 -0
- package/dist/scripts/memory-value-tests.js +328 -0
- package/dist/scripts/metrics-report-tests.js +151 -0
- package/dist/scripts/model-override-e2e.js +137 -0
- package/dist/scripts/nightly-evidence-tests.js +203 -0
- package/dist/scripts/nightly-evidence.js +303 -0
- package/dist/scripts/nudge-digest.js +39 -28
- package/dist/scripts/observability-tests.js +381 -0
- package/dist/scripts/onboarding-tests.js +161 -0
- package/dist/scripts/opensky-check.js +18 -13
- package/dist/scripts/opensky-tests.js +28 -28
- package/dist/scripts/outcome-projection-tests.js +427 -0
- package/dist/scripts/persona-sim-tests.js +603 -0
- package/dist/scripts/persona-sim.js +1081 -0
- package/dist/scripts/persona-surface-guard-tests.js +49 -0
- package/dist/scripts/pnpm-dsh-closure-proof.js +17 -0
- package/dist/scripts/policy-anchor-359-registered-e2e.js +214 -0
- package/dist/scripts/price-drift-tests.js +340 -0
- package/dist/scripts/price-drift-watch.js +447 -0
- package/dist/scripts/probe-poi-tests.js +53 -45
- package/dist/scripts/product-metrics.js +483 -0
- package/dist/scripts/publish-preverify.js +110 -0
- package/dist/scripts/realtime-pricing-tests.js +76 -0
- package/dist/scripts/recall-tests.js +513 -0
- package/dist/scripts/replay-async.js +22 -18
- package/dist/scripts/replay-real.js +18 -18
- package/dist/scripts/replay.js +54 -82
- package/dist/scripts/route-provider-conformance-tests.js +391 -0
- package/dist/scripts/session-attach-diagnose.js +20 -20
- package/dist/scripts/session-attach-poc.js +34 -37
- package/dist/scripts/session-benchmark.js +180 -0
- package/dist/scripts/session-dida-live-e2e.js +199 -0
- package/dist/scripts/session-extract-tests.js +14 -35
- package/dist/scripts/session-link-tests.js +478 -0
- package/dist/scripts/session-login.js +27 -46
- package/dist/scripts/session-tests.js +796 -96
- package/dist/scripts/session-zone-crash.js +49 -0
- package/dist/scripts/session-zone-ledger-tests.js +432 -0
- package/dist/scripts/session-zone-observation-tests.js +492 -0
- package/dist/scripts/session-zone-observe.js +135 -0
- package/dist/scripts/session-zone-wiring-tests.js +566 -0
- package/dist/scripts/session-zones-tests.js +374 -0
- package/dist/scripts/sf-live-benchmark.js +367 -0
- package/dist/scripts/sf-live-challenge-stop-tests.js +453 -0
- package/dist/scripts/sf-live-cli-tests.js +92 -0
- package/dist/scripts/sf-live-options.js +46 -0
- package/dist/scripts/sf-manifest-tests.js +30 -0
- package/dist/scripts/sf-manifest.js +33 -0
- package/dist/scripts/sf-soft-score-tests.js +67 -0
- package/dist/scripts/sf-summary-tests.js +324 -0
- package/dist/scripts/sf-summary.js +525 -0
- package/dist/scripts/share-tests.js +432 -0
- package/dist/scripts/skeleton-check.js +16 -14
- package/dist/scripts/skeleton-integration-test.js +28 -11
- package/dist/scripts/skills-contract-tests.js +51 -46
- package/dist/scripts/smoke-session-gate-tests.js +21 -0
- package/dist/scripts/smoke.js +690 -246
- package/dist/scripts/spawn-bounded-abort-tests.js +244 -0
- package/dist/scripts/sponsor-reuse-tests.js +262 -0
- package/dist/scripts/state-cli-tests.js +226 -101
- package/dist/scripts/state-cli.js +565 -198
- package/dist/scripts/state-repair-cli.js +66 -0
- package/dist/scripts/state-repair-tests.js +140 -0
- package/dist/scripts/static-golden-tests.js +165 -0
- package/dist/scripts/time-eval-tests.js +212 -192
- package/dist/scripts/travel-timeline-tests.js +29 -93
- package/dist/scripts/turn-handoff-collect-tests.js +169 -0
- package/dist/scripts/turn-handoff-collect.js +161 -0
- package/dist/scripts/turn-policy-tests.js +55 -0
- package/dist/scripts/typed-contract-canary.js +176 -0
- package/dist/scripts/tz-resolver-sanity.js +50 -0
- package/dist/scripts/tz-resolver-tests.js +584 -0
- package/dist/scripts/unified-tests.js +60 -20
- package/dist/scripts/visa-policy-tests.js +62 -0
- package/dist/scripts/weather-tests.js +276 -41
- package/dist/scripts/wish-channel-gate-tests.js +54 -0
- package/dist/scripts/write-gate-tests.js +522 -0
- package/dist/scripts/z3-lifecycle-fault-tests.js +188 -0
- package/dist/scripts/z3-lifecycle-tests.js +170 -0
- package/dist/scripts/z3-race-repeat-tests.js +39 -0
- package/dist/scripts/z3-race-tests.js +46 -0
- package/dist/src/artifact-gate.js +829 -0
- package/dist/src/backend/kernel.js +91 -0
- package/dist/src/backend/modules/booking-copilot.js +92 -0
- package/dist/src/backend/modules/booking-executor.js +124 -0
- package/dist/src/backend/modules/session-search.js +551 -0
- package/dist/src/benchmark-agent-conformance.js +578 -0
- package/dist/src/benchmark-environment-bridge.js +515 -0
- package/dist/src/benchmark-headless-child-diagnostics.js +166 -0
- package/dist/src/benchmark-tool-isolation.js +151 -0
- package/dist/src/bookable-facts.js +533 -0
- package/dist/src/booking-saga.js +97 -0
- package/dist/src/booking-surface/availability-policy.js +697 -0
- package/dist/src/booking-surface/booking-intent.js +43 -0
- package/dist/src/booking-surface/cancel-refund-commission.js +379 -0
- package/dist/src/booking-surface/canonical-schema.js +116 -0
- package/dist/src/booking-surface/contracts.js +75 -0
- package/dist/src/booking-surface/dsh-planner.js +1854 -0
- package/dist/src/booking-surface/dsh-plugin.js +378 -0
- package/dist/src/booking-surface/dsh-worker.js +98 -0
- package/dist/src/booking-surface/error-codes.js +231 -0
- package/dist/src/booking-surface/index.js +9 -0
- package/dist/src/booking-surface/managed-dsh-cleanup-diagnostic.js +97 -0
- package/dist/src/booking-surface/managed-dsh-run-port.js +244 -0
- package/dist/src/booking-surface/profile.js +24 -0
- package/dist/src/booking-surface/recovery-chain.js +367 -0
- package/dist/src/booking-surface/runtime.js +1968 -0
- package/dist/src/booking-surface/server.js +674 -0
- package/dist/src/booking-surface/startup.js +168 -0
- package/dist/src/booking-surface/validation.js +261 -0
- package/dist/src/bridge.js +20 -13
- package/dist/src/city-scenario-tier.js +378 -0
- package/dist/src/companions.js +48 -74
- package/dist/src/contracts.js +21 -43
- package/dist/src/dsh-llm.js +171 -115
- package/dist/src/engine.js +276 -193
- package/dist/src/evaluation-cadence.js +97 -0
- package/dist/src/evaluation-contracts.js +283 -0
- package/dist/src/flight-pack-adapter.js +54 -0
- package/dist/src/flight-pack-contract.js +2 -0
- package/dist/src/flyai-setup-tool.js +70 -0
- package/dist/src/gotry-backend.js +125 -0
- package/dist/src/hotel-date-gate.js +118 -0
- package/dist/src/i18n.js +88 -0
- package/dist/src/index.js +2385 -881
- package/dist/src/itinerary-deck.js +139 -0
- package/dist/src/itinerary-doc-shared.js +661 -0
- package/dist/src/itinerary-html.js +131 -0
- package/dist/src/journey.js +155 -108
- package/dist/src/lavish-tools.js +400 -0
- package/dist/src/ledger-repair-apply.js +538 -0
- package/dist/src/ledger-repair-plan.js +463 -0
- package/dist/src/loop.js +331 -161
- package/dist/src/m3-cohort.js +1577 -0
- package/dist/src/memory-capture.js +180 -32
- package/dist/src/memory-decay.js +30 -14
- package/dist/src/memory-lifecycle.js +1310 -0
- package/dist/src/memory-utility.js +27 -40
- package/dist/src/mock-llm.js +36 -61
- package/dist/src/model.js +81 -36
- package/dist/src/outcome-projection.js +746 -0
- package/dist/src/realtime-pricing.js +103 -0
- package/dist/src/recall/card.js +74 -0
- package/dist/src/recall/evaluator.js +140 -0
- package/dist/src/recall/integration.js +17 -0
- package/dist/src/recall/tick.js +166 -0
- package/dist/src/session-link/plan-it-action.js +48 -0
- package/dist/src/session-link/session-link.js +248 -0
- package/dist/src/session-zone-ledger.js +312 -0
- package/dist/src/session-zone-observation.js +354 -0
- package/dist/src/session-zone-wiring.js +658 -0
- package/dist/src/session-zones.js +510 -0
- package/dist/src/share/adapters.js +51 -0
- package/dist/src/share/share-consent.js +76 -0
- package/dist/src/share/share-deck.js +58 -0
- package/dist/src/share/share-token.js +146 -0
- package/dist/src/slot-spec.js +84 -106
- package/dist/src/state-ledger.js +696 -524
- package/dist/src/state-repair.js +299 -0
- package/dist/src/subagent-job-id-guard.js +58 -0
- package/dist/src/time-anchor.js +231 -33
- package/dist/src/tool-packet.js +20 -8
- package/dist/src/travel-slots.js +58 -35
- package/dist/src/travel-timeline.js +44 -63
- package/dist/src/turn-deadline.js +287 -0
- package/dist/src/turn-policy.js +118 -0
- package/dist/src/tz-resolver.js +143 -0
- package/dist/src/unified.js +600 -360
- package/dist/src/wish-pool.js +42 -12
- package/dist/src/write-gate.js +495 -0
- package/dist/src/z3-shared.js +284 -0
- package/extension/README.md +21 -0
- package/extension/README.zh-CN.md +21 -0
- package/extension/background.js +463 -0
- package/extension/content-bridge.js +270 -0
- package/extension/content-main.js +111 -0
- package/extension/manifest.json +60 -0
- package/package.json +407 -14
- package/schemas/booking.intent.schema.json +193 -0
- package/schemas/booking.surface.schema.json +2622 -0
- package/ts/capabilities/agent-reach-deep.ts +114 -0
- package/ts/capabilities/agent-reach.ts +198 -0
- package/ts/capabilities/anything.ts +282 -0
- package/ts/capabilities/artifacts.ts +428 -0
- package/ts/capabilities/fact-log.ts +54 -0
- package/ts/capabilities/flyai-config.ts +388 -0
- package/ts/capabilities/flyai.ts +1274 -0
- package/ts/capabilities/hbcli.ts +253 -71
- package/ts/capabilities/incident-log.ts +88 -59
- package/ts/capabilities/itinerary-artifact.ts +214 -0
- package/ts/capabilities/itinerary-deck-artifact.ts +218 -0
- package/ts/capabilities/itinerary-deck-export.ts +378 -0
- package/ts/capabilities/opensky.ts +121 -0
- package/ts/capabilities/session/action-cache.ts +148 -0
- package/ts/capabilities/session/adapters/ctrip-flight.ts +181 -0
- package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
- package/ts/capabilities/session/adapters/dida-portal.ts +338 -0
- package/ts/capabilities/session/adapters/meituan-local.ts +70 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +392 -0
- package/ts/capabilities/session/benchmark.ts +276 -0
- package/ts/capabilities/session/bridge-ledger.ts +333 -0
- package/ts/capabilities/session/extension-bridge.ts +794 -0
- package/ts/capabilities/session/extension-channel.ts +144 -0
- package/ts/capabilities/session/extension-distribution.ts +266 -0
- package/ts/capabilities/session/extract.ts +54 -0
- package/ts/capabilities/session/golden-score.ts +139 -0
- package/ts/capabilities/session/health-watch.ts +264 -0
- package/ts/capabilities/session/read-guard.ts +141 -0
- package/ts/capabilities/session/static-flight-golden.ts +209 -0
- package/ts/capabilities/session/transport.ts +146 -0
- package/ts/capabilities/session/wizard.ts +140 -0
- package/ts/capabilities/session-consent.ts +211 -0
- package/ts/capabilities/session-login.ts +208 -0
- package/ts/capabilities/session-search.ts +893 -0
- package/ts/capabilities/weather.ts +330 -0
- package/ts/dsh-runtime/vendor/README.md +68 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/LICENSE +21 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +405 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +404 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/client/client.js +1584 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/cordis.patch.yml +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/icon.svg +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/amap.js +595 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/nominatim.js +63 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/osrm.js +58 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/photon.js +55 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-file.js +87 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-route.js +131 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/geo.js +232 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/index.js +120 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +40 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/staticmap-route.js +115 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/geocode.js +127 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/poi.js +84 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/routes.js +267 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/amap.d.ts +90 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/nominatim.d.ts +17 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/osrm.d.ts +15 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/photon.d.ts +22 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-file.d.ts +33 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-route.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/geo.d.ts +61 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/index.d.ts +18 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +14 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/staticmap-route.d.ts +31 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/geocode.d.ts +11 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/poi.d.ts +9 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/routes.d.ts +75 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/types.d.ts +68 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +97 -0
- package/ts/package.json +293 -3
- package/ts/scripts/async-collect.ts +91 -0
- package/ts/scripts/map-tools-vendor-package-proof.ts +404 -0
- package/ts/scripts/skeleton-check.ts +1 -1
- package/ts/scripts/skeleton-integration-test.ts +23 -1
- package/ts/scripts/state-cli.ts +586 -0
- package/ts/scripts/turn-handoff-collect.ts +178 -0
- package/ts/src/artifact-gate.ts +991 -0
- package/ts/src/benchmark-agent-conformance.ts +619 -0
- package/ts/src/benchmark-environment-bridge.ts +538 -0
- package/ts/src/benchmark-headless-child-diagnostics.ts +184 -0
- package/ts/src/benchmark-tool-isolation.ts +166 -0
- package/ts/src/bookable-facts.ts +837 -0
- package/ts/src/booking-saga.ts +133 -0
- package/ts/src/booking-surface/availability-policy.ts +522 -0
- package/ts/src/booking-surface/booking-intent.ts +86 -0
- package/ts/src/booking-surface/cancel-refund-commission.ts +488 -0
- package/ts/src/booking-surface/canonical-schema.js +116 -0
- package/ts/src/booking-surface/contracts.ts +475 -0
- package/ts/src/booking-surface/dsh-planner.ts +1949 -0
- package/ts/src/booking-surface/dsh-plugin.js +378 -0
- package/ts/src/booking-surface/dsh-worker.ts +110 -0
- package/ts/src/booking-surface/error-codes.ts +241 -0
- package/ts/src/booking-surface/index.ts +9 -0
- package/ts/src/booking-surface/managed-dsh-cleanup-diagnostic.ts +151 -0
- package/ts/src/booking-surface/managed-dsh-run-port.ts +273 -0
- package/ts/src/booking-surface/profile.ts +42 -0
- package/ts/src/booking-surface/recovery-chain.ts +409 -0
- package/ts/src/booking-surface/runtime.ts +1793 -0
- package/ts/src/booking-surface/server.ts +733 -0
- package/ts/src/booking-surface/startup.ts +201 -0
- package/ts/src/booking-surface/validation.ts +217 -0
- package/ts/src/companions.ts +113 -0
- package/ts/src/contracts.ts +17 -3
- package/ts/src/dsh-llm.ts +152 -17
- package/ts/src/flyai-setup-tool.ts +77 -0
- package/ts/src/index.ts +2123 -200
- package/ts/src/itinerary-deck.ts +189 -0
- package/ts/src/itinerary-doc-shared.ts +741 -0
- package/ts/src/itinerary-html.ts +171 -0
- package/ts/src/loop.ts +234 -26
- package/ts/src/memory-capture.ts +283 -0
- package/ts/src/memory-decay.ts +55 -0
- package/ts/src/memory-utility.ts +70 -0
- package/ts/src/mock-llm.ts +4 -8
- package/ts/src/model.ts +88 -2
- package/ts/src/recall/card.ts +106 -0
- package/ts/src/recall/evaluator.ts +170 -0
- package/ts/src/recall/integration.ts +35 -0
- package/ts/src/recall/tick.ts +213 -0
- package/ts/src/session-link/plan-it-action.ts +78 -0
- package/ts/src/session-link/session-link.ts +275 -0
- package/ts/src/share/adapters.ts +93 -0
- package/ts/src/share/share-consent.ts +105 -0
- package/ts/src/share/share-deck.ts +85 -0
- package/ts/src/share/share-token.ts +166 -0
- package/ts/src/slot-spec.ts +172 -0
- package/ts/src/state-ledger.ts +1166 -0
- package/ts/src/subagent-job-id-guard.ts +72 -0
- package/ts/src/time-anchor.ts +338 -0
- package/ts/src/tool-packet.ts +32 -0
- package/ts/src/travel-slots.ts +219 -0
- package/ts/src/travel-timeline.ts +83 -0
- package/ts/src/turn-deadline.ts +366 -0
- package/ts/src/turn-policy.ts +154 -0
- package/ts/src/unified.ts +444 -105
- package/ts/src/wish-pool.ts +79 -0
- package/dist/scripts/session-attach-wait.js +0 -41
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 行程 deck 渲染器契约测试(issue #564)。
|
|
3
|
+
*
|
|
4
|
+
* 只使用合成数据:与 itinerary-html-tests.ts 同源的合成行程 + 4 条已注册事实
|
|
5
|
+
* + 恶意 HTML 反例。不含任何用户真实行程或个人细节。
|
|
6
|
+
*
|
|
7
|
+
* 核心断言组:①deck 形态契约(幻灯派生/scroll-snap 零脚本翻页/导航锚点);
|
|
8
|
+
* ②证据面语义与单页文档逐字一致(同一共享层);③**反漂移锁**——同一输入下
|
|
9
|
+
* renderItineraryHtml 与 renderItineraryDeck 的拒绝结果(errors 数组)逐字一致;
|
|
10
|
+
* ④纯度源检查;⑤字节上限与逐字节确定性。
|
|
11
|
+
*
|
|
12
|
+
* 运行(在 ts/ 下):npx tsx scripts/itinerary-deck-tests.ts
|
|
13
|
+
*/
|
|
14
|
+
import { BOOKABLE_FACT_SCHEMA, renderFlightFact, renderHotelFact, renderPolicyFact, } from '../src/bookable-facts.js';
|
|
15
|
+
import { renderItineraryDeck } from '../src/itinerary-deck.js';
|
|
16
|
+
import { renderItineraryHtml } from '../src/itinerary-html.js';
|
|
17
|
+
import { ITINERARY_DOC_LIMITS } from '../src/itinerary-doc-shared.js';
|
|
18
|
+
let pass = 0;
|
|
19
|
+
let fail = 0;
|
|
20
|
+
const failures = [];
|
|
21
|
+
function assert(cond, msg) {
|
|
22
|
+
if (cond) {
|
|
23
|
+
pass++;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
fail++;
|
|
27
|
+
failures.push(msg);
|
|
28
|
+
}
|
|
29
|
+
function assertRejected(result, needle, msg) {
|
|
30
|
+
if (result.ok) {
|
|
31
|
+
assert(false, `${msg}(期望 ok:false,实际渲染出 ${result.html.length} 字符)`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
assert(result.errors.some(e => e.includes(needle)), `${msg}(errors=${JSON.stringify(result.errors)} 未含「${needle}」)`);
|
|
35
|
+
}
|
|
36
|
+
function assertRendered(result, msg) {
|
|
37
|
+
if (!result.ok) {
|
|
38
|
+
assert(false, `${msg}(期望 ok:true,实际 errors=${JSON.stringify(result.errors)})`);
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
assert(true, msg);
|
|
42
|
+
return result.html;
|
|
43
|
+
}
|
|
44
|
+
function countOf(haystack, needle) {
|
|
45
|
+
return haystack.split(needle).length - 1;
|
|
46
|
+
}
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// 合成 fixture(与 itinerary-html-tests.ts 同源)
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
const FLIGHT_HIT = {
|
|
51
|
+
schema: BOOKABLE_FACT_SCHEMA,
|
|
52
|
+
fact_id: 'a1b2c3d4e5f60718',
|
|
53
|
+
kind: 'flight',
|
|
54
|
+
route: { origin: 'SZX', destination: 'HKT', origin_airport: 'SZX', dest_airport: 'HKT' },
|
|
55
|
+
date: '2027-07-17',
|
|
56
|
+
flight_no: 'CZ6061',
|
|
57
|
+
marketing_carrier: '南方航空',
|
|
58
|
+
dep_local: '09:20',
|
|
59
|
+
arr_local: '12:05',
|
|
60
|
+
nonstop: true,
|
|
61
|
+
price: 1680,
|
|
62
|
+
currency: 'CNY',
|
|
63
|
+
baggage_included: false,
|
|
64
|
+
tier: 'live_inventory',
|
|
65
|
+
bookability: 'bookable_exact_date',
|
|
66
|
+
source: 'session:ctrip-flight',
|
|
67
|
+
query_id: 'session:ctrip-flight:flight:SZX-HKT:2027-07-17',
|
|
68
|
+
fetched_at: '2026-09-12T02:10:03.000Z',
|
|
69
|
+
as_of: '2026-09-12',
|
|
70
|
+
};
|
|
71
|
+
const FLIGHT_NEGATIVE = {
|
|
72
|
+
schema: BOOKABLE_FACT_SCHEMA,
|
|
73
|
+
fact_id: 'b1b2c3d4e5f60719',
|
|
74
|
+
kind: 'flight',
|
|
75
|
+
route: { origin: 'HKT', destination: 'BKK' },
|
|
76
|
+
date: '2027-07-21',
|
|
77
|
+
flight_no: '',
|
|
78
|
+
tier: 'live_inventory',
|
|
79
|
+
bookability: 'unavailable_exact_date',
|
|
80
|
+
source: 'flyai',
|
|
81
|
+
query_id: 'flyai:flight:HKT-BKK:2027-07-21',
|
|
82
|
+
fetched_at: '2026-09-12T02:12:44.000Z',
|
|
83
|
+
as_of: '2026-09-12',
|
|
84
|
+
review_by: '2027-06-21',
|
|
85
|
+
};
|
|
86
|
+
const TRAIN_UNVERIFIED = {
|
|
87
|
+
schema: BOOKABLE_FACT_SCHEMA,
|
|
88
|
+
fact_id: 'c1b2c3d4e5f60720',
|
|
89
|
+
kind: 'train',
|
|
90
|
+
route: { origin: '广州南', destination: '深圳北' },
|
|
91
|
+
date: '2027-07-16',
|
|
92
|
+
flight_no: 'G6011',
|
|
93
|
+
dep_local: '07:12',
|
|
94
|
+
arr_local: '07:48',
|
|
95
|
+
tier: 'historical_schedule',
|
|
96
|
+
bookability: 'unverified',
|
|
97
|
+
source: 'flyai',
|
|
98
|
+
query_id: 'flyai:train:广州南-深圳北:2027-07-16',
|
|
99
|
+
fetched_at: '2026-09-12T02:00:00.000Z',
|
|
100
|
+
as_of: '2026-08-01',
|
|
101
|
+
};
|
|
102
|
+
const HOTEL_HIT = {
|
|
103
|
+
schema: BOOKABLE_FACT_SCHEMA,
|
|
104
|
+
fact_id: 'd1b2c3d4e5f60721',
|
|
105
|
+
kind: 'hotel',
|
|
106
|
+
destination: '普吉岛',
|
|
107
|
+
check_in: '2027-07-17',
|
|
108
|
+
check_out: '2027-07-21',
|
|
109
|
+
verdict: 'hit',
|
|
110
|
+
bookability: 'bookable_exact_date',
|
|
111
|
+
options_masked: 37,
|
|
112
|
+
source: 'flyai-hotel',
|
|
113
|
+
query_id: 'hotel:flyai-hotel:普吉岛:2027-07-17_2027-07-21',
|
|
114
|
+
fetched_at: '2026-09-12T02:20:00.000Z',
|
|
115
|
+
as_of: '2026-09-12',
|
|
116
|
+
tier: 'live_inventory',
|
|
117
|
+
};
|
|
118
|
+
const HOTEL_MISS = {
|
|
119
|
+
schema: BOOKABLE_FACT_SCHEMA,
|
|
120
|
+
fact_id: 'e1b2c3d4e5f60722',
|
|
121
|
+
kind: 'hotel',
|
|
122
|
+
destination: '甲米',
|
|
123
|
+
check_in: '2027-07-21',
|
|
124
|
+
check_out: '2027-07-23',
|
|
125
|
+
verdict: 'miss',
|
|
126
|
+
bookability: 'unavailable_exact_date',
|
|
127
|
+
options_masked: 0,
|
|
128
|
+
source: 'flyai-hotel',
|
|
129
|
+
query_id: 'hotel:flyai-hotel:甲米:2027-07-21_2027-07-23',
|
|
130
|
+
fetched_at: '2026-09-12T02:22:00.000Z',
|
|
131
|
+
as_of: '2026-09-12',
|
|
132
|
+
tier: 'live_inventory',
|
|
133
|
+
};
|
|
134
|
+
const POLICY_PLAN = Object.assign({
|
|
135
|
+
schema: BOOKABLE_FACT_SCHEMA,
|
|
136
|
+
fact_id: 'f1b2c3d4e5f60723',
|
|
137
|
+
kind: 'policy',
|
|
138
|
+
subject: '泰国免签',
|
|
139
|
+
statement: '中国护照可免签入境停留不超过 30 天(以落地执行口径为准)',
|
|
140
|
+
source: 'flyai',
|
|
141
|
+
query_id: 'flyai:policy:泰国免签',
|
|
142
|
+
fetched_at: '2026-09-12T02:30:00.000Z',
|
|
143
|
+
as_of: '2026-09-12',
|
|
144
|
+
review_by: '2027-06-17',
|
|
145
|
+
}, { runtime: { is_plan: true } });
|
|
146
|
+
const FACTS = [FLIGHT_HIT, FLIGHT_NEGATIVE, TRAIN_UNVERIFIED, HOTEL_HIT, HOTEL_MISS, POLICY_PLAN];
|
|
147
|
+
function completeInput(overrides = {}) {
|
|
148
|
+
return {
|
|
149
|
+
title: '合成行程:深圳 → 普吉 → 甲米 → 曼谷',
|
|
150
|
+
itinerary: {
|
|
151
|
+
trip_start: '2027-07-16',
|
|
152
|
+
trip_end: '2027-07-24',
|
|
153
|
+
stays: [
|
|
154
|
+
{ place: '普吉岛', check_in: '2027-07-17', check_out: '2027-07-21' },
|
|
155
|
+
{ place: '甲米', check_in: '2027-07-21', check_out: '2027-07-23' },
|
|
156
|
+
],
|
|
157
|
+
od_segments: [
|
|
158
|
+
{ from: '广州南', to: '深圳北', date: '2027-07-16', mode: 'rail', legs: 1 },
|
|
159
|
+
{ from: 'SZX', to: 'HKT', date: '2027-07-17', mode: 'flight', legs: 1 },
|
|
160
|
+
{ from: 'HKT', to: 'BKK', date: '2027-07-21', mode: 'flight', legs: 2 },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
facts: FACTS,
|
|
164
|
+
...overrides,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
// §1 完整行程:deck 形态契约 + 证据面语义与单页文档一致
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
{
|
|
171
|
+
const html = assertRendered(renderItineraryDeck(completeInput()), '§1 完整合成行程渲染成功');
|
|
172
|
+
assert(html.startsWith('<!DOCTYPE html>\n<html lang="zh-CN">'), '§1a 输出为完整独立文档(DOCTYPE + lang)');
|
|
173
|
+
assert(!/<script/i.test(html) && !/<iframe/i.test(html), '§1b 产物不含 script/iframe(零脚本翻页)');
|
|
174
|
+
assert(!/\son[a-z]+\s*=/i.test(html), '§1c 产物不含内联事件处理器');
|
|
175
|
+
assert(!/https?:\/\//i.test(html) && !/<link/i.test(html) && !/@import/i.test(html) && !/url\(/i.test(html), '§1d 产物无远端依赖(无 http/link/@import/url())');
|
|
176
|
+
assert(html.includes('html{scroll-snap-type:y proximity}') && html.includes('scroll-snap-align:start'), '§1e 纯 CSS scroll-snap 翻页(proximity:超长页不卡死滚动)');
|
|
177
|
+
assert(html.includes('counter-reset:slide') && html.includes('counter-increment:slide')
|
|
178
|
+
&& html.includes('content:"第 " counter(slide) " 页"'), '§1f 页码用 CSS counter 渲染(零脚本计数)');
|
|
179
|
+
assert(html.includes('@media print') && html.includes('page-break-after:always'), '§1g 打印时一页一张幻灯');
|
|
180
|
+
assert(html.includes('<style>') && html.includes('@media (max-width:480px)'), '§1h 样式自包含且含窄屏断点');
|
|
181
|
+
assert(html.includes('<a class="skip" href="#slide-cover">'), '§1i 提供跳转封面链接(键盘可达)');
|
|
182
|
+
// 页结构确定性派生:封面/按日期/3 段/2 住宿/住宿证据/政策/证据附录/航班事实 = 11 页
|
|
183
|
+
assert(countOf(html, '<section class="slide') === 11, `§1j 幻灯页数确定性派生(实测 ${countOf(html, '<section class="slide')} 页,期望 11)`);
|
|
184
|
+
for (const id of ['slide-cover', 'slide-overview', 'slide-seg-1', 'slide-seg-2', 'slide-seg-3',
|
|
185
|
+
'slide-stay-1', 'slide-stay-2', 'slide-hotel-evidence', 'slide-policy', 'slide-leftovers', 'slide-flights']) {
|
|
186
|
+
assert(html.includes(`id="${id}"`), `§1k 幻灯锚点齐全(${id})`);
|
|
187
|
+
}
|
|
188
|
+
// 导航是组级锚点,且每个 href 目标真实存在
|
|
189
|
+
const nav = html.slice(html.indexOf('<nav class="deck-nav"'), html.indexOf('</nav>'));
|
|
190
|
+
for (const label of ['封面', '按日期', '交通段', '住宿', '住宿证据', '政策', '证据附录', '航班/车次事实']) {
|
|
191
|
+
assert(nav.includes(`>${label}</a>`), `§1l deck 导航含「${label}」组锚点`);
|
|
192
|
+
}
|
|
193
|
+
for (const href of [...nav.matchAll(/href="#(slide-[a-z-]+)"/g)].map(m => m[1])) {
|
|
194
|
+
assert(html.includes(`id="${href}"`), `§1m 导航目标 ${href} 真实存在`);
|
|
195
|
+
}
|
|
196
|
+
// 封面:双面声明 + 证据边界 + 事实计数,与单页文档同一句话
|
|
197
|
+
assert(html.includes('计划面(明示日期与段落)与证据面(已注册事实)分开陈述') && html.includes('本文档不给出整体「已验证」结论'), '§1n 封面带双面声明(共享层同一文案)');
|
|
198
|
+
assert(html.includes('本文档只投影调用方给出的显式行程与已注册事实') && html.includes('不做夜数/预算/时间运算'), '§1o 封面带证据边界声明(共享层同一文案)');
|
|
199
|
+
assert(html.includes('共 6 条事实(航班/车次 3,酒店 2,政策 1)'), '§1p 封面事实计数如实分解');
|
|
200
|
+
// 每段/每住宿一页,计划卡内证据语义与单页文档一致
|
|
201
|
+
assert(html.includes('铁路 广州南 → 深圳北 2027-07-16') && html.includes('该段可回溯的事实(独立于计划段)'), '§1q 交通段页带计划卡与可回溯事实');
|
|
202
|
+
assert(html.includes('计划住宿:普吉岛 2027-07-17→2027-07-21') && html.includes('该目的地 + 该档期另有 1 条'), '§1r 住宿页带计划卡与独立证据指针');
|
|
203
|
+
assert(html.includes('独立记录:目的地级酒店事实'), '§1s 住宿证据页保留独立记录区');
|
|
204
|
+
assert(html.includes('政政策事实'.slice(1)) || html.includes('政策事实'), '§1t 政策页单独成页');
|
|
205
|
+
// 证据字段逐条保留:canonical 原文必须随产物输出(按 HTML 文本转义后逐字可回读)
|
|
206
|
+
for (const f of FACTS) {
|
|
207
|
+
const canonical = f.kind === 'hotel' ? renderHotelFact(f) : f.kind === 'policy' ? renderPolicyFact(f) : renderFlightFact(f);
|
|
208
|
+
assert(html.includes(canonical.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''')), `§1u 事实 ${f.fact_id} 的 canonical 原文随产物输出(可回溯)`);
|
|
209
|
+
}
|
|
210
|
+
assert(html.includes('bookable_exact_date') && html.includes('unavailable_exact_date') && html.includes('unverified'), '§1v 三条不同 bookability 原样保留(不合并、不提升)');
|
|
211
|
+
assert(html.includes('[session:ctrip-flight]') && html.includes('[flyai-hotel]'), '§1w 来源标识保留');
|
|
212
|
+
assert(html.includes('该档期无结果') && html.includes('未核验'), '§1x 负事实/未核验显式渲染');
|
|
213
|
+
assert(html.includes('标注为「计划」意图'), '§1y runtime.is_plan 不升级为现行政策');
|
|
214
|
+
// 无整体 verified 徽章 / 无预算夜数
|
|
215
|
+
assert(!html.includes('全部已核验') && !html.includes('整体已核验') && !html.includes('整体可订')
|
|
216
|
+
&& !html.includes('badge ok">整体'), '§1z 产物不含整体核验/可订徽章');
|
|
217
|
+
assert(!/\d+\s*天\s*\d+\s*晚/.test(html) && !/共\s*\d+\s*天/.test(html) && !/总预算|预算合计/.test(html), '§1aa 产物无天数/预算合计');
|
|
218
|
+
}
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
// §2 部分行程:空段/空住宿/无政策时页结构如实收缩,不伪造内容
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
{
|
|
223
|
+
const partial = {
|
|
224
|
+
title: '部分行程:只有日期窗',
|
|
225
|
+
itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-16', stays: [], od_segments: [] },
|
|
226
|
+
facts: [],
|
|
227
|
+
};
|
|
228
|
+
const html = assertRendered(renderItineraryDeck(partial), '§2 部分行程(单日窗、零段零住宿零事实)渲染成功');
|
|
229
|
+
assert(countOf(html, '<section class="slide') === 5, `§2a 无段无住宿无政策:封面/按日期/住宿证据/证据附录/航班事实(实测 ${countOf(html, '<section class="slide')} 页,期望 5)`);
|
|
230
|
+
assert(!html.includes('id="slide-seg-1"') && !html.includes('id="slide-stay-1"') && !html.includes('id="slide-policy"'), '§2b 无内容则不生成对应页(导航也随之收缩)');
|
|
231
|
+
assert(html.includes('没有显式日期条目'), '§2c 空日期页显式说明,不合成日历日');
|
|
232
|
+
assert(html.includes('本次输入没有酒店事实') && html.includes('本次输入没有航班/车次事实'), '§2d 空证据页各自成状态');
|
|
233
|
+
assert(html.includes('共 0 条事实(航班/车次 0,酒店 0,政策 0)'), '§2e 零事实计数如实呈现');
|
|
234
|
+
assert(!html.includes('>交通段</a>') && !html.includes('>住宿</a>') && !html.includes('>政策</a>'), '§2f 导航不指向不存在的页');
|
|
235
|
+
const segOnly = {
|
|
236
|
+
title: '部分行程:只给一段',
|
|
237
|
+
itinerary: {
|
|
238
|
+
trip_start: '2027-07-16',
|
|
239
|
+
trip_end: '2027-07-20',
|
|
240
|
+
stays: [],
|
|
241
|
+
od_segments: [{ from: 'SZX', to: 'HKT', date: '2027-07-17', mode: 'flight', legs: 1 }],
|
|
242
|
+
},
|
|
243
|
+
facts: [],
|
|
244
|
+
};
|
|
245
|
+
const segHtml = assertRendered(renderItineraryDeck(segOnly), '§2g 只有交通段的行程渲染成功');
|
|
246
|
+
assert(segHtml.includes('id="slide-seg-1"') && segHtml.includes('交通段 1/1'), '§2h 段页计数如实(1/1)');
|
|
247
|
+
assert(segHtml.includes('该段没有匹配的已注册事实'), '§2i 计划段无证据时显式标注未核验');
|
|
248
|
+
}
|
|
249
|
+
// ---------------------------------------------------------------------------
|
|
250
|
+
// §3 未知不被升级(语义与单页文档同源)
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
{
|
|
253
|
+
const unknownTier = { ...FLIGHT_HIT, fact_id: 'aaaa0000bbbb1111', tier: 'route_exists', bookability: 'unverified' };
|
|
254
|
+
const html = assertRendered(renderItineraryDeck({ ...completeInput(), facts: [unknownTier] }), '§3 仅含未核验事实的输入渲染成功');
|
|
255
|
+
assert(html.includes('route_exists(仅航线存在)') && html.includes('unverified(未核验)'), '§3a 弱证据层原样展示');
|
|
256
|
+
assert(!html.includes('该档期可下单'), '§3b 未核验事实不得到可下单措辞');
|
|
257
|
+
const staleBenchmark = { ...FLIGHT_HIT, fact_id: 'cccc0000dddd2222', tier: 'benchmark_price', bookability: 'conflict', price: undefined, currency: undefined };
|
|
258
|
+
const staleHtml = assertRendered(renderItineraryDeck({ ...completeInput(), facts: [staleBenchmark] }), '§3c 冲突事实渲染成功');
|
|
259
|
+
assert(staleHtml.includes('conflict(两源冲突)'), '§3d 冲突状态原样展示');
|
|
260
|
+
assert(!staleHtml.includes('¥undefined') && !staleHtml.includes('¥NaN'), '§3e 不产生 NaN/undefined 价格');
|
|
261
|
+
const destinationOnly = assertRendered(renderItineraryDeck({ ...completeInput(), facts: [HOTEL_HIT] }), '§3f 只有目的地级酒店事实的输入渲染成功');
|
|
262
|
+
assert(destinationOnly.includes('不是本条目这家酒店的房型/报价'), '§3g 明确否定「目的地级 = 某家酒店」的等价');
|
|
263
|
+
const staySlide = destinationOnly.slice(destinationOnly.indexOf('id="slide-stay-1"'), destinationOnly.indexOf('id="slide-hotel-evidence"'));
|
|
264
|
+
assert(!staySlide.includes('住宿已核验') && !staySlide.includes('<pre'), '§3h 目的地级命中不得写成计划住宿的核验结论');
|
|
265
|
+
}
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
// §4 恶意 HTML:转义而非拒绝
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
{
|
|
270
|
+
const hostileTitle = '<script>alert(1)</script><img src=x onerror="fetch(\'http://evil\')">';
|
|
271
|
+
const hostilePlace = '"><iframe src="javascript:alert(2)"></iframe>';
|
|
272
|
+
const hostileFacts = [
|
|
273
|
+
{ ...FLIGHT_HIT, fact_id: '1111222233334444', marketing_carrier: '</summary><script>alert(3)</script>' },
|
|
274
|
+
{ ...HOTEL_HIT, fact_id: '5555666677778888', destination: hostilePlace },
|
|
275
|
+
{ ...POLICY_PLAN, fact_id: '99990000aaaabbbb', statement: '<b>加粗</b> & <svg onload=alert(4)>' },
|
|
276
|
+
];
|
|
277
|
+
const hostileInput = {
|
|
278
|
+
title: hostileTitle,
|
|
279
|
+
itinerary: {
|
|
280
|
+
trip_start: '2027-07-16',
|
|
281
|
+
trip_end: '2027-07-24',
|
|
282
|
+
stays: [{ place: hostilePlace, check_in: '2027-07-17', check_out: '2027-07-21' }],
|
|
283
|
+
od_segments: [{ from: '<em>SZX</em>', to: 'HKT">', date: '2027-07-17', mode: 'flight', legs: 1 }],
|
|
284
|
+
},
|
|
285
|
+
facts: hostileFacts,
|
|
286
|
+
};
|
|
287
|
+
const html = assertRendered(renderItineraryDeck(hostileInput), '§4 恶意 HTML 输入仍渲染(转义而非执行)');
|
|
288
|
+
assert(!html.includes('<script'), '§4a 无未转义 <script');
|
|
289
|
+
assert(!html.includes('<iframe'), '§4b 无未转义 <iframe');
|
|
290
|
+
assert(!/<svg/i.test(html) && !html.includes('<b>') && html.includes('<b>加粗</b>'), '§4c 事实文本中的标签被转义');
|
|
291
|
+
assert(!/<[a-zA-Z][^>]*\son[a-z]+\s*=/i.test(html), '§4d 标签内无未转义事件处理器');
|
|
292
|
+
assert(html.includes('<script>alert(1)</script>'), '§4e 标题中的脚本按实体转义');
|
|
293
|
+
assert(html.includes('"><iframe'), '§4f 属性位置的双引号被转义(不能逃出属性)');
|
|
294
|
+
assert(html.includes('<em>SZX</em>'), '§4g 段起点的标签被转义');
|
|
295
|
+
assert(countOf(html, '<section class="slide') === countOf(html, '</section>'), '§4h 恶意输入未破坏幻灯配对');
|
|
296
|
+
assert(!/(?:href|src)\s*=\s*"?javascript:/i.test(html), '§4i javascript: 载荷不构成可执行链接');
|
|
297
|
+
}
|
|
298
|
+
// ---------------------------------------------------------------------------
|
|
299
|
+
// §5 拒绝集与反漂移锁:同一输入下 HTML 与 deck 的拒绝结果逐字一致
|
|
300
|
+
// ---------------------------------------------------------------------------
|
|
301
|
+
{
|
|
302
|
+
const cases = [
|
|
303
|
+
['§5a 非对象', 'not-an-object', 'input 必须是对象'],
|
|
304
|
+
['§5b null', null, 'input 必须是对象'],
|
|
305
|
+
['§5c 缺 title', { itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-20', stays: [], od_segments: [] }, facts: [] }, 'title 必须是字符串'],
|
|
306
|
+
['§5d 空 title', completeInput({ title: '' }), 'title 不能为空'],
|
|
307
|
+
['§5e 缺 itinerary', { title: 't', facts: [] }, 'itinerary 必须是对象'],
|
|
308
|
+
['§5f stays 非数组', completeInput({ itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-20', stays: 'x', od_segments: [] } }), 'itinerary.stays 必须是数组'],
|
|
309
|
+
['§5g facts 非数组', completeInput({ facts: {} }), 'facts 必须是数组'],
|
|
310
|
+
['§5h 缺 facts', { title: 't', itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-20', stays: [], od_segments: [] } }, 'facts 必须是数组'],
|
|
311
|
+
['§5i 非法 mode', completeInput({ itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-20', stays: [], od_segments: [{ from: 'A', to: 'B', date: '2027-07-17', mode: 'teleport', legs: 1 }] } }), 'itinerary.od_segments[0].mode 不是受支持取值'],
|
|
312
|
+
['§5j 非法 bookability', completeInput({ facts: [{ ...FLIGHT_HIT, bookability: 'verified' }] }), 'facts[0].bookability 不是受支持取值'],
|
|
313
|
+
['§5k 非法 tier', completeInput({ facts: [{ ...FLIGHT_HIT, tier: 'maybe' }] }), 'facts[0].tier 不是受支持取值'],
|
|
314
|
+
['§5l 非法事实 schema', completeInput({ facts: [{ ...FLIGHT_HIT, schema: 'gotry_bookable_fact.v2' }] }), 'facts[0].schema 不是受支持的事实 schema'],
|
|
315
|
+
['§5m 非法事实 kind', completeInput({ facts: [{ ...FLIGHT_HIT, kind: 'ferry' }] }), 'facts[0].kind 不是受支持的事实类型'],
|
|
316
|
+
// 日期边界与格式
|
|
317
|
+
['§5n1 2 月 30 日', completeInput({ itinerary: { trip_start: '2027-02-30', trip_end: '2027-07-24', stays: [], od_segments: [] } }), 'itinerary.trip_start 不是真实日历日期'],
|
|
318
|
+
['§5n2 非闰年 2 月 29', completeInput({ itinerary: { trip_start: '2027-02-29', trip_end: '2027-07-24', stays: [], od_segments: [] } }), 'itinerary.trip_start 不是真实日历日期'],
|
|
319
|
+
['§5n3 13 月', completeInput({ itinerary: { trip_start: '2027-13-01', trip_end: '2027-07-24', stays: [], od_segments: [] } }), 'itinerary.trip_start 不是真实日历日期'],
|
|
320
|
+
['§5n4 越界年', completeInput({ itinerary: { trip_start: '1999-12-31', trip_end: '2027-07-24', stays: [], od_segments: [] } }), 'itinerary.trip_start 不是真实日历日期'],
|
|
321
|
+
['§5n5 非法日期格式', completeInput({ itinerary: { trip_start: '2027/07/16', trip_end: '2027-07-24', stays: [], od_segments: [] } }), 'itinerary.trip_start 不是真实日历日期'],
|
|
322
|
+
['§5n6 时间串当日期', completeInput({ itinerary: { trip_start: '2027-07-16T00:00:00Z', trip_end: '2027-07-24', stays: [], od_segments: [] } }), 'itinerary.trip_start 不是真实日历日期'],
|
|
323
|
+
// 时间戳与时刻
|
|
324
|
+
['§5o1 fetched_at 非法日历', completeInput({ facts: [{ ...FLIGHT_HIT, fetched_at: '2027-06-31T00:00:00Z' }] }), 'facts[0].fetched_at 必须是可解析的 ISO 时间戳'],
|
|
325
|
+
['§5o2 fetched_at 缺时分秒', completeInput({ facts: [{ ...FLIGHT_HIT, fetched_at: '2026-09-12' }] }), 'facts[0].fetched_at 必须是可解析的 ISO 时间戳'],
|
|
326
|
+
['§5o3 as_of 非法', completeInput({ facts: [{ ...FLIGHT_HIT, as_of: '2026-13-01' }] }), 'facts[0].as_of 必须是真实日历日期'],
|
|
327
|
+
['§5o4 dep_local 非法 HH:MM', completeInput({ facts: [{ ...FLIGHT_HIT, dep_local: '25:00' }] }), 'facts[0].dep_local 必须是 HH:MM'],
|
|
328
|
+
['§5o5 review_by 非法', completeInput({ facts: [{ ...FLIGHT_HIT, review_by: '2027-02-30' }] }), 'facts[0].review_by 必须是真实日历日期'],
|
|
329
|
+
// 数值边界
|
|
330
|
+
['§5p1 无限价格', completeInput({ facts: [{ ...FLIGHT_HIT, price: Number.POSITIVE_INFINITY }] }), 'facts[0].price 必须是有限数值'],
|
|
331
|
+
['§5p2 负价格', completeInput({ facts: [{ ...FLIGHT_HIT, price: -1 }] }), 'facts[0].price 超出允许范围'],
|
|
332
|
+
['§5p3 非整数在架家数', completeInput({ facts: [{ ...HOTEL_HIT, options_masked: 1.5 }] }), 'facts[0].options_masked 必须是整数'],
|
|
333
|
+
['§5p4 负在架', completeInput({ facts: [{ ...HOTEL_HIT, options_masked: -3 }] }), 'facts[0].options_masked 超出允许范围'],
|
|
334
|
+
['§5p5 legs=0', completeInput({ itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-24', stays: [], od_segments: [{ from: 'A', to: 'B', date: '2027-07-17', mode: 'car', legs: 0 }] } }), 'itinerary.od_segments[0].legs 超出允许范围'],
|
|
335
|
+
['§5p6 非整数 legs', completeInput({ itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-24', stays: [], od_segments: [{ from: 'A', to: 'B', date: '2027-07-17', mode: 'car', legs: 1.5 }] } }), 'itinerary.od_segments[0].legs 必须是整数'],
|
|
336
|
+
// 容量与长度上限
|
|
337
|
+
['§5q1 超量住宿', completeInput({ itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-24', stays: Array.from({ length: ITINERARY_DOC_LIMITS.stays + 1 }, () => ({ place: 'P', check_in: '2027-07-17', check_out: '2027-07-18' })), od_segments: [] } }), `itinerary.stays 超出容量上限(${ITINERARY_DOC_LIMITS.stays} 条`],
|
|
338
|
+
['§5q2 超量事实', completeInput({ facts: Array.from({ length: ITINERARY_DOC_LIMITS.facts + 1 }, (_v, i) => ({ ...FLIGHT_HIT, fact_id: `f${String(i).padStart(15, '0')}` })) }), `facts 超出容量上限(${ITINERARY_DOC_LIMITS.facts} 条`],
|
|
339
|
+
['§5q3 超长 title', completeInput({ title: 'x'.repeat(ITINERARY_DOC_LIMITS.titleChars + 1) }), 'title 超出长度上限'],
|
|
340
|
+
['§5q4 超长城市名', completeInput({ itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-24', stays: [], od_segments: [{ from: 'x'.repeat(ITINERARY_DOC_LIMITS.fromToChars + 1), to: 'B', date: '2027-07-17', mode: 'car', legs: 1 }] } }), 'itinerary.od_segments[0].from 超出长度上限'],
|
|
341
|
+
['§5q5 超长政策陈述', completeInput({ facts: [{ ...POLICY_PLAN, statement: 'x'.repeat(ITINERARY_DOC_LIMITS.statementChars + 1) }] }), 'facts[0].statement 超出长度上限'],
|
|
342
|
+
// 逻辑矛盾
|
|
343
|
+
['§5r1 行程窗倒置', completeInput({ itinerary: { trip_start: '2027-07-24', trip_end: '2027-07-16', stays: [], od_segments: [] } }), 'itinerary.trip_end 早于 trip_start'],
|
|
344
|
+
['§5r2 零夜住宿', completeInput({ itinerary: { trip_start: '2027-07-16', trip_end: '2027-07-24', stays: [{ place: 'P', check_in: '2027-07-20', check_out: '2027-07-20' }], od_segments: [] } }), '退房日期不晚于入住日期'],
|
|
345
|
+
['§5r3 可下单事实缺班次号', completeInput({ facts: [{ ...FLIGHT_HIT, bookability: 'bookable_exact_date', flight_no: '' }] }), 'facts[0].flight_no 缺失'],
|
|
346
|
+
['§5r4 空出发地', completeInput({ facts: [{ ...FLIGHT_HIT, route: { origin: '', destination: 'HKT' } }] }), 'facts[0].route.origin 不能为空'],
|
|
347
|
+
];
|
|
348
|
+
for (const [label, input, needle] of cases) {
|
|
349
|
+
const deck = renderItineraryDeck(input);
|
|
350
|
+
assertRejected(deck, needle, label);
|
|
351
|
+
// 反漂移锁:同一输入,两个投影的 errors 逐字一致
|
|
352
|
+
const doc = renderItineraryHtml(input);
|
|
353
|
+
assert(doc.ok === deck.ok, `${label}(html.ok=${doc.ok} 与 deck.ok=${deck.ok} 必须一致)`);
|
|
354
|
+
if (!doc.ok && !deck.ok) {
|
|
355
|
+
assert(JSON.stringify(doc.errors) === JSON.stringify(deck.errors), `${label}(errors 数组必须逐字一致)`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// 噪音输入:错误条数有界 + 不回显原始输入
|
|
359
|
+
const noisy = completeInput({
|
|
360
|
+
itinerary: { trip_start: 'bad', trip_end: 'bad', stays: 'x', od_segments: 'y' },
|
|
361
|
+
facts: Array.from({ length: ITINERARY_DOC_LIMITS.facts }, () => ({ kind: 'ferry', schema: 'nope' })),
|
|
362
|
+
});
|
|
363
|
+
const noisyResult = renderItineraryDeck(noisy);
|
|
364
|
+
assert(!noisyResult.ok && noisyResult.errors.length <= ITINERARY_DOC_LIMITS.errors + 1, '§5u errors 条数有界');
|
|
365
|
+
if (!noisyResult.ok) {
|
|
366
|
+
assert(noisyResult.errors.every(e => !e.includes('nope')), '§5v 错误信息不回显原始输入内容');
|
|
367
|
+
const noisyDoc = renderItineraryHtml(noisy);
|
|
368
|
+
assert(!noisyDoc.ok && JSON.stringify(noisyDoc.errors) === JSON.stringify(noisyResult.errors), '§5w 噪音输入的 errors 两投影逐字一致');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// ---------------------------------------------------------------------------
|
|
372
|
+
// §6 无隐式借道:渲染器与共享契约层都不引入 IO/时间/子进程;deck 切片自含纯度证据
|
|
373
|
+
// ---------------------------------------------------------------------------
|
|
374
|
+
{
|
|
375
|
+
const readSource = (name) => import('node:fs/promises').then(fs => fs.readFile(new URL(name, import.meta.url), 'utf8'));
|
|
376
|
+
const source = await readSource('../src/itinerary-deck.js');
|
|
377
|
+
const shared = await readSource('../src/itinerary-doc-shared.js');
|
|
378
|
+
// issue #564 共享契约层是本切片的事实源:deck 套件独立证明它的纯度(不只依赖 html §6c)
|
|
379
|
+
for (const [label, src] of [['itinerary-deck', source], ['itinerary-doc-shared', shared]]) {
|
|
380
|
+
assert(!/from\s+'node:(fs|child_process|net|http|https|dns|worker_threads)'/.test(src), `§6a ${label} 不 import IO/子进程/网络模块`);
|
|
381
|
+
assert(!/\bDate\.now\b/.test(src) && !/new Date\(\s*\)/.test(src), `§6b ${label} 无当前时间依赖(纯函数)`);
|
|
382
|
+
assert(!/from\s+'\.\/(engine|journey)\.ts'/.test(src), `§6c ${label} 不 import 已弃用引擎层`);
|
|
383
|
+
assert(!/dangerouslySetInnerHTML|innerHTML|document\.write|eval\(/.test(src), `§6d ${label} 无 DOM 注入/求值原语`);
|
|
384
|
+
assert(!/fetch\(|XMLHttpRequest|WebSocket/.test(src), `§6e ${label} 无网络调用`);
|
|
385
|
+
}
|
|
386
|
+
assert(/from '\.\/itinerary-doc-shared\.ts'/.test(source), '§6f deck 仅依赖共享契约层的事实源(无第二实现)');
|
|
387
|
+
assert(/from '\.\/bookable-facts\.ts'/.test(shared), '§6g 共享契约层复用既有事实类型与 canonical 渲染原语');
|
|
388
|
+
}
|
|
389
|
+
// ---------------------------------------------------------------------------
|
|
390
|
+
// §7 逐字节确定性 + 文档大小硬上限
|
|
391
|
+
// ---------------------------------------------------------------------------
|
|
392
|
+
{
|
|
393
|
+
const first = renderItineraryDeck(completeInput());
|
|
394
|
+
const second = renderItineraryDeck(completeInput());
|
|
395
|
+
assert(first.ok && second.ok && first.html === second.html, '§7a 同输入两次渲染逐字节一致');
|
|
396
|
+
const docResult = renderItineraryHtml(completeInput());
|
|
397
|
+
assert(first.ok && docResult.ok && first.html !== docResult.html, '§7b deck 与单页文档是两种投影(deck ≠ 单页输出)');
|
|
398
|
+
assert(first.ok && first.html.length > 0, '§7c 产物非空');
|
|
399
|
+
// 文档大小:合法但庞大的输入必须整体失败,而不是截断(与单页文档同一上限)
|
|
400
|
+
const hugeFacts = Array.from({ length: ITINERARY_DOC_LIMITS.facts }, (_v, i) => ({
|
|
401
|
+
...POLICY_PLAN,
|
|
402
|
+
fact_id: `g${String(i).padStart(15, '0')}`,
|
|
403
|
+
statement: 'y'.repeat(2000),
|
|
404
|
+
}));
|
|
405
|
+
const hugeDeck = renderItineraryDeck(completeInput({ facts: hugeFacts }));
|
|
406
|
+
assertRejected(hugeDeck, '渲染文档超出大小上限', '§7d 超文档大小整体失败');
|
|
407
|
+
const hugeDoc = renderItineraryHtml(completeInput({ facts: hugeFacts }));
|
|
408
|
+
if (!hugeDeck.ok && !hugeDoc.ok) {
|
|
409
|
+
assert(hugeDeck.errors.length === 1, '§7e 超大小只有一条明确错误');
|
|
410
|
+
assert(JSON.stringify(hugeDoc.errors) === JSON.stringify(hugeDeck.errors), '§7f 超大小错误两投影逐字一致');
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
assert(false, '§7d/e/f 超大输入必须两个投影同时失败(实测 deck.ok 与 doc.ok 均应为 false)');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
// ---------------------------------------------------------------------------
|
|
417
|
+
// §8 根审反例回归:同目的地异档期事实不得挂到计划住宿(语义与单页文档同源)
|
|
418
|
+
// ---------------------------------------------------------------------------
|
|
419
|
+
{
|
|
420
|
+
const otherWindow = { ...HOTEL_HIT, fact_id: 'aaaa1111bbbb2222', check_in: '2028-01-01', check_out: '2028-01-02' };
|
|
421
|
+
const noWindow = { ...HOTEL_HIT, fact_id: 'cccc3333dddd4444', check_in: undefined, check_out: undefined };
|
|
422
|
+
const html = assertRendered(renderItineraryDeck({ ...completeInput(), facts: [otherWindow, noWindow] }), '§8 同目的地异档期 / 缺档期酒店事实仍渲染成功');
|
|
423
|
+
const staySlide = html.slice(html.indexOf('id="slide-stay-1"'), html.indexOf('id="slide-stay-2"'));
|
|
424
|
+
assert(staySlide.includes('该计划住宿没有对应的酒店档期事实'), '§8a 异档期事实不得宣称是该计划住宿的同档期证据');
|
|
425
|
+
assert(!staySlide.includes('aaaa1111bbbb2222') && !staySlide.includes('cccc3333dddd4444'), '§8b 异档期/缺档期事实 id 不得出现在计划住宿卡内');
|
|
426
|
+
const evidence = html.slice(html.indexOf('id="slide-hotel-evidence"'));
|
|
427
|
+
assert(evidence.includes('aaaa1111bbbb2222') && evidence.includes('cccc3333dddd4444'), '§8c 异档期/缺档期事实仍留在独立证据区(不被丢弃也不被改写)');
|
|
428
|
+
}
|
|
429
|
+
console.log(`\nITINERARY DECK TESTS: ${pass} pass, ${fail} fail`);
|
|
430
|
+
if (fail > 0) {
|
|
431
|
+
console.log('\nFAILURES:');
|
|
432
|
+
for (const f of failures)
|
|
433
|
+
console.log(` - ${f}`);
|
|
434
|
+
process.exit(1);
|
|
435
|
+
}
|