pfs: descriptor_runs absorbs multi-thousand-character background paragraphs as a descriptor stem (G0502/G0503 self-referential addon-of bridges CoCM into CCM) #700

Closed
opened 2026-09-09 18:24:05 +00:00 by kert · 1 comment
Owner

Found by the P49 slice-1 final-review pipeline re-run (report .superpowers/sdd/2026-09-09-code-family-foundation/final-fix-wave-report.md, Step 3).

Symptom. After stack pfs families --write, CCM = hand list + G2058 (correct) plus G0502 and G0503 — the CY2017 psychiatric Collaborative Care Management codes, which are not CCM.

Mechanism. A ~5,543-character FR paragraph that recounts G0502/G0503's CY2017 descriptors inline (background prose in a later rule) matches _stem_pattern and is absorbed wholesale as G0502's descriptor. parse_descriptor on that text yields self-referential relation/addon-of rows (G0502→G0502, G0502→G0503) plus generic phrase hits (activity=comprehensive-care-plan, medical-decision-making, population=multiple-chronic-conditions-12-months, significant-risk). derive_families then bridges the G0502/G0503 component into CCM via the stem-token + identical-activity Jaccard rule (not via addon-of). Reproduces on 9691d4a and on the fix-wave head; C1 (stem case-insensitivity) did not cover it.

Fix. In pfs/descriptors.py: cap the stem paragraph length used for parsing (e.g. parse only the parenthetical that opens at the code, up to its matching close paren, not the whole paragraph), and drop relation elements whose target is the code itself (pfs/elements.py or pfs/extract.py). Test with the real G0502 paragraph. Then re-run stack pfs elements --code G0502 --code G0503 and families --write; expected CCM = hand list + G2058 only.

Done when CCM's derived membership equals the hand list + G2058 and no addon-of row has detail == code.

Found by the P49 slice-1 final-review pipeline re-run (report `.superpowers/sdd/2026-09-09-code-family-foundation/final-fix-wave-report.md`, Step 3). **Symptom.** After `stack pfs families --write`, CCM = hand list + G2058 (correct) **plus G0502 and G0503** — the CY2017 psychiatric Collaborative Care Management codes, which are not CCM. **Mechanism.** A ~5,543-character FR paragraph that recounts G0502/G0503's CY2017 descriptors inline (background prose in a later rule) matches `_stem_pattern` and is absorbed wholesale as G0502's descriptor. `parse_descriptor` on that text yields self-referential `relation/addon-of` rows (`G0502→G0502`, `G0502→G0503`) plus generic phrase hits (`activity=comprehensive-care-plan`, `medical-decision-making`, `population=multiple-chronic-conditions-12-months`, `significant-risk`). `derive_families` then bridges the G0502/G0503 component into CCM via the stem-token + identical-activity Jaccard rule (not via addon-of). Reproduces on 9691d4a and on the fix-wave head; C1 (stem case-insensitivity) did not cover it. **Fix.** In `pfs/descriptors.py`: cap the stem paragraph length used for parsing (e.g. parse only the parenthetical that opens at the code, up to its matching close paren, not the whole paragraph), and drop relation elements whose target is the code itself (`pfs/elements.py` or `pfs/extract.py`). Test with the real G0502 paragraph. Then re-run `stack pfs elements --code G0502 --code G0503` and `families --write`; expected CCM = hand list + G2058 only. **Done when** CCM's derived membership equals the hand list + G2058 and no `addon-of` row has `detail == code`.
kert added this to the P49: Code families as first-class objects — element model, lineage anchors, longitudinal chat milestone 2026-09-09 18:24:05 +00:00
kert added the pfs label 2026-09-09 18:24:05 +00:00
Author
Owner

Fixed in 2de806d: descriptor_runs now trims the stem paragraph to the code's own parenthetical (pfs.descriptors.descriptor_span — the code through the balanced close paren, capped at 1,500 chars, sentence cut past the cap). The 5,543-char CY2027 NPRM paragraph (5ITGVDJV ¶509) no longer yields G0502/G0503 elements. Live: elements re-extracted for the five hand families and families rebuilt — CCM is now 99437, 99439, 99487, 99489, 99490, 99491 + predecessor G2058; G0502/G0503 are out, and the chat's CCM history no longer narrates the psychiatric CoCM codes as early CCM.

Fixed in 2de806d: descriptor_runs now trims the stem paragraph to the code's own parenthetical (pfs.descriptors.descriptor_span — the code through the balanced close paren, capped at 1,500 chars, sentence cut past the cap). The 5,543-char CY2027 NPRM paragraph (5ITGVDJV ¶509) no longer yields G0502/G0503 elements. Live: elements re-extracted for the five hand families and families rebuilt — CCM is now 99437, 99439, 99487, 99489, 99490, 99491 + predecessor G2058; G0502/G0503 are out, and the chat's CCM history no longer narrates the psychiatric CoCM codes as early CCM.
kert closed this issue 2026-09-10 21:54:22 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: homelab/stack#700