@biffo/cli 0.316.2 → 0.316.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -351,6 +351,39 @@ def load_baseline(baseline: Path) -> dict | None:
351
351
  return json.loads(baseline.read_text())
352
352
 
353
353
 
354
+ def _legacy_key(k: str) -> str:
355
+ """A v2 `path:line:kind:label` key rendered in v1 `path:kind:label` form.
356
+
357
+ Migration shim for #2037: the trusted script that computes `keys` is
358
+ always fetched from the default branch, but `--baseline` is read from the
359
+ checkout under test, so a PR that changes `Branch.key()`'s shape (#2026,
360
+ #2031) is comparing keys the trusted script emits in the OLD format
361
+ against a baseline it wrote in the NEW format — every baselined branch
362
+ then reads NEW and the gate deadlocks structurally, not on anything wrong
363
+ in the PR's diff. Normalising each already-baselined key to its v1 form
364
+ lets a v1-computing script recognise a v2-shaped baseline entry.
365
+
366
+ `split(":", 2)` rather than a regex: `label` legitimately contains colons
367
+ (a bare handler's label is `except:`) while `kind` is never numeric and a
368
+ repo-relative `path` carries no colon, so "is the second field all
369
+ digits" is an unambiguous discriminator between the two shapes. A v1 key
370
+ is returned unchanged (its second field is `except`/`fallback`, never a
371
+ digit), so this is a no-op for every baseline still in v1 form.
372
+
373
+ Retire this — and the union in `main()` that calls it — in Milestone 3 of
374
+ #2037, once every inheriting repo's baseline has been regenerated as v2.
375
+ Kept only for the duration of that migration: while it is in effect, a
376
+ genuinely new v2 branch that collides on `path:kind:label` with an
377
+ already-baselined branch at a different line is absorbed as "known"
378
+ rather than flagged — reintroducing #2026's collision bug for exactly as
379
+ long as this shim lives.
380
+ """
381
+ parts = k.split(":", 2)
382
+ if len(parts) == 3 and parts[1].isdigit():
383
+ return f"{parts[0]}:{parts[2]}"
384
+ return k
385
+
386
+
354
387
  def main() -> int:
355
388
  parser = argparse.ArgumentParser(description=__doc__)
356
389
  parser.add_argument("--write", action="store_true", help="record the current set as baseline")
@@ -481,7 +514,15 @@ def main() -> int:
481
514
  print(f"unexecuted error branches: {len(keys)} (no baseline yet; {coverage_note})")
482
515
  return 0
483
516
 
484
- known = set(baseline.get("branches", []))
517
+ # `keys` (above) comes from THIS script, always fetched from the trusted
518
+ # default branch. `recorded` comes from --baseline, read from the
519
+ # checkout under test — which may already be in the newer key format
520
+ # this script does not compute yet. Widen membership with each
521
+ # baselined key's legacy-normalised form so a v1-computing script still
522
+ # recognises a v2-shaped baseline entry (#2037 migration shim; see
523
+ # `_legacy_key`). `keys` itself is left untouched.
524
+ recorded = set(baseline.get("branches", []))
525
+ known = recorded | {_legacy_key(k) for k in recorded}
485
526
  new = [k for k in keys if k not in known]
486
527
 
487
528
  print(
@@ -351,6 +351,39 @@ def load_baseline(baseline: Path) -> dict | None:
351
351
  return json.loads(baseline.read_text())
352
352
 
353
353
 
354
+ def _legacy_key(k: str) -> str:
355
+ """A v2 `path:line:kind:label` key rendered in v1 `path:kind:label` form.
356
+
357
+ Migration shim for #2037: the trusted script that computes `keys` is
358
+ always fetched from the default branch, but `--baseline` is read from the
359
+ checkout under test, so a PR that changes `Branch.key()`'s shape (#2026,
360
+ #2031) is comparing keys the trusted script emits in the OLD format
361
+ against a baseline it wrote in the NEW format — every baselined branch
362
+ then reads NEW and the gate deadlocks structurally, not on anything wrong
363
+ in the PR's diff. Normalising each already-baselined key to its v1 form
364
+ lets a v1-computing script recognise a v2-shaped baseline entry.
365
+
366
+ `split(":", 2)` rather than a regex: `label` legitimately contains colons
367
+ (a bare handler's label is `except:`) while `kind` is never numeric and a
368
+ repo-relative `path` carries no colon, so "is the second field all
369
+ digits" is an unambiguous discriminator between the two shapes. A v1 key
370
+ is returned unchanged (its second field is `except`/`fallback`, never a
371
+ digit), so this is a no-op for every baseline still in v1 form.
372
+
373
+ Retire this — and the union in `main()` that calls it — in Milestone 3 of
374
+ #2037, once every inheriting repo's baseline has been regenerated as v2.
375
+ Kept only for the duration of that migration: while it is in effect, a
376
+ genuinely new v2 branch that collides on `path:kind:label` with an
377
+ already-baselined branch at a different line is absorbed as "known"
378
+ rather than flagged — reintroducing #2026's collision bug for exactly as
379
+ long as this shim lives.
380
+ """
381
+ parts = k.split(":", 2)
382
+ if len(parts) == 3 and parts[1].isdigit():
383
+ return f"{parts[0]}:{parts[2]}"
384
+ return k
385
+
386
+
354
387
  def main() -> int:
355
388
  parser = argparse.ArgumentParser(description=__doc__)
356
389
  parser.add_argument("--write", action="store_true", help="record the current set as baseline")
@@ -481,7 +514,15 @@ def main() -> int:
481
514
  print(f"unexecuted error branches: {len(keys)} (no baseline yet; {coverage_note})")
482
515
  return 0
483
516
 
484
- known = set(baseline.get("branches", []))
517
+ # `keys` (above) comes from THIS script, always fetched from the trusted
518
+ # default branch. `recorded` comes from --baseline, read from the
519
+ # checkout under test — which may already be in the newer key format
520
+ # this script does not compute yet. Widen membership with each
521
+ # baselined key's legacy-normalised form so a v1-computing script still
522
+ # recognises a v2-shaped baseline entry (#2037 migration shim; see
523
+ # `_legacy_key`). `keys` itself is left untouched.
524
+ recorded = set(baseline.get("branches", []))
525
+ known = recorded | {_legacy_key(k) for k in recorded}
485
526
  new = [k for k in keys if k not in known]
486
527
 
487
528
  print(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.316.2",
3
+ "version": "0.316.3",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",