Skip to content

feat(sequence): derive and draw activation bars - #376

Merged
graphite-app[bot] merged 1 commit into
mainfrom
feat/sequence-activations
Oct 11, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
feat/sequence-activations

Conversation

@anandpant

@anandpant anandpant commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

  • sequenceActivations (diagram-core) derives activation spans from message order. A return answers the latest open call between the two participants, a call to a participant that is already active nests at the next depth, and calls nobody answers (fire-and-forget) open no span. The model authors nothing new; the spans are deterministic from the existing contract.
  • The sequence renderer draws each span as a sequence-activation bar on the callee's lifeline, offset half a bar per nesting level. Calls, returns, and messages sent while a participant is active attach to the edge of its innermost bar; otherwise they stay on the lifeline. Bar ids live under <participant>:lifeline:activation:<call id>, and core validation now reserves every id under a participant's lifeline.
  • CanvasRendererRole covers lifelines and activation bars together. Neither carries labels or icons, and Excalidraw validation lets messages cross either. Excalidraw export tags bars with customData.sketchiRendererRole.
  • Code Mode keeps the activation role through patches only while the bar still sits on its lifeline (isStructurallyValidSequenceActivation). The MCP canvas contract and the generated docs types list the new role, and the buildSequenceDiagram docs and generation prompt explain that returns close calls.

Why

#280 requires that sequence semantics, including activation and lifelines, are kept rather than flattened. Before this, nothing modeled activations and every message attached to a bare lifeline.

Verification

  • pnpm nx affected -t typecheck,test --base=origin/main (18 projects)
  • New tests: span derivation (answered, nested, fire-and-forget, stray return), bar geometry and attachment, a valid Excalidraw export with messages crossing other participants' bars, Code Mode patch round-trip
  • MCP generated types refreshed. Storybook Diagram Types/Sequence checked in Chrome. Screenshot: bars on API Worker, Cache, and Database, with no bar for the fire-and-forget analytics call.

Refs #280

Review follow-ups

  • Bars nested two or more levels deep keep sequence-activation through Code Mode patches. The structural check accepts whole nesting steps, up to the number of bars on that lifeline, and still rejects a bar moved off it. Tests cover a depth-2 renderer case and a Code Mode patch round-trip.
  • Answering one call no longer closes other open calls on the same lifeline. Depth counts the spans still open when a span starts, so partially overlapping spans stack instead of overlapping. A test covers a→b q1, c→b q2, b→a p1, b→c p2.
  • Behavior change: a participant id that starts with another participant id followed by :lifeline (for example api:lifeline:v2 next to api) is now rejected, because bars live under that prefix. The hint reads "...does not start with another participant id followed by :lifeline." This is noted in the changeset.
  • Free lanes: each span takes the lowest depth no still-open span on its lifeline holds, above every span enclosing it. Partially overlapping spans (q1 0..2, q2 1..4, q3 3..5) no longer draw on top of each other. A message attaches to the bar of the span it opens or closes. Tests: the q1/q2/q3 case, its rendering, and a property check over 500 seeded random diagrams.

anandpant commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • fast - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment thread packages/diagram/renderer/src/sequence.ts
@anandpant
anandpant force-pushed the feat/sequence-activations branch from be34ec4 to 664fc62 Compare October 10, 2026 22:11
@anandpant
anandpant force-pushed the feat/sequence-one-contract branch from 3bdf75b to 518ebb0 Compare October 10, 2026 22:11
@anandpant
anandpant marked this pull request as ready for review October 10, 2026 22:12
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread packages/diagram/core/src/types/sequence.ts Outdated
@graphite-app

graphite-app Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Merge activity

## What changed

- `sequenceActivations` (diagram-core) derives activation spans from message order. A `return` answers the latest open call between the two participants, a call to a participant that is already active nests at the next depth, and calls nobody answers (fire-and-forget) open no span. The model authors nothing new; the spans are deterministic from the existing contract.
- The sequence renderer draws each span as a `sequence-activation` bar on the callee's lifeline, offset half a bar per nesting level. Calls, returns, and messages sent while a participant is active attach to the edge of its innermost bar; otherwise they stay on the lifeline. Bar ids live under `<participant>:lifeline:activation:<call id>`, and core validation now reserves every id under a participant's lifeline.
- `CanvasRendererRole` covers lifelines and activation bars together. Neither carries labels or icons, and Excalidraw validation lets messages cross either. Excalidraw export tags bars with `customData.sketchiRendererRole`.
- Code Mode keeps the activation role through patches only while the bar still sits on its lifeline (`isStructurallyValidSequenceActivation`). The MCP canvas contract and the generated docs types list the new role, and the `buildSequenceDiagram` docs and generation prompt explain that returns close calls.

## Why

#280 requires that sequence semantics, including activation and lifelines, are kept rather than flattened. Before this, nothing modeled activations and every message attached to a bare lifeline.

## Verification

- `pnpm nx affected -t typecheck,test --base=origin/main` (18 projects)
- New tests: span derivation (answered, nested, fire-and-forget, stray return), bar geometry and attachment, a valid Excalidraw export with messages crossing other participants' bars, Code Mode patch round-trip
- MCP generated types refreshed. Storybook `Diagram Types/Sequence` checked in Chrome. Screenshot: bars on API Worker, Cache, and Database, with no bar for the fire-and-forget analytics call.

Refs #280

## Review follow-ups

- Bars nested two or more levels deep keep `sequence-activation` through Code Mode patches. The structural check accepts whole nesting steps, up to the number of bars on that lifeline, and still rejects a bar moved off it. Tests cover a depth-2 renderer case and a Code Mode patch round-trip.
- Answering one call no longer closes other open calls on the same lifeline. Depth counts the spans still open when a span starts, so partially overlapping spans stack instead of overlapping. A test covers `a→b q1, c→b q2, b→a p1, b→c p2`.
- **Behavior change:** a participant id that starts with another participant id followed by `:lifeline` (for example `api:lifeline:v2` next to `api`) is now rejected, because bars live under that prefix. The hint reads "...does not start with another participant id followed by :lifeline." This is noted in the changeset.
- **Free lanes:** each span takes the lowest depth no still-open span on its lifeline holds, above every span enclosing it. Partially overlapping spans (q1 0..2, q2 1..4, q3 3..5) no longer draw on top of each other. A message attaches to the bar of the span it opens or closes. Tests: the q1/q2/q3 case, its rendering, and a property check over 500 seeded random diagrams.
@graphite-app
graphite-app Bot force-pushed the feat/sequence-one-contract branch from 97f5817 to 4d3079f Compare October 11, 2026 01:48
@graphite-app
graphite-app Bot force-pushed the feat/sequence-activations branch from de73f7e to 49c0292 Compare October 11, 2026 01:49
Base automatically changed from feat/sequence-one-contract to main October 11, 2026 01:53
@graphite-app
graphite-app Bot merged commit 49c0292 into main Oct 11, 2026
4 checks passed
@graphite-app
graphite-app Bot deployed to production October 11, 2026 01:53 Active
@graphite-app
graphite-app Bot deployed to production October 11, 2026 01:53 Active
@graphite-app
graphite-app Bot deployed to production October 11, 2026 01:53 Active
@graphite-app
graphite-app Bot deployed to production October 11, 2026 01:53 Active
@graphite-app
graphite-app Bot deployed to production October 11, 2026 01:53 Active
@graphite-app
graphite-app Bot deleted the feat/sequence-activations branch October 11, 2026 01:53
@github-actions

Copy link
Copy Markdown
Contributor

Sketchi Excalidraw Workspace Preview

Status: deleted

@github-actions

Copy link
Copy Markdown
Contributor

Sketchi Eval Harness Preview

Status: deleted

@github-actions

Copy link
Copy Markdown
Contributor

Sketchi Web Preview

Status: deleted

@github-actions

Copy link
Copy Markdown
Contributor

Sketchi Icons Preview

Status: deleted

@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Sketchi Playground / Studio Preview

Status: deleted

This branch was successfully deployed

2 active deployments
staging — 49c02920 Deployed Oct 11, 2026 by graphite-app[bot] via cleanup-preview (playground) #443
production — 49c02920 Deployed Oct 11, 2026 by graphite-app[bot] via deploy (eval-harness) #122
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