# CRM: requirements coverage check

Fixtures are fictional and use example.test addresses. This is not a client case or evidence of a commercial result.

## Actually tested

Five fixed requirements and 25 required fields: initially 22 fields are populated, with three empty fields in three different requirements. After completion, 25 of 25 are present. A four-requirement control is rejected even though all its own fields are populated.

## Editable contract

- Rule owner: [name].
- Input version and expected scope: [values].
- Allowed fields, mappings and exceptions: [rules].
- Expected outcome for each case: [examples].
- Repeat-check and evidence retention procedure: [steps].

## Function and independent reproduction

Download both inventory JSON files for this locale. Save them beside model.mjs, copy the function and test code below into model.mjs, and run node model.mjs with Node.js. JSON and Markdown do not execute checks on their own.

```js
function checkRequirements(rows,expectedKeys) {
  const fields=['owner','role','input','output','acceptance'],findings=[],keys=rows.map(r=>r.key),missing=expectedKeys.filter(k=>!keys.includes(k)),unexpected=keys.filter(k=>!expectedKeys.includes(k)),duplicates=[...new Set(keys.filter((k,i)=>keys.indexOf(k)!==i))];
  let filled=0;
  for(const row of rows)for(const field of fields) {
    const present=typeof row[field]==='string'&&row[field].trim().length>0;
    if(present&&expectedKeys.includes(row.key))filled++;
    if(!present)findings.push({requirement:row.key,field,code:'required-field-empty'});
  }
  const scopeComplete=missing.length===0&&unexpected.length===0&&duplicates.length===0&&rows.length===expectedKeys.length;
  return {accepted:scopeComplete&&findings.length===0,scopeComplete,expectedRequirements:expectedKeys.length,observedRequirements:rows.length,missing,unexpected,duplicates,expectedFields:expectedKeys.length*fields.length,filledFields:filled,findings,scope:'Field-presence and exact-key-set contract only; not semantic quality, feasibility, security or completeness of business requirements.'};
}

import fs from 'node:fs';
import assert from 'node:assert/strict';
const before = JSON.parse(fs.readFileSync('en-before-inventory.json', 'utf8'));
const after = JSON.parse(fs.readFileSync('en-after-inventory.json', 'utf8'));
assert.equal(checkRequirements(before.requirements, before.expectedKeys).findings.length, 3);
assert.equal(checkRequirements(after.requirements, after.expectedKeys).accepted, true);
assert.equal(checkRequirements(after.requirements.slice(0, 4), after.expectedKeys).accepted, false);
console.log('PASS');
```

## Files

- [before inventory](https://evolkov.tech/wp-content/uploads/reproleaf-guides/crm-requirements-20261117/en-before-inventory.json)
- [before report](https://evolkov.tech/wp-content/uploads/reproleaf-guides/crm-requirements-20261117/en-before-report.json)
- [after inventory](https://evolkov.tech/wp-content/uploads/reproleaf-guides/crm-requirements-20261117/en-after-inventory.json)
- [after report](https://evolkov.tech/wp-content/uploads/reproleaf-guides/crm-requirements-20261117/en-after-report.json)

Screenshots show an owned local worksheet or form with actual results. This is not the Reproleaf interface. Example data does not establish production CRM readiness, specification quality, security, legal compliance or the absence of all defects.
