Skip to content

fix(core): give default seed candidates a per-run id (#163) - #164

Open
RupeshMaster wants to merge 1 commit into
CodewithJha:mainfrom
RupeshMaster:fix/unique-seed-candidate-ids
Open

RupeshMaster wants to merge 1 commit into
CodewithJha:mainfrom
RupeshMaster:fix/unique-seed-candidate-ids

Conversation

@RupeshMaster

Copy link
Copy Markdown

Summary

Fixes #163. From the second campaign over the same policy onward, Hosted listed none of the campaign's seed candidates and overwrote the first campaign's candidate rows and traces, because default seed ids are a hash of the seed text and Hosted keys candidates by id alone.

  • CampaignEngine now suffixes default seed ids with a per-run token: seed-0-a792b2c8 becomes seed-0-a792b2c8-<run>. Padded copies and children are unaffected (children already use UUIDs).
  • Seeds passed explicitly with seeds= keep their ids, and default_policy_seeds() itself is unchanged (still deterministic per policy).
  • One change in Core fixes both paths: the Hosted demo supervisor and mutiny run --hosted ingest.

Not in this PR

The Hosted schema still keys candidates / traces by candidate id alone, and upsert_candidate updates a row owned by another campaign. After this change the CLI and the demo no longer produce duplicate ids, but a client that sends them (for example an older CLI) can still collide. A (campaign_id, id) key or a conflict check on ingest would close that; it needs a migration, so I left it for a separate change if you want it.

Type of change

Checklist

  • I read CONTRIBUTING.md (where to ask, how reviews work, how to run tests)
  • Linked related issue (Fixes #N) or Discussion when applicable
  • Core stays free of framework SDK imports (adapters own glue)
  • Tests added or updated when behavior changes (uv run pytest tests/unit -q)
  • Docs / README claims match reality (no PyPI / multi-adapter claims unless shipped)
  • One concern per PR when possible
  • Authorized testing only — no open-internet attack-proxy behavior

Test plan

  • Python lint: uv run --locked ruff check → all checks passed
  • Backend tests: uv run pytest tests/unit tests/integration tests/reliability -q → 851 passed. Run locally on Python 3.12 only (macOS, OPENAI_API_KEY unset); 3.11 is left for CI.
  • CLI smoke: from a copy of examples/openai_support_agent, mutiny --help, mutiny init, mutiny run with MUTINY_SAMPLE_OFFLINE=1 and empty OPENAI_API_KEY / FEATHERLESS_API_KEY → violation found, regression saved.
  • Web typecheck + build: not run; apps/web is not touched.
  • Package build + isolated artifact gate: tests/unit/test_package_release.py passed as part of the unit run; ./scripts/verify_release_artifacts.sh not run.

Extra:

  • New tests: two in tests/unit/test_campaign.py (ids unique per run, explicit seeds kept) and one in tests/integration/test_api.py (two demo campaigns each keep their own candidates and traces). The first unit test and the integration test fail on main (ee7e898).
  • Against a running API with a fresh database: two demo campaigns followed by two mutiny run --hosted runs of the sample project now each list their own candidate (seed-0-a792b2c8-d068b5be, …-77b6aaa1, …-62c7ad66, …-96f691ac). On main only the first of the four listed any.

Notes

  • Independent of my other open PRs; it merges cleanly with each of them.
  • AI assistance: this change was written with an AI coding agent. The checks above were run locally before opening the PR.

default_policy_seeds() ids are a hash of the seed text, so they are the
same for every campaign over the same policy. Hosted keys candidates
(and traces) by candidate id alone, and its upsert keeps the original
campaign_id, so from the second campaign on:

- the campaign page listed none of its seed candidates (with
  stop_on_first_violation the page said "Break found" with nothing to
  inspect, minimize or save)
- the first campaign's candidate row and trace were overwritten with the
  later run's evidence

This happened for a repeated Hosted demo run and for `mutiny run --hosted`
run twice on one project. The engine now suffixes default seed ids with a
per-run token (seed-0-<hash>-<run>). Explicitly passed seeds keep their
ids, and default_policy_seeds() itself is unchanged.
@vercel

vercel Bot commented Nov 27, 2026

Copy link
Copy Markdown

@RupeshMaster is attempting to deploy a commit to the priyanshu's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Hosted: second campaign over the same policy shows no seed candidates and overwrites the first campaign's evidence

1 participant