Skip to content

fix(validation): address PR15 Gemini review comments#16

Merged
ProfRandom92 merged 2 commits into
mainfrom
fix/pr15-gemini-review-comments
Jul 9, 2026
Merged

fix(validation): address PR15 Gemini review comments#16
ProfRandom92 merged 2 commits into
mainfrom
fix/pr15-gemini-review-comments

Conversation

@ProfRandom92

Copy link
Copy Markdown
Owner

Summary:

  • Uses JSON Schema-compliant search semantics for pattern validation.
  • Rejects empty state log chains to align verifier behavior with minItems: 1.
  • Moves verify_file_state_log import to top-level in status_screen.py.

Context:
Follow-up to Gemini Code Assist comments on PR #15.

Changed files:

  • modules/validation/schema_validator.py
  • modules/evidence/evidence.py
  • modules/cli/status_screen.py
  • tests/validation/test_schema_validator.py
  • tests/evidence/test_state_log.py

Validation:

  • python -m pytest: 230 passed
  • comptext status --dry-run
  • comptext doctor --dry-run
  • git diff --check

Risk:
Low. Small correctness fix plus import cleanup; no public CLI behavior change beyond rejecting invalid empty state log chains.

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

Copy link
Copy Markdown

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 refactors imports in status_screen.py, adds a check for empty entries in verify_state_log_chain along with corresponding tests, and updates the JSON schema validator to use re.search instead of re.match for pattern matching (with new tests). The reviewer suggested making the schema pattern validation more robust by ensuring the pattern is a string and handling regular expression compilation errors gracefully.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread modules/validation/schema_validator.py Outdated
Comment on lines 46 to 49
if "pattern" in schema and isinstance(instance, str):
import re
if not re.match(schema["pattern"], instance):
if not re.search(schema["pattern"], instance):
raise ValueError(f"{location} does not match pattern {schema['pattern']}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If schema["pattern"] is not a string, or if it is an invalid regular expression, re.search will raise a TypeError or re.error respectively. To make the validator more robust and defensive, we should validate that the pattern is a string and handle any compilation errors gracefully by raising a ValueError.

Suggested change
if "pattern" in schema and isinstance(instance, str):
import re
if not re.match(schema["pattern"], instance):
if not re.search(schema["pattern"], instance):
raise ValueError(f"{location} does not match pattern {schema['pattern']}")
if "pattern" in schema and isinstance(instance, str):
import re
pattern = schema["pattern"]
if not isinstance(pattern, str):
raise ValueError(f"Schema pattern must be a string, got {type(pattern).__name__}")
try:
compiled_pattern = re.compile(pattern)
except re.error as err:
raise ValueError(f"Invalid regular expression pattern '{pattern}': {err}")
if not compiled_pattern.search(instance):
raise ValueError(f"{location} does not match pattern {pattern}")

@ProfRandom92 ProfRandom92 merged commit 2143032 into main Jul 9, 2026
6 checks passed
@ProfRandom92 ProfRandom92 deleted the fix/pr15-gemini-review-comments branch July 9, 2026 00:03
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