gatewaysdk 0.3.2__py3-none-any.whl
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.
- gatewaysdk/__init__.py +540 -0
- gatewaysdk/adapter/__init__.py +15 -0
- gatewaysdk/adapter/base.py +94 -0
- gatewaysdk/adapter/messages.py +270 -0
- gatewaysdk/adapter/triplet.py +1026 -0
- gatewaysdk/algorithm/__init__.py +39 -0
- gatewaysdk/algorithm/apo/__init__.py +5 -0
- gatewaysdk/algorithm/apo/apo.py +898 -0
- gatewaysdk/algorithm/apo/prompts/apply_edit_variant01.poml +22 -0
- gatewaysdk/algorithm/apo/prompts/apply_edit_variant02.poml +18 -0
- gatewaysdk/algorithm/apo/prompts/text_gradient_variant01.poml +18 -0
- gatewaysdk/algorithm/apo/prompts/text_gradient_variant02.poml +16 -0
- gatewaysdk/algorithm/apo/prompts/text_gradient_variant03.poml +107 -0
- gatewaysdk/algorithm/base.py +262 -0
- gatewaysdk/algorithm/decorator.py +264 -0
- gatewaysdk/algorithm/evals/__init__.py +7 -0
- gatewaysdk/algorithm/evals/evals.py +217 -0
- gatewaysdk/algorithm/fast.py +250 -0
- gatewaysdk/algorithm/gepa/__init__.py +61 -0
- gatewaysdk/algorithm/gepa/adapter.py +495 -0
- gatewaysdk/algorithm/gepa/gepa.py +570 -0
- gatewaysdk/algorithm/gepa/lib/__init__.py +18 -0
- gatewaysdk/algorithm/gepa/lib/adapters/README.md +12 -0
- gatewaysdk/algorithm/gepa/lib/adapters/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/adapters/anymaths_adapter/README.md +341 -0
- gatewaysdk/algorithm/gepa/lib/adapters/anymaths_adapter/__init__.py +1 -0
- gatewaysdk/algorithm/gepa/lib/adapters/anymaths_adapter/anymaths_adapter.py +174 -0
- gatewaysdk/algorithm/gepa/lib/adapters/anymaths_adapter/requirements.txt +1 -0
- gatewaysdk/algorithm/gepa/lib/adapters/default_adapter/README.md +0 -0
- gatewaysdk/algorithm/gepa/lib/adapters/default_adapter/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/adapters/default_adapter/default_adapter.py +209 -0
- gatewaysdk/algorithm/gepa/lib/adapters/dspy_adapter/README.md +7 -0
- gatewaysdk/algorithm/gepa/lib/adapters/dspy_adapter/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/adapters/dspy_adapter/dspy_adapter.py +307 -0
- gatewaysdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/README.md +99 -0
- gatewaysdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/dspy_program_proposal_signature.py +137 -0
- gatewaysdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/full_program_adapter.py +268 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/GEPA_RAG.md +621 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/__init__.py +56 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/evaluation_metrics.py +226 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/generic_rag_adapter.py +496 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/rag_pipeline.py +238 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_store_interface.py +212 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/__init__.py +2 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/chroma_store.py +196 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/lancedb_store.py +422 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/milvus_store.py +409 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/qdrant_store.py +368 -0
- gatewaysdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/weaviate_store.py +418 -0
- gatewaysdk/algorithm/gepa/lib/adapters/mcp_adapter/README.md +552 -0
- gatewaysdk/algorithm/gepa/lib/adapters/mcp_adapter/__init__.py +37 -0
- gatewaysdk/algorithm/gepa/lib/adapters/mcp_adapter/mcp_adapter.py +699 -0
- gatewaysdk/algorithm/gepa/lib/adapters/mcp_adapter/mcp_client.py +364 -0
- gatewaysdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/README.md +9 -0
- gatewaysdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/terminal_bench_adapter.py +217 -0
- gatewaysdk/algorithm/gepa/lib/api.py +382 -0
- gatewaysdk/algorithm/gepa/lib/core/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/core/adapter.py +180 -0
- gatewaysdk/algorithm/gepa/lib/core/data_loader.py +74 -0
- gatewaysdk/algorithm/gepa/lib/core/engine.py +379 -0
- gatewaysdk/algorithm/gepa/lib/core/result.py +233 -0
- gatewaysdk/algorithm/gepa/lib/core/state.py +636 -0
- gatewaysdk/algorithm/gepa/lib/examples/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/examples/aime.py +24 -0
- gatewaysdk/algorithm/gepa/lib/examples/anymaths-bench/eval_default.py +111 -0
- gatewaysdk/algorithm/gepa/lib/examples/anymaths-bench/prompt-templates/instruction_prompt.txt +9 -0
- gatewaysdk/algorithm/gepa/lib/examples/anymaths-bench/prompt-templates/optimal_prompt.txt +24 -0
- gatewaysdk/algorithm/gepa/lib/examples/anymaths-bench/train_anymaths.py +177 -0
- gatewaysdk/algorithm/gepa/lib/examples/dspy_full_program_evolution/arc_agi.ipynb +25705 -0
- gatewaysdk/algorithm/gepa/lib/examples/dspy_full_program_evolution/example.ipynb +348 -0
- gatewaysdk/algorithm/gepa/lib/examples/mcp_adapter/__init__.py +4 -0
- gatewaysdk/algorithm/gepa/lib/examples/mcp_adapter/mcp_optimization_example.py +456 -0
- gatewaysdk/algorithm/gepa/lib/examples/rag_adapter/RAG_GUIDE.md +613 -0
- gatewaysdk/algorithm/gepa/lib/examples/rag_adapter/__init__.py +9 -0
- gatewaysdk/algorithm/gepa/lib/examples/rag_adapter/rag_optimization.py +820 -0
- gatewaysdk/algorithm/gepa/lib/examples/rag_adapter/requirements-rag.txt +29 -0
- gatewaysdk/algorithm/gepa/lib/examples/terminal-bench/prompt-templates/instruction_prompt.txt +16 -0
- gatewaysdk/algorithm/gepa/lib/examples/terminal-bench/prompt-templates/terminus.txt +9 -0
- gatewaysdk/algorithm/gepa/lib/examples/terminal-bench/train_terminus.py +161 -0
- gatewaysdk/algorithm/gepa/lib/gepa_utils.py +117 -0
- gatewaysdk/algorithm/gepa/lib/logging/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/logging/experiment_tracker.py +187 -0
- gatewaysdk/algorithm/gepa/lib/logging/logger.py +75 -0
- gatewaysdk/algorithm/gepa/lib/logging/utils.py +103 -0
- gatewaysdk/algorithm/gepa/lib/proposer/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/proposer/base.py +31 -0
- gatewaysdk/algorithm/gepa/lib/proposer/merge.py +357 -0
- gatewaysdk/algorithm/gepa/lib/proposer/reflective_mutation/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/proposer/reflective_mutation/base.py +49 -0
- gatewaysdk/algorithm/gepa/lib/proposer/reflective_mutation/reflective_mutation.py +176 -0
- gatewaysdk/algorithm/gepa/lib/py.typed +0 -0
- gatewaysdk/algorithm/gepa/lib/strategies/__init__.py +0 -0
- gatewaysdk/algorithm/gepa/lib/strategies/batch_sampler.py +77 -0
- gatewaysdk/algorithm/gepa/lib/strategies/candidate_selector.py +50 -0
- gatewaysdk/algorithm/gepa/lib/strategies/component_selector.py +36 -0
- gatewaysdk/algorithm/gepa/lib/strategies/eval_policy.py +64 -0
- gatewaysdk/algorithm/gepa/lib/strategies/instruction_proposal.py +126 -0
- gatewaysdk/algorithm/gepa/lib/utils/__init__.py +10 -0
- gatewaysdk/algorithm/gepa/lib/utils/stop_condition.py +196 -0
- gatewaysdk/algorithm/gepa/tracing.py +105 -0
- gatewaysdk/algorithm/utils.py +177 -0
- gatewaysdk/algorithm/verl/__init__.py +5 -0
- gatewaysdk/algorithm/verl/interface.py +202 -0
- gatewaysdk/automations.py +111 -0
- gatewaysdk/benchmark_hub/README.md +88 -0
- gatewaysdk/benchmark_hub/__init__.py +119 -0
- gatewaysdk/benchmark_hub/_archive.py +189 -0
- gatewaysdk/benchmark_hub/_tar.py +6 -0
- gatewaysdk/benchmark_hub/client.py +992 -0
- gatewaysdk/benchmark_hub/dispatch_shard.py +34 -0
- gatewaysdk/benchmark_hub/eval_config.py +20 -0
- gatewaysdk/benchmark_hub/evals.py +351 -0
- gatewaysdk/benchmark_hub/harbor_adapter.py +673 -0
- gatewaysdk/benchmark_hub/path_utils.py +81 -0
- gatewaysdk/benchmark_hub/save_utils.py +101 -0
- gatewaysdk/benchmark_hub/verifiers_adapter.py +327 -0
- gatewaysdk/benchmark_hub/versioning.py +72 -0
- gatewaysdk/build.py +515 -0
- gatewaysdk/cli/__init__.py +58 -0
- gatewaysdk/cli/agent_runner.py +132 -0
- gatewaysdk/cli/http_client.py +115 -0
- gatewaysdk/cli/platform.py +4086 -0
- gatewaysdk/cli/prometheus.py +115 -0
- gatewaysdk/cli/release_gate.py +215 -0
- gatewaysdk/cli/store.py +131 -0
- gatewaysdk/cli/vllm.py +29 -0
- gatewaysdk/client.py +406 -0
- gatewaysdk/config.py +348 -0
- gatewaysdk/connectors/__init__.py +25 -0
- gatewaysdk/connectors/client.py +203 -0
- gatewaysdk/connectors/skill.py +25 -0
- gatewaysdk/connectors/template.py +106 -0
- gatewaysdk/context.py +606 -0
- gatewaysdk/emitter/__init__.py +43 -0
- gatewaysdk/emitter/annotation.py +370 -0
- gatewaysdk/emitter/exception.py +54 -0
- gatewaysdk/emitter/message.py +61 -0
- gatewaysdk/emitter/object.py +117 -0
- gatewaysdk/emitter/reward.py +320 -0
- gatewaysdk/env_var.py +156 -0
- gatewaysdk/environment/__init__.py +108 -0
- gatewaysdk/environment/_bundle.py +281 -0
- gatewaysdk/environment/_harbor.py +276 -0
- gatewaysdk/environment/_materialize.py +97 -0
- gatewaysdk/environment/_tar.py +33 -0
- gatewaysdk/environment/_world.py +346 -0
- gatewaysdk/environment/core.py +527 -0
- gatewaysdk/environment/errors.py +58 -0
- gatewaysdk/environment/runtime.py +150 -0
- gatewaysdk/environment/schema/__init__.py +35 -0
- gatewaysdk/environment/schema/__main__.py +225 -0
- gatewaysdk/environment/schema/_slack_fidelity.py +116 -0
- gatewaysdk/environment/schema/_slack_scenario.py +183 -0
- gatewaysdk/environment/schema/api.py +1628 -0
- gatewaysdk/environment/schema/batch.py +755 -0
- gatewaysdk/environment/schema/compiler.py +615 -0
- gatewaysdk/environment/schema/conform.py +428 -0
- gatewaysdk/environment/schema/connector.py +777 -0
- gatewaysdk/environment/schema/connectors/apple-business-manager/handlers.py +17 -0
- gatewaysdk/environment/schema/connectors/apple-business-manager/parity.json +28 -0
- gatewaysdk/environment/schema/connectors/apple-business-manager/provenance.json +233 -0
- gatewaysdk/environment/schema/connectors/apple-business-manager/scope.toml +112 -0
- gatewaysdk/environment/schema/connectors/apple-business-manager/world.json +1380 -0
- gatewaysdk/environment/schema/connectors/base.json +28 -0
- gatewaysdk/environment/schema/connectors/custom/handlers.py +18 -0
- gatewaysdk/environment/schema/connectors/custom/world.json +123 -0
- gatewaysdk/environment/schema/connectors/github/handlers.py +81 -0
- gatewaysdk/environment/schema/connectors/github/parity.json +37 -0
- gatewaysdk/environment/schema/connectors/github/provenance.json +134 -0
- gatewaysdk/environment/schema/connectors/github/scope.toml +158 -0
- gatewaysdk/environment/schema/connectors/github/world.json +5869 -0
- gatewaysdk/environment/schema/connectors/google-calendar/handlers.py +23 -0
- gatewaysdk/environment/schema/connectors/google-calendar/world.json +209 -0
- gatewaysdk/environment/schema/connectors/google-drive/handlers.py +18 -0
- gatewaysdk/environment/schema/connectors/google-drive/world.json +286 -0
- gatewaysdk/environment/schema/connectors/jamf/handlers.py +34 -0
- gatewaysdk/environment/schema/connectors/jamf/parity.json +49 -0
- gatewaysdk/environment/schema/connectors/jamf/provenance.json +181 -0
- gatewaysdk/environment/schema/connectors/jamf/scope.toml +128 -0
- gatewaysdk/environment/schema/connectors/jamf/world.json +2218 -0
- gatewaysdk/environment/schema/connectors/jira/handlers.py +28 -0
- gatewaysdk/environment/schema/connectors/jira/world.json +389 -0
- gatewaysdk/environment/schema/connectors/kandji/handlers.py +38 -0
- gatewaysdk/environment/schema/connectors/kandji/parity.json +29 -0
- gatewaysdk/environment/schema/connectors/kandji/provenance.json +152 -0
- gatewaysdk/environment/schema/connectors/kandji/scope.toml +120 -0
- gatewaysdk/environment/schema/connectors/kandji/world.json +765 -0
- gatewaysdk/environment/schema/connectors/linear/handlers.py +20 -0
- gatewaysdk/environment/schema/connectors/linear/world.json +363 -0
- gatewaysdk/environment/schema/connectors/microsoft-teams/fidelity.json +45 -0
- gatewaysdk/environment/schema/connectors/microsoft-teams/handlers.py +1 -0
- gatewaysdk/environment/schema/connectors/microsoft-teams/provenance.json +851 -0
- gatewaysdk/environment/schema/connectors/microsoft-teams/scope.md +231 -0
- gatewaysdk/environment/schema/connectors/microsoft-teams/teams-types.json +1710 -0
- gatewaysdk/environment/schema/connectors/microsoft-teams/world.json +858 -0
- gatewaysdk/environment/schema/connectors/netsuite/handlers.py +32 -0
- gatewaysdk/environment/schema/connectors/netsuite/parity.json +50 -0
- gatewaysdk/environment/schema/connectors/netsuite/provenance.json +137 -0
- gatewaysdk/environment/schema/connectors/netsuite/scope.toml +78 -0
- gatewaysdk/environment/schema/connectors/netsuite/world.json +16243 -0
- gatewaysdk/environment/schema/connectors/salesforce/handlers.py +806 -0
- gatewaysdk/environment/schema/connectors/salesforce/parity.json +46 -0
- gatewaysdk/environment/schema/connectors/salesforce/provenance.json +143 -0
- gatewaysdk/environment/schema/connectors/salesforce/scope.toml +174 -0
- gatewaysdk/environment/schema/connectors/salesforce/world.json +4695 -0
- gatewaysdk/environment/schema/connectors/slack/MODEL.md +236 -0
- gatewaysdk/environment/schema/connectors/slack/capabilities.json +1039 -0
- gatewaysdk/environment/schema/connectors/slack/handlers.py +762 -0
- gatewaysdk/environment/schema/connectors/slack/parity.json +65 -0
- gatewaysdk/environment/schema/connectors/slack/provenance.json +294 -0
- gatewaysdk/environment/schema/connectors/slack/scope.toml +44 -0
- gatewaysdk/environment/schema/connectors/slack/world.json +4993 -0
- gatewaysdk/environment/schema/connectors/workday/handlers.py +75 -0
- gatewaysdk/environment/schema/connectors/workday/parity.json +36 -0
- gatewaysdk/environment/schema/connectors/workday/provenance.json +179 -0
- gatewaysdk/environment/schema/connectors/workday/scope.toml +180 -0
- gatewaysdk/environment/schema/connectors/workday/world.json +806 -0
- gatewaysdk/environment/schema/data.py +593 -0
- gatewaysdk/environment/schema/extract.py +263 -0
- gatewaysdk/environment/schema/host.py +2437 -0
- gatewaysdk/environment/schema/host_surfaces.py +275 -0
- gatewaysdk/environment/schema/platform.py +1272 -0
- gatewaysdk/environment/schema/scaffold.py +250 -0
- gatewaysdk/environment/schema/skill.py +118 -0
- gatewaysdk/environment/schema/skills/agents/connector-template-author.md +202 -0
- gatewaysdk/environment/schema/skills/connector-schema-authoring/CONNECTORS.md +331 -0
- gatewaysdk/environment/schema/skills/connector-schema-authoring/CONVENTIONS.md +100 -0
- gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +313 -0
- gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +223 -0
- gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +293 -0
- gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +390 -0
- gatewaysdk/environment/schema/slack.py +757 -0
- gatewaysdk/environment/schema/snapshot.py +479 -0
- gatewaysdk/environment/schema/store.py +904 -0
- gatewaysdk/environment/schema/tasks.py +525 -0
- gatewaysdk/environment/schema/tools_world.py +322 -0
- gatewaysdk/environment/schema/validation.py +577 -0
- gatewaysdk/environment/schema/worker.py +78 -0
- gatewaysdk/environment/schema/workers.py +500 -0
- gatewaysdk/environment/schema/world_tests.py +336 -0
- gatewaysdk/environments/__init__.py +24 -0
- gatewaysdk/environments/client.py +486 -0
- gatewaysdk/environments/types.py +318 -0
- gatewaysdk/execution/__init__.py +15 -0
- gatewaysdk/execution/base.py +64 -0
- gatewaysdk/execution/client_server.py +443 -0
- gatewaysdk/execution/events.py +69 -0
- gatewaysdk/execution/inter_process.py +16 -0
- gatewaysdk/execution/shared_memory.py +282 -0
- gatewaysdk/experiments/__init__.py +90 -0
- gatewaysdk/experiments/assignment.py +177 -0
- gatewaysdk/experiments/client.py +877 -0
- gatewaysdk/experiments/exposure.py +222 -0
- gatewaysdk/experiments/types.py +81 -0
- gatewaysdk/importers/__init__.py +49 -0
- gatewaysdk/importers/_normalize.py +91 -0
- gatewaysdk/importers/builder.py +173 -0
- gatewaysdk/importers/client.py +95 -0
- gatewaysdk/importers/langsmith.py +196 -0
- gatewaysdk/importers/recipes.py +249 -0
- gatewaysdk/instrumentation/__init__.py +300 -0
- gatewaysdk/instrumentation/agentops.py +314 -0
- gatewaysdk/instrumentation/agentops_langchain.py +45 -0
- gatewaysdk/instrumentation/base.py +119 -0
- gatewaysdk/instrumentation/litellm.py +83 -0
- gatewaysdk/instrumentation/registry.py +273 -0
- gatewaysdk/instrumentation/vllm.py +81 -0
- gatewaysdk/instrumentation/weave.py +500 -0
- gatewaysdk/integrations/__init__.py +15 -0
- gatewaysdk/integrations/gateway/__init__.py +11 -0
- gatewaysdk/integrations/gateway/client.py +171 -0
- gatewaysdk/integrations/tool_access.py +549 -0
- gatewaysdk/litagent/__init__.py +11 -0
- gatewaysdk/litagent/decorator.py +536 -0
- gatewaysdk/litagent/litagent.py +252 -0
- gatewaysdk/llm_proxy.py +1742 -0
- gatewaysdk/logging.py +370 -0
- gatewaysdk/memory.py +278 -0
- gatewaysdk/personas.py +186 -0
- gatewaysdk/platform/__init__.py +17 -0
- gatewaysdk/platform/builder.py +221 -0
- gatewaysdk/platform/compatibility.py +67 -0
- gatewaysdk/platform/manifest.py +185 -0
- gatewaysdk/platform/orchestrator.py +901 -0
- gatewaysdk/platform/registry.py +122 -0
- gatewaysdk/platform/worker.py +864 -0
- gatewaysdk/replay/__init__.py +1032 -0
- gatewaysdk/replay/pytest.py +56 -0
- gatewaysdk/reward.py +7 -0
- gatewaysdk/run.py +1781 -0
- gatewaysdk/runner/__init__.py +11 -0
- gatewaysdk/runner/agent.py +878 -0
- gatewaysdk/runner/base.py +182 -0
- gatewaysdk/runner/legacy.py +309 -0
- gatewaysdk/security.py +700 -0
- gatewaysdk/semconv.py +170 -0
- gatewaysdk/server.py +399 -0
- gatewaysdk/sessions.py +282 -0
- gatewaysdk/store/__init__.py +45 -0
- gatewaysdk/store/base.py +908 -0
- gatewaysdk/store/client_server.py +2093 -0
- gatewaysdk/store/collection/__init__.py +30 -0
- gatewaysdk/store/collection/base.py +587 -0
- gatewaysdk/store/collection/memory.py +970 -0
- gatewaysdk/store/collection/mongo.py +1412 -0
- gatewaysdk/store/collection_based.py +1823 -0
- gatewaysdk/store/gateway.py +983 -0
- gatewaysdk/store/gateway_listener.py +465 -0
- gatewaysdk/store/listener.py +58 -0
- gatewaysdk/store/memory.py +396 -0
- gatewaysdk/store/mongo.py +165 -0
- gatewaysdk/store/redis_stream.py +517 -0
- gatewaysdk/store/sqlite.py +3 -0
- gatewaysdk/store/threading.py +370 -0
- gatewaysdk/store/utils.py +142 -0
- gatewaysdk/tracer/__init__.py +14 -0
- gatewaysdk/tracer/base.py +286 -0
- gatewaysdk/tracer/dummy.py +106 -0
- gatewaysdk/tracer/otel.py +559 -0
- gatewaysdk/tracing/__init__.py +110 -0
- gatewaysdk/tracing/api.py +808 -0
- gatewaysdk/tracing/attributes.py +9 -0
- gatewaysdk/tracing/context.py +272 -0
- gatewaysdk/tracing/exporters/__init__.py +10 -0
- gatewaysdk/tracing/exporters/gateway.py +228 -0
- gatewaysdk/tracing/identity.py +288 -0
- gatewaysdk/tracing/init.py +620 -0
- gatewaysdk/tracing/instrumentors/__init__.py +15 -0
- gatewaysdk/tracing/instrumentors/claude_agent_sdk.py +766 -0
- gatewaysdk/tracing/instrumentors/instrumentation_principles.md +294 -0
- gatewaysdk/tracing/instrumentors/registry.py +352 -0
- gatewaysdk/tracing/mapping.py +729 -0
- gatewaysdk/tracing/processors.py +393 -0
- gatewaysdk/tracing/push.py +617 -0
- gatewaysdk/tracing/push_models.py +247 -0
- gatewaysdk/tracing/semconv.py +294 -0
- gatewaysdk/tracing/span_builder.py +356 -0
- gatewaysdk/trainer/__init__.py +6 -0
- gatewaysdk/trainer/init_utils.py +263 -0
- gatewaysdk/trainer/legacy.py +359 -0
- gatewaysdk/trainer/registry.py +12 -0
- gatewaysdk/trainer/trainer.py +638 -0
- gatewaysdk/types/__init__.py +63 -0
- gatewaysdk/types/core.py +556 -0
- gatewaysdk/types/resources.py +204 -0
- gatewaysdk/types/tracer.py +515 -0
- gatewaysdk/types/tracing.py +162 -0
- gatewaysdk/users.py +251 -0
- gatewaysdk/utils/__init__.py +1 -0
- gatewaysdk/utils/id.py +18 -0
- gatewaysdk/utils/metrics.py +1025 -0
- gatewaysdk/utils/otel.py +550 -0
- gatewaysdk/utils/otlp.py +556 -0
- gatewaysdk/utils/redact.py +22 -0
- gatewaysdk/utils/server_launcher.py +1045 -0
- gatewaysdk/utils/system_snapshot.py +90 -0
- gatewaysdk/verl/__init__.py +8 -0
- gatewaysdk/verl/__main__.py +6 -0
- gatewaysdk/verl/async_server.py +46 -0
- gatewaysdk/verl/config.yaml +27 -0
- gatewaysdk/verl/daemon.py +1154 -0
- gatewaysdk/verl/dataset.py +44 -0
- gatewaysdk/verl/entrypoint.py +248 -0
- gatewaysdk/verl/trainer.py +549 -0
- gatewaysdk/world_browser.py +748 -0
- gatewaysdk/world_data.py +453 -0
- gatewaysdk/world_sessions.py +978 -0
- gatewaysdk/world_tasks.py +285 -0
- gatewaysdk/world_tools.py +115 -0
- gatewaysdk/worlds.py +639 -0
- gatewaysdk-0.3.2.dist-info/METADATA +236 -0
- gatewaysdk-0.3.2.dist-info/RECORD +376 -0
- gatewaysdk-0.3.2.dist-info/WHEEL +4 -0
- gatewaysdk-0.3.2.dist-info/entry_points.txt +5 -0
- gatewaysdk-0.3.2.dist-info/licenses/LICENSE +19 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: world-data-ingestion
|
|
3
|
+
description: Put rows into a world from any agent. Use when uploading data to a world, seeding a world, importing rows (a few or millions), adding records to a schema world or mock-tools world, seeding a live session, exporting a session's calls, turning a vendor export or a real run into world data, or asking why a served world starts from a snapshot. Covers the rows file contract (JSON object, JSONL, --entity), append vs replace, primary-key upsert, `gateway worlds data show|import|check|extract|status|batches|publish`, chunked resumable uploads, refusal reports, data snapshots (`db/state.sqlite`, `WORLD_SNAPSHOT_*`), `gateway worlds session seed|export`, the MCP twins import_world_data / seed_world_session / export_world_session, the refusals, and the definition of done.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# World data ingestion
|
|
7
|
+
|
|
8
|
+
> **Two copies, kept identical.** This file ships inside the `gatewaysdk` Python package
|
|
9
|
+
> (`gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md`) and the `@withgateway/sdk`
|
|
10
|
+
> npm package (copied into `skills/` at build) and is what
|
|
11
|
+
> `gateway worlds skill world-data-ingestion` prints and `--install DIR` writes into a
|
|
12
|
+
> repository's `.claude/skills/`. The repository copy is `.claude/skills/world-data-ingestion/SKILL.md`.
|
|
13
|
+
> Edit one, copy to the other; a test compares them.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
> **Two copies, kept identical.** This file ships inside the `gatewaysdk` Python package
|
|
17
|
+
> (`gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md`) and the `@withgateway/sdk`
|
|
18
|
+
> npm package (copied into `skills/` at build) and is what
|
|
19
|
+
> `gateway worlds skill world-data-ingestion` prints and `--install DIR` writes into a
|
|
20
|
+
> repository's `.claude/skills/`. The repository copy is `.claude/skills/world-data-ingestion/SKILL.md`.
|
|
21
|
+
> Edit one, copy to the other; a test compares them.
|
|
22
|
+
|
|
23
|
+
## Purpose
|
|
24
|
+
|
|
25
|
+
Get rows into a world without knowing the world's file layout. One rows file, one
|
|
26
|
+
command, one MCP tool. The world's contract decides whether a row is accepted; the
|
|
27
|
+
command never writes a partial result.
|
|
28
|
+
|
|
29
|
+
Read [ROWS.md](ROWS.md) for the full rows file reference and worked examples.
|
|
30
|
+
|
|
31
|
+
## When to use
|
|
32
|
+
|
|
33
|
+
- An agent has records (fixtures, a customer's sanitized export, rows harvested from a real
|
|
34
|
+
run) and a world that should contain them.
|
|
35
|
+
- A world exists but is empty or thin and a scenario needs data behind it.
|
|
36
|
+
- A live session should start from, or be extended with, specific rows.
|
|
37
|
+
- A real run's tool calls should become the seed of the next version.
|
|
38
|
+
|
|
39
|
+
Do not use this skill to author the world's data model; that is
|
|
40
|
+
`connector-schema-authoring`. Do not use it for vendor captures; that is
|
|
41
|
+
`gateway worlds connector capture` + `ingest` (see `documentation/features/connector-worlds.md`).
|
|
42
|
+
For the end-to-end path (connector, world, session, runs) read `worlds-getting-started`.
|
|
43
|
+
|
|
44
|
+
## The rows file
|
|
45
|
+
|
|
46
|
+
Three accepted shapes. Pick one per file; a command may take several files.
|
|
47
|
+
|
|
48
|
+
| Shape | Looks like | When |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| JSON object | `{"users": [{...}, {...}], "channels": [{...}]}` | several entities in one file |
|
|
51
|
+
| JSONL, tagged | one line per row: `{"entity": "users", "row": {...}}` | streaming, mixed entities |
|
|
52
|
+
| Bare rows + `--entity NAME` | `[{...}, {...}]` or one bare `{...}` per line | one entity, rows straight from a query |
|
|
53
|
+
|
|
54
|
+
Rules:
|
|
55
|
+
|
|
56
|
+
- Entity names are the world's own: the `entities` keys of `schema/world.json` for a schema
|
|
57
|
+
world, the table names of `db/schema.sql` for a mock-tools world. Unknown entity: refused.
|
|
58
|
+
- A row is a flat JSON object with the entity's field names in the vendor's casing. Unknown
|
|
59
|
+
field, wrong type, missing required field, broken reference: refused, field named.
|
|
60
|
+
- **Mode `append` (default)** adds rows. A row whose primary key already exists is an
|
|
61
|
+
update, not a duplicate (upsert by primary key). **Mode `replace`** replaces every row of
|
|
62
|
+
each entity named in the file; entities the file does not name are untouched.
|
|
63
|
+
- The whole file is checked before anything is written. One bad row means nothing is written
|
|
64
|
+
(`--atomic`, the default); `--per-chunk` keeps the good chunks of a large upload and lists
|
|
65
|
+
the refused ones.
|
|
66
|
+
- Inside one batch, two rows with the same key merge by `--merge`: `upsert` (default, the
|
|
67
|
+
later row replaces the earlier) or `fill` (the first row wins, later rows only add fields
|
|
68
|
+
it lacks).
|
|
69
|
+
|
|
70
|
+
## Decision table by world kind
|
|
71
|
+
|
|
72
|
+
`gateway worlds data show <WORLD>` prints the kind first. Then:
|
|
73
|
+
|
|
74
|
+
| Kind | How the import lands | What you edit instead |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `schema` (has `schema/world.json`) | Directory: a contract-checked batch appended to `data/initial.json`, proven by building the snapshot, then `compile` + `check`. Slug: a data batch on the platform, applied onto the world's snapshot | nothing; the batch is the source |
|
|
77
|
+
| `mock-tools` (has `gateway-env.toml` + `db/schema.sql`) | `INSERT` statements appended to `db/seed.sql` for tables found in `db/schema.sql`; columns come from the table | nothing; `seed.sql` is the source |
|
|
78
|
+
| `api` (has `gateway-api-world.toml` at the root) | Refused: the api bundle is generated from a schema world | the schema world it was packaged from, then `bench push` again |
|
|
79
|
+
| `harbor` (task dirs) | Refused | the task's own fixtures under its task dir |
|
|
80
|
+
| other | Refused, naming the kind and the file to edit | the file named in the refusal |
|
|
81
|
+
|
|
82
|
+
The refusal for `api`/`harbor` is a result, not an error: it names the world kind and the
|
|
83
|
+
file the agent should edit.
|
|
84
|
+
|
|
85
|
+
## Commands, in order
|
|
86
|
+
|
|
87
|
+
Every CLI step has its MCP twin on the next line. `<WORLD>` is a local world directory, else a
|
|
88
|
+
platform world slug (the CLI pulls it to a temp dir, imports, and pushes a new version unless
|
|
89
|
+
`--no-push`). Auth and host: `GATEWAY_HOST`, `GATEWAY_PUBLIC_KEY`, `GATEWAY_SECRET_KEY`, or
|
|
90
|
+
`gateway auth login`.
|
|
91
|
+
|
|
92
|
+
### 1. See what the world holds
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
gateway worlds data show <WORLD> # {world, kind, entity_counts}
|
|
96
|
+
gateway worlds data show <WORLD> --entity users # the rows of one entity
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
MCP: no counts tool. `get_environment({ containerId })` lists versions; `import_world_data`
|
|
100
|
+
returns `entityCounts` after a write. Use the CLI to look before writing.
|
|
101
|
+
|
|
102
|
+
### 2. Import
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
gateway worlds data import <WORLD> rows.json # append (default)
|
|
106
|
+
gateway worlds data import <WORLD> users.jsonl --entity users # bare rows, one entity
|
|
107
|
+
gateway worlds data import <WORLD> rows.json --mode replace # replace the named entities
|
|
108
|
+
gateway worlds data import <WORLD> rows.json --dry-run # check only, write nothing
|
|
109
|
+
gateway worlds data import <slug> export.jsonl -m "Q3 tenants" # platform: chunked upload, new version
|
|
110
|
+
gateway worlds data import <slug> export.jsonl --per-chunk --publish later --report refusals.jsonl
|
|
111
|
+
gateway worlds data import <slug> export.jsonl --resume # pick a dead upload back up
|
|
112
|
+
gateway worlds data check <WORLD> rows.json --report refusals.jsonl # the dry run on its own; exit 2 on refusals
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**A directory** takes small inputs only (at most 5,000 rows / 4 MiB, the inline cap): the rows
|
|
116
|
+
land in the tree and the snapshot is rebuilt. Prints `{world, kind, entity_counts, changed}`.
|
|
117
|
+
Above the cap it refuses with `import into the platform world <slug>`.
|
|
118
|
+
|
|
119
|
+
**A slug** streams the files (never loaded whole; `-` is stdin, `.gz` is fine) into gzipped
|
|
120
|
+
JSONL chunks of `--chunk-bytes` (64 MiB default) or `--chunk-rows N`, uploads them
|
|
121
|
+
`--parallel 4` at a time straight to the bucket, and completes the batch; the platform
|
|
122
|
+
validates every row against the contract, applies the batch onto the world's data snapshot
|
|
123
|
+
and, with `--publish now` (default), cuts a data-only version (no image rebuild). `--wait`
|
|
124
|
+
(default) polls to the end and prints the batch: `{batchId, state, rows, refusalCount,
|
|
125
|
+
refusals[:200], entityCounts, versionId?, batchDigest?}`. `--no-wait` prints `{batchId,
|
|
126
|
+
state}` and `gateway worlds data status <batchId>` reads it later. Exit codes: 0 applied or
|
|
127
|
+
published, 2 refused (the report is written when `--report` is given: JSONL of refusal
|
|
128
|
+
records, at most 10,000 then `{"truncated": true, "total": N}`), 1 error.
|
|
129
|
+
|
|
130
|
+
A manifest at `.gateway/imports/<batchId>.json` records every chunk's digest as it lands;
|
|
131
|
+
`--resume` reopens the newest incomplete batch for that slug and files, re-registers the
|
|
132
|
+
chunks (the platform answers `uploaded: true` for digests it already holds) and uploads only
|
|
133
|
+
the rest. `--publish later` applies without a version; `gateway worlds data publish <slug>`
|
|
134
|
+
folds every pending batch into one. `gateway worlds data batches <slug>` lists them.
|
|
135
|
+
|
|
136
|
+
A refusal record, everywhere (dry run, report, status, MCP):
|
|
137
|
+
`{"chunk", "index", "entity", "primaryKey", "field", "pointer", "detail"}`, `pointer` being
|
|
138
|
+
`/<entity>/<index>/<field>` inside the chunk.
|
|
139
|
+
|
|
140
|
+
MCP: `import_world_data({ containerId | slug, rows, mode?, message? })`. `rows` is the JSON
|
|
141
|
+
object shape (`{entity: [rows]}`), at most 5,000 rows and 4 MiB per call: the inline lane,
|
|
142
|
+
one chunk through the same batch job. Returns `{ versionId, entityCounts, deduped }`; a
|
|
143
|
+
refused row is a tool error naming the field, and nothing is written.
|
|
144
|
+
|
|
145
|
+
### 2b. Extract rows from what you already have
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
gateway worlds data extract <WORLD> calls.jsonl --shape session-export --entity users --out users.jsonl
|
|
149
|
+
gateway worlds data extract <WORLD> response.json --shape vendor-envelope --entity records | gateway worlds data import <slug> -
|
|
150
|
+
gateway worlds data extract <WORLD> tool-results.jsonl --shape tool-results --entity records --merge upsert --no-redact
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Three shapes: `tool-results` (`raw_output.results[]` or `.items[]` of each line, rows that
|
|
154
|
+
carry the key), `vendor-envelope` (the vendor's response, one per line or one document; rows
|
|
155
|
+
under the world's `[api].envelope` key, the bare array when it is `""`), `session-export`
|
|
156
|
+
(`calls.jsonl`; `result.<envelope>[]` of successful `call` records). Every adapter drops null
|
|
157
|
+
and empty-string fields, strips fields the entity does not declare (counted on stderr, never
|
|
158
|
+
silently), dedupes by primary key (`--merge fill` default) and applies the world's `[redact]`
|
|
159
|
+
policy (`drop`, `hash` as `sha256:<hex>` of `<slug>:<value>`, `round`) unless `--no-redact`.
|
|
160
|
+
Output is tagged JSONL; the summary `{"read", "rows", "unknownFields", "redacted"}` is on
|
|
161
|
+
stderr.
|
|
162
|
+
|
|
163
|
+
Platform agent (console): the same `import_world_data`, plus `sandboxPath` for a rows file
|
|
164
|
+
already in the sandbox (any ROWS form above; `entity` for bare arrays/JSONL) instead of
|
|
165
|
+
`rows`. Build the file with code, then import — do not paste 4 MiB through `rows`.
|
|
166
|
+
`run_gateway_cli({ command: "data show" | "data check" | "data import" | "data extract", args: ["/workspace/<world>", ...] })`
|
|
167
|
+
is the local-directory form for a world you `load_world_to_sandbox`ed — the same TypeScript
|
|
168
|
+
`gateway worlds data …` commands and flags as above (`--entity`, `--mode`, `--merge`, `--dry-run`,
|
|
169
|
+
`--report`, `--shape`), no remote slugs; land the result with `ingest_to_world`. Capture pages are not rows: `get_connector_capture(downloadTo)` →
|
|
170
|
+
`run_gateway_cli connector ingest` → `ingest_to_world`.
|
|
171
|
+
|
|
172
|
+
### 3. Verify on a live session
|
|
173
|
+
|
|
174
|
+
Open a session, seed it, hit it. Live seeding does not change the world's version; it
|
|
175
|
+
changes this session only.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
gateway worlds session open <slug> -t <scenario> --surface api # prints sessionId and api.url
|
|
179
|
+
gateway worlds session seed <SESSION_ID> rows.json # kind:"seed" call, waits for the result
|
|
180
|
+
gateway worlds session seed <SESSION_ID> rows.json --mode replace # swap the named entities
|
|
181
|
+
curl -H 'x-api-key: any' "$API_URL/<route>" # read it back through the vendor's route
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Prints `{sessionId, mode, result}`. MCP: `seed_world_session({ sessionId, rows, mode? })` waits
|
|
185
|
+
up to 60 seconds for the engine and otherwise returns a `callId` to poll. Same caps as the
|
|
186
|
+
import. Public API: `POST /api/public/world-sessions/{sessionId}/calls` with
|
|
187
|
+
`{ kind: "seed", rows, mode }`.
|
|
188
|
+
|
|
189
|
+
The tools surface is open by default; `--surface api` adds the vendor's HTTP routes. A fresh
|
|
190
|
+
version's first session takes about fifteen minutes to come up (`PROVISIONING`, 503 on the
|
|
191
|
+
URL); that is a cold pod, not a fault. Pass `--no-wait` and poll
|
|
192
|
+
`gateway worlds session status <SESSION_ID>`.
|
|
193
|
+
|
|
194
|
+
Which kinds can seed live: schema worlds (the store applies the batch through the contract),
|
|
195
|
+
api worlds (the runner merges the rows into the whole state and posts it to the world's seed
|
|
196
|
+
route; `append` upserts where the world declares keys), mock-tools task worlds with an
|
|
197
|
+
`environment/schema.sql` (INSERTs against the live SQLite). Any other kind answers
|
|
198
|
+
`this world kind cannot be seeded live`.
|
|
199
|
+
|
|
200
|
+
Iterate here: seed, run the agent, adjust the rows, seed again with `--mode replace`. When
|
|
201
|
+
the rows are right, `data import` them so the next version carries them.
|
|
202
|
+
|
|
203
|
+
**Rows that belong to one task, not the world.** A World Host session can take its seed with
|
|
204
|
+
the open: `gateway worlds session open <slug> --task-file task.json`, where the file is
|
|
205
|
+
`{instruction, seed: {mode?, rows}, grader?, metadata?, name?}` and `seed.rows` is this same
|
|
206
|
+
rows contract (`{entity: [row, …]}`, primary-key upsert on `append`). The host lays the rows on
|
|
207
|
+
the fresh clone before the first call, and `session reset <SESSION_ID>` re-applies them, so an
|
|
208
|
+
episode restarts at the task's rows rather than the bare snapshot. Caps: 5,000 rows / 4 MiB per
|
|
209
|
+
task seed; a row for an entity the version's contract does not declare is refused at open with
|
|
210
|
+
the entity's name. SDK: `openSession(slug, { task: { instruction, seed } })` /
|
|
211
|
+
`open_session(slug, {"instruction": …, "seed": …})`. `session state <SESSION_ID>` prints
|
|
212
|
+
every entity's rows as the world holds them now (the dump a grader reads) — the quickest way
|
|
213
|
+
to see what a seed did.
|
|
214
|
+
|
|
215
|
+
### 4. Export a real run as rows
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
gateway worlds session export <SESSION_ID> --out calls.jsonl
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Each line is `{seq, kind, tool, args, result, error, state, createdAt, completedAt}`, the
|
|
222
|
+
session's call log oldest first; `kind` is one of `call`, `grade`, `seed`, `state`, `reset`, `close`.
|
|
223
|
+
MCP: `export_world_session({ sessionId, limit? })` returns the same records. Public API:
|
|
224
|
+
`GET /api/public/world-sessions/{sessionId}/calls` (paged by `cursor` and `limit`).
|
|
225
|
+
|
|
226
|
+
To turn it into a rows file, keep successful calls whose results are rows of one entity and
|
|
227
|
+
map them to the entity's fields. The schema, not the tool, decides the shape:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
jq -c 'select(.kind == "call" and .error == null and .tool == "list_users")
|
|
231
|
+
| .result.users[]? | {entity: "users", row: .}' calls.jsonl > users.jsonl
|
|
232
|
+
gateway worlds data import <WORLD> users.jsonl
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Sanitize before importing: hash or drop personal fields the world's redaction policy
|
|
236
|
+
(`[redact]` in `connector.toml`) would have hashed or dropped. Customer rows never enter a
|
|
237
|
+
shared template.
|
|
238
|
+
|
|
239
|
+
## Failure modes
|
|
240
|
+
|
|
241
|
+
| You see | Cause | Do |
|
|
242
|
+
| --- | --- | --- |
|
|
243
|
+
| `<file> is a bare array; say which entity it holds with --entity` | bare rows without `--entity` | add `--entity NAME` |
|
|
244
|
+
| `<file> maps entities; drop --entity or make the file a bare array` | object shape given with `--entity` | drop the flag |
|
|
245
|
+
| `Unknown entity X; the world has a, b, c` | name is not in `schema/world.json` | `data show` lists entities; fix the name |
|
|
246
|
+
| `No table X in db/schema.sql; tables: ...` / `Column c is not in table t; columns: ...` | mock-tools name mismatch | fix the name; nested values must be encoded as text yourself |
|
|
247
|
+
| `Row is missing primary key field 'id'` at `/users/3` | a row lacks its key | add the key; nothing was written |
|
|
248
|
+
| a contract error at `/<entity>/<index>/<field>` | type, enum, required or reference broken | fix that row; nothing was written |
|
|
249
|
+
| refused, kind `api` (or `harbor`), naming the file to edit | the world is a generated bundle or a task suite | edit the named source, `bench push` again |
|
|
250
|
+
| `version` missing from the result | a local directory was given | push with `gateway bench push <dir>` when ready |
|
|
251
|
+
| `exceed the inline cap ... import into the platform world <slug>` | a directory import above 5,000 rows / 4 MiB | import into the platform slug (chunked), or `--dry-run` to check locally |
|
|
252
|
+
| exit 2, `state: refused` | the platform refused the batch; `--report` has every record | fix the rows named, `--resume` is not for this: run the import again |
|
|
253
|
+
| `nothing to resume` / `only an open or uploading batch resumes` | no incomplete manifest, or the batch already ran | run the import without `--resume` |
|
|
254
|
+
| `409 base_mismatch` from `/__world/seed` | the overlay named another snapshot digest than the pod is on | the runner posts the digest of the version's snapshot; a mismatch is a version mismatch, never reseed silently |
|
|
255
|
+
| `world snapshot refused: ... sha256` at pod start | `WORLD_SNAPSHOT_SHA256` does not match the download | the platform must hand out the snapshot's own sha256; the pod exits 2 rather than serve the wrong data |
|
|
256
|
+
| `this world kind cannot be seeded live` | the session's engine has no seed door | import into the world instead and open a new session |
|
|
257
|
+
| `A seed call carries at most 5000 rows` / `exceed 4 MiB` | one call too large | split the file |
|
|
258
|
+
| session stays `PROVISIONING` | cold pod on a fresh version | wait up to twenty minutes; `session status` |
|
|
259
|
+
| duplicate rows after a live append on an api world | the world declares no primary keys, so append adds without upserting | use `--mode replace`, or declare keys in `world.json` |
|
|
260
|
+
|
|
261
|
+
## Data snapshots (why a served world starts in under a second)
|
|
262
|
+
|
|
263
|
+
A schema world's validated database is kept, not rebuilt. `gateway worlds schema compile`
|
|
264
|
+
builds `db/state.sqlite` (the default snapshot: `data/initial.json` applied through the
|
|
265
|
+
contract) and `scenarios/<name>/state.sqlite` (the default with the scenario's overlays),
|
|
266
|
+
each with a `state.json` sidecar `{contractHash, batchDigest, entityCounts, builtAt,
|
|
267
|
+
runtime, fileSha256}`; the same key is never rebuilt, `schema check` verifies the sidecars,
|
|
268
|
+
and a data batch the contract refuses leaves no snapshot behind. `gateway worlds serve` and
|
|
269
|
+
the api bundle open the snapshot (copy + `SQLiteStore.open`, no row replay) and reset by
|
|
270
|
+
copying it again; without one the JSON is replayed as before. A hosted pod gets
|
|
271
|
+
`WORLD_SNAPSHOT_URL` (presigned GET, `.gz` or `Content-Encoding: gzip` is gunzipped),
|
|
272
|
+
`WORLD_SNAPSHOT_SHA256` and `WORLD_SNAPSHOT_DIGEST`; the server downloads, verifies, writes
|
|
273
|
+
the sidecar and only then serves; a mismatch exits 2 naming the digest. `/__world/state`
|
|
274
|
+
reports `"snapshot": {batchDigest, contractHash}` (or null) and `/__world/seed` takes the
|
|
275
|
+
overlay form `{"base": digest, "rows": {...}, "mode": append|replace}` beside the legacy
|
|
276
|
+
whole-state body. Snapshot files are build outputs: gitignore `db/state.sqlite`,
|
|
277
|
+
`db/state.json`, `scenarios/*/state.*`.
|
|
278
|
+
|
|
279
|
+
## Definition of done
|
|
280
|
+
|
|
281
|
+
- [ ] `gateway worlds data show <WORLD>` before and after; the counts moved by what you sent.
|
|
282
|
+
- [ ] The import printed `entity_counts` (directory) or `state: applied|published` with a `versionId` (slug); a refused batch has its `--report`.
|
|
283
|
+
- [ ] A session opened on that version answers the rows (tools surface or vendor route).
|
|
284
|
+
- [ ] Rows carry no unsanitized customer data; `captures/` and `data/` stay out of templates.
|
|
285
|
+
- [ ] If the rows came from a run: `calls.jsonl` is kept beside the rows file with the session id.
|
|
286
|
+
|
|
287
|
+
## Related
|
|
288
|
+
|
|
289
|
+
- `worlds-getting-started`: the whole path, auth to runs, CLI with MCP twins.
|
|
290
|
+
- `connector-schema-authoring`: the data model the rows are checked against.
|
|
291
|
+
- `documentation/features/world-data-ingestion.md`: what exists, the contract, code pointers.
|
|
292
|
+
- `documentation/features/connector-worlds.md`: captures, ingest, serving the vendor's API.
|
|
293
|
+
- Consumer page: `gateway_documentation/pages/worlds/data.mdx`.
|