Skip to content

[rig-sampler] Add type: "string" to all-string enum schemas#30

Merged
pelikhan merged 1 commit into
mainfrom
rig-sampler/10-triage-pr-b8876a773f1d7652
Jul 23, 2026
Merged

[rig-sampler] Add type: "string" to all-string enum schemas#30
pelikhan merged 1 commit into
mainfrom
rig-sampler/10-triage-pr-b8876a773f1d7652

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Sample run: 10-triage-pr.ts

Sample executed: src/samples/10-triage-pr.ts — classifies a GitHub issue and suggests labels using s.enum for both kind and priority fields.

Run result: ✅ Succeeded in 1 turn (no repair loops). The stub produced valid output matching the schema.

Observation from the run output:

The generated <output_schema> block emitted by the harness for s.enum("bug", "feature", "question", "chore") was:

{"enum": ["bug", "feature", "question", "chore"]}

This is valid JSON Schema, but omits the type constraint. JSON Schema best-practice (and many LLM prompt guides) recommend including "type": "string" alongside enum when all values are strings — it gives the model a clearer, redundant signal to produce a string and helps schema validators surface type mismatches before value mismatches.

Change

In serializeSchema, when an EnumSchema's values are all strings, the serialized output now includes "type": "string":

{"type": "string", "enum": ["bug", "feature", "question", "chore"]}

Mixed-type or non-string enums (e.g. s.enum(1, 2, 3)) continue to emit only {"enum": [...]}.

Tests

  • Updated the existing "converts enum schemas" test to expect the new type: "string" field.
  • Added a new "adds type:string to all-string enums but not mixed enums" test covering string-only, number-only, mixed, and empty enum cases.

All 129 tests pass.

Generated by Daily Rig Sampler · 35.9 AIC · ⌖ 8.08 AIC · ⊞ 5.2K ·

When all enum values are strings, include "type": "string" alongside the
"enum" array in the serialized JSON Schema. This gives LLMs a stronger
type constraint and follows JSON Schema best-practice (RFC 3986 §6.1.2).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review July 23, 2026 10:49
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@pelikhan
pelikhan merged commit 75f579f into main Jul 23, 2026
4 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd — changes are well-tested and the implementation is correct.

📋 Highlights

Positive Highlights

  • ✅ New test covers all four meaningful cases: all-string, all-number, mixed, and empty enum
  • ✅ Empty-enum edge case correctly skips type: "string" (via enumValues.length > 0 guard)
  • ✅ Existing test updated to match new expected output — no silent drift
  • ✅ Minimal, surgical change; unrelated code is untouched

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 14.4 AIC · ⌖ 3.94 AIC · ⊞ 6.3K
Comment /matt to run again

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant