Skip to content

fix(CODEWIKI-005): CU-86akbhg0r 4 review findings across 3 files - #40

Merged
michaelassraf merged 5 commits into
mainfrom
ai-fix/codewiki-005-fc4e0cc2-bef4f5a8
Sep 8, 2026
Merged

michaelassraf merged 5 commits into
mainfrom
ai-fix/codewiki-005-fc4e0cc2-bef4f5a8

Conversation

@flamingo

@flamingo flamingo Bot commented Aug 24, 2026

Copy link
Copy Markdown

Closes 4 review findings across 3 files.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟢 90 high flamingo_guidelines.py uses print() for diagnostic output instead of module logger codewiki/src/be/flamingo_guidelines.py:39
2 🟡 88 medium Verbose DEBUG-level print() statements left in production sanitization code path codewiki/src/be/flamingo_guidelines.py:82
3 🔴 40 low — review closely analysis_service.py mixes logger usage with commented-out print-based README reading code left in place codewiki/src/be/dependency_analyzer/analysis/analysis_service.py:220
4 🟢 90 high print() used instead of module logger in background_worker.py codewiki/src/fe/background_worker.py:39

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: bef4f5a8-e7f3-478b-8731-2becca2de658

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

ClickUp task: CU-86akbhg0r Code review fixes: CodeWiki backend and CLI review findings (5 PRs)

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 What this fix changed, finding by finding

4 finding(s) fixed in this draft — 4 explained inline on the diff; 1 low-confidence hunk(s) need close review before merging.

print(f"[CodeWiki] {GUIDELINES_ENV_VAR} not set - continuing without Flamingo guidelines")
logger.info(f"{GUIDELINES_ENV_VAR} not set - continuing without Flamingo guidelines")
return ""

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 flamingo_guidelines.py uses print() for diagnostic output instead of module logger

Added import logging and module-level logger = logging.getLogger(__name__) near the top of the file, then replaced all print(...) calls in load_flamingo_guidelines, load_custom_instructions, load_validation_rules with logger.info/logger.warning/logger.error as appropriate (e.g. "not set" messages → logger.info, missing-file messages → logger.warning, exception messages → logger.error).

🤖 Prompt for AI agents
In codewiki/src/be/flamingo_guidelines.py around line 39, review and complete this code-review fix: flamingo_guidelines.py uses print() for diagnostic output instead of module logger.
What the draft fix changed: Added `import logging` and module-level `logger = logging.getLogger(__name__)` near the top of the file, then replaced all `print(...)` calls in `load_flamingo_guidelines`, `load_custom_instructions`, `load_validation_rules` with `logger.info`/`logger.warning`/`logger.error` as appropriate (e.g. "not set" messages → `logger.info`, missing-file messages → `logger.warning`, exception messages → `logger.error`).
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer


# Count braces before sanitization
open_count_before = text.count('{')
close_count_before = text.count('}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 Verbose DEBUG-level print() statements left in production sanitization code path

Replaced all print(f"[DEBUG] ...") diagnostic/trace statements in sanitize_problematic_patterns and sanitize_and_escape_format_braces with logger.debug(...) calls (brace counts, preserved-placeholder counts, and content previews), so these no longer print unconditionally to stdout and can be suppressed/leveled via standard logging configuration.

🤖 Prompt for AI agents
In codewiki/src/be/flamingo_guidelines.py around line 82, review and complete this code-review fix: Verbose DEBUG-level print() statements left in production sanitization code path.
What the draft fix changed: Replaced all `print(f"[DEBUG] ...")` diagnostic/trace statements in `sanitize_problematic_patterns` and `sanitize_and_escape_format_braces` with `logger.debug(...)` calls (brace counts, preserved-placeholder counts, and content previews), so these no longer print unconditionally to stdout and can be suppressed/leveled via standard logging configuration.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 88 medium — react 👍/👎 to teach the reviewer

Comment on lines 252 to 257

def _read_readme_file(self, repo_dir: str) -> Optional[str]:
"""Find and read the README file from the repository root."""
# possible_readme_names = ["README.md", "README", "readme.md", "README.txt"]
# for name in possible_readme_names:
# readme_path = Path(repo_dir) / name
# if readme_path.exists():
# try:
# logger.debug(f"Found README file at {readme_path}")
# return readme_path.read_text(encoding="utf-8")
# except Exception as e:
# logger.warning(f"Could not read README file at {readme_path}: {e}")
# return None
# logger.debug("No README file found in repository root.")
# return None
base = Path(repo_dir)
possible_readme_names = ["README.md", "README", "readme.md", "README.txt"]
for name in possible_readme_names:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 analysis_service.py mixes logger usage with commented-out print-based README reading code left in place

Removed the dead, commented-out block of the old unsafe README-reading implementation (the # possible_readme_names ... return None comment block) inside _read_readme_file in analysis_service.py, leaving only the active, safe implementation using assert_safe_path/safe_open_text. No behavioral change; purely deletion of leftover dead code.

(Automatically downgraded: no change in this fix lands near this finding's line — verify whether it was actually addressed.)

🤖 Prompt for AI agents
In codewiki/src/be/dependency_analyzer/analysis/analysis_service.py around line 220, review and complete this code-review fix: analysis_service.py mixes logger usage with commented-out print-based README reading code left in place.
What the draft fix changed: Removed the dead, commented-out block of the old unsafe README-reading implementation (the `# possible_readme_names ... return None` comment block) inside `_read_readme_file` in `analysis_service.py`, leaving only the active, safe implementation using `assert_safe_path`/`safe_open_text`. No behavioral change; purely deletion of leftover dead code.

_(Automatically downgraded: no change in this fix lands near this finding's line — verify whether it was actually addressed.)_
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 40 low — review closely — react 👍/👎 to teach the reviewer

Comment on lines 44 to 50
self.running = True
thread = threading.Thread(target=self._worker_loop, daemon=True)
thread.start()
print("Background worker started")
logger.info("Background worker started")

def stop(self):
"""Stop the background worker."""

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 print() used instead of module logger in background_worker.py

Added import logging and a module-level logger = logging.getLogger(__name__) near the top of codewiki/src/fe/background_worker.py, then replaced every print(...) call across the file (in start, load_job_statuses, _reconstruct_jobs_from_cache, save_job_statuses, _worker_loop, and _process_job) with the equivalent logger.info(...) or logger.error(...) call depending on whether the original message indicated a normal status update or an error/failure condition. No behavior, formatting, or control flow was otherwise changed.

🤖 Prompt for AI agents
In codewiki/src/fe/background_worker.py around line 39, review and complete this code-review fix: print() used instead of module logger in background_worker.py.
What the draft fix changed: Added `import logging` and a module-level `logger = logging.getLogger(__name__)` near the top of `codewiki/src/fe/background_worker.py`, then replaced every `print(...)` call across the file (in `start`, `load_job_statuses`, `_reconstruct_jobs_from_cache`, `save_job_statuses`, `_worker_loop`, and `_process_job`) with the equivalent `logger.info(...)` or `logger.error(...)` call depending on whether the original message indicated a normal status update or an error/failure condition. No behavior, formatting, or control flow was otherwise changed.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(CODEWIKI-005): 4 review findings across 3 files fix(CODEWIKI-005): CU-86akbhg0r 4 review findings across 3 files Sep 3, 2026
@michaelassraf

Copy link
Copy Markdown

Superseded by #52, which has merged.

#52 covers the same printlogging conversion in flamingo_guidelines.py and background_worker.py, plus cache_manager.py and github_processor.py. The two diverge only on message prefixes and a couple of level choices (logger.error here vs logger.warning there for guideline-load failures) — they conflicted textually in flamingo_guidelines.py.

The one thing here that #52 does not include is the analysis_service.py cleanup (deleting the commented-out _read_readme_file body). That is worth keeping — please rebase and reopen with just that hunk.

michaelassraf and others added 2 commits September 7, 2026 22:47
Bring the branch up to date with main (PRs #48, #49, #52, #53, #54, #55).

flamingo_guidelines.py is fully superseded by #52, which has merged: this
branch's changes to that file are dropped and the file is taken from main
wholesale. Resolving the conflict hunk-by-hunk instead left a duplicate
'import logging', since main already has one.

What remains is the part of this PR #52 did not cover: the analysis_service.py
dead-code cleanup and the background_worker.py print -> logging conversion.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
#50 landed the analysis_service.py dead-code cleanup this branch also carried,
so what remains here is the background_worker.py print -> logging conversion.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@michaelassraf
michaelassraf marked this pull request as ready for review September 8, 2026 02:57
@michaelassraf
michaelassraf merged commit a46d17d into main Sep 8, 2026
michaelassraf added a commit that referenced this pull request Sep 8, 2026
The branch replaced the background worker's fake-argparse.Namespace dance with
Config.from_web_job(...), but that classmethod did not exist on Config (only
from_args, from_cli and from_config_manager), so _process_job raised
AttributeError on the first job.

Add it, delegating to from_args for the environment-driven resolution and then
applying the job-specific docs_dir - behaviourally identical to the three lines
it replaces.

Also merges main; the background_worker cleanup log line conflicted with #40's
print -> logging conversion and is resolved in favour of main.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@michaelassraf
michaelassraf deleted the ai-fix/codewiki-005-fc4e0cc2-bef4f5a8 branch September 8, 2026 03:11
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