cloverleaf-larry/lib
Bryan Johnson b9415f3b57 v0.3.3: PHI sanitize/desanitize + {{phi:...}} prompt preprocessing
Bryan's ask: use Larry on prod data without PHI ever leaving the client box.

Added:
  lib/hl7-sanitize.sh       — tokenize PHI fields in HL7 messages
  lib/hl7-desanitize.sh     — reverse op (local view-time unmask)

Tokenization model:
  - Replace PHI fields with [[CATEGORY_NNNN]] tokens (MRN, NAME, DOB,
    ADDR, PHONE, ACCT, SSN, PROV, VISIT, etc.)
  - Same value → same token across messages (deterministic via local
    lookup table; analysis can still correlate patients).
  - Lookup table at $LARRY_HOME/sanitize/lookup.tsv mode 0600 — never
    leaves the client.
  - Default PHI rule set covers PID, PV1, NK1, GT1, IN1, OBR, OBX,
    DG1, ORC; --rules-file to extend.
  - --strict also tokenizes unknown Z segments wholesale.

Prompt-side preprocessing in larry.sh:
  - {{phi:VALUE}}             inline marker, auto-category lookup
  - {{phi:CATEGORY:VALUE}}    explicit category
  - Replaced with the token BEFORE the user input enters conversation
    history. The original never reaches the API.
  - Local feedback "phi> {{phi:...}} → [[TOKEN]]" printed to terminal only.

New REPL slash commands:
  /phi <value>        tokenize a single value, print the token
  /unmask <token>     show original (local terminal only, never API)
  /tokens             show full PHI ↔ token lookup table

New tools in larry.sh schema:
  hl7_sanitize        agent can sanitize a file before reading PHI
  tokenize-value / detokenize-value (subcommands of hl7-sanitize.sh)

Persona update (agents/larry.md):
  - Documented PHI mode and rules for proactive sanitize-first behavior

MANUAL.md updated with the full PHI section including limitations.

Brings total native tools to 29.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 10:29:20 -07:00
..
hl7-desanitize.sh v0.3.3: PHI sanitize/desanitize + {{phi:...}} prompt preprocessing 2026-05-26 10:29:20 -07:00
hl7-diff.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
hl7-field.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
hl7-sanitize.sh v0.3.3: PHI sanitize/desanitize + {{phi:...}} prompt preprocessing 2026-05-26 10:29:20 -07:00
journal.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
lessons.sh v0.3.2: lesson capture (local-first learning loop) 2026-05-26 10:00:37 -07:00
nc-diff-interface.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-document.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-find.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-inbound.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-insert-protocol.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-make-jump.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-msgs.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-parse.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
nc-regression.sh v0.3.0: initial release of Larry-Anywhere 2026-05-26 09:46:20 -07:00
oauth.sh v0.3.1: OAuth subscription auth + offline manual cheat sheet 2026-05-26 09:57:44 -07:00