diff --git a/core/fixtures/generate_contract.json b/core/fixtures/generate_contract.json new file mode 100644 index 000000000..453b3c1b1 --- /dev/null +++ b/core/fixtures/generate_contract.json @@ -0,0 +1,936 @@ +{ + "conformance_vectors": [ + { + "exit_code": 0, + "framing": "one_shot", + "id": "generated", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "finish_reason": "stop", + "id": "fixture-request", + "inference": null, + "input_budget": null, + "model": "fixture-model", + "outcome": "generated", + "request_budget": null, + "schema": "solstone-generate-response-v2", + "schema_validation": null, + "text": "OK", + "thinking": null, + "usage": { + "input_tokens": 2, + "output_tokens": 1, + "total_tokens": 3 + } + }, + "source": { + "path": "generated" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-attestation-not-verified", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": true, + "detail": "fixture attestation-not-verified", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "attestation-not-verified", + "reason_code": "attestation_not_yet_verified", + "reset_at_ms": null, + "retryable": true, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "AttestationNotVerifiedError", + "path": "typed_exception", + "reason_code": "attestation_not_yet_verified" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-attestation-failed", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": true, + "detail": "fixture attestation-failed", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "attestation-failed", + "reason_code": "attestation_failed", + "reset_at_ms": null, + "retryable": true, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "AttestationFailedError", + "path": "typed_exception", + "reason_code": "attestation_failed" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-attestation-stale", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": true, + "detail": "fixture attestation-stale", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "attestation-stale", + "reason_code": "attestation_stale", + "reset_at_ms": null, + "retryable": true, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "AttestationStaleError", + "path": "typed_exception", + "reason_code": "attestation_stale" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-no-engine-configured", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": true, + "detail": "fixture no-engine-configured", + "id": "fixture-request", + "outcome": "refused", + "provider": "none", + "reason": "no-engine-configured", + "reason_code": "thinking_engine_not_chosen", + "reset_at_ms": null, + "retryable": true, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "NoBrainConfiguredError", + "path": "typed_exception", + "reason_code": "thinking_engine_not_chosen" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-incomplete-json", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": false, + "detail": "fixture incomplete-json", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "incomplete-json", + "reason_code": "incomplete_json_length", + "reset_at_ms": null, + "retryable": true, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "IncompleteJSONError", + "path": "typed_exception", + "reason_code": "incomplete_json_length" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-incomplete-text", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": false, + "detail": "fixture incomplete-text", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "incomplete-text", + "reason_code": "incomplete_text_length", + "reset_at_ms": null, + "retryable": true, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "IncompleteTextError", + "path": "typed_exception", + "reason_code": "incomplete_text_length" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-provider-response-invalid", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": false, + "detail": "fixture provider-response-invalid", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "provider-response-invalid", + "reason_code": "provider_response_invalid", + "reset_at_ms": null, + "retryable": true, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "ProviderResponseInvalidError", + "path": "typed_exception", + "reason_code": "provider_response_invalid" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-schema-validation-failed", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": true, + "detail": "fixture schema-validation-failed", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "schema-validation-failed", + "reason_code": null, + "reset_at_ms": null, + "retryable": false, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "SchemaValidationError", + "path": "typed_exception", + "reason_code": null + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "refused-non-responsive-output", + "request": { + "attempt_index": 0, + "contents": [ + { + "text": "Reply with OK.", + "type": "text" + } + ], + "context": "fixture.generate", + "enforce_responsiveness": true, + "exclusive_admission": false, + "id": "fixture-request", + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "schema": "solstone-generate-request-v2", + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "response": { + "blocking": false, + "detail": "fixture non-responsive-output", + "id": "fixture-request", + "outcome": "refused", + "provider": "local", + "reason": "non-responsive-output", + "reason_code": "non_responsive", + "reset_at_ms": null, + "retryable": false, + "schema": "solstone-generate-response-v2" + }, + "source": { + "exception": "NonResponsiveOutputError", + "path": "typed_exception", + "reason_code": "non_responsive" + } + }, + { + "exit_code": 64, + "framing": "protocol_error", + "id": "malformed-request", + "protocol_error": { + "detail": "stdin is not valid JSON", + "id": null, + "reason": "malformed-request", + "schema": "solstone-generate-error-v2" + }, + "source": { + "path": "malformed_request" + }, + "stdin": "{" + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "unknown-refusal-reason", + "response": { + "blocking": true, + "detail": "future", + "id": "fixture-request", + "outcome": "refused", + "provider": null, + "reason": "future-reason", + "reason_code": null, + "reset_at_ms": null, + "retryable": false, + "schema": "solstone-generate-response-v2" + }, + "source": { + "path": "reader_tolerance" + } + }, + { + "exit_code": 0, + "framing": "one_shot", + "id": "unknown-reason-code", + "response": { + "blocking": true, + "detail": "future", + "id": "fixture-request", + "outcome": "refused", + "provider": null, + "reason": "provider-response-invalid", + "reason_code": "future_code", + "reset_at_ms": null, + "retryable": false, + "schema": "solstone-generate-response-v2" + }, + "source": { + "path": "reader_tolerance" + } + } + ], + "exit_codes": { + "internal_failure": 70, + "malformed_request": 64, + "response": 0 + }, + "fixture": "solstone-generate-contract", + "fixture_version": 1, + "framing": { + "one_shot": { + "id": "optional", + "selector": "--one-shot", + "stdin": "json-eof" + }, + "session": { + "concurrency": { + "flag": "--max-in-flight", + "minimum": 1 + }, + "id": "required", + "selector": "--session", + "stdin": "ndjson" + } + }, + "generated_by": "make core-fixtures", + "outcomes": [ + "generated", + "refused" + ], + "protocol_error": { + "fields": [ + "schema", + "id", + "reason", + "detail" + ] + }, + "reason_codes": [ + { + "blocking": true, + "code": "archive_path_traversal", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "attestation_failed", + "overrides_live_taxonomy": true, + "retryable": true + }, + { + "blocking": true, + "code": "attestation_not_yet_verified", + "overrides_live_taxonomy": true, + "retryable": true + }, + { + "blocking": true, + "code": "attestation_stale", + "overrides_live_taxonomy": true, + "retryable": true + }, + { + "blocking": true, + "code": "binary_missing", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "chat_pipeline_unavailable", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "chat_timeout", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "context_budget_exceeded", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "context_window_exceeded", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "cuda_runtime_incomplete", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "gpu_probe_failed", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "gpu_unavailable", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "host_unfit", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "incomplete_json_length", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "incomplete_text_length", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "install_busy", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "local_artifact_proof_unavailable", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "local_capacity_exhausted", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "local_endpoint_contract_failed", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "local_endpoint_unreachable", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "local_model_installing", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "local_model_loading", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "local_model_missing", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "local_model_not_ready", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "local_queue_timeout", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "local_server_unhealthy", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "max_turns_exhausted", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "model_missing", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "model_not_found", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "network_unreachable", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "no_output", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "non_responsive", + "overrides_live_taxonomy": false, + "retryable": false + }, + { + "blocking": true, + "code": "provider_key_invalid", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "provider_key_missing", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "provider_quota_exceeded", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "provider_request_rejected", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "provider_response_invalid", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "provider_unavailable", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "ram_insufficient", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "sha256_mismatch", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "thinking_engine_not_chosen", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "token_budget_exceeded", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "unknown", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "unsupported_model", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": true, + "code": "unsupported_platform", + "overrides_live_taxonomy": false, + "retryable": true + }, + { + "blocking": false, + "code": "wall_clock_exceeded", + "overrides_live_taxonomy": false, + "retryable": true + } + ], + "refusal_reasons": [ + "attestation-not-verified", + "attestation-failed", + "attestation-stale", + "no-engine-configured", + "incomplete-json", + "incomplete-text", + "provider-response-invalid", + "schema-validation-failed", + "non-responsive-output", + "unknown" + ], + "request": { + "content_parts": { + "image": { + "fields": [ + "type", + "mime_type", + "data" + ] + }, + "text": { + "fields": [ + "type", + "text" + ] + } + }, + "defaults": { + "attempt_index": 0, + "enforce_responsiveness": true, + "exclusive_admission": false, + "json_output": false, + "json_schema": null, + "max_output_tokens": 16384, + "system_instruction": null, + "temperature": 0.3, + "thinking_budget": null, + "timeout_s": null, + "transport_retries": null + }, + "fields": [ + "schema", + "id", + "context", + "contents", + "system_instruction", + "temperature", + "max_output_tokens", + "thinking_budget", + "timeout_s", + "json_output", + "json_schema", + "enforce_responsiveness", + "attempt_index", + "exclusive_admission", + "transport_retries" + ], + "forbidden_fields": [ + "provider", + "model" + ], + "one_shot_optional_fields": [ + "id" + ], + "required_fields": [ + "schema", + "context", + "contents" + ], + "session_required_fields": [ + "id" + ] + }, + "response": { + "outcome_field": "outcome", + "outcomes": { + "generated": { + "fields": [ + "schema", + "id", + "outcome", + "text", + "model", + "usage", + "finish_reason", + "thinking", + "schema_validation", + "input_budget", + "request_budget", + "inference" + ] + }, + "refused": { + "fields": [ + "schema", + "id", + "outcome", + "reason", + "reason_code", + "retryable", + "blocking", + "reset_at_ms", + "provider", + "detail" + ] + } + } + }, + "schema_identifiers": { + "error": "solstone-generate-error-v2", + "request": "solstone-generate-request-v2", + "response": "solstone-generate-response-v2" + }, + "unknown_member": { + "blocking": true, + "refusal_reason": "unknown", + "retryable": false + } +} diff --git a/scripts/build_core_fixtures.py b/scripts/build_core_fixtures.py index b6885641b..19b5c4092 100644 --- a/scripts/build_core_fixtures.py +++ b/scripts/build_core_fixtures.py @@ -72,6 +72,10 @@ from solstone.apps.speakers.encoder_config import ( VP_OUTLIER_MIN_SIMILARITY, ) from solstone.convey.contract.assemble import CALLOSUM_REGISTRY +from solstone.convey.provider_readiness import ( + is_blocking_reason, + mapped_reason_codes, +) from solstone.think import markdown as markdown_formatter from solstone.think.cogitate_contract import ( COGITATE_ACCESS_TIERS, @@ -82,6 +86,7 @@ from solstone.think.cogitate_contract import ( capabilities_for_access_tier, ) from solstone.think.indexer.edges import EDGES_SCHEMA_VERSION, _ensure_edges_schema +from solstone.think.providers.shared import is_non_retryable_generate_reason from tests.speaker_oracle.diarize import ( AHC_LINKAGE, AHC_METRIC, @@ -133,6 +138,7 @@ import entity_corpus # noqa: E402 — sibling module, not a package FIXTURE_DIR = ROOT / "core" / "fixtures" CALLOSUM_ARTIFACT_PATH = FIXTURE_DIR / "callosum_registry.json" COGITATE_ARTIFACT_PATH = FIXTURE_DIR / "cogitate_contract.json" +GENERATE_ARTIFACT_PATH = FIXTURE_DIR / "generate_contract.json" EDGE_SCHEMA_ARTIFACT_PATH = FIXTURE_DIR / "edge_schema.json" MARKDOWN_CHUNKS_ARTIFACT_PATH = FIXTURE_DIR / "markdown_chunks.json" SPEAKER_FILTERBANK_ARTIFACT_PATH = FIXTURE_DIR / "speaker_filterbank.json" @@ -231,6 +237,200 @@ def build_cogitate_contract_fixture() -> dict[str, Any]: } +def build_generate_contract_fixture() -> dict[str, Any]: + """Build the cross-language generate boundary contract.""" + + schemas = { + "request": "solstone-generate-request-v2", + "response": "solstone-generate-response-v2", + "error": "solstone-generate-error-v2", + } + attestation_codes = { + "attestation_not_yet_verified", + "attestation_failed", + "attestation_stale", + } + live_codes = mapped_reason_codes() + reason_codes = [ + { + "code": code, + "blocking": True if code in attestation_codes else is_blocking_reason(code), + "retryable": not is_non_retryable_generate_reason(code), + "overrides_live_taxonomy": code in attestation_codes, + } + for code in sorted(live_codes | attestation_codes) + ] + request = { + "schema": schemas["request"], + "id": "fixture-request", + "context": "fixture.generate", + "contents": [{"type": "text", "text": "Reply with OK."}], + "system_instruction": None, + "temperature": 0.3, + "max_output_tokens": 16384, + "thinking_budget": None, + "timeout_s": None, + "json_output": False, + "json_schema": None, + "enforce_responsiveness": True, + "attempt_index": 0, + "exclusive_admission": False, + "transport_retries": None, + } + generated = { + "schema": schemas["response"], + "id": request["id"], + "outcome": "generated", + "text": "OK", + "model": "fixture-model", + "usage": {"input_tokens": 2, "output_tokens": 1, "total_tokens": 3}, + "finish_reason": "stop", + "thinking": None, + "schema_validation": None, + "input_budget": None, + "request_budget": None, + "inference": None, + } + typed_refusals = [ + ("attestation-not-verified", "AttestationNotVerifiedError", "attestation_not_yet_verified"), + ("attestation-failed", "AttestationFailedError", "attestation_failed"), + ("attestation-stale", "AttestationStaleError", "attestation_stale"), + ("no-engine-configured", "NoBrainConfiguredError", "thinking_engine_not_chosen"), + ("incomplete-json", "IncompleteJSONError", "incomplete_json_length"), + ("incomplete-text", "IncompleteTextError", "incomplete_text_length"), + ("provider-response-invalid", "ProviderResponseInvalidError", "provider_response_invalid"), + ("schema-validation-failed", "SchemaValidationError", None), + ("non-responsive-output", "NonResponsiveOutputError", "non_responsive"), + ] + by_code = {entry["code"]: entry for entry in reason_codes} + vectors: list[dict[str, Any]] = [ + { + "id": "generated", + "framing": "one_shot", + "request": request, + "response": generated, + "exit_code": 0, + "source": {"path": "generated"}, + } + ] + for reason, exception, reason_code in typed_refusals: + classification = ( + by_code[reason_code] + if reason_code is not None + else {"blocking": True, "retryable": False} + ) + vectors.append( + { + "id": f"refused-{reason}", + "framing": "one_shot", + "request": request, + "response": { + "schema": schemas["response"], + "id": request["id"], + "outcome": "refused", + "reason": reason, + "reason_code": reason_code, + "retryable": classification["retryable"], + "blocking": classification["blocking"], + "reset_at_ms": None, + "provider": "none" if reason == "no-engine-configured" else "local", + "detail": f"fixture {reason}", + }, + "exit_code": 0, + "source": {"path": "typed_exception", "exception": exception, "reason_code": reason_code}, + } + ) + vectors.extend( + [ + { + "id": "malformed-request", + "framing": "protocol_error", + "stdin": "{", + "protocol_error": { + "schema": schemas["error"], + "id": None, + "reason": "malformed-request", + "detail": "stdin is not valid JSON", + }, + "exit_code": 64, + "source": {"path": "malformed_request"}, + }, + { + "id": "unknown-refusal-reason", + "framing": "one_shot", + "response": { + "schema": schemas["response"], + "id": request["id"], + "outcome": "refused", + "reason": "future-reason", + "reason_code": None, + "retryable": False, + "blocking": True, + "reset_at_ms": None, + "provider": None, + "detail": "future", + }, + "exit_code": 0, + "source": {"path": "reader_tolerance"}, + }, + { + "id": "unknown-reason-code", + "framing": "one_shot", + "response": { + "schema": schemas["response"], + "id": request["id"], + "outcome": "refused", + "reason": "provider-response-invalid", + "reason_code": "future_code", + "retryable": False, + "blocking": True, + "reset_at_ms": None, + "provider": None, + "detail": "future", + }, + "exit_code": 0, + "source": {"path": "reader_tolerance"}, + }, + ] + ) + return { + "fixture": "solstone-generate-contract", + "fixture_version": 1, + "generated_by": "make core-fixtures", + "schema_identifiers": schemas, + "request": { + "fields": list(request), + "required_fields": ["schema", "context", "contents"], + "one_shot_optional_fields": ["id"], + "session_required_fields": ["id"], + "forbidden_fields": ["provider", "model"], + "defaults": {key: value for key, value in request.items() if key not in {"schema", "id", "context", "contents"}}, + "content_parts": { + "text": {"fields": ["type", "text"]}, + "image": {"fields": ["type", "mime_type", "data"]}, + }, + }, + "response": { + "outcome_field": "outcome", + "outcomes": { + "generated": {"fields": list(generated)}, + "refused": {"fields": ["schema", "id", "outcome", "reason", "reason_code", "retryable", "blocking", "reset_at_ms", "provider", "detail"]}, + }, + }, + "protocol_error": {"fields": ["schema", "id", "reason", "detail"]}, + "outcomes": ["generated", "refused"], + "refusal_reasons": [reason for reason, _, _ in typed_refusals] + ["unknown"], + "unknown_member": {"refusal_reason": "unknown", "retryable": False, "blocking": True}, + "reason_codes": reason_codes, + "exit_codes": {"response": 0, "malformed_request": 64, "internal_failure": 70}, + "framing": { + "one_shot": {"selector": "--one-shot", "stdin": "json-eof", "id": "optional"}, + "session": {"selector": "--session", "stdin": "ndjson", "id": "required", "concurrency": {"flag": "--max-in-flight", "minimum": 1}}, + }, + "conformance_vectors": vectors, + } + + def build_edge_schema_fixture() -> dict[str, Any]: conn = sqlite3.connect(":memory:") @@ -1327,6 +1527,9 @@ def expected_outputs() -> dict[Path, ArtifactDescriptor]: COGITATE_ARTIFACT_PATH: ArtifactDescriptor( build_cogitate_contract_fixture, ), + GENERATE_ARTIFACT_PATH: ArtifactDescriptor( + build_generate_contract_fixture, + ), EDGE_SCHEMA_ARTIFACT_PATH: ArtifactDescriptor( build_edge_schema_fixture, ),