Skip to content

Scope legacy variable selection by databaseStart (0.5.0 release review) - #65

Merged
DougManuel merged 1 commit into
devfrom
v05-db-scoping
Sep 27, 2026
Merged

DougManuel merged 1 commit into
devfrom
v05-db-scoping

Conversation

@DougManuel

Copy link
Copy Markdown
Collaborator

Summary

A second external review of the release candidate (f8d012a) found a regression in #64's formula guard, and it was reproduced here. A formula variable listed only for another database stopped generation for the requested database on the legacy path. The survival guard from #61 had the same flaw.

Root cause, wider than the guards: the legacy path chose variables from detail rows alone and ignored variable-level databaseStart, which the v0.4 adapter honours. A variable listed only for other was generated for study as random values, in every detail layout tested: no databaseStart in the details, shared detail rows, and other-only detail rows.

Fix: the legacy path filters enabled variables by variable-level databaseStart with the adapter's matcher (.filter_recodeflow_by_database(), empty means all databases) before the guards run.

The review suggested scoping only the guards' candidates. That would remove the false stop, but it would leave the legacy path generating the other database's formula variable as random values, the silent-wrong output the guard exists to prevent. So this fixes the selection instead.

This also reverses a ruling I made during #61's final review ("the D10 guard checks role-filtered rows, not databaseStart-filtered; stands"). The reproduction shows it could not stand.

Tests

the legacy path generates only variables that belong to the requested database covers:

  • a plain variable, a formula variable and a survival variable listed only for other
  • shared and other-only detail rows

It was RED before the fix: the plain variable was generated, and the formula guard stopped the run.

Verification (local, R 4.4.2)

  • Full suite: FAIL 0 | ERROR 0 | WARN 35 | SKIP 3 | PASS 954. No existing legacy test relied on the old cross-database behaviour.
  • The migration vignette, which exercises the legacy path most, renders.
  • NEWS: a Breaking changes entry for the legacy-path change.

One pre-existing limitation seen while testing, not changed here: when variables has a databaseStart column and variable_details does not, the v0.4 adapter stops with "databaseStart filtering was requested, but metadata has no 'databaseStart' column".

After this merges into dev, release PR #63 picks it up; rerun its checks before merging and tagging.

🤖 Generated with Claude Code

Found in a second release review of 0.5.0. The legacy path chose which
variables to generate from detail rows alone and ignored variable-level
databaseStart, which the v0.4 adapter honours. So a formula or survival
variable listed only for another database made the new guards stop
generation for the requested one, and a plain variable listed only for
another database was generated as random values, in every detail layout
tested (no detail databaseStart, shared rows, other-only rows).

The legacy path now filters enabled variables by variable-level
databaseStart with the adapter's matcher and empty-means-all rule, before
the guards run. Scoping only the guards' candidates would have removed the
false stop but left the legacy path generating another database's formula
variable as random values. This also corrects an earlier ruling that the
survival guard's lack of databaseStart scoping could stand.
Copilot AI lite review requested due to automatic review settings September 27, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@DougManuel
DougManuel merged commit b6e2189 into dev Sep 27, 2026
1 check passed
@DougManuel DougManuel mentioned this pull request Sep 27, 2026
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.

2 participants