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,313 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: connector-schema-authoring
|
|
3
|
+
description: Checklist for creating or updating an SDK connector schema contract (Microsoft Teams, Slack, GitHub, Salesforce, Microsoft 365 / Entra ID, or any connector). Use when adding templates, authoring vendor schemas, choosing fidelity shape, recording provenance, or validating fixtures through the schema-aware store. Also covers optional tenant overlays, tools, MCP comparison, live evidence, and later platform integration, distinguishing implemented tooling from future work. Covers gateway-world/1, schema init/compile/check, store.ingest, honest fidelity assessment, and the definition of done.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> **For agents.** This copy ships inside the `gatewaysdk` Python package and is installed
|
|
7
|
+
> into a repository by `gateway worlds connector skill --install .` (with the
|
|
8
|
+
> `connector-template-author` agent under `.claude/agents/`). Author the template with the
|
|
9
|
+
> checklist below; when it compiles and conforms, `gateway worlds connector publish <dir>`
|
|
10
|
+
> turns it into a workspace connector — an org-owned, versioned object on the platform that
|
|
11
|
+
> worlds are initialized from (`gateway worlds schema init ./x --connector workspace:<slug>`)
|
|
12
|
+
> and that can be published to every organization and cloned. The `briefs/` directory and
|
|
13
|
+
> the repository-relative links below are not shipped; the checklist stands on its own.
|
|
14
|
+
|
|
15
|
+
# Connector Schema Authoring
|
|
16
|
+
|
|
17
|
+
## Purpose
|
|
18
|
+
|
|
19
|
+
Author an SDK schema contract with documented scope and fidelity evidence.
|
|
20
|
+
The **data model is the deliverable**; tools are optional consumers.
|
|
21
|
+
The checklist distinguishes implemented commands from future tooling.
|
|
22
|
+
|
|
23
|
+
Read first, in this order:
|
|
24
|
+
|
|
25
|
+
1. [world-schema.md](../../../documentation/features/world-schema.md): the `gateway-world/1` contract, store API, raw ingestion, templates.
|
|
26
|
+
2. [connector-capture-and-schema-handoff.md](../../../documentation/architecture/connector-capture-and-schema-handoff.md): the implemented capture boundary and future mapper contract.
|
|
27
|
+
3. [CONNECTORS.md](CONNECTORS.md) in this folder: per-connector shape, model source, tenant channel, sandbox.
|
|
28
|
+
4. [briefs/](briefs/README.md): one self-contained work order per connector (sources to pin, entities, tools, errors, sandbox, definition of done); the `connector-template-author` agent implements one brief.
|
|
29
|
+
5. [CONVENTIONS.md](CONVENTIONS.md) in this folder: the generation standard every template follows (identity, prefixes, keys, types, tools, data, layout), enforced by `test_committed_templates_follow_the_generation_conventions`.
|
|
30
|
+
6. [gateway-tool-access.md](../../../documentation/integrations/gateway-tool-access.md) only if the world declares an MCP surface.
|
|
31
|
+
|
|
32
|
+
The formerly referenced `connector-fidelity-scope.md` and
|
|
33
|
+
`connector-platform-infra-plan.md` are absent from this checkout. Do not reconstruct
|
|
34
|
+
them or treat their old work-item identifiers as authoritative. Verify current code
|
|
35
|
+
and scope the milestone explicitly: SDK schema authoring does not require provider
|
|
36
|
+
registration, a platform builder, live ingestion, tools, or a registry framework.
|
|
37
|
+
|
|
38
|
+
## The rules that never bend
|
|
39
|
+
|
|
40
|
+
- **The schema is the deliverable.** A world with a faithful model and no tools is complete. Tools are added when wanted, by whoever wants them.
|
|
41
|
+
- **Every write goes through the schema.** Handlers use `gateway_env.store`; ingestion uses `store.apply_batch` or `store.ingest`; nothing else writes. Out-of-contract writes are rejected with the reason.
|
|
42
|
+
- **Check the right boundary.** Compile/check validate compiled artifacts; materialization and store operations validate persisted data. Publication checks actual bundle bytes, handler declarations and initial state through the trusted runtime. Fidelity evidence and Environment Actions remain advisory.
|
|
43
|
+
- **Fidelity shape is decided by the vendor, not by a house rule.** A **base** connector is prebaked once (Slack). A **tenant-shaped** connector's model is mostly customer-defined, so describe at bind time is required (Salesforce, NetSuite, Workday). A **mixed** connector is a base plus an optional overlay (Okta, Entra, Google, LDAP, Jamf).
|
|
44
|
+
- **Surface parity is advisory.** If the world declares it mirrors an MCP surface, produce the parity report and show it. Never block on it, never shrink or bend the model to satisfy it.
|
|
45
|
+
- **The label is honest.** Compilation and synthetic fixtures do not establish live fidelity or behavioral equivalence. Use a provisional `subset` assessment when coverage or evidence is incomplete; identify synthetic fixtures as synthetic. Never invent replay scores or claim `mimic` without measured supporting evidence. A check that could not run is `skipped`, never `passed`.
|
|
46
|
+
- **Customer data never enters a shared template.** Sanitize captured goldens; keep tenant overlays private.
|
|
47
|
+
- **Anyone can author a contract.** SDK-shipped and user-authored contracts use the same compiler/store checks. Platform registration is a separate milestone.
|
|
48
|
+
- **A customer's connectors are the customer's.** A world we build for a customer against their third-party providers is their custom connector: it is authored from `--connector custom` (or their own template) in their project or untracked staging, pushed to their project, and never merged as an SDK template, catalog row or reserved prefix. The repo ships the abstraction (`connector.toml`, capture, ingest, the world's API), not their worlds.
|
|
49
|
+
|
|
50
|
+
## Tooling status (2026-09-07)
|
|
51
|
+
|
|
52
|
+
| Command or path | Status |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `gateway worlds schema init PATH --connector <slug> [--name NAME]` | exists (#219); `--connector custom` is the blank starting point for an arbitrary connector |
|
|
55
|
+
| `gateway worlds connector validate\|capture\|ingest PATH` | exists; a `connector.toml` in the world describes base URL, auth scheme, pacing, redaction and operations; `capture` records paced, redacted pages (errors included) under `captures/` with the secret never written; `ingest` seeds `data/initial.json` through the contract in a scratch copy first |
|
|
56
|
+
| `gateway worlds connector conform PATH --openapi vendor.yaml` | exists; serves the world in-process, calls every declared operation with arguments from its own seed, and checks status + body against the vendor's OpenAPI response schemas; non-zero exit on any mismatch. Run it before calling a world 1:1; its FAIL list is the work list (unseeded entities → 404s, creates the contract rejects → 4xx, honest 501s) |
|
|
57
|
+
| `gateway worlds connector capture PATH --op … --remote` | exists; the platform runs the capture (web pod egress = the allow-listed NAT IP) with `gateway bench secrets set` credentials; pages land in the drive under `worlds/<slug>/captures/` and are pulled into the world's `captures/` with the manifest merged |
|
|
58
|
+
| `gateway worlds serve PATH` / `gateway bench push PATH` | exists; `serve` answers the vendor's routes from the world's store locally (stdlib only); `bench push` on a world carrying `connector.toml` packages the api-kind bundle the platform hosts itself (`gateway worlds schema api-bundle` writes it explicitly) |
|
|
59
|
+
| `gateway worlds schema compile \| check \| describe PATH` | exists (#216) |
|
|
60
|
+
| `gateway worlds schema entity add PATH NAME --ref D \| --fields "a:string,b:integer?" \| --schema JSON --key F [--unique F,F] [--relationship F->entity]` | exists (TS CLI, local); declares one entity in `schema/world.json` without hand-editing the document: keeps `$defs`, package metadata and other entities byte-for-byte in meaning, refuses duplicate names, non-required or non-string/integer keys, unknown `$defs` and undeclared relationship targets, and writes nothing on refusal |
|
|
61
|
+
| `gateway worlds connector route add PATH NAME --path /v1/x/{id} [-X POST] [--param q] [--entity E] [--results r] [--action create] [--filter id=id] [--body f=p] [--handler fn]` | exists (TS CLI, local); appends one `[[operations]]` (+ `[operations.api]`) to `connector.toml` leaving existing bytes untouched; validates name, method, path, entity against `schema/world.json`, filter keys against `{args}`/params, and the handler/action pairing |
|
|
62
|
+
| `gateway worlds connector publish DIR [--slug S] [-m MSG] [--tag T] [--workspace-visible] [--project-scope]` | exists; saves a template directory, or the world it was authored in, as a workspace connector (Context Hub `connector` repo, org-owned, versioned); the platform compiles the template before accepting it and answers 400 with the reason; a re-publish is a new commit and paths no longer present are removed; `data/`, `captures/`, `db/` and generated files stay behind |
|
|
63
|
+
| `gateway worlds connector list [--hub] [--query Q]` / `pull SLUG [--out DIR] [--version V]` / `clone SLUG-OR-ID [--name N] [--slug S]` | exists; `list` shows this org's connectors (vendor, auth, entities, operations), `--hub` adds every connector another org published; `pull` writes the template files; `clone` copies a published connector into this org with provenance — a live reference is never made, so the publisher's later edits need a re-clone |
|
|
64
|
+
| `gateway worlds schema init PATH --connector workspace:<slug>` | exists; initializes from the platform's copy through `init_bundle_from_files` (needs `GATEWAY_*` keys); the offline `python -m gatewaysdk.environment.schema init` refuses `workspace:` and names this command |
|
|
65
|
+
| `gateway worlds connector skill [--install DIR] [--force]` | exists; prints this skill, or installs it (SKILL.md, CONVENTIONS.md, CONNECTORS.md) plus the `connector-template-author` agent under `DIR/.claude/`; never overwrites a differing file without `--force`; the packaged copy is `gatewaysdk/environment/schema/skills/` and a test keeps it in sync with this file — re-copy it (with its "For agents" note) after editing here |
|
|
66
|
+
| `world.store.ingest(...)`, `store.apply_batch(...)` | exists (#219, #216) |
|
|
67
|
+
| Connector templates under `gatewaysdk/sdk/src/gatewaysdk/environment/schema/connectors/` | authored templates; see [CONNECTORS.md](CONNECTORS.md), including the schema-only Microsoft Teams base |
|
|
68
|
+
| `gateway worlds schema import PATH --from <kind> --spec <url\|path> [--scope scope.toml]` | not implemented; author the contract and provenance manually |
|
|
69
|
+
| `gateway worlds schema parity PATH --surface <tools-list.json> \| --connection <id>` (advisory report) | not implemented |
|
|
70
|
+
| `gateway worlds playground <connector>` | not implemented |
|
|
71
|
+
| Platform upload of a JSON Schema, OpenAPI, or DDL as a new connector | not implemented as a UI upload; the platform agent's `create_custom_world` takes an authored `gateway-world/1` document, inline files, a sandbox tree or `--connector`-style `template` and publishes it through the trusted `compile` bridge (2026-09-09) |
|
|
72
|
+
| Platform agent record ingestion (`ingest_records_to_world` → `platform.py apply-batch`, `ingest_to_world` file writes with recompile, `describe_world_schema`, `load_world_to_sandbox`) | exists; schema-gated, `batchId` idempotent, one immutable READY version per call, project-scoped; see `documentation/features/agent.md` |
|
|
73
|
+
| SDK/public and platform publication | validates assembled files and actual stored archive bytes through the trusted compiler/materializer, including READY/dedup/ref paths |
|
|
74
|
+
| Connectors Slack world creation | durable structured capture → shared Python mapper → immutable publication; explicit synthetic mode |
|
|
75
|
+
| Worker schema tests/workbench | shared validation and isolated E2B author execution; missing isolation is non-green |
|
|
76
|
+
| Hosted schema tools sessions | standalone `mock-tools` worlds use the shared `World` child for calls, grading and reset; composed dependencies and API/Harbor/verifiers schema engines remain unsupported |
|
|
77
|
+
|
|
78
|
+
Do only the manual work authorized by the milestone; record unavailable tooling and
|
|
79
|
+
skipped live checks without expanding a schema task into connector implementation.
|
|
80
|
+
|
|
81
|
+
## The checklist
|
|
82
|
+
|
|
83
|
+
Copy the applicable items into the PR description. Sections 2, 3, 5, 6, and platform
|
|
84
|
+
registration apply only when the milestone includes those capabilities. A schema-only
|
|
85
|
+
deliverable can finish with synthetic fixtures and explicitly skipped live validation.
|
|
86
|
+
|
|
87
|
+
### 0. Decide the shape
|
|
88
|
+
|
|
89
|
+
- [ ] **Fidelity shape**: base, tenant-shaped, or mixed. See [CONNECTORS.md](CONNECTORS.md). Tenant-shaped means describe-on-bind is a requirement of the world, and the shared template is only a skeleton.
|
|
90
|
+
- [ ] **Model source**: authored by hand (start from `--connector custom`), imported (`openapi`, `odata-csdl`, `discovery`, `wsdl-xsd`, `ldap-subschema`, `describe`, `docs`), or uploaded. Pin the spec URL and version now.
|
|
91
|
+
- [ ] **Scope of the model**: which entities and fields, decided from what the connector's users need the world to be faithful about. Record the reasoning in `scope.md` or `scope.toml`; coverage of the vendor's full model is reported, not required.
|
|
92
|
+
- [ ] **Sandbox**: record whether live validation is available and in scope. If it is not, record the reason and mark live checks `skipped`; a schema foundation can still ship as provisional `subset`.
|
|
93
|
+
- [ ] **Tools and surface** (optional): none, generated defaults, hand-written, user's custom, or mapped to an MCP surface. Decide now so the entity scope covers what those tools touch.
|
|
94
|
+
|
|
95
|
+
### 1. Build the model
|
|
96
|
+
|
|
97
|
+
- [ ] Author `schema/world.json` and reusable sibling definitions from pinned vendor sources, following the type-mapping notes in [CONNECTORS.md](CONNECTORS.md). `gateway worlds schema entity add` declares an entity with its key, uniques and relationships in one command so the declaration shape is never wrong; hand-author only the payload definitions (`--schema` or `$defs`). Record source URLs, versions/retrieval dates, and hashes of the actual retrieved bytes in `schema/provenance.json`.
|
|
98
|
+
- [ ] Entities have the vendor's keys, relationships, enums, and nullability, and follow [CONVENTIONS.md](CONVENTIONS.md): one reserved prefix per template, plural snake_case names, vendor casing on fields, shared `base.json` primitives. Reserved prefixes and the `payload` name are avoided.
|
|
99
|
+
- [ ] Enforce supported required fields, types, enums, key uniqueness, and reference integrity. Document vendor rules the dialect cannot express, normalization choices, and constraints the future mapper must enforce; structural validation is not vendor behavior.
|
|
100
|
+
- [ ] `gateway worlds schema compile PATH` then `check PATH` pass. Never edit generated files; SDK templates contain authored inputs and generate bundle artifacts at `init` time.
|
|
101
|
+
- [ ] Shared templates and committed fixtures hold synthetic data only. Tenant captures stay in their owning project; initial batches and refresh journals retain explicit capture/synthetic provenance.
|
|
102
|
+
|
|
103
|
+
### 2. Tenant overlay (required for tenant-shaped, optional for mixed, absent for base)
|
|
104
|
+
|
|
105
|
+
- [ ] No automatic overlay/describe-on-bind implementation exists. When tenant integration is in scope, run the vendor describe manually through an authorized connection and document the authored overlay process.
|
|
106
|
+
- [ ] The overlay is additive only: new entities, fields, enum values. A retype or removal is drift and becomes a proposal on the template.
|
|
107
|
+
- [ ] The overlaid world compiles and passes `check`; its lock differs from the template's.
|
|
108
|
+
- [ ] For tenant-shaped connectors, the badge states that an unbound world is a skeleton.
|
|
109
|
+
|
|
110
|
+
### 3. Playground and evidence
|
|
111
|
+
|
|
112
|
+
- [ ] Keep sandbox credentials in authorized secret storage, never in a shared template or bundle. Do not assume an internal playground project has been provisioned.
|
|
113
|
+
- [ ] Seed synthetic records through the vendor write API where the sandbox allows it (seedable table in [CONNECTORS.md](CONNECTORS.md)); seeding is idempotent.
|
|
114
|
+
- [ ] Pull records back through the vendor API and land them with `store.ingest(source=..., mapping=...)`; `audit()` passes with zero violations.
|
|
115
|
+
- [ ] Distinguish captured, sanitized vendor goldens from wholly synthetic fixtures. Record actual replay methods and results when available; no replay runner or universal score threshold is implemented here.
|
|
116
|
+
- [ ] Production evidence requires an authorized capture workflow and sanitized records; do not infer that a generic grant flag or vendor mapper already exists.
|
|
117
|
+
|
|
118
|
+
### 4. Fidelity report
|
|
119
|
+
|
|
120
|
+
- [ ] `fidelity.json` records shape, assessment, scope coverage, source identity, and measured or skipped checks with reasons. Include a replay score only when replay ran; include parity only when a surface is declared.
|
|
121
|
+
- [ ] The label follows the checks. Reasons for `subset` are listed.
|
|
122
|
+
- [ ] A check that could not run is `skipped`.
|
|
123
|
+
|
|
124
|
+
### 5. Tools (only if the world ships tools)
|
|
125
|
+
|
|
126
|
+
- [ ] Every tool in `x-gateway.tools` has exactly one handler in `tools/*.py` (the loader refuses a mismatch); generated defaults are fine.
|
|
127
|
+
- [ ] Handler reads use `gateway_env.store.get` / `list`; writes use `insert` / `update` / `delete`. Read-only SQL uses `gateway_env.db.one/all`; raw SQL writes are denied. The host's `SQLiteStore.query` is not exposed by the handler store proxy.
|
|
128
|
+
- [ ] Handlers never read `benchmark_runtime_context` or `benchmark_conversation_events`.
|
|
129
|
+
- [ ] A user attaching custom tools to this world needs nothing from this checklist beyond the store API; document any conventions the model expects (key formats, enum values).
|
|
130
|
+
|
|
131
|
+
### 6. Surface binding (only if the world declares it mirrors an MCP surface)
|
|
132
|
+
|
|
133
|
+
- [ ] Export a real connection's filtered `tools/list` through the MCP proxy under a grant, or inspect its `AgentSecurityResource` tool rows. Native Slack source capture has no live MCP catalog; its schema template tools are separate offline behavior.
|
|
134
|
+
- [ ] Produce an advisory comparison of names and input schemas, recording coverage and mismatches in `parity.json`. Do not alter the model to satisfy it; report unsupported tool-contract constructs explicitly.
|
|
135
|
+
- [ ] Compare read-only tools manually against a live connection only when such comparison is authorized and in scope.
|
|
136
|
+
- [ ] Native manifest changes bump `TOOL_VERSIONS`.
|
|
137
|
+
|
|
138
|
+
### 7. Ship the template; register platform integration only when in scope
|
|
139
|
+
|
|
140
|
+
- [ ] SDK-shipped: commit authored files under `gatewaysdk/sdk/src/gatewaysdk/environment/schema/connectors/<slug>/`; `list_templates()` and `test_schema_scaffold.py` cover the slug and preserve its authored dependencies/provenance during initialization. Schema-only templates declare an empty tools map and have no operation handlers.
|
|
141
|
+
- [ ] Platform integration, if separately in scope: map an existing source kind in `schemaWorldTemplates.ts` so "Build from connector" offers it. Do not register a native provider or invent a source kind for an SDK-only schema milestone.
|
|
142
|
+
- [ ] Treat `connectionMode` as the primary authentication path, not the only setup path. A managed connector may retain `remoteMcpPreset` as a fallback; render that action from the preset's presence. For native source connectors such as Slack, the source-backed Link action is the managed authentication path because native-provider dispatch intentionally precedes Merge.
|
|
143
|
+
- [ ] User-added templates can use `--connector custom` and SDK publication. Generic schema upload and shared/project registry infrastructure remain unimplemented.
|
|
144
|
+
- [ ] Record shape, assessment, coverage, source hashes, and limitations in the PR and authored metadata.
|
|
145
|
+
- [ ] Docs updated: `world-schema.md` template list, `environment-files.md` if the panel changed, [CONNECTORS.md](CONNECTORS.md) row.
|
|
146
|
+
- [ ] Pin source versions/retrieval dates and document a revalidation procedure; automated vendor drift checks are not supplied by this checklist.
|
|
147
|
+
|
|
148
|
+
### 8. Definition of done
|
|
149
|
+
|
|
150
|
+
- [ ] Relevant schema test suites and required scoped checks pass, including the slug in the scaffold suite if SDK-shipped. Report exact commands and results.
|
|
151
|
+
- [ ] Synthetic fixture round trips exercise the store boundary. Live round trips either have recorded results or a dated `skipped` reason; never claim them from offline tests.
|
|
152
|
+
- [ ] For tenant-shaped integration milestones, an overlay comes from an authorized tenant; a schema-only skeleton states that limitation. Base connectors require no tenant overlay.
|
|
153
|
+
- [ ] Fixtures identify their origin; captured goldens are sanitized and distinct from synthetic examples. No customer data enters the shared template.
|
|
154
|
+
- [ ] Shape, label and coverage in the PR description; parity summary if a surface is declared.
|
|
155
|
+
- [ ] Review flags resolved; report observed CI status without claiming checks that did not run; docs and [CONNECTORS.md](CONNECTORS.md) updated.
|
|
156
|
+
|
|
157
|
+
## Runtime authoring boundary
|
|
158
|
+
|
|
159
|
+
When adding a bridge command to `schema/platform.py`, mirror it as a typed wrapper in
|
|
160
|
+
`worldSchemaRuntime.ts` (`compileWorldFiles` / `applyWorldBatch` are the pattern: file map
|
|
161
|
+
in, `{entries, report, ...}` out, errors as `SchemaBridgeError`), cover it in
|
|
162
|
+
`tests/environment/test_schema_platform.py`, and let the agent tool call the wrapper, never
|
|
163
|
+
the subprocess. The bridge needs Python ≥ 3.11 (`tomllib`); set `GATEWAY_SCHEMA_PYTHON`
|
|
164
|
+
when the default interpreter is older.
|
|
165
|
+
|
|
166
|
+
Use `worldSchemaRuntime.ts` for platform validation and `schema.platform` for
|
|
167
|
+
the Python bridge. Publication parses bundle Python without importing it on the
|
|
168
|
+
web or worker host. Schema workbench edits use `/workspace/schema_edit.py` with
|
|
169
|
+
an explicit batch; publish the resulting ordered `data/batches/*.json` journal,
|
|
170
|
+
not a raw database dump. The hosted session owns an isolated shared `World` and
|
|
171
|
+
receives no provider tokens. API/Harbor/verifiers schema runtimes and hosted
|
|
172
|
+
dependency composition retain explicit rejection.
|
|
173
|
+
|
|
174
|
+
## Implementing many connectors in parallel
|
|
175
|
+
|
|
176
|
+
Once a brief exists for every connector, spawn one `connector-template-author` agent
|
|
177
|
+
per brief (`.claude/agents/connector-template-author.md`). Overlap is prevented by
|
|
178
|
+
ownership, not by coordination:
|
|
179
|
+
|
|
180
|
+
- Each agent writes only `connectors/<slug>/`, its own rows in `CONNECTORS.md`, and its
|
|
181
|
+
own line in `PREFIXES`. Prefixes for the whole catalog are reserved in
|
|
182
|
+
`test_schema_scaffold.py` before any agent starts.
|
|
183
|
+
- Shared files (`base.json`, `scaffold.py`, compiler, store, `schemaWorldTemplates.ts`)
|
|
184
|
+
are orchestrator-only. An agent that needs a shared change stops and reports it.
|
|
185
|
+
- The gate is the same for every branch: `test_committed_templates_follow_the_generation_conventions`
|
|
186
|
+
plus the full `tests/environment` suite. One PR per connector, stacked or independent.
|
|
187
|
+
- The orchestrator merges in wave order, re-runs the suite after each merge, and reconciles
|
|
188
|
+
`CONNECTORS.md` if two agents touched adjacent rows.
|
|
189
|
+
|
|
190
|
+
Full procedure: `.llm_artifacts/plans/connector-implementation-orchestration.md`.
|
|
191
|
+
|
|
192
|
+
## Common mistakes
|
|
193
|
+
|
|
194
|
+
- Treating the MCP tool list as the model. The model comes from the vendor's schema and the tenant; tools are mapped onto it afterwards, if at all.
|
|
195
|
+
- Blocking or bending the model because a declared surface does not match. Report the mismatch; the model stays faithful to the system.
|
|
196
|
+
- Shipping a tenant-shaped connector (Salesforce, NetSuite, Workday) as if its skeleton were the model. Describe-on-bind is required there.
|
|
197
|
+
- Adding a required overlay step to a base connector. Slack and the Microsoft Teams collaboration base do not require tenant schema discovery.
|
|
198
|
+
- Skipping the round trip silently when there is no sandbox. Record the blocker and set the label.
|
|
199
|
+
- Committing captured production records as goldens without sanitizing them.
|
|
200
|
+
- Assuming a planned command exists. Check current tooling and perform only in-scope manual work.
|
|
201
|
+
- Treating descriptive resources as schema authority. `init` preserves flat supporting `.json`, `.md` and `.toml` files; only referenced schemas become compiler inputs. Slack capability defaults expand into self-contained entries; see [world-schema.md](../../../documentation/features/world-schema.md#connector-templates-and-init).
|
|
202
|
+
- Converting Slack message timestamps to floats or RFC3339. Preserve exact `(workspace_id, channel_id, ts)` keys; see the [Slack model guide](../../../gatewaysdk/sdk/src/gatewaysdk/environment/schema/connectors/slack/MODEL.md) for normalization and limits.
|
|
203
|
+
|
|
204
|
+
## Where this skill is discoverable
|
|
205
|
+
|
|
206
|
+
This file is the source. It is not published to the platform Context Hub, but it ships with the
|
|
207
|
+
Python SDK as package data so an agent in any repository can install it.
|
|
208
|
+
|
|
209
|
+
| Harness | How it finds this skill |
|
|
210
|
+
| --- | --- |
|
|
211
|
+
| Claude Code | `skill-rules.json` triggers (prompt keywords, intent patterns, file paths) and the Skills table in `CLAUDE.md` |
|
|
212
|
+
| Codex | the Skills table in `AGENTS.md` |
|
|
213
|
+
| Cursor | `.cursor/rules/connector-schema-authoring.mdc` (agent-requestable, points here) |
|
|
214
|
+
| Any harness, any repository | `gateway worlds connector skill --install .` writes the packaged copy (this file + CONVENTIONS.md + CONNECTORS.md and the `connector-template-author` agent) under that repository's `.claude/`; `briefs/` is not shipped |
|
|
215
|
+
|
|
216
|
+
## Related
|
|
217
|
+
|
|
218
|
+
- [session-trace-parity](../session-trace-parity/SKILL.md): unrelated parity rule for sessions and traces.
|
|
219
|
+
- [Microsoft Teams schema](../../../documentation/features/microsoft-teams-schema.md): schema-only collaboration scope, source provenance, and future mapper obligations.
|
|
220
|
+
- [prisma-migration-patterns](../prisma-migration-patterns/SKILL.md): only when separately authorized platform infrastructure requires database migrations.
|
|
221
|
+
- [backend-dev-guidelines](../backend-dev-guidelines/SKILL.md): for the tRPC route and worker queue conventions the platform pieces follow.
|
|
222
|
+
|
|
223
|
+
## Source verification
|
|
224
|
+
|
|
225
|
+
Revalidated 2026-09-07 while integrating `ba89fe16` with `015d6b25`:
|
|
226
|
+
`schema/scaffold.py`, `schema/platform.py`, `tests/environment/test_schema_scaffold.py`,
|
|
227
|
+
`worldSchemaPublication.ts`, `worldSchemaRuntime.ts`, `environmentBundleTester.ts`,
|
|
228
|
+
`environmentBuildWorkbench.ts`, `environmentSchemaSandbox.ts`,
|
|
229
|
+
`NativeSlackService.ts`, and `deploy/benchmark-runner/engines/{session_server,schema_session}.py`.
|
|
230
|
+
Full source paths and runtime boundaries are listed in [world-schema.md](../../../documentation/features/world-schema.md).
|
|
231
|
+
These source checks do not imply live-provider validation or executed fidelity scores.
|
|
232
|
+
|
|
233
|
+
## Custom connections (any vendor with an API key)
|
|
234
|
+
|
|
235
|
+
A world can describe the vendor it mirrors in `connector.toml` at its root: base URL,
|
|
236
|
+
auth scheme (`header`, `bearer`, `basic`, `query`, `oauth2`, `none`) with the secret named by an
|
|
237
|
+
environment variable, capture pacing, a redaction policy (`hash` or `drop` fields at any
|
|
238
|
+
depth), and the operations the agent actually calls (method, path with `{args}`, query
|
|
239
|
+
params, and the entity plus results path their rows land in). The same file is meant to
|
|
240
|
+
drive the platform's custom source later, so describe once.
|
|
241
|
+
|
|
242
|
+
- `gateway worlds connector validate PATH` parses the spec and lists operations.
|
|
243
|
+
- `gateway worlds connector capture PATH --op NAME --arg k=v --param k=v` calls the live
|
|
244
|
+
connection, follows the spec's cursor up to `max_pages`, and writes every page under
|
|
245
|
+
`captures/<op>/` plus `captures/manifest.json` (sha256 per file). The recorded request
|
|
246
|
+
never carries the secret; bodies are redacted before they touch disk; non-2xx replies are
|
|
247
|
+
recorded too, since the vendor's error bodies are part of the contract, and end the run.
|
|
248
|
+
- `gateway worlds connector ingest PATH` turns the successful captures into the world's
|
|
249
|
+
`data/initial.json` batch (rows deduped by primary key against what the batch already
|
|
250
|
+
holds: new rows insert, changed rows update, unchanged rows are skipped), proves the batch
|
|
251
|
+
applies in a scratch copy, then writes it and recompiles. Nothing new means nothing written.
|
|
252
|
+
|
|
253
|
+
Three refinements the first three vendors forced:
|
|
254
|
+
|
|
255
|
+
- **Vendors inline what the convention splits.** A user row that carries `channels[]`
|
|
256
|
+
does not fit a closed `users` entity when memberships are their own entity. Per
|
|
257
|
+
operation, `[operations.ingest] drop = ["channels"]` removes the inline collection from
|
|
258
|
+
the parent, and `[[operations.ingest.explode]]` turns each item into a child row:
|
|
259
|
+
`field`, `entity`, `carry = { user_id = "id" }` (child field from the parent row) and
|
|
260
|
+
`take = { channel_id = "entity_id" }` (child field from the item). Children are inserted
|
|
261
|
+
first; keys dedupe against the batch like any other row.
|
|
262
|
+
- **Multi-part credentials.** `[auth] headers = { "X-App-Token" = "VENDOR_APP_TOKEN" }`
|
|
263
|
+
adds credential headers whose values come from the named env vars, beside the primary
|
|
264
|
+
secret. A missing variable refuses the capture rather than sending a partial credential.
|
|
265
|
+
- **Query-driven lookups.** `[operations.api] filter` may name a declared query parameter
|
|
266
|
+
as well as a path argument; a parameter the caller leaves out does not narrow.
|
|
267
|
+
|
|
268
|
+
Be sparing with live calls; providers ask for it and `requests_per_minute` is the knob.
|
|
269
|
+
Commit `connector.toml`; commit captures only after checking the redaction policy covers
|
|
270
|
+
every PII field the vendor returns. The platform half exists: the key is held encrypted on
|
|
271
|
+
the world (Secrets tab / `gateway bench secrets set`), `gateway worlds connector capture --remote`
|
|
272
|
+
runs the same operations server-side into the project's file drive, and the CLI pulls the
|
|
273
|
+
redacted pages back into `captures/`.
|
|
274
|
+
|
|
275
|
+
### From the platform agent (no checkout)
|
|
276
|
+
|
|
277
|
+
The console agent has this loop as tools, all discoverable with `search_tools`:
|
|
278
|
+
`get_connector_authoring_skill` (this file) → write `connector.toml` + `schema/` in the
|
|
279
|
+
sandbox → `run_gateway_cli({ command: "connector validate" | "connector conform" | "schema check", args: [...] })`
|
|
280
|
+
→ `validate_connector_template({ files })` → `publish_connector({ slug, files, parentCommit? })`
|
|
281
|
+
(needs `hub:write` and the session's `allowConnectorWrites`, else `confirm: true`; a moved
|
|
282
|
+
head is refused by `parentCommit`, re-read with `get_connector`) → `init_world_from_connector`
|
|
283
|
+
→ `start_connector_capture({ containerId, op, args, params })` → `get_connector_capture({ …, downloadTo })`
|
|
284
|
+
→ `run_gateway_cli connector ingest` → `ingest_to_world`. `list_world_secrets` shows the env
|
|
285
|
+
var names the world holds, never values; a `connector.toml` with an inline credential is
|
|
286
|
+
refused before anything is queued. `run_gateway_cli` runs the TypeScript `gateway worlds …` CLI
|
|
287
|
+
(the same flags as this page) staged into the sandbox, local-only (paths under `/workspace`,
|
|
288
|
+
no `--host`/`--remote`/`workspace:<slug>`, platform env stripped, pinned to its local runtime),
|
|
289
|
+
so publishing always goes through the tools above. To parallelise several connectors, `spawn_subagent` with a brief
|
|
290
|
+
naming only the tools that child needs (`allowSubagents` on the session).
|
|
291
|
+
|
|
292
|
+
### Serving the vendor's API from the world
|
|
293
|
+
|
|
294
|
+
A provider's client speaks the vendor's REST paths, not tool calls, so the world answers
|
|
295
|
+
those paths itself. `connector.toml` already names them; add what the world needs to serve
|
|
296
|
+
them:
|
|
297
|
+
|
|
298
|
+
- `[api] envelope = "results"` wraps rows as `{"results": [...], "hits": N, "cursor": ""}`
|
|
299
|
+
- `[operations.api] action` makes a route a `create`, `update`, `delete` or `handler`; handlers live in the world's `api/handlers.py` and carry computed results and workflow state (`ctx.ladder` on the clock). A world is read *and* write: an agent that creates a search and gets 501 is not testing anything. Full reference: `documentation/features/connector-worlds.md`.
|
|
300
|
+
(empty means a bare array); `unauthorized` / `not_found` are JSON strings replayed on
|
|
301
|
+
401 / 404, so the vendor's own error bodies come back.
|
|
302
|
+
- `[operations.api] filter = { email = "attributes.email" }` maps a path argument to the
|
|
303
|
+
row field it selects on, matched case-insensitively at any depth. An operation without
|
|
304
|
+
an `entity` answers 501 `not_modelled` rather than inventing a response.
|
|
305
|
+
|
|
306
|
+
`gateway worlds serve PATH --port 8080 [--api-key K]` runs it locally; the runner's admin
|
|
307
|
+
endpoints (`/healthz`, `/__world/seed`, `/__world/reset`, `/__world/state`) sit beside the
|
|
308
|
+
vendor routes. `gateway bench push PATH` publishes the world: for a world carrying
|
|
309
|
+
`connector.toml` it packages the api-kind bundle the platform hosts on the way (root
|
|
310
|
+
legacy-shaped on purpose, since the api runner refuses a schema bundle there; `server/`
|
|
311
|
+
needs nothing installed). Open a session with `--surface api` and hand the client that
|
|
312
|
+
URL; the vendor's auth scheme applies (`WORLD_API_KEY` on the host pins the credential,
|
|
313
|
+
otherwise any non-empty one).
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Rows file reference
|
|
2
|
+
|
|
3
|
+
Companion to [SKILL.md](SKILL.md). The contract is fixed in
|
|
4
|
+
`.llm_artifacts/plans/world-data-ingestion-plan.md`; this page is the worked form.
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
1. [Shapes](#shapes)
|
|
9
|
+
2. [Modes](#modes)
|
|
10
|
+
3. [Keys and upserts](#keys-and-upserts)
|
|
11
|
+
4. [Schema worlds](#schema-worlds)
|
|
12
|
+
5. [Mock-tools worlds](#mock-tools-worlds)
|
|
13
|
+
6. [Live seeding](#live-seeding)
|
|
14
|
+
7. [From a call log to rows](#from-a-call-log-to-rows)
|
|
15
|
+
8. [MCP payloads](#mcp-payloads)
|
|
16
|
+
9. [Chunks, batches and refusal records](#chunks-batches-and-refusal-records)
|
|
17
|
+
10. [Extract adapters](#extract-adapters)
|
|
18
|
+
|
|
19
|
+
## Shapes
|
|
20
|
+
|
|
21
|
+
**JSON object, entity to rows.** One file, many entities.
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"users": [
|
|
26
|
+
{"id": "U1", "name": "Ada", "email": "ada@example.com"},
|
|
27
|
+
{"id": "U2", "name": "Lin", "email": "lin@example.com"}
|
|
28
|
+
],
|
|
29
|
+
"channels": [
|
|
30
|
+
{"id": "C1", "name": "general", "created_by": "U1"}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**JSONL, tagged.** One row per line, each line names its entity.
|
|
36
|
+
|
|
37
|
+
```jsonl
|
|
38
|
+
{"entity": "users", "row": {"id": "U1", "name": "Ada", "email": "ada@example.com"}}
|
|
39
|
+
{"entity": "channels", "row": {"id": "C1", "name": "general", "created_by": "U1"}}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Bare rows with `--entity NAME`.** A JSON array, or JSONL of bare objects.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
gateway worlds data import ./world users.json --entity users
|
|
46
|
+
gateway worlds data import ./world users.jsonl --entity users
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
A file that mixes shapes is refused. Several files on one command are applied as one batch:
|
|
50
|
+
all or nothing (`--per-chunk` on a platform import relaxes that to one chunk at a time). Files
|
|
51
|
+
are streamed, so size is not a concern: pass `-` for stdin, `.gz` files are gunzipped.
|
|
52
|
+
|
|
53
|
+
## Modes
|
|
54
|
+
|
|
55
|
+
| Mode | Named entities | Other entities |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `append` (default) | rows added; existing keys updated | untouched |
|
|
58
|
+
| `replace` | every existing row removed, then the file's rows inserted | untouched |
|
|
59
|
+
|
|
60
|
+
`replace` on a live session swaps the named entities in the running state; the rest stays.
|
|
61
|
+
`replace` on a world rewrites only the named entities in `data/initial.json` (schema) or
|
|
62
|
+
`db/seed.sql` (mock-tools).
|
|
63
|
+
|
|
64
|
+
## Keys and upserts
|
|
65
|
+
|
|
66
|
+
The primary key is the entity's `primaryKey` in `schema/world.json`, or the table's
|
|
67
|
+
`PRIMARY KEY` in `db/schema.sql`. On `append`, a row whose key already exists updates the
|
|
68
|
+
existing row; an identical row is skipped; a new key inserts. Order inside a file does not
|
|
69
|
+
matter for keys, but referenced rows must exist by the end of the batch (a `channels` row
|
|
70
|
+
whose `created_by` names an unknown user is refused).
|
|
71
|
+
|
|
72
|
+
A row that lacks its entity's key field is refused (`Row is missing primary key field 'id'`).
|
|
73
|
+
Where the contract declares no key at all (a hand-built api world), a live `append` adds
|
|
74
|
+
without upserting; use `replace` there.
|
|
75
|
+
|
|
76
|
+
## Schema worlds
|
|
77
|
+
|
|
78
|
+
The import builds an `apply_batch` payload and proves it in a scratch copy first:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"id": "<package id>.initial.v<N>",
|
|
83
|
+
"target": "<contract target>",
|
|
84
|
+
"mapping": {"id": "data-import", "version": "1"},
|
|
85
|
+
"coverage": "partial",
|
|
86
|
+
"mutations": [
|
|
87
|
+
{"op": "insert", "entity": "users", "value": {"id": "U1", "...": "..."}, "source": {"record": "data-import:users:<identity>"}}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
On success the batch is appended to `data/initial.json`, then `compile` (which rebuilds the
|
|
93
|
+
world's snapshot, `db/state.sqlite`, and every scenario's) and `check` run. A refusal points at
|
|
94
|
+
the row and field (`/users/3/email`) with the store's reason. Nothing is written on refusal.
|
|
95
|
+
A directory takes at most 5,000 rows / 4 MiB; a platform slug takes any size as chunks. Rows already held with the same key and content are skipped, so the
|
|
96
|
+
result says `changed: false` when nothing was new.
|
|
97
|
+
|
|
98
|
+
The same batch is what `gateway worlds connector ingest` builds from captures; the two
|
|
99
|
+
commands share the check. Source: `gatewaysdk/environment/schema/data.py` (`import_rows`,
|
|
100
|
+
`seed_batch`) beside `connector.py` (`ingest`).
|
|
101
|
+
|
|
102
|
+
## Mock-tools worlds
|
|
103
|
+
|
|
104
|
+
Tables come from `db/schema.sql`; columns from each table's `CREATE TABLE`. Rows become
|
|
105
|
+
statements appended to `db/seed.sql`: `INSERT OR REPLACE` on `append` (an upsert by the
|
|
106
|
+
table's own key), plain `INSERT` on `replace`. A column the table does not have is refused
|
|
107
|
+
by name (`Column c is not in table t; columns: ...`). Values are scalars quoted as SQLite
|
|
108
|
+
literals; a nested object or array is refused (`takes a scalar; encode nested values as
|
|
109
|
+
text yourself`).
|
|
110
|
+
|
|
111
|
+
Materialization (`gatewaysdk/environment/_materialize.py`) runs `schema.sql` then
|
|
112
|
+
`seed.sql`, so the appended block is part of every future session's starting state.
|
|
113
|
+
|
|
114
|
+
## Live seeding
|
|
115
|
+
|
|
116
|
+
`gateway worlds session seed <SESSION_ID> rows.json [--mode]` posts a session call:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{"kind": "seed", "args": {"mode": "append", "rows": {"users": [{"id": "U9", "name": "New"}]}}}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
and waits for the result. Schema worlds: the engine applies one batch through the contract
|
|
123
|
+
(`seed_batch`), so a refused row leaves the session as it was. Api worlds: the runner reads
|
|
124
|
+
the world's state, merges the rows in (`merge_seed`: `replace` swaps the named entities,
|
|
125
|
+
`append` upserts where keys are known) and posts the whole state to the world's seed route,
|
|
126
|
+
restoring the previous state if the world refuses. Mock-tools task worlds: the session
|
|
127
|
+
server executes the INSERTs against the live SQLite. Any other kind answers
|
|
128
|
+
`this world kind cannot be seeded live`. A call carries at most 5,000 rows and 4 MiB. A live
|
|
129
|
+
seed never changes the world's version.
|
|
130
|
+
|
|
131
|
+
## From a call log to rows
|
|
132
|
+
|
|
133
|
+
`gateway worlds session export <SESSION_ID> --out calls.jsonl` writes one line per call:
|
|
134
|
+
|
|
135
|
+
```jsonl
|
|
136
|
+
{"seq": 1, "kind": "call", "tool": "list_users", "args": {}, "result": {"users": [{"id": "U1"}]}, "error": null, "state": "done", "createdAt": "2026-09-11T10:00:00Z", "completedAt": "2026-09-11T10:00:00Z"}
|
|
137
|
+
{"seq": 2, "kind": "call", "tool": "post_message", "args": {"channel": "C1", "text": "hi"}, "result": {"ok": true, "ts": "1.0"}, "error": null, "state": "done", "createdAt": "2026-09-11T10:00:01Z", "completedAt": "2026-09-11T10:00:01Z"}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`kind` is `call`, `grade`, `seed`, `reset` or `close`; seeds and resets are in the log too, so
|
|
141
|
+
filter on `kind == "call"`.
|
|
142
|
+
|
|
143
|
+
Two ways to make rows from it:
|
|
144
|
+
|
|
145
|
+
- **Reads become seed.** Results of list/get tools already are rows of an entity. Select the
|
|
146
|
+
tool, unwrap the result, tag the entity.
|
|
147
|
+
- **Writes become expected state.** A `post_message` call's `args` plus the ids in its
|
|
148
|
+
`result` are the row the world should contain after the run. Build the row from both.
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
jq -c 'select(.kind == "call" and .error == null and .tool == "post_message")
|
|
152
|
+
| {entity: "messages", row: {channel_id: .args.channel, text: .args.text, ts: .result.ts}}' \
|
|
153
|
+
calls.jsonl > messages.jsonl
|
|
154
|
+
gateway worlds data import ./world messages.jsonl
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Hash or drop personal fields before importing. Keep `calls.jsonl` beside the rows with the
|
|
158
|
+
session id so the provenance survives.
|
|
159
|
+
|
|
160
|
+
## MCP payloads
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{"tool": "import_world_data", "input": {"slug": "vendor-world", "rows": {"users": [{"id": "U1", "name": "Ada"}]}, "mode": "append", "message": "seed users"}}
|
|
164
|
+
{"tool": "seed_world_session", "input": {"sessionId": "<id>", "rows": {"users": [{"id": "U9"}]}, "mode": "replace"}}
|
|
165
|
+
{"tool": "export_world_session", "input": {"sessionId": "<id>", "limit": 500}}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`import_world_data` accepts `containerId` or `slug`; `rows` is always the JSON object shape
|
|
169
|
+
(5,000 rows / 4 MiB per call). It returns `{ versionId, entityCounts, deduped }`;
|
|
170
|
+
`seed_world_session` returns the engine's `{ seeded, mode, entity_counts? }` or a `callId` to
|
|
171
|
+
poll when the engine takes longer than 60 seconds. A refused row is a tool error naming the
|
|
172
|
+
row and field; nothing is written.
|
|
173
|
+
|
|
174
|
+
## Chunks, batches and refusal records
|
|
175
|
+
|
|
176
|
+
A platform import (`data import <slug>`) cuts the row stream into chunks: gzip over JSONL,
|
|
177
|
+
one row per line, either tagged `{"entity": "users", "row": {...}}` or, when the chunk was
|
|
178
|
+
declared with `--entity`, the bare row. A line is
|
|
179
|
+
`json.dumps(row, ensure_ascii=False, separators=(",", ":"))`. A chunk closes on a row
|
|
180
|
+
boundary when the next line would exceed `--chunk-bytes` (64 MiB) or at `--chunk-rows`.
|
|
181
|
+
Chunks are addressed by the sha256 of their gzipped bytes; a batch by
|
|
182
|
+
`sha256(parent + "\n" + batchId + "\n" + sorted chunk digests joined by "\n")`.
|
|
183
|
+
|
|
184
|
+
The manifest `.gateway/imports/<batchId>.json`:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{"version": 1, "batchId": "...", "slug": "...", "host": "...",
|
|
188
|
+
"flags": {"mode": "append", "merge": "upsert", "atomic": true, "publish": "now", "dryRun": false, "chunkBytes": 67108864, "chunkRows": null, "entity": null},
|
|
189
|
+
"inputs": ["export.jsonl"],
|
|
190
|
+
"chunks": [{"ordinal": 0, "digest": "...", "bytes": 123, "rows": 50000, "entity": null, "chunkId": "...", "uploaded": true}],
|
|
191
|
+
"completed": false, "createdAt": "...", "updatedAt": "..."}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
A refusal record (dry run, `--report`, `status`, MCP):
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{"chunk": 0, "index": 17, "entity": "users", "primaryKey": {"id": "u17"}, "field": "email", "pointer": "/users/17/email", "detail": "String length is outside the declared bound"}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`chunk` is the chunk ordinal, `index` the row's line inside it, `primaryKey` null when the
|
|
201
|
+
row lacks its key, `field` null for a row-level refusal (a missing required property, an
|
|
202
|
+
unknown property; `detail` names it). Reports are JSONL of these, at most 10,000 records
|
|
203
|
+
then `{"truncated": true, "total": N}`. `data check` (or `import --dry-run`) produces the
|
|
204
|
+
same records locally against the world's contract: shape first (type, bounds, required,
|
|
205
|
+
unknown property, key present), then references and key conflicts in a scratch apply.
|
|
206
|
+
|
|
207
|
+
## Extract adapters
|
|
208
|
+
|
|
209
|
+
`gateway worlds data extract <WORLD> <file|-> --shape S --entity E [--out F] [--merge fill|upsert] [--no-redact]`
|
|
210
|
+
|
|
211
|
+
| Shape | Input | Rows |
|
|
212
|
+
| --- | --- | --- |
|
|
213
|
+
| `tool-results` | one `{..., "raw_output": {...}}` per line | every object of `raw_output.results[]` (else `.items[]`) carrying the entity's key |
|
|
214
|
+
| `vendor-envelope` | the vendor's response, one per line or one document | under the world's `[api].envelope` key; the bare array when it is `""` |
|
|
215
|
+
| `session-export` | `calls.jsonl` from `session export` | `result.<envelope>[]` of `kind == "call"` records with no error |
|
|
216
|
+
|
|
217
|
+
Then, in order: null and `""` values dropped; fields the entity does not declare stripped
|
|
218
|
+
and counted; rows deduped by primary key in first-seen order (`fill`: first wins, later
|
|
219
|
+
rows add missing fields; `upsert`: last wins); the world's `[redact]` policy applied
|
|
220
|
+
(`drop` removed, `hash` replaced by `"sha256:" + sha256("<slug>:<value>")`, lists element
|
|
221
|
+
by element, `round` rounded). Output is tagged JSONL; stderr gets
|
|
222
|
+
`{"read": N, "rows": M, "unknownFields": {name: n}, "redacted": {"dropped": n, "hashed": n}}`.
|
|
223
|
+
The fixtures under `gatewaysdk/fixtures/world-data/extract/` are the worked examples.
|