Skip to content

fix(adr-016): pre-compute groupMembers display counts in question payload#579

Draft
let-sunny wants to merge 3 commits into
mainfrom
develop/577
Draft

fix(adr-016): pre-compute groupMembers display counts in question payload#579
let-sunny wants to merge 3 commits into
mainfrom
develop/577

Conversation

@let-sunny

Copy link
Copy Markdown
Owner

Summary

  • Adds othersCount and totalCount pre-computed fields to GotchaSurveyQuestion Zod schema and TypeScript type
  • Co-locates computation with groupMembers in the survey generator (single conditional spread), satisfying exactOptionalPropertyTypes via .optional() with .min() constraints
  • Updates SKILL.md L266–269 to substitute {others}question.othersCount and {total}question.totalCount, removing the arithmetic prose (groupMembers.length - 1, others + 1) that ADR-016 prohibits
  • Adds boundary test (2-member group: othersCount===1, totalCount===2) alongside the existing 3-member test

Closes #577

Test plan

  • TypeScript type check (tsc --noEmit) — no errors
  • Full test suite (vitest run) — 82 files, 1291 tests, all passed
  • SKILL.md arithmetic prose replaced with pre-computed field references

🤖 Generated with Claude Code

let-sunny and others added 3 commits June 10, 2026 19:18
…ayload

Add `othersCount` (= groupMembers.length - 1) and `totalCount` (=
groupMembers.length) as optional pre-computed fields on the
`missing-component:structure-repetition` question payload. Per ADR-016,
deterministic transformations must live in TypeScript, not SKILL.md prose.

- Extend `GotchaSurveyQuestionSchema` with `.min(1)/.min(2)` constraints
  mirroring the existing `groupMembers .min(2)` invariant
- Co-emit both fields with `groupMembers` in `mapToQuestion`
- Add vitest coverage confirming values and absence on non-group questions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pins the Zod .min(1)/.min(2) floor — a 2-member groupMembers array must
yield othersCount===1, totalCount===2, and pass schema validation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…unt fields

Replace arithmetic prose (groupMembers.length - 1, others + 1) with
direct field references (question.othersCount, question.totalCount)
so the LLM reads pre-computed values instead of computing them inline.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

fix(adr-016): pre-compute groupMembers display counts in question payload instead of arithmetic in SKILL.md

1 participant