Modernize ClearPath for safer, maintainable clinical drafting - #1
Draft
rdsciv wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This PR turns the original ClearPath MVP into a safer, better documented, and more maintainable clinical-documentation prototype without expanding its core product scope. The repository had a sound small-app foundation, but the review found several issues that had accumulated around a single initial implementation:
What changed
Align the clinical framework with current ASAM terminology
Consolidate and harden server-side streaming
createStreamingToolResponsehelper.400), invalid input (400), missing API configuration (503), and pre-stream provider failures (502).Cache-Control: no-store, explicit text content types, and request cancellation propagation.ANTHROPIC_MODEL, withclaude-sonnet-5as the default.Fix client streaming and improve usability
useStreamingToolhook.TextDecoder.decode(..., { stream: true })and flush the decoder at completion, preventing split multibyte characters from becoming replacement glyphs.Add privacy, safety, and accessibility guardrails
aria-invalid,aria-current,aria-busy, and meaningful labels for generated results and ASAM badges.Modernize dependencies and build behavior
eslint-config-nextin lockstep.brace-expansionand PostCSS releases after verifying compatibility through lint, types, tests, and a production build.typecheck,test, andcheckscripts.Document the project and automate verification
.env.exampleand adjusted.gitignoreto keep it tracked.User and developer impact
Users get current Fourth Edition labels, clearer safety expectations, better mobile/accessibility behavior, a cancel control, and more reliable streamed text. Developers get one request path and one client streaming path instead of maintaining six copies, along with documented setup, tests, CI, configurable models, and deterministic builds.
No database, authentication system, EHR integration, or persistence layer was introduced.
Validation
npm run lint— passednpm run typecheck— passednpm test— 2 files / 10 tests passednpm run build— passed with all pages and API routes generated on Next.js 16.2.10npm audit— 0 vulnerabilities after the dependency update and scoped overridesgit diff --check— passed/,/treatment-plan,/asam-mapper, and/doc-reviewerreturned200with HTML content400400ANTHROPIC_API_KEYreturned503Not run: a live Anthropic generation, because no API key was placed in the review environment. Screenshot-level browser verification was also unavailable in the review session; compilation and live HTTP checks were completed instead.
Important boundaries and follow-up work
This remains an educational prototype. It is not ready for identifiable clinical data. Before real-world deployment, the project still needs organizational clinical/privacy/security review plus authentication, authorization, rate limiting, abuse controls, monitoring, a logging and retention policy, vendor agreements where required, and clinician-led prompt/output evaluations.
The model still returns plain text shaped by prompt instructions. A valuable next step is structured output with schema validation, which would remove the ASAM badge parser's dependence on Markdown headings and status phrases.
Suggested review order
README.mdfor intended scope and safety boundaries.src/lib/prompts.tsandsrc/lib/asam.tsfor the Fourth Edition update.src/lib/streaming-tool-route.tsandsrc/hooks/use-streaming-tool.tsfor the shared request path.tests/and.github/workflows/ci.ymlfor verification coverage.package.jsonandpackage-lock.jsonfor the dependency/security update.