Skip to content

feat(sequence-diagram): carry AppMap labels on diagram actions#2369

Open
kgilpin wants to merge 1 commit into
mainfrom
feat/sequence-diagram-labels
Open

feat(sequence-diagram): carry AppMap labels on diagram actions#2369
kgilpin wants to merge 1 commit into
mainfrom
feat/sequence-diagram-labels

Conversation

@kgilpin

@kgilpin kgilpin commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

What

Each diagram action (function call, HTTP server/client RPC, SQL query) now records the AppMap labels applied to its callee code object, as a sorted labels?: string[] field — omitted when empty.

// buildDiagram.ts, every callee-based branch
labels: labelsOf(callee),   // [...event.codeObject.labels].sort(), or undefined

Why

Labels live only in the raw AppMap classMap and were dropped on sequence-diagram export. Consumers that wanted them (notably the gold-traces behavioral-diff work, which raises the severity of a detected change when the changed node is security-labeled) had to re-join the diagram against the raw AppMap. This makes the exported diagram self-contained: one source of truth for the analysis.

Design notes

  • Not in the digest. labels is not folded into digest/subtreeDigest (those derive from buildStableHash/stableProperties). A pure re-label is therefore not a behavioral change — labels are a classification signal, not a behavioral one.
  • No formatter change. formatter/json.ts serializes the whole diagram, so labels flows into --format json automatically. Text/PlantUML are unchanged (could annotate labeled calls later if desired).
  • All message types. Applied to ServerRPC / ClientRPC / Query / FunctionCall — anything with a callee code object.

Testing

  • yarn test — 40 passed (3 new: label reported on a labeled action, undefined on an unlabeled one, and labels excluded from the digest).
  • yarn lint — 0 errors.
  • End-to-end against a real Python (Strawberry/SQLAlchemy) AppMap: security-labeled resolvers surface their labels in sequence-diagram --format json:
    _claim_player  => ["security.authorization","security.join_code"]
    _game_by_code  => ["security.authorization","security.join_code"]
    

🤖 Generated with Claude Code

Each function/RPC/query action now records the AppMap labels applied to its
callee code object (sorted, omitted when empty), so consumers can read labels
straight from the exported sequence diagram instead of re-joining against the
raw AppMap classMap.

Labels are not folded into `digest`/`subtreeDigest`, so a pure re-label is not
treated as a behavioral change — labels are a classification signal, not a
behavioral one. The JSON formatter serializes the whole diagram, so the new
field flows into `--format json` output with no formatter change.

Motivated by the gold-traces behavioral-diff work, which classifies the
severity of a detected change by whether the changed node is security-labeled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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