@danceiny/gotry 0.0.1-rc.8 → 0.2.0-rc.27
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 -217
- 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 +1744 -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 -49
- 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 +135 -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 +546 -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 +968 -0
- package/dist/capabilities/fx-contract.js +293 -0
- package/dist/capabilities/geo-atlas.js +246 -0
- package/dist/capabilities/ground-transfer.js +509 -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/resilience.js +191 -0
- package/dist/capabilities/session/action-cache.js +126 -0
- package/dist/capabilities/session/adapters/ctrip-flight.js +141 -0
- 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 +54 -0
- 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 +50 -0
- 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 +107 -0
- package/dist/capabilities/session/static-flight-golden.js +150 -0
- package/dist/capabilities/session/transport.js +109 -0
- 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 +686 -0
- 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 +72 -0
- 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-tests.js +116 -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 +68 -10
- 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 +123 -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 +1479 -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/companion-tests.js +67 -0
- 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 +564 -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-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 +131 -0
- package/dist/scripts/g5-guard.js +189 -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 +480 -0
- package/dist/scripts/ledger-workflow-crash.js +32 -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 +49 -0
- package/dist/scripts/memory-lifecycle-tests.js +657 -0
- package/dist/scripts/memory-lifecycle.js +196 -0
- package/dist/scripts/memory-metrics.js +29 -31
- 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 +161 -0
- package/dist/scripts/nightly-evidence.js +286 -0
- package/dist/scripts/nudge-digest.js +43 -42
- 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/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 +20 -18
- package/dist/scripts/replay-real.js +18 -18
- package/dist/scripts/replay.js +52 -82
- package/dist/scripts/session-attach-diagnose.js +31 -0
- package/dist/scripts/session-attach-poc.js +62 -0
- 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 +60 -0
- package/dist/scripts/session-link-tests.js +478 -0
- package/dist/scripts/session-login.js +29 -0
- package/dist/scripts/session-tests.js +862 -0
- package/dist/scripts/session-zones-tests.js +358 -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 +703 -219
- package/dist/scripts/spawn-bounded-abort-tests.js +241 -0
- package/dist/scripts/sponsor-reuse-tests.js +262 -0
- package/dist/scripts/state-cli-tests.js +261 -0
- package/dist/scripts/state-cli.js +585 -0
- 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 +210 -192
- package/dist/scripts/travel-timeline-tests.js +59 -0
- 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 +23 -19
- 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 +41 -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/companions.js +86 -0
- package/dist/src/contracts.js +21 -43
- package/dist/src/dsh-llm.js +97 -111
- 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 +2305 -731
- 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 +358 -162
- package/dist/src/memory-capture.js +180 -32
- package/dist/src/memory-decay.js +47 -0
- 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/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-zones.js +507 -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 +767 -0
- 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 +59 -0
- 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 +538 -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 +255 -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 +296 -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 +568 -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 +13 -3
- package/ts/src/dsh-llm.ts +44 -11
- package/ts/src/flyai-setup-tool.ts +77 -0
- package/ts/src/index.ts +2107 -224
- 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 +278 -40
- 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 +912 -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 +360 -89
- package/ts/src/wish-pool.ts +79 -0
|
@@ -1,52 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opensky 能力层测试(免费匿名 API):
|
|
3
|
+
* 1. 真实航班号(可能不是当前在飞)→ 命中时 observed,查空时 not_observed(三值语义)
|
|
4
|
+
* 2. 完全不在飞的小众号 → not_observed
|
|
5
|
+
* 3. 网络超时 → unavailable(降级不抛错)
|
|
6
|
+
* 4. 证据链:各 verdict 正确标注
|
|
7
|
+
*
|
|
8
|
+
* 注:OpenSky 当前 ADS-B 全球观测并非同一时间覆盖所有航班——EK329 一天
|
|
9
|
+
* 飞数十次但中间有「不在飞」的窗口。所以验 not_observed 也是有效路径。
|
|
10
|
+
*
|
|
11
|
+
* 运行: cd ts && npx tsx scripts/opensky-tests.ts
|
|
12
|
+
*/
|
|
1
13
|
import assert from 'node:assert/strict';
|
|
2
14
|
import { verifyFlight } from '../capabilities/opensky.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
15
|
+
// 1. 真实航班号 + 明确目的地机场(机场能筛掉部分不命中)
|
|
16
|
+
// EK329 是 LHR-DXB 路径。观察时段不命中时 verdict='not_observed',不是错误。
|
|
17
|
+
const live = await verifyFlight({ callsign: 'EK329', airport: 'OMDB' });
|
|
7
18
|
assert.ok(live.sampleSize >= 0, 'sampleSize ≥ 0(空数组也合法)');
|
|
8
|
-
assert.ok([
|
|
9
|
-
'observed',
|
|
10
|
-
'not_observed',
|
|
11
|
-
'unavailable'
|
|
12
|
-
].includes(live.verdict), `verdict 三值之一:${live.verdict}`);
|
|
19
|
+
assert.ok(['observed', 'not_observed', 'unavailable'].includes(live.verdict), `verdict 三值之一:${live.verdict}`);
|
|
13
20
|
if (live.verdict === 'observed') {
|
|
14
21
|
assert.ok((live.hits?.length ?? 0) > 0, 'observed 必须配 hits');
|
|
15
22
|
const h = live.hits[0];
|
|
16
23
|
assert.ok(typeof h.icao24 === 'string' && h.icao24.length > 0, 'icao24 存在');
|
|
17
24
|
assert.match(live.evidence, /\[实时API:opensky@/, '证据链标注');
|
|
18
25
|
console.log(`1. EK329 OMDB → ${live.verdict} (sample=${live.sampleSize}, hits=${live.hits?.length}) OK`);
|
|
19
|
-
}
|
|
26
|
+
}
|
|
27
|
+
else if (live.verdict === 'not_observed') {
|
|
20
28
|
assert.match(live.evidence, /○|not_observed|未见/, 'not_observed 标注 ○');
|
|
21
29
|
console.log(`1. EK329 OMDB → not_observed 当前观测窗没飞 (o) OK`);
|
|
22
|
-
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// unavailable = API 限流/不可达,失败也合法
|
|
23
33
|
assert.match(live.evidence, /error/, 'unavailable 标注 error');
|
|
24
34
|
console.log(`1. EK329 OMDB → unavailable (API 异常,降级合法) OK`);
|
|
25
35
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
assert.ok([
|
|
31
|
-
'not_observed',
|
|
32
|
-
'unavailable'
|
|
33
|
-
].includes(fake.verdict), `期望 not_observed/unavailable,实际 ${fake.verdict}`);
|
|
36
|
+
// 2. 完全不存在的航班号 → not_observed 或 unavailable(API 限流 429 时走 unavailable)
|
|
37
|
+
const fake = await verifyFlight({ callsign: 'XXDODO1234', airport: 'OMDB' });
|
|
38
|
+
assert.ok(['not_observed', 'unavailable'].includes(fake.verdict), `期望 not_observed/unavailable,实际 ${fake.verdict}`);
|
|
34
39
|
if (fake.verdict === 'not_observed') {
|
|
35
40
|
assert.match(fake.evidence, /○/, 'not_observed 标 ○');
|
|
36
41
|
console.log('2. XXDODO1234 OMDB → not_observed (○) OK');
|
|
37
|
-
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
38
44
|
console.log('2. XXDODO1234 OMDB → unavailable (API 限流 OK) OK');
|
|
39
45
|
}
|
|
46
|
+
// 3. 网络超时 → unavailable
|
|
40
47
|
import { verifyFlight as vf } from '../capabilities/opensky.js';
|
|
41
|
-
const to = await vf({
|
|
42
|
-
callsign: 'EK329',
|
|
43
|
-
airport: 'OMDB',
|
|
44
|
-
timeoutMs: 1
|
|
45
|
-
});
|
|
48
|
+
const to = await vf({ callsign: 'EK329', airport: 'OMDB', timeoutMs: 1 });
|
|
46
49
|
assert.equal(to.verdict, 'unavailable', `timeout 应 unavailable,实际 ${to.verdict}`);
|
|
47
50
|
assert.match(to.evidence, /error/, 'unavailable 证据带 error');
|
|
48
51
|
console.log('3. timeout → unavailable OK');
|
|
49
52
|
console.log('\nOPEN-SKY TESTS: 3/3 OK(免费匿名 OpenSky API)');
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//# sourceURL=/Users/bytedance/work/gotry/ts/scripts/opensky-tests.ts
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* persona 表层护栏测试(issue #192/#2/#194 回归锚;2026-09-11 契约瘦身改锚,
|
|
3
|
+
* 全离线,只读仓根 patch):
|
|
4
|
+
* 1. (10) 域边界含表层规则句——gotry 能力一律是工具调用,绝不把 gotry_* 传给
|
|
5
|
+
* skill 加载器(dsh skill 面名合法域 ^[a-z0-9]+(-[a-z0-9]+)*$,下划线必抛
|
|
6
|
+
* invalid skill name,rc18 真实用户踩坑);
|
|
7
|
+
* 2. 行为契约 13 条编号完整(2026-09-11 瘦身 23→13,防后续编辑吞条目;窄域
|
|
8
|
+
* 细则归位工具描述/路由卡,persona 只留跨场景行为契约);
|
|
9
|
+
* 3. skill 失败后的行为指引存在(改回 tool call,不换名重试 skill);
|
|
10
|
+
* 4. (4) 候选时段示例枚举绑定锚点卡——澄清卡/访谈/选项不列已过节日
|
|
11
|
+
* (#2 rc18 真实复发:卡把已过的春节/清明/五一当「想用的时候」示例);
|
|
12
|
+
* 5. (13) 后台协作——子任务等待纪律(#194 rc19 实踩:子代理回执 id 不是
|
|
13
|
+
* job id,job_output 轮询子代理 = unknown job 硬错误)+ 永不宣称「工具
|
|
14
|
+
* 预算已耗尽」(ADR-24 v2:唯一边界是运行时时间闸);
|
|
15
|
+
* 6. 动态变量注入面完整——current_date/time_anchor_card/motivation_brief/
|
|
16
|
+
* channel_routing_card 四个引用缺一不可(瘦身不得吞注入面)。
|
|
17
|
+
*
|
|
18
|
+
* 运行: cd ts && npx tsx scripts/persona-surface-guard-tests.ts
|
|
19
|
+
*/
|
|
20
|
+
import assert from 'node:assert/strict';
|
|
21
|
+
import { readFileSync } from 'node:fs';
|
|
22
|
+
import { join } from 'node:path';
|
|
23
|
+
const patch = readFileSync(join(process.cwd(), '..', 'cordis.gotry-patch.yml'), 'utf-8');
|
|
24
|
+
// 1. 表层规则句存在且仅一次
|
|
25
|
+
const guard = '表层规则:gotry 的全部能力一律是【工具调用】';
|
|
26
|
+
assert.equal((patch.match(new RegExp(guard, 'g')) ?? []).length, 1, '表层规则句应恰好出现一次');
|
|
27
|
+
assert.ok(patch.includes('绝不把 gotry_* 名字传给 skill 加载器'), '应显式禁止 gotry_* 进 skill 加载器');
|
|
28
|
+
// 2. 行为契约 13 条编号完整(2026-09-11 瘦身 23→13)
|
|
29
|
+
const markers = new Set([...patch.matchAll(/\((\d{1,2})\)/g)].map((m) => Number(m[1])));
|
|
30
|
+
for (let i = 1; i <= 13; i += 1) {
|
|
31
|
+
assert.ok(markers.has(i), `行为契约 (${i}) 应存在`);
|
|
32
|
+
}
|
|
33
|
+
assert.equal(markers.size, 13, `契约条目应恰为 13 条,实际 ${markers.size}`);
|
|
34
|
+
// 3. skill 用错面后的行为指引
|
|
35
|
+
assert.ok(patch.includes('改回 tool call'), '应指引失败后改回 tool call');
|
|
36
|
+
// 4. #2 复发回归锚:澄清卡示例枚举同样过锚点卡(契约 (4) 内部澄清)
|
|
37
|
+
assert.ok(patch.includes('候选时段示例'), '#2 回归:候选时段示例条款应存在');
|
|
38
|
+
assert.ok(patch.includes('已过的节日不进示例枚举'), '应禁止已过节日进澄清卡示例枚举');
|
|
39
|
+
// 5. #194 回归锚:子任务等待纪律((13) 后台协作)
|
|
40
|
+
assert.ok(patch.includes('(13)后台协作'), '#194 回归:后台协作条款应存在');
|
|
41
|
+
assert.ok(patch.includes('对子代理绝不调用 job_output/job_kill'), '应禁止对子代理调用 job_output/job_kill');
|
|
42
|
+
assert.ok(patch.includes('job_output/job_kill 只用于'), '应限定 job_output/job_kill 的适用面');
|
|
43
|
+
// ADR-24 v2:工具循环唯一边界是运行时时间闸
|
|
44
|
+
assert.ok(patch.includes('工具预算已耗尽'), 'ADR-24 v2:永不宣称工具预算耗尽的指引应存在');
|
|
45
|
+
// 6. 动态变量注入面完整(瘦身不得吞注入面)
|
|
46
|
+
for (const v of ['{{current_date}}', '{{time_anchor_card}}', '{{motivation_brief}}', '{{channel_routing_card}}']) {
|
|
47
|
+
assert.ok(patch.includes(v), `persona 应保留动态变量引用 ${v}`);
|
|
48
|
+
}
|
|
49
|
+
console.log('PERSONA SURFACE GUARD TESTS: 6/6 OK(表层规则句 / 13 条契约完整 / skill 失败行为指引 / 澄清卡示例过锚点卡 / 子任务等待纪律+预算话术 / 动态变量注入面)');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { REQUIRED_BENCHMARK_DSH_VERSION } from '../../bin/gotry-runtime-resolution.js';
|
|
5
|
+
import { parsePnpmDshLock, REQUIRED_DSH_RUNTIME_PACKAGE_COUNT, validateDshRuntimeClosure, } from './dsh-runtime-closure.js';
|
|
6
|
+
const consumerRoot = process.argv[2];
|
|
7
|
+
assert.ok(consumerRoot, 'usage: pnpm-dsh-closure-proof.ts <clean-consumer-root>');
|
|
8
|
+
const installedPackage = JSON.parse(readFileSync(resolve(consumerRoot, 'node_modules/@danceiny/gotry/package.json'), 'utf8'));
|
|
9
|
+
const lockPackages = parsePnpmDshLock(readFileSync(resolve(consumerRoot, 'pnpm-lock.yaml'), 'utf8'));
|
|
10
|
+
const closure = validateDshRuntimeClosure({
|
|
11
|
+
dependencies: installedPackage.dependencies ?? {},
|
|
12
|
+
lockPackages,
|
|
13
|
+
runtimeVersion: REQUIRED_BENCHMARK_DSH_VERSION,
|
|
14
|
+
expectedPackageCount: REQUIRED_DSH_RUNTIME_PACKAGE_COUNT,
|
|
15
|
+
});
|
|
16
|
+
assert.equal(closure.names.length, REQUIRED_DSH_RUNTIME_PACKAGE_COUNT, 'clean pnpm consumer must resolve the complete Round 5 DSH closure');
|
|
17
|
+
console.log(`PNPM DSH CLOSURE PROOF: ${closure.names.length} packages at ${closure.version}`);
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Issue #359 — 政策锚点全字段内容指纹(注册 `gotry_fact_gate` 路径 E2E)。
|
|
3
|
+
*
|
|
4
|
+
* 真实执行面:在临时 stateRoot 下装载 gotry-tools 插件,通过 `apply(ctx, config)`
|
|
5
|
+
* 装载注册定义,捕获 `gotry_fact_gate` 的 execute 函数,以 markdown 直接调用——
|
|
6
|
+
* 经注册的 tool definition 走完 `loadFactRegistry(stateRoot)` → `gateArtifact`
|
|
7
|
+
* → `itinerary.trip_start` 桥接(issue #359 finding 2),完整覆盖公开闸侧路径。
|
|
8
|
+
* 不启动 dsh 宿主、不调用真实 ToolRuntime、不触碰供应商 / browser / policy
|
|
9
|
+
* service / 共享状态。
|
|
10
|
+
*
|
|
11
|
+
* 运行(在 ts/ 下):
|
|
12
|
+
* PATH=/opt/homebrew/opt/node@24/bin:$PATH GOTRY_SESSION_LIVE=0 \
|
|
13
|
+
* npx tsx scripts/policy-anchor-359-registered-e2e.ts
|
|
14
|
+
*/
|
|
15
|
+
import assert from 'node:assert/strict';
|
|
16
|
+
import { mkdtempSync, rmSync, mkdirSync } from 'node:fs';
|
|
17
|
+
import { tmpdir } from 'node:os';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { apply } from '../src/index.js';
|
|
20
|
+
import { BOOKABLE_FACT_SCHEMA, makeFactId, renderPolicyFact, } from '../src/bookable-facts.js';
|
|
21
|
+
import { appendFacts } from '../capabilities/fact-log.js';
|
|
22
|
+
const FETCHED = '2026-09-10T00:00:00.000Z';
|
|
23
|
+
async function main() {
|
|
24
|
+
const home = mkdtempSync(join(tmpdir(), 'gotry-policy-359-registered-'));
|
|
25
|
+
const stateRoot = join(home, 'state');
|
|
26
|
+
const cwd = join(home, 'workspace');
|
|
27
|
+
mkdirSync(stateRoot, { recursive: true });
|
|
28
|
+
mkdirSync(cwd, { recursive: true });
|
|
29
|
+
const policy = {
|
|
30
|
+
schema: BOOKABLE_FACT_SCHEMA,
|
|
31
|
+
fact_id: makeFactId(['policy-359', 'reg', '泰国免签']),
|
|
32
|
+
kind: 'policy',
|
|
33
|
+
subject: '泰国入境(中国护照)',
|
|
34
|
+
statement: '免签停留(口径以泰方公告为准);UAE 居民返程应优先校验 residence visa / Emirates ID 而非游客免签口径',
|
|
35
|
+
source: 'web:official',
|
|
36
|
+
query_id: 'web:policy:泰国免签',
|
|
37
|
+
fetched_at: FETCHED,
|
|
38
|
+
as_of: '2026-08-29',
|
|
39
|
+
};
|
|
40
|
+
// 走真实事实日志路径(append-only JSONL),与产品 gotry_flyai_search /
|
|
41
|
+
// gotry_session_search 同款事实落账接口;闸侧 loadFactRegistry 直接读这里。
|
|
42
|
+
await appendFacts(stateRoot, [policy]);
|
|
43
|
+
// 装载 gotry-tools 插件 → 捕获 gotry_fact_gate 的真实 execute。
|
|
44
|
+
const registered = [];
|
|
45
|
+
const ctx = {
|
|
46
|
+
tools: { register: (t) => registered.push(t) },
|
|
47
|
+
systemPrompt: { section: () => undefined, variable: () => undefined },
|
|
48
|
+
on: () => () => undefined,
|
|
49
|
+
};
|
|
50
|
+
apply(ctx, {
|
|
51
|
+
stateRoot,
|
|
52
|
+
timeoutMs: 30_000,
|
|
53
|
+
hbcliBin: 'hbcli-not-on-path',
|
|
54
|
+
sessionAccess: 'off',
|
|
55
|
+
});
|
|
56
|
+
const factGate = registered.find(t => t.name === 'gotry_fact_gate');
|
|
57
|
+
if (!factGate)
|
|
58
|
+
throw new Error(`FAIL: 注册定义列表缺少 gotry_fact_gate,实际注册: ${registered.map(t => t.name).join(',')}`);
|
|
59
|
+
const exec = { agent: { session: { header: { cwd } } } };
|
|
60
|
+
// Case 1:canonical no-reminder 行经真实 gotry_fact_gate → pass。
|
|
61
|
+
const canonicalLine = renderPolicyFact(policy);
|
|
62
|
+
const c1Artifact = ['## 政策', canonicalLine].join('\n');
|
|
63
|
+
const r1 = await factGate.execute({ markdown: c1Artifact }, exec);
|
|
64
|
+
assert.equal(r1.verdict, 'pass', `canonical no-reminder 经注册闸应 pass,实际: ${JSON.stringify({ verdict: r1.verdict, summary: r1.summary })}`);
|
|
65
|
+
assert.equal(r1.traceable, 1);
|
|
66
|
+
console.log(` ok - 注册 gotry_fact_gate canonical no-reminder → pass`);
|
|
67
|
+
// Case 2:legitimate review_by(事实自带)— 无 trip_start,canonical body 已含复核提醒。
|
|
68
|
+
const reviewByPolicy = { ...policy, fact_id: makeFactId(['policy-359', 'reg', 'review-by']), review_by: '2027-06-16' };
|
|
69
|
+
await appendFacts(stateRoot, [reviewByPolicy]);
|
|
70
|
+
const reviewByLine = renderPolicyFact(reviewByPolicy);
|
|
71
|
+
const r2 = await factGate.execute({ markdown: ['## 政策', reviewByLine].join('\n') }, exec);
|
|
72
|
+
assert.equal(r2.verdict, 'pass', `legitimate review_by 经注册闸应 pass,实际: ${JSON.stringify({ verdict: r2.verdict, summary: r2.summary })}`);
|
|
73
|
+
console.log(` ok - 注册 gotry_fact_gate legitimate review_by → pass`);
|
|
74
|
+
// Case 3:legitimate tripStart-derived reminder — 通过已加载 itinerary.trip_start 桥接
|
|
75
|
+
// (不要求调用方额外传 opts.tripStart;闸侧自动从 itinerary 派)。
|
|
76
|
+
// itinerary 必须保持自身不变量合法(nights/legs),否则闸会被 itineraryInvariants
|
|
77
|
+
// 单独阻断,影响 policy 收口的可读性。这里给一个合法的同日往返零夜行程。
|
|
78
|
+
const tripStart = '2027-07-16';
|
|
79
|
+
const tripStartLine = renderPolicyFact(policy, tripStart);
|
|
80
|
+
const r3 = await factGate.execute({
|
|
81
|
+
markdown: ['## 政策', tripStartLine].join('\n'),
|
|
82
|
+
itinerary: {
|
|
83
|
+
trip_start: tripStart,
|
|
84
|
+
trip_end: tripStart,
|
|
85
|
+
stays: [],
|
|
86
|
+
onboard_nights: 0,
|
|
87
|
+
od_segments: [],
|
|
88
|
+
budget_items: [],
|
|
89
|
+
},
|
|
90
|
+
}, exec);
|
|
91
|
+
assert.equal(r3.verdict, 'pass', `legitimate tripStart-derived reminder 经注册闸应 pass,实际: ${JSON.stringify({ verdict: r3.verdict, summary: r3.summary })}`);
|
|
92
|
+
console.log(` ok - 注册 gotry_fact_gate legitimate tripStart reminder(经 itinerary.trip_start 桥接)→ pass`);
|
|
93
|
+
// Case 4:trailing-after-anchor 攻击:合法 fact_id + 锚点后追加相反政策正文 → blocked。
|
|
94
|
+
const trailingLine = `${canonicalLine} 反而是落地签,需提前办签证`;
|
|
95
|
+
const r4 = await factGate.execute({ markdown: ['## 政策', trailingLine].join('\n') }, exec);
|
|
96
|
+
assert.equal(r4.verdict, 'blocked', `trailing-after-anchor 经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r4.verdict, summary: r4.summary })}`);
|
|
97
|
+
assert.ok(r4.violations?.some(v => v.kind === 'fact_anchor_unknown'), `trailing-after-anchor 应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r4.violations?.map(v => v.kind))}`);
|
|
98
|
+
console.log(` ok - 注册 gotry_fact_gate trailing-after-anchor 攻击 → blocked/fact_anchor_unknown`);
|
|
99
|
+
// Case 5:subject 篡改(原 main 静默 pass 的反例)。
|
|
100
|
+
const tamperedSubject = canonicalLine.replace('泰国入境(中国护照)', '另一对象的政策');
|
|
101
|
+
const r5 = await factGate.execute({ markdown: ['## 政策', tamperedSubject].join('\n') }, exec);
|
|
102
|
+
assert.equal(r5.verdict, 'blocked', `subject 篡改经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r5.verdict, summary: r5.summary })}`);
|
|
103
|
+
assert.ok(r5.violations?.some(v => v.kind === 'fact_anchor_unknown'), `subject 篡改应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r5.violations?.map(v => v.kind))}`);
|
|
104
|
+
console.log(` ok - 注册 gotry_fact_gate subject 篡改 → blocked/fact_anchor_unknown`);
|
|
105
|
+
// Case 6:opposite statement 篡改 — 现实威胁:沿用合法 fact_id + 锚点改写 statement 方向。
|
|
106
|
+
const oppositeStatement = canonicalLine.replace('免签停留', '不免签,需提前办签证');
|
|
107
|
+
const r6 = await factGate.execute({ markdown: ['## 政策', oppositeStatement].join('\n') }, exec);
|
|
108
|
+
assert.equal(r6.verdict, 'blocked', `opposite statement 篡改经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r6.verdict, summary: r6.summary })}`);
|
|
109
|
+
assert.ok(r6.violations?.some(v => v.kind === 'fact_anchor_unknown'), `opposite statement 应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r6.violations?.map(v => v.kind))}`);
|
|
110
|
+
console.log(` ok - 注册 gotry_fact_gate opposite statement 篡改 → blocked/fact_anchor_unknown`);
|
|
111
|
+
// Case 7:provenance 篡改(source / fetched_at / query_id 任一)→ blocked。
|
|
112
|
+
const tamperedProv = canonicalLine
|
|
113
|
+
.replace('[web:official@', '[synthetic:official@')
|
|
114
|
+
.replace(FETCHED, '2026-09-01T00:00:00.000Z')
|
|
115
|
+
.replace('#web:policy:泰国免签', '#synthetic:policy:泰国免签');
|
|
116
|
+
const r7 = await factGate.execute({ markdown: ['## 政策', tamperedProv].join('\n') }, exec);
|
|
117
|
+
assert.equal(r7.verdict, 'blocked', `provenance 篡改经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r7.verdict, summary: r7.summary })}`);
|
|
118
|
+
assert.ok(r7.violations?.some(v => v.kind === 'fact_anchor_unknown'), `provenance 篡改应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r7.violations?.map(v => v.kind))}`);
|
|
119
|
+
console.log(` ok - 注册 gotry_fact_gate provenance(source/fetched_at/query_id)篡改 → blocked/fact_anchor_unknown`);
|
|
120
|
+
// Compatibility(issue #359 final repair):注册闸侧既不传 itinerary、调用方也不显式
|
|
121
|
+
// opts.tripStart 时,renderer 给的两类合法 canonical form 必须经真实 gotry_fact_gate
|
|
122
|
+
// pass;否则(伪 reminder 日期、body 篡改、review_by 改写、trailing-after-anchor)
|
|
123
|
+
// 必须仍走 fact_anchor_unknown。证明兼容性回退收敛于 renderer 自身的输出空间,
|
|
124
|
+
// 不引入新公共 API,也不放行任意政策文本。
|
|
125
|
+
const compatExec = exec;
|
|
126
|
+
// Case 8:context-free canonical no-reminder 经注册闸 → pass
|
|
127
|
+
// (renderer 不接 tripStart,policy 也无 review_by → 不应出现 reminder 段)
|
|
128
|
+
const r8 = await factGate.execute({ markdown: ['## 政策', canonicalLine].join('\n') }, compatExec);
|
|
129
|
+
assert.equal(r8.verdict, 'pass', `context-free no-reminder 经注册闸应 pass,实际: ${JSON.stringify({ verdict: r8.verdict, summary: r8.summary })}`);
|
|
130
|
+
assert.equal(r8.traceable, 1);
|
|
131
|
+
console.log(` ok - 注册 gotry_fact_gate context-free canonical no-reminder → pass`);
|
|
132
|
+
// Case 9:context-free canonical reminder(renderer 默认 defaultReviewBy(as_of))→ pass
|
|
133
|
+
// 这是 issue #273 已有的历史形态,最终修复必须恢复。
|
|
134
|
+
const compatTripStart = '2027-08-01';
|
|
135
|
+
const compatTripStartLine = renderPolicyFact(policy, compatTripStart);
|
|
136
|
+
const r9 = await factGate.execute({ markdown: ['## 政策', compatTripStartLine].join('\n') }, compatExec);
|
|
137
|
+
assert.equal(r9.verdict, 'pass', `context-free derived reminder(无 itinerary 桥接)经注册闸应 pass,实际: ${JSON.stringify({ verdict: r9.verdict, summary: r9.summary })}`);
|
|
138
|
+
assert.equal(r9.traceable, 1);
|
|
139
|
+
console.log(` ok - 注册 gotry_fact_gate context-free canonical derived reminder(无 itinerary 桥接)→ pass`);
|
|
140
|
+
// Case 10:context-free canonical reminder(review_by 已知)→ pass
|
|
141
|
+
// reviewByPolicy 已在 Case 2 装载;这里只重复调用同一锚定行,证明无 itinerary 仍合法
|
|
142
|
+
const r10 = await factGate.execute({ markdown: ['## 政策', reviewByLine].join('\n') }, compatExec);
|
|
143
|
+
assert.equal(r10.verdict, 'pass', `context-free canonical reminder(review_by 已知)经注册闸应 pass,实际: ${JSON.stringify({ verdict: r10.verdict, summary: r10.summary })}`);
|
|
144
|
+
assert.equal(r10.traceable, 1);
|
|
145
|
+
console.log(` ok - 注册 gotry_fact_gate context-free canonical reminder(review_by 已知)→ pass`);
|
|
146
|
+
// Case 11:context-free reminder 错位(把 reminder 段追加到 provenance 之后,而不是
|
|
147
|
+
// renderer 固定位置 `[provenance]` 之前)→ 重建 `renderPolicyFact({...f, review_by: '1999-01-01'})`
|
|
148
|
+
// 与原行不匹配 → fail-closed。日期 '1999-01-01' 本身合法 ISO 阳历日;此例证伪在于
|
|
149
|
+
// reminder 位置错配,不在日期本身。
|
|
150
|
+
const compatBadDateLine = `${canonicalLine};远期政策须复核——到 1999-01-01 再核验一次 <!-- fact:${policy.fact_id} -->`;
|
|
151
|
+
const r11 = await factGate.execute({ markdown: ['## 政策', compatBadDateLine].join('\n') }, compatExec);
|
|
152
|
+
assert.equal(r11.verdict, 'blocked', `reminder 错位经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r11.verdict, summary: r11.summary })}`);
|
|
153
|
+
assert.ok(r11.violations?.some(v => v.kind === 'fact_anchor_unknown'), `reminder 错位应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r11.violations?.map(v => v.kind))}`);
|
|
154
|
+
console.log(` ok - 注册 gotry_fact_gate context-free reminder 错位 → blocked/fact_anchor_unknown`);
|
|
155
|
+
// Case 12:context-free body 篡改(免签停留 → 不免签停留,保留 fact_id 锚点)→ blocked
|
|
156
|
+
const compatBadBodyLine = canonicalLine.replace('免签停留', '不免签停留');
|
|
157
|
+
const r12 = await factGate.execute({ markdown: ['## 政策', compatBadBodyLine].join('\n') }, compatExec);
|
|
158
|
+
assert.equal(r12.verdict, 'blocked', `body 篡改经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r12.verdict, summary: r12.summary })}`);
|
|
159
|
+
assert.ok(r12.violations?.some(v => v.kind === 'fact_anchor_unknown'), `body 篡改应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r12.violations?.map(v => v.kind))}`);
|
|
160
|
+
console.log(` ok - 注册 gotry_fact_gate context-free body 篡改 → blocked/fact_anchor_unknown`);
|
|
161
|
+
// Case 13:context-free review_by 篡改(事实带 review_by,改 reminder 日期)→ blocked
|
|
162
|
+
// 根 contract 第 2 条:若事实自带 review_by,renderer 优先级 review_by > tripStart,
|
|
163
|
+
// reminder 日期必须 == f.review_by;改了就是伪造。这里注册的是带 review_by 的事实。
|
|
164
|
+
const fReviewBy = { ...policy, fact_id: makeFactId(['policy-359', 'reg', 'review-by-tamper']), review_by: '2027-06-16' };
|
|
165
|
+
await appendFacts(stateRoot, [fReviewBy]);
|
|
166
|
+
const compatReviewByTamperedLine = renderPolicyFact(fReviewBy).replace('2027-06-16', '2027-12-31');
|
|
167
|
+
const r13 = await factGate.execute({ markdown: ['## 政策', compatReviewByTamperedLine].join('\n') }, compatExec);
|
|
168
|
+
assert.equal(r13.verdict, 'blocked', `事实带 review_by 时改 reminder 日期经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r13.verdict, summary: r13.summary })}`);
|
|
169
|
+
assert.ok(r13.violations?.some(v => v.kind === 'fact_anchor_unknown'), `事实带 review_by 时改 reminder 日期应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r13.violations?.map(v => v.kind))}`);
|
|
170
|
+
console.log(` ok - 注册 gotry_fact_gate 事实带 review_by 改 reminder 日期 → blocked/fact_anchor_unknown`);
|
|
171
|
+
// Case 14:context-free trailing-after-anchor(锚点后追加非空)→ blocked
|
|
172
|
+
const compatTrailingLine = `${canonicalLine} 反而是落地签`;
|
|
173
|
+
const r14 = await factGate.execute({ markdown: ['## 政策', compatTrailingLine].join('\n') }, compatExec);
|
|
174
|
+
assert.equal(r14.verdict, 'blocked', `trailing-after-anchor 经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r14.verdict, summary: r14.summary })}`);
|
|
175
|
+
assert.ok(r14.violations?.some(v => v.kind === 'fact_anchor_unknown'), `trailing-after-anchor 应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r14.violations?.map(v => v.kind))}`);
|
|
176
|
+
console.log(` ok - 注册 gotry_fact_gate context-free trailing-after-anchor → blocked/fact_anchor_unknown`);
|
|
177
|
+
// Case 15:itinerary.trip_start 与 renderer reminder 不一致 → blocked
|
|
178
|
+
// 闸侧走 itinerary 派发后不再回退兼容,renderer 给的是 2027-08-01 而 itinerary
|
|
179
|
+
// 给的是 2027-08-15 → 必 fail-closed。
|
|
180
|
+
const r15 = await factGate.execute({
|
|
181
|
+
markdown: ['## 政策', compatTripStartLine].join('\n'),
|
|
182
|
+
itinerary: {
|
|
183
|
+
trip_start: '2027-08-15',
|
|
184
|
+
trip_end: '2027-08-15',
|
|
185
|
+
stays: [],
|
|
186
|
+
onboard_nights: 0,
|
|
187
|
+
od_segments: [],
|
|
188
|
+
budget_items: [],
|
|
189
|
+
},
|
|
190
|
+
}, compatExec);
|
|
191
|
+
assert.equal(r15.verdict, 'blocked', `itinerary 与 reminder 不一致经注册闸应 blocked,实际: ${JSON.stringify({ verdict: r15.verdict, summary: r15.summary })}`);
|
|
192
|
+
assert.ok(r15.violations?.some(v => v.kind === 'fact_anchor_unknown'), `itinerary 与 reminder 不一致应有 fact_anchor_unknown 违例,实际: ${JSON.stringify(r15.violations?.map(v => v.kind))}`);
|
|
193
|
+
console.log(` ok - 注册 gotry_fact_gate itinerary 与 reminder 不一致 → blocked/fact_anchor_unknown`);
|
|
194
|
+
// Case 16:itinerary.trip_start 存在时 canonical no-reminder 仍合法 → pass
|
|
195
|
+
// renderer 没接 tripStart 时,policy 文本里没有 reminder 段,与 itinerary 共存
|
|
196
|
+
// 仍是合法的 canonical body。
|
|
197
|
+
const r16 = await factGate.execute({
|
|
198
|
+
markdown: ['## 政策', canonicalLine].join('\n'),
|
|
199
|
+
itinerary: {
|
|
200
|
+
trip_start: '2027-08-15',
|
|
201
|
+
trip_end: '2027-08-15',
|
|
202
|
+
stays: [],
|
|
203
|
+
onboard_nights: 0,
|
|
204
|
+
od_segments: [],
|
|
205
|
+
budget_items: [],
|
|
206
|
+
},
|
|
207
|
+
}, compatExec);
|
|
208
|
+
assert.equal(r16.verdict, 'pass', `itinerary 存在时 canonical no-reminder 经注册闸应 pass,实际: ${JSON.stringify({ verdict: r16.verdict, summary: r16.summary })}`);
|
|
209
|
+
assert.equal(r16.traceable, 1);
|
|
210
|
+
console.log(` ok - 注册 gotry_fact_gate itinerary 存在时 canonical no-reminder → pass`);
|
|
211
|
+
rmSync(home, { recursive: true, force: true });
|
|
212
|
+
console.log('\nPOLICY ANCHOR #359 REGISTERED E2E: pass (deterministic synthetic, isolated stateRoot, registered gotry_fact_gate execute())');
|
|
213
|
+
}
|
|
214
|
+
await main();
|