Skip to content

feat: reproducible placeholder values with a fixed clock and seed - #95

Merged
Bbenchaya merged 1 commit into
intuit:mainfrom
atishay-kasliwal:feature/62-reproducible-placeholders
Nov 23, 2026
Merged

Bbenchaya merged 1 commit into
intuit:mainfrom
atishay-kasliwal:feature/62-reproducible-placeholders

Conversation

@atishay-kasliwal

Copy link
Copy Markdown
Contributor

What

Opt-in reproducible mock output. scenario_metadata["stuntdouble"] accepts base_time to freeze timestamp placeholders and seed to drive {{uuid}} and the random_* placeholders from a private stream. Nothing changes unless a scenario sets them.

"stuntdouble": {"base_time": "2026-01-15T10:00:00Z", "seed": 42}

Also adds {{now_utc}} for a timezone-aware UTC default, and base_time= and rng= on resolve_output. The new "Reproducible Outputs" section in matchers-and-resolvers.md covers the rules below.

Fixes #62

Run identity and lifetime

#62 asks for these to be defined, so here is the contract for review:

Case Behaviour
Run identity thread_id, narrowed by an optional invocation_id
Repeated thread_id Continues the stream, because a thread is one conversation. A new invocation_id starts fresh
Missing identifier A seeded scenario with neither identifier fails, because its values could be neither repeated nor isolated
Reset registry.reset_run_state(config) forgets one run, and with no config forgets all
Direct call, config=None The resolved callable is the run, as with sequence counters. Resolving again restarts it
Retention About 1,024 streams per tool. Past that, only streams idle for an hour are dropped, so an active run is never reset
Parallel calls, different tools Independent, whatever order they run in
Parallel calls, one tool Each draws new values, but which call gets which depends on execution order

Streams are per tool and per run, stored on the factory, because the wrapper resolves on every call. scenario_id isn't part of the identity since concurrent runs can share it, and checkpoint_ns isn't because LangGraph changes it on every tools step.

Relation to #53 and #81

This doesn't require the #53 world-state work, as the issue says. {{sequence}} counters are unchanged and out of scope, so #81 stays open. The run identity above is the part I'd like checked against #53, and if #81 or #53 settles on something else, _run_key is the one place to change.

#90 also edits DataDrivenMockFactory.__call__, so whichever lands second has a small conflict in scenario_mocking.py.

Tests

tests/test_reproducible_outputs.py adds 44 test cases, including graph runs through create_mockable_tool_wrapper: stream advance across tool calls, replay in a fresh run, concurrent runs sharing a registry, repeated threads, reset, parallel calls and a fixed clock across calls. Other tests confirm that unconfigured scenarios keep their current behaviour.

Removing each key behaviour fails a test: the per-run stream, run isolation, per-tool streams, the missing-identifier error, protection for active runs, the registry lock and the private generator.

Locally, on Python 3.12, 3.13 and 3.14: pytest tests/ passes 578. On 3.14, tests-e2e/ passes 15, ruff check, ruff format --check and mypy src pass, and coverage on scenario_mocking.py is 100%. Merged with #93 and #94, 598 pass.

scenario_metadata["stuntdouble"] accepts base_time to freeze timestamp
placeholders and seed to drive {{uuid}} and the random_* placeholders
from a private stream. Defaults are unchanged.

A stream is private to a tool and a run, identified by thread_id and an
optional invocation_id, so it advances across the wrapper's per-call
resolves and concurrent runs cannot consume each other's values. A
seeded scenario with no run identifier fails. reset_run_state() replays
a run.

Fixes intuit#62
@Bbenchaya
Bbenchaya merged commit 445a9c5 into intuit:main Nov 23, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
pypi — 4d73590b Deployed Nov 23, 2026 by Bbenchaya via Tag & Publish #54
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.

feat: reproducible placeholder resolution — injectable clock (UTC-aware) and seeded RNG

2 participants