Skip to content

correctness: make autoFIPC itemtype-vector control flow length-safe #374

Description

@seonghobae

Finding

Protected master@f87c2324f1686135e57d8730c1b0b9420874f300 explicitly accepts itemtype with length 1 or nItems, but autoFIPC() later feeds vector comparisons into scalar control flow. Examples include:

if (itemtype == '3PL' && length(oldformBILOGprior) == 0) { ... }
...
if (itemtype == 'Rasch') {
  NewScaleParms[NewScaleParms$name == "a1", "est"] <- FALSE
  OldScaleParms[OldScaleParms$name == "a1", "est"] <- FALSE
}

R-devel documents if(cond) as requiring a length-one logical and treats longer conditions as an error; &&/|| likewise error when operands have more than one element. This means the public validation admits an nItems vector that later fails in ordinary control flow before the intended per-item mirt semantics can be honored.

Authoritative reference: R Project, base Control / Logic documentation: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Control.html and https://stat.ethz.ch/R-manual/R-patched/library/base/html/Logic.html

RED

Add a realistic regression using a 2+ item form where itemtype has exactly nItems entries. At minimum cover:

  • homogeneous vector, e.g. rep("2PL", nItems), proving the accepted vector form no longer dies at the first 3PL/control-flow predicate;
  • mixed vector containing Rasch and non-Rasch items, proving the form-wide Rasch branch does not freeze every a1 simply because one item is Rasch;
  • mixed ideal/non-ideal vector, preserving convergence checks whenever any non-ideal item requires them;
  • mixed 3PL/non-3PL behavior with BILOG-prior handling defined explicitly rather than by first-element coercion.

Do not weaken the current input-length validation and do not replace the defect with itemtype[1].

Repair acceptance

Use explicit form-wide/per-item predicates whose semantics are testable (all(...), any(...), or a named helper) instead of passing a vector into if, &&, or ||. Preserve mirt::mod2values() item-level structural est flags for mixed item types; any additional global override must only apply when its invariant is truly form-wide. Add regression coverage before changing production code, then require exact-head R CMD check / owned tests / security gates and independent review.

No force rewrite, no warning suppression, no test fixture that reduces itemtype back to length 1.

@jules Please take this as a bounded TDD correctness repair from current protected master. Keep #349 and other active PR semantics separate; do not copy their unrelated deltas into this branch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions