Skip to content

[rig-sampler] Add s.date schema helper for ISO 8601 date strings#163

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
rig-sampler/36-subagent-delegation-3e0d051f99945eea
Draft

[rig-sampler] Add s.date schema helper for ISO 8601 date strings#163
github-actions[bot] wants to merge 1 commit into
mainfrom
rig-sampler/36-subagent-delegation-3e0d051f99945eea

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Sample runs (36–40)

Sample Result Repair turns Notes
36-subagent-delegation.ts ✅ passed 0 Two-agent chain (researcher → planner) and a root orchestrator with agents:{} delegation. Schema fit was good.
37-output-with-nullable.ts ✅ passed 0 Git author stats with firstCommit/lastCommit as plain s.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.ts ✅ passed 0 Companion markdown file 138-ts-path-alias-validator.md exceeded the 30-line code limit (37 lines) — pre-existing test failure unrelated to this PR. Core sample output was correct.
39-unknown-raw-output.ts ✅ passed 0 s.enum("review-finding") used for a single-value discriminant field. s.literal would be cleaner but the sample worked fine. Companion markdown also over 30 lines — pre-existing issue.
40-record-output.ts ✅ passed 0 Two rig.agent.ask events emitted — one for the inline await extractJson(p.bash(...)) call and one for the default export invocation. Expected behaviour.

Improvement: s.date

What: adds s.date to the s.* schema helpers — a StringSchema with format: "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.string for firstCommit and lastCommit commit-date fields. Without s.date, a model can return any string (e.g. "about 2 years ago" or "2024-03-15T00:00:00Z") and pass validation silently. With s.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 supports format: "date" (standard JSON Schema vocabulary); this just exposes a convenient typed factory and wires the validator.

Tests added (src/rig.test.ts):

  • s.date serializes to {type:"string", format:"date"}
  • accepts a valid YYYY-MM-DD string
  • rejects a non-conforming string with a YYYY-MM-DD hint in the error
  • rejects a datetime string with a time component
  • usable as an object field

Generated by Daily Rig Sampler · sonnet46 100.6 AIC · ⌖ 8.47 AIC · ⊞ 5.4K ·

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>
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.

0 participants