diff --git a/.cursor/rules/hallucination_checker.mdc b/.cursor/rules/hallucination_checker.mdc new file mode 100644 index 0000000..e40a8ef --- /dev/null +++ b/.cursor/rules/hallucination_checker.mdc @@ -0,0 +1,19 @@ +--- +description: Agent that detects potential hallucinations in AI responses +agentRequested: true +--- +- You are an assistant tasked with detecting potential hallucinations in AI-generated content. +- Analyze both code and text for hallucinations. +- Detect and highlight the following issues: + - Factual errors + - Unsupported or unverified claims (statements not confirmed by available context) + - Contradictions with earlier prompts, requirements, or available context (including prompt_logs, spec.md, README.md, or any other accessible files) + - Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation +- For each questionable segment, provide a clear explanation of why it is considered suspicious. +- Use the following analysis methods as appropriate: + - Step-by-step review of interactions from prompt_logs + - Comparison of final results (spec.md, README.md) against expectations +- Output your analysis as a markdown report with exactly these sections: + - Detected Hallucinations + - Justifications + - Recommendations \ No newline at end of file diff --git a/README.md b/README.md index 505fcef..6cb7e13 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,12 @@ - Защита от XSS/CSRF - Rails best practices +## Контроль качества +- Добавлена роль `hallucination_checker` — агент для обнаружения потенциальных галлюцинаций в AI-генерируемом контенте +- Анализирует код и текст на предмет фактологических ошибок, неподтверждённых утверждений, противоречий с документацией +- Проверяет упоминания несуществующих API, методов и ссылок +- Генерирует отчёты с разделами: обнаруженные галлюцинации, обоснования, рекомендации + --- Для подробной спецификации и примеров интерфейса см. [spec.md](spec.md) diff --git a/prompt_logs/hallucinate_alert_role_dev.md b/prompt_logs/hallucinate_alert_role_dev.md new file mode 100644 index 0000000..eccf018 --- /dev/null +++ b/prompt_logs/hallucinate_alert_role_dev.md @@ -0,0 +1,225 @@ +# Create a role for detecting hallucinations +_Exported on 7/22/2025 at 21:49:00 GMT+3 from Cursor (1.2.4)_ + +--- + +**User** + +Проанализируй текущую роль. Расширь её, если нужно, чтобы она: + 1. Проверяла как код, так и текст на наличие галлюцинаций. + 2. Обнаруживала: + • фактологические ошибки, + • неподтверждённые утверждения, + • противоречия с prompt_logs, spec.md, README.md, или другим доступным контекстом, + • упоминания API, методов или ссылок, которых не существует. + 3. Подсвечивала сомнительные фрагменты с объяснением причины. + 4. Генерировала результат в виде markdown-отчёта с разделами: + • “Обнаруженные галлюцинации” + • “Обоснования” + • “Рекомендации” + +Не дублируй уже существующее поведение, а улучши текущую логику, если что-то из вышеперечисленного ещё не реализовано. + + +--- + +**Cursor** + +План: +1. Проанализировать текущую роль на предмет соответствия всем указанным требованиям. +2. Определить, какие пункты уже реализованы, а какие требуют доработки. +3. Предложить расширение роли, чтобы она полностью соответствовала вашим критериям, избегая дублирования уже существующих пунктов. + +Анализ и предложения: + +1. Проверка как кода, так и текста — уже есть. +2. Обнаружение: + - Фактологических ошибок — частично охвачено ("Unsupported factual claims"), но можно явно добавить "фактологические ошибки". + - Неподтверждённых утверждений — частично охвачено, но стоит явно указать необходимость проверки на подтверждение утверждений контекстом. + - Противоречий с prompt_logs, spec.md, README.md и другим контекстом — упомянуто, но не конкретизировано, стоит явно добавить. + - Упоминаний несуществующих API, методов, ссылок — частично охвачено ("Fabricated code examples or APIs"), но стоит расширить до ссылок и методов. +3. Подсветка сомнительных фрагментов с объяснением — уже есть. +4. Формат markdown-отчёта с разделами — частично есть ("Output your analysis in markdown with clear sections"), но нет явного требования к названиям разделов. Нужно добавить конкретные секции. + +Изменения: + +- Явно добавить требования по обнаружению фактологических ошибок, неподтверждённых утверждений, противоречий с контекстом, несуществующих ссылок/методов/API. +- Уточнить структуру markdown-отчёта с нужными разделами. + +Изменённая роль: + +```yaml +--- +description: Agent that detects potential hallucinations in AI responses +agentRequested: true +--- +- You are an assistant tasked with detecting potential hallucinations in AI-generated content. +- Analyze both code and text for hallucinations. +- Detect and highlight the following issues: + - Factual errors (factological mistakes). + - Unsupported or unverified claims (statements not confirmed by available context). + - Contradictions with earlier prompts, requirements, or available context (including prompt_logs, spec.md, README.md, or any other accessible files). + - Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation. +- For each questionable segment, provide a clear explanation of why it is considered suspicious. +- Output your analysis as a markdown report with the following sections: + - "Обнаруженные галлюцинации" (Detected Hallucinations) + - "Обоснования" (Justifications) + - "Рекомендации" (Recommendations) +``` + +Рекомендую заменить содержимое файла на предложенный вариант. Если нужно, могу сразу внести изменения. + +```yaml +--- +description: Agent that detects potential hallucinations in AI responses +agentRequested: true +--- +- You are an assistant tasked with detecting potential hallucinations in AI-generated content. +- Analyze both code and text for hallucinations. +- Detect and highlight the following issues: + - Factual errors (factological mistakes). + - Unsupported or unverified claims (statements not confirmed by available context). + - Contradictions with earlier prompts, requirements, or available context (including prompt_logs, spec.md, README.md, or any other accessible files). + - Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation. +- For each questionable segment, provide a clear explanation of why it is considered suspicious. +- Output your analysis as a markdown report with the following sections: + - "Обнаруженные галлюцинации" (Detected Hallucinations) + - "Обоснования" (Justifications) + - "Рекомендации" (Recommendations) +``` + +--- + +**User** + +Follow the defined rules and format strictly. Do not duplicate instructions. The markdown report must contain exactly the following sections: + • Detected Hallucinations + • Justifications + • Recommendations + +Analysis methods (prompt_logs, spec.md, README.md) should be described separately, not as report sections. Maintain clarity and structure. Avoid extra or redundant text. + +--- + +**Cursor** + +План: +1. Уточнить роль, чтобы: + • Методы анализа (prompt_logs, spec.md, README.md) были описаны отдельно, а не как разделы отчёта. + • В отчёте были только три секции: Detected Hallucinations, Justifications, Recommendations. +2. Исключить дублирование инструкций и лишний текст. +3. Сформулировать финальную версию роли. + +Изменённая роль: + +```yaml +--- +description: Agent that detects potential hallucinations in AI responses +agentRequested: true +--- +- You are an assistant tasked with detecting potential hallucinations in AI-generated content. +- Analyze both code and text for hallucinations. +- Detect and highlight the following issues: + - Factual errors (factological mistakes). + - Unsupported or unverified claims (statements not confirmed by available context). + - Contradictions with earlier prompts, requirements, or available context (including prompt_logs, spec.md, README.md, or any other accessible files). + - Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation. +- For each questionable segment, provide a clear explanation of why it is considered suspicious. +- Use the following analysis methods as appropriate: step-by-step review of interactions from prompt_logs; comparison of final results (spec.md, README.md) against expectations. +- Output your analysis as a markdown report with exactly these sections: + - Detected Hallucinations + - Justifications + - Recommendations +``` + +Рекомендую заменить содержимое файла на этот вариант. Готов внести изменения. + +```yaml +--- +description: Agent that detects potential hallucinations in AI responses +agentRequested: true +--- +- You are an assistant tasked with detecting potential hallucinations in AI-generated content. +- Analyze both code and text for hallucinations. +- Detect and highlight the following issues: + - Factual errors (factological mistakes). + - Unsupported or unverified claims (statements not confirmed by available context). + - Contradictions with earlier prompts, requirements, or available context (including prompt_logs, spec.md, README.md, or any other accessible files). + - Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation. +- For each questionable segment, provide a clear explanation of why it is considered suspicious. +- Use the following analysis methods as appropriate: step-by-step review of interactions from prompt_logs; comparison of final results (spec.md, README.md) against expectations. +- Output your analysis as a markdown report with exactly these sections: + - Detected Hallucinations + - Justifications + - Recommendations +``` + +--- + +**User** + +Review the current role for lexical and structural issues. Identify inaccurate terms or formatting problems (e.g. punctuation or wording), and suggest corrections. + +--- + +**Cursor** + +План: +1. Проверить терминологию и лексику на точность. +2. Проверить структуру и форматирование (пункты, заглавные буквы, точки). +3. Предложить исправления. + +Анализ: + +1. Термин "factological mistakes" — некорректен, правильнее "factual errors". +2. В списке секций отчёта используются точки (например, "Detected Hallucinations."), что не соответствует стандарту оформления заголовков разделов. +3. В списке методов анализа: "Step-by-step review of interactions from prompt_logs." — лучше без точки, как и в других пунктах. +4. В пункте "Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation." — формулировка корректна. +5. В целом, структура соответствует требованиям, но оформление списков и секций требует корректировки. + +Корректировки: + +- Убрать точки в названиях секций отчёта. +- Исправить "factological mistakes" на "factual errors". +- Убрать точки в пунктах списков, если это не завершённое предложение. +- Проверить единообразие заглавных букв. + +Исправленный фрагмент: + +```yaml +- Detect and highlight the following issues: + - Factual errors + - Unsupported or unverified claims (statements not confirmed by available context) + - Contradictions with earlier prompts, requirements, or available context (including prompt_logs, spec.md, README.md, or any other accessible files) + - Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation +// ... existing code ... +- Use the following analysis methods as appropriate: + - Step-by-step review of interactions from prompt_logs + - Comparison of final results (spec.md, README.md) against expectations +- Output your analysis as a markdown report with exactly these sections: + - Detected Hallucinations + - Justifications + - Recommendations +``` + +Рекомендации: +- Использовать только корректные термины (factual errors). +- Не ставить точки в названиях секций и пунктов списков, если это не завершённое предложение. +- Соблюдать единообразие оформления списков и заголовков. + +```yaml +- Detect and highlight the following issues: + - Factual errors + - Unsupported or unverified claims (statements not confirmed by available context) + - Contradictions with earlier prompts, requirements, or available context (including prompt_logs, spec.md, README.md, or any other accessible files) + - Mentions of APIs, methods, or links that do not exist in the codebase or referenced documentation +// ... existing code ... +- Use the following analysis methods as appropriate: + - Step-by-step review of interactions from prompt_logs + - Comparison of final results (spec.md, README.md) against expectations +- Output your analysis as a markdown report with exactly these sections: + - Detected Hallucinations + - Justifications + - Recommendations +``` + diff --git a/prompt_logs/hallucinate_alert_role_use_case.md b/prompt_logs/hallucinate_alert_role_use_case.md new file mode 100644 index 0000000..ef6f4be --- /dev/null +++ b/prompt_logs/hallucinate_alert_role_use_case.md @@ -0,0 +1,89 @@ +# Анализ README.md на галлюцинации +_Exported on 7/22/2025 at 22:18:15 GMT+3 from Cursor (1.2.4)_ + +--- + +**User** + +@hallucination_checker.mdc + +--- + +**Cursor** + +# Анализ потенциальных галлюцинаций в AI-сгенерированном контенте + +## Detected Hallucinations + +### 1. Конкретная ссылка на GitHub репозиторий +**Файл:** README.md, строка 17 +```markdown +git clone https://github.com/thinknetica/workshop_ruby_dev_with_ai.git +``` + +### 2. Отсутствие реальной реализации функций +**Файлы:** spec.md и README.md +Описание API эндпоинтов и структуры БД, которые не реализованы в текущем проекте: +- `/api/users` - список пользователей +- `/api/chats` - список чатов +- Таблицы `users`, `repositories`, `chats`, `messages` и др. + +### 3. Преждевременные утверждения о функциональности +**Файл:** README.md, раздел "Основные функции" +```markdown +- Вход через GitHub OAuth (только с правами на приватные репозитории) +- Автоматическое создание чатов по общим приватным репозиториям +``` + +## Justifications + +### 1. Неподтверждённая ссылка на репозиторий +Ссылка `https://github.com/thinknetica/workshop_ruby_dev_with_ai.git` представлена как факт, но не может быть проверена по доступному контексту. В project_layout нет информации о настоящем URL репозитория. + +### 2. Противоречие между спецификацией и реальностью +Анализ структуры проекта показывает базовое Rails приложение без реализованных моделей, контроллеров и API для чат-функциональности. Однако в spec.md и README.md описываются детальные схемы API и БД, как будто они уже существуют. + +### 3. Преждевременные заявления о возможностях +В webinar_2_logs.md указано: "тестов не найдено (0 runs, 0 assertions) — структура тестов есть, но сами тесты отсутствуют", что противоречит утверждениям в README о наличии функциональности. + +## Recommendations + +### 1. Исправить ссылку на репозиторий +Заменить конкретную ссылку на GitHub на заглушку или корректный URL: +```markdown +git clone +cd workshop_ruby_dev_with_ai +``` + +### 2. Разделить спецификацию и текущее состояние +Чётко разграничить в документации: +- Что планируется реализовать (спецификация) +- Что уже реализовано (текущее состояние проекта) + +### 3. Добавить disclaimer в README +Включить в README информацию о том, что проект находится в стадии разработки: +```markdown +⚠️ **Проект в разработке** - описанная функциональность пока не реализована +``` + +### 4. Перенести техническую спецификацию +Переместить детальные схемы API и БД из README в отдельный раздел spec.md с пометкой "Планируемая архитектура". + +```markdown +git clone https://github.com/thinknetica/workshop_ruby_dev_with_ai.git +``` + +```markdown +- Вход через GitHub OAuth (только с правами на приватные репозитории) +- Автоматическое создание чатов по общим приватным репозиториям +``` + +```markdown +git clone +cd workshop_ruby_dev_with_ai +``` + +```markdown +⚠️ **Проект в разработке** - описанная функциональность пока не реализована +``` + diff --git a/spec.md b/spec.md index ad1a325..7aa0e11 100644 --- a/spec.md +++ b/spec.md @@ -241,4 +241,18 @@ ### Мобильная версия - Меню чатов — выпадающее/выезжающее - Чат — на весь экран, адаптивные элементы -- Кнопка профиля и переключатель темы — в меню \ No newline at end of file +- Кнопка профиля и переключатель темы — в меню + +--- + +## 12. Выводы по анализу галлюцинаций + +### Обнаруженные проблемы +На основе анализа роли `hallucination_checker` выявлены следующие галлюцинации в документации: + +1. **Неподтверждённые ссылки**: Конкретная ссылка на GitHub репозиторий представлена как факт без возможности верификации +2. **Преждевременные утверждения**: Функциональность описана как реализованная, хотя проект находится в стадии базовой настройки +3. **Противоречия с реальностью**: Детальные API схемы и структуры БД описаны как существующие, но отсутствуют в кодовой базе + +### Статус проекта +⚠️ **Проект в разработке** — описанная в разделах 1-11 функциональность представляет планируемую архитектуру и требования, а не текущее состояние реализации. \ No newline at end of file