Skip to content

Add blueprint workflow CLI commands#385

Merged
txmed82 merged 1 commit into
masterfrom
codex/blueprint-workflow-cli
Jun 4, 2026
Merged

Add blueprint workflow CLI commands#385
txmed82 merged 1 commit into
masterfrom
codex/blueprint-workflow-cli

Conversation

@txmed82

@txmed82 txmed82 commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • add materialize-blueprints CLI command for persisted release-ready blueprints
  • add export-blueprint-release-summary CLI command for audit JSON output
  • add CLI smoke test covering validate -> materialize -> release summary export
  • use unbounded blueprint scans in existing blueprint export/validation commands

Tests

  • .venv/bin/python -m pytest tests/test_cli_synthetic.py -q
  • .venv/bin/python -m ruff check src/casecrawler/cli.py tests/test_cli_synthetic.py
  • .venv/bin/python -m pytest tests/test_cli_synthetic.py tests/test_blueprint_release_summary.py tests/test_blueprint_materializer.py tests/test_blueprint_storage.py tests/test_blueprint_export.py -q
  • .venv/bin/python -m pytest -q -m 'not optional_backend and not network and not slow'

Summary by CodeRabbit

Release Notes

  • New Features

    • Added materialize-blueprints CLI command to generate synthetic record scaffolds from blueprints with optional release-ready validation
    • Added export-blueprint-release-summary CLI command to output blueprint release readiness summary in JSON format
  • Changes

    • export-blueprints and validate-blueprints commands now retrieve all persisted blueprints (previously limited to fixed threshold)
  • Tests

    • Added integration test for blueprint materialization and release summary export workflow

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds two new CLI commands for blueprint materialization and release auditing. The materialize-blueprints command loads persisted validation reports and materializes blueprints into synthetic record scaffolds. The export-blueprint-release-summary command exports a release-readiness audit. Existing export-blueprints and validate-blueprints commands are updated to use unbounded blueprint listing.

Changes

Blueprint CLI Enhancement

Layer / File(s) Summary
Unbounded blueprint retrieval in existing commands
src/casecrawler/cli.py
export-blueprints and validate-blueprints now pass limit=None to store.list_blueprints(...) instead of a fixed large limit.
New materialization and release summary export commands
src/casecrawler/cli.py
Added materialize-blueprints command that loads stored validation reports and materializes each blueprint with BlueprintMaterializer, supporting --require-release-ready and converting materialization errors to click exceptions. Added export-blueprint-release-summary command that writes JSON release audit summaries via write_blueprint_release_summary(...).
Test fixture update and CLI integration test
tests/test_cli_synthetic.py
Imports JudgeReport; updates _blueprint_cli_result fixture to include clinical_reasoning_targets; adds new integration test that seeds a dataset with blueprint and judge report, executes the full validate→materialize→export CLI workflow, and verifies command outcomes, exported summary counts, and stored record metadata.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • txmed82/case-crawler#383: Introduces BlueprintMaterializer.materialize(...) which is directly used by the new materialize-blueprints command.
  • txmed82/case-crawler#384: Implements write_blueprint_release_summary(...) and build_blueprint_release_summary(...) that power the new export-blueprint-release-summary command.
  • txmed82/case-crawler#380: Adds validate-blueprints and BlueprintValidator that persist BlueprintValidationReports, which the new materialize-blueprints command reads and uses.

Poem

🐰 A blueprint takes shape with a hop and a bound,
Materialize, validate, export all around!
With reports tucked away, now we summon release,
The CLI hops forward, no limits decreased! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add blueprint workflow CLI commands' directly and clearly summarizes the main change: two new CLI commands (materialize-blueprints and export-blueprint-release-summary) and updates to existing blueprint commands.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/blueprint-workflow-cli

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/casecrawler/cli.py`:
- Around line 2076-2080: The CLI is calling DatasetStore.list_blueprints(...)
with limit=None which forces an eager load of every blueprint into memory
(blueprints) and makes export-blueprints / validate-blueprints /
materialize-blueprints OOM-prone; instead either (A) change the DatasetStore API
to provide a streaming/paginated iterator (e.g., stream_blueprints or make
list_blueprints yield an iterator) and consume that here, or (B) replace the
single call with a paginated loop that repeatedly calls list_blueprints with a
fixed batch size and a cursor/offset until no more results, processing each
batch as you go; update the CLI paths (export-blueprints, validate-blueprints,
materialize-blueprints) to use the streaming/paginated approach rather than
limit=None so blueprints are processed in bounded batches.
- Around line 2164-2176: The current loop calls materializer.materialize per
blueprint and may persist partial results before a later blueprint fails
release-readiness; first preflight all selected blueprints by calling
store.get_blueprint_validation_report(...) and invoking
materializer.materialize(...) in a dry-run/preflight mode (or call a
validation-only API) for each blueprint to detect
ValueError/require_release_ready failures, raising click.ClickException
immediately if any fail; only after all blueprints pass the preflight, run a
second loop that calls materializer.materialize(...) for real (the existing
call) to perform writes. Ensure you reference the existing symbols blueprint,
store.get_blueprint_validation_report, materializer.materialize, and the
require_release_ready flag when implementing the two-phase
preflight-then-materialize change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a10abd2-ff0f-424f-a5af-7e7483936752

📥 Commits

Reviewing files that changed from the base of the PR and between d32acd1 and 8ab7b96.

📒 Files selected for processing (2)
  • src/casecrawler/cli.py
  • tests/test_cli_synthetic.py

Comment thread src/casecrawler/cli.py
Comment on lines 2076 to 2080
blueprints = store.list_blueprints(
dataset_id=dataset_id,
cohort_plan_id=cohort_plan_id,
limit=1_000_000,
limit=None,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Unbounded scans still eagerly load every blueprint into memory.

DatasetStore.list_blueprints() returns a full Python list, so limit=None turns these CLI paths into all-at-once loads. On large datasets, export-blueprints, validate-blueprints, and materialize-blueprints can become OOM-prone or stall before doing useful work. If the intent is truly unbounded processing, this needs a paged/streaming store API rather than removing the cap at the call site.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/casecrawler/cli.py` around lines 2076 - 2080, The CLI is calling
DatasetStore.list_blueprints(...) with limit=None which forces an eager load of
every blueprint into memory (blueprints) and makes export-blueprints /
validate-blueprints / materialize-blueprints OOM-prone; instead either (A)
change the DatasetStore API to provide a streaming/paginated iterator (e.g.,
stream_blueprints or make list_blueprints yield an iterator) and consume that
here, or (B) replace the single call with a paginated loop that repeatedly calls
list_blueprints with a fixed batch size and a cursor/offset until no more
results, processing each batch as you go; update the CLI paths
(export-blueprints, validate-blueprints, materialize-blueprints) to use the
streaming/paginated approach rather than limit=None so blueprints are processed
in bounded batches.

Comment thread src/casecrawler/cli.py
Comment on lines +2164 to +2176
for blueprint in blueprints:
validation_report = store.get_blueprint_validation_report(
blueprint.blueprint_id
)
try:
materializer.materialize(
blueprint,
validation_report=validation_report,
store=store,
require_release_ready=require_release_ready,
)
except ValueError as exc:
raise click.ClickException(str(exc)) from exc

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid partial materialization on a later release-readiness failure.

Because records are persisted inside the same loop that can still raise on a later blueprint, this command can exit non-zero after already saving a partial dataset. Preflight the selected blueprints first, then materialize once the whole batch is known to be eligible.

💡 One way to make the command fail before any writes
     materializer = BlueprintMaterializer()
+    validation_reports = {
+        blueprint.blueprint_id: store.get_blueprint_validation_report(blueprint.blueprint_id)
+        for blueprint in blueprints
+    }
+
+    if require_release_ready:
+        for blueprint in blueprints:
+            report = validation_reports[blueprint.blueprint_id]
+            if report is None or not report.research_release_ready:
+                raise click.ClickException(
+                    "Blueprint must be research release ready before materialization."
+                )
+
     materialized_count = 0
     for blueprint in blueprints:
-        validation_report = store.get_blueprint_validation_report(
-            blueprint.blueprint_id
-        )
         try:
             materializer.materialize(
                 blueprint,
-                validation_report=validation_report,
+                validation_report=validation_reports[blueprint.blueprint_id],
                 store=store,
                 require_release_ready=require_release_ready,
             )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/casecrawler/cli.py` around lines 2164 - 2176, The current loop calls
materializer.materialize per blueprint and may persist partial results before a
later blueprint fails release-readiness; first preflight all selected blueprints
by calling store.get_blueprint_validation_report(...) and invoking
materializer.materialize(...) in a dry-run/preflight mode (or call a
validation-only API) for each blueprint to detect
ValueError/require_release_ready failures, raising click.ClickException
immediately if any fail; only after all blueprints pass the preflight, run a
second loop that calls materializer.materialize(...) for real (the existing
call) to perform writes. Ensure you reference the existing symbols blueprint,
store.get_blueprint_validation_report, materializer.materialize, and the
require_release_ready flag when implementing the two-phase
preflight-then-materialize change.

@txmed82 txmed82 merged commit d0edaad into master Jun 4, 2026
4 checks passed
@txmed82 txmed82 deleted the codex/blueprint-workflow-cli branch June 4, 2026 02:27
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