← Back to Pull requests

feat(deploy): report each deploy step with its duration #338

Closed
unknown closed this pull request without merging on Oct 07, 2026 09:39 UTC
View on GitHub
unknown unknown commented on Oct 06, 2026 12:13 UTC
Author

Linked issue

n/a. Follows the deploy output investigation for the pdp-control-plane production deploy.

Summary

The pdp-control-plane production deploy on 2026-10-05 (run 37316359545) printed nothing for 4 min 25 s. In that time Composer assembled each service one after another (about 223 s for the Console service, whose runtime dependencies are traced), then checked 53 env vars (about 38 s). The final line, Done: 32 succeeded (66.0s), is the deploy engine's apply time only. The whole step took 9 min 35 s.

This PR makes prisma deploy report each step as it starts and finishes, with how long it took, and end with the real total.

What changed

  • The deploy operation takes an onEvent sink, as destroy and dev already do. It reports a step-started and a step-finished event for each step:

  • - load config and app
    - assemble services, with one child step per service
    - connect to project and branch
    - check environment variables
    - plan and apply
    - record result
  • Each finished step carries outcome, durationMs and the counts it measured. When a step fails, it and the steps around it finish as failed. The record step still runs. An onEvent that throws does not fail the deploy.

  • To get the counts:

  • - An assemble gets an optional report callback (AssembleInput.report), like preflight's. Core never reads what goes through it. The node build adapter reports form, filesTraced, filesStaged and bytesStaged, from the trace and copy it already does. Other adapters report nothing, and a new one needs no core change. These fields belong to the adapter and are not a stable format.
    - An extension's preflight gets an optional report callback. The Prisma Cloud target reports checked, filled and missing.
  • prisma deploy maps the events to the CLI engine's step-started and step-finished events (with id and parentId), so people see each step and json mode streams them as NDJSON. After a successful deploy it reports an endpoint event per service URL.

  • The deploy operation measures the whole deploy and returns it as durationMs on its result, so library callers get the total too. The CLI prints that value. The final line now names the stage and the real total: Deployed shop to production in 9m 35s. The json result has a new durationMs field next to summary. Nothing was removed from the result.

  • The record step starts and finishes in one place, together with closing the reporting sessions and writing the run report. It runs after a success, a failure or a thrown error.

  • The deploying guide and the skill describe the new output.
  • No change is needed in @prisma/cli-engine (prisma/prisma-cli). The engine's human renderer prints only the step text, so a finished step puts its duration in the text, for example assemble console (3m 42s). The number is also in data.durationMs.

    Example output

    A person in a terminal sees this, with the engine's own output between plan and apply lines as today:

    ▸ load config and app
    ✔ load config and app (1.1s)
    ▸ assemble services
    ▸ assemble bloom.service
    ✔ assemble bloom.service (200ms)
    ▸ assemble console
    ✔ assemble console (3m 42s)
    ✔ assemble services (3m 42s)
    ▸ connect to project and branch
    ✔ connect to project and branch (2.0s)
    ▸ check environment variables
    ✔ check environment variables (38.2s)
    ▸ plan and apply
    ✔ plan and apply (1m 31s)
    ▸ record result
    ✔ record result (10.3s)
    console: https://afts84u2cdv70w8jbcyv6fh3.ewr.prisma.build
    ✔ Deployed pdp-control-plane-console to production in 6m 5s.
    

    In json mode, which is also what CI gets because stdout is not a terminal:

    {"kind":"step-started","step":"assemble console","id":"deploy.assemble.console","parentId":"deploy.assemble",...}
    {"kind":"step-finished","step":"assemble console (3m 42s)","id":"deploy.assemble.console","outcome":"ok","data":{"durationMs":221780,"form":"directory","filesTraced":975,"filesStaged":885,"bytesStaged":32505856},...}
    {"kind":"step-finished","step":"check environment variables (38.2s)","id":"deploy.preflight","outcome":"ok","data":{"durationMs":38170,"checked":53,"filled":0,"missing":0},...}
    {"kind":"endpoint","name":"console","url":"https://afts84u2cdv70w8jbcyv6fh3.ewr.prisma.build",...}
    {"kind":"result","envelope":{"ok":true,"commandId":"deploy","result":{"summary":{...},"durationMs":364600},...}}
    

    The timings above are from the 2026-10-05 run, replayed through the test CLI. No real deploy was run for this PR.

    What is not included

  • Plan counts. Alchemy plans and applies in one child process, and Composer only sees that process from the outside. Splitting plan from apply, or counting creates, updates, replaces and deletes, needs a hook in alchemy. So plan and apply are one step, with no counts.

  • Counts on a failed preflight. The step finishes as failed without counts. The error message already lists each missing name.

  • Connect data. The project and branch ids belong to the extension's container, which the CLI treats as opaque. The step has only its duration.

  • The Next.js build adapter reports nothing yet. Its services show only the duration.
  • Related

    A separate cloud-deploy-action PR streams the CLI's output line by line instead of buffering it. With both, these events appear in the CI log as they happen.

    Testing performed

  • pnpm build && pnpm typecheck && pnpm lint && pnpm test pass (66 test tasks, 0 failures; @internal/cli 226 pass, @internal/prisma-cloud 392 pass, @internal/node 35 pass).

  • pnpm test:scripts, pnpm lint:deps, test:types, check:floor-imports, check:cli-engine-pin, check:skill-packaging and check:family-static-graph pass.

  • New tests:

  • - The deploy operation reports every step in order, each finished step has a duration, and the assemble and preflight data arrive.
    - A failing assemble closes the service step and the assemble step as failed, then records the result.
    - An onEvent that throws does not fail the deploy.
    - prisma deploy renders steps with durations, the endpoint line and the total in human mode, and streams ids, parentId, data, endpoints and durationMs in json mode.
    - The node adapter reports through report for both of its build shapes, and the assemble event carries what the adapter reported. A type test checks the two report callbacks and that Bundle carries no measurements.
    - The record step closes after a success, a failure and a thrown error, and the operation returns the total.
    - The Prisma Cloud preflight reports checked, filled and missing, and a fill that lost a 409 race is not counted.

    Checklist

  • All commits are signed off (git commit -s) per the DCO.

  • I read CONTRIBUTING.md and the change is scoped to one logical concern.

  • The PR title is a conventional commit.

  • Tests are updated.
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: wmadden-electric Review duration: 1285m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #338"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%