Skip to content

freerange: assert user-facing option ranges - #2187

Draft
u9g wants to merge 3 commits into
mainfrom
jason/freerange
Draft

freerange: assert user-facing option ranges#2187
u9g wants to merge 3 commits into
mainfrom
jason/freerange

Conversation

@u9g

@u9g u9g commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Adds @chenglou/freerange and encodes the ranges of user-supplied numeric options as leading console.assert contracts, so out-of-range values are caught at compile time (pnpm fr) and reported at runtime.

All contracts live in agents/src/option_ranges.ts, one function per distinct range, named after its bounds and documenting which options carry it. Covered so far: inference/{vad,stt,llm}.ts, inference/interruption, inference/eot, voice/agent_session.ts, voice/turn_config/utils.ts, voice/background_audio.ts, worker.ts. pnpm fr reports 0 findings; pnpm fr:audit prints requirements like requires: modelOptions.max_delay >= 0.7.

Two freerange constraints shape the file: requirements propagate only within a file, so the aggregators sit next to the helpers they call (call sites are constructors and methods, which freerange does not analyze wherever the contract lives), and a leading assert may only compare a parameter to a fixed number, so bounds are literals rather than parameters.

tsconfig.json drops the deprecated baseUrl (the TS 6 freerange bundles errors on it) and makes paths relative, which resolves identically.

Draft: inference/tts.ts, transcription/synchronizer.ts, ipc/supervised_proc.ts and the plugins with documented ranges are still to come.

Add @chenglou/freerange and encode the ranges of user-supplied numeric
options as leading `console.assert` contracts. Contracts must be per-file
functions with literal bounds: freerange does not follow imported bodies,
and a leading assert may only compare a parameter to a fixed number.

Drop `baseUrl` (deprecated in the TS 6 that freerange bundles) and make
`paths` relative, which resolves identically.
@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8672625

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

u9g added 2 commits July 31, 2026 08:32
Contracts propagate within a file, and the call sites are constructors and
methods that freerange does not analyze wherever the contract lives, so one
module can hold them all and share the domain helpers across providers.

Add `pnpm fr` / `pnpm fr:audit`.
Three ranges had two names each: 0..1 (checkedProbability, checkedEotThreshold),
>= 0 (checkedDuration, checkedWeight) and 0.5..0.9 (checkedTurnStartThreshold,
checkedFluxEotThreshold). Naming each contract after its bounds makes a
duplicate impossible to add without noticing; each one lists the options that
carry it.
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.

1 participant