Skip to content

Version and Register Verification Prompts - #1114

Open
richardgittest wants to merge 3 commits into
Pulsefy:mainfrom
richardgittest:main
Open

richardgittest wants to merge 3 commits into
Pulsefy:mainfrom
richardgittest:main

Conversation

@richardgittest

Copy link
Copy Markdown

Files Changed

  1. Core registry + prompt library — humanitarian_prompt.py

New PromptVersion (frozen dataclass): name, version, description, immutable builder. Exposes content_hash(**kw) and build(**kw).
New PromptRegistry class:
register(prompt_version) — rejects duplicates → enforces no edit-in-place
set_active_version(name, version) — runtime pinning
get_active_version(name) — falls back to latest registered when config is silent
resolve(name, version=None) — explicit or active lookup
build_prompt(name, version=None, **kw) — returns {system, user, prompt_name, prompt_version, prompt_content_hash}
Default 1.0 versions for both humanitarian_primary and humanitarian_fallback are the exact original prompt texts extracted from the inline builder — semantically identical.
2. Configuration — config.py

New field humanitarian_prompt_active_versions: Dict[str, str] with JSON env var example in docstring.
3. Verification service — humanitarian_verification.py

Constructor now accepts prompt_registry: Optional[PromptRegistry] (defaults to one built from settings).
verify_claim() builds both prompts via registry.build_prompt(...), records prompt_name, prompt_version, prompt_content_hash in the returned dict alongside the existing prompt_variant label.
New get_prompt_versions_tag() → "primary=1.0|fallback=1.0" used as a cache key tag so a version bump auto-invalidates.
4. Response schemas — schemas/common.py and schemas/humanitarian.py

Common: new PromptVersionInfo(name, version, content_hash) model + new optional prompt_versions: Dict[str, PromptVersionInfo] field on ResultEnvelope.
Humanitarian legacy schema: added prompt_name, prompt_version, prompt_content_hash fields + model_config = { "extra": "ignore" } so HumanitarianVerificationResponse(success=True, **result) in the deprecated route stays permissive.
5. Humanitarian API route — api/v1/humanitarian.py

Added prompt_versions_tag to @cached_response key_tags so prompt-version changes bust the cache (no stale responses after rollback/upgrade).
Builds prompt_versions envelope map from raw["prompt_name"] / ["prompt_version"] / ["prompt_content_hash"] keyed by the prompt_variant label ("primary" or "fallback").
6. Regression harness migration — regression_harness/deterministic_provider.py

Replaced HumanitarianPromptEngine() + build_primary_prompt/build_fallback_prompt with PromptRegistry().build_prompt("humanitarian_primary"/"humanitarian_fallback", …). llm_chat still consumes prompt["system"]/prompt["user"] unchanged — behaviour preserved.

Closes #979

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@richardgittest Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Cedarich

Cedarich commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

@richardgittest kindly fix CI

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.

Version and Register Verification Prompts

3 participants