@cosyte/hl7 0.0.7 → 0.0.8

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.
package/CHANGELOG.md CHANGED
@@ -605,6 +605,68 @@ kind, value)`** sets one at a field or `field[rep]` dot-path. Component values a
605
605
 
606
606
  ### Fixed
607
607
 
608
+ - **A staged RENAME bypassed the PHI scan's pre-commit route entirely
609
+ (`PHI-SCAN-RENAME-BLIND-AT-PRECOMMIT`).** `git diff --cached --raw --diff-filter=AMT` returns
610
+ neither `R` (rename) nor `C` (copy), and rename detection is on by git's default, so
611
+ `git mv <link> test/fixtures/<name>` staged as `:120000 120000 <sha> <sha> R100` with **two**
612
+ paths and the filter deleted the record outright. **Reproduced on `ae4a35f` before the fix**, in
613
+ a throwaway repo: an ordinary `git mv` put a mode-`120000` entry under a scan root and
614
+ `pnpm phi-scan --staged` printed `OK: no hits` and exited **0**. A rename that also
615
+ **substitutes a real name** into the moved file passed the same way (measured at `R098`, mode
616
+ `100644`, a real-looking surname in the staged blob). The gap is at **pre-commit**; the all-mode
617
+ sweep is the backstop, and it saw both.
618
+
619
+ **The remedy is `--no-renames`, and it needs no stride work and no scope decision.** An earlier
620
+ reading of this gap said admitting `R`/`C` required the two-path `--raw` record shape handled;
621
+ that reading was wrong, and the previous entry in this file repeated it. Turning detection off
622
+ makes the destination arrive as an ordinary single-path `A`
623
+ (`:000000 120000 0000000 <sha> A`) and the source a `D` the filter already drops. Verified under
624
+ `diff.renames=true|copies|false|1` and `diff.renameLimit=1`: every one yields the same
625
+ single-path `A`, so the two-field stride is **structural** rather than conditional on the
626
+ caller's git config, and the new enumeration **contains** the old one (pinned by
627
+ a test that compares the two path sets under each of those settings).
628
+
629
+ - **A staged COPY bypassed the same route, and no rename fixture reaches it.** With
630
+ `diff.renames=copies`, copying an out-of-scope PHI-bearing file INTO a scan root stages as a
631
+ genuine `C100` two-path record and was dropped exactly as a rename was: measured **exit 0**
632
+ before and **exit 1** after. One precondition is
633
+ recorded because it is easy to state this too broadly: config-only copy detection also needs the
634
+ COPY SOURCE modified in the same staged diff. Without that, git finds no copy source, the record
635
+ arrives as an ordinary `A` that even the old argv enumerated, and a naive copy fixture passes on
636
+ both scanners while proving nothing.
637
+
638
+ - **A scan ROOT'S OWN path was outside the `--staged` filter, on both roots.** An index entry at
639
+ exactly `test/fixtures` or exactly `src` is never a directory, because git records no entry for
640
+ one, so it is a scan root REPLACED by a blob, a link or a gitlink. The prefix test alone let that
641
+ through: measured **exit 0** over a staged mode-`120000` `test/fixtures`, and again over `src`.
642
+ The filter now matches each root's own path as well as the prefix. This is the one **addition to
643
+ the path scope** in this change, and it is stated as such rather than filed under "narrowing".
644
+ The `.ts` suffix rule is deliberately not applied to `src`'s own name: that rule is a judgement
645
+ about bytes the route could have read, and the name of an entry that replaced a walk root is no
646
+ evidence about what is on the other side of it.
647
+
648
+ - **The PHI scan reported clean over an UNMERGED path.** `U` is returned by neither `AM` nor
649
+ `AMT`, so a conflicted in-scope path made `--staged` print `OK: no hits` and exit **0** over an
650
+ index it structurally cannot read (measured, with a real-looking surname in one of the stages).
651
+ Such a path is recorded at one or more of stages 1/2/3 and never at stage 0, so `git show :<path>`
652
+ fails outright
653
+ and there is no one staged blob to scan. It is now enumerated and **refused** (exit 2), with its
654
+ own message: a `U` record's destination mode is `000000`, and the existing mode refusal's
655
+ sentence about `git show` handing back a target path is false for an unmerged regular file.
656
+ **The bound, stated precisely:** git itself refuses to commit while a path is unmerged, so this
657
+ was never a route to a committed leak. What it was is the gate attesting clean over a state it
658
+ never observed, and `pnpm phi-scan --staged` is run by hand and from scripts as well as from the
659
+ hook.
660
+
661
+ - **The PHI scan exited 1, its code for HITS FOUND, when it had not scanned anything.** A missing
662
+ or unreadable `scripts/phi-allow-list.txt` and a walk root `readdirSync` could not list both
663
+ threw out of `main` uncaught, and node reports an uncaught throw as exit **1**, with a v8 stack
664
+ trace in place of the scanner's own diagnostic. Both now refuse with exit **2** and a named
665
+ `[phi-scan]` line, and a top-level backstop catches whatever else throws so nothing can reach
666
+ node's default handler again. Nothing downstream reads the difference today (both codes are
667
+ non-zero and the gate blocks either way); a caller that ever split them would have read a scan
668
+ that never started as a scan that found PHI.
669
+
608
670
  - **The PHI scan read a symbolic link as clean on BOTH of its enumerating routes
609
671
  (`PHI-SCAN-SYMLINK-BLIND-ON-BOTH-ROUTES`).** A link under a scan root pointing at a PHI-bearing
610
672
  file passed the gate twice over. **Reproduced on `5debd18` before the fix**, in a throwaway repo,
@@ -651,14 +713,27 @@ kind, value)`** sets one at a field or `field[rep]` dot-path. Component values a
651
713
  (copy) are still not enumerated by `--staged` at all, so a staged rename that appends PHI passes
652
714
  that route; admitting them needs the two-path `--raw` record shape handled, which is a scope
653
715
  decision rather than this one. If such a record ever reached the parser the field stride would
654
- desync and it refuses, which is the safe outcome. `--staged`'s path scope is unchanged
716
+ desync and it refuses, which is the safe outcome.
717
+ **CORRECTED 2026-08-04, ON BOTH CLAUSES, and left in place rather than edited because it
718
+ shipped. Read this note before acting on the paragraph above it: the paragraph now describes a
719
+ hole that is CLOSED.** (a) `R` and `C` really were not enumerated by `--staged`, and a staged
720
+ rename into a scan root really did pass that route, but that is no longer true: the route reads
721
+ `--no-renames`, so the destination arrives as an ordinary single-path `A` and is scanned. (b)
722
+ Closing it needed neither the two-path `--raw` record shape nor a scope decision, which is what
723
+ the second clause asserted; `--no-renames` does it under every `diff.renames` and
724
+ `diff.renameLimit` setting, with the record stride untouched. A first draft of this note rebutted
725
+ only (b) and left (a) reading as a live hole under a "What this does NOT close" heading, which a
726
+ reviewer caught. See the `PHI-SCAN-RENAME-BLIND-AT-PRECOMMIT` entry at the top of this section
727
+ for the measurement.
728
+ `--staged`'s path scope is unchanged
655
729
  (`test/fixtures/**` and `src/**.ts`), and the walk's gitignore exemption is unchanged: an ignored
656
730
  link is out of scope by the same rule that already excludes an ignored file, though an entry in
657
731
  the index cannot be excused that way. That prefix is literal, so a link staged at exactly
658
732
  `test/fixtures` (the root itself, not an entry under it) is outside the `--staged` filter and is
659
733
  unchanged here; it is not both-routes-blind, because `readdirSync` resolves a symlinked walk root
660
- and all-mode reads straight through it (measured, exit 1 on the PHI). A tracked file absent from
661
- the worktree is still caught at `git add` time only. The enumerate-then-read tolerance and the
734
+ and all-mode reads straight through it (measured, exit 1 on the PHI). **(c) CLOSED 2026-08-04:
735
+ the `--staged` filter now matches each root's own path as well as the prefix, on both roots.**
736
+ A tracked file absent from the worktree is still caught at `git add` time only. The enumerate-then-read tolerance and the
662
737
  refuse-a-sweep-that-observed-nothing rule are untouched.
663
738
 
664
739
  Pinned by 19 cases in `test/scripts/phi-scan.test.ts`, **8 of them red on `5debd18`**, all against
package/dist/index.cjs CHANGED
@@ -6874,7 +6874,7 @@ async function* parseStream(source, optionsOrProfile) {
6874
6874
  }
6875
6875
 
6876
6876
  // src/index.ts
6877
- var VERSION = "0.0.7";
6877
+ var VERSION = "0.0.8";
6878
6878
 
6879
6879
  exports.ACK_CODES = ACK_CODES;
6880
6880
  exports.ACK_CONDITIONS = ACK_CONDITIONS;