Skip to content

refactor(assessment): Merge assessment_run columns - #1235

Closed
vprashrex wants to merge 2 commits into
mainfrom
refactor/merge-assessment-run
Closed

vprashrex wants to merge 2 commits into
mainfrom
refactor/merge-assessment-run

Conversation

@vprashrex

@vprashrex vprashrex commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Closes #PLEASE_TYPE_ISSUE_NUMBER

Summary

  • Before: assessment_run was a 1:N child, causing redundancy due to the console no longer offering multi-config submission.
  • Now: The flow integrates assessment_run columns into assessment, resulting in a 1:1 relationship.
  • Added seven run-only columns to assessment.
  • Backfilled data from assessment_run while keeping it and application code untouched.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Migration compiles offline (alembic upgrade 085:086 --sql)
  • Run uv run alembic upgrade head against a dev DB, then downgrade -1, then upgrade head
  • Verify backfill on dev: SELECT COUNT(*) FROM assessment WHERE config_id IS NULL AND method <> 'RESPONSE' returns 0

Notes

Follow-up PR (not this one): switch crud/services/celery/routes from AssessmentRun to the new assessment columns, delete the dead /assessment/runs* routes, rename assessment_run to assessment_run_legacy, and drop it after a release cycle.

Original PR description

Issue

Closes #PLEASE_TYPE_ISSUE_NUMBER

Summary

assessment_run was built as a 1:N child so one submission could fan out to up to four configs. The console no longer offers multi-config submission and the API-client path always creates exactly one execution, so the tables are 1:1 in every environment (prod: 334 assessments, 334 runs, 0 duplicates) and the child is redundant.

This PR is the additive half of folding assessment_run into assessment:

  • Adds the seven run-only columns to assessment: config_id, config_version, total_items, batch_job_id, execution, post_processing_config, error_message. All nullable, no server default, so ADD COLUMN is catalog-only (no rewrite, no long lock).
  • Adds FKs to config and batch_job (ON DELETE SET NULL) plus idx_assessment_config and a partial idx_assessment_batch_job, mirroring the indexes on assessment_run.
  • Backfills from assessment_run in one statement guarded by config_id IS NULL, so a re-run copies only what is missing.
  • Leaves assessment_run and all application code untouched. Current prod code keeps reading and writing the child table; the new columns are inert until the follow-up PR switches reads/writes and drops the child.

No code change, no model change, no API contract change. Safe to deploy independently.

Checklist

  • Migration compiles offline (alembic upgrade 085:086 --sql)
  • Run uv run alembic upgrade head against a dev DB, then downgrade -1, then upgrade head
  • Verify backfill on dev: SELECT COUNT(*) FROM assessment WHERE config_id IS NULL AND method <> 'RESPONSE' returns 0

Notes

Follow-up PR (not this one): switch crud/services/celery/routes from AssessmentRun to the new assessment columns, delete the dead /assessment/runs* routes, rename assessment_run to assessment_run_legacy, and drop it after a release cycle.

Additive expand step toward folding the 1:1 assessment_run child into
its parent. Adds the seven run-only columns to assessment (nullable, no
table rewrite), backfills them from assessment_run, and leaves
assessment_run untouched so deployed code keeps working. The code
switch and the child-table drop follow in a separate PR.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ready-for-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: ProjectTech4DevAI/kaapi-backend/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5762b1f9-4e93-4746-8896-849ebef0c68a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the title feat(assessment): copy assessment_run columns onto assessment (expand step) refactor(assessment): Merge assessment_run columns Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

OpenAPI changes   🔴 11 breaking changes

Caution

Downstream consumers may need an update before merging.

Breaking changes  ·  11
Method Path Change
🔴 GET /api/v1/assessment/assessments api path removed without deprecation
🔴 GET /api/v1/assessment/assessments/{assessment_id} api path removed without deprecation
🔴 GET /api/v1/assessment/assessments/{assessment_id}/results api path removed without deprecation
🔴 POST /api/v1/assessment/assessments/{assessment_id}/retry api path removed without deprecation
🔴 GET /api/v1/assessment/runs api path removed without deprecation
🔴 POST /api/v1/assessment/runs api path removed without deprecation
🔴 GET /api/v1/assessment/runs/{run_id} api path removed without deprecation
🔴 PATCH /api/v1/assessment/runs/{run_id}/post-processing api path removed without deprecation
🔴 GET /api/v1/assessment/runs/{run_id}/results api path removed without deprecation
🔴 POST /api/v1/assessment/runs/{run_id}/resume api path removed without deprecation
🔴 POST /api/v1/assessment/runs/{run_id}/retry api path removed without deprecation
Full changelog  ·  33
Method Path Change
🔴 GET /api/v1/assessment/assessments api path removed without deprecation
🔴 GET /api/v1/assessment/assessments/{assessment_id} api path removed without deprecation
🔴 GET /api/v1/assessment/assessments/{assessment_id}/results api path removed without deprecation
🔴 POST /api/v1/assessment/assessments/{assessment_id}/retry api path removed without deprecation
🔴 GET /api/v1/assessment/runs api path removed without deprecation
🔴 POST /api/v1/assessment/runs api path removed without deprecation
🔴 GET /api/v1/assessment/runs/{run_id} api path removed without deprecation
🔴 PATCH /api/v1/assessment/runs/{run_id}/post-processing api path removed without deprecation
🔴 GET /api/v1/assessment/runs/{run_id}/results api path removed without deprecation
🔴 POST /api/v1/assessment/runs/{run_id}/resume api path removed without deprecation
🔴 POST /api/v1/assessment/runs/{run_id}/retry api path removed without deprecation
🟢 — — removed the schema APIResponse_AssessmentPublic_
🟢 — — removed the schema APIResponse_AssessmentResponse_
🟢 — — removed the schema APIResponse_AssessmentRunPublic_
🟢 — — removed the schema APIResponse_AssessmentRunResponse_
🟢 — — removed the schema APIResponse_list_AssessmentPublic__
🟢 — — removed the schema APIResponse_list_AssessmentRunPublic__
🟢 — — removed the schema APIResponse_list_dict_str__Any___
🟢 — — removed the schema AssessmentAttachment
🟢 — — removed the schema AssessmentExecutionPublic
🟢 — — removed the schema AssessmentPublic
🟢 — — removed the schema AssessmentResponse
🟢 — — removed the schema AssessmentRunCounts
🟢 — — removed the schema AssessmentRunCreate
🟢 — — removed the schema AssessmentRunPublic
🟢 — — removed the schema AssessmentRunResponse
🟢 — — removed the schema AssessmentRunStat
🟢 — — removed the schema AssessmentRunSummary
🟢 — — removed the schema InputBinding
🟢 — — removed the schema RunExecution
🟢 — — removed the schema Stage
🟢 — — removed the schema StageStatus
🟢 — — a breaking change was detected but the version is still 0.5.0

main ↔ 246270ec · generated by oasdiff

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ve legacy RUN pipeline

- Merged AssessmentRun into Assessment, simplifying the data model and removing unnecessary complexity.
- Updated AssessmentExecution to encapsulate execution state and related data, replacing BatchRunState.
- Refactored error handling and result file management to streamline error reporting and file uploads.
- Adjusted API routes and documentation to reflect the removal of the RUN method and the focus on BATCH and RESPONSE methods.
- Enhanced type annotations and improved code readability across various service modules.
- Updated submission handling to ensure consistent execution state management and error handling.
@vprashrex vprashrex closed this Oct 6, 2026
@vprashrex
vprashrex deleted the refactor/merge-assessment-run branch October 6, 2026 18:52
@vprashrex

Copy link
Copy Markdown
Collaborator Author

Superseded by the renamed branch; see the new draft PR on feat/assessment-consolidation.

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