Skip to content

Fix/libstatus 20251213#348

Merged
nlothian merged 5 commits intomainfrom
fix/libstatus-20251213
Dec 13, 2025
Merged

Fix/libstatus 20251213#348
nlothian merged 5 commits intomainfrom
fix/libstatus-20251213

Conversation

@nlothian
Copy link
Copy Markdown
Owner

No description provided.

nlothian and others added 3 commits December 13, 2025 09:43
…d ensure version bump only on actual changes; apply consistent changed = changed or (previous != info) logic for table and module_operators and removals
Copy link
Copy Markdown

@kilo-code-bot kilo-code-bot Bot left a comment

Choose a reason for hiding this comment

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

✅ No Issues Found

7 files reviewed | Confidence: 95% | Recommendation: Merge

Review Details

Files: .paige/library_test_progress.json, docs/FEATURES.md, docs/LIBRARY_STATUS.md, docs/SYNTAX_NOTES.md, tests/test_module_parsing_cache.py, vibeprolog/interpreter.py, vibeprolog/operators.py

Checked: Security, bugs, performance, error handling, code style, test coverage

Summary: The PR adds parsed module caching to improve performance by avoiding redundant parsing of unchanged Prolog files. The implementation is well-designed with proper cache invalidation based on file modification time, operator table version, character conversions, and conditional compilation state. Tests verify cache reuse and invalidation behavior. No security issues, bugs, or style violations found.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a parsed module caching mechanism to the Prolog interpreter, aiming to improve performance by avoiding redundant parsing. Key changes include adding a ParsedModuleCacheEntry TypedDict and associated caching logic within vibeprolog/interpreter.py, which now checks for cached parsed items based on file modification time, operator table version, character conversions, and conditional compilation state. The consult method was updated to leverage this cache, and new tests were added in tests/test_module_parsing_cache.py to verify cache reuse and invalidation on file changes. Additionally, the OperatorTable in vibeprolog/operators.py now tracks a version number that increments upon operator definition changes, ensuring cache consistency. Documentation was updated in docs/FEATURES.md, docs/LIBRARY_STATUS.md, and docs/SYNTAX_NOTES.md to reflect the new caching feature and updated library loading statistics, including library/xpath.pl now loading successfully, and changes in error messages for library/numerics/special_functions.pl, library/numerics/testutils.pl, library/ordsets.pl, and library/ugraphs.pl. Review comments suggest removing an unused all_items variable in _process_parsed_items for clarity and simplifying a conditional logic for the changed flag in _define_single within the operator table.

Comment thread vibeprolog/interpreter.py Outdated
Comment on lines +1897 to +1917
all_items: list[Clause | Directive] = []

def _process_parsed_items(
parsed_items: list[Clause | Directive],
last_pred: tuple[str, str, int] | None,
) -> tuple[str, str, int] | None:
for item in parsed_items:
expanded_item = self._apply_term_expansion(item)
if hasattr(expanded_item, "elements") and isinstance(expanded_item.elements, list):
items_to_process = list(expanded_item.elements)
else:
items_to_process = [expanded_item]

last_pred = self._process_items(
items_to_process,
source_name,
closed_predicates,
last_pred,
)
all_items.extend(items_to_process)
return last_pred
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.

medium

The variable all_items is initialized and extended within the _process_parsed_items function, but it is never used. It appears to be a remnant from a previous implementation and can be safely removed to improve code clarity and maintainability.

        def _process_parsed_items(
            parsed_items: list[Clause | Directive],
            last_pred: tuple[str, str, int] | None,
        ) -> tuple[str, str, int] | None:
            for item in parsed_items:
                expanded_item = self._apply_term_expansion(item)
                if hasattr(expanded_item, "elements") and isinstance(expanded_item.elements, list):
                    items_to_process = list(expanded_item.elements)
                else:
                    items_to_process = [expanded_item]

                last_pred = self._process_items(
                    items_to_process,
                    source_name,
                    closed_predicates,
                    last_pred,
                )
            return last_pred
References
  1. Code should be easy to understand for all team members. Removing unused code improves readability and maintainability. (link)

Comment thread vibeprolog/operators.py Outdated
nlothian and others added 2 commits December 13, 2025 12:46
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@kilo-code-bot kilo-code-bot Bot left a comment

Choose a reason for hiding this comment

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

⚠️ WARNING: Unused variable all_items in _consult_code

Remove the unused all_items = [] variable and related code, as items are now processed immediately instead of collected.

-        all_items = []
+        

⚠️ WARNING: Redundant changed flag logic in _define_single

The changed flag can be simplified by directly setting it to True when changes occur, rather than using or operations.

-        changed = changed or (previous != info)
+        changed = True

And similar for other places.

@nlothian nlothian merged commit 58e78dd into main Dec 13, 2025
2 checks passed
Copy link
Copy Markdown

@kilo-code-bot kilo-code-bot Bot left a comment

Choose a reason for hiding this comment

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

⚠️ 2 Issues Found

Severity Issue Location
WARNING Unused variable all_items in _consult_code vibeprolog/interpreter.py:1894
WARNING Redundant changed flag logic in _define_single vibeprolog/operators.py:268

Recommendation: Address minor code quality issues before merge

Review Details

Files: .paige/library_test_progress.json, docs/FEATURES.md, docs/LIBRARY_STATUS.md, docs/SYNTAX_NOTES.md, tests/test_module_parsing_cache.py, vibeprolog/interpreter.py, vibeprolog/operators.py

Checked: Security, bugs, performance, error handling, code style, test coverage

Summary: The PR implements parsed module caching to improve performance by avoiding redundant parsing of unchanged Prolog files. The implementation includes proper cache invalidation based on file modification time, operator table version, character conversions, and conditional compilation state. Tests verify cache reuse and invalidation behavior. Two minor code quality issues found: an unused variable and redundant flag logic.

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