Request action and full_text_xml_url; rank proposals by length - #6
Open
abigailhaddad wants to merge 1 commit into
Open
Request action and full_text_xml_url; rank proposals by length#6abigailhaddad wants to merge 1 commit into
abigailhaddad wants to merge 1 commit into
Conversation
find_documents does not request the action or full_text_xml_url fields, so _pick's action tests all match against "" and load() never has XML to hand parse_structural. Selection falls through to the ordering rules and the structural parser is unreachable from the live pipeline. With action restored, DOD-2023-OS-0063 still picks a one-page notice of an informational video over the 81-page NPRM, because proposals were ranked by publication date before length and no action keyword covers that document. That left textdiff on the validation docket diffing a one-page notice against the final rule. Three stress checks added; they fail on a379c2b. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V67xCuSySuXH9JNRb7Lv39
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.
Three lines, two of which are the field list. Against v0.8.0 (a379c2b).
find_documentsdoesn't requestactionorfull_text_xml_url_pickreadsd.get("action"), andload()readsfinal.get("full_text_xml_url"), but neither field is in thefields[]list, so both are absent from every document the live pipeline sees. Two consequences:actiontest in_pickis inert —_NOT_OPERATIVE,_INTERIMand_SUPPLEMENTALall search"", so nothing is ever skipped and selection falls through to the ordering rulesxml_textis alwaysNone, soparse_structuralnever runs fromload()and the parse always takes the regex pathload()is the only caller that passes XML, and it is what both__main__.py:130andserver.py:235invoke, so this is the whole live path. The stress checks pass because they hand_pickdocument dicts that carryaction.On the live path:
Both fields are available on the same list endpoint, so this is just the two names.
Proposals were ranked by date before length
With
actionrestored,DOD-2023-OS-0063still selects the wrong proposal. The docket carries a second document typedProposed Rule—2024-03460, one page, "Notification of posting of informational video on CMMC." — published two months after the NPRM. No_NOT_OPERATIVEkeyword covers it, andmax(pool, key=(publication_date, pages))takes the later one.That regressed
textdiffon the validation docket, which diffed a one-page notice against the final rule:Ranking by length first, as the
Rulebranch already does, fixes it. The supplemental preference still runs first, so EPA is unaffected.Length is a better backstop than the keyword list because the keyword list can't be completed. In 400 rule and proposed-rule documents published since January 2025 there are 97 distinct
actionstrings, and the ancillary ones take forms no fixed list anticipates —Notification of petition.,Notification of availability.,Proposed rule; public hearing.,Notification of enforcement discretion.Two near-misses in the current pattern, left alone here since length ranking covers them:Final rule; technical amendments.doesn't matchtechnical amendmentbecause\bfails before the plural, andNotice of proposed rulemaking; extension of public comment period.doesn't matchextension of (the )?comment periodbecause of the intervening word. The EPA stress fixture carries that same construction, and_pickdoes not skip it — the "comment-period extension is not treated as a proposal" check passes because the supplemental preference selects2022-24675before the extension is ever compared.After
Structural parsing, once reachable, does what #5 hoped. Against the XML label counts on five documents, both paths as of a379c2b:
SSA
2026-13420was 37% recall with 17 of 26 stored pairs beginning inside a Response before v0.8.0. The anchored regex alone accounts for that recovery; structural matches it and is equal or slightly better on exact label-boundary matches (112/112 against 111/112 on CMMC, 219/219 against 216/219 on CMS). Those last differences are small enough that they may be an artifact of comparing flattened text against XML paragraph boundaries rather than a defect in either path — the recall and in-Response columns are the ones that carry weight.Tests
Three checks added to the existing block. They fail on a379c2b and pass here:
The first two capture the params
find_documentssends rather than asserting on the source, so the field list can't drift back without failing. The third is the real CMMC docket with the action text stripped, which is howfind_documentscurrently returns it.Full suite otherwise unchanged — baseline 75 pass / 4 fail, patched 78 pass / 4 fail, no check that passed on a379c2b changed state. The four failures are
flaskmissing in my environment, identical in both runs.