Skip to content

Commit 1c1b062

Browse files
authored
fix: add resolution path (#4215)
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 01f5fee commit 1c1b062

6 files changed

Lines changed: 66 additions & 13 deletions

File tree

backend/src/api/public/v1/packages/getPackage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
9494
status: (pkg.stewardshipStatus ?? 'unassigned') as StewardshipStatus,
9595
stewards: stewardshipSummary?.stewards ?? null,
9696
lastActivityAt: stewardshipSummary?.lastActivityAt ?? null,
97+
resolutionPath: pkg.stewardshipResolutionPath ?? null,
98+
statusNote: pkg.stewardshipStatusNote ?? null,
9799
},
98100
history: {},
99101
})

backend/src/api/public/v1/packages/openapi.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,17 @@ components:
8585

8686
Steward:
8787
type: object
88-
required: [userId, name, role, assignedAt]
88+
required: [userId, role, assignedAt]
8989
properties:
9090
userId:
9191
type: string
92-
description: LFID.
93-
example: jdoe
92+
description: Auth0 sub of the assigned steward.
93+
example: abc123
9494
name:
95-
type: string
95+
type:
96+
- string
97+
- 'null'
98+
description: Display name of the steward. Null if not available.
9699
example: Jonathan R.
97100
role:
98101
type: string
@@ -424,7 +427,7 @@ components:
424427
- 'null'
425428
stewardship:
426429
type: object
427-
description: Stewardship state. In v1 always unassigned with no stewards or activity.
430+
description: Stewardship state.
428431
properties:
429432
id:
430433
type:
@@ -435,7 +438,7 @@ components:
435438
status:
436439
$ref: '#/components/schemas/StewardshipStatus'
437440
stewards:
438-
description: Assigned stewards or null. Null in v1.
441+
description: Assigned stewards or null.
439442
oneOf:
440443
- type: array
441444
items:
@@ -446,7 +449,16 @@ components:
446449
- string
447450
- 'null'
448451
format: date-time
449-
description: Null in v1.
452+
resolutionPath:
453+
type:
454+
- string
455+
- 'null'
456+
description: Set on `escalated` status. Null for all other statuses.
457+
statusNote:
458+
type:
459+
- string
460+
- 'null'
461+
description: Free-text note for the current status.
450462
history:
451463
type: object
452464
description: Package history data. Empty in v1.

backend/src/api/public/v1/stewardships/openapi.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ components:
9494
- stepped_down
9595
- no_longer_critical
9696
- 'null'
97+
resolutionPath:
98+
description: Set on `escalated` status. Null for all other statuses.
99+
oneOf:
100+
- $ref: '#/components/schemas/EscalationResolutionPath'
101+
- type: 'null'
102+
statusNote:
103+
type:
104+
- string
105+
- 'null'
106+
description: Free-text note for the current status. Set by escalate or updateStatus. Null on open.
107+
example: Contacted maintainer, no response after 30 days.
97108
createdAt:
98109
type: string
99110
format: date-time
@@ -115,6 +126,12 @@ components:
115126
type: string
116127
description: Auth0 sub of the assigned steward.
117128
example: abc123
129+
name:
130+
type:
131+
- string
132+
- 'null'
133+
description: Display name of the steward. Null if not available.
134+
example: Jonathan R.
118135
role:
119136
type: string
120137
enum: [lead, co_steward]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE stewardships
2+
ADD COLUMN IF NOT EXISTS resolution_path TEXT,
3+
ADD COLUMN IF NOT EXISTS status_note TEXT;

services/libs/data-access-layer/src/osspckgs/api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ export interface PackageDetailRow {
278278
stewardshipId: string | null
279279
stewardshipStatus: string | null
280280
stewardshipLastStatusAt: Date | null
281+
stewardshipResolutionPath: string | null
282+
stewardshipStatusNote: string | null
281283
// from package_repos + repos
282284
repoUrl: string | null
283285
repoMappingConfidence: number | null
@@ -321,6 +323,8 @@ export async function getPackageDetailByPurl(
321323
s.id::text AS "stewardshipId",
322324
s.status AS "stewardshipStatus",
323325
s.last_status_at AS "stewardshipLastStatusAt",
326+
s.resolution_path AS "stewardshipResolutionPath",
327+
s.status_note AS "stewardshipStatusNote",
324328
-- best repo link (highest confidence, prefer declared)
325329
r.url AS "repoUrl",
326330
pr.confidence AS "repoMappingConfidence",

services/libs/data-access-layer/src/osspckgs/stewardships.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface StewardshipRecord {
99
openedAt: string | null
1010
lastStatusAt: string | null
1111
inactiveReason: string | null
12+
resolutionPath: string | null
13+
statusNote: string | null
1214
createdAt: string
1315
updatedAt: string
1416
}
@@ -17,6 +19,7 @@ export interface StewardshipStewardRecord {
1719
id: string
1820
stewardshipId: string
1921
userId: string
22+
name: string | null
2023
role: string
2124
assignedAt: string
2225
assignedBy: string | null
@@ -89,6 +92,7 @@ function mapStewardStewardRow(row: Record<string, unknown>): StewardshipStewardR
8992
id: String(row.id),
9093
stewardshipId: String(row.stewardship_id),
9194
userId: String(row.user_id),
95+
name: null,
9296
role: String(row.role),
9397
assignedAt: toIso(row.assigned_at),
9498
assignedBy: row.assigned_by ? String(row.assigned_by) : null,
@@ -105,6 +109,8 @@ function mapStewardshipRow(row: Record<string, unknown>): StewardshipRecord {
105109
openedAt: row.opened_at ? toIso(row.opened_at) : null,
106110
lastStatusAt: row.last_status_at ? toIso(row.last_status_at) : null,
107111
inactiveReason: row.inactive_reason ? String(row.inactive_reason) : null,
112+
resolutionPath: row.resolution_path ? String(row.resolution_path) : null,
113+
statusNote: row.status_note ? String(row.status_note) : null,
108114
createdAt: toIso(row.created_at),
109115
updatedAt: toIso(row.updated_at),
110116
}
@@ -116,7 +122,7 @@ export async function getStewardshipById(
116122
): Promise<StewardshipRecord | null> {
117123
const row: Record<string, unknown> | null = await qx.selectOneOrNone(
118124
`SELECT id, package_id, status, origin, version, opened_at, last_status_at,
119-
inactive_reason, created_at, updated_at
125+
inactive_reason, resolution_path, status_note, created_at, updated_at
120126
FROM stewardships
121127
WHERE id = $(id)`,
122128
{ id },
@@ -151,12 +157,14 @@ export async function openStewardshipByPurl(
151157
FROM pkg
152158
ON CONFLICT (package_id) DO UPDATE
153159
SET status = 'open',
154-
opened_at = COALESCE(stewardships.opened_at, NOW()),
160+
opened_at = NOW(),
155161
last_status_at = NOW(),
156162
inactive_reason = NULL,
163+
resolution_path = NULL,
164+
status_note = NULL,
157165
updated_at = NOW()
158166
RETURNING id, package_id, status, origin, version, opened_at,
159-
last_status_at, inactive_reason, created_at, updated_at
167+
last_status_at, inactive_reason, resolution_path, status_note, created_at, updated_at
160168
),
161169
_log AS (
162170
INSERT INTO stewardship_activity (stewardship_id, actor_user_id, actor_type, activity_type, content)
@@ -319,10 +327,12 @@ export async function escalateStewardship(
319327
SET status = 'escalated',
320328
last_status_at = NOW(),
321329
inactive_reason = NULL,
330+
resolution_path = $(resolutionPath),
331+
status_note = $(statusNote),
322332
updated_at = NOW()
323333
WHERE id = $(stewardshipId)
324334
RETURNING id, package_id, status, origin, version, opened_at,
325-
last_status_at, inactive_reason, created_at, updated_at
335+
last_status_at, inactive_reason, resolution_path, status_note, created_at, updated_at
326336
),
327337
_log AS (
328338
INSERT INTO stewardship_activity
@@ -335,6 +345,8 @@ export async function escalateStewardship(
335345
`,
336346
{
337347
stewardshipId,
348+
resolutionPath: data.resolutionPath,
349+
statusNote: data.notes ?? null,
338350
actorUserId: data.actorUserId,
339351
content: `Escalated with resolution path: ${data.resolutionPath}`,
340352
metadata: JSON.stringify({
@@ -384,11 +396,13 @@ export async function updateStewardshipStatus(
384396
UPDATE stewardships
385397
SET status = $(status),
386398
last_status_at = NOW(),
387-
inactive_reason = CASE WHEN $(status) = 'inactive' THEN $(inactiveReason) ELSE NULL END,
399+
inactive_reason = CASE WHEN $(status) = 'inactive' THEN $(inactiveReason) ELSE inactive_reason END,
400+
resolution_path = NULL,
401+
status_note = $(statusNote),
388402
updated_at = NOW()
389403
WHERE id = $(stewardshipId)
390404
RETURNING id, package_id, status, origin, version, opened_at,
391-
last_status_at, inactive_reason, created_at, updated_at
405+
last_status_at, inactive_reason, resolution_path, status_note, created_at, updated_at
392406
),
393407
_log AS (
394408
INSERT INTO stewardship_activity
@@ -403,6 +417,7 @@ export async function updateStewardshipStatus(
403417
stewardshipId,
404418
status: data.status,
405419
inactiveReason: data.inactiveReason ?? null,
420+
statusNote: data.notes ?? null,
406421
actorUserId: data.actorUserId,
407422
content: `Status updated to ${data.status}`,
408423
metadata: JSON.stringify({

0 commit comments

Comments
 (0)