8000 Update ai project and scenario schema to include archive property by gabriellui1 · Pull Request #7688 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

gabriellui1
Copy link
Collaborator
@gabriellui1 gabriellui1 commented Sep 9, 2024

The schema is auto-generated from AI Hackstack repo.
https://github.com/codecombat/ai/pull/287
fixes ENG-1080

Summary by CodeRabbit

  • New Features

    • Introduced an archived property in both AI Project and AI Scenario schemas to track archived items.
    • Added a source property in the AI Document schema for enhanced data tracking.
  • Improvements

    • Simplified the wrongChoices and isReadyToReview properties in the AI Project schema for better clarity.
    • Updated the initialActionQueue property in the AI Scenario schema for improved item definition.
    • Enhanced the safetyValidation property in the AI Chat Message schema for clearer context.
  • Validation Updates

    • Expanded required fields in both the AI Project and AI Scenario schemas to include the new archived property, enforcing stricter validation rules.

Copy link
Contributor
coderabbitai bot commented Sep 9, 2024

Walkthrough

The changes introduced in this pull request involve updates to the AIProjectSchema, AIScenarioSchema, AIChatMessageSchema, AIDocumentSchema, and AIModelSchema in the application. Key modifications include the addition of a new archived boolean property to both the AIProjectSchema and AIScenarioSchema, indicating whether a project or scenario is archived instead of deleted. Existing properties have been updated for clarity, and required fields have been modified accordingly. The AIChatMessageSchema has seen changes to the safetyValidation section, while AIDocumentSchema has introduced a new source property.

Changes

Files Change Summary
app/schemas/models/ai_project.schema.js, app/schemas/models/ai_scenario.schema.js Added archived property (boolean) to both schemas; modified existing properties for clarity; updated required fields to include archived.
app/schemas/models/ai_chat_message.schema.js Updated safetyValidation title and description; added "Drugs" to failureType enum; updated descriptions for failureType and failureDetails.
app/schemas/models/ai_document.schema.js Added source property (object) with several sub-properties; updated last modified timestamp.
app/schemas/models/ai_model.schema.js Updated last modified timestamp; no changes to properties or required fields.

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
Loading

Assessment against linked issues

Objective Addressed Explanation
Move ai_scenario and project deletion to archive (ENG-1080)
Add a boolean in the schema called archived (ENG-1080)
Set archived to true when deleting project/scenario (ENG-1080) The implementation of the deletion route is not confirmed.
Ensure GET requests only send unarchived data (ENG-1080) The changes do not address filtering of archived data in GET requests.

Poem

🐇 In the garden where projects bloom,
Archiving keeps them from doom.
With a flick of a tail, they’re saved with care,
No need for deletion, just a hop and a stare.
So here’s to the changes, bright and new,
Our tales of scenarios will now ring true! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 98a8698 and 3c71cf6.

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 simplified wrongChoices and isReadyToReview 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' },
Copy link
Contributor

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',
Copy link
Contributor
10000

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?

Copy link
Contributor
@mrfinch mrfinch left a 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

@gabriellui1
Copy link
Collaborator Author

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 archived: true property

@mrfinch mrfinch force-pushed the gabriel/archive-ai-scenario-project branch from 653bfd5 to f77872f Compare October 3, 2024 16:16
Copy link
Contributor
@coderabbitai coderabbitai bot left a 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: New source property added.

The addition of the source property to the AIDocumentSchema 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 of archived 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 changes

The changes to the AIProjectSchema successfully implement the archival feature and improve the overall structure of the schema. Key points:

  1. The wrongChoices property has been clarified and structured better.
  2. The isReadyToReview property title has been updated for clarity.
  3. A new archived boolean property has been added to support the archival system.
  4. Required fields have been updated to include isReadyToReview and archived.

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

📥 Commits

Files that changed from the base of the PR and between 653bfd5 and f77872f.

📒 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 new source property.

The changes to the AIDocumentSchema have been implemented correctly and align well with the PR objectives. The addition of the source 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 the AIDocumentSchema.

app/schemas/models/ai_project.schema.js (3)

47-57: Approve changes to wrongChoices 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 to isReadyToReview 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 and archived 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:

  1. Implement a data migration script to update existing documents with default values for these new required fields.
  2. Temporarily make these fields optional during the migration period.
  3. 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 in safetyValidation 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 to failureDetails 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:

  1. Improving clarity in property descriptions, focusing on message validation rather than generation.
  2. Expanding the failureType enum to include "Drugs", enhancing the coverage of potential safety issues.
  3. 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: Enhanced failureType property with additional validation category.

The changes to the failureType property improve the schema by:

  1. Updating the description to accurately reflect the validation context.
  2. 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:

@mrfinch mrfinch merged commit d95da70 into master Oct 3, 2024
2 checks passed
@mrfinch mrfinch deleted the gabriel/archive-ai-scenario-project branch October 3, 2024 16:37
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.

2 participants
0