[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-108745":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":13,"stars7d":13,"stars30d":14,"stars90d":13,"forks30d":13,"starsTrendScore":13,"compositeScore":15,"rankGlobal":9,"rankLanguage":9,"license":16,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":9,"pushedAt":21,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":13,"starSnapshotCount":13,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},108745,"witnessforge","skavuri143\u002Fwitnessforge","skavuri143","Generate the smallest test dataset that provably catches broken data-mapping rules in ETL pipelines.",null,"Python",125,65,0,62,52.5,"Apache License 2.0",false,"main",true,[],"2026-11-01 18:08:38","2026-11-21 06:54:28","# WitnessForge\n\n**Generate the smallest test dataset that provably catches broken data-mapping rules in your ETL pipeline.**\n\nWitnessForge reads a COBOL copybook and a source-to-target mapping specification, generates realistic\nfaults for every mapping rule, and builds a small set of copybook-conformant EBCDIC records\n(\"witnesses\") that detects each fault. It then reports, rule by rule, which faults your test data would\ncatch, gates your CI\u002FCD pipeline on that score, and verifies your real pipeline's output: documents,\nrejects, filters, duplicates, arrays and nested objects.\n\n```\n$ witnessforge generate examples\u002Feligibility\u002Fmember.cpy examples\u002Feligibility\u002Fmapping.yaml -o out\nWitnessForge 0.1.0: 27 witness records detect 163\u002F163 mapping faults (score 100%).\n  15 should load, 11 should be rejected, 1 should be filtered out.\n```\n\n27 synthetic records cover 17 mapping rules and 37 kinds of fault, with no production data.\n\n---\n\n## The problem\n\nTeams migrating mainframe data (fixed-width EBCDIC files described by COBOL copybooks) into modern\nstores such as JSON documents usually test their transformation jobs in one of two ways:\n\n| Approach | Problem |\n|---|---|\n| Copy of production data | Millions of records, slow CI runs, high compute cost, and real personal or health data in test environments |\n| Hand-made test files | Fast, but nobody knows whether they exercise the tricky cases |\n\nEither way, there is no **evidence of coverage**. A test suite can be green while a broken rule ships,\nbecause no test record happens to trigger it.\n\nExample: `BILLED-AMT PIC S9(7)V99 COMP-3` should become `amounts.billed = 12345.67`. A job that ignores\nthe implied decimal produces `1234567`. If every test record has an amount of zero, the broken job and\nthe correct one produce identical output, and the bug ships.\n\n## How it works\n\n1. **Parse** the copybook into a byte-level layout (text, zoned decimal, COMP-3, binary COMP, OCCURS).\n2. **Generate faults (mutants)**: for every rule, create realistic faulty versions of the pipeline.\n   Each one contains exactly one fault in exactly one rule (see the fault catalogue below).\n3. **Build candidate records** from what each rule needs: parseable and unparseable formats, validation\n   boundaries (min - 1, min, max, max + 1, lengths, item counts), pattern matches and near misses,\n   allowed and disallowed codes, blanks, sentinel values, duplicates and element layouts for arrays,\n   and values that switch conditions and filters on and off. Every candidate is valid for the copybook\n   by construction.\n4. **Execute** the reference pipeline and every fault on every candidate at the byte level. A candidate\n   *detects* a fault when the outputs differ.\n5. **Minimize** with greedy set cover: keep the fewest records that detect every detectable fault.\n6. **Report and gate**: per-rule score, undetected faults, and a non-zero exit code below your threshold.\n\nThen feed `witnesses.dat` to your real pipeline (AWS Glue, Spark, anything) and run `witnessforge verify`\non what it loaded and what it rejected.\n\n## ETL scenario coverage\n\n| Area | Scenario | How WitnessForge covers it |\n|---|---|---|\n| **Field decoding** | Text, zoned decimal, packed decimal (COMP-3), binary (COMP\u002FCOMP-4\u002FCOMP-5\u002FBINARY) | Encoder and decoder; faults: offset shift, lost implied decimal, lost sign, little-endian binary |\n| | Wrong source field, truncation | `wrong_source`, `truncate` faults |\n| **Transformations** | Trim, case, substring, padding, leading zeros | `strip` `rstrip` `lstrip` `upper` `lower` `substring` `pad` `lstrip_zeros` |\n| | Type conversion | `number` (decimal places kept), `boolean` (Y\u002FN codes) |\n| | Dates | `date` with input\u002Foutput formats and sentinel nulls (`00000000`); faults: day\u002Fmonth swap, sentinel ignored |\n| | Code lookups and defaults | `map` with default, `default` |\n| | Arithmetic | `multiply`, `divide`, `round` (for example cents to dollars) |\n| | Reformatting | `replace` (regular expression, for example phone formatting) |\n| | Null handling | `null_if_blank`; fault: blank loaded as `\"\"` instead of null |\n| | Constants and derived fields | `value:` constants, multi-field concatenation with separator |\n| | Conditional mapping | `when:` with `else:` |\n| **Validations** | Required \u002F not null | `required` |\n| | Length | `min_length`, `max_length` (boundary values tested) |\n| | Numeric range | `min`, `max` (boundaries tested at output precision, after scaling and rounding) |\n| | Format | `pattern` (matching values and near misses generated automatically) |\n| | Allowed values \u002F domain | `allowed` |\n| | Invalid input handling | `on_error: reject`; fault: invalid input silently loaded as null |\n| **Records** | Filters (which records load) | mapping-level `filter:`; faults: filter ignored or inverted |\n| | Rejects | rejected records carry reasons; `verify --rejects` checks the reject file |\n| | Missing, extra and duplicate output documents | `verify`, matched by key |\n| | Duplicate values across records | `unique` check, verified across the whole output |\n| **Arrays (OCCURS)** | Blank elements, duplicates | `drop_blank`, `distinct`; faults: blanks or duplicates kept |\n| | Element count | `min_items`, `max_items`, `required` (non-empty) |\n| | Lost or misaligned elements | faults: last element lost, only first kept, element i reads i+1 |\n| | Duplicate items | `unique_items`; verify reports duplicate, missing and extra items, and order changes |\n| **Objects** | Nested objects | dotted targets (`member.address.zip5`); verify reports missing and extra paths |\n| | Arrays of objects | `items:` builds `[{code, qualifier}, ...]` from parallel OCCURS fields; faults: members swapped, misaligned elements, blank objects kept |\n\n### Not covered by this version\n\nThese need a different kind of test than per-record mapping checks, and are on the roadmap:\n\n- **Cross-table referential integrity** (every claim's member exists in the member table)\n- **Aggregates and reconciliation** (totals and counts per batch, source-to-target control totals)\n- **Change data capture and history** (SCD type 2, incremental loads, deletes)\n- **Cross-field rules** (end date after start date), **REDEFINES**, **OCCURS DEPENDING ON**\n- **Performance and volume** testing\n\nCopybook constructs that are not supported fail loudly instead of being misread.\n\n## Install\n\n```bash\npip install witnessforge          # once published to PyPI\n# or from source\ngit clone https:\u002F\u002Fgithub.com\u002Fskavuri143\u002Fwitnessforge.git\ncd witnessforge\npip install -e \".[dev]\"\n```\n\nRequires Python 3.9+ and PyYAML.\n\n## Quick start\n\n```bash\n# 1. See which faults will be checked\nwitnessforge mutants examples\u002Feligibility\u002Fmember.cpy examples\u002Feligibility\u002Fmapping.yaml\n\n# 2. Build the witness dataset and coverage report\nwitnessforge generate examples\u002Feligibility\u002Fmember.cpy examples\u002Feligibility\u002Fmapping.yaml -o out\n\n# 3. Run your real pipeline on out\u002Fwitnesses.dat, then check what it loaded and rejected:\nwitnessforge verify examples\u002Feligibility\u002Fmember.cpy examples\u002Feligibility\u002Fmapping.yaml \\\n    --input out\u002Fwitnesses.dat --actual loaded.jsonl --rejects rejects.jsonl\n```\n\n`generate` writes:\n\n| File | Contents |\n|---|---|\n| `witnesses.dat` | Fixed-length EBCDIC records (RECFM=F), ready to land in S3 or a mainframe dataset |\n| `witnesses.jsonl` | The same records, decoded and human-readable |\n| `expected.jsonl` | The documents a correct pipeline must load |\n| `expected_rejects.jsonl` | Records a correct pipeline must reject, with the failing checks |\n| `expected_filtered.jsonl` | Records a correct pipeline must skip |\n| `report.json` \u002F `report.md` | Score per rule, undetected faults, what each record detects |\n\n`verify` output for a pipeline with five defects: a document written twice, a record loaded that should\nhave been rejected (and is missing from the reject file), array items not de-duplicated, and two\ndiagnosis objects with their qualifiers misaligned:\n\n```\nPROBLEM: duplicate output: memberId = 'M012345082' appears 2 times\nPROBLEM: record 2: memberId = 'HIJKLMN030' was loaded but should be rejected (E01:pattern, E05:pattern, E11:min, E16.qualifier:allowed)\nPROBLEM: reject file: memberId = 'HIJKLMN030' expected 1 time(s), found 0\nMISMATCH record 0 diagnoses[0].qualifier (rule E16.qualifier): expected 'AB', got 'BK'\nMISMATCH record 0 diagnoses[1].qualifier (rule E16.qualifier): expected 'BK', got 'AB'\nMISMATCH record 0 programs (rule E15): expected '3 items', got '4 items' [item count differs]\nMISMATCH record 0 programs (rule E15): expected \"'CHP' x1\", got \"'CHP' x2\" [duplicate item: appears 2 times, expected 1]\nMISMATCH memberId (rule E01): expected 'unique values', got \"'M012345082' in 2 documents\" [duplicate value across records]\nFAIL: 5 mismatches; rules involved: E01, E15, E16.qualifier\n```\n\nIt also reports missing documents, unexpected documents, filtered records that were loaded, missing or\nextra fields and objects, wrong types (`\"12\"` instead of `12`), and array items that are missing or\nout of order.\n\nExit codes: `0` pass, `1` score below threshold or verification failed, `2` invalid input.\n\n## Mapping specification\n\n```yaml\nname: member-eligibility\nkey: E01                                 # rule identifying a document (unique per witness)\nfilter: {field: REC-TYPE, equals: D}     # only these records are loaded\n\nrules:\n  - id: E01\n    source: MEMBER-ID                    # copybook field\n    target: memberId                     # dotted JSON path\n    steps: [strip]                       # transformations, in order\n    checks: [required, {pattern: '^M[0-9]{9}$'}, unique]\n\n  - id: E02                              # concatenation\n    source: [FIRST-NAME, LAST-NAME]\n    separator: \" \"\n    target: name.full\n\n  - id: E04                              # dates, sentinel nulls, reject invalid input\n    source: BIRTH-DATE\n    target: birthDate\n    steps: [{date: {in: \"%Y%m%d\", out: \"%Y-%m-%d\", nulls: [\"00000000\"]}}]\n    checks: [required]\n    on_error: reject\n\n  - id: E10                              # binary COMP cents to dollars, range\n    source: PREMIUM-CENTS\n    target: premium.monthly\n    steps: [{divide: 100}, number]\n    checks: [{min: 0}, {max: 5000}]\n\n  - id: E14                              # conditional mapping\n    source: TERM-DATE\n    target: coverage.termDate\n    when: {field: ACTIVE-FLAG, equals: N}     # also: in: [...], not_blank: true, blank: true\n    else: null\n    steps: [{date: {in: \"%Y%m%d\", out: \"%Y-%m-%d\"}}]\n\n  - id: E15                              # OCCURS -> array\n    source: PROGRAM-CODE\n    target: programs\n    steps: [strip, upper]\n    drop_blank: true\n    distinct: true\n    checks: [required, {max_items: 3}, {allowed: [CHP, MED, LTC]}]\n\n  - id: E16                              # parallel OCCURS -> array of objects\n    target: diagnoses\n    items:\n      code: {source: DIAG-CODE, steps: [strip, upper]}\n      qualifier: {source: DIAG-QUAL, steps: [strip], checks: [{allowed: [AB, BK]}]}\n    drop_blank: true\n    checks: [unique_items]\n\n  - id: E17                              # constant\n    value: MMIS\n    target: sourceSystem\n```\n\nThe complete example, with every feature, is in [`examples\u002Feligibility`](examples\u002Feligibility).\n\n### Steps\n\n| Step | Behaviour |\n|---|---|\n| `strip`, `rstrip`, `lstrip`, `upper`, `lower` | String operations |\n| `substring: {start, length}` | 1-based, like SQL `SUBSTR` |\n| `pad: {length, char, side}` | Pad to a length on the `left` or `right` |\n| `lstrip_zeros` | `000120` becomes `120`, `000` becomes `0` |\n| `null_if_blank` | Blank becomes `null` |\n| `number` | Decimal to JSON number (decimal places kept) |\n| `boolean: {true: [...], false: [...], default}` | Code to `true`\u002F`false` |\n| `date: {in, out, nulls}` | Reformat a date (`strftime` formats); blanks and `nulls` become `null` |\n| `map: {values, default}` | Code lookup |\n| `multiply: n`, `divide: n`, `round: places` | Arithmetic (put `number` last) |\n| `replace: {pattern, with}` | Regular-expression replace |\n| `default: value` | Replace `null` with a value |\n\n### Checks\n\nA record that fails any check is **rejected**; it does not load, and it appears in\n`expected_rejects.jsonl` with the failing checks.\n\n| Check | Applies to |\n|---|---|\n| `required` | Value is not blank or null (arrays: at least one item) |\n| `min_length`, `max_length` | Text length |\n| `min`, `max` | Numeric value |\n| `pattern` | Regular expression (full match) |\n| `allowed: [...]` | Domain of valid values |\n| `min_items`, `max_items`, `unique_items` | Arrays |\n| `unique` | Value is unique across all output documents (checked by `verify`) |\n\nOnly `required` fails on a null value; the others skip nulls. Use `on_error: reject` on a rule to reject\nrecords whose input cannot be transformed (for example an invalid date) instead of failing the job.\n\nMapping files are read with YAML 1.2 boolean rules, so codes such as `NO`, `YES`, `ON` and `OFF` stay text.\n\n## Fault catalogue\n\n| Area | Faults |\n|---|---|\n| Decoding | `offset_shift`, `scale_loss`, `sign_loss`, `byte_order`, `wrong_source`, `truncate` |\n| Transformations | `drop_step`, `case_flip`, `date_swap`, `date_nulls_ignored`, `map_default`, `substring_shift`, `substring_short`, `pad_side`, `boolean_invert`, `arith_swap`, `round_places`, `blank_as_empty`, `constant_null` |\n| Concatenation | `concat_separator`, `concat_order`, `concat_missing_part`, `concat_untrimmed` |\n| Conditions and filters | `condition_ignored`, `condition_negated`, `filter_ignored`, `filter_negated` |\n| Validations | `drop_check`, `bound_shift` (off by one on every boundary), `allowed_shrunk`, `error_swallowed` |\n| Arrays and objects | `array_drop_last`, `array_first_only`, `keep_blanks`, `keep_duplicates`, `index_shift`, `item_field_swap` |\n\nA fault that no valid input can expose is reported as *undetected*. It is either an equivalent mutant\n(for example, a check that can never fail given the field size) or a sign that the specification has a\ngap. Both are worth a look.\n\n## Using it in CI\u002FCD\n\n```yaml\n# GitHub Actions\n- run: pip install witnessforge\n- run: witnessforge generate mapping\u002Fmember.cpy mapping\u002Fmember.yaml -o witness --min-score 1.0\n- run: .\u002Frun-etl-job.sh witness\u002Fwitnesses.dat --out loaded.jsonl --rejects rejects.jsonl\n- run: witnessforge verify mapping\u002Fmember.cpy mapping\u002Fmember.yaml --input witness\u002Fwitnesses.dat --actual loaded.jsonl --rejects rejects.jsonl\n```\n\nThe same commands work as AWS CodePipeline \u002F CodeBuild steps.\n\n## Python API\n\n```python\nfrom witnessforge import load_copybook, load_mapping, forge, verify\n\nlayout = load_copybook(\"member.cpy\")\nmapping = load_mapping(\"mapping.yaml\", layout)\nresult = forge(layout, mapping)\n\nprint(result.score, len(result.witnesses))\nfor witness in result.witnesses:\n    witness.data        # EBCDIC bytes\n    witness.outcome     # \"loaded\", \"rejected\" or \"filtered\"\n    witness.expected    # expected document, or reject\u002Ffilter marker\n    witness.kills       # faults this record detects\n```\n\n## Roadmap\n\n- Referential integrity and control totals across files\n- Cross-field rules, REDEFINES and variable-length records\n- SMT-solver backend for witness search on complex conditional rules\n- Optional AI-proposed domain faults, filtered by a deterministic validity check\n- Glue\u002FPySpark adapter that runs `verify` directly against DocumentDB\n\n## Development\n\n```bash\npip install -e \".[dev]\"\npytest\n```\n\nContributions are welcome. Please open an issue to discuss larger changes first.\n\n## License\n\nApache License 2.0. See [LICENSE](LICENSE).\n\n## Citation\n\nIf you use WitnessForge in research, please cite it using [CITATION.cff](CITATION.cff).\n\nCopyright 2026 Srikanth Kavuri.\n","WitnessForge 是一个面向主数据迁移场景的测试数据生成工具，用于自动生成最小规模、数学可证明有效的测试数据集，以检测 ETL 管道中数据映射规则的缺陷。它解析 COBOL copybook 和源-目标映射规范，系统性地构造覆盖边界值、格式异常、编码错误、数组\u002F嵌套结构等 37 类故障的 EBCDIC 格式见证记录（witnesses），并基于集合覆盖算法最小化记录数量。输出支持 CI\u002FCD 流水线门禁与真实管道验证，全程无需生产数据。适用于金融、保险、政务等依赖大型机（mainframe）COBOL 数据迁移至现代数据平台（如 JSON、Parquet、云数仓）的质量保障场景。",2,"2026-11-24 04:35:07","CREATED_QUERY"]