Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkgs/fleet/crates/fleet-queue/src/needs_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! [`ALERTS_INTAKE_TOKEN_SECRET`], resolved by name through
//! fleet-secrets — never read from a file here)
//! {"source": "fleet-queue",
//! "key": "needs-drew:<ledgerId>",
//! "key": "needs-user:<ledgerId>",
//! "severity": "warning",
//! "title": <question>,
//! "body": <context or blocker text>,
Expand Down Expand Up @@ -96,7 +96,7 @@ pub fn build_throat_body(block: &BlockNeedsUser) -> Value {
let body = block.context.as_deref().unwrap_or(&block.blocker);
json!({
"source": "fleet-queue",
"key": format!("needs-drew:{}", block.ledger_id),
"key": format!("needs-user:{}", block.ledger_id),
"severity": "warning",
"title": block.question,
"body": body,
Expand Down Expand Up @@ -489,7 +489,7 @@ mod tests {
body,
json!({
"source": "fleet-queue",
"key": "needs-drew:ledger-42",
"key": "needs-user:ledger-42",
"severity": "warning",
"title": "Ship the red or the blue build?",
"body": "Both pass CI; blue is 2 days older.",
Expand Down Expand Up @@ -518,7 +518,7 @@ mod tests {
blocker: "blocked on Drew".to_string(),
};
let body = build_throat_body(&block);
assert_eq!(body["key"], json!("needs-drew:99"));
assert_eq!(body["key"], json!("needs-user:99"));
assert_eq!(body["title"], json!("Proceed?"));
// No context: the blocker text is the alert body.
assert_eq!(body["body"], json!("blocked on Drew"));
Expand Down Expand Up @@ -574,7 +574,7 @@ mod tests {
assert_eq!(nd.links.len(), 1);
assert_eq!(nd.blocker, "waiting on Drew");
// And the throat body built from it carries the same key.
assert_eq!(build_throat_body(&nd)["key"], json!("needs-drew:ledger-7"));
assert_eq!(build_throat_body(&nd)["key"], json!("needs-user:ledger-7"));
}

#[test]
Expand Down
21 changes: 16 additions & 5 deletions pm-stack/aggregator/src/needs-drew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,22 @@ export async function getNeedsDrew(file: string, ledgerId: string): Promise<Need
}

/**
* The alert-incident key a needs-drew question's incident is posted under:
* the raiser (fleet-queue's needs_drew poster) posts the incident with key
* `needs-drew:<ledgerId>`, and the answer path closes the incident by this
* key (#8605). Pinned here so the convention has exactly one spelling.
* The alert-incident key a needs-user question's incident is posted under:
* the raiser (fleet-queue's needs_user poster) posts the incident with key
* `needs-user:<ledgerId>` since #13507 slice A3, and the answer path
* closes the incident by this key (#8605). Pinned here so the convention
* has exactly one current spelling.
*/
export function needsUserIncidentKey(ledgerId: string): string {
return `needs-user:${ledgerId}`;
}

/**
* The legacy incident-key spelling (`needs-drew:<ledgerId>`), used by
* the poster before #13507 slice A3. Incidents posted under it are
* still open in the store, so the answer path closes under both
* spellings during the alias window; this spelling is never posted
* anew.
*/
export function needsDrewIncidentKey(ledgerId: string): string {
return `needs-drew:${ledgerId}`;
Expand Down Expand Up @@ -814,5 +826,4 @@ export const raiseNeedsUser = raiseNeedsDrew;
export const needsUserAnswerHandle = needsDrewAnswerHandle;
export type NeedsUserBrokerResolution = NeedsDrewBrokerResolution;
export const getNeedsUser = getNeedsDrew;
export const needsUserIncidentKey = needsDrewIncidentKey;
export const listOpenNeedsUser = listOpenNeedsDrew;
4 changes: 2 additions & 2 deletions pm-stack/aggregator/src/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,13 @@ export function buildNotificationCandidates(snapshot: NotificationSnapshot, now
candidates.push(
candidate({
class: "needs-user",
objectRef: `needs-drew:${item.ledgerId}`,
objectRef: `needs-user:${item.ledgerId}`,
title: item.question,
body: item.context ?? "A fleet worker is blocked on your answer.",
url: `/answer/${encodeURIComponent(item.ledgerId)}`,
observedAt: item.raisedAt,
breakthrough: true,
actedRefs: [`needs-drew:${item.ledgerId}`],
actedRefs: [`needs-user:${item.ledgerId}`],
state: { raisedAt: item.raisedAt },
needsDrew: {
ledgerId: item.ledgerId,
Expand Down
6 changes: 5 additions & 1 deletion pm-stack/aggregator/src/server-decision-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getNeedsDrew,
listOpenNeedsDrew,
needsDrewIncidentKey,
needsUserIncidentKey,
recordAnswer,
type NeedsDrewQuestion,
} from "./needs-drew.ts";
Expand Down Expand Up @@ -77,7 +78,7 @@ import { alertsIntakeAuthorized } from "./server-alert-routes.ts";
*
* #8605: the answer resolves the question, so close its alert
* incident — the raiser posted it under this question's source with
* key needs-drew:<ledgerId>. #14084 S1: "Send back" returns the item
* key needs-user:<ledgerId> (needs-drew: before #13507 A3). #14084 S1: "Send back" returns the item
* to review; any other answer resolves it, keyed on the recorded
* (first) answer. */
export async function afterNeedsDrewAnswered(item: NeedsDrewQuestion, answered: NeedsDrewQuestion): Promise<void> {
Expand All @@ -92,6 +93,9 @@ export async function afterNeedsDrewAnswered(item: NeedsDrewQuestion, answered:
try {
const store = await getAlertsStore();
if (store) {
// #13507 A3: incidents posted since the prefix move carry the
// needs-user: key; older ones carry needs-drew:. Close both.
await store.closeOpenIncidentByKey(item.source, needsUserIncidentKey(item.ledgerId));
await store.closeOpenIncidentByKey(item.source, needsDrewIncidentKey(item.ledgerId));
requestAlertTick();
}
Expand Down
6 changes: 5 additions & 1 deletion pm-stack/aggregator/test/needs-user-aliases-13507.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ describe("needsUser aliases are the needsDrew originals", () => {
expect(raiseNeedsUser).toBe(drew.raiseNeedsDrew);
expect(needsUserAnswerHandle).toBe(drew.needsDrewAnswerHandle);
expect(getNeedsUser).toBe(drew.getNeedsDrew);
expect(needsUserIncidentKey).toBe(drew.needsDrewIncidentKey);
expect(listOpenNeedsUser).toBe(drew.listOpenNeedsDrew);
});

test("incident key: needsUser is the A3 spelling, needsDrew the legacy one", () => {
expect(needsUserIncidentKey("ledger-42")).toBe("needs-user:ledger-42");
expect(drew.needsDrewIncidentKey("ledger-42")).toBe("needs-drew:ledger-42");
});

test("an alias computes the same result as the original", () => {
expect(needsUserListUrl("developing-today/code", "user/review", 2)).toBe(
drew.needsDrewListUrl("developing-today/code", "user/review", 2),
Expand Down