[rig-sampler] Add s.date schema helper for ISO 8601 date strings#163
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[rig-sampler] Add s.date schema helper for ISO 8601 date strings#163github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Motivated by sample-run analysis (samples 36–40): sample 37 (git-author-stats) uses plain s.string for firstCommit/lastCommit date fields. A dedicated s.date helper (format:"date", validated as YYYY-MM-DD) makes the intent explicit and catches non-conforming strings before they reach repair turns. Changes: - Add s.date to the s.* helpers: string schema with format:"date" - Validate format:"date" in validateSchema with a clear YYYY-MM-DD error message - Update @file header comment to document the new helper - Add 5 unit tests in src/rig.test.ts covering serialization, acceptance, and rejection cases Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 runs (36–40)
36-subagent-delegation.tsagents:{}delegation. Schema fit was good.37-output-with-nullable.tsfirstCommit/lastCommitas plains.string. Date fields lacked a dedicated schema type; any string would pass validation even if the model returned a prose description instead of a date.38-exact-literal-output.ts138-ts-path-alias-validator.mdexceeded the 30-line code limit (37 lines) — pre-existing test failure unrelated to this PR. Core sample output was correct.39-unknown-raw-output.tss.enum("review-finding")used for a single-value discriminant field.s.literalwould be cleaner but the sample worked fine. Companion markdown also over 30 lines — pre-existing issue.40-record-output.tsrig.agent.askevents emitted — one for the inlineawait extractJson(p.bash(...))call and one for the default export invocation. Expected behaviour.Improvement:
s.dateWhat: adds
s.dateto thes.*schema helpers — aStringSchemawithformat: "date". The runtime validator checks that the value matches/^\d{4}-\d{2}-\d{2}$/and returns a clear error message (expected a date string in YYYY-MM-DD format) on mismatch.Why this run evidence supports it: sample 37 uses
s.stringforfirstCommitandlastCommitcommit-date fields. Withouts.date, a model can return any string (e.g."about 2 years ago"or"2024-03-15T00:00:00Z") and pass validation silently. Withs.date, a non-conforming value fails fast on the first turn with an actionable error, reducing the chance of a silent schema mismatch reaching the caller.Scope: additive only — no existing
s.*helpers changed, no public API removed. The serialized JSON Schema already supportsformat: "date"(standard JSON Schema vocabulary); this just exposes a convenient typed factory and wires the validator.Tests added (
src/rig.test.ts):s.dateserializes to{type:"string", format:"date"}YYYY-MM-DDstringYYYY-MM-DDhint in the error