Skip to content

Fix clinical answer output correctness - #108

Merged
BigSimmo merged 1 commit into
mainfrom
claude/answer-output-fixes
Jun 30, 2026
Merged

Fix clinical answer output correctness#108
BigSimmo merged 1 commit into
mainfrom
claude/answer-output-fixes

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Preserves the unique answer output fixes from claude/answer-output-fixes for review.

- citations: derive the compact label from the document title instead of a
  hardcoded clozapine/lithium/risk whitelist, so real documents are labelled
  correctly and a passage from a multi-drug title is no longer misattributed
  to one drug; trim labels to avoid stray whitespace.
- api: cap query length at 2000 chars on the search/answer/stream/interaction
  routes so oversized input fails as a clean 400 instead of flowing unbounded
  into query expansion, embeddings, and RPCs.
- display-text: number-safe truncation so a dose/threshold value is never split
  from its unit (e.g. "1.5 ×10⁹/L", "150 mg/day") and a dangling connector is
  dropped at the truncation boundary.
- rag: raise answer/section length caps (1200->1600, 420->600) to reduce silent
  truncation of multi-part clinical answers.
- rag-answer-text: strip the dangling brace left behind when removing a
  mid-stream JSON-artifact leak that follows clean prose.
- demo-data: require genuine escalation/triage context (not the bare word
  "risk") before returning a confident acute-risk answer in demo mode.

Tests added/updated for each change. Offline gates green: check:runtime, lint,
typecheck, and vitest (560 tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13c91ff5d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/demo-data.ts
@BigSimmo
BigSimmo enabled auto-merge June 30, 2026 01:22
@BigSimmo
BigSimmo merged commit 30480aa into main Jun 30, 2026
6 checks passed
@BigSimmo
BigSimmo deleted the claude/answer-output-fixes branch June 30, 2026 01:23
BigSimmo pushed a commit that referenced this pull request Jul 29, 2026
Branch-cleanup review of all 92 remote branches against main, recorded
with scope `branch-cleanup-deletion-pending` because deletion could not
be completed: the session git proxy rejects ref deletion with HTTP 403
and no delete-branch capability is exposed.

Five branches are verified safe to delete (empty diff against main, no
open PR) and are tracked as #108. The other 87 were deliberately not
cleared — their touched files still differ from main, the conservative
direction.

#109 records the trap that made the first pass wrong: the session clone
was shallow (74 of 2829 commits), which silently invalidated every
merge-base, cherry-pick and ahead/behind result. In that state local
main read as "ahead 52" with unrelated histories, and 90 of 91 branches
read as unmerged. `git fetch --unshallow` corrected both, and the guide
and sweep script should check for it rather than report silently.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YRCXgX4AWZ579bKN6sk6b
BigSimmo pushed a commit that referenced this pull request Jul 29, 2026
… classification

Three P2 findings from the Codex review of 873d28d, all documentation
correctness on rows added in this PR.

Record each deletion candidate's HEAD (finding 2, the substantive one).
`hasCompletedCleanupReview` in scripts/sweep-branch-ledger.mjs matches a
completed row on branch name AND HEAD together, and the aggregate row was
keyed only to main@855aa291. Once the five refs are deleted their HEADs
are unrecoverable, so no later operator could append the required
`branch-cleanup` rows. Each candidate now has its own pending row keyed to
its own HEAD, and #108 carries the same SHAs.

Record the two-tree evidence explicitly (finding 1). The rows now state
the merge-base and the `git diff --name-only <merge-base> <tip>` result
per branch rather than only the three-dot form. Two tips
(df29f31, c9bec8f) are themselves the merge-base with main, i.e. direct
ancestors; the other three have tree(merge-base) == tree(tip).

Correct the provider-backed classification (finding 3). The prior checks
cell said "no provider-backed checks" while the outcome described GitHub
open-PR cross-checks and an HTTP 403 deletion attempt. The new rows
enumerate the GitHub reads and the rejected mutation, and reserve the
"no provider-backed" wording for genuinely local work.

The ledger is append-only, so these are superseding rows; the original
aggregate row is left intact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YRCXgX4AWZ579bKN6sk6b
BigSimmo pushed a commit that referenced this pull request Jul 29, 2026
…ting refs

Codex review of 4cb33ed found the documented order unexecutable, and it
is right. #108 said to delete the five branches and then append the
completed `branch-cleanup` rows, but `resolveHead`
(scripts/branch-review-ledger.mjs:155-167) runs
`git rev-parse --verify <sha>^{commit}` and refuses a HEAD that is not a
commit in the repository. Once the refs are gone and their objects are
pruned, the append can never succeed, so recording the SHAs in the
previous commit was necessary but not sufficient.

Order is now append-then-delete, and the note explains why the
`n/a - <reason>` escape hatch is not an acceptable substitute:
`hasCompletedCleanupReview` matches only a 7-40 char hex HEAD, so an
`n/a` row would leave each branch resurfacing in every future sweep.

Verified locally: all five recorded SHAs resolve in this checkout, and an
absent SHA produces `refusing to append: head "..." is not a commit in
this repository`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YRCXgX4AWZ579bKN6sk6b
BigSimmo added a commit that referenced this pull request Jul 29, 2026
…low-clone trap (#1387)

Documentation and ledger bookkeeping only; the whole diff is
docs/branch-review-ledger.md and docs/outstanding-issues.md.

Records the PR #1383 prlanded verification (squash-vs-tip content diff empty,
nothing orphaned by the auto-merge race), carries the babysit closeout row that
the squash left behind, and files the branch-cleanup review with a per-candidate
row keyed to each branch's own HEAD.

New issue #109: remote sessions clone shallow, which silently invalidates every
merge-base, cherry-pick and ahead/behind result. A sweep in that state wrongly
reported 90 of 91 branches as carrying unmerged work; git fetch --unshallow
corrected it.

#108 records the ordering constraint that makes the cleanup executable: append
each completed branch-cleanup ledger row BEFORE deleting the ref, because
resolveHead refuses a HEAD that is no longer a commit in the repository, and the
n/a escape hatch never satisfies hasCompletedCleanupReview.

Clinical governance preflight not applicable: classifyPullRequestFiles reports
clinicalRisk false for a docs-only diff.
BigSimmo pushed a commit that referenced this pull request Jul 29, 2026
Resolved docs/outstanding-issues.md by keeping this branch's updated #98,
#102, #104 and #105 entries (the ones this PR rewrites) and adding main's new
#108 and #109 rows; the rest of the conflict was prettier re-padding column
widths after a summary-cell length change. next-id stays at 110.

Removed four exact-duplicate branch-review-ledger rows produced by the union
merge driver keeping both copies of rows present on this branch and on main -
the duplication risk tracked as #88.
BigSimmo pushed a commit that referenced this pull request Jul 29, 2026
Resolves the `docs/outstanding-issues.md` conflict. Two independent causes:

1. Rows #98#105 diverged. `main` carries the newer text (PR #1377 landed
   "Done 2026-07-29" outcomes and rewrote several summaries); this branch
   carried the pre-#1377 wording. Took `main`'s rows wholesale — the branch
   made no edits to that range, it simply forked before them.

2. `#108`/`#109` were allocated twice. `main` used them for the verified-landed
   branch deletions and the shallow-clone finding; this branch had used the same
   two ids for the design-system token manifest and the `ui-overlap` flake. The
   `issues:next-id` marker has no concurrency protection, which is exactly the
   failure the branch's own PR notes predicted. Renumbered this branch's two rows
   to #110/#111 and bumped the marker to 112. No content was dropped from either
   side; all 111 rows are unique.

Also records #111 as done, since this branch is what fixes it: the ui-overlap
inset measurement now retries inside `toPass` with the 2px symmetry tolerance
and the assertions unchanged. Leaving it open with a "Next: apply the retry
shape" action would have re-queued work this PR already did.
BigSimmo added a commit that referenced this pull request Jul 29, 2026
 (#1391)

Follow-ups to #1375 (Clinical Sky design system), which merged before these landed.

`text-4xs` was dead on main. #1375 retired the `--text-4xs` token, so Tailwind
emits no such rule and every remaining `text-4xs` class was a silent no-op with
the text falling back to inherited size. Two files carrying it landed from main
while #1375 was in flight and were dead on arrival. Repointed to `text-3xs`, the
10px floor, and guarded: the design-token contract now fails if any tracked file
under `src/` references the retired class outside a comment. Mockups are
deliberately not exempt — a dead utility breaks a mockup exactly as it breaks
production.

Six hydration races fixed at the source. In this app visible never implies
interactive: the server-rendered tree paints before React owns it, so a single
un-retried action asserted once is a coin flip under load. Every fix retries the
action together with the effect it should produce, so a swallowed first attempt
retries while a genuine regression still fails.

Both retries added to ui-smoke are idempotent, which review caught and which
matters more than it looks. `toPass` schedules another attempt whenever the
inner assertion's own deadline expires — which can happen after the click
already landed. Without a guard, `openGuide` clicked a Settings trigger the
modal was already covering, and the mode-menu retry clicked a TOGGLE a second
time, closing a menu that had just opened and oscillating until the budget ran
out. The mobile branch needed a second guard: a swallowed Settings click leaves
the phone menu open, so re-running `openMobileClinicalGuideMenu` would toggle it
shut and then fail to find Settings inside it — meaning the <768px branch could
not recover on retry at all.

The ui-overlap phone-inset measurement now retries inside `toPass` with the 2px
symmetry tolerance and the assertions byte-for-byte unchanged, so a genuinely
asymmetric header still fails once the retry budget is spent.

Documentation records that the intermediate font weights on the variable face
are deliberate rather than drift, and that redefining Tailwind's own leading
names silently retunes every existing call site.

Also resolves an `issues:next-id` double-allocation: #108/#109 were claimed
concurrently by two branches, so this branch's two rows are renumbered #110/#111
and the marker moved to 112. #111 is archived rather than left open, since this
change is what closes it.

RAG impact: no retrieval behaviour change — test robustness, two mockup class
names, and docs only; nothing under `src/lib/rag/**`, clinical-search,
ranking-config, the eval harness or the golden fixture is touched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FvU8z73P6TXUXoYBqN5K1P
BigSimmo pushed a commit that referenced this pull request Jul 30, 2026
Re-verified the five branches against the live remote before touching anything,
which mattered: claude/clinical-kb-pwa-review-asi3wb and
claude/dazzling-blackwell-f348d0 are already gone, deleted by someone with the
permission this session lacks and surfaced only by `git remote prune`. The list
is three, not five, and #108 said five.

The remaining three are still at exactly the recorded HEADs, and the proof was
re-run and strengthened. For each, tree(tip) == tree(merge-base) byte-for-byte,
so the branch nets zero content change from where it forked and nothing on it is
absent from main. That is stronger than either check the cleanup guide names:
--cherry-pick still reports 13/6/4 patch-unique commits on them, which is the
squash-merge false positive the guide warns about, and none is an ancestor of
main, so an ancestry --merged check would miss them too.

A completed `branch-cleanup` row keyed to its own HEAD is now appended for each,
which is the step that had to happen while the objects still exist —
resolveHead refuses a HEAD that is not a commit in the repository, so the reverse
order is unexecutable. check:branch-review-ledger passes at 1272 records with
union merge intact. The refs can now be deleted safely at any time.

Deletion itself is still blocked and is not mine to unblock: `git push origin
--delete` exits 1 with HTTP 403 from the session git proxy, with
recentRelayFailures empty, so it is credential scope rather than a relay fault;
and the GitHub MCP set exposes create_branch but no delete-branch capability.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YRCXgX4AWZ579bKN6sk6b
BigSimmo added a commit that referenced this pull request Jul 30, 2026
…2vcd8a

Complete #108's prerequisite and correct its branch list
BigSimmo pushed a commit that referenced this pull request Jul 30, 2026
Second conflict in docs/outstanding-issues.md in under an hour, same shape:
main re-padded the table so the hunk spanned every row, while only two rows
differed. Took main's #108 (completed by #1403) and kept this branch's #115
closure. #116 does not collide — main's next-id was still 116.

This recurrence is the case #116 itself describes: while conflicted, the PR
ran no CI at all and nothing said so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akwz3Sdms8uJ5AkDt3CduY
BigSimmo added a commit that referenced this pull request Jul 30, 2026
… audit batch (#1426)

* chore: close #108 after deleting empty remotes; record audit-branch cleanup batch

Delete five superseded remote refs (#108 trio plus circleci-project-setup and
execute-audit-code-remediation). Archive #108 and append branch-cleanup ledger
rows for a ten-branch audit/remediation review batch (two rejected, eight retained).

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: resolve outstanding-issues merge without conflict markers

Rebuild from origin/main (archives #113/#114, adds #125) and re-apply the
#108 archive so the duplicate-id and conflict-marker breakage from the prior
merge commit is gone.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* docs: correct branch cleanup ledger references

* docs: record PR 1426 review

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@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.

1 participant