feat(cli): run a repeatable IFC delivery check from a saved recipe

Merged
PE
3mo ago
+1372-0

Summary

Closes #3931.

  • Add ifc-lite delivery <recipe.json> [--json] [--out F] [--html F]: a repeatable, reviewable model-delivery check that packages the existing structural validation (ifc-lite validate) and IDS validation (ifc-lite ids) into one saved, versioned recipe.
  • Recipe shape: {"models": ["model.ifc"], "structural": true, "ids": ["rules.ids"]}. Every models/ids path resolves relative to the recipe file's own directory. A recipe declaring zero applicable checks is a fatal error — it can never produce a meaningful delivery verdict.
  • Every check reports pass / fail / error — never folded together. error covers an unreadable/empty/corrupt model, an unreadable or unparsable IDS file, or an IDS document declaring zero specifications; none of those count as a pass.
  • The overall verdict is pass only when every declared check on every declared model passed, so an unreadable model or an empty ruleset can never read as a successful delivery (the issue's explicit boundary).
  • The consolidated report is a flat array of checks (never keyed by model/type/source), so two checks can never collide/overwrite each other in the output — the defect class behind two shipped bugs in ifc-lite schedule. Running the same recipe twice against unchanged files produces byte-identical --json output.
  • --html <file> renders an additional standalone HTML report.
  • A committed worked example lives at packages/cli/examples/delivery/ (a passing model, a structurally-broken model, an unreadable model, and an IDS specification that fails) and is exercised by delivery-example.test.ts.

Assumptions (stated per the issue's ambiguity guidance)

  • Modeled the command on ifc-lite schedule's --spec/--save saved-definition pattern (path-resolution-relative-to-file, fatal(...) on any malformed field) and on ifc-lite gym's reuse of computeValidationIssues/IDSNamespace for running the underlying checks without a second implementation.
  • A recipe applies the same structural/ids selection to every listed model (no per-model check overrides) — the simplest reading consistent with "one documented CLI invocation."
  • An IDS document whose specifications are ALL "not applicable" (matched no entities) counts as error, not pass — nothing was actually evaluated, so a green check would rest on zero evidence.
  • Duplicate models/ids entries in a recipe are a fatal error rather than silently deduplicated.

Test plan

  • RED: wrote delivery.test.ts/delivery-example.test.ts first; failing assertions confirmed the not-yet-implemented behavior before writing delivery.ts/delivery-checks.ts/delivery-recipe.ts/delivery-report.ts.
  • Mutation testing (each confirmed to break a test): (1) silently dropping checks for an unreadable model, (2) computing the verdict from fail count only (ignoring error), (3) folding an IDS-file read failure into pass, (4) disabling the zero-checks-in-recipe fatal.
  • pnpm turbo test --filter @ifc-lite/cli: 68 test files, 774 passed, 8 skipped, 0 failed (includes 14 new delivery tests).
  • pnpm turbo typecheck --filter @ifc-lite/cli: OK.
  • node scripts/check-module-size.mjs, check-test-wiring.mjs, check-source-text-assertions.mjs: all OK.
  • Manual smoke test of the built binary against the committed example recipe: correct pass/fail/error mix, --html report renders, and two --json runs are byte-identical (diff clean).
  • docs/guide/cli.md updated with a delivery section and the generated command table refreshed (pnpm docs:generate).
  • Changeset added (.changeset/delivery-check-recipe.md), no license header.

https://claude.ai/code/session_01QPHChk3Ve9N519A4kY7436

Summary by CodeRabbit

  • New Features

    • Added the ifc-lite delivery command for repeatable structural and IDS checks across multiple IFC models.
    • Supports recipe-based configuration, consolidated JSON results, deterministic SHA-256 model fingerprints, and optional standalone HTML reports.
    • Reports pass, fail, and error outcomes, including missing or invalid model and rule files.
    • Added example delivery recipes, IFC models, and IDS requirements.
  • Documentation

    • Added CLI usage guidance, recipe format details, report behavior, and command reference information.