Skip to content

Keep published families in their splits with a split lock - #47

Merged
EonHao merged 1 commit into
mainfrom
fix/stable-family-splits
Nov 1, 2026
Merged

EonHao merged 1 commit into
mainfrom
fix/stable-family-splits

Conversation

@EonHao

@EonHao EonHao commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Closes #35.

Behavior

The bug. When recipe.family_splits was empty, families were ranked by hash and sliced into quotas. Adding one family shifted the slice boundaries, so a rebuild with build could move existing families between train, development, and test. A v2 dataset could then train on v1's test families.

Why not just a different hash. Without stored state, an assignment that keeps every existing family in place when families are added must, by induction, depend on each family alone. That is independent hashing, and independent hashing can leave a small project without a test split, which is exactly why the quota assignment was introduced. Both properties cannot hold without remembering previous assignments.

The fix: a split lock, like a package lock file.

Situation Behavior
First build of a specification Families are assigned by quota (split sizes unchanged), and every assignment is written to project.splits.lock.json next to the spec
Later builds Locked families keep their split; new families get a per-family hash split that no other family affects, and are appended
Family removed, later re-added Stays in the lock and returns to its original split
Recipe pin contradicts the lock Error. Editing the lock is the deliberate way to move a family
Build fails The lock is untouched; it is written only after a successful build
build --locked-splits Fails instead of creating or changing the lock. CI uses it for the example, whose lock is committed

plan-recipe, impact, and update resolve splits the same way, so plans and builds agree. update also carries the previous run's cumulative registry into the lock.

Code cleanup along the way:

  • Split planning moves from generation into a dedicated splits module.
  • A shared Split type replaces five copies of Literal["train", "development", "test"].
  • generate_family now requires the resolved split. It used to silently fall back to an unlocked assignment.
  • _build computes the plan and the engine fingerprint once instead of three times. scenario_fingerprint requires both arguments explicitly.

Docs. Updated docs/specification.md (new Split lock section), docs/index.md, docs/architecture.md, both READMEs, and CHANGELOG.md.

Validation

New tests/test_splits.py (11 tests):

  • Growth never moves a family. Grows a project from 3 to 59 families one at a time and asserts no locked family ever moves. The same sweep confirms that the old quota assignment does move families.
  • Lock behavior:
    • first versions fill every configured split;
    • removed families return to their split;
    • contradicting pins are rejected, and so is a lock from another organization;
    • a rebuild into the same directory is unchanged once the lock exists;
    • --locked-splits rejects a missing or stale lock;
    • failed builds leave no lock;
    • plans made before and after the first build both load;
    • update keeps removed families in the lock.
  • Example unchanged. The committed example lock is current and still yields 196 train · 84 development · 56 test episodes.

Two existing tests now assert the stronger guarantees. The family-growth test checks that existing families keep their splits. The expansion test checks that the lock refuses the move, and that expansion import still refuses crossing splits after a deliberate lock edit.

Checks:

  • pytest: 287 passed, 4 skipped (optional extras not installed locally).
  • ruff check, ruff format --check, mypy src (strict), and mkdocs build --strict pass.
  • pre-commit and actionlint pass.
  • decision-forge build examples/customer_support/project.yaml --output … --locked-splits succeeds.

Compatibility and data

  • Existing projects: the first build after upgrading writes a lock from the current family set; commit it next to the specification.
  • Projects that already grew after publishing: their previous assignment is preserved by update, which seeds the lock from the previous run's registry.
  • Engine fingerprint changes (as with every release); use new output directories.
  • Plans from plan-recipe made with older versions must be regenerated, because plan fingerprints now include the resolved splits.

🤖 Generated with Claude Code

Fixes #35. Without stored state, an assignment that keeps existing
families in place when families are added must depend on each family
alone, and independent hashing can leave a small project without a test
split. Quota slicing avoided that but reshuffled families whenever the
project grew, so a rebuild could move held-out families into training.

Record assignments instead, like a package lock file:

- The first build assigns families by quota (unchanged split sizes) and
  writes project.splits.lock.json next to the specification.
- Later builds pin every locked family, give new families a per-family
  hash split, and keep removed families in the lock so they return to
  their original split.
- A recipe pin that contradicts the lock is an error; editing the lock is
  the deliberate way to move a family.
- The lock is written only after a successful build. `build
  --locked-splits` fails instead of creating or changing it; CI uses it
  for the example, whose lock is committed.
- `plan-recipe`, `impact`, and `update` resolve splits the same way, and
  `update` also carries the previous run's registry into the lock.

Split planning moves into a dedicated `splits` module. A shared `Split`
type replaces repeated literals, `generate_family` now requires the
resolved split instead of silently recomputing an unlocked one, and
`_build` computes the plan and engine fingerprint once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added area/policy Rule semantics, priority, conflict analysis area/generation Scenarios, quotas, synthesis, deduplication area/harness Workflow tasks, Harbor export, grading area/feedback Runtime events, reviewed feedback, lineage, targeted updates area/infra CI, packaging, releases, and repository automation area/docs Site, README, and reference material labels Nov 1, 2026
@EonHao
EonHao merged commit 7bb1034 into main Nov 1, 2026
18 checks passed
@EonHao EonHao mentioned this pull request Nov 3, 2026
@EonHao
EonHao deleted the fix/stable-family-splits branch November 22, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Site, README, and reference material area/feedback Runtime events, reviewed feedback, lineage, targeted updates area/generation Scenarios, quotas, synthesis, deduplication area/harness Workflow tasks, Harbor export, grading area/infra CI, packaging, releases, and repository automation area/policy Rule semantics, priority, conflict analysis

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unpinned builds reassign existing families to different splits when a family is added

1 participant