Skip to content

feat(ai): AI Draft CQL — Sprint 7.1#52

Merged
Taleef7 merged 2 commits into
mainfrom
feat/sprint7-1-ai-draft-cql
May 22, 2026
Merged

feat(ai): AI Draft CQL — Sprint 7.1#52
Taleef7 merged 2 commits into
mainfrom
feat/sprint7-1-ai-draft-cql

Conversation

@Taleef7
Copy link
Copy Markdown
Owner

@Taleef7 Taleef7 commented May 22, 2026

Summary

  • New POST /api/measures/{id}/ai/draft-cql endpoint generates a CQL skeleton from the measure's spec_json plus optional pasted OSHA/policy text.
  • Deterministic fallback template (fallbackUsed=true) when the model is unavailable — authoring is never blocked.
  • CqlTab adds an "AI Draft CQL" button that opens an OSHA-text modal; the result is pushed into Monaco with a dismissible amber review banner. Compile state resets so the user must compile before activation.
  • AI_DRAFT_CQL_GENERATED audit event is written for every call (success or fallback).

AI never decides compliance — the existing compile gate + structured CQL evaluation remain the sole source of truth.

Test plan

  • ./gradlew.bat compileJava --rerun-tasks clean
  • ./gradlew.bat test --tests "com.workwell.ai.*" passes
  • npm run lint clean (one pre-existing warning unrelated to this PR)
  • Manual: open Studio CQL tab, click "AI Draft CQL", paste OSHA text, confirm CQL appears in Monaco with banner and that Compile still gates activation

Closes #47

POST /api/measures/{id}/ai/draft-cql generates a CQL skeleton from the
measure's spec_json plus optional OSHA policy text. Returns a deterministic
fallback template (annotated TODOs, full Outcome Status define) when the
model call fails so authoring is never blocked. Audit row written with
fallbackUsed.

CqlTab adds an "AI Draft CQL" button that opens an OSHA-text modal; the
returned CQL is pushed into Monaco and surfaced with a dismissible amber
review banner. Compile state resets so the user must compile before
activation — AI never decides compliance.

Closes #47
Copilot AI review requested due to automatic review settings May 22, 2026 05:58
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workwell-measure-studio Ready Ready Preview, Comment May 22, 2026 3:47pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c3f63d94e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/src/main/java/com/workwell/ai/AiAssistService.java Outdated
Previously the version query prioritised Active status over recency, so a
newer Draft version would be skipped in favour of an older Active one.
Now orders by created_at DESC so the prompt always reflects the version
currently open in Studio.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Taleef7 Taleef7 merged commit 42c4e57 into main May 22, 2026
7 of 8 checks passed
@Taleef7 Taleef7 deleted the feat/sprint7-1-ai-draft-cql branch May 22, 2026 15:51
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.

Sprint 7.1 — AI Draft CQL: OSHA text → CQL authoring assist

2 participants