Skip to content

wizard: drop generated questions whose name collides with a demographic (#47) - #49

Merged
jstet merged 1 commit into
mainfrom
issue-47-dedup-demographics
Sep 25, 2026
Merged

jstet merged 1 commit into
mainfrom
issue-47-dedup-demographics

Conversation

@jstet

@jstet jstet commented Sep 25, 2026

Copy link
Copy Markdown
Member

Follow-up to #48: the survey-view fix moved the divider into the right place, but the underlying duplicate was still in the workbook.

Why duplicates happened. The model is told demographicsAddedSeparately: 'age, ...' but still occasionally writes a birth-date question and names it age (the natural word). assembleSurvey then appends the qwac age alongside it; sanitizeSurvey dedupes by variable name, turning the duplicate into age2 — but the labels stay identical, so the user sees two "Wann sind Sie geboren?" rows under the same divider family.

Fix. Filter generated questions against the demographic name set inside evaluate(), so the first generation and the repair loop both go through it. The qwac demographic is the canonical version and stays appended by assembleSurvey; the generated duplicate is dropped before the survey is built. Cheap Set lookup; only kicks in when the model misbehaves.

  • New helper dedupAgainstDemographics exported from lead.ts for testing.
  • New tests in lead.test.ts: end-to-end (model returns a question named age alongside the demographic — exactly the reported case), plus three unit cases for the helper.

The follow-up commit on this branch strengthens the prompt so the model is less likely to do this in the first place (separate PR).

Verified: npm run test:unit (90 pass, +3), npm run test:e2e (45 pass), npm run check, npm run lint.

Closes #47.

…ic (#47)

The model is told `demographicsAddedSeparately: 'age, ...'` but still
occasionally writes a birth-date / age / sex question and names it the
same as a demographic. assembleSurvey then appends the qwac copy,
sanitizeSurvey renames the duplicate (e.g. 'age' -> 'age2'), and the
user ends up with two 'Wann sind Sie geboren?' rows under the same
name family.

Filter generated questions against the demographic name set inside
`evaluate()` so both the first generation and the repair loop go
through it. The qwac demographic is the canonical version and stays
appended by assembleSurvey; the generated duplicate is dropped before
the survey is built.

New helper `dedupAgainstDemographics` exported for testing; new tests
in lead.test.ts cover the end-to-end path (model returns a question
named 'age' alongside the demographic) and the unit cases for the
helper.
@jstet
jstet force-pushed the issue-47-dedup-demographics branch from 8e633eb to 33b00ef Compare September 25, 2026 12:54
@jstet
jstet merged commit 6fe1c59 into main Sep 25, 2026
1 check passed
@jstet
jstet deleted the issue-47-dedup-demographics branch September 25, 2026 12:56
jstet added a commit that referenced this pull request Sep 25, 2026
… (#50)

Defensive follow-up to #49: the dedup strips generated questions that
land on a demographic's name, but the prompt only told the model to
avoid the topic. Add an explicit 'don't reuse the names either' clause
with the concrete failure mode (sanitize would leave 'age' + 'age2'
both with the German birth-date label) and a couple of rename hints
('birthyear', 'age_group', 'years_active').

The dedup stays as the safety net — the prompt nudges, the code
guarantees.
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.

generated questions ended up in automatically added section

1 participant