Skip to content

feat(api): a deployment's timeline, its steps and agent actions (part of #265) - #418

Merged
samuelmbabhazi merged 5 commits into
mainfrom
feat/265-deployment-timeline
Nov 22, 2026
Merged

samuelmbabhazi merged 5 commits into
mainfrom
feat/265-deployment-timeline

Conversation

@samuelmbabhazi

@samuelmbabhazi samuelmbabhazi commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #265 (step 2 of #413). This is the API half; the deployment page follows in its own pull request.

What changed

GET …/applications/{applicationId}/deployments/{deploymentId}/timeline

Requires environment.read, with a session or a scoped token, like the other deployment reads. It answers:

  • steps: the deployment's state changes, oldest first. Each has from (null for the first), to, at, and reason when it failed. They are read back from the audit log, where every change is already recorded (deployment.queued, .advanced, .failed, .cancelled, .rolled_back). Only the action, its metadata and its time are selected, never the actor or the address.
  • actions: the agent actions the deployment requested, oldest first, at most 200. They use the same safe summaries as …/agent-actions (Show the agent actions run for an application #263), without payload or raw error.
  • truncated: true when the deployment requested more actions than listed.

Build and release command output is not part of it: that needs builds (M3.3) and log collection (M6.1). SPEC says so.

Code:

  • deployments/domain/timeline.ts: pure deploymentSteps(). Unknown actions and states that are not deployment states are left out rather than guessed. A failure reason is capped at 512 characters.
  • DeploymentStepStore, implemented by PrismaDeploymentSteps, reads the audit rows in the tenant transaction.
  • AgentActions.forDeployment() and AgentActionStore.forDeployment(). The history select and mapping are shared with forApplication(), and the encrypted payload is never selected.
  • DeploymentCommands.timeline(): the same read check as get(), and the deployment is found under its own application before anything is read.

The generated openapi.json, API client and route and role matrix are updated, and SPEC describes the route.

Why

#265 is the deployment page of the design: per-step timings and a log of what happened. The audit log already records every state change with its time, and the agent actions already carry their deployment (#263). Nothing exposed them per deployment.

How it was tested

  • Unit:
    • timeline.spec.ts: pipeline order with from, a failure with its reason, a cancel and a rollback, unreadable events left out, the reason capped.
    • API unit suite: 685 passed.
  • Integration, against real PostgreSQL (deployment-timeline-http.integration.spec.ts, restricted runtime role):
    • a pipeline run gives the queued, scheduling and starting steps and its ensureNetwork action on the enrolled server, read as an environment viewer;
    • another application's deployment is left out;
    • a cancelled deployment ends at cancelled with no action;
    • outsider and member get 404, as do a deployment read under another application and an unknown one;
    • a malformed id gets 400.
  • Full integration suite: green except the 3 known PostgreSQL 18 differences, and the metrics suite, which needs Docker for VictoriaMetrics, unavailable in this sandbox. CI runs both.
  • Lint and typecheck: green.

Security considerations

  • Read-only: no new write, so no audit event.
  • It is scoped like the other deployment reads: live environment.read, then the application inside its environment, then the deployment inside its application. Anything else answers 404, without an existence leak.
  • Audit rows are filtered to this deployment's state actions, inside the tenant transaction under row security. Actors, IP addresses and other events never leave the audit module's reach.
  • Agent actions use the existing safe summaries: no payload, no raw error. Secrets cannot appear, because payloads are never selected.

Summary by CodeRabbit

  • New Features
    • Added an endpoint to view a deployment’s state-transition timeline and requested agent actions, ordered from oldest to newest. Timeline entries include timestamps and failure reasons when available. The response indicates when the action list is truncated; actions are limited to 200.
  • Documentation
    • Documented the deployment timeline endpoint, its response fields, ordering, action limit, and that timeline steps depend on available audit events.

@samuelmbabhazi samuelmbabhazi added track:control-plane v0.1-stable In the scope of the first stable version (docs/PLAN.md) labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds a deployment timeline API that returns audited state transitions and safe agent-action summaries. The response includes timestamps and a truncation flag. The endpoint applies access checks and validates deployment lookup. An organization binding test resets identity throttling before an incorrect-password check.

Changes: Deployment timeline

Layer / File(s) Summary
Map and read deployment state steps
apps/api/src/modules/deployments/domain/timeline.ts, apps/api/src/modules/deployments/domain/timeline.spec.ts, apps/api/src/modules/deployments/application/ports.ts, apps/api/src/modules/deployments/infrastructure/prisma-deployment-steps.store.ts, apps/api/src/modules/deployments/deployments.module.ts
Defines audited event and step shapes, maps recognized events to state transitions, limits failure reasons to 512 characters, reads ordered audit events, and registers the store.
Read deployment agent actions
apps/api/src/modules/fleet/application/ports.ts, apps/api/src/modules/deployments/application/ports.ts, apps/api/src/modules/fleet/application/agent-actions.ts, apps/api/src/modules/fleet/infrastructure/prisma-agent-action.store.ts
Adds deployment-scoped action history with a limit of 200 and a shared projection and mapper that omit encrypted payloads.
Compose and expose the timeline
apps/api/src/modules/deployments/application/deployment-commands.ts, apps/api/src/modules/deployments/interface/deployment.dto.ts, apps/api/src/modules/deployments/interface/deployment.controller.ts, apps/api/src/modules/deployments/deployment-timeline-http.integration.spec.ts, docs/SPEC.md
Combines steps with up to 200 actions, reports whether more actions exist, adds the protected timeline route, and documents and tests the response and lookup behavior.

Identity throttling test adjustment

Layer / File(s) Summary
Reset throttling before password check
apps/api/src/modules/organizations/binding-http.integration.spec.ts
Resets identity throttling after earlier rejection requests and before checking an incorrect password.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant DeploymentController
  participant DeploymentCommands
  participant DeploymentStepStore
  participant ActionHistory
  Client->>DeploymentController: GET deployment timeline
  DeploymentController->>DeploymentCommands: timeline(context, target, applicationId, deploymentId)
  par Read audit steps
    DeploymentCommands->>DeploymentStepStore: events(organizationId, deploymentId, limit)
  and Read action history
    DeploymentCommands->>ActionHistory: forDeployment(organizationId, deploymentId, limit)
  end
  DeploymentCommands->>DeploymentController: steps, actions, truncated
  DeploymentController->>Client: mapped timeline response
Loading

Possibly related issues

  • Issue 265 — The timeline returns audited state transitions and timestamps, but does not include build or release logs requested by the issue.

Possibly related PRs

  • shipkeepdev/shipkeep#291 — Adds deployment links and safe action summaries used by the deployment-scoped action history.
Merge Risk: Minimal · up to f9963

This adds a read-only deployment timeline endpoint with access checks and bounded results, plus a test-only throttle reset. No actionable merge-blocking risk was identified.

Security architecture risk: Minimal · up to 18c96

The timeline is a bounded read using the existing deployment permissions and tenant/application checks. The inspected change does not add agent execution authority or alter deployment state, and no introduced or worsened security issue was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected endpoint's data exposure is limited to the selected deployment within an authorized application/environment. Both history queries explicitly filter by organization and deployment identity, and the new path only reads history rather than enqueueing agent work or acquiring execution privileges.

Trust Boundaries and Controls

  • observed — The timeline declares the same environment.read tenant permission and explicit bearer-token opt-in as the existing deployment GET. The identity guard authenticates sessions or bearer credentials; bearer access requires matching route/token permission metadata and passes the route target to token authentication. The command preserves authenticated credential context and repeats the scoped authorization path.
  • observed — Audit reads select only action, metadata and timestamp, excluding actor and address columns. Action-history reads exclude payload ciphertext; actionView removes raw error and result fields and replaces them with allowlisted reason codes and validated result summaries before DTO serialization.

Resilience and Maintainability Implications

  • observed — The nested action-history tenant scope joins the same organization's transaction. The existing unit-of-work rejects conflicting scope identities or leases, clears transaction-local context after success, and fails the command if cleanup fails rather than retaining a scope.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(api): a deployment's timeline, its steps and agent actions (part of #265)" matches the main change. The changeset adds a GET deployment timeline endpoint that returns deployment steps …
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.
Full details: Title check

Explanation

The title "feat(api): a deployment's timeline, its steps and agent actions (part of #265)" matches the main change. The changeset adds a GET deployment timeline endpoint that returns deployment steps built from audit-log state changes and up to 200 agent-action summaries. The title names the endpoint's content accurately. It is concise and specific, and it does not use vague terms. The "(part of #265)" suffix refers to a related tracking issue and adds no content about the change, but it does not make the title misleading.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 58b454d and f99630d.

Files selected for processing: 1

  • apps/api/src/modules/organizations/binding-http.integration.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@samuelmbabhazi
samuelmbabhazi merged commit d74810a into main Nov 22, 2026
24 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/265-deployment-timeline branch November 22, 2026 12:27
samuelmbabhazi added a commit that referenced this pull request Nov 22, 2026
) (#419)

Closes #265 (step 2 of #413). The API it reads was merged in #418.

## What changed

Screen 15 of the design, built on real data. It replaces the preview at
`/deployments/sample`; the preview screen and its sample data are
removed.

**`…/applications/:applicationId/deployments/:deploymentId`
(`delivery/deployment-page.ts`)**
- **Header:**
- the deployment's release number ("Deployment #3"), as the agent
actions already name it, or the start of the release id when that
release is not among the 50 most recent;
  - the status and the elapsed time;
  - the application, environment, image, trigger and who started it;
  - a link back to the application's Deployments tab.
- **Step durations:** queued, build, release command, placement,
starting, health check, switchover, draining, each with the time it
began. The step a deployment failed in reads red, the running one blue.
- **Timeline:** the audited steps and the agent actions merged by time,
with the server, the result and the failure cause (the cause in red).
- **While it runs:** the page reads the deployment again every 3
seconds, as the application page does, and stops once it has finished.
- **Said plainly:** build output and the release command's output arrive
with builds and log collection (M3.3, M6.1). It never shows sample
lines.
- **Not found:** an unknown deployment, or one read under another
application, shows "Deployment not found".

**`delivery/deployment-view.ts`**
- A pure function from the deployment and its timeline to what the page
shows.
- Durations come in whole units ("< 1 s", "14 s", "2 min"), so there is
no decimal mark to translate.

**Application page**
- In the Deployments tab, each deployment's version opens its page, and
the current deployment's card has a "Details" button.
- Deployments are named by their release number everywhere on that page
(the list, the current deployment's card, "Roll back to #2", "Start
#3"), as the agent actions and the new page already were. It falls back
to the start of the release id for a release older than the 50 listed.
The maintainer asked for it while validating.

**French**
- The new texts are translated.
- Step labels are nouns ("Démarrage", "Drainage") rather than the
existing verb keys.

## Size

About 900 added lines, over the 500 we aim for. About 400 of them are
tests, and the rest is one screen. It stays together because the page,
its view model and the links into it make sense only as a whole.

## How it was tested

- **Unit:**
- `deployment-view.spec.ts`: durations, the failed and running step
colours, steps and actions merged with steps first at the same instant,
a stop, whole-unit durations.
  - `deployment-page.spec.ts`, through the real router:
    - the content and the back link;
- a running deployment followed until it finishes, read twice, then no
more;
    - French;
    - "Deployment not found";
    - the link from the application page;
- the trail naming the project once the shell loads it after the title.
This test fails without the fix.
  - Web suite: green. Lint and typecheck green.
- **Browser** (`tenant.browser.spec.ts`, production build and CSP): the
page opens from its application's Deployments tab, shows its timeline,
passes axe and has no CSP problem. 12 tests passed.
- **Lab** (a real agent): captures on desktop in English and mobile in
French, next to the mockup, of a succeeded deployment and of one made to
fail its health check. No horizontal overflow, and no failed API call
after sign-in.

## Security considerations

- Read-only: it uses the routes of #418 (`environment.read`) and the
existing deployment, release and application reads.
- No new write and no new audit event.
- No inline style, so the strict CSP is unchanged; the browser test runs
under it.
- Names typed by people (application, project, environment) are never
translated.
- Failure reasons come from the API and are already capped at 512
characters.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added deployment detail pages with status, elapsed time, release
information, statistics, and a chronological activity timeline.
* Added links from deployment listings to their detail pages, with
clearer release-number labels.
* Deployment details update while a deployment is in progress and show
loading, unavailable, or error states.
* Added French translations for deployment details, statuses, timeline
entries, and related messages.

* **Tests**
* Added browser and component coverage for deployment navigation, status
updates, timelines, and error states.

* **Removed**
  * Removed the sample deployment preview screen and route.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: samuel mbabhazi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

track:control-plane v0.1-stable In the scope of the first stable version (docs/PLAN.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant