[rig-sampler] feat(s): add s.null schema helper for the JSON null literal type#26
Merged
pelikhan merged 1 commit intoJul 23, 2026
Conversation
Add NullSchema type, s.null helper, InferSchema<NullSchema> → null, validateSchema null check, and test coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pelikhan
marked this pull request as ready for review
July 23, 2026 09:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sample run
Sample:
src/samples/07-summarize-many-files.tsThe agent uses
s.object({ files: s.string })as input (with ap.bash(...)prompt intent) ands.object({ summary: s.string })as output. The run completed in 1 turn with no repair loops — clean success.What the run revealed
While the sample itself ran smoothly, reading the code during analysis exposed a gap in the
s.*schema helper API: there is nos.nullhelper for the JSONnullliteral type.nullis a valid JSON value (it appears in theJsontype union), yet authors had no way to declare a null-typed output field or a nullable slot in a schema. The only workaround was to uses.unknown, which is too loose and disables validation entirely.Change
NullSchema = { type: "null"; description?: string }Schemaunion:NullSchemaadded alongside the other primitivesInferSchema:T extends { type: "null" } ? nullbranch added for correct TypeScript inferencevalidateSchema:schema.type === "null"check — accepts onlynull, rejects everything else with a clear error messages.null: helper added to the exportedsobject, callable ass.nullors.null("description"), consistent with all other primitive helperscreateTypedPrimitiveSchemaconstraint: extended to includeNullSchemaWhy this improves the harness
Without
s.null, schema authors writing agents that reset a field, clear a value, or emit an explicit "no result" were forced to uses.unknown(disabling validation) ors.optional(which models absence, not null).s.nullis a direct, self-documenting solution that slots neatly into the existings.*API surface with no breaking changes.