Skip to content

feat: add actor interface#4255

Merged
ulemons merged 3 commits into
mainfrom
feat/add-activity-user-metainfo
Jun 23, 2026
Merged

feat: add actor interface#4255
ulemons merged 3 commits into
mainfrom
feat/add-activity-user-metainfo

Conversation

@ulemons

@ulemons ulemons commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Stores a snapshot of the acting user's profile on every stewardship activity log entry. Every write action now accepts an actor object in the request body; the server validates it, persists username, display_name, and avatar_url alongside the existing actor_user_id, and returns a nested actor object on all activity fetch endpoints.

Changes

  • Migration — adds 3 nullable TEXT columns to stewardship_activity: actor_username, actor_display_name, actor_avatar_url
  • DAL — all write functions (openStewardshipByPurl, assignSteward, escalateStewardship, updateStewardshipStatus) accept and INSERT the new actor fields; all read functions (listStewardshipActivity, listMyActivity, listPackageHistory) SELECT and map them into a nested actor: ActivityActor object instead of the flat actorUserId field
  • API handlers — all 4 action endpoints require actor in the request body; actor.userId is validated against req.actor.id from JWT (mismatch returns 400); username, displayName, avatarUrl are forwarded to the DAL
  • Shared schema — actor Zod schema extracted to actorSchema.ts instead of copy-pasted across 4 handlers
  • OpenAPI — added ActivityActor (response) and ActorInput (request) component schemas; all action requestBody and activity feed responses updated
  • Fix — listMyPackages was calling translateActivityContent twice per row (for both lastActivityContent and lastActivityDescription); now only lastActivityDescription is translated; lastActivityContent returns the raw DB value

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Performance improvement
  • Chore / dependency update
  • Documentation

Note

Medium Risk
Breaking request/response shapes and documented route/method changes for stewardship clients; core auth still comes from the JWT while new profile fields are client-supplied snapshots on the activity log.

Overview
Stewardship activity responses no longer expose flat actorUserId (and the placeholder actorName); they return a nested actor object (userId, username, displayName, avatarUrl) built from new snapshot columns on stewardship_activity.

Write APIs now require an actor object in the JSON body (shared actorInputSchema: optional username, display name, avatar URL). Handlers still record the authenticated user via req.actor.id as actor_user_id and pass the optional display fields into the DAL. Assign steward reshapes the body: steward fields move under steward, with actor separate. OpenAPI documents ActivityActor / ActorInput, updates server base paths to include /akrites, and adjusts routes/methods (e.g. open → POST /stewardships/open, assign → POST …/assign, status → PATCH …/status).

The DAL migration adds nullable actor_username, actor_display_name, and actor_avatar_url; all stewardship mutations that insert activity rows persist them. My packages exposes lastActivityDescription from the DAL (single translateActivityContent pass) instead of translating again in the handler.

Small refactor: buildHealthBandCondition centralizes health-band SQL used by listMyPackages.

Reviewed by Cursor Bugbot for commit 938ad46. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons ulemons self-assigned this Jun 23, 2026
Copilot AI review requested due to automatic review settings June 23, 2026 13:31
@ulemons ulemons added the Feature Created by Linear-GitHub Sync label Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an “actor” interface to stewardship activity logging so each activity row can persist a snapshot of the acting user’s profile (username/displayName/avatarUrl) and activity read endpoints can return a nested actor object rather than only actorUserId.

Changes:

  • Database migration adds actor_username, actor_display_name, actor_avatar_url to stewardship_activity.
  • Data-access-layer updates stewardship write paths to persist actor snapshot fields and updates activity read paths to return a nested actor object.
  • Public API write handlers now require actor in the request body and validate actor.userId against the authenticated user id; some handlers/feeds now include the nested actor in responses.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
services/libs/data-access-layer/src/osspckgs/stewardships.ts Persists actor snapshot fields on activity inserts; maps activity reads to nested actor; adjusts my-packages translation behavior.
services/libs/data-access-layer/src/osspckgs/api.ts Adds buildHealthBandCondition helper and reuses it from stewardship queries.
backend/src/osspckgs/migrations/V1781700000__stewardship-activity-actor-display.sql Adds nullable actor snapshot columns to stewardship_activity.
backend/src/api/public/v1/stewardships/updateStatus.ts Requires actor input, validates against JWT actor id, forwards snapshot fields to DAL.
backend/src/api/public/v1/stewardships/openStewardship.ts Requires actor input, validates against JWT actor id, forwards snapshot fields to DAL.
backend/src/api/public/v1/stewardships/openapi.yaml Introduces ActorInput/ActivityActor schemas and updates action request bodies (but currently has contract mismatches noted in comments).
backend/src/api/public/v1/stewardships/getMyPackages.ts Uses DAL-provided lastActivityDescription (removes double-translation).
backend/src/api/public/v1/stewardships/getMyActivity.ts Adds actor to response items.
backend/src/api/public/v1/stewardships/escalate.ts Requires actor input, validates against JWT actor id, forwards snapshot fields to DAL.
backend/src/api/public/v1/stewardships/assignSteward.ts Requires actor input, validates against JWT actor id, forwards snapshot fields to DAL.
backend/src/api/public/v1/stewardships/actorSchema.ts Extracts shared actorInputSchema for request validation.
backend/src/api/public/v1/ossprey/activityFeed.ts Returns nested actor in activity feed response items.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/ossprey/activityFeed.ts
Comment thread backend/src/api/public/v1/stewardships/getMyActivity.ts
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Comment thread backend/src/api/public/v1/stewardships/assignSteward.ts
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings June 23, 2026 16:02

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 938ad46. Configure here.

Comment thread backend/src/api/public/v1/stewardships/actorSchema.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comment thread backend/src/api/public/v1/stewardships/actorSchema.ts
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
Comment thread backend/src/api/public/v1/stewardships/openapi.yaml
@ulemons ulemons merged commit b11748e into main Jun 23, 2026
17 checks passed
@ulemons ulemons deleted the feat/add-activity-user-metainfo branch June 23, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants