45 sample contract - #53
Open
ajtritt wants to merge 2 commits into
Open
Conversation
- this will form the basis for updating the sample contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #45
Summary
dataset_contract.yamlis a plain dict validated by explicit checks (matching theconfig.yamlpattern insession.py), not a dataclass hierarchy — consistent with this codebase's existing schema style. No MCP tool or skill consumes the contract yet.Code changes
src/dsagt/contract.py(new): the sample-contract schema.validate_contract()checks sample keys (dtype, shape with symbolic dims, value range, role), per-key collation, split policy (strategy, group key, seed, ratios), the normalization-ownership flag, the pipeline fingerprint (required inmode: pipeline, forbidden inmode: standalone), and the reconciliation section (producer/consumer/resolution per key, key must be declared).load_contract()/save_contract()read and write<project>/dataset_contract.yaml, validating on both ends. Each closed-vocabulary constant (VALID_MODES,VALID_ROLES,VALID_NORMALIZATION_OWNERS,VALID_SPLIT_STRATEGIES) carries a comment defining what every one of its values means — the enum names alone weren't documentation, and that was a real gap in the first pass of this PR.src/dsagt/provenance.py: addedcompute_pipeline_fingerprint(), hashing onlydependency_graphandterminal_outputsfrom areconstruct_pipeline(fmt="json")payload — neverrecords, so timestamps/stdout/exit codes that vary rerun to rerun don't perturb the hash. Updated the module docstring's pipeline-reconstruction summary to mention the JSON format (from Structured output format forreconstruct_pipeline#44) and the fingerprint.docs/dataset-contract.md(new): documents the schema, a field reference defining what each enum value means (mode,keys.<name>.role,normalization.owner,split.strategy), and both worked examples — a tabular case (standalone mode, group split by patient) and the XGC graph case fromuse_cases/fusion-fm/skills/xgc-ai-training/scripts/xgc_dataset.py(pipeline mode, symbolicN/Edims, PyG graph collation, split grouped by phi-plane). Added to the mkdocs nav under Capabilities.CLAUDE.md: addedcontract.pyto the module list.tests/test_contract.py(new): both worked examples validated and round-tripped through disk; failure cases for every schema rule (missing version, bad mode, fingerprint required/forbidden by mode, empty keys, missing dtype, bad role, non-int/symbolic shape entry, bad normalization owner, bad split strategy, missing group_key, ratios not summing to 1, reconciliation referencing an undeclared key, missing reconciliation field);save_contractdoesn't write the file when validation fails.tests/test_pipeline.py: addedTestComputePipelineFingerprint— stable across a simulated rerun with different timestamps/stdout/exit code, changes when a step is added, changes when a step is removed, changes when an output path is renamed, and unaffected by noisystdout/return_codemutations that don't touch the dependency graph or terminal outputs.