-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Update ai project and scenario schema to include archive property #7688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes introduced in this pull request involve updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant Database
User->>API: Request to delete project/scenario
API->>Database: Set archived to true
Database-->>API: Confirm archival
API-->>User: Confirm project/scenario archived
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- app/schemas/models/ai_project.schema.js (2 hunks)
- app/schemas/models/ai_scenario.schema.js (2 hunks)
Additional comments not posted (7)
app/schemas/models/ai_project.schema.js (4)
46-46
: LGTM!The simplification of the
wrongChoices
property is approved. The change does not affect the functionality as the property type is still an array.
47-47
: LGTM!The simplification of the
isReadyToReview
property is approved. The change does not affect the functionality as the property type is still a boolean.
48-48
: LGTM!The addition of the
archived
property to the schema is approved. This change is necessary to support the archival of projects as per the PR objectives.
51-59
: LGTM!The update to the required fields for the schema is approved. This change ensures that the new
archived
property and the simplifiedwrongChoices
andisReadyToReview
properties are required fields in the schema, which is consistent with the PR objectives.app/schemas/models/ai_scenario.schema.js (3)
52-52
: LGTM!The simplification of the
coverImage
property is approved. The change does not affect the functionality as the property type is still a string.
59-59
: LGTM!The addition of the
archived
property to the schema is approved. This change is necessary to support the archival of scenarios as per the PR objectives.
69-69
: LGTM!The update to the required fields for the schema is approved. This change ensures that the new
archived
property is a required field in the schema, which is consistent with the PR objectives.
type: 'boolean', | ||
description: 'Whether this project is ready for review by the teacher', | ||
}, | ||
wrongChoices: { title: 'Wrong Choices', type: 'array' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why has wrongChoices schema changed? Any ideas?
'actionQueue', | ||
'wrongChoices', | ||
'isReadyToReview', | ||
'archived', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are old project/scenarios fine with this change? Or do they fail on saving to db?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the script that marks archived as false in coco-server code, not here in the client
There is no need for script to add archived as false now as the backend code searches for ai projects/scenarios that doesn't have the |
653bfd5
to
f77872f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
app/schemas/models/ai_document.schema.js (1)
Line range hint
15-32
: LGTM: Newsource
property added.The addition of the
source
property to theAIDocumentSchema
is a valuable enhancement. It provides a structured way to capture the origin and type of AI documents, which aligns well with the project objectives. Making it a required field ensures consistency across all documents.A minor suggestion for improvement:
Consider adding a brief description or example for the
i18n
property to clarify its usage, especially for developers who might not be familiar with the internationalization format.For example:
- i18n: { type: 'object', format: 'i18n', props: ['text'], description: 'Help translate this property' }, + i18n: { + type: 'object', + format: 'i18n', + props: ['text'], + description: 'Internationalization object for translatable properties. Example: { "en": "English text", "es": "Spanish text" }' + },This change would provide more clarity on how the
i18n
property should be used.app/schemas/models/ai_project.schema.js (2)
64-64
: Approve addition ofarchived
property, consider default value.The addition of the
archived
property aligns well with the PR objectives to implement an archival system instead of deletion for AI projects. This boolean property will allow for marking projects as archived rather than deleting them permanently.Consider adding a default value of
false
to ensure consistency across all projects. This could prevent potential issues with older projects that don't have this property set.- archived: { title: 'Archived', type: 'boolean' }, + archived: { title: 'Archived', type: 'boolean', default: false },
Line range hint
1-74
: Summary of AIProjectSchema changesThe changes to the AIProjectSchema successfully implement the archival feature and improve the overall structure of the schema. Key points:
- The
wrongChoices
property has been clarified and structured better.- The
isReadyToReview
property title has been updated for clarity.- A new
archived
boolean property has been added to support the archival system.- Required fields have been updated to include
isReadyToReview
andarchived
.These changes align well with the PR objectives. However, careful consideration is needed regarding backward compatibility and data migration for existing projects. It's recommended to implement a migration strategy and thoroughly test the impact on existing data before merging these changes.
Consider implementing a schema versioning system to handle different versions of documents in the database. This would allow for smoother transitions when making significant schema changes in the future.
app/schemas/models/ai_scenario.schema.js (1)
58-58
: LGTM: 'archived' property added as per requirements.The addition of the 'archived' boolean property aligns with the PR objectives to implement an archival system for AI scenarios.
Consider adding a description to the 'archived' property for clarity, e.g.:
- archived: { title: 'Archived', type: 'boolean' }, + archived: { title: 'Archived', type: 'boolean', description: 'Indicates whether the scenario is archived instead of active' },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- app/schemas/models/ai_chat_message.schema.js (2 hunks)
- app/schemas/models/ai_document.schema.js (1 hunks)
- app/schemas/models/ai_model.schema.js (1 hunks)
- app/schemas/models/ai_project.schema.js (2 hunks)
- app/schemas/models/ai_scenario.schema.js (3 hunks)
✅ Files skipped from review due to trivial changes (1)
- app/schemas/models/ai_model.schema.js
🔇 Additional comments (12)
app/schemas/models/ai_document.schema.js (2)
4-4
: LGTM: Timestamp updated.The updated timestamp reflects the latest changes to the schema. This is expected for an auto-generated file.
Line range hint
1-43
: Summary: Schema updated successfully with newsource
property.The changes to the
AIDocumentSchema
have been implemented correctly and align well with the PR objectives. The addition of thesource
property enhances the schema by providing a structured way to capture the origin and type of AI documents. Making it a required field ensures consistency across all documents.These changes will improve the management and traceability of AI documents within the system. The schema now provides a more comprehensive representation of AI documents, which should facilitate better organization and retrieval of information.
To ensure that these changes are consistently applied across the codebase, please run the following verification script:
This script will help identify any areas of the codebase that might need to be updated to accommodate the new
source
property in theAIDocumentSchema
.app/schemas/models/ai_project.schema.js (3)
47-57
: Approve changes towrongChoices
property, but clarification needed.The updates to the
wrongChoices
property improve the schema's clarity and structure. The addition of a title and the explicit structure for items enhance schema validation.@mrfinch: Your p 8000 revious question about why the
wrongChoices
schema changed is still relevant. Could you provide more context on the reasoning behind these changes?
60-63
: Approve minor update toisReadyToReview
property title.The change from 'Ready to Review' to 'Is Ready To Review' in the title of the
isReadyToReview
property slightly improves clarity. This update makes the property name more explicit without changing its functionality.
67-67
: Approve required fields update, but migration strategy needed.The addition of
isReadyToReview
andarchived
to the required fields aligns with the schema updates. However, this change raises concerns about backward compatibility.@mrfinch: Your previous question about the impact on old projects/scenarios is crucial. We need to ensure that existing data in the database won't fail validation with these new required fields.
To address this, consider the following:
- Implement a data migration script to update existing documents with default values for these new required fields.
- Temporarily make these fields optional during the migration period.
- Use a versioning system for the schema to handle different versions of documents.
Let's verify the potential impact:
#!/bin/bash # Description: Check for AI projects without 'isReadyToReview' or 'archived' fields # Test: Count documents without 'isReadyToReview' echo "AI Projects without 'isReadyToReview':" db.ai_projects.count({ isReadyToReview: { $exists: false } }) # Test: Count documents without 'archived' echo "AI Projects without 'archived':" db.ai_projects.count({ archived: { $exists: false } })Please review the results of this script to determine the scope of the required migration.
app/schemas/models/ai_scenario.schema.js (3)
4-4
: LGTM: Timestamp update is as expected.The update to the last modified timestamp is consistent with the auto-generated nature of this file.
73-73
: LGTM: 'priority' property formatting improved.The consolidation of the 'priority' property definition into a single line improves code readability and consistency.
76-76
: LGTM: 'archived' added to required fields, but verify backwards compatibility.The addition of 'archived' to the required fields ensures that the archival status is always specified for AI scenarios, which aligns with the PR objectives.
Please verify that this change doesn't break backwards compatibility with existing data or API consumers. Run the following script to check for any existing scenarios without the 'archived' field:
If the script returns results, consider implementing a data migration strategy or providing default values for existing scenarios.
app/schemas/models/ai_chat_message.schema.js (4)
70-72
: LGTM: Improved clarity insafetyValidation
property.The changes to the title and description of the
safetyValidation
property enhance clarity and accuracy. The new wording is more consistent with the overall purpose of the schema.
85-89
: LGTM: Consistent update tofailureDetails
description.The change to the
failureDetails
description maintains consistency with the other updates in the schema, focusing on the validation of chat messages rather than their generation. This aligns well with the overall changes and improves the clarity of the schema.
Line range hint
4-89
: Summary: Changes align well with PR objectives and enhance schema functionality.The modifications to the
AIChatMessageSchema
in this file successfully address the PR objectives by:
- Improving clarity in property descriptions, focusing on message validation rather than generation.
- Expanding the
failureType
enum to include "Drugs", enhancing the coverage of potential safety issues.- Maintaining consistency throughout the schema with regards to terminology and focus on validation.
These changes contribute to better management of AI projects and scenarios by providing a more comprehensive framework for safety validation of chat messages. The updates align with the goal of enhancing functionality and usability of the AI project and scenario management system.
79-80
: LGTM: EnhancedfailureType
property with additional validation category.The changes to the
failureType
property improve the schema by:
- Updating the description to accurately reflect the validation context.
- Adding "Drugs" as a new failure type, expanding the coverage of potential safety issues.
These improvements align well with the PR objectives of enhancing the management of AI projects and scenarios.
Please ensure that the corresponding validation logic and UI components are updated to handle the new "Drugs" failure type. Run the following script to check for potential areas that might need updates:
The schema is auto-generated from AI Hackstack repo.
https://github.com/codecombat/ai/pull/287
fixes ENG-1080
Summary by CodeRabbit
New Features
archived
property in both AI Project and AI Scenario schemas to track archived items.source
property in the AI Document schema for enhanced data tracking.Improvements
wrongChoices
andisReadyToReview
properties in the AI Project schema for better clarity.initialActionQueue
property in the AI Scenario schema for improved item definition.safetyValidation
property in the AI Chat Message schema for clearer context.Validation Updates
archived
property, enforcing stricter validation rules.