castform 0.2.2.dev0__tar.gz → 0.2.4__tar.gz
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.
- {castform-0.2.2.dev0 → castform-0.2.4}/PKG-INFO +11 -11
- {castform-0.2.2.dev0 → castform-0.2.4}/README.md +4 -2
- {castform-0.2.2.dev0 → castform-0.2.4}/pyproject.toml +6 -7
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/CLAUDE.md +19 -4
- castform-0.2.4/src/castform/cli/scaffold/HARBOR_STARTER.md +50 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/STARTER.md +18 -5
- castform-0.2.4/src/castform/cli/scaffold/generic_env_tests.py +92 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/generic_main.py +60 -32
- castform-0.2.4/src/castform/cli/scaffold/harbor_env_tests.py +64 -0
- castform-0.2.4/src/castform/cli/scaffold/harbor_main.py +283 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/skills/design-environment/SKILL.md +19 -3
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/skills/generate-data/SKILL.md +19 -9
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/skills/launch-run/SKILL.md +9 -1
- castform-0.2.4/src/castform/cli/scaffold/skills/train-sft/SKILL.md +141 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/skills/verify-environment/SKILL.md +10 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/setup.py +69 -50
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/model_auth.py +2 -49
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/__init__.py +4 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/client.py +90 -2
- castform-0.2.4/src/castform/platform/sft.py +363 -0
- castform-0.2.4/src/castform/rag/chunkers/__init__.py +1 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/chunkers/email.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/chunkers/inspector.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/chunkers/markdown.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/chunkers/models.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/chunkers/storage.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/chroma/client.py +2 -3
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/pinecone/index_client.py +2 -2
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/postgres/client.py +1 -2
- castform-0.2.4/src/castform/rag/corpus/search_schema/__init__.py +1 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/search_schema/builders.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/search_schema/dsl_parser.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/search_schema/search_exceptions.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/search_schema/search_types.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/source.py +1 -1
- castform-0.2.4/src/castform/rag/example_data.py +308 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/preprocess/email/schema.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/validation.py +82 -5
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/platform/test_client.py +22 -0
- castform-0.2.4/tests/unit/platform/test_sft.py +581 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/chunkers/test_builders.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/chunkers/test_chunk_models.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/test_search_types.py +1 -1
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/tpuf/test_content_field.py +1 -12
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_chunkers.py +1 -1
- castform-0.2.4/tests/unit/rag/test_example_data.py +128 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_setup.py +53 -110
- castform-0.2.4/tests/unit/test_example_validation_contract.py +33 -0
- castform-0.2.4/tests/unit/test_harbor_scaffold_runner.py +141 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_scaffold_runner.py +144 -25
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_validation.py +312 -1
- castform-0.2.2.dev0/src/castform/cli/scaffold/generic_env_tests.py +0 -57
- castform-0.2.2.dev0/src/castform/cli/scaffold/rag_eval_dataset.jsonl +0 -1
- castform-0.2.2.dev0/src/castform/cli/scaffold/rag_main.py +0 -401
- castform-0.2.2.dev0/src/castform/cli/scaffold/rag_train_dataset.jsonl +0 -2
- castform-0.2.2.dev0/src/castform/rag/corpus/chroma/search.py +0 -213
- castform-0.2.2.dev0/src/castform/rag/corpus/embed.py +0 -80
- castform-0.2.2.dev0/src/castform/rag/corpus/pinecone/search.py +0 -131
- castform-0.2.2.dev0/src/castform/rag/corpus/postgres/search.py +0 -121
- castform-0.2.2.dev0/src/castform/rag/corpus/search_client.py +0 -64
- castform-0.2.2.dev0/src/castform/rag/corpus/turbopuffer/search.py +0 -222
- castform-0.2.2.dev0/src/castform/rag/preprocess/email/__init__.py +0 -0
- castform-0.2.2.dev0/src/castform/traces/braintrust/__init__.py +0 -0
- castform-0.2.2.dev0/tests/unit/rag/corpus/chroma/test_search.py +0 -200
- castform-0.2.2.dev0/tests/unit/rag/corpus/pinecone/test_search.py +0 -114
- castform-0.2.2.dev0/tests/unit/rag/corpus/postgres/test_search.py +0 -147
- castform-0.2.2.dev0/tests/unit/rag/corpus/test_embed.py +0 -126
- castform-0.2.2.dev0/tests/unit/rag/corpus/test_search_client_conformance.py +0 -111
- castform-0.2.2.dev0/tests/unit/rag/corpus/tpuf/test_search.py +0 -79
- {castform-0.2.2.dev0 → castform-0.2.4}/.gitignore +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/pytest.ini +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/_auth.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/_client.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/_output.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/_preflight.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/control.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/doctor.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/help.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/runs.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/generic_eval_dataset.jsonl +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/generic_train_dataset.jsonl +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/skills/view-progress/SKILL.md +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/cli/scaffold/tests_conftest.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/config.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/browser.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/config.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/credentials.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/device_auth.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/environment_assets.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/exceptions.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/login.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/platform/model_session.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/profile_config.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/__init__.py +0 -0
- {castform-0.2.2.dev0/src/castform/rag/chunkers → castform-0.2.4/src/castform/rag/corpus/chroma}/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/chroma/files.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/chroma/filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/chroma/source.py +0 -0
- {castform-0.2.2.dev0/src/castform/rag/corpus/chroma → castform-0.2.4/src/castform/rag/corpus/pinecone}/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/pinecone/files.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/pinecone/filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/pinecone/source.py +0 -0
- {castform-0.2.2.dev0/src/castform/rag/corpus/pinecone → castform-0.2.4/src/castform/rag/corpus/postgres}/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/postgres/exceptions.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/postgres/filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/postgres/models.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/postgres/source.py +0 -0
- {castform-0.2.2.dev0/src/castform/rag/corpus/postgres → castform-0.2.4/src/castform/rag/corpus/turbopuffer}/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/turbopuffer/files.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/turbopuffer/filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/turbopuffer/namespace.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/corpus/turbopuffer/source.py +0 -0
- {castform-0.2.2.dev0/src/castform/rag/corpus/search_schema → castform-0.2.4/src/castform/rag/preprocess}/__init__.py +0 -0
- {castform-0.2.2.dev0/src/castform/rag/corpus/turbopuffer → castform-0.2.4/src/castform/rag/preprocess/email}/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/preprocess/email/clean_bodies.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/preprocess/email/dedupe.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/preprocess/email/filter_automated_email_qas.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/preprocess/email/filter_automated_emails.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/preprocess/email/mbox.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/anchor_selector.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/auto_tune.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/batch_processor.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/checkpoint.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/corpus_capabilities.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/corpus_profile.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/filters/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/filters/deterministic_guards.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/filters/grounding_llm.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/filters/hop_count_validity.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/filters/quality_gate.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/filters/retrieval_llm.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/formatters/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/formatters/train_eval.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/generated_qa.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/generators/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/generators/direct_llm.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/helpers.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/metadata_linker.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/metrics.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/models.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/pipeline.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/pipeline_config.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/protocols.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/query_rewriter.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/response_parsers.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/retrieval_query.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/scoring.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/storage.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/style_controls.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/transformers/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/transformers/base.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/transformers/dedup.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/wiki_builder.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/rag/qa_generation/wiki_chunk_linker.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/adapter.py +0 -0
- {castform-0.2.2.dev0/src/castform/rag/preprocess → castform-0.2.4/src/castform/traces/braintrust}/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/braintrust/adapter.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/braintrust/message_extraction.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/http.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/pipeline.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/pivot.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/processing.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/traces/registry.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/utils/__init__.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/src/castform/utils/checkpoint.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/conftest.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/integration/harbor/README.md +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/integration/harbor/test_harbor_modal_live.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/integration/platform/test_rollout_reads.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/integration/test_async_corpus_client.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/integration/test_diversity_llm.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/integration/test_rubric_auth_retry.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/integration/traces/test_braintrust_e2e.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/_scaffold.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/cli_help.golden +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/platform/test_credentials.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/platform/test_device_auth.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/platform/test_environment_assets.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/platform/test_keyless_public_api.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/platform/test_model_session.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/conftest.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/chroma/test_configurations.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/chroma/test_filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/chroma/test_search_related.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/pinecone/test_configurations.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/pinecone/test_filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/pinecone/test_search_related.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/pinecone/test_sparse_and_sampling.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/postgres/test_async_client.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/postgres/test_filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/postgres/test_search_related.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/postgres/test_source.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/test_dsl_parser.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/test_protocol_conformance.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/tpuf/test_configurations.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/tpuf/test_filter_mapper.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/tpuf/test_hybrid_search.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/tpuf/test_namespace.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/corpus/tpuf/test_search_related.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/fakes/chroma.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/fakes/pinecone.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/qa_generation/test_async_cleanup.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/qa_generation/test_batch_processor_async.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/qa_generation/test_filter_and_sample_seeds.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/qa_generation/test_grounding_batch_isolation.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/qa_generation/test_grounding_removed_chunks.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_auto_tune.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_checkpoint_base.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_corpus_profile.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_dedup.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_deterministic_guards.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_entity_quality.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_hop_count_validity.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_keybert_extraction.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_metadata_linker.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_micro_batch.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_relabel_qa_types.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_wiki_builder.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/rag/test_wiki_chunk_linker.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_control.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_doctor.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_help.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_help_render.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_output.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_preflight.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_cli_runs.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_config.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_model_auth.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/test_profile_config.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/traces/test_adapter.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/traces/test_braintrust_adapter.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/traces/test_braintrust_extraction.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/traces/test_http.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/traces/test_pivot.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/traces/test_processing.py +0 -0
- {castform-0.2.2.dev0 → castform-0.2.4}/tests/unit/traces/test_registry.py +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: castform
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: SDK and CLI for the Castform training platform
|
|
5
5
|
Author: castie@castform.com
|
|
6
6
|
Classifier: Operating System :: OS Independent
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Requires-Python: ==3.12.*
|
|
9
|
-
Requires-Dist: benchmax==0.2.
|
|
9
|
+
Requires-Dist: benchmax==0.2.4
|
|
10
10
|
Requires-Dist: httpx[http2]>=0.27.0
|
|
11
|
+
Requires-Dist: tqdm>=4.66.0
|
|
11
12
|
Provides-Extra: chroma
|
|
12
|
-
Requires-Dist: chromadb
|
|
13
|
+
Requires-Dist: chromadb<2,>=1.5.9; extra == 'chroma'
|
|
13
14
|
Requires-Dist: snowballstemmer>=2.2.0; extra == 'chroma'
|
|
14
15
|
Provides-Extra: pinecone
|
|
15
|
-
Requires-Dist: pinecone
|
|
16
|
+
Requires-Dist: pinecone<10,>=9.1.0; extra == 'pinecone'
|
|
16
17
|
Provides-Extra: rag
|
|
17
18
|
Requires-Dist: keybert>=0.8; extra == 'rag'
|
|
18
19
|
Requires-Dist: langchain-text-splitters>=0.3.0; extra == 'rag'
|
|
@@ -22,11 +23,8 @@ Requires-Dist: pydantic>=2.0.0; extra == 'rag'
|
|
|
22
23
|
Requires-Dist: ruamel-yaml>=0.19.1; extra == 'rag'
|
|
23
24
|
Requires-Dist: scikit-learn>=1.8.0; extra == 'rag'
|
|
24
25
|
Requires-Dist: sentence-transformers>=5.2.3; extra == 'rag'
|
|
25
|
-
Requires-Dist: tqdm>=4.66.0; extra == 'rag'
|
|
26
|
-
Provides-Extra: traces
|
|
27
|
-
Requires-Dist: tqdm>=4.66.0; extra == 'traces'
|
|
28
26
|
Provides-Extra: turbopuffer
|
|
29
|
-
Requires-Dist: turbopuffer
|
|
27
|
+
Requires-Dist: turbopuffer<3,>=2.6.0; extra == 'turbopuffer'
|
|
30
28
|
Description-Content-Type: text/markdown
|
|
31
29
|
|
|
32
30
|
# Castform
|
|
@@ -91,13 +89,15 @@ The CLI does not duplicate that orchestration. Use it for `login`, `setup`,
|
|
|
91
89
|
|
|
92
90
|
## Optional libraries
|
|
93
91
|
|
|
94
|
-
Add only the features the project uses:
|
|
92
|
+
Add only the optional features the project uses:
|
|
95
93
|
|
|
96
94
|
```bash
|
|
97
95
|
uv add 'castform[rag]'
|
|
98
|
-
uv add 'castform[traces]'
|
|
99
96
|
```
|
|
100
97
|
|
|
98
|
+
Trace adapters and `castform.traces.TracesPipeline` ship with the base
|
|
99
|
+
`castform` package; no trace-specific extra is required.
|
|
100
|
+
|
|
101
101
|
Vector-store integrations ship as their own extras: `castform[chroma]`,
|
|
102
102
|
`castform[pinecone]`, `castform[turbopuffer]`.
|
|
103
103
|
|
|
@@ -60,13 +60,15 @@ The CLI does not duplicate that orchestration. Use it for `login`, `setup`,
|
|
|
60
60
|
|
|
61
61
|
## Optional libraries
|
|
62
62
|
|
|
63
|
-
Add only the features the project uses:
|
|
63
|
+
Add only the optional features the project uses:
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
66
|
uv add 'castform[rag]'
|
|
67
|
-
uv add 'castform[traces]'
|
|
68
67
|
```
|
|
69
68
|
|
|
69
|
+
Trace adapters and `castform.traces.TracesPipeline` ship with the base
|
|
70
|
+
`castform` package; no trace-specific extra is required.
|
|
71
|
+
|
|
70
72
|
Vector-store integrations ship as their own extras: `castform[chroma]`,
|
|
71
73
|
`castform[pinecone]`, `castform[turbopuffer]`.
|
|
72
74
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "castform"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.4"
|
|
4
4
|
description = "SDK and CLI for the Castform training platform"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "castie@castform.com" }]
|
|
7
7
|
requires-python = "==3.12.*"
|
|
8
8
|
dependencies = [
|
|
9
|
-
"benchmax==0.2.
|
|
9
|
+
"benchmax==0.2.4",
|
|
10
10
|
"httpx[http2]>=0.27.0",
|
|
11
|
+
"tqdm>=4.66.0",
|
|
11
12
|
]
|
|
12
13
|
classifiers = [
|
|
13
14
|
"Programming Language :: Python :: 3",
|
|
@@ -34,12 +35,10 @@ rag = [
|
|
|
34
35
|
"ruamel-yaml>=0.19.1",
|
|
35
36
|
"scikit-learn>=1.8.0",
|
|
36
37
|
"sentence-transformers>=5.2.3",
|
|
37
|
-
"tqdm>=4.66.0",
|
|
38
38
|
]
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
turbopuffer = ["turbopuffer>=1.16.2"]
|
|
39
|
+
chroma = ["chromadb>=1.5.9,<2", "snowballstemmer>=2.2.0"]
|
|
40
|
+
pinecone = ["pinecone>=9.1.0,<10"]
|
|
41
|
+
turbopuffer = ["turbopuffer>=2.6.0,<3"]
|
|
43
42
|
|
|
44
43
|
[dependency-groups]
|
|
45
44
|
dev = [
|
|
@@ -26,6 +26,12 @@ Before changing a stage, load its skill:
|
|
|
26
26
|
| validation and baseline review | `.claude/skills/verify-environment/SKILL.md` |
|
|
27
27
|
| bundle, upload and launch | `.claude/skills/launch-run/SKILL.md` |
|
|
28
28
|
| status, curves, rollouts and logs | `.claude/skills/view-progress/SKILL.md` |
|
|
29
|
+
| supervised finetuning from labeled data | `.claude/skills/train-sft/SKILL.md` |
|
|
30
|
+
|
|
31
|
+
If the user already has the completions the model should imitate (labeled
|
|
32
|
+
conversations, transcripts, input→output pairs), that is **supervised
|
|
33
|
+
finetuning** — read the `train-sft` skill and skip the RL loop above entirely:
|
|
34
|
+
SFT has no environment, validate stage, or rewards.
|
|
29
35
|
|
|
30
36
|
## Project contract
|
|
31
37
|
|
|
@@ -53,6 +59,14 @@ completed zero reward is valid, while an empty result with a failure termination
|
|
|
53
59
|
reason is not. Hosted validation uses the exact uploaded assets that launch would
|
|
54
60
|
consume.
|
|
55
61
|
|
|
62
|
+
Model sampling is trainer-owned. Harness code may request only an output ceiling
|
|
63
|
+
with `max_tokens` or `max_completion_tokens`; validation prints a warning because
|
|
64
|
+
the effective cap may be lower. Do not set `temperature`, `top_p`, `top_k`,
|
|
65
|
+
penalties, `seed`, or `stop` in harness model kwargs. Static validation rejects
|
|
66
|
+
those controls and unsupported response options. Tracked local and hosted
|
|
67
|
+
validation also rejects sampling conflicts, changed tools, overlapping calls,
|
|
68
|
+
and rewritten multi-turn history. Never launch with a contract error.
|
|
69
|
+
|
|
56
70
|
## Bundle and launch boundary
|
|
57
71
|
|
|
58
72
|
The launch stage must remain visibly ordered:
|
|
@@ -90,10 +104,11 @@ that data at runtime. Passing `[]` explicitly uploads an empty JSONL file.
|
|
|
90
104
|
<!-- rag:start -->
|
|
91
105
|
For the RAG template, inspect retrieval separately from answer correctness. Verify
|
|
92
106
|
that reference source IDs and model citations use the same canonicalization, and
|
|
93
|
-
test a known query against the configured corpus before validation.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
107
|
+
test a known query against the configured corpus before validation. Start from the
|
|
108
|
+
matching provider example under
|
|
109
|
+
https://github.com/castform-ai/benchmax/tree/main/examples. Keep corpus ingestion
|
|
110
|
+
or QA generation in the data stage using public `castform.rag` interfaces; the
|
|
111
|
+
rollout environment should depend only on its search adapter and runtime SDKs.
|
|
97
112
|
<!-- rag:end -->
|
|
98
113
|
|
|
99
114
|
The Castform CLI is for login, setup, doctor, guide, run inspection and run
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Get started with Harbor
|
|
2
|
+
|
|
3
|
+
This project is shaped for a Harbor package: Harbor resolves the task dataset,
|
|
4
|
+
creates the sandbox, runs the harness, and executes the verifier. Castform uploads
|
|
5
|
+
the environment bundle and supplies the model session used by the harness.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv sync
|
|
9
|
+
uv run python main.py data --dataset <org/package>
|
|
10
|
+
uv run python main.py validate --dataset <org/package> \
|
|
11
|
+
--modal-token-id <id> --modal-token-secret <secret>
|
|
12
|
+
uv run python main.py launch --dataset <org/package> \
|
|
13
|
+
--modal-token-id <id> --modal-token-secret <secret>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If the packaged verifier needs credentials, inspect its configuration and pass
|
|
17
|
+
each requirement explicitly, for example
|
|
18
|
+
`--verifier-env OPENAI_API_KEY=<key>`. Do not read ambient environment variables
|
|
19
|
+
inside the environment constructor.
|
|
20
|
+
|
|
21
|
+
## Work with your agent
|
|
22
|
+
|
|
23
|
+
Ask your agent to inspect the task package, then start from the closest maintained
|
|
24
|
+
example under <https://github.com/castform-ai/benchmax/tree/main/examples>.
|
|
25
|
+
|
|
26
|
+
Use Harbor when the source is a Harbor package or its records describe executable
|
|
27
|
+
tasks with sandbox/build configuration, a named harness, and an in-sandbox
|
|
28
|
+
verifier. Use `BaseEnv` when the records are ordinary prompts/examples and your
|
|
29
|
+
Python environment owns the model loop and reward directly.
|
|
30
|
+
|
|
31
|
+
Keep the stock `TrialAgentConfig(name="mini-swe-agent")` when it fits. AIME shows
|
|
32
|
+
an offline-installed Mini-SWE variant for unreliable per-sandbox installation;
|
|
33
|
+
Harvey shows a task-specific native harness. Add custom harness code only for a
|
|
34
|
+
similarly concrete reason.
|
|
35
|
+
|
|
36
|
+
The script follows the maintained example shape:
|
|
37
|
+
|
|
38
|
+
- `_constructor_args(args)` builds explicit, serializable configuration once;
|
|
39
|
+
- the same dictionary constructs the local env and the uploaded bundle;
|
|
40
|
+
- Harbor data remains runtime-managed, so `upload_assets` gets no JSONL dataset;
|
|
41
|
+
- validation prints static, local, and remote warnings/errors before launch.
|
|
42
|
+
|
|
43
|
+
Harnesses may request `max_tokens` or `max_completion_tokens`, but validation warns
|
|
44
|
+
because Castform can clamp the effective cap. Do not set trainer-owned sampling
|
|
45
|
+
controls such as `temperature`, `top_p`, penalties, `seed`, or `stop`. A green
|
|
46
|
+
validation also requires real model calls, compatible tracked history, verifier
|
|
47
|
+
execution, and scorable rewards—not merely a completed process.
|
|
48
|
+
|
|
49
|
+
Run `uv run pytest tests` for the structural seed tests, then add task-specific
|
|
50
|
+
tests for required verifier environment, sandbox configuration, and reward output.
|
|
@@ -29,16 +29,19 @@ Point your coding agent at the real task and ask it to load the matching skill i
|
|
|
29
29
|
|
|
30
30
|
```
|
|
31
31
|
Build a Castform environment for <task>. Start with a small representative train
|
|
32
|
-
and eval set
|
|
33
|
-
|
|
32
|
+
set and add an eval set when available. Use the closest maintained example under
|
|
33
|
+
https://github.com/castform-ai/benchmax/tree/main/examples as the starting point,
|
|
34
|
+
define an explicit reward shape, validate two sibling rollouts, and show me the
|
|
35
|
+
result before proposing a launch.
|
|
34
36
|
```
|
|
35
37
|
|
|
36
38
|
**RAG environment:**
|
|
37
39
|
|
|
38
40
|
```
|
|
39
|
-
Build a Castform
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
Build a Castform RAG environment over <corpus>. Use the matching provider example
|
|
42
|
+
under https://github.com/castform-ai/benchmax/tree/main/examples as the starting
|
|
43
|
+
point, test retrieval and reward behavior locally, and show me validation results
|
|
44
|
+
before proposing a launch.
|
|
42
45
|
```
|
|
43
46
|
|
|
44
47
|
Use these skills in order:
|
|
@@ -59,6 +62,16 @@ can be a valid completed result. An operational failure instead has a
|
|
|
59
62
|
non-`finished` `termination_reason`, empty rewards, an `error` message on the
|
|
60
63
|
outcome, and a corresponding log entry.
|
|
61
64
|
|
|
65
|
+
Validation smoke-tests the required train split. Eval data is optional and remains
|
|
66
|
+
the right source for measuring generalization when the task provides it.
|
|
67
|
+
|
|
68
|
+
Validation checks model-request ownership before running and checks tracked
|
|
69
|
+
sampling and history behavior at runtime. Harnesses may request `max_tokens` or
|
|
70
|
+
`max_completion_tokens`, but the scorecard emits a warning when Castform can
|
|
71
|
+
clamp the effective ceiling. Do not set trainer-owned controls such as
|
|
72
|
+
`temperature`, `top_p`, `top_k`, penalties, `seed`, or `stop`; fix any static or
|
|
73
|
+
runtime contract error before launch.
|
|
74
|
+
|
|
62
75
|
After a green baseline, decide deliberately:
|
|
63
76
|
|
|
64
77
|
- iterate on the environment, data or reward and validate again; or
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Unit tests for the dataset and reward. Grow these alongside main.py: cover
|
|
2
|
+
malformed rows plus empty, wrong, partial and correct answers.
|
|
3
|
+
|
|
4
|
+
Plain `asyncio.run` keeps the suite dependency-free; run with `uv run pytest tests`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import asyncio
|
|
8
|
+
import json
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
from benchmax.envs.base import BaseRollout
|
|
12
|
+
from main import CustomEnv
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _rollout(answer: str, ground_truth: str) -> BaseRollout:
|
|
16
|
+
return BaseRollout(
|
|
17
|
+
rollout_id="rollout-1",
|
|
18
|
+
termination_reason="stop",
|
|
19
|
+
messages=[
|
|
20
|
+
{"role": "user", "content": "prompt"},
|
|
21
|
+
{"role": "assistant", "content": answer},
|
|
22
|
+
],
|
|
23
|
+
example_args={"ground_truth": ground_truth},
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _reward(answer: str, ground_truth: str) -> dict[str, float]:
|
|
28
|
+
return asyncio.run(CustomEnv().compute_reward(_rollout(answer, ground_truth)))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_empty_answer_is_incorrect() -> None:
|
|
32
|
+
assert _reward("", "Paris") == {"correctness": 0.0}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_exact_answer_is_correct() -> None:
|
|
36
|
+
assert _reward("Paris", "Paris") == {"correctness": 1.0}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_case_and_outer_whitespace_are_normalized() -> None:
|
|
40
|
+
assert _reward(" PARIS\n", "Paris") == {"correctness": 1.0}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_wrong_answer_is_incorrect() -> None:
|
|
44
|
+
assert _reward("Berlin", "Paris") == {"correctness": 0.0}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_verbose_answer_containing_gold_is_not_an_exact_answer() -> None:
|
|
48
|
+
assert _reward("The capital of France is Paris.", "Paris") == {"correctness": 0.0}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.mark.parametrize(
|
|
52
|
+
"row",
|
|
53
|
+
[
|
|
54
|
+
{},
|
|
55
|
+
{"prompt": "", "ground_truth": "Paris"},
|
|
56
|
+
{"prompt": "Capital of France?"},
|
|
57
|
+
{"prompt": "Capital of France?", "ground_truth": ""},
|
|
58
|
+
],
|
|
59
|
+
)
|
|
60
|
+
def test_malformed_rows_fail_loudly(row) -> None:
|
|
61
|
+
with pytest.raises((TypeError, ValueError)):
|
|
62
|
+
CustomEnv()._example_from_row(row)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_semantic_payload_has_stable_identity() -> None:
|
|
66
|
+
env = CustomEnv()
|
|
67
|
+
row = {"prompt": "Capital of France?", "ground_truth": "Paris"}
|
|
68
|
+
|
|
69
|
+
assert env._example_from_row(row).id == env._example_from_row(dict(row)).id
|
|
70
|
+
assert (
|
|
71
|
+
env._example_from_row(row).id != env._example_from_row({**row, "ground_truth": "Lyon"}).id
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_split_order_and_identity_are_preserved(tmp_path) -> None:
|
|
76
|
+
train_rows = [
|
|
77
|
+
{"prompt": "first", "ground_truth": "one"},
|
|
78
|
+
{"prompt": "second", "ground_truth": "two"},
|
|
79
|
+
]
|
|
80
|
+
eval_rows = [{"prompt": "third", "ground_truth": "three"}]
|
|
81
|
+
for split, rows in (("train", train_rows), ("eval", eval_rows)):
|
|
82
|
+
(tmp_path / f"{split}.jsonl").write_text(
|
|
83
|
+
"".join(f"{json.dumps(row)}\n" for row in rows),
|
|
84
|
+
encoding="utf-8",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
env = CustomEnv()
|
|
88
|
+
train = asyncio.run(env.create_dataset("train", tmp_path))
|
|
89
|
+
eval_ = asyncio.run(env.create_dataset("eval", tmp_path))
|
|
90
|
+
|
|
91
|
+
assert [example.payload["ground_truth"] for example in train] == ["one", "two"]
|
|
92
|
+
assert {example.id for example in train}.isdisjoint(example.id for example in eval_)
|
|
@@ -17,11 +17,12 @@ from __future__ import annotations
|
|
|
17
17
|
import argparse
|
|
18
18
|
import asyncio
|
|
19
19
|
import dataclasses
|
|
20
|
-
import difflib
|
|
21
20
|
import json
|
|
22
21
|
from pathlib import Path
|
|
23
22
|
from typing import Any
|
|
24
23
|
|
|
24
|
+
from benchmax.envs.base import resolve_dataset_path
|
|
25
|
+
|
|
25
26
|
from benchmax.bundle import dump_bundle
|
|
26
27
|
from benchmax.envs import (
|
|
27
28
|
BaseEnv,
|
|
@@ -34,7 +35,6 @@ from benchmax.envs import (
|
|
|
34
35
|
canonical_example_id,
|
|
35
36
|
)
|
|
36
37
|
from benchmax.rewards import extract_completion_text
|
|
37
|
-
|
|
38
38
|
from castform import validate_environment
|
|
39
39
|
from castform.platform.client import TrainerClient
|
|
40
40
|
from castform.platform.environment_assets import upload_assets
|
|
@@ -44,12 +44,12 @@ from castform.platform.login import ensure_session
|
|
|
44
44
|
class CustomEnv(BaseEnv):
|
|
45
45
|
"""A single-turn env: the model answers a prompt, scored against ground_truth.
|
|
46
46
|
|
|
47
|
-
No tools and no LLM judge — the reward
|
|
47
|
+
No tools and no LLM judge — the reward is normalized exact-match correctness
|
|
48
48
|
and needs no separate judge call. Swap in your own reward / tools / judge.
|
|
49
49
|
"""
|
|
50
50
|
|
|
51
51
|
# Advertised to the model each rollout (optional; default ""). Keep it short.
|
|
52
|
-
system_prompt = "
|
|
52
|
+
system_prompt = "Return only the answer, without explanation."
|
|
53
53
|
max_turns = 1
|
|
54
54
|
|
|
55
55
|
async def create_dataset(
|
|
@@ -60,7 +60,7 @@ class CustomEnv(BaseEnv):
|
|
|
60
60
|
max_examples: int | None = None,
|
|
61
61
|
) -> JsonlDataset[JsonRow]:
|
|
62
62
|
return JsonlDataset(
|
|
63
|
-
base_dir
|
|
63
|
+
resolve_dataset_path(base_dir, f"{split}.jsonl"),
|
|
64
64
|
row_to_example=self._example_from_row,
|
|
65
65
|
max_examples=max_examples,
|
|
66
66
|
)
|
|
@@ -69,12 +69,25 @@ class CustomEnv(BaseEnv):
|
|
|
69
69
|
prompt = row.get("prompt")
|
|
70
70
|
if not isinstance(prompt, str):
|
|
71
71
|
raise TypeError("dataset rows require a string 'prompt'")
|
|
72
|
+
if not prompt.strip():
|
|
73
|
+
raise ValueError("dataset rows require a non-empty 'prompt'")
|
|
74
|
+
ground_truth = row.get("ground_truth")
|
|
75
|
+
if not isinstance(ground_truth, str):
|
|
76
|
+
raise TypeError("dataset rows require a string 'ground_truth'")
|
|
77
|
+
if not ground_truth.strip():
|
|
78
|
+
raise ValueError("dataset rows require a non-empty 'ground_truth'")
|
|
79
|
+
extra = {
|
|
80
|
+
key: value
|
|
81
|
+
for key, value in row.items()
|
|
82
|
+
if key not in ("prompt", "ground_truth", "prompt_messages")
|
|
83
|
+
}
|
|
72
84
|
payload: JsonRow = {
|
|
85
|
+
**extra,
|
|
73
86
|
"prompt_messages": [
|
|
74
87
|
{"role": "system", "content": self.system_prompt},
|
|
75
88
|
{"role": "user", "content": prompt},
|
|
76
89
|
],
|
|
77
|
-
|
|
90
|
+
"ground_truth": ground_truth,
|
|
78
91
|
}
|
|
79
92
|
return Example(id=canonical_example_id(payload), payload=payload)
|
|
80
93
|
|
|
@@ -82,25 +95,14 @@ class CustomEnv(BaseEnv):
|
|
|
82
95
|
self,
|
|
83
96
|
rollout: BaseRollout,
|
|
84
97
|
) -> dict[str, float]:
|
|
85
|
-
"""Score
|
|
86
|
-
components are SUMMED into one scalar — this is your whole training signal,
|
|
87
|
-
so edit it. (Deterministic overlap here; swap in an LLM judge for open-ended
|
|
88
|
-
answers — see the design-environment skill.)
|
|
89
|
-
"""
|
|
90
|
-
t = rollout.example_args
|
|
98
|
+
"""Score a normalized exact answer against the required ground truth."""
|
|
91
99
|
answer = extract_completion_text(rollout.messages).strip()
|
|
92
|
-
gold =
|
|
93
|
-
if not
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
contains = 1.0 if gold and gold.lower() in answer.lower() else 0.0
|
|
99
|
-
return {
|
|
100
|
-
"overlap": overlap, # fuzzy match with the gold answer, in [0, 1]
|
|
101
|
-
"contains_gold": 0.5 * contains, # the gold string appears verbatim
|
|
102
|
-
"answered": 0.1, # small shaping: produced a non-empty answer
|
|
103
|
-
}
|
|
100
|
+
gold = rollout.example_args.get("ground_truth")
|
|
101
|
+
if not isinstance(gold, str) or not gold.strip():
|
|
102
|
+
raise ValueError("rollout requires a non-empty string 'ground_truth'")
|
|
103
|
+
normalized_answer = " ".join(answer.casefold().split())
|
|
104
|
+
normalized_gold = " ".join(gold.casefold().split())
|
|
105
|
+
return {"correctness": float(normalized_answer == normalized_gold)}
|
|
104
106
|
|
|
105
107
|
|
|
106
108
|
# ── Run config — validate/launch read these so the run reproduces from this
|
|
@@ -112,6 +114,7 @@ VALIDATE_CONFIG = {
|
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
LAUNCH_CONFIG = {
|
|
117
|
+
"model": "Qwen/Qwen3.5-4B",
|
|
115
118
|
# Total prompt + response tokens across the WHOLE rollout. Single-turn answers
|
|
116
119
|
# are short; raise it if your task needs longer prompts or tool transcripts.
|
|
117
120
|
"max_context_tokens": 4096,
|
|
@@ -135,7 +138,6 @@ LAUNCH_CONFIG = {
|
|
|
135
138
|
|
|
136
139
|
TRAIN_FILE = "train.jsonl"
|
|
137
140
|
EVAL_FILE = "eval.jsonl"
|
|
138
|
-
ENV_ARGS: dict[str, Any] = {} # CustomEnv constructor kwargs (none by default)
|
|
139
141
|
|
|
140
142
|
# Dependencies installed in the remote rollout runtime. Keep this declaration at
|
|
141
143
|
# the script boundary: add only packages imported by your env/reward/tool code.
|
|
@@ -172,6 +174,16 @@ def _run_name() -> str:
|
|
|
172
174
|
return str(LAUNCH_CONFIG.get("name") or CustomEnv.__name__.lower())
|
|
173
175
|
|
|
174
176
|
|
|
177
|
+
def _constructor_args(args: argparse.Namespace) -> dict[str, Any]:
|
|
178
|
+
"""Build explicit, serializable kwargs shared by local and remote envs.
|
|
179
|
+
|
|
180
|
+
Add task configuration and credentials as CLI arguments, then translate them
|
|
181
|
+
here instead of reading ambient environment variables inside ``CustomEnv``.
|
|
182
|
+
"""
|
|
183
|
+
del args
|
|
184
|
+
return {}
|
|
185
|
+
|
|
186
|
+
|
|
175
187
|
def generate_data(force: bool = False) -> bool:
|
|
176
188
|
"""Produce `train.jsonl` / `eval.jsonl`.
|
|
177
189
|
|
|
@@ -180,17 +192,32 @@ def generate_data(force: bool = False) -> bool:
|
|
|
180
192
|
the gen code here so the dataset stays reproducible from this file. Re-run with
|
|
181
193
|
--force to regenerate; skip-if-exists otherwise.
|
|
182
194
|
"""
|
|
183
|
-
|
|
184
|
-
|
|
195
|
+
datasets = (
|
|
196
|
+
(Path(TRAIN_FILE), _SEED_TRAIN),
|
|
197
|
+
(Path(EVAL_FILE), _SEED_EVAL),
|
|
198
|
+
)
|
|
199
|
+
pending = (
|
|
200
|
+
list(datasets) if force else [(path, rows) for path, rows in datasets if not path.exists()]
|
|
201
|
+
)
|
|
202
|
+
if not pending:
|
|
185
203
|
print(f"data: {TRAIN_FILE} / {EVAL_FILE} present — skipping (--force to redo)")
|
|
186
204
|
return True
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
205
|
+
for path, rows in pending:
|
|
206
|
+
_write_jsonl(str(path), rows)
|
|
207
|
+
written = ", ".join(f"{path} ({len(rows)} rows)" for path, rows in pending)
|
|
208
|
+
print(f"data: wrote {written}")
|
|
190
209
|
return True
|
|
191
210
|
|
|
192
211
|
|
|
193
212
|
def _print_validation(report: Any) -> None:
|
|
213
|
+
for location in ("static", "local", "remote"):
|
|
214
|
+
warnings = getattr(report, f"{location}_warnings", {}) or {}
|
|
215
|
+
for item, messages in warnings.items():
|
|
216
|
+
values = messages if isinstance(messages, list) else [messages]
|
|
217
|
+
for message in values:
|
|
218
|
+
print(f"⚠️ {location} {item}: {message}")
|
|
219
|
+
for item, error in (getattr(report, "static_errors", {}) or {}).items():
|
|
220
|
+
print(f"❌ static {item}: {error}")
|
|
194
221
|
for location in ("local", "remote"):
|
|
195
222
|
outcomes = getattr(report, location)
|
|
196
223
|
if outcomes is None:
|
|
@@ -287,11 +314,12 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
287
314
|
if args.action == "data":
|
|
288
315
|
return 0
|
|
289
316
|
|
|
317
|
+
constructor_args = _constructor_args(args)
|
|
290
318
|
ensure_session() # data preparation stays usable without platform login
|
|
291
319
|
print(f"[stage 2/{total_stages}] bundling environment")
|
|
292
320
|
bundled_environment = dump_bundle(
|
|
293
321
|
CustomEnv,
|
|
294
|
-
constructor_args=
|
|
322
|
+
constructor_args=constructor_args,
|
|
295
323
|
pip_dependencies=RUNTIME_DEPENDENCIES,
|
|
296
324
|
)
|
|
297
325
|
print(f"[stage 3/{total_stages}] uploading environment and dataset")
|
|
@@ -305,7 +333,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
305
333
|
print(f" env_metadata_path: {uploaded_assets.env_metadata_path}")
|
|
306
334
|
print(f" dataset_path: {uploaded_assets.dataset_path}")
|
|
307
335
|
print(f"[stage 4/{total_stages}] validating environment")
|
|
308
|
-
report = validate(CustomEnv(**
|
|
336
|
+
report = validate(CustomEnv(**constructor_args), uploaded_assets)
|
|
309
337
|
if not report.ok:
|
|
310
338
|
return 1
|
|
311
339
|
if args.action == "launch":
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Structural tests for the Harbor seed. Add task-specific verifier tests here."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
from benchmax.envs.harbor import HarborEnv, ModalCredentials
|
|
7
|
+
from main import (
|
|
8
|
+
CustomHarborEnv,
|
|
9
|
+
_constructor_args,
|
|
10
|
+
_parse_verifier_env,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _args(**overrides):
|
|
15
|
+
values = {
|
|
16
|
+
"dataset": "org/task-package",
|
|
17
|
+
"dataset_ref": "latest",
|
|
18
|
+
"modal_token_id": "modal-id",
|
|
19
|
+
"modal_token_secret": "modal-secret",
|
|
20
|
+
"verifier_env": ["OPENAI_API_KEY=judge-key"],
|
|
21
|
+
}
|
|
22
|
+
values.update(overrides)
|
|
23
|
+
return argparse.Namespace(**values)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_constructor_args_are_explicit_and_build_the_stock_harness() -> None:
|
|
27
|
+
constructor_args = _constructor_args(_args())
|
|
28
|
+
env = CustomHarborEnv(**constructor_args)
|
|
29
|
+
|
|
30
|
+
assert isinstance(env, HarborEnv)
|
|
31
|
+
assert constructor_args["dataset_name"] == "org/task-package"
|
|
32
|
+
assert constructor_args["dataset_ref"] == "latest"
|
|
33
|
+
assert isinstance(constructor_args["sandbox_credentials"], ModalCredentials)
|
|
34
|
+
assert constructor_args["verifier_env"] == {"OPENAI_API_KEY": "judge-key"}
|
|
35
|
+
assert env._trial.agent.name == "mini-swe-agent"
|
|
36
|
+
assert env._trial.agent.model_name is None
|
|
37
|
+
assert env._trial.agent.kwargs == {}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_stock_harness_has_no_static_model_contract_errors() -> None:
|
|
41
|
+
env = CustomHarborEnv(**_constructor_args(_args()))
|
|
42
|
+
|
|
43
|
+
assert env.validation_diagnostics() == ()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_verifier_env_accepts_repeated_name_value_arguments() -> None:
|
|
47
|
+
assert _parse_verifier_env(["OPENAI_API_KEY=key", "OPENAI_BASE_URL=https://host/v1"]) == {
|
|
48
|
+
"OPENAI_API_KEY": "key",
|
|
49
|
+
"OPENAI_BASE_URL": "https://host/v1",
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@pytest.mark.parametrize(
|
|
54
|
+
"assignments",
|
|
55
|
+
[
|
|
56
|
+
["OPENAI_API_KEY"],
|
|
57
|
+
["OPENAI_API_KEY="],
|
|
58
|
+
["BAD-NAME=value"],
|
|
59
|
+
["OPENAI_API_KEY=one", "OPENAI_API_KEY=two"],
|
|
60
|
+
],
|
|
61
|
+
)
|
|
62
|
+
def test_verifier_env_rejects_ambiguous_values(assignments: list[str]) -> None:
|
|
63
|
+
with pytest.raises(ValueError):
|
|
64
|
+
_parse_verifier_env(assignments)
|