|
20 | 20 | via CURIE form, and definitions whose genus disagrees with the asserted parent |
21 | 21 | (DEF-FORM; the hierarchy/label/definition compatibility principle, #64/#377). |
22 | 22 |
|
23 | | -Baseline ratchet: ``--write-baseline PATH`` records the currently-accepted findings; |
| 23 | +Baseline ratchet: ``--baseline PATH --write-baseline`` records the currently-accepted findings; |
24 | 24 | a later run with ``--baseline PATH`` fails only on findings BEYOND that floor, so a |
25 | 25 | large existing-debt audit can gate new additions without first paying down the debt. |
26 | 26 | Regenerate the baseline as debt is fixed -- the count can only go down. |
@@ -316,21 +316,25 @@ def check_definition_form(rid, typ, definition, parent_cell, mode): |
316 | 316 | ] |
317 | 317 | genus = m.group(1).strip() |
318 | 318 | glow = genus.lower() |
| 319 | + # CURIE-form parents (e.g. METPO:1000000) are governed by PARENT/HOUSE-STYLE; |
| 320 | + # the genus is compared only against LABEL-form parents (the sheet convention), |
| 321 | + # so a CURIE parent does not trigger a spurious DEF-FORM mismatch. |
| 322 | + label_parents = [p for p in parents if not re.match(r"^[A-Za-z][\w.]*:\S", p)] |
319 | 323 | # Accept the parent label itself, or the parent label qualified as a head noun |
320 | 324 | # ("a <parent> phenotype/preference in which ..."). For adjectival parents (e.g. |
321 | 325 | # 'halophilic', 'anaerobic') the natural genus is "<parent> phenotype", which is |
322 | 326 | # still hierarchy/label/definition compatible. |
323 | 327 | _heads = ("phenotype", "preference", "quality") |
324 | 328 | genus_ok = any( |
325 | | - glow == p.lower() or glow in {f"{p.lower()} {h}" for h in _heads} for p in parents |
| 329 | + glow == p.lower() or glow in {f"{p.lower()} {h}" for h in _heads} for p in label_parents |
326 | 330 | ) |
327 | | - if parents and not genus_ok: |
| 331 | + if label_parents and not genus_ok: |
328 | 332 | return [ |
329 | 333 | Finding( |
330 | 334 | sev, |
331 | 335 | "DEF-FORM", |
332 | 336 | rid, |
333 | | - f"definition genus '{genus}' does not match asserted parent(s) {parents} " |
| 337 | + f"definition genus '{genus}' does not match asserted parent(s) {label_parents} " |
334 | 338 | "(hierarchy/label/definition must be compatible)", |
335 | 339 | ) |
336 | 340 | ] |
@@ -537,13 +541,15 @@ def _fp(f): |
537 | 541 | if write_baseline: |
538 | 542 | if not baseline: |
539 | 543 | raise click.UsageError("--write-baseline requires --baseline PATH") |
540 | | - Path(baseline).write_text(json.dumps(sorted({_fp(f) for f in findings}), indent=1) + "\n") |
| 544 | + Path(baseline).write_text( |
| 545 | + json.dumps(sorted({_fp(f) for f in findings}), indent=1) + "\n", encoding="utf-8" |
| 546 | + ) |
541 | 547 | click.echo(f"# wrote baseline: {baseline} ({len(findings)} findings recorded)") |
542 | 548 | raise SystemExit(0) |
543 | 549 |
|
544 | 550 | baseline_set = set() |
545 | 551 | if baseline and Path(baseline).exists(): |
546 | | - baseline_set = set(json.loads(Path(baseline).read_text())) |
| 552 | + baseline_set = set(json.loads(Path(baseline).read_text(encoding="utf-8"))) |
547 | 553 | new_findings = [f for f in findings if _fp(f) not in baseline_set] |
548 | 554 | baselined = len(findings) - len(new_findings) |
549 | 555 | # When a baseline is in play, only findings beyond it count toward pass/fail. |
|
0 commit comments