Skip to content

Keep LLM-provided value on qualitative rows - #611

Merged
castelao merged 2 commits into
mainfrom
conditional_value_from_summary
Nov 20, 2026
Merged

castelao merged 2 commits into
mainfrom
conditional_value_from_summary

Conversation

@castelao

Copy link
Copy Markdown
Member

Only fill value from summary when the LLM left it null, so qualitative features that return structured values (e.g. a list of franchise grantees or permit types) are no longer overwritten by summary.

Summary is currently redundant with value for qualitative features, so this is a natural transition to eventually drop the summary in favor of the combination: value + ord_text + explanation.

@castelao castelao self-assigned this Nov 12, 2026
@castelao
castelao requested a review from ppinchuk as a code owner November 12, 2026 12:33
Copilot AI balanced review requested due to automatic review settings November 12, 2026 12:33
@castelao castelao added the enhancement Update to logic or general code improvements label Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are identified for the change preserving non-null qualitative values and using summaries only as a null-value fallback.

No open issues 🎉

What changed in this PR

This PR preserves LLM-provided values for qualitative features when COMPASS saves ordinance results, using the summary only when the value is null.

Changes:

  • Keep non-null qualitative values, including structured lists, rather than overwriting them with summaries.
  • Add regression coverage for list preservation and the null-value fallback.
File Description
tests/​python/​unit/​utilities/​test_utilities_finalize.py Tests preservation of structured values and fallback to summary for null values.
compass/​utilities/​finalize.py Restricts summary-to-value copying to null qualitative values and updates the docstring.

Review effort: Balanced

@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.64%. Comparing base (667c0eb) to head (ff3f0b6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #611   +/-   ##
=======================================
  Coverage   76.63%   76.64%           
=======================================
  Files          85       85           
  Lines        9866     9870    +4     
  Branches     1086     1086           
=======================================
+ Hits         7561     7565    +4     
  Misses       2097     2097           
  Partials      208      208           
Flag Coverage Δ
unittests 76.64% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ppinchuk
ppinchuk previously approved these changes Nov 12, 2026

@ppinchuk ppinchuk left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems harmless enough. I think the reason that this hasn't been an issue before is that we have been defining qualitative features as those that only have a summary (i.e. explicitly no value output). In other words, I was routing the list-output features like "prohibited districts", etc. to the "quantitative" output.

This is not a bulletproof system though, so the check you added in this PR increases the robustness of the code. Thanks!

…fore fill

Only fill value from summary when both value is empty and summary is
not blank. This prevents garbage data when both are blank, and ensures
LLM-provided values (such as lists or structured text) are preserved.
Add tests for:
- Both value and summary blank (should not fill)
- Value blank with real summary (should fill)
- Value real with blank summary (should not fill)
- Whitespace variations (tabs, newlines, mixed)
- Falsy non-string values (0, False, [])
- Numeric summary values (should not be treated as valid)

@ppinchuk ppinchuk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks solid!

@castelao
castelao merged commit 224e333 into main Nov 20, 2026
25 checks passed
@castelao
castelao deleted the conditional_value_from_summary branch November 20, 2026 17:30

This branch was previously deployed

2 inactive deployments
codecov — ff3f0b62 Deployed Nov 20, 2026 by castelao via Codecov #723
pypi — ff3f0b62 Deployed Nov 20, 2026 by castelao via Build, check, and optionally upload wheels #555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Update to logic or general code improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants