llm: code valuation evidence in chat (APCM etc.) — registry, replica lookup, codes metadata, valuation event + table #682
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements docs/superpowers/specs/2026-09-08-llm-chat-code-valuation-design.md per docs/superpowers/plans/2026-09-08-llm-chat-code-valuation.md. Rollout: force re-index rules, mount ./data ro into llm, live APCM probe + control.
P48 residuals parked from the final re-review (minor):
llm/evidence.pyreplica cache: on a republish (mtime change) the parent connection is closed while another thread may still hold a cursor; that one turn logs "valuation evidence skipped" — needs refcounting or a grace periodcodesGIN + collection_id indexes ride in_HNSW_DDL, sobuild_ann_index = falsewould also skip them; split into their ownensure_indexes_UNKNOWN_YEARS_SQLruns one extrapfs.rvuscan per code-bearing chat turn (silent today)notebooks/palliative_care_rfi.pystill carries its own family registry copy — importpfs.families.FAMILIESpfs/valuation.pyround()is banker's rounding (CMS rounds half-up); unreachable with float RVUs, add a commentstream_answerdocstring should mention the silent degrade-to-no-evidence pathP48 rolled out (main @ d7ba609; llm container
fhirworx/llm:ac06d7d, rolled 2026-09-08 23:51 ET).Live probes (SSE, in-container):
valuationevent: G0556/G0557/G0558 × {CY2025 final, CY2026 final, CY2027 proposed} = 9 rows; prose cites[PFS CY2025 Addendum B],[PFS CY2026 Addendum B],[CY2027 NPRM Addendum B](4 each) plus[89 FR 97897 ¶10]and a docket comment; 5 code-cited rule paragraphs merged into the 11 sources; 0 errors.Browser probe (Playwright on the gateway network, real page): table rendered with 9 rows, 3 proposed rows flagged, caption present, 3 FR provenance links (89-FR-98452, 90-FR-49266, 91-FR-43842), 11 sources (5 rule), no page errors.
Rollout steps: rules re-indexed with
codesmetadata (80 rules, 67,340 chunks); DuckDB replica relocated todata/replica/(only that directory is mounted read-only into the container); GIN + collection_id indexes created byensure_hnsw.Final-review fixes landed before merge: payments only for status A/R/T with status notes (bundled/carrier-priced/anesthesia…), FR citations never read as CPT codes, case-insensitive codes, CF labelled non-APM vs QP and CY2024 split, table caption, per-code cited-source window, collection-filtered query, cached replica handle with per-call cursor (thread-safe), prompt-size caps. Residual minors are in the comment above.
Delivered and merged as
ac06d7d(P48): valuation SSE event + table, codes chunk metadata, cached replica handle; rolled to the llm image. Closing.