Skip to content

Retry reports after privacy-review outages and retire stale model output - #1700

Merged
elkimek merged 4 commits into
elkimek:mainfrom
bhargavmehta01:fix/auto-import-outage-retry
Nov 2, 2026
Merged

elkimek merged 4 commits into
elkimek:mainfrom
bhargavmehta01:fix/auto-import-outage-retry

Conversation

@bhargavmehta01

@bhargavmehta01 bhargavmehta01 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

A report cancelled after an unavailable privacy review must remain eligible for a later auto-import feed check. Previously, the batch outcome was skipped, so the feed permanently remembered the report as handled.

Batch review now opts into a distinct unavailable result for review-loading failure or cancellation after an unrecovered local-model failure. Cancellation while a configured local privacy model is unreachable also reports failure. Ordinary cancellation still skips deliberately; a successful stream retry or an explicit Regex replacement clears the failed-stream state. Other review callers keep their existing cancellation contract.

The review controller also retires every callback from replaced, stopped, completed, or closed attempts, including queued animation frames, text, thinking, completion, and error callbacks. A delayed model response can no longer overwrite a selected Regex result or a newer retry. Integration with current main preserves report-local aliases, clinical text, scroll synchronization, and the finalized privacy payload used by Send.

Validation on Node 24 / TypeScript 7:

  • 229 focused tests passed across privacy redaction, review presentation/styles/scroll, batch privacy outcomes, auto-import runtime, and import-file dispatch.
  • 15 Chromium tests passed across privacy review and PDF import, including the controlled queued-frame regression.
  • Strict application and test type checks, Svelte checks, all 17 quality guardrails, architecture generation/checks, DOM sink audit, and the production build passed.
  • Batch/feed integration tests verify failure stays retryable, a later deliberate skip becomes handled, and a third feed check does not offer the handled report.

The fixtures are synthetic and deterministic. They verify application lifecycle and bookkeeping rather than a particular local model's extraction accuracy. Exhaustive browser and combined-coverage matrices remain owned by GitHub Actions; no assertions, safety settings, or budgets were relaxed.

Contracts and the generated module map are updated. Public documentation companion: elkimek/getbased-docs#27 (draft until this application change is merged).

Fresh CI on 894a618f: Tests workflow passed, including 3,322 affected unit tests in 139 suites, selected legacy checks, 110 shipping Chromium tests across four shards, and the final test gate. CodeQL and sync scope checks passed. Greptile reviewed this exact commit with 5/5 confidence and no actionable findings; all review threads are resolved.

CI used the repository's affected-test policy. The optional full-regression, real-model, combined-coverage, and separate performance lanes were not requested; the shipping resource-budget checks did run and pass.

A report whose privacy review could not run, or was cancelled after the
local privacy model failed (or while a configured model is unreachable),
was recorded as an explicit skip, so the auto-import source never offered
it again. Report it as failed instead so it is retried on a later check.
Other review callers are unchanged: the new result is opt-in.
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues remain.

Summary

Keeps auto-imported reports eligible for retry when privacy review is unavailable.

  • Unavailable privacy reviews leave auto-imported reports ready for another check.
  • Stopped or replaced privacy streams no longer change the open review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Batch privacy review] --> B{Review outcome}
  B -->|Unavailable| C[Report failed]
  C --> D[Offer report on a later feed check]
  B -->|Deliberate cancel| E[Report skipped]
  E --> F[Mark report handled]
  B -->|Approved text| G[Analyze and preview report]
Loading

Reviews (4) · Last reviewed commit: "Merge main and harden privacy-outage ret..." · Reviewed by Greptile

Comment thread js/pii-review.ts Resolved
Comment thread tests/pii-review-presentation.test.ts Resolved
bhargavmehta01 and others added 2 commits October 31, 2026 08:36
A stream aborted for the regex fallback could reject later with a plain
Error (the reachability probe rewraps the abort), which marked the local
model as failed again and turned an explicit cancel into a retry. Ignore
results from a stream that was aborted or replaced.

Add tests through the real handleBatchPDFs path: an unavailable review and
a cancel while the configured local model is unreachable report 'failed';
ordinary cancels report 'skipped'.
@bhargavmehta01

Copy link
Copy Markdown
Contributor Author

Both review points are fixed (acbb68b), and I merged the latest main so the branch is up to date (45bb384). CI is green on the new head. @elkimek could you take another look and approve when you get a chance? Thanks!

@elkimek

elkimek commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Hey, thanks, will look into this later but I don't have the issue at least with my Czech lab reports so it might be language problem.

@elkimek elkimek changed the title Retry auto-imported reports when the local privacy model is unavailable Retry reports after privacy-review outages and retire stale model output Nov 2, 2026
@elkimek
elkimek merged commit 9c2d29c into elkimek:main Nov 2, 2026
23 checks passed
@elkimek

elkimek commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution!

elkimek added a commit that referenced this pull request Nov 3, 2026
#1711)

* Keep every dated medication course visible in supplement AI context

The supplements section of the AI context capped compact mode at 12
products (24 in detail), ranked active records first, and summarised the
rest as an unnamed '+N more therapy records' line: the 'Other stored
therapy records' list was diffed against the pre-cap set, so it was empty
whenever the inventory itself was the input. A medication stopped before
the latest blood draw lost to any current supplement, and the model
received neither its name nor its dates. Users who log each dose change as
a separate record (common for titrated medications) lose exactly the
course that explains their lab history, and the model then fills the gap
with invented dates.

- Fill the character budget instead of a fixed product cap (cap kept as a
  safety net: 40 compact / 60 detail).
- Rank records named in the question first, then medications before
  supplements; within each, current before lab-range overlapping before
  unrelated.
- List every record without full detail by name, type, status and date
  ranges.
- Match named records case/diacritic-insensitively with a leading-word
  stem, including genericName and brand, so inflected mentions open
  detail mode; add folded Slovak/Czech therapy vocabulary.
- Add a completeness rule: never fill a therapy timeline gap by assumption.
- Report 'N of M records detailed' in the chat context receipt.

Fixes #1710

* Keep report privacy replacements consistent and synchronize review panes (#1699)

* Make privacy redaction consistent and sync the review panes

Regex redaction before the analysis model now uses keyed, deterministic
replacements (HMAC-SHA256 with a random per-profile key), so a value maps
to the same replacement on every page and in every report of a profile:

- Patient names are removed ([PATIENT]) in every written form ("Last,
  First", "First M Last", upper case), detected from labels, header
  layouts before DOB, and the profile name when it is a full name.
- Dates of birth keep the real year; only month/day are replaced, the
  same way everywhere (including the profile DOB in any format). Age is
  left unchanged so age-based analysis stays correct.
- IDs are format-preserving; physicians, addresses, cities/ZIPs, phones
  and emails get neutral keyed placeholders instead of random Czech data.
- Labeled values stop at the next column/label, so labels such as
  "Patient Report" or "Specimen Details" are never treated as values and
  neighbouring fields on the same line survive.
- The local-model path pre-redacts deterministically first, so repeated
  identifiers stay consistent there too.

The Review & Edit panes now scroll together (vertical and horizontal),
following the textarea, diff preview, or pane itself, with echo
suppression to avoid feedback loops.

* Skip profile labels as patient names and create the pseudonym key lazily

* Expect the regex fallback to redact the patient name instead of faking one

* Close redaction gaps from review and keep pre-pass replacements stable

- Accept English name labels without a colon (full names only, at line or column start) and lowercase full names behind explicit labels
- Replace uppercase month DOBs and keep their case
- Replace letters-only and dotted labeled IDs; route labeled birth numbers through the birth-number replacement
- Keep labeled phone matches within one field and stop treating pH as a phone label
- Keep the deterministic pre-pass replacements in the final pass and send the finalized text from streaming review

* Keep the obfuscatePDFText return shape compatible for review callers

* Keep empty ID labels from consuming the next line

* Redact titled physician names after a label without a colon

* fix: redact odd DOB formats and spaced Czech addresses; keep result flags and compact collection dates

* fix: keep DOB labels on one line, narrow result-flag and compact-date exceptions

* fix: keep result-flag surnames only after a measured value, compact dates only beside their label

- A surname like Low is kept only when it trails a number on a result line
  with a unit, never right after a label (Surname: Low  Age: 27).
- An 8-digit date is kept only when it sits directly beside a collection or
  report label, so a later Order: number on the same line is still redacted.
- Regression tests use the exact review examples.

* fix: keep every given name after the comma in Last, First Middle names

Patient and physician names written as "Smith, Jane Anne Marie" kept only
the first middle name, so "Marie" survived. All given names after the comma
are now kept, and each middle name or its initial can appear in any written
form of the name.

* Add Slovak privacy aliases and recognize Slovak report fields

* Fix privacy alias collisions and preserve labeled birth-date copies

---------

Co-authored-by: bhargavmehta01 <bhargavmehta01@users.noreply.github.com>
Co-authored-by: bhargavmehta01 <16927944+bhargavmehta01@users.noreply.github.com>
Co-authored-by: Elkim <36666630+elkimek@users.noreply.github.com>

* Retry reports after privacy-review outages and retire stale model output (#1700)

* Retry auto-imported reports when the local privacy model is unavailable

A report whose privacy review could not run, or was cancelled after the
local privacy model failed (or while a configured model is unreachable),
was recorded as an explicit skip, so the auto-import source never offered
it again. Report it as failed instead so it is retried on a later check.
Other review callers are unchanged: the new result is opt-in.

* Ignore stale privacy streams and cover batch retry outcomes

A stream aborted for the regex fallback could reject later with a plain
Error (the reachability probe rewraps the abort), which marked the local
model as failed again and turned an explicit cancel into a retry. Ignore
results from a stream that was aborted or replaced.

Add tests through the real handleBatchPDFs path: an unavailable review and
a cancel while the configured local model is unreachable report 'failed';
ordinary cancels report 'skipped'.

---------

Co-authored-by: bhargavmehta01 <bhargavmehta01@users.noreply.github.com>
Co-authored-by: bhargavmehta01 <16927944+bhargavmehta01@users.noreply.github.com>
Co-authored-by: Elkim <36666630+elkimek@users.noreply.github.com>

* Add medication-aware demos and proportionate chat safety

* Bound therapy context by actual coverage and align browser fixtures

* Select demo refresh behavior tests in affected CI plans

* Preserve specimen duration and volume during privacy redaction

* Cache demo treatment data and refresh affected test fixtures

* Stabilize owned chat fixtures and retain wellness prompt contracts

* Cancel dashboard auto-open before discussion fixture setup

* Enable paused AI before asserting the shipping chat composer

* Wait for the delayed profile write before replacing its view

* Persist native conversation fixtures before testing chat controls

---------

Co-authored-by: Bhargav Mehta <bhargav.mehta01@gmail.com>
Co-authored-by: bhargavmehta01 <bhargavmehta01@users.noreply.github.com>
Co-authored-by: bhargavmehta01 <16927944+bhargavmehta01@users.noreply.github.com>
Co-authored-by: Elkim <36666630+elkimek@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants